in reply to Removing digits until you see | in a string
$str = '703555121245874|45874 Smith St|Your Town|New Hampshire'; %data_hash = map { split m{\|}, $_, 2 } $str;
If you are perhaps reading a lot of these strings from a file you could populate the hash in one fell swoop.
my %data_hash = map { split m{\|}, $_, 2 } map {chomp; $_} <$fileHandle>;
I hope this is of use.
Cheers,
JohnGG
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^2: Removing digits until you see | in a string
by Animator (Hermit) on Jan 08, 2007 at 12:10 UTC | |
by johngg (Canon) on Jan 08, 2007 at 13:53 UTC | |
by Animator (Hermit) on Jan 08, 2007 at 14:11 UTC | |
by johngg (Canon) on Jan 08, 2007 at 16:55 UTC | |
by Animator (Hermit) on Jan 08, 2007 at 18:41 UTC | |
|