in reply to Use of uninitialized value $_ in pattern match (m//)
You were close, but you're getting the error because you haven't done anything to put a value in $_. It appears like you're wanting to scan through a file, so you'd do something like this:
#!/tool/pandora64/bin/perl5.8.8 -w use strict; use warnings; my @verilogfiles = glob '*.verilog'; my ($vf, $of, $i, $j); print "Define the path for sdf_annotate.v: "; my $path = <STDIN>; chomp($path); #For verilog files foreach my $b (@verilogfiles) { open $vf, '>>', $b or die "Could not open file '@verilogfiles' +$!"; while (<$vf>) { if($_ =~ /module entity\;/) { print $vf "\`include \"$path\"\n"; } } } close ($vf);
The while (<$vf>) { loop will load a line from $vf into $_ and execute the loop body, and repeat until there are no more lines in the file.
...roboticus
When your only tool is a hammer, all problems look like your thumb.
|
|---|