See Tutorials: Context in Perl: Context tutorial
split, in scalar context, returns the number of fields found, so you need to use list context
See also autodie and Modern Perl: the free book
#!/usr/bin/perl -- #~ 2011-10-19-05:27:59PDT by Anonymous Monk #~ perltidy -csc -otr -opr -ce -nibc -i=4 use strict; use warnings; use autodie; # dies if open/close... fail Main( @ARGV ); exit( 0 ); sub Main { if ( @_ == 2 ) { NotDemoMeaningfulName(@_); } else { Demo(); print '#' x 33 ,"\n", Usage(); } } ## end sub Main sub NotDemoMeaningfulName { my( $transaction, $res ) = @_; open my($in), '<', $transaction; open my($re), '>', $res; while( <$in> ){ my( $left, $right ) = split /T/, $_, 2; print $re $left; } close $in; close $re; } ## end sub NotDemoMeaningfulName sub Usage { <<"__USAGE__"; $0 $0 dataFile newDataFile perl ${\__FILE__} perl ${\__FILE__} dataFile newDataFile __USAGE__ } ## end sub Usage sub Demo { my ( $Input, $WantedOutput ) = DemoData(); NotDemoMeaningfulName( \$Input, \my $Output ); require Test::More; Test::More::is( $Output, $WantedOutput, ' NotDemoMeaningfulName Works Aas Designed' ); Test::More::done_testing(); } ## end sub Demo sub DemoData { my $One = <<'__One__'; 2010-12-01T21:15:40.000+01:00 2010-12-01T23:28:04.000+01:00 __One__ my $Two = <<'__Two__'; 2010-12-01 2010-12-01 __Two__ return $One, $Two; } ## end sub DemoData __END__
In reply to Re: split line from one point
by Anonymous Monk
in thread split line from one point
by Anonymous Monk
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |