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]