Beefy Boxes and Bandwidth Generously Provided by pair Networks
laziness, impatience, and hubris
 
PerlMonks  

Re: Re: Re: Re: Re: Scoping issues with code evaluation asserstions?

by sauoq (Abbot)
on Jun 19, 2003 at 19:34 UTC ( [id://267322]=note: print w/replies, xml ) Need Help??


in reply to Re: Re: Re: Re: Scoping issues with code evaluation asserstions?
in thread Scoping issues with code evaluation asserstions?

I think that's a bit too clever. What if there is a global variable named $regex? You've just clobbered it. I think creating a local alias is probably better.

use strict; use warnings; sub regex { my $in = shift; my $ret = ''; # Assign something to $ret in a code assertion local *alias = \$ret; $in =~ m/^(a)(?{ $alias = 1})/; return $ret; } while(<DATA>) { print regex($_) . "."; } print "\n"; __DATA__ a b a abcd bcda
-sauoq
"My two cents aren't worth a dime.";

Log In?
Username:
Password:

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

How do I use this?Last hourOther CB clients
Other Users?
Others chanting in the Monastery: (5)
As of 2024-03-29 12:11 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found