CGI/Perl Guide | Learning Center | Forums | Advertise | Login
Site Search: in

  Main Index MAIN
INDEX
Search Posts SEARCH
POSTS
Who's Online WHO'S
ONLINE
Log in LOG
IN

Home: Perl Programming Help: Beginner: Re: [FishMonger] removing all lines that contain the asterisk: Edit Log



goudeuk
Novice

May 9, 2014, 8:02 AM


Views: 10201
Re: [FishMonger] removing all lines that contain the asterisk

Hi fishmonger

I am trying to save the output to a new file like this:


Code
my $file = 'passwd.global';  
open my $fh, '<', $file or die "failed to open '$file' <!>";
while ( <$fh> ) {
my ($user, $name) = (split /:/)[0,4];
print $fh "$user\t$name\n" unless $user =~ /\*/;
}
close $fh;


Code
 
But I can't get it work. Could you please let me know how can I save the output into passwd.global or in a newly created file?
Or direct me to a relative tutorial.

Many thanks for your help


(This post was edited by goudeuk on May 9, 2014, 8:06 AM)


Edit Log:
Post edited by goudeuk (Novice) on May 9, 2014, 8:06 AM


Search for (options) Powered by Gossamer Forum v.1.2.0

Web Applications & Managed Hosting Powered by Gossamer Threads
Visit our Mailing List Archives