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

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

by Marshall (Canon)
on May 25, 2022 at 20:06 UTC ( [id://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
  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?

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

How do I use this?Last hourOther CB clients
Other Users?
Others about the Monastery: (9)
As of 2024-05-19 23:02 GMT
Find Nodes?
    Voting Booth?

    No recent polls found