Lust69 has asked for the wisdom of the Perl Monks concerning the following question:
#commandline.pl #\!C:\strawberry\perl\bin\perl.exe $y=0; for $x (@ARGV) {print "argument $y is $ARGV[$y] \n";$y++;}
Now I must modify the code above and the question is... Write a perl script which prints out the value and length of its longest command line argument. For example, running the script with argument a b df ert and y produces,#split.pl #\!C:\strawberry\perl\bin\perl.exe while($input=<STDIN>) { @line=split(" " ,$input); $i=0; for $word (@line) { $len=length($word); print " word $i = '$word' has a length of $len \n"; $i++; } }
>perl longest.pl a b df ert y
>perl longest argument is "ert" - length = 3
Can someone modify the code above to do this for me (I have tried), I am learning alone this is not homework but in lab questions that do not have to be completed. I obviously want to learn.
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: Simple Perl, to get me started.
by toolic (Bishop) on Oct 27, 2010 at 15:48 UTC | |
by Lust69 (Initiate) on Oct 27, 2010 at 15:54 UTC | |
by marto (Cardinal) on Oct 27, 2010 at 16:01 UTC | |
by Anonymous Monk on Oct 27, 2010 at 16:42 UTC | |
by ig (Vicar) on Oct 27, 2010 at 17:00 UTC | |
by toolic (Bishop) on Oct 27, 2010 at 17:41 UTC | |
|
Re: Simple Perl, to get me started.
by jethro (Monsignor) on Oct 27, 2010 at 16:46 UTC | |
by ww (Archbishop) on Oct 27, 2010 at 21:49 UTC | |
|
Re: Simple Perl, to get me started.
by MidLifeXis (Monsignor) on Oct 27, 2010 at 16:03 UTC | |
|
Re: Simple Perl, to get me started.
by ig (Vicar) on Oct 27, 2010 at 17:49 UTC |