Forking from inside ptk:
# my $pid;
# if (!defined($pid = fork)) {
# warn "cannot fork: $!";
# return;
# } elsif ($pid) {
# warn "begat $pid";
# return; # I’m the parent
# }
# exec 'mozilla', '-url', "$url";
or use
$pid = fork;
exec 'mozilla', '-url', $url unless defined $pid;
Standard Sentence Boundary Code:
/
(
.+? # match (non-greedy) anything ...
[.!?] # ... followed by any one of !?.
[")]? # ... and optionally " or )
)
(?= # with lookahead that it is followed by ...
(?: # either ...
\s+ # some whitespace ...
["(]? # maybe a " or ( ...
[A-Z] # and capital letter
| # or ...
\s*$ # optional whitespace, followed by end of string
)
)
/gx
;
To find if a directory exists;
use Cwd;
my $dir = getcwd; #find root of script
print "Current Directory is $dir\n";
print "Appending skudb to dir\n";
$dir = $dir . "skudb";
if (-d $dir) {
chdir $dir; #move into the new directory
#do some stuff in $dir here
}
else
{
mkdir $dir
}
Or a better version perhaps
use Cwd 'chdir'; #That overrides chdir to update $ENV{PWD}
my $dir = getcwd; #find root of script
print "Current Directory is $dir\n";
print "Appending skudb to dir\n";
$dir = $dir . "skudb";
unless (-d $dir) { mkdir $dir }
chdir $dir; #move into the new directory
print $ENV{'PWD'};
#do some stuff in $dir here
For Sulfericacid
Here is a countdown until 2am for you
my ($sec2, $min2, $hour2) = localtime(time);
print "Whole hours remaining until midnight: (24-$hour2)=";print 24-$h
+our2;print" hours\n";
print "Minutes remaining until next hour: (60-$min2)=";print 60-$min2;
+print" minutes\n";
if ($hour2>2) {
$newdayhours = 24-$hour2+2; $min2=60-$min2;
print "There are $newdayhours hour(s) and $min2 minute(s) until the ne
+w day.";
}
else {
print "There are ";print 2-$hour2;print" hour(s) and ";print 60-$min2;
+print " minute(s) until the new day.";
}
|