I'm at my wit's end, and cannot for the life of me get this to work itself out correctly! Any advice is welcome:
I have a string that's basically an ID number, consisting of a product prefix and a number, for example
STPC0001. What I need to know is what number item I'm on, STPC0001 or STPC0010? Right now I'm doing the following:
if ($currNumber =~ /^($product)./) {
@currNumber = split //, $currNumber;
@product = split //, $product;
$prodLength = @product;
@adjNum = splice(@currNumber,$prodLength); }
@adjNum captures the string of numbers I want to look at - in this case it cuts off the STPC and leaves me with 0001. However, this only works for 0001-0009, when I get to 0010, it starts back at 0, and thusly screws me up. I've tried scalar(@adjNum) to kinda force the 0001 into a single number, but that also doesn't work properly after 9.
Any help/advice is *greatly* appreciated!
Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
Read Where should I post X? if you're not absolutely sure you're posting in the right place.
Please read these before you post! —
Posts may use any of the Perl Monks Approved HTML tags:
- a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
| |
For: |
|
Use: |
| & | | & |
| < | | < |
| > | | > |
| [ | | [ |
| ] | | ] |
Link using PerlMonks shortcuts! What shortcuts can I use for linking?
See Writeup Formatting Tips and other pages linked from there for more info.