Beefy Boxes and Bandwidth Generously Provided by pair Networks
Clear questions and runnable code
get the best and fastest answer
 
PerlMonks  

Re: Re: Reusing camel code

by gmax (Abbot)
on Dec 03, 2001 at 15:19 UTC ( [id://129064]=note: print w/replies, xml ) Need Help??


in reply to Re: Reusing camel code
in thread Reusing camel code

Thank you very much for your hints. I tested your code
for (split(/:/, $$pattern)) { $_ = 'S0' . $_ unless /^S/; $_ .= 'S0' unless /S\d+$/; print STDERR "pattern: $_\n"; my @pieces = split(/[SF](\d+)/, $_); foreach my $count (0..$#pieces) { print STDERR "$count -> [$pieces[$count]] "; } print STDERR "\n"; }
But I got an odd output. Split gives back some empty items
pattern: S51F11S0 0 -> [] 1 -> [51] 2 -> [] 3 -> [11] 4 -> [] 5 -> [0]
Changing split to match only /[SF]/ (your update suggestion) and adding a shift afterwards improves the output,
pattern: S51F11S0 0 -> [51] 1 -> [11] 2 -> [0]
leaving me with the second problem, i.e. that having an odd number of items in my array, splice(@,0,2) will give back an undefined second element.
Nothing catastrophic, but it is going to increase the number of necessary checks.
Even if it doesn't do what I need, though, this code of yours gives me some ideas that I can further develop.
As for the second hint:
tr/ //d; $camel .= $_;
yes, it looks much faster (not to mention smarter) than my code.
Ciao gmax

Log In?
Username:
Password:

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

How do I use this?Last hourOther CB clients
Other Users?
Others taking refuge in the Monastery: (2)
As of 2024-03-19 06:01 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found