Beefy Boxes and Bandwidth Generously Provided by pair Networks
Don't ask to ask, just ask
 
PerlMonks  

Re: question on declaring variables

by toolic (Bishop)
on Nov 22, 2018 at 12:03 UTC ( #1226177=note: print w/replies, xml ) Need Help??


in reply to question on declaring variables

Yes, the declaration is the same for both files, but $a is a special variable, whereas $x and $y are not. You get the error messages because you correctly use strict:
Because of their special use by sort(), the variables $a and $b are exempted from this check.
You should avoid using $a and $b because they are special for the sort function. As the helpful message reports, you need to declare x and y with my.

Replies are listed 'Best First'.
Re^2: question on declaring variables
by badbanana (Novice) on Nov 22, 2018 at 12:15 UTC
    oh i see. thanks, got it!

Log In?
Username:
Password:

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

How do I use this? | Other CB clients
Other Users?
Others lurking in the Monastery: (5)
As of 2021-10-18 10:22 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?
    My first memorable Perl project was:







    Results (73 votes). Check out past polls.

    Notices?