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