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
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |