any ideas on how to Print the converted values out into another tab-delimited file of equal dimensions

Just open an output file, and print to that file handle, instead of printing to (the default) STDOUT; that is:

... open OUT, ">", "outfile.name" or die "outfile.name: $!\n"; ... print OUT $DNA_conc; # and so on...
Or, you could just use redirection on the shell command line, but for that to be effective, you want to use @ARGV for user input to the script, rather than printing a prompt to ask for input -- that is:
# don't do this: # print " Enter the number. \n"; # chomp ($df = <STDIN>); # do this instead: die "Usage: $0 multiplier_value\n" unless ( @ARGV == 1 and $ARG[0] =~ /([\d.]+)/ ); my $df = $1;
(The sanity check on the @ARGV value is not exactly a perfect one for checking that a string is a valid numeric -- e.g. it won't accept negative numbers -- but it's more than what you've been doing so far, and every little bit helps.)

Doing it that way, your shell command line would go like this, to set the value (e.g. to "10.5") and redirect output to some other file:

your_script_name 10.5 > outfile.name
As a rule, it makes sense to use @ARGV for the input file name too -- in fact, perl defaults to reading file names given as command-line args. I would do your script like this:
#!/usr/bin/perl use strict; use Regexp::Common; die "Usage: $0 multiplier_number [input.file]\n" unless ( @ARGV and $ARGV[0] =~ /^$RE{num}{real}$/ ); my $df = shift; # take the numeric arg off @ARGV while (<>) # read from STDIN, or from file(s) named in @ARGV { if ( ! /^\s*(?:$RE{num}{real}\s+)+$/ ) { # if line has non-numer +ics print; } else { my @vals = map { $_ * $df * 50 } split; print join( "\t", @vals ), "\n"; } }
That also uses a better method of checking for numbers. Run it like this:
script_name 10 input.txt > 10_x_50_x_input.txt

In reply to Re^6: handling tab delimited files by graff
in thread handling tab delimited files by shaludr

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.