japhmi has asked for the wisdom of the Perl Monks concerning the following question:
There are other lines with other formats, but I don't care about them. What I want is to make a hash that looks like this:foo = bar foo = bar bar
The expression I have looks like this, but it's not working like I expected (this is within a while loop going through the file):%hash = { "foo" => "bar" "foo" => "bar bar" )
Could the Monks please help me find a better regex? Thanks.if( $_ =~ /(\w*) = (\w*)/ ){ $filehash{ $1 } = $2; }
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: Determining the regex for foo=bar
by BrowserUk (Patriarch) on Mar 11, 2010 at 22:20 UTC | |
by japhmi (Novice) on Mar 12, 2010 at 00:14 UTC | |
|
Re: Determining the regex for foo=bar
by kennethk (Abbot) on Mar 11, 2010 at 22:24 UTC | |
by ack (Deacon) on Mar 12, 2010 at 02:20 UTC | |
|
Re: Determining the regex for foo=bar
by toolic (Bishop) on Mar 11, 2010 at 22:24 UTC | |
by johngg (Canon) on Mar 12, 2010 at 00:11 UTC |