in reply to Bash script to perl script

Hi acrobat118,

Here's a rough outline of what you'll need:

  1. Read a file and loop over its lines: "Files and I/O" in perlintro (also covers how to write to an output file)
  2. Act only on lines that match a pattern (grep): "Regular expressions" in perlintro
  3. Break a line into columns (awk): split, e.g. my @F = split; splits the current line $_ on whitespace; the first column is then $F[0], second column $F[1], etc.
  4. Operate only on lines that match certain conditions (awk): "Conditional and looping constructs" in perlintro and the section following it "Builtin operators and functions"
  5. Adding the resulting items to an array: push (for a more advanced approach see "arrays of arrays" in perldsc)
  6. Sorting the array: sort and "How do I sort an array by (anything)?" in perlfaq4

Try using this information to write some code, and if you run into trouble feel free to ask here.

Hope this helps,
-- Hauke D

Update: Expanded post slightly.