http://www.perlmonks.org?node_id=904829


in reply to Re^4: string value assignment
in thread string value assignment

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:

  1. 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;
  2. 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.