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

Re^2: Extracting text from a line

by targetsmart (Curate)
on Jul 12, 2010 at 05:47 UTC ( #848925=note: print w/replies, xml ) Need Help??


in reply to Re: Extracting text from a line
in thread Extracting text from a line

print $fh $uid if $uid;

you meant to say
print $fh $1 if $uid;
I guess.

update almut was right
I thought it was scalar context, missed to notice that "(" ")" => "list context" ,my mistake :-).
Thanks to almut and pemungkah



Vivek
-- 'I' am not the body, 'I' am the 'soul/consciousness', which has no beginning or no end, no attachment or no aversion, nothing to attain or lose.

Replies are listed 'Best First'.
Re^3: Extracting text from a line
by almut (Canon) on Jul 12, 2010 at 07:28 UTC

    What's the difference, semantically?

    Note that in list context (my ($uid) = ...), the match operation returns the captures, so $uid holds the same value as $1.  If there is no match, both values are undef.

      Vivek, I strongly disagree with you here because of the fact that the number variables are very fragile: they are global to every pattern match.

      If someone else comes along and adds (for instance) a"harmless" subroutine call that sometimes does a pattern match of its own between the match and the usage of $1, then the results are unpredictable because the intervening match has reused the global variables.

      If you always capture the value in a separate variable immediately, you're safe from this potential bug.

Log In?
Username:
Password:

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://848925]
help
Chatterbox?
Lady_Aleena clean up after dinner finally.
[Discipulus]: uch! so we are twice lucky to have MCE..;=)
[marioroy]: Working a midnight graveyard shift, on the way home ran out of gas. just 2 minutes later somebody stops with a small tank of gas. It's wierd. There's always someone nearby for some reason.
[Lady_Aleena]: I was the one who stop[ed in the middle of a cold night to pick up a small family walking to a gas station. I got a few gallons of free gas for the round trip, and the grandmother said she'd pray for me.
[marioroy]: Folks do not know it, but MCE was ridiculously difficult. At Niagra Falls, heard a voice on enabling Grace while in the mist boat. That 10x performance is possible.
[marioroy]: Lady_Aleena Angels on earth are real people. That's awesome.
[Lady_Aleena]: marioroy, what does MCE stand for in this instance? There are 3 pages of abbreviations to go through.
[Lady_Aleena]: ^ or Discipulus...
[marioroy]: Many-core Engine
[choroba]: MCE

How do I use this? | Other CB clients
Other Users?
Others examining the Monastery: (12)
As of 2017-05-29 08:26 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?