In order to help you proceed, it would be very kind of you to provide the following:
1) What is that first command line parameter supposed to be? You can simply give me a string to use, or better, if you have time, also explain what it is supposed to be in a more conceptual manner.
2) Where in your script were you expecting to read in the lines from your two files and process them?
We can solve this problem, but to do so we must BOTH understand what is going on. YOU possess the knowledge of what is to be done. WE possess the knowledge of how you can get it done in Perl. But we haven't connected these two bits of knowledge yet, and we must do that in order to make useful progress.
OBSERVATIONS:
- In your opening note, you mention two input files. I don't see you opening
any two files for input in the Perl script. If you want to read multiple lines from a file, you generally have to open it and read the lines in a loop. Sort of like this:
#!/usr/bin/perl -w
use strict;
if (open INPFIL, "<file1.dat")
{
# File opened. Proceed.
while (my $inpbuf = <INPFIL>)
{
# Next line from input file
chomp $inpbuf;
&processInputLine($inpbuf);
}
# Cleanup
close INFPIL;
}
exit;
- In your script, you blindly absorb two parameters from the command line without explanation or recourse. I get it; you wrote the code, you know what needs to go on the command line. But you didn't pass that information along with the code, so I don't know what to put in there. I can see the second parameter needs to be a filename, and further deduce we will be writing something to that file. But there's no clue at all for an outsider to understand what is to be supplied with the first parameter. I like to give the user options:
#!/usr/bin/perl -w
use strict;
# Grab command line parameters
my ($seqcod, $outfnm) = @ARGV;
# Avoid Perl warnings about undefined values
if (!defined $seqcod) { $seqcod = ''; }
if (!defined $outfnm) { $outfnm = ''; }
# Ask user to supply missing parameters. Exit if user just presses En
+ter.
if ($seqcod =~ /^\s*$/)
{
print " Sequence Code: ";
$seqcod = <STDIN>;
}
if ($seqcod =~ /^\s*$/)
{
exit;
}
if ($outfnm =~ /^\s*$/)
{
print "Output Filename: ";
$outfnm = <STDIN>;
}
if ($outfnm =~ /^\s*$/)
{
exit;
}
# All parameters verified. Proceed.
&doTheRealWork($seqcod, $outfnm);
exit;
I await your reply that we may proceed.
edit: The script does open one file for read, but it does not open two.
-
Are you posting in the right place? Check out Where do I post X? to know for sure.
-
Posts may use any of the Perl Monks Approved HTML tags. Currently these include the following:
<code> <a> <b> <big>
<blockquote> <br /> <dd>
<dl> <dt> <em> <font>
<h1> <h2> <h3> <h4>
<h5> <h6> <hr /> <i>
<li> <nbsp> <ol> <p>
<small> <strike> <strong>
<sub> <sup> <table>
<td> <th> <tr> <tt>
<u> <ul>
-
Snippets of code should be wrapped in
<code> tags not
<pre> tags. In fact, <pre>
tags should generally be avoided. If they must
be used, extreme care should be
taken to ensure that their contents do not
have long lines (<70 chars), in order to prevent
horizontal scrolling (and possible janitor
intervention).
-
Want more info? How to link
or How to display code and escape characters
are good places to start.
|