greatshots has asked for the wisdom of the Perl Monks concerning the following question:
dear monks
Changed the code as follows :-Prog_name : print.pl #!/usr/bin/perl use strict; use warnings; my @array = ( 11,12,13,14,15); #my @new = @array[join(",",@ARGV)]; my @new = @array[1,3]; print "@new\n"; Output :- 12 14
Is it mandatory that all the arguements which I am passing from command line arguements should need to be converted to numbers ( if it is a number ) to print ? Is there anyother way in which, will I be able to tell my program to treat the command line arguements as integers ?#!/usr/bin/perl use strict; use warnings; my @array = ( 11,12,13,14,15); my @new = @array[join(",",@ARGV)]; #my @new = @array[1,3]; print "@new\n"; Output : perl print.pl 1 3 Argument "" isn't numeric in array slice at l.pl line 8. 11
|
---|
Replies are listed 'Best First'. | |
---|---|
Re: print the array using command line arguements
by Sidhekin (Priest) on Nov 30, 2006 at 07:48 UTC | |
Re: print the array using command line arguements
by loris (Hermit) on Nov 30, 2006 at 07:57 UTC | |
Re: print the array using command line arguements
by ocs (Monk) on Nov 30, 2006 at 08:26 UTC | |
Re: print the array using command line arguements
by Fengor (Pilgrim) on Nov 30, 2006 at 07:48 UTC | |
by lidden (Curate) on Nov 30, 2006 at 07:57 UTC | |
by Fengor (Pilgrim) on Nov 30, 2006 at 08:03 UTC | |
by reneeb (Chaplain) on Nov 30, 2006 at 08:00 UTC |
Back to
Seekers of Perl Wisdom