Beefy Boxes and Bandwidth Generously Provided by pair Networks
Just another Perl shrine
 
PerlMonks  

Re^3: Purpose of =~ and = in this statement

by Marshall (Canon)
on May 25, 2022 at 20:06 UTC ( #11144186=note: print w/replies, xml ) Need Help??

Help for this page

Select Code to Download


  1. or download this
    $chapter =~ s/\D+//g;   # remove all non-digit characters 
    # or perhaps to avoid the /g flag, (I wouldn't code it this way
    ...
                                         # before or after the digits
    # try the above with "XX546YYY", just "453ZZ" and "AAA123ZZZ77548" as
    # cases to probe the limits... what happens if it is not just "11VI"?
    
  2. or download this
    my $x = "3";
    if ($x > 3){...}
    
  3. or download this
    my $x = "chapter 5";
    print "chap 5 ok!" if $x == 5;
    ...
    # chapter 5 is ok now!
    # The string got "fixed" to be completely numeric
    # Then when Perl made it into binary number to compare against 5, it w
    +orked!
    
  4. or download this
    $x = "00005";
    print "$x\n";  #yields "00005"
    $x += 0; #adding zero forces numeric conversion
    print "$x\n";  #yields "5"
    

Log In?
Username:
Password:

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

How do I use this? | Other CB clients
Other Users?
Others meditating upon the Monastery: (4)
As of 2022-08-17 21:52 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found

    Notices?