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: [anishkumarv] Overwrite is not working?: Edit Log



g4143
Novice

Apr 11, 2013, 5:38 AM


Views: 492
Re: [anishkumarv] Overwrite is not working?

I noted that this


Code
close DIR;


should be


Code
closedir DIR;


I logged in as root and tried this and it worked.


Code
#!/usr/bin/perl 
use strict;
use warnings;
use autodie qw/open close/;
use diagnostics;

chdir("/var/log") or die "$!";
opendir (my $DIR, ".") or die "$!";

my @files = grep {/secure*?\.*/} readdir $DIR;
closedir $DIR;

open(my $OFILE, ">>", "data.txt");

foreach( @files )
{
if ( -r $_ )
{
open(my $IFILE, "<", $_);

while ( <$IFILE> )
{
print {$OFILE} $_;
}

close($IFILE);
}
}

close($OFILE);

__END__



(This post was edited by g4143 on Apr 11, 2013, 5:40 AM)


Edit Log:
Post edited by g4143 (Novice) on Apr 11, 2013, 5:40 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