Beefy Boxes and Bandwidth Generously Provided by pair Networks
There's more than one way to do things
 
PerlMonks  

Re: = rather than =~ ?

by inman (Curate)
on Jan 02, 2004 at 18:04 UTC ( [id://318381]=note: print w/replies, xml ) Need Help??


in reply to = rather than =~ ?

Another potentially confusing variation would be if list context was used since the match will return the list of matched sub-expressions. In the example below, $input is assigned a value for each iteration wheras $1 is only changed on a good match.

#! /usr/bin/perl use strict; my $input; while (<DATA>) { ($input) = /(\w+)/; print "\$input=$input\t\$1=$1\n"; } __DATA__ Hello World

Output:

$input=Hello $1=Hello $input= $1=Hello $input=World $1=World

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: note [id://318381]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others chilling in the Monastery: (2)
As of 2024-04-26 07:49 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found