in reply to Re^3: Seperating individual lines of a file
in thread Seperating individual lines of a file
But this produces a syntax error of#!/usr/bin/perl # set $listfile to some constant, or to $ARGV[0] (and supply the file #+name # as a command-line arg when you run the script) my %outfh; # hash to hold output file handles open ORIGFILE, $ARGV[0] or die "$ARGV[0]: $!"; while ( <ORIGFILE> ) { my ( $host, $data ) = split " ", $_, 2; if ( ! exists( $outfh{$host} )) { open( $outfh{$host}, ">", $host ) or die "$host: $!"; } print $outfh{$host} $data; } # perl will flush and close output files when done
It seems to not like theScalar found where operator expected at ./nocsplit.pl line 17, near "} + $data" (Missing operator before $data?) syntax error at ./nocsplit.pl line 17, near "} $data" Execution of ./nocsplit.pl aborted due to compilation errors.
print to $outfh{$host} $data;
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^5: Seperating individual lines of a file
by Not_a_Number (Prior) on Feb 03, 2006 at 20:14 UTC | |
|
Re^5: Seperating individual lines of a file
by blazar (Canon) on Feb 05, 2006 at 07:58 UTC |