i have a file of the form

(9430, 3656) (9147, 14355) (133, 14393) (7917, 9513) (3719, 12775)

lets say i need to store it as a hash.such that 9430=>3656 and so on.I tried using split but it takes whitespaces for right hand values.How can i do it the better way?

#!/usr/bin/perl
use strict;
use warnings;
use Data::Dumper;

my $rec = '(9430, 3656) (9147, 14355) (133, 14393) (7917, 9513) (3719, 12775)';

$rec =~ s/['(),]//g; #Remove everything except digits and spaces

my %hash = split / /, $rec; #Split on space character and assign to hash

print Dumper(\%hash);
Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.