Loading ...
Sorry, an error occurred while loading the content.

RE: [PBML] Adding quotes to end of array value

Expand Messages
  • Charles K. Clarkson
    ... FYI: print won t end the program. Try using die instead. Perl will tell you some information about the error if you include its standard error message
    Message 1 of 2 , May 1, 2003
    • 0 Attachment
      Karalius, Joseph <Joseph.Karalius@...> wrote:

      : #!/usr/bin/perl -w
      :
      : use strict;
      :
      : # Print title of program
      : print "\n\n";
      : print "***********************************\n";
      : print "* CLONE IMPORT TOOL FOR IMAGE *\n";
      : print "***********************************\n";
      : print "\n";
      :
      : #Determine number of lanes in gel
      :
      : print "\nEnter number of lanes in gel: ";
      : my $gelmaxlane = <STDIN>;
      : chomp $gelmaxlane;
      : print "You entered $gelmaxlane.\n";
      :
      : #Determine number of lanes between markers
      :
      : print "\nEnter spacing of marker lanes: ";
      : my $markerspace = <STDIN>;
      : chomp $markerspace;
      : print "You entered $markerspace.\n";
      :
      : #Get filename containing clones in gel
      :
      : print "\nEnter filename containing clone names: ";
      : my $clone_list = <STDIN>;
      : chomp $clone_list;
      :
      : # open the file or exit
      : unless ( open(CLONES, $clone_list) ) {
      : print "Cannot open file \$clone_list\"\n\n";
      : }

      FYI:
      'print' won't end the program. Try using 'die'
      instead. Perl will tell you some information about
      the error if you include its standard error
      message $! at the end of the line. Don't put a \n
      after it, though. The most common idioms seem to
      be:

      open(CLONES, $clone_list) || die "Cannot open '$clone_list': $!";

      Or:

      open CLONES, $clone_list or die "Cannot open '$clone_list': $!";


      : print "\nEnter name of file to output to: ";
      : my $cloneout = <STDIN>;
      : chomp $cloneout;
      :
      : # open the file or exit
      : unless ( open(CLONEOUT, "+>$cloneout") ) {
      : print "Cannot open file \$clone_out\"\n\n";
      : }
      :
      : my @clonenames = <CLONES>;

      Go ahead and get rid of the line endings here:
      chomp( my @clonenames = <CLONES> );

      : # print @clonenames; #debugging
      :
      : my $lane = 0;
      : my $clonenum = 0;
      : my $marker = $markerspace;
      : # print "$marker\n"; #debugging
      :
      : print CLONEOUT "NAMES\n"; # print file header
      : print "NAMES\n"; # print file header
      :
      : while ( $lane < $gelmaxlane )
      : {
      : print CLONEOUT "$lane ";
      : print "$lane ";
      : if ( $marker < $markerspace )
      : {
      : # chomp $clonenames[$clonenum]; #debugging
      : # print $clonenames[$clonenum]; #debugging
      : my $cline = '+ "' . $clonenames[$clonenum] . '"';
      : #chomp $cline; #debugging
      : print CLONEOUT "$cline";
      : print "$cline";


      The line endings are gone. Let's put them back:

      my $cline = qq(+ "$clonenames[$clonenum]"\n);
      print CLONEOUT $cline;
      print $cline;

      : $clonenum += 1;
      : $marker += 1;
      : }

      HTH,


      Charles K. Clarkson
      --
      Head Bottle Washer,
      Clarkson Energy Homes, Inc.
      Mobile Home Specialists
      254 968-8328
    Your message has been successfully submitted and would be delivered to recipients shortly.