Maybe the code piece in my mail is misleading. My question is why does the input from
STDIN assigned to $_ when given within a loop
construct and not when given stand alone.

Chris Garringer wrote:

> Blunder matches on the under at the end of the string.  If you want to match only 
>under
> m/^under$/
>
> Chris D. Garringer
> LAN/WAN Manager
> Master Certified Netware Engineer
> Microsoft Certified Systems Engineer
> Certified Solaris Administrator
> Red Hat Certified Engineer
> [EMAIL PROTECTED]
> fax 713-896-5266
>
> >>> "Sudarsan.Raghavan" <[EMAIL PROTECTED]> 07/27/01 05:15PM >>>
> 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