package Cisco::Utils::Internal::PrintLogConsole; $VERSION = 0.02.09; @EXPORT_OK = qw(PrintLogConsole); use strict; use base 'Exporter'; sub PrintLogConsole { my ($file, $aRefMssgItems) = @_; open(FH, "> $file") or return "Error opening $file: $!\n"; for(@$aRefMssgItems){ print "$_\n"; print(FH "$_\n") or return "Error printing to $file: $!\n"; } close FH or return "Error closing $file: $!\n"; } 1; =head1 NAME PrintLogConsole =head1 SYNOPSIS PrintLogConsole is intended for use by Cisco::Utils modules. It's not meant for use directly from Perl scripts, and it's interface may change at any time without notice. PrintLogConsole accepts a list of two elements. The first is a scalar of the file to print to. The second is an array reference of the message(s) to print. #!/usr/bin/perl -w use strict; use Cisco::Utils::Internal::PrintLogConsole qw(PrintLogConsole); my $logfile = './file.log'; my @msgs = ( "Starting program run", "La-la-la...", "Humina humina...", ); my $response = PrintLogConsole($logfile, \@msgs); unless ($response = 1) { print $response; exit; } =head1 UPDATE 2001-11-17 22:25 CDT Original working code. =head1 TODO Figure out enough h2xs to package this module for distribution. =head1 BUGS None that I know of. =head1 REQUIRES Nothing aside from Perl. =head1 AUTHOR ybiC =head1 CREDITS Thanks to Petruchio for kickstarting me into modulitazing my Ciscoey scripts. And to jcwren for scalar+array passing tips. And to vroom for PerlMonks. =cut