Hello, i'm working on this program that opens a file reads its content line by line and replaces commas with pipes; then graps a string and format it to put it into another file. I'm not sure it fI should be using an array with this program to do the formatting of $var7 field or could it be done the way, I have it now. Could you give me any suggestions on how to handle a string formatting.
print "#! perl -w use strict; #use File::Find; #use File::Copy cp; sub parse_file { my $string1; my $string2; my $string3; my $finstring; open(IN, '<c:/doclist.chr') or die "Couldn't open file, $!"; open(OUT, '>c:/doclist.txt') or die "Couldn't open file, $!"; ## print OUT join '|', split /,/ while <IN>; while(<IN>) { chomp; # Remove the newline my ($var1, $var2, $var3, $var4, $var5, $var6, $var7) = split /, +/; $string1 = $var7; substr($string1, 24) = "H:\"; $string2 = substr($string1,25,2); $string3 = substr($string1,-13); $finstring = $string1.$string2.$string3; print OUT "$var1,"|",$var2,"|",$var3,"|",$var4,"|",$var5,"|",$v +ar6,"|",$finstring," \n"; } exit; } \n";

In reply to Open file & Strip comma delimiter by skyler

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.