in reply to Perl Regular Expressions

timtowtdi
#!/usr/bin/perl use strict; use warnings; my %Hash = (); my $thiskey=''; while(<DATA>) { chomp; my @line = (split /\s*-\s*/); $thiskey = $line[0] || $thiskey; $Hash{$thiskey} = defined $Hash{$thiskey} ? $Hash{$thiskey}.=" $li +ne[1]" : $line[1]; print "$thiskey $line[1]\n"; } __DATA__ ABD - some text ACDB- some more text WD - more text - which spills onto the next line SD - another line

cLive ;-)