I want to further process two files so i wrote the code like this

use POSIX; use List::Util qw[min max]; use English; use Getopt::Long; use File::Basename; use autodie; my ($help,$csv_add, $csv_flex); GetOptions ( "csv_add=s" => \$csv_add, "csv_flex=s" => \$csv_flex, "help" => \$help ); if ($help || !$csv_add || !$csv_flex ) { die " Description: Provide the csv_add and csv_flex Usage $0 \t-csv_add <path> -csv_flex <path> : full csv file paths "; } print "$csv_add\n"; print "$csv_flex\n"; open (CSVADD_FILE,"$csv_add") or die "Could not open $csv_add in read +mode OR there is no file with name $csv_add"; open (CSVFLEX_FILE,"$csv_flex") or die "Could not open $csv_flex in re +ad mode OR there is no file with name $csv_flex"; #removing the spaces between the fields of csv open(STDOUT, "+>csv_add_up"); rm_spaces(\*CSVADD_FILE); close STDOUT; open(STDOUT, "+>csv_flex_up"); rm_spaces(\*CSVFLEX_FILE); close STDOUT; #chomp removes any new line character at the end of line and can retur +n number of elements removed #remove spaces and /I/0 and /T/0 sub rm_spaces { my $file = shift; while (<$file>) { chomp; my @fields = split /,/; s/\s+//g for @fields; s/\/I\/0//g for @fields; s/\/T\/0//g for @fields; print join ",", @fields,"\n"; } }

Please suggest on how to make a single function that does the work of rm_spaces() and takes different files.


In reply to Re^2: Inline change to the file passed by Glob by jagtar
in thread Inline change to the file passed by Glob by jagtar

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.