Beefy Boxes and Bandwidth Generously Provided by pair Networks
Keep It Simple, Stupid
 
PerlMonks  

Re^3: HTML::Parser / Regex

by kcott (Archbishop)
on May 29, 2017 at 03:34 UTC ( [id://1191473]=note: print w/replies, xml ) Need Help??


in reply to Re^2: HTML::Parser / Regex
in thread HTML::Parser / Regex

"... the error "Can't use global $1 in "my"" ..."

Somewhere in your code, you have "... my $1 ...". Here's a couple of examples:

$ perl -e 'my $1;' Can't use global $1 in "my" at -e line 1, near "my $1" Execution of -e aborted due to compilation errors. $ perl -e 'my $1 = 42;' Can't use global $1 in "my" at -e line 1, near "my $1 " Execution of -e aborted due to compilation errors.

You can find the full description of the problem from "perldiag - Perl diagnostic messages". Until you're familiar with that document, it can be a bit difficult finding the information. In this instance, you'd need to search for "Can't use global" (not "Can't use global $1"). Doing so, locates this:

Can't use global %s in "%s"
(F) You tried to declare a magical variable as a lexical variable. This is not allowed, because the magic can be tied to only one location (namely the global variable) and it would be incredibly confusing to have variables in your program that looked like magical variables but weren't.

While you're learning, you may find it useful to use the diagnostics pragma. Put this line near the start of your code:

use diagnostics;

That will give you a full description, rather than the somewhat terse shortened form.

Important: That pragma is intended as a developer tool. Do not leave it production code.

— Ken

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: note [id://1191473]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others romping around the Monastery: (3)
As of 2024-04-20 11:00 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found