Beefy Boxes and Bandwidth Generously Provided by pair Networks
more useful options
 
PerlMonks  

Re^2: "42" ~~ "42.0" is false in 5.10

by tomfahle (Priest)
on Jan 24, 2008 at 17:09 UTC ( [id://664083]=note: print w/replies, xml ) Need Help??


in reply to Re: "42" ~~ "42.0" is false in 5.10
in thread "42" ~~ "42.0" is false in 5.10

Hi,

To me it looks right:

If it looks like a string, it will be treated as string.

Here's a small programm to test the new ~~ Operator.

use strict; use warnings; use 5.010; ## No quotes &test_smartmatch(42, 42); # yields 42 smartmatches 42 &test_smartmatch(42,42.0); # yields 42 smartmatches 42 ## Single Quotes &test_smartmatch(42,'42.0'); # yields 42 smartmatches 42.0 &test_smartmatch('42','42.0'); # yields 42 doesn't smartmatch 42.0 ## Double Quotes &test_smartmatch("42","42.0"); # yields 42 doesn't smartmatch 42.0 ########################################################### sub test_smartmatch { my $lhs = shift @_; # Left Hand Side (LHS) my $rhs = shift @_; # Right Hand Side (RHS) if ( $lhs ~~ $rhs ) { say "$lhs smartmatches $rhs"; } else { say "$lhs doesn't smartmatch $rhs"; } } ## ########################################################### __END__

Just my 2 cents.

Hope this helps.

Log In?
Username:
Password:

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

How do I use this?Last hourOther CB clients
Other Users?
Others examining the Monastery: (7)
As of 2024-04-18 03:05 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found