Richard Lee wrote:
John W. Krahn wrote:
Richard Lee wrote:
sub shove_it {
my $start = time_this(scalar localtime( ( time() - ( 60 * 60 )
) ));
What does the time_this() function do?
sub time_this {
my $chunli = join(' ', ( split( /\s+/, $_[0]))[1,2,3]);
if ($chunli =~ s/^(\S\S\S)(\s)(\d\d\s)(\d\d:).+$/$1$2$3$4/g) {
^^^
return $chunli;
} elsif ($chunli =~ s/^(\S\S\S)(\s)(\d\s)(\d\d:).+$/$1$2 $3$4/g) {
^^^
The /g option is superfluous as the pattern is anchored at the beginning
and end of the string so it will only ever match once.
return $chunli;
} else {
print "There was a problem\n";
exit 0;
}
}
You can replace all of that with:
use POSIX qw/ strftime /;
sub shove_it {
my $start = strftime '%b %e %H:', localtime time - 60 * 60;
[ SNIP ]
You are not returning the contents of @bad and you are not passing in
the name of the file to open so I assume that this is in a subroutine
because you are calling it many times in your program?
Yes, it is sub
The question was: are you calling the subroutine once or calling it many
different times?
John
--
Perl isn't a toolbox, but a small machine shop where you
can special-order certain sorts of tools at low cost and
in short order. -- Larry Wall
--
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
http://learn.perl.org/