Andrej Kastrin wrote:
> Dear Perl community,

Hello,

> I need to re-sort a set of data. I think that the below example is self
> explained; so which Perl structure should I use to handle this dataset?
> 
> Thanks in advance for any suggestion, Andre
> 
> 
> 2;John;Apple;Banana
> 3;Andrew;Pear;Apple;Melon;Orange
> 8;Susan;Pear;Melon
> 
> 2;John;Apple
> 2;John;Banana
> 3;Andrew;Pear
> 3;Andrew;Apple
> 3;Andrew;Melon
> 3;Andrew;Orange
> 8;Susan;Pear
> 8;Susan;Melon

#!/usr/bin/perl
use warnings;
use strict;

print
    sort
    map {
        chomp;
        my ( $number, $name, @fruit ) = split /;/;
        map "$number;$name;$_\n", @fruit;
        }
    <DATA>;

__DATA__
2;John;Apple;Banana
3;Andrew;Pear;Apple;Melon;Orange
8;Susan;Pear;Melon




John
-- 
use Perl;
program
fulfillment

-- 
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
<http://learn.perl.org/> <http://learn.perl.org/first-response>


Reply via email to