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: print if defined statement to file: Edit Log



regex2012
User

Apr 19, 2016, 9:23 AM


Views: 2086
print if defined statement to file

I am trying to print this to a file:

Code
open my $FH2, '<', '/tmp/testq.txt' or die "unable to open file 'file' for reading : $!"; 
open my $FH6, '>', '/tmp/tst.txt' or die "unable to open file 'file' for reading : $!";
my %duplicates;
while (<$FH2>) {
print if defined "$duplicates{$_},";
$duplicates{$_}++;
}

but I haven't been able to . I am not sure where to indicate the file handle in this statement to get it to print the duplicate line to /tmp/tst.txt.

Can anyone help?


(This post was edited by regex2012 on Apr 19, 2016, 9:24 AM)


Edit Log:
Post edited by regex2012 (User) on Apr 19, 2016, 9:24 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