In addition to what Shlomi has mentioned, I will add: On May 3, 2012, at 4:34 AM, venkates wrote:
> sub parse { > > my $pazar_file_path = shift; > my $pazar_data; # ref to a hash holding the parsed data > > open FH, '<', $pazar_file_path or croak ( "Cannot open file > '$pazar_file_path': $!" ); > while ( my $data = <FH> ) { > > chomp $data; > my @record_lines = split /\t/, $data; > my ( $pazar_p_id, $prot_id, $pazar_g_id, $ensembl_id ) = splice ( > @record_lines, 0, 4 ); The above two lines can be replaced with: my ( $pazar_p_id, $prot_id, $pazar_g_id, $ensembl_id, @record_lines ) = split /\t/, $data; > push @{ $pazar_data->{$pazar_p_id}{$prot_id}{$pazar_g_id}{$ensembl_id} > }, @record_lines; If you don't want to save the duplicate lines, assign a reference to an array instead of pushing each new line to the end: $pazar_data->{$pazar_p_id}{$prot_id}{$pazar_g_id}{$ensembl_id} = [@record_lines]; -- To unsubscribe, e-mail: beginners-unsubscr...@perl.org For additional commands, e-mail: beginners-h...@perl.org http://learn.perl.org/