[Date Prev][Date Next][Thread Prev][Thread Next] [Search] [Date Index] [Thread Index]

Re: [MacPerl] New User's MacPerl Questions



> 2) My UNIX-centric learning Perl book uses something like system('date')
> get the date from the machine. When I do this I always get a -1. I guess
> my question is -- where in the documentation does it cover finding the
> date and assigning it to a variable?

Use localtime():

#!perl -w

print 'Simple: ', scalar localtime, "\n";

($sec,$min,$hour,$mday,$mon,$year,$wday,$yday,$isdst) = localtime;
$year += 1900;
if ($hour > 12) {
  $hour -= 12;
  $m = 'PM';
} else {
  $m = 'AM';
}

@months = qw(
  January   February March    April
  May       June     July     August
  September October  November December
);

@days = qw(Sunday Monday Tuesday Wednesday Thursday Friday);

print <<"END";
Complex:
  $days[$wday], $months[$mon] $mday, $year
    @{[sprintf '%02d:%02d:%02d', $hour, $min, $sec]} $m
  Day $yday of $year.
  It is currently @{[$isdst ? '' : 'not ']}daylight savings time.
END

__END__

> 3) Many of the text files I'll be encoding into HTML will have special Mac
> characters like option-8 bullets and long dashes. What is the best way to
> tackle this?

MacPerl handles them just fine, both in input and in scripts.

> 4) I'd like to be able to 'watch' a folder (like in AS with an idle
> timer), is this a MacPerl question, or should I just buy the next book in
> that UNIX-centric Perl series?

The disadvantage of watching a folder in MacPerl is that you can't do
anything else while the script is running.

-- 
  Kevin Reid.      |         Macintosh.
   "I'm me."       |      Think different.

***** Want to unsubscribe from this list?
***** Send mail with body "unsubscribe" to mac-perl-request@iis.ee.ethz.ch