Beefy Boxes and Bandwidth Generously Provided by pair Networks
No such thing as a small change
 
PerlMonks  

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

by sauoq (Abbot)
on Jun 19, 2003 at 19:34 UTC ( #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.";


Comment on Re: Re: Re: Re: Re: Scoping issues with code evaluation asserstions?
Download Code

Log In?
Username:
Password:

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

How do I use this? | Other CB clients
Other Users?
Others meditating upon the Monastery: (13)
As of 2014-12-29 16:15 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    Is guessing a good strategy for surviving in the IT business?





    Results (193 votes), past polls