Beefy Boxes and Bandwidth Generously Provided by pair Networks
good chemistry is complicated,
and a little bit messy -LW
 
PerlMonks  

Re: How to convert a string with regex to a string with a fixed length?

by olus (Curate)
on Jul 29, 2008 at 16:37 UTC ( [id://700852]=note: print w/replies, xml ) Need Help??


in reply to How to convert a string with regex to a string with a fixed length?

Also with sprintf

$barcode = sprintf("%.13s%s", $barcode, "0"x(13-length($barcode)));

update thanks lodin, I misunderstood the question and assumed the input was always 13 or less characters. Fixed now

Replies are listed 'Best First'.
Re^2: How to convert a string with regex to a string with a fixed length?
by lodin (Hermit) on Jul 29, 2008 at 17:12 UTC

    As this is just a cumbersome way to do concatenation it does not fullfil the requirement to make $barcode shorter if it's over 13 chars long.

    lodin

Log In?
Username:
Password:

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

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

    No recent polls found