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: Perl program that accepts integer argument: Edit Log



iammgg
Novice

May 25, 2017, 1:19 AM


Views: 1862
Perl program that accepts integer argument

Hello there. I have no idea about the reverse function so I did a research through the internet. My code doesn't work well when I try to execute it on the terminal.

The instruction is written inside.


Code
#!/usr/bin/perl 
use strict;
use warnings;

=pod
Write a perl program that will accept an integer argument
and output the example below,
use any kind of loops you prefer.

Example:
3.2_LoopTest.pl 5
5 4 3 2 1
Boom!!
=cut

if(@ARGV > 0) {
print "@ARGV\n";
foreach my $i (reverse(0..$#ARGV)) {
print "Boom!!\n";
}
}


Can you guys tell me what's wrong with this one? I know that there's something wrong because the output appears as:


Code
$ ./3.2_loopTest.pl 5 
5
Boom!!


instead of the output that was shown inside (comment) of the code.

thanks in advance.


(This post was edited by iammgg on May 25, 2017, 1:29 AM)


Edit Log:
Post edited by iammgg (Novice) on May 25, 2017, 1:21 AM
Post edited by iammgg (Novice) on May 25, 2017, 1:29 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