Beefy Boxes and Bandwidth Generously Provided by pair Networks
Clear questions and runnable code
get the best and fastest answer

Re: Nested loops

by nuance (Hermit)
on Sep 13, 2015 at 13:42 UTC ( #1141831=note: print w/replies, xml ) Need Help??

in reply to Nested loops

$a and $b are special variables in perl, $c isn't.

You have forgotten to put my statements in your foreach loops. The $a and $b that you're using are package variables that exist, so you don't get a waring. $c is not a pre-existing package variable so you get a warning.

It's probably not a great idea to use $a and $b at all. If you were going to, the loops need to look like

foreach my $a (@list1)


Replies are listed 'Best First'.
Re^2: Nested loops
by robert44444uk (Acolyte) on Sep 13, 2015 at 13:45 UTC

    Ahh, that's very kind, nuance. I keep forgetting to put "my" at the front of these things.

      As nuance stated, $a and $b are special variables to perl (used in things like sort. They don't need to be declared with my because of this). It's highly advisable that you don't use these special variables except for where they are normally expected.

      $a and  $b are just the beginning of Perl's pre-defined special variables. Please see perlvar (or perldoc perlvar on your local machine) for the whole story.

      Give a man a fish:  <%-{-{-{-<

Log In?

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

How do I use this? | Other CB clients
Other Users?
Others about the Monastery: (3)
As of 2022-01-21 04:41 GMT
Find Nodes?
    Voting Booth?
    In 2022, my preferred method to securely store passwords is:

    Results (57 votes). Check out past polls.