>>>>> "JWK" == John W Krahn <jwkr...@shaw.ca> writes:

  JWK> Uri Guttman wrote:
  >>>>>>> "a" == addie<ad...@refenestration.com>  writes:
  >> 
  a> %hash = split(/\s/, $locus_line);
  >> 
  >> that assigns a single pair to the hash. a SINGLE PAIR to the WHOLE
  >> HASH. anything in the hash before that is wiped out. also the values
  >> will have newlines on them which isn't the main bug but is usually wrong
  >> when loading text from lines.

  JWK> The pattern /\s/ will remove newlines.

true. the trailing empty string will be dropped by default.

and i didn't post my fave way of loading a file to a hash:

use File::Slurp ;

my %hash = read_file( $file ) =~ /^(\w+)=(.+)$/mg ;

adjust the regex to your liking for spaces, =, etc.

uri

-- 
Uri Guttman  ------  u...@stemsystems.com  --------  http://www.sysarch.com --
-----  Perl Code Review , Architecture, Development, Training, Support ------
---------  Gourmet Hot Cocoa Mix  ----  http://bestfriendscocoa.com ---------

-- 
To unsubscribe, e-mail: beginners-unsubscr...@perl.org
For additional commands, e-mail: beginners-h...@perl.org
http://learn.perl.org/


Reply via email to