Beefy Boxes and Bandwidth Generously Provided by pair Networks
Problems? Is your data what you think it is?
 
PerlMonks  

Re: understanding curly braces surrounding an array

by GrandFather (Saint)
on Mar 09, 2012 at 00:51 UTC ( [id://958569]=note: print w/replies, xml ) Need Help??


in reply to understanding curly braces surrounding an array

Actually "the" solution is changing the for loop to:

for my $alarm (@alarms) { print $alarm; }

which even your C friends will understand, although they wouldn't write it that way. Or if you don't mind that your C friends may be fazed by a little Perl you could:

print $_ for @alarms;
True laziness is hard work

Replies are listed 'Best First'.
Re^2: understanding curly braces surrounding an array
by davido (Cardinal) on Mar 09, 2012 at 02:19 UTC

    Well, since nothing's being done with $_,:

    print @alarms;

    More "work" might make sense if you're trying to append a newline per iteration or something.


    Dave

      Indeed, although that doesn't contrast the Perl for loop constructs with the C construct used by the OP. ;) (And maybe, perhaps, the OP simplified his example code.)

      True laziness is hard work

Log In?
Username:
Password:

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

How do I use this?Last hourOther CB clients
Other Users?
Others chilling in the Monastery: (2)
As of 2024-04-26 00:47 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found