enkiki has asked for the wisdom of the Perl Monks concerning the following question:
Hello all, I'm trying to pass arguments in a subroutine. The first argument is passed successfully but the second doesn't work. Here is the code I wrote. any help would be greatly appreciated!
EXTRACT_FIRST_COLUMN(my $TEMPCSV = 'C:\temp\part1.csv', my $TEMPTXT = +'TEMP_AM.txt', my $FINALCSV = 'C:\temp\OUT.CSV'); EXTRACT_FIRST_COLUMN(my $TEMPCSV = 'C:\temp\part2.csv', my $TEMPTXT = +'TEMP_CA.txt', my $FINALCSV = 'C:\temp\OUT2.CSV'); sub EXTRACT_FIRST_COLUMN { my $csv = Text::CSV->new(); open (FILE,">","$TEMPTXT"); open (CSV, "<", $TEMPCSV); while (CSV>) { if $csv->parse($_)) { my @column = $csv-> fields(); print FILE "$column[0]\n"; } else { my #err = $csv->error_input; print "ERROR: Failed to parse line: $err"; } } close (FILE); open (OUTPUT2,">","$FINALCSV); my $file = $TEMPTXT; open (my $FH, "<", $file) or die $!; while <$fh>) { my $uri = $_; $uri =~ s/\s+//g; my ($name, $aliases, $addrtype, $length, @addrs) = gethostbyname $uri; my ($w,$x,$y,$z) = unpack('C4',$addr[0]); print OUTPUT2 "$w.$x.$y.$z\n"; } close (OUTPUT2); } sub EXTRACT_FIRST_COLUMN();
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: Passing arguments in a subroutine
by davido (Cardinal) on Apr 12, 2015 at 05:43 UTC | |
|
Re: Passing arguments in a subroutine
by AnomalousMonk (Archbishop) on Apr 12, 2015 at 06:28 UTC | |
|
Re: Passing arguments in a subroutine
by vinoth.ree (Monsignor) on Apr 12, 2015 at 06:39 UTC | |
by AnomalousMonk (Archbishop) on Apr 12, 2015 at 06:56 UTC |