Wiggins d'Anconia <[EMAIL PROTECTED]> writes:
> "The file must return true as the last statement to indicate
> successful execution of any initialization code, so it�s customary to
> end such a file with "1;" unless you�re sure it�ll return true
> otherwise. But it�s better just to put the "1;", in case you add more
> statements."
Maybe unrelated to the comments above since this is `do' I'm posting
about in this post. But I'm still seeing something here I don't
understand.
I'll use my reall example code since that is where I notice this
phenomena.
My function to slurp looks like:
cat /home/hgp/scripts/perl/fnc/lctime
sub lctime {
## Fucntion to create a date in my preferred format
@lta = localtime;
## Adjust for mnth range of 0-11
$lta[4] += 1;
## Adjust for year based on 1900, and remove leading 2 digits so
## 103 first becomes 2003 and then 03
($lta[5] = ($lta[5] += 1900)) =~ s/^..//;
## Print it out in this format:
## mnthdayyr hr:min:sec wkday (padding with zeros where necessary)
## Like 012003 15:15:51 01
printf "%02d%02d%02d %02d:%02d:%02d %02d\n", @lta[4,3,5,2,1,0,6];
}
How can I print the output of this into a file handle?
When I try, I get an extra numeral 1 which I'm guessing is a return
value from misguided referencing.
Example:
#!/usr/local/bin/perl -w
do "/home/hgp/scripts/perl/fnc/lctime";
open(FILE,">somefile");
print FILE "An extra numeral <" . &lctime . "> appears\n";
cat somefile
An extra numeral <1> appears
But the output of &lctime goes to tty.
--
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]