http://www.perlmonks.org?node_id=1008720


in reply to process a file and reading a line and passing the values to another sub function

ok, finally i found out that we can use split function to put the comma seperated line into array element.

</codesub readout_file { my ($filename) = @_; my (@linecolumns); open my $fh, '<', $filename or die "can't open file:$!"; while (<$fh>) { chomp; ~s/ /,/g; ## OR s/ /,/g; if you want print $_, $/; @linecolumns = split(',',$_); #print $_, $/; ## OR any other subroutine you want print $linecolumns[0],$/; print $filename, $/; } }
  • Comment on Re: process a file and reading a line and passing the values to another sub function
  • Download Code