Beefy Boxes and Bandwidth Generously Provided by pair Networks
Do you know where your variables are?
 
PerlMonks  

Re^2: how to convert fractional string to decimal numbers ?

by graff (Chancellor)
on Dec 17, 2008 at 07:29 UTC ( [id://730851]=note: print w/replies, xml ) Need Help??

Help for this page

Select Code to Download


  1. or download this
    my $fractionValue =
        ( $str =~ m{^(\d+)/([1-9]\d*)} )   # regex match will evaluate to 
    +true or false
    ...
        :            # otherwise (if above condition was false), ...
        "undefined"  #   return this value
        ;            # end of statement
    
  2. or download this
    /blah/
    m/blah/
    m=blah=
    m!blah!
    m{blah}
    
  3. or download this
    /http:\/\/my\/path\/to\/insanity/
    m{my/path/back/to/sanity}
    
  4. or download this
    $_ = "123.456/789-0";
    if ( /(\d+)\D(\d+)\D(\d+)/ ) {
        printf( "Found three numbers: %d was between %d and %d\n", $2, $1,
    + $3 );
    }
    
  5. or download this
    if ( $_ =~ /(\d+)\D(\d+)\D(\d+)/ ) { ...
    

Log In?
Username:
Password:

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

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

    No recent polls found