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

Re: Removing digits until you see | in a string

by inman (Curate)
on Jan 08, 2007 at 09:31 UTC ( #593492=note: print w/ replies, xml ) Need Help??

in reply to Removing digits until you see | in a string

A couple of suggestions. The following uses a substituation and removes the index from the rest of the data (i.e. the original data is changed).

$data_hash{$1}= $str if $str =~ s/(\d+)\|//;
This uses matches the index and remaing data without altering the original.
$data_hash{$1}= $2 if $str =~ /(\d+)\|(.*)$/;
I have used a conditional to assess the validity of the assignment beforehand. This is useful for data processing where the quality of the data is variable.

Comment on Re: Removing digits until you see | in a string
Select or Download Code

Log In?

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

How do I use this? | Other CB clients
Other Users?
Others romping around the Monastery: (10)
As of 2015-12-02 06:15 GMT
Find Nodes?
    Voting Booth?

    My keyboard shows this many letters:

    Results (35 votes), past polls