develooper Front page | perl.beginners | Postings from March 2012

Re: hey need hep on this please

Thread Previous | Thread Next
From:
John W. Krahn
Date:
March 29, 2012 03:08
Subject:
Re: hey need hep on this please
Message ID:
4F743480.1050100@shaw.ca
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>;

__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

Thread Previous | Thread Next


nntp.perl.org: Perl Programming lists via nntp and http.
Comments to Ask Bjørn Hansen at ask@perl.org | Group listing | About