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. input1 input2....
like a=$1   b=$2......

What is the easiest way to do this...

John KratzerAsked:
Who is Participating?
BlackDiamondConnect With a Mentor Commented:
Here you go.  Pretty self explanatory I think, but let me know if you need more info.


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

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

#! /usr/bin/perl
print "You passed ",$#ARGV+1," arguments";
I would call that less perlish
More perlish might be:

print "You passed ".@ARGV." arguments";
print "The argument values are:\n";
print for( @ARGV );
Cloud Class® Course: CompTIA Healthcare IT Tech

This course will help prep you to earn the CompTIA Healthcare IT Technician certification showing that you have the knowledge and skills needed to succeed in installing, managing, and troubleshooting IT systems in medical and clinical settings.

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

jkratzer, sorry for being off-topic
John KratzerAuthor 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...

Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.