Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Perl Expert.. Pls help

Status
Not open for further replies.

hendnov

Technical User
Feb 27, 2006
73
AU
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
 
Modify the bang line:
#! /home/SOFTS/Perl/5.8.0/bin/perl -w
with the right location of your perl executable

Hope This Helps, PH.
Want to get great answers to your Tek-Tips questions? Have a look at FAQ219-2884 or FAQ181-2886
 
Bash isn't finding your script. You don't have this directory in your [tt]PATH[/tt]. You also don't have a dot in your path to run things in your current working directory. Do this in your [tt].profile[/tt]...
Code:
PATH=${PATH}:/where/that/script/is
PATH=${PATH}:.
export PATH
Hope this helps.
 
I think PHV is right - I changed my bang line to what you had, and got this:
Code:
ksh: testscript.pl:  not found
(I use Korn Shell instead of bash)

Looks like the same type of error.
To find what the path should be, do this:
Code:
which perl
/usr/local/bin/perl
So I know my first line should be:
Code:
#!/usr/local/bin/perl -w
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top