You are not using warnings which would have told you that you were
trying an uninitialize value. Now that said, I don't understand why it
doesn't work.  One of the higher Gurus will have to fill us in.

        ps I tried to remove the \n on STDIN and got an error:

Can't modify <HANDLE> in chomp at d:\currwrka\00COMM~1\03AAPL~1\aapl210.pl
line 2, near "<STDIN>)"
 and the code looked like:

chomp(<STDIN>);

        So we need someone with a higher level to explain the significance.

Wags ;)
-----Original Message-----
From: Sudarsan.Raghavan [mailto:[EMAIL PROTECTED]]
Sent: Friday, July 27, 2001 15:16
To: [EMAIL PROTECTED]
Subject: $_ question


All,

This may be a stupid question. I was going through some online perl
tutorials and they say that $_ is the default input, output and pattern
matching variable.
I tried this out

[suddy@incq231e hash]$ perl
<STDIN>;
if (m/under/) {
        print "Found Under\n";
}
else {
        print "No Match\n";
}
under
No Match

When I tried with <STDIN>  inside while
[suddy@incq231e hash]$ perl
while (<STDIN>) {
        if (m/under/) {
                print "Found Under\n";
        }
        else {
                print "No Match\n";
        }
}
under
Found Under
blunder
Found Under
boom
No Match

What is the reason for this difference in behavior.

Thanks,
Sudarsan



-- 
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]

Reply via email to