#!/usr/bin/perl use strict; use warnings; my $file = '1140475.txt';; open my $raw, '<', $file or die "open: $!"; open my $out, '>', "out_$file" or die "close: $!"; while ( my $line = <$raw> ) { chomp( $line ); my @splits = split ( ',', $line ); print $out "First line, first field: $splits[0]\n"; last; } close $out or die "close: $!"; __END__ #### $ cat out_1140475.txt First line, first field: 1424621700 #### #!/usr/bin/perl use strict; use warnings; use Path::Tiny qw/ path /; my $file = '1140475.txt'; my $first = ( split ',', (path($file)->lines( {chomp => 1, count => 1} ))[0] )[0]; print "$first\n"; __END__ #### $ perl 1140475-2.pl 1424621700 $