Hi guys,
I've got perl script as below
*******************************************************
#! /home/SOFTS/Perl/5.8.0/bin/perl -w
## open the sgml file and read it line by line
## search for the <effect with the attribut effrg
## extract the value of the effrg, if it has more than 6 digits
if ($ARGV[0]) {
open(LOGFILE, ">effrg.log") or die "Couldn't open startfile: $!\n";
while (<>) {
if ( /<effect |<sbeff |<coceff |<aclist /i .. /<\/effect>|<\/sbeff>|<\/coceff>|<\/aclist>/i) {
fix();
} else {
print; }
}
sub fix {
if (/effrg="(\d{7,})"/i) { ## only lines with more than 6 digits in EFFRG
$numeff = length($1)/6;
if ( $numeff*6 != length($1) ) { print; ## It must be a multiple of 6
} else {
$out = $1;
print LOGFILE "EFFRG=\"$1\" changed to ";
$out =~ s/(\d{6})/$1 /g; ## put in the spaces
$out =~ s/(\d{6}) $/$1/g; ## take out the last one
s/(effrg=")\d+"/$1$out"/gi; ## fix the original line
print LOGFILE "$1$out\"\n";
print;
}
} elsif (/(effrg="\d{6}")/i) {
print LOGFILE "$1 left unchanged\n";
print;
} else { print; }
}
} else { print "\nUsage : effrg.pl sgml_file_name > output_file_name\n";
print "Takes an SGML file and splits the EFFRG attribute into blocks of 6 digits\n";
print "Currently treats the EFFRG attribute in the effect,sbeff,coceff & aclist tags\n";
print "Generates the effrg.log file showing actions taken\n";
}
************************************************************
But when I tried to execute it, it came up this message :
bash: ./effrg.pl: No such file or directory
I've already put the file in the same directory and chmod to 775. Any idea what's wrong of the script?
Cheers,
Hendra
I've got perl script as below
*******************************************************
#! /home/SOFTS/Perl/5.8.0/bin/perl -w
## open the sgml file and read it line by line
## search for the <effect with the attribut effrg
## extract the value of the effrg, if it has more than 6 digits
if ($ARGV[0]) {
open(LOGFILE, ">effrg.log") or die "Couldn't open startfile: $!\n";
while (<>) {
if ( /<effect |<sbeff |<coceff |<aclist /i .. /<\/effect>|<\/sbeff>|<\/coceff>|<\/aclist>/i) {
fix();
} else {
print; }
}
sub fix {
if (/effrg="(\d{7,})"/i) { ## only lines with more than 6 digits in EFFRG
$numeff = length($1)/6;
if ( $numeff*6 != length($1) ) { print; ## It must be a multiple of 6
} else {
$out = $1;
print LOGFILE "EFFRG=\"$1\" changed to ";
$out =~ s/(\d{6})/$1 /g; ## put in the spaces
$out =~ s/(\d{6}) $/$1/g; ## take out the last one
s/(effrg=")\d+"/$1$out"/gi; ## fix the original line
print LOGFILE "$1$out\"\n";
print;
}
} elsif (/(effrg="\d{6}")/i) {
print LOGFILE "$1 left unchanged\n";
print;
} else { print; }
}
} else { print "\nUsage : effrg.pl sgml_file_name > output_file_name\n";
print "Takes an SGML file and splits the EFFRG attribute into blocks of 6 digits\n";
print "Currently treats the EFFRG attribute in the effect,sbeff,coceff & aclist tags\n";
print "Generates the effrg.log file showing actions taken\n";
}
************************************************************
But when I tried to execute it, it came up this message :
bash: ./effrg.pl: No such file or directory
I've already put the file in the same directory and chmod to 775. Any idea what's wrong of the script?
Cheers,
Hendra