# loop through every file named on the command line, setting # $_ to each successive line while (<>) { chomp; # remove any line ending (implicitly uses $_) # ... aha! the interesting part goes here my @fields = split /\|/; # implicitly uses $_ # Now we have the values for this row in $fields[0], $fields[1], ... # write to STDOUT print join( ',', @fields ), "\n"; }