P
Petterson Mikael
Hi,
I am trying to run the following perl script but I cannot
get it to compile. I get the following error:
"my" variable $msg masks earlier declaration in same scope at
run_dtest.pl line 34.
syntax error at run_dtest.pl line 33, near "sub printWARNING "
Can't use global @_ in "my" at run_dtest.pl line 34, near "=$_"
syntax error at run_dtest.pl line 38, near "}"
Execution of run_dtest.pl aborted due to compilation errors.
All help is very much appreciated.
//Mikael
####################### SCRIPT #######################
#!/usr/local/bin/perl -w
# turn on perl's safety features
use strict;
#use warning;
# load our modules
my $msg;
my $current_dir = `pwd`;
my $log="dtest.log";
print "Current directory is $current_dir";
# Main
prepare
######################################################################
### SUBROUTINES
######################################################################
######################################################################
### printWARNING to stdout and $log
######################################################################
sub printWARNING {
my $msg=$_[0];
# make STDOUT go to log file, plus original STDOUT
open (STDOUT, "| tee $log") or die "Teeing off: $!\n";
print "WARNING: $msg \n" or die "Writing: $!\n";
}
sub prepare () {
rmdir "$current_dir/RBSSW*" or printWARNING("No RBSSW* found the
search directory.");
}
I am trying to run the following perl script but I cannot
get it to compile. I get the following error:
"my" variable $msg masks earlier declaration in same scope at
run_dtest.pl line 34.
syntax error at run_dtest.pl line 33, near "sub printWARNING "
Can't use global @_ in "my" at run_dtest.pl line 34, near "=$_"
syntax error at run_dtest.pl line 38, near "}"
Execution of run_dtest.pl aborted due to compilation errors.
All help is very much appreciated.
//Mikael
####################### SCRIPT #######################
#!/usr/local/bin/perl -w
# turn on perl's safety features
use strict;
#use warning;
# load our modules
my $msg;
my $current_dir = `pwd`;
my $log="dtest.log";
print "Current directory is $current_dir";
# Main
prepare
######################################################################
### SUBROUTINES
######################################################################
######################################################################
### printWARNING to stdout and $log
######################################################################
sub printWARNING {
my $msg=$_[0];
# make STDOUT go to log file, plus original STDOUT
open (STDOUT, "| tee $log") or die "Teeing off: $!\n";
print "WARNING: $msg \n" or die "Writing: $!\n";
}
sub prepare () {
rmdir "$current_dir/RBSSW*" or printWARNING("No RBSSW* found the
search directory.");
}