On 10/2/07, Beginner <[EMAIL PROTECTED]> wrote: > Ideally I want to create the log file outside any sub routines so > that $log to be available to any sub I have created and hence not > scoped to any one sub routine.
In other words, $log needs to be a global variable, so that it's available everywhere in your program. > #!/bin/perl > > package Images; > > use strict; > use warnings; > use vars qw($log); So, you're declaring the global variable $Images::log. > $| = 1; Are you meaning to affect STDOUT with this statement? It doesn't affect your log. > our $log; And here, you seem to be declaring $Images::log again. You shouldn't need 'use vars' if you use 'our', mostly. > my $logpath = 'mylog.txt'; > open($log,">>$logpath") or die "Can't append to $logpath: $!\n"; > > > sub mysub { > > my $var = 'Hello'; > print $log "Starting mysub with val\n"; > > } Did you ever use $var? I don't think it's needed. Did you ever call that subroutine? If you do, I think you'll find data in the logfile. Hope this helps! --Tom Phoenix -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] http://learn.perl.org/