Beefy Boxes and Bandwidth Generously Provided by pair Networks
Perl-Sensitive Sunglasses
 
PerlMonks  

Re: Re: Re: Re: Re: Why do we say the =~ operator "binds"?

by William G. Davis (Friar)
on Apr 20, 2004 at 04:48 UTC ( [id://346544]=note: print w/replies, xml ) Need Help??


in reply to Re: Re: Re: Re: Why do we say the =~ operator "binds"?
in thread Why do we say the =~ operator "binds"?

Emazep, it was just an example; Diotalevi and I were talking about a situation in which the assignment is practical for some reason (like if you're calling m//g in scalar context), not one where you can get away with sticking m// in a conditional by itself. (Who on earth would store away the result unless they needed for something later on, anyway?)

My point was that if you have an assignment like "$var = /pattern/", then name the variables and use the binding operator explicitly so it's completely unambiguous: "$pos = $string =~ /pattern/g".

In real life I would have written that validity checking code like this:

foreach my $address (@email_addresses) { return unless ($address =~ /[a-zA-Z0-0.]+\@[a-zA-Z0-0.]+/); # proceed normally...

Replies are listed 'Best First'.
Re: Re: Re: Re: Re: Re: Why do we say the =~ operator "binds"?
by emazep (Priest) on Apr 20, 2004 at 05:08 UTC
    I apologize for my (pointless) excess of pedantry.

    Cheers,
    Emanuele.

Log In?
Username:
Password:

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

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

    No recent polls found