in reply to Re: Getting args
in thread Getting args

How do I pattern-match a variable with the first one?
if ($var =~ m/@ARGV[1]/) { ... }
???

Replies are listed 'Best First'.
Re: Re: Re: Getting args
by joealba (Hermit) on Dec 10, 2001 at 22:55 UTC
    You were close.
    if ($var =~ /$ARGV[0]/) { ... }

    A more exact match:
    if ($var =~ /^$ARGV[0]$/) { ... }

    Updated: $ARGV[1] is the SECOND argument. $ARGV[0] is the first one.