Hi
I have a problem with a perl program that I have been writing. I have so far managed to pass in the contents of an external file and have it displayed on the screen in a structured way. The file is meant to be a bit like a message board. I now want to sort the messages by a certain field such as email, name or subject but I am completely unsure on how to do this. I know that I need to use the Sort function but everytime I try and use this it doesnt work. I have copied below the code that works for the displaying of the file.
#!/usr/bin/perl
use strict;
use warnings;
use CGI "Vars";
my ($filename, @all, $list, @items, $item);
$filename = "msgs";
open(MYFILE,"< $filename");
@all=;
$list ="@all";
@items = split /__FINISH__\n/ , $list;
for my $item (@items)
{
my($name, $email, $subject, $text) =split /\n/, $item, 4;
print "Name:- $name\n";
print "Email:- $email\n";
print "Subject:- $subject\n";
print "Message:- $text\n";
}
Thank You
I have a problem with a perl program that I have been writing. I have so far managed to pass in the contents of an external file and have it displayed on the screen in a structured way. The file is meant to be a bit like a message board. I now want to sort the messages by a certain field such as email, name or subject but I am completely unsure on how to do this. I know that I need to use the Sort function but everytime I try and use this it doesnt work. I have copied below the code that works for the displaying of the file.
#!/usr/bin/perl
use strict;
use warnings;
use CGI "Vars";
my ($filename, @all, $list, @items, $item);
$filename = "msgs";
open(MYFILE,"< $filename");
@all=;
$list ="@all";
@items = split /__FINISH__\n/ , $list;
for my $item (@items)
{
my($name, $email, $subject, $text) =split /\n/, $item, 4;
print "Name:- $name\n";
print "Email:- $email\n";
print "Subject:- $subject\n";
print "Message:- $text\n";
}
Thank You