On Wed, Nov 14, 2012 at 9:05 AM, jet speed <speedj...@googlemail.com> wrote:
> Hi
> Is there a way, i can build an %hash from a file as Input. Appreciate you
> help with this.
>
> file.txt
> ----------------
>
> 22:5a => 10.00.00.00.aa.56.9b.7a
> 32:9c => 10.00.00.00.aa.46.9b.33
> a2:cc=> 10.00.00.00.aa.5a.9b.63

Assuming no anomalies/surprises in file.txt:

use File::Slurp;
use strict;
use warnings;

my @lines = read_file( 'file.txt', chomp=>1 );
my %hash =  map { split( /\s*=>\s*/,$_ ) } @lines;

-- 
Charles DeRykus

-- 
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