Beefy Boxes and Bandwidth Generously Provided by pair Networks
We don't bite newbies here... much
 
PerlMonks  

Re^2: search position is getting reset after 'local'

by ikegami (Patriarch)
on Jun 12, 2006 at 15:22 UTC ( [id://554830]=note: print w/replies, xml ) Need Help??


in reply to Re: search position is getting reset after 'local'
in thread search position is getting reset after 'local'

Re your update, here's a version that doesn't use use vars:

#!/usr/bin/perl -w use strict; our $x = "123 56"; $x =~ / /g; print "$x, ", pos($x), "\n"; { local $x } print "$x, ", pos($x), "\n";

I think you meant, "another reason to avoid using package variables".

By the way, I don't see how you got it to work with strict on. It doesn't work if you keep $x as a package variable, and local $x doesn't work if you changed $x into a lexical (i.e. used my $x).

Log In?
Username:
Password:

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

How do I use this?Last hourOther CB clients
Other Users?
Others taking refuge in the Monastery: (3)
As of 2024-04-19 21:29 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found