az noted sAN duz not wrk & ***SHOUTING*** duz not hlp U 2 git Ansz. az we hav d luxury of full [abc]z 2 typ w & usrz 4 huM eng iz not thR 1st lngwij UzN SMS shrt& iz gnrle :-(D upon
transl8it here.
Look below when you post and you will see some Writeup Formatting Tips. In Tutorials there are lots of how to ask questions the smart way hints.
Anyway you are obviously on windows and seem to want to apply to power of Perl to automating some stuff for you. Perl can do everything a .bat batch file can and lots more.
To get windows to run a perl script you just make a text file that contains perl code and save it with a .pl extension. If you type script.pl at the command line windows looks at the .pl extension and knows you want perl to execute the script using the perl executable. You can also type C:\>perl script which explicitly tells windows to execute the file <scipt> using perl and lets you call the script anything you want, using any extension you feel like. As a rule .pl makes sense so use it.
In unix the shebang line tells the shell where to find perl. In your application the only significant thing on the usual first line of a perl script (called the shebang line) is the -w flag which switches on warnings. Any script you write should probably start like this:
#!/usr/bin/perl -w
use strict
This switches on warning and strict which makes you write code where perl catches lots of errors for you.
To execute an external binary perl gives you three options. backtics, system and exec. You can RTFM to find out the finer details.
#!/usr/bin/perl -w
use strict;
my $prog = "C:\\path\to\\RNAfold";
my $infile = "C:\\path\\to\\infile";
my $outfile= "C:\\path\\to\\outfile";
my @args = qw/ -p noOUTPUTFILE /;
print "Executing with one arg system\n";
my $return_value = system("$prog $infile $outfile");
if ($return_value == 0) {
print "Success!\n";
}
else {
printf "Failed with error code %d\nError message: $?\n",
$return_value>>8;
}
print "Executing with muti arg system\n";
$return_value = system($prog, $infile, $outfile);
# or
$return_value = system($prog, @args);
# check how it went by checking return_value as above
print "Executing $prog $infile $outfile with backtics\n";
my $screenoutput = `$prog $infile $outfile`;
print "Got $screenoutput\n";
# check how it went by checking $?
die "Got error $?\n" if $?
|