I have copied the content of file.txt to myoutput.txt manually and then trying to compare two files when executing above program; getting below error print() on closed filehandle DATA#!/usr/bin/perl use strict; use warnings; use Getopt::Long; use Opsware::NAS::Connect; use File::Compare; my $hostname = $ARGV[0]; my @output; my $con = Opsware::NAS::Connect->new(-user => "admin", -pass => "pass +word", -host => $hostname, -port => "8023"); $con->login(); @output = $con->cmd("help list acl"); open(DATA, "+>", "file.txt") or die "Couldn't open: $!"; select DATA; print join("\n", @output); close DATA; my $file1 = "C:\\newperl\\myoutput.txt"; my $file2 = "C:\\newperl\\file.txt"; if (compare("$file1","$file2") == 0) { print "They're equal\n"; } else { print "failed\n"; } $con->logout(); undef $con; exit(0)
In reply to Getting error when trying to compare two files by adalamre
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |