in reply to Perl Regular Expressions

I like it small and simple:
#!/usr/bin/perl use strict; use warnings; use Data::Dumper; my %hash; my @array; while (<DATA>) { chomp; push @array, split "- " }; %hash = @array; print Dumper(\%hash); __DATA__ ABD - some text ACDB- some more text WD - more text - which spills onto the next line SD - another line
best regards, neniro

Replies are listed 'Best First'.
Re: Re: Perl Regular Expressions
by CountZero (Bishop) on Mar 22, 2004 at 22:34 UTC
    The basic idea is nice,but in practice it doesn't work:
    • It doesn't handle the continuation line the way it should.
    • A second continuation line would clobber the previous one.
    • If there is a hyphen+space in the text, the whole array/hash gets uncoordinated from there on. This can probably be corrected by only splitting on the first hyphen+space combo.

    CountZero

    "If you have four groups working on a compiler, you'll get a 4-pass compiler." - Conway's Law