I'll give you a hint.  This is perfectly legal:

my @array = <STDIN>;

Let me know if you still can't figure it out.

-----Original Message-----
From: Grant Hansen [mailto:[EMAIL PROTECTED]]
Sent: Friday, September 20, 2002 6:03 PM
To: [EMAIL PROTECTED]
Subject: Help on Arrays - Beginner


Hello All,

I am new to Perl and I will admit up front this is for a Perl course.  
However, the course is online and thus timely communication from the 
instructor is not always possible, so I am hoping someone will steer me in 
the right direction.

The assignment has to do with taking a file, and reading it to <STDIN>, 
modifying each line, sort and then print.

Here is the Input:

Grant Hansen
Dave Thomas
Roger Starbauch

Here is the intended output:

Hansen, Grant
Starbauch, Roger
Thomas, Dave

Here is my code:

while(<STDIN>) {
     chomp(@lines = split);
     @lines1 = $lines[1] . ", " .  $lines[0];
     @lines2 = sort (@lines1);
     print "@lines2 \n";
}

My code is not sorting correctly and I know why (I sort after each line of 
input), I just don't know how to fix it.

Any help is appreciated.

-- 
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

-- 
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to