Want to win a PS4? Go Premium and enter to win our High-Tech Treats giveaway. Enter to Win

x
?
Solved

Perl input question

Posted on 2002-07-26
6
Medium Priority
?
155 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
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!

 
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

Hire Technology Freelancers with Gigs

Work with freelancers specializing in everything from database administration to programming, who have proven themselves as experts in their field. Hire the best, collaborate easily, pay securely, and get projects done right.

Question has a verified solution.

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

There are many situations when we need to display the data in sorted order. For example: Student details by name or by rank or by total marks etc. If you are working on data driven based projects then you will use sorting techniques very frequently.…
Checking the Alert Log in AWS RDS Oracle can be a pain through their user interface.  I made a script to download the Alert Log, look for errors, and email me the trace files.  In this article I'll describe what I did and share my script.
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

609 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