in reply to Removing digits until you see | in a string
This uses matches the index and remaing data without altering the original.$data_hash{$1}= $str if $str =~ s/(\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.$data_hash{$1}= $2 if $str =~ /(\d+)\|(.*)$/;
|
---|