What does $mylead = '^' and if
(/${mylead}$name_passed$/) mean?



--- Wagner-David <[EMAIL PROTECTED]>
wrote:
>       But don't you need to distinguish between: n-4.t-1
> and n-4.t-11? And
> if you are passed only t-1 then that should be
> distinguised from t-11 or
> t-100?
> 
>       I looked at :
> 
>       $mylead = '';
>  while(<FILE>) {
>     chomp;
>     $mylead = '^';
>     if ( $named_passed =~ /^t/ ) {
>        $mylead = '';
>      }
>     if (/${mylead}$name_passed$/) {
>         .....
> 
>     By doing the above, you match against whole name
> if n-4.t-1 is passed or
> only the node if t-1 is passed.  I could be missing
> something.
> 
> Wags ;)
> -----Original Message-----
> From: Lynn Glessner [mailto:[EMAIL PROTECTED]]
> Sent: Thursday, August 09, 2001 10:18
> To: Sofia; [EMAIL PROTECTED]
> Subject: Re: Matching strings
> 
> 
> I think that you just need to match the other way
> around to get the partial
> match.
> Instead of looking for the fileline within the
> name_passed, look for the
> name_passed within the fileline.
> 
> Something like this should do the desired partial
> match, and be shorter and
> clearer (at least to me, another newbie).
> 
>  while(<FILE>) {
>     chomp;
>     if (/$name_passed/) {
>         .....
> 
> ----- Original Message -----
> From: "Sofia" <[EMAIL PROTECTED]>
> To: <[EMAIL PROTECTED]>
> Sent: Thursday, August 09, 2001 9:59 AM
> Subject: Matching strings
> 
> 
> > I am having problems matching strings.  I have the
> > following code that reads a file with computer
> names
> > and if a named passed to the script is in the file
> > print yes otherwise print no, for example. The
> > computer names are in the format n-4.t-1 meaning
> node
> > four on rack 1.
> >
> > while(<FILE>) {
> >    $line = $_;
> >    chomp($line);
> >    $_ = $name_passed; # name is the argument
> passed to
> > this script
> >    if (/$line/) {
> >        print "yes\n";
> >        exit 0;
> >    }
> > }
> > print "no\n";
> >
> > Now, if the file contains computer n-4.t-1 and I
> want
> > to see if computer n-4.t-11 exists in the file
> (which
> > it doesn't) the script return yes because it
> matches
> > n-4.t-1.  However, the file might contain the
> entry
> > "t-2" which means that all the nodes on rack 2
> need to
> > be disabled.  So, if I passed the script the name
> of
> > n-4.t-2, the script should return "yes" because
> that
> > nodes is part of rack 2.
> >
> > Any ideas anyone???
> >
> > __________________________________________________
> > Do You Yahoo!?
> > Make international calls for as low as $.04/minute
> with Yahoo! Messenger
> > http://phonecard.yahoo.com/
> >
> > --
> > To unsubscribe, e-mail:
> [EMAIL PROTECTED]
> > For additional commands, e-mail:
> [EMAIL PROTECTED]
> >
> 
> 
> -- 
> To unsubscribe, e-mail:
> [EMAIL PROTECTED]
> For additional commands, e-mail:
> [EMAIL PROTECTED]
> 
> -- 
> To unsubscribe, e-mail:
> [EMAIL PROTECTED]
> For additional commands, e-mail:
> [EMAIL PROTECTED]
> 


__________________________________________________
Do You Yahoo!?
Make international calls for as low as $.04/minute with Yahoo! Messenger
http://phonecard.yahoo.com/

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

Reply via email to