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

Re: [MacPerl] Browser Redirect Script (Thanks)



At 03.20 -0500 1998.11.29, Kevin Diffily wrote:
>It will print out a message directing your viewer to the
>most recent browsers based upon their OS.

Are you sure about that?  These check $^O, which has nothing to do with the
viewer's OS.  You want to check $ENV{HTTP_USER_AGENT}, as I demonstrated
last week.

Also, as a style issue, this could be cleaned up:


if ($^O =~ /Win/) {
  $netlocation = 'ftp://ftp.netscape.com/pub/communicator/4.5/' .
   'english/windows/windows95_or_nt/complete_install/cc32e45.exe';
  $explocation = 'http://www.microsoft.com/windows/ie/download/default.asp';
  $os = 'Windows';
} elsif ($^O =~ /Mac/) {
  $netlocation = 'ftp://ftp.netscape.com/pub/communicator/4.5/' .
    'english/mac/complete_install/Comm4.5_Complete_EX.bin';
  $explocation = 'http://www.microsoft.com/windows/ie/download/mac.htm';
  $os = 'Macintosh';
} elsif ($^O =~ /Unix/) {
  # etc.
}

Although, you have the serious problem that $^O checks what platform the
script is running on, which will always be the same, depending on what
server you are running on, and you want to check $ENV{HTTP_USER_AGENT}.
You have the other serious problem that /Mac/ matches more than just Mac
OS.  It also matches MachTen, and probably some others, too.  Further, I am
not sure if ANYTHING matches /Unix/, and if it does, it is only a very
small number of platforms.  Linux and Solaris and SunOS and AIX and *BSD
will not match /Unix/.

--
Chris Nandor          mailto:pudge@pobox.com         http://pudge.net/
%PGPKey = ('B76E72AD', [1024, '0824090B CE73CA10  1FF77F13 8180B6B6'])

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