Beefy Boxes and Bandwidth Generously Provided by pair Networks
Come for the quick hacks, stay for the epiphanies.
 
PerlMonks  

Re: Why is this incorrect?

by rafl (Friar)
on Mar 17, 2006 at 02:18 UTC ( [id://537368]=note: print w/replies, xml ) Need Help??


in reply to Why is this incorrect?

$_ is a global.

Beside that to get the first parameter you passed to your subs you should use

my $line = lc $_[0]; # and $another_line = $_[0];

as it is the first element in the @_ array, which contains all arguments to the sub.

Beside that you should not use $ in sub names, you should not use & in function calls and you should use warnings.

Cheers, Flo

Replies are listed 'Best First'.
Re^2: Why is this incorrect?
by zer (Deacon) on Mar 17, 2006 at 05:09 UTC
    you can override the $_ for the subrouting by declaring it with 'local'. This may make things easier in the future for you.
Re^2: Why is this incorrect?
by kettle (Beadle) on Mar 17, 2006 at 07:08 UTC
    I guess I should look this up, but why should '&' not be used in function calls? thanks for the other advice!

Log In?
Username:
Password:

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

How do I use this?Last hourOther CB clients
Other Users?
Others contemplating the Monastery: (6)
As of 2024-04-23 17:26 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found