$VAR1 = { '' => '', '362520' => 'Fktn and Name: fukutin[Rattus norvegicus]', '375790' => 'AGRN and Name: agrin[Homo sapiens]', '3339' => 'HSPG2 and Name: heparan sulfate proteoglycan 2[Ho +mo sapiens]', '1428' => 'CRYM and Name: crystallin, mu[Homo sapiens]', }
I am very new at this so help would be appreciated I have a file containing text like the one above, I have called it dumpparse.txt, that I created parsing a bigger file using Data::Dumper module. I want to very siimply change the lead text from $VAR1 to my %hash. Then I can read the file back in and do a hash search. so far I have read in the file as an array and the idea is to just use a simple substitution useing the code like the following. The trouble is the regex and the substitution look like variables and the programme compalins, help would be apreciated. Thanks
# #!/usr/bin/perl; use strict; use warnings; my $hashfile = 'dumpparse.txt'; unless ( open(DUMPPARSE, $hashfile) ) { print "Could not open file $hashfile!\n"; exit; } my @hashfile = <DUMPPARSE>; foreach my $line (@hashfile){ if ($line = ~s/ $VAR1/ my %hash /) } # Close the file. close DUMPPARSE; exit;
In reply to trouble with substitution by Interzona
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |