C
coolchick
Hi All,
I am trying to go through a file and grab all the arithmetic operators
using a perl hash.
It is not working for me. What am I doing wrong? I think my issue is
with the key value that I can't escape. HELP!
#!/usr/bin/perl
%operators = ('+',0,'-',0,'=',0,'*',0,'/',0);
$FILE="operator.txt";
open(FILE) or die("Could not open $FILE.");
foreach $line (<FILE>) {
while (($key,$value) = each(%operators)){
if ($line =~ /\$key/) {
$operators{$key}=$value+1;
}
}
}
I am trying to go through a file and grab all the arithmetic operators
using a perl hash.
It is not working for me. What am I doing wrong? I think my issue is
with the key value that I can't escape. HELP!
#!/usr/bin/perl
%operators = ('+',0,'-',0,'=',0,'*',0,'/',0);
$FILE="operator.txt";
open(FILE) or die("Could not open $FILE.");
foreach $line (<FILE>) {
while (($key,$value) = each(%operators)){
if ($line =~ /\$key/) {
$operators{$key}=$value+1;
}
}
}