Beefy Boxes and Bandwidth Generously Provided by pair Networks
laziness, impatience, and hubris
 
PerlMonks  

comment on

( [id://3333]=superdoc: print w/replies, xml ) Need Help??
If you get the strings like you say are there, then you can use them as numbers. In Perl, you don't have to call a function to convert a string to a number, if that string is a number, you can just use it like one. Here I just added 10 to the "string" to show that feature. Of course once "$string" is a "number", leading zero'es are suppressed unless you use some kind of printf statement to add them back into the printout. A common idiom to suppress leading zeroes is $number_string+=0;
#!usr/bin/perl use warnings; use strict; my @input = qw /0001144204-09-017358 0001144204-10-065610 0001042167-15-000175 0000053669-16-000051 /; foreach my $string (@input) { $string =~ tr/-//d; print "string = $string\n"; print "string +10 as number: ", $string + 10,"\n"; } __END__ prints: string = 000114420409017358 string +10 as number: 114420409017368 string = 000114420410065610 string +10 as number: 114420410065620 string = 000104216715000175 string +10 as number: 104216715000185 string = 000005366916000051 string +10 as number: 5366916000061
Update: I ran this on Win XP, 32 bit.
normally, 2,147,483,647 would be max int, but Perl 5.22 was able to get 104,216,715,000,185 from the addition.

In reply to Re^5: REGEX omit dashes - simple but ... by Marshall
in thread REGEX omit dashes - simple but ... by wrkrbeee

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post; it's "PerlMonks-approved HTML":



  • Are you posting in the right place? Check out Where do I post X? to know for sure.
  • Posts may use any of the Perl Monks Approved HTML tags. Currently these include the following:
    <code> <a> <b> <big> <blockquote> <br /> <dd> <dl> <dt> <em> <font> <h1> <h2> <h3> <h4> <h5> <h6> <hr /> <i> <li> <nbsp> <ol> <p> <small> <strike> <strong> <sub> <sup> <table> <td> <th> <tr> <tt> <u> <ul>
  • Snippets of code should be wrapped in <code> tags not <pre> tags. In fact, <pre> tags should generally be avoided. If they must be used, extreme care should be taken to ensure that their contents do not have long lines (<70 chars), in order to prevent horizontal scrolling (and possible janitor intervention).
  • Want more info? How to link or How to display code and escape characters are good places to start.
Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Chatterbox?
and the web crawler heard nothing...

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

    No recent polls found