On Thu, Mar 29, 2012 at 6:08 PM, John W. Krahn <jwkr...@shaw.ca> wrote:
> my wrote:
>>
>> The goal of this assignment is to put in practice the list and I/O
>> functionalities implemented by Perl.
>>
>>
>>
>> Write a program that will read a list from a file (input), will sort
>> the list in lexical order and write back the sorted list to another
>> file (output).  You can use arrays and any of the Perl built-in
>> functions learned so far to solve this problem.
>>
>>
>>
>> this it what i have
>>
>> #!/bin/perl
>>
>>
>> open ( PWFILE, "/etc/passwd" ) ;
>> open ( NEWPWFILE , ">  /tmp/newpasswd" ) ;
>>
>> @lines =<HELLO>  ; this is how you sort the line;
>>
>> while ( $line =<PWFILE>  ) {
>>    print NEWPWFILE "@line" ;
>>    print @lines
>> }
>>
>> close ( PWFILE ) ;
>> close ( NEWPWFILE ) ;
>>
>> need help finish it  and need how to with the sort code and finish it
>
>
> #!/usr/bin/perl
> use warnings;
> use strict;
>
> open PWFILE,    '<', '/etc/passwd'     or die "Cannot open  because: $!";
> open NEWPWFILE, '>',  '/tmp/newpasswd' or die "Cannot open  because: $!";
>
> print NEWPWFILE sort <PWFILE>;

I didn't know "sort" can do this way.

Thanks,
>
> __END__
>
>
>
> John
> --
> Any intelligent fool can make things bigger and
> more complex... It takes a touch of genius -
> and a lot of courage to move in the opposite
> direction.                   -- Albert Einstein
>
>
> --
> To unsubscribe, e-mail: beginners-unsubscr...@perl.org
> For additional commands, e-mail: beginners-h...@perl.org
> http://learn.perl.org/
>
>

--
To unsubscribe, e-mail: beginners-unsubscr...@perl.org
For additional commands, e-mail: beginners-h...@perl.org
http://learn.perl.org/


Reply via email to