A few hints:
my ($infile, $outfile, $indent) = @ARGV; # Use my for better scoping $infile ||= "default_infile"; # For a default value, in case none is supplied; # if the value is required, die if it doesn't exist; $outfile ||= "default_outfile"; $indent ||= "20"; # Rather than using the order of arguments, # you might like Getopt::Long instead. # It gives you good option-checking, and # dies if any options are missing or otherwise ungood. open(IN, $infile) or die "Can't open input file: $!"; # Good. You're checking the returns of every system call. open(OUT, ">$outfile") or die "Can't open output file: $!"; # A little easier to read with variable interpolation print "Starting..."; select (OUT); # So you don't have to type the filehandle name all the time print "<%\n"; $indent = ' ' x $indent; # To save the time required to recompute this; # if you're using the value of $indent later, just say # length($indent), or save this in a separate variable print "${indent}Response.Write(",($_ ? "$_ +" : ""),"vbNewLine)\n" wh +ile(chomp ($_ = <IN>)); # Using var interpolation and quick if (?:), # you can combine all this into one print # statement; chomp can be put inside the while # condition; then, since you have a one-statement # while loop, you can use the alternate syntax # to avoid messy braces print "%>\n"; print STDOUT "Done."; # You could also do select(STDOUT); first close IN or die "Can't close input file: $!"; close OUT or die "Can't close output file: $!";
See also: perlfunc, perlsyn, perlop, and Getopt::Long.

In reply to Re: A simple input/output script, suggestions wanted by premchai21
in thread A simple input/output script, suggestions wanted by patgas

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.