?
Solved

Perl input question

Posted on 2002-07-26
6
Medium Priority
?
154 Views
Last Modified: 2010-03-05
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
Comment
Question by:jkratzer
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
6 Comments
 
LVL 5

Accepted Solution

by:
BlackDiamond earned 150 total points
ID: 7181171
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
 
LVL 51

Expert Comment

by:ahoffmann
ID: 7181235
probably not self explanatory (for everyone), but more perlish ;-)

#! /usr/bin/perl
$\="\n";
print "You passed ",$#ARGV+1," arguments";
grep(print,@ARGV);
0
 
LVL 84

Expert Comment

by:ozo
ID: 7181240
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
Industry Leaders: 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!

 
LVL 5

Expert Comment

by:BlackDiamond
ID: 7181451
Gotta love Perl.  Always 10 different ways to do everything, hehe.
0
 
LVL 51

Expert Comment

by:ahoffmann
ID: 7181777
perl slogan by Larry Wall: There's More Than One Way To Do It.
;-)

jkratzer, sorry for being off-topic
0
 
LVL 6

Author Comment

by:jkratzer
ID: 7184960
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

Free Tool: SSL Checker

Scans your site and returns information about your SSL implementation and certificate. Helpful for debugging and validating your SSL configuration.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

I've just discovered very important differences between Windows an Unix formats in Perl,at least 5.xx.. MOST IMPORTANT: Use Unix file format while saving Your script. otherwise it will have ^M s or smth likely weird in the EOL, Then DO NOT use m…
Email validation in proper way is  very important validation required in any web pages. This code is self explainable except that Regular Expression which I used for pattern matching. I originally published as a thread on my website : http://www…
Explain concepts important to validation of email addresses with regular expressions. Applies to most languages/tools that uses regular expressions. Consider email address RFCs: Look at HTML5 form input element (with type=email) regex pattern: T…
Six Sigma Control Plans

770 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question