CGI/Perl Guide | Learning Center | Forums | Advertise | Login
Site Search: in

  Main Index MAIN
INDEX
Search Posts SEARCH
POSTS
Who's Online WHO'S
ONLINE
Log in LOG
IN

Home: Perl Programming Help: Beginner: variable declaration and countdown: Edit Log



jazzo
Novice

Aug 25, 2012, 10:41 AM


Views: 749
variable declaration and countdown

Hi peeps, I came across this simple script:

Code
 
#!/usr/bin/perl
# countdown.plx
use warnings;
use strict;
my @count = (1..5);
for (reverse(@count)) {
print "$_...\n";
sleep 1;
}
print "BLAST OFF!\n";

and I was wondering, shouldn't the variable

Code
reverse

be declare as

Code
my reverse

rather than using it without declaring it?
The the other thing. to print off the numbers we say:

Code
print "$_...\n";

why do we use "$_"?
can we not use the array something like

Code
print "$count[reverse]\n";

thanks


(This post was edited by jazzo on Aug 25, 2012, 10:48 AM)


Edit Log:
Post edited by jazzo (Novice) on Aug 25, 2012, 10:48 AM


Search for (options) Powered by Gossamer Forum v.1.2.0

Web Applications & Managed Hosting Powered by Gossamer Threads
Visit our Mailing List Archives