Assuming that the text is put into a single variable $info, then you can split it into separate lines using the intrinsic perl split function:
my @lines = split("\n", $info);
where @lines is an array of your lines. The "\n" is the regex for a newline. You can loop through each line as follows:
foreach (@lines) {
$line = $_;
# do something with $line....
}
You can then split each line on whitespace (regex \s+, where the \s is one whitespace character, and the + means 1 or more times):
@fields = split("\s+", $line);
and you can then access each field directly via its array index: $field[0], $field[1] etc.
or, you can do:
($var1, $var2, $var3, $var4) = split("\s+", $line);
which will put the fields in each line into seperate named variables.
Now - if you want to sort your lines by the character in the third column, you could do this:
my @lines = split("\n", $info);
my @arr = (); # declare new array
foreach (@lines) {
my @fields = split("\s+", $_);
push(@arr, \@fields) # add @fields REFERENCE to @arr
}
Now you have an "array of arrays". This can easily be sorted as follows:
@sorted = sort { $a->[2] <=> $b->[2] } @arr;
which will sort @arr by the 3rd element (index 2) of @fields.
Edit 2 To put lines with the same third column into their own variables, do this:
my %hash = (); # declare new hash
foreach $line (@arr) { # loop through lines
my @fields = @$line; # deference the field array
my $el = $fields[2]; # get our key - the character in the third column
my $val = "";
if (exists $hash { $el }) { # check if key already in hash
my $val = $hash{ $el }; # get the current value for key
$val = $val . "\n" . $line; # append new line to hash value
} else {
$val = $line;
}
$hash{ $el } = $val; # put the new value (back) into the hash
}
Now you have a hash keyed with the third column characters, with the value for each key being the lines that contain that key. You can then loop through the hash and print out or otherwise use the hash values.