in reply to Help me write a good reg-exp for this text
Is the data of fixed width? If so, you're better off with unpack:
# @LIST_OF_ENTRIES contains your data, one line per element my %description_hash; foreach my $entry (@LIST_OF_ENTRIES) { # Replace 20 with the number of characters in the value portion my ($value, $name) = unpack('A20 A*', $entry); $value =~ s/\A\s*//; $value =~ s/\s*\z//; $description_hash($name} = $value; }
----
I wanted to explore how Perl's closures can be manipulated, and ended up creating an object system by accident.
-- Schemer
Note: All code is untested, unless otherwise stated
|
---|
Replies are listed 'Best First'. | |
---|---|
Care to explain s/\A\s*//?
by waxmop (Beadle) on Sep 05, 2003 at 16:59 UTC | |
by halley (Prior) on Sep 05, 2003 at 17:22 UTC | |
by bart (Canon) on Sep 05, 2003 at 17:46 UTC |