Once user provides input from command line it should look it[California] ;;Name $;FIrst_Name = ;;Last_name $;Last_Name= ;;Age of member $;Age = [NewYork] ;;Name $;FIrst_Name = ;;Last_name $;Last_Name= ;;Age of member $;Age = [Washington] ;;Name $;FIrst_Name = ;;Last_name $;Last_Name= ;;Age of member $;Age =
The order of First_Name, Last_Name and Age within each location can change and even order of locations can change, but each location section should remain separate and intact. I wrote following code so far and some of my code works for taking whole file in one hash, but i am not able to preserve each location section within it! I tried using two hashes - can someone please help me this complex problem! Thanks a lot.[California] ;;Name $;FIrst_Name = Jack ;;Last_name $;Last_Name= Daner ;;Age of member $;Age = 27 [NewYork] ;;Name $;FIrst_Name = Jill ;;Last_name $;Last_Name= XYZ ;;Age of member $;Age = 30 [Washington] ;;Name $;FIrst_Name = Kim ;;Last_name $;Last_Name= ABC ;;Age of member $;Age = 25
open($input.file, "<$InputFile") or die "Error! Cannot open $InputFile + for reading: $!"; while (<$input.file>) { $_ =~ s/\s+$//; next if ($_ =~ /^#/); next if ($_ =~ /^$/); if ($_ =~ m/^\[(\S+)\]$/) { $sComponent = $1; next; } elsif ($_ =~ m/^;;\s*(.*)/) { $sDesc .= "$1."; next; } elsif ($_ =~ m/\$;(\S+)\$;\s*=\s*(.*)/) { $sParam = $1; $sValue = $2; } $sParam = $sValue = $sDesc = ""; next; } }
In reply to Read an input file in two hashes to retain order by Bioinfocoder
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |