• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 156
  • Last Modified:

Perl input question

I am writing a perl script to do some file comparisons, but I would like it to take inputs similar to how korn does it....i.e.    script.sh input1 input2....
like a=$1   b=$2......

What is the easiest way to do this...

0
jkratzer
Asked:
jkratzer
1 Solution
 
BlackDiamondCommented:
Here you go.  Pretty self explanatory I think, but let me know if you need more info.


#!/usr/bin/perl

print "You passed " . scalar(@ARGV) . " arguments\n";
print "The argument values are:\n\n";

foreach $arg (@ARGV) {
   print "$arg\n";
}
0
 
ahoffmannCommented:
probably not self explanatory (for everyone), but more perlish ;-)

#! /usr/bin/perl
$\="\n";
print "You passed ",$#ARGV+1," arguments";
grep(print,@ARGV);
0
 
ozoCommented:
I would call that less perlish
More perlish might be:

#!/usr/bin/perl
$\="\n";
print "You passed ".@ARGV." arguments";
print "The argument values are:\n";
print for( @ARGV );
0
Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 
BlackDiamondCommented:
Gotta love Perl.  Always 10 different ways to do everything, hehe.
0
 
ahoffmannCommented:
perl slogan by Larry Wall: There's More Than One Way To Do It.
;-)

jkratzer, sorry for being off-topic
0
 
jkratzerAuthor Commented:
I figured it out about 1 hour after I posted.
I used......

open F,"<$ARGV[0]" or die "Can't open $ARGV[0] because $!";
$count{$_} |= 1 while <F> ;
open F,"<$ARGV[1]" or die "Can't open $ARGV[1] because $!";
$count{$_} |= 2 while <F> ;

Since BlackDiamond answered first I will give him the credit......Thanks for the help guys...


0

Featured Post

How to Use the Help Bell

Need to boost the visibility of your question for solutions? Use the Experts Exchange Help Bell to confirm priority levels and contact subject-matter experts for question attention.  Check out this how-to article for more information.

Tackle projects and never again get stuck behind a technical roadblock.
Join Now