I don't see a problem with your first example:

$Line = "Hey there look it works";
if ($Line =~ /@ARGV[2]/i){
        print "True\n";
        }

if the script is called pl.pl then the following happens:
$ pl.pl arg0 arg1 THERE
True

$ pl.pl arg0 arg1 crap

but if @ARGV[2] is nothing (ie "") then // will use the last successful
pattern match to try again, or else it will always be true if there was no
previous pattern match.

Show us more code or the error if any.

-----Original Message-----
From: Michael Pastore [mailto:[EMAIL PROTECTED]]
Sent: Wednesday, February 20, 2002 12:45 PM
To: '[EMAIL PROTECTED]'
Subject: Question Regarding Pattern Matching and ARGV


> Hello All,
> 
> This is my first posting to this Peg, please excuse any protocol ...
> 
> I am currently working on a Perl Script and trying to do a pattern match
> within an If, like:
> 
> if ($Line =~ /field vendno/i)....searching for string "field vendno" .
> 
> but instead of hard-coding the pattern match I would like to read it in
> from an argument passed when running from the command line, like @ARGV[2].
> 
> I have tried:
> 
> if ($Line =~ /@ARGV[2]/i)
> 
> if ($Line =~ /$ARGV[2]/i)
> 
> I have also tried assigning the value of the ARGV to another variable
> like:
> 
> $ArgMatch = @ARGV[2];
> 
> if ($Line =~ /$ArgMatch/)
> 
> Any help would be greatly appreciated!!!
> 
> TIA,
> Mike
> 
> Michael Pastore
> Business Systems Analyst,CPIM
> Velocity Enhancements Group
> Frontstep
> Ph        (614)523-7186
> Fax      (614)410-2649
> Email    [EMAIL PROTECTED]
> 
> 

-- 
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

----------------------------------------------------------------------------
--------------------
The views and opinions expressed in this email message are the sender's
own, and do not necessarily represent the views and opinions of Summit
Systems Inc.


-- 
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to