[17767] in Perl-Users-Digest
Perl-Users Digest, Issue: 5187 Volume: 9
daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Sat Dec 23 06:10:27 2000
Date: Sat, 23 Dec 2000 03:10:08 -0800 (PST)
From: Perl-Users Digest <Perl-Users-Request@ruby.OCE.ORST.EDU>
To: Perl-Users@ruby.OCE.ORST.EDU (Perl-Users Digest)
Message-Id: <977569808-v9-i5187@ruby.oce.orst.edu>
Content-Type: text
Perl-Users Digest Sat, 23 Dec 2000 Volume: 9 Number: 5187
Today's topics:
REF: Help with Hash in a loop. Desperate! <angel@reflex-point.com>
Re: Simple REGEX question <rick.delaney@home.com>
Re: switch/case in Perl? (Martien Verbruggen)
Re: Understanding interpolation <nospam@nospam.com>
Re: Why are multiple zeroes true? <uri@sysarch.com>
Re: Why are multiple zeroes true? <rick.delaney@home.com>
Re: Why are multiple zeroes true? <uri@sysarch.com>
Re: Why not have lvalue subs autovivification? <rick.delaney@home.com>
Digest Administrivia (Last modified: 16 Sep 99) (Perl-Users-Digest Admin)
----------------------------------------------------------------------
Date: Sat, 23 Dec 2000 04:15:15 -0600
From: "angel" <angel@reflex-point.com>
Subject: REF: Help with Hash in a loop. Desperate!
Message-Id: <vT_06.495$lg5.140155@nnrp3.sbc.net>
This is a multi-part message in MIME format.
------=_NextPart_000_0024_01C06C96.F3BF0410
Content-Type: text/plain;
charset="iso-8859-1"
Content-Transfer-Encoding: quoted-printable
Good Samaritan:
I can't seem to understand why the following statement will only =
work once in any loop:
my $fext =3D $mime{$ext};
Anytime I try to print $fext in a loop it will only print once no matter =
the size of the loop. What am I missing here?
Sincerely,
ANGEL
#!/usr/bin/perl5.004
require "cgi-lib.pl";
&ReadParse;
#!/usr/bin/perl5.004
require "cgi-lib.pl";
&ReadParse;
print &PrintHeader;
open(X2,"<X2.txt") || &ShitBiskits;
@FILELIST =3D <X2>;
close(X2);
while (@FILELIST)
{=20
undef $mime{$ext};
undef $fext;
undef %mime;
my %mime =3D (
#-------------------------------------<TEXT>-----
'HTML', "text/html",
'HTM', "text/html",
'STM', "text/html",
'SHTML', "text/html",
'TXT', "text/plain",
'PREF', "text/plain",
'AIS', "text/plain",
'RTX', "text/richtext",
'CSV', "text/comma-separated-values",
'TSV', "text/tab-separated-values",
'NFO', "text/warez-info",
'ETX', "text/x-setext",
'SGML', "text/x-sgml",
'SGM', "text/x-sgml",
'TALK', "text/x-speech",
'CGI', "text/plain", # we want these two as text files
'PL', "text/plain", # and not application/x-httpd-cgi
#-------------------------------------<IMAGE>----
'COD', "image/cis-cod",
'FID', "image/fif",
'GIF', "image/gif",
'ICO', "image/ico",
'IEF', "image/ief",
'JPEG', "image/jpeg",
'JPG', "image/jpeg",
'JPE', "image/jpeg",
'PNG', "image/png",
'TIF', "image/tiff",
'TIFF', "image/tiff",
'MCF', "image/vasa",
'RAS', "image/x-cmu-raster",
'CMX', "image/x-cmx",
'PCD', "image/x-photo-cd",
'PNM', "image/x-portable-anymap",
'PBM', "image/x-portable-bitmap",
'PGM', "image/x-portable-graymap",
'PPM', "image/x-portable-pixmap",
'RGB', "image/x-rgb",
'XBM', "image/x-xbitmap",
'XPM', "image/x-xpixmap",
'XWD', "image/x-xwindowdump",
#-------------------------------------<APPS>-----
'EXE', "application/octet-stream",
'BIN', "application/octet-stream",
'DMS', "application/octet-stream",
'LHA', "application/octet-stream",
'CLASS', "application/octet-stream",
'DLL', "application/octet-stream",
'AAM', "application/x-authorware-map",
'AAS', "application/x-authorware-seg",
'AAB', "application/x-authorware-bin",
'VMD', "application/vocaltec-media-desc",
'VMF', "application/vocaltec-media-file",
'ASD', "application/astound",
'ASN', "application/astound",
'DWG', "application/autocad",
'DSP', "application/dsptype",
'DFX', "application/dsptype",
'EVY', "application/envoy",
'SPL', "application/futuresplash",
'IMD', "application/immedia",
'HQX', "application/mac-binhex40",
'CPT', "application/mac-compactpro",
'DOC', "application/msword",
'ODA', "application/oda",
'PDF', "application/pdf",
'AI', "application/postscript",
'EPS', "application/postscript",
'PS', "application/postscript",
'PPT', "application/powerpoint",
'RTF', "application/rtf",
'APM', "application/studiom",
'XAR', "application/vnd.xara",
'ANO', "application/x-annotator",
'ASP', "application/x-asap",
'CHAT', "application/x-chat",
'BCPIO', "application/x-bcpio",
'VCD', "application/x-cdlink",
'TGZ', "application/x-compressed",
'Z', "application/x-compress",
'CPIO', "application/x-cpio",
'PUZ', "application/x-crossword",
'CSH', "application/x-csh",
'DCR', "application/x-director",
'DIR', "application/x-director",
'DXR', "application/x-director",
'FGD', "application/x-director",
'DVI', "application/x-dvi",
'LIC', "application/x-enterlicense",
'EPB', "application/x-epublisher",
'FAXMGR', "application/x-fax-manager",
'FAXMGRJOB', "application/x-fax-manager-job",
'FM', "application/x-framemaker",
'FRAME', "application/x-framemaker",
'FRM', "application/x-framemaker",
'MAKER', "application/x-framemaker",
'GTAR', "application/x-gtar",
'GZ', "application/x-gzip",
'HDF', "application/x-hdf",
'INS', "application/x-insight",
'INSIGHT', "application/x-insight",
'INST', "application/x-install",
'IV', "application/x-inventor",
'JS', "application/x-javascript",
'SKP', "application/x-koan",
'SKD', "application/x-koan",
'SKT', "application/x-koan",
'SKM', "application/x-koan",
'LATEX', "application/x-latex",
'LICMGR', "application/x-licensemgr",
'MAIL', "application/x-mailfolder",
'MIF', "application/x-mailfolder",
'NC', "application/x-netcdf",
'CDF', "application/x-netcdf",
'SDS', "application/x-onlive",
'SGI-LPR', "application/x-sgi-lpr",
'SH', "application/x-sh",
'SHAR', "application/x-shar",
'SWF', "application/x-shockwave-flash",
'SPRITE', "application/x-sprite",
'SPR', "application/x-sprite",
'SIT', "application/x-stuffit",
'SV4CPIO', "application/x-sv4cpio",
'SV4CRC', "application/x-sv4crc",
'TAR', "application/x-tar",
'TARDIST', "application/x-tardist",
'TCL', "application/x-tcl",
'TEX', "application/x-tex",
'TEXINFO', "application/x-texinfo",
'TEXI', "application/x-texinfo",
'T', "application/x-troff",
'TR', "application/x-troff",
'TROFF', "application/x-troff",
'MAN', "application/x-troff-man",
'ME', "application/x-troff-me",
'MS', "application/x-troff-ms",
'TVM', "application/x-tvml",
'TVM', "application/x-tvml",
'USTAR', "application/x-ustar",
'SRC', "application/x-wais-source",
'WKZ', "application/x-wingz",
'ZIP', "application/x-zip-compressed",
'ZTARDIST', "application/x-ztardist",
#-------------------------------------<AUDIO>----
'AU', "audio/basic",
'SND', "audio/basic",
'ES', "audio/echospeech",
'MID', "audio/midi",
'KAR', "audio/midi",
'MPGA', "audio/mpeg",
'MP2', "audio/mpeg",
'TSI', "audio/tsplayer",
'VOX', "audio/voxware",
'AIF', "audio/x-aiff",
'AIFC', "audio/x-aiff",
'AIFF', "audio/x-aiff",
'MID', "audio/x-midi",
'MP3', "audio/x-mpeg",
'MP2A', "audio/x-mpeg2",
'MPA2', "audio/x-mpeg2",
'M3U', "audio/x-mpegurl",
'MP3URL', "audio/x-mpegurl",
'PAT', "audio/x-pat",
'RAM', "audio/x-pn-realaudio",
'RPM', "audio/x-pn-realaudio-plugin",
'RA', "audio/x-realaudio",
'SBK', "audio/x-sbk",
'STR', "audio/x-str",
'WAV', "audio/x-wav",
#-------------------------------------<VIDEO>----
'MPEG', "video/mpeg",
'MPG', "video/mpeg",
'MPE', "video/mpeg",
'QT', "video/quicktime",
'MOV', "video/quicktime",
'VIV', "video/vivo",
'VIVO', "video/vivo",
'MPS', "video/x-mpeg-system",
'SYS', "video/x-mpeg-system",
'MP2V', "video/x-mpeg2",
'MPV2', "video/x-mpeg2",
'AVI', "video/x-msvideo",
'MV', "video/x-sgi-movie",
'MOVIE', "video/x-sgi-movie",
#-------------------------------------<EXTRA>----
'PDB', "chemical/x-pdb",
'XYZ', "chemical/x-pdb",
'CHM', "chemical/x-cs-chemdraw",
'SMI', "chemical/x-daylight-smiles",
'SKC', "chemical/x-mdl-isis",
'MOL', "chemical/x-mdl-molfile",
'RXN', "chemical/x-mdl-rxn",
'SMD', "chemical/x-smd",
'ACC', "chemical/x-synopsys-accord",
'ICE', "x-conference/x-cooltalk",
'SVR', "x-world/x-svr",
'WRL', "x-world/x-vrml",
'VRML', "x-world/x-vrml",
'VRJ', "x-world/x-vrt",
'VRJT', "x-world/x-vrt",
);
my $file =3D (pop @FILELIST);
print "<br>File =3D $file";
my ($ext) =3D $file =3D~ m,\.([^\.]*)$,;
print "<br>Ext =3D $ext";
$ext =3D~ tr,a-z,A-Z,;
print "<br>Again, $ext";
my $fext =3D $mime{$ext};
print "---$fext\n";
}
print "<br>All Done!";
------=_NextPart_000_0024_01C06C96.F3BF0410
Content-Type: text/html;
charset="iso-8859-1"
Content-Transfer-Encoding: quoted-printable
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<HTML><HEAD>
<META http-equiv=3DContent-Type content=3D"text/html; =
charset=3Diso-8859-1">
<META content=3D"MSHTML 5.50.4611.1300" name=3DGENERATOR>
<STYLE></STYLE>
</HEAD>
<BODY>
<DIV>
<P><FONT face=3DArial size=3D2>Good Samaritan:</FONT></P>
<P><FONT face=3DArial size=3D2> I can't seem to =
understand why the=20
following statement will only work once in any loop:</FONT></P>
<P><FONT face=3DArial size=3D2><STRONG>my $fext =3D =
$mime{$ext};</STRONG></FONT></P>
<P><FONT face=3DArial size=3D2>Anytime I try to print $fext in a loop it =
will only=20
print once no matter the size of the loop. What am I missing=20
here?</FONT></P>
<P><FONT face=3DArial size=3D2>Sincerely,</FONT></P>
<P><FONT face=3DArial color=3D#0000ff size=3D2><STRONG><EM><U><A=20
href=3D"mailto:angel@reflex-point.com">ANGEL</A></U></EM></STRONG></FONT>=
</P>
<P><FONT face=3DArial size=3D2>#!/usr/bin/perl5.004</FONT></P>
<P><FONT face=3DArial size=3D2>require "cgi-lib.pl";</FONT></P>
<P><FONT face=3DArial size=3D2>&ReadParse;</FONT></P>
<P><FONT face=3DArial size=3D2>#!/usr/bin/perl5.004</FONT></P>
<P><FONT face=3DArial size=3D2>require "cgi-lib.pl";</FONT></P>
<P><FONT face=3DArial size=3D2>&ReadParse;</FONT></P>
<P><FONT face=3DArial size=3D2>print &PrintHeader;</FONT></P>
<P><FONT face=3DArial size=3D2></FONT> </P>
<P><FONT face=3DArial size=3D2></FONT> </P>
<P><FONT face=3DArial size=3D2>open(X2,"<X2.txt") || =
&ShitBiskits;</FONT></P>
<P><FONT face=3DArial size=3D2>@FILELIST =3D <X2>;</FONT></P>
<P><FONT face=3DArial size=3D2>close(X2);</FONT></P>
<P><FONT face=3DArial size=3D2></FONT> </P>
<P><FONT face=3DArial size=3D2>while (@FILELIST)</FONT></P>
<P><FONT face=3DArial size=3D2>{ </FONT></P>
<P><FONT face=3DArial size=3D2>undef $mime{$ext};</FONT></P>
<P><FONT face=3DArial size=3D2>undef $fext;</FONT></P>
<P><FONT face=3DArial size=3D2>undef %mime;</FONT></P>
<P><FONT face=3DArial size=3D2>my %mime =3D (</FONT></P>
<P><FONT face=3DArial=20
size=3D2>#-------------------------------------<TEXT>-----</FONT></=
P>
<P><FONT face=3DArial size=3D2>'HTML', "text/html",</FONT></P>
<P><FONT face=3DArial size=3D2>'HTM', "text/html",</FONT></P>
<P><FONT face=3DArial size=3D2>'STM', "text/html",</FONT></P>
<P><FONT face=3DArial size=3D2>'SHTML', "text/html",</FONT></P>
<P><FONT face=3DArial size=3D2>'TXT', "text/plain",</FONT></P>
<P><FONT face=3DArial size=3D2>'PREF', "text/plain",</FONT></P>
<P><FONT face=3DArial size=3D2>'AIS', "text/plain",</FONT></P>
<P><FONT face=3DArial size=3D2>'RTX', "text/richtext",</FONT></P>
<P><FONT face=3DArial size=3D2>'CSV', =
"text/comma-separated-values",</FONT></P>
<P><FONT face=3DArial size=3D2>'TSV', =
"text/tab-separated-values",</FONT></P>
<P><FONT face=3DArial size=3D2>'NFO', "text/warez-info",</FONT></P>
<P><FONT face=3DArial size=3D2>'ETX', "text/x-setext",</FONT></P>
<P><FONT face=3DArial size=3D2>'SGML', "text/x-sgml",</FONT></P>
<P><FONT face=3DArial size=3D2>'SGM', "text/x-sgml",</FONT></P>
<P><FONT face=3DArial size=3D2>'TALK', "text/x-speech",</FONT></P>
<P><FONT face=3DArial size=3D2>'CGI', "text/plain", # we want these two =
as text=20
files</FONT></P>
<P><FONT face=3DArial size=3D2>'PL', "text/plain", # and not=20
application/x-httpd-cgi</FONT></P>
<P><FONT face=3DArial=20
size=3D2>#-------------------------------------<IMAGE>----</FONT></=
P>
<P><FONT face=3DArial size=3D2>'COD', "image/cis-cod",</FONT></P>
<P><FONT face=3DArial size=3D2>'FID', "image/fif",</FONT></P>
<P><FONT face=3DArial size=3D2>'GIF', "image/gif",</FONT></P>
<P><FONT face=3DArial size=3D2>'ICO', "image/ico",</FONT></P>
<P><FONT face=3DArial size=3D2>'IEF', "image/ief",</FONT></P>
<P><FONT face=3DArial size=3D2>'JPEG', "image/jpeg",</FONT></P>
<P><FONT face=3DArial size=3D2>'JPG', "image/jpeg",</FONT></P>
<P><FONT face=3DArial size=3D2>'JPE', "image/jpeg",</FONT></P>
<P><FONT face=3DArial size=3D2>'PNG', "image/png",</FONT></P>
<P><FONT face=3DArial size=3D2>'TIF', "image/tiff",</FONT></P>
<P><FONT face=3DArial size=3D2>'TIFF', "image/tiff",</FONT></P>
<P><FONT face=3DArial size=3D2>'MCF', "image/vasa",</FONT></P>
<P><FONT face=3DArial size=3D2>'RAS', "image/x-cmu-raster",</FONT></P>
<P><FONT face=3DArial size=3D2>'CMX', "image/x-cmx",</FONT></P>
<P><FONT face=3DArial size=3D2>'PCD', "image/x-photo-cd",</FONT></P>
<P><FONT face=3DArial size=3D2>'PNM', =
"image/x-portable-anymap",</FONT></P>
<P><FONT face=3DArial size=3D2>'PBM', =
"image/x-portable-bitmap",</FONT></P>
<P><FONT face=3DArial size=3D2>'PGM', =
"image/x-portable-graymap",</FONT></P>
<P><FONT face=3DArial size=3D2>'PPM', =
"image/x-portable-pixmap",</FONT></P>
<P><FONT face=3DArial size=3D2>'RGB', "image/x-rgb",</FONT></P>
<P><FONT face=3DArial size=3D2>'XBM', "image/x-xbitmap",</FONT></P>
<P><FONT face=3DArial size=3D2>'XPM', "image/x-xpixmap",</FONT></P>
<P><FONT face=3DArial size=3D2>'XWD', "image/x-xwindowdump",</FONT></P>
<P><FONT face=3DArial=20
size=3D2>#-------------------------------------<APPS>-----</FONT></=
P>
<P><FONT face=3DArial size=3D2>'EXE', =
"application/octet-stream",</FONT></P>
<P><FONT face=3DArial size=3D2>'BIN', =
"application/octet-stream",</FONT></P>
<P><FONT face=3DArial size=3D2>'DMS', =
"application/octet-stream",</FONT></P>
<P><FONT face=3DArial size=3D2>'LHA', =
"application/octet-stream",</FONT></P>
<P><FONT face=3DArial size=3D2>'CLASS', =
"application/octet-stream",</FONT></P>
<P><FONT face=3DArial size=3D2>'DLL', =
"application/octet-stream",</FONT></P>
<P><FONT face=3DArial size=3D2>'AAM', =
"application/x-authorware-map",</FONT></P>
<P><FONT face=3DArial size=3D2>'AAS', =
"application/x-authorware-seg",</FONT></P>
<P><FONT face=3DArial size=3D2>'AAB', =
"application/x-authorware-bin",</FONT></P>
<P><FONT face=3DArial size=3D2>'VMD', =
"application/vocaltec-media-desc",</FONT></P>
<P><FONT face=3DArial size=3D2>'VMF', =
"application/vocaltec-media-file",</FONT></P>
<P><FONT face=3DArial size=3D2>'ASD', "application/astound",</FONT></P>
<P><FONT face=3DArial size=3D2>'ASN', "application/astound",</FONT></P>
<P><FONT face=3DArial size=3D2>'DWG', "application/autocad",</FONT></P>
<P><FONT face=3DArial size=3D2>'DSP', "application/dsptype",</FONT></P>
<P><FONT face=3DArial size=3D2>'DFX', "application/dsptype",</FONT></P>
<P><FONT face=3DArial size=3D2>'EVY', "application/envoy",</FONT></P>
<P><FONT face=3DArial size=3D2>'SPL', =
"application/futuresplash",</FONT></P>
<P><FONT face=3DArial size=3D2>'IMD', "application/immedia",</FONT></P>
<P><FONT face=3DArial size=3D2>'HQX', =
"application/mac-binhex40",</FONT></P>
<P><FONT face=3DArial size=3D2>'CPT', =
"application/mac-compactpro",</FONT></P>
<P><FONT face=3DArial size=3D2>'DOC', "application/msword",</FONT></P>
<P><FONT face=3DArial size=3D2>'ODA', "application/oda",</FONT></P>
<P><FONT face=3DArial size=3D2>'PDF', "application/pdf",</FONT></P>
<P><FONT face=3DArial size=3D2>'AI', =
"application/postscript",</FONT></P>
<P><FONT face=3DArial size=3D2>'EPS', =
"application/postscript",</FONT></P>
<P><FONT face=3DArial size=3D2>'PS', =
"application/postscript",</FONT></P>
<P><FONT face=3DArial size=3D2>'PPT', =
"application/powerpoint",</FONT></P>
<P><FONT face=3DArial size=3D2>'RTF', "application/rtf",</FONT></P>
<P><FONT face=3DArial size=3D2>'APM', "application/studiom",</FONT></P>
<P><FONT face=3DArial size=3D2>'XAR', "application/vnd.xara",</FONT></P>
<P><FONT face=3DArial size=3D2>'ANO', =
"application/x-annotator",</FONT></P>
<P><FONT face=3DArial size=3D2>'ASP', "application/x-asap",</FONT></P>
<P><FONT face=3DArial size=3D2>'CHAT', "application/x-chat",</FONT></P>
<P><FONT face=3DArial size=3D2>'BCPIO', =
"application/x-bcpio",</FONT></P>
<P><FONT face=3DArial size=3D2>'VCD', "application/x-cdlink",</FONT></P>
<P><FONT face=3DArial size=3D2>'TGZ', =
"application/x-compressed",</FONT></P>
<P><FONT face=3DArial size=3D2>'Z', "application/x-compress",</FONT></P>
<P><FONT face=3DArial size=3D2>'CPIO', "application/x-cpio",</FONT></P>
<P><FONT face=3DArial size=3D2>'PUZ', =
"application/x-crossword",</FONT></P>
<P><FONT face=3DArial size=3D2>'CSH', "application/x-csh",</FONT></P>
<P><FONT face=3DArial size=3D2>'DCR', =
"application/x-director",</FONT></P>
<P><FONT face=3DArial size=3D2>'DIR', =
"application/x-director",</FONT></P>
<P><FONT face=3DArial size=3D2>'DXR', =
"application/x-director",</FONT></P>
<P><FONT face=3DArial size=3D2>'FGD', =
"application/x-director",</FONT></P>
<P><FONT face=3DArial size=3D2>'DVI', "application/x-dvi",</FONT></P>
<P><FONT face=3DArial size=3D2>'LIC', =
"application/x-enterlicense",</FONT></P>
<P><FONT face=3DArial size=3D2>'EPB', =
"application/x-epublisher",</FONT></P>
<P><FONT face=3DArial size=3D2>'FAXMGR', =
"application/x-fax-manager",</FONT></P>
<P><FONT face=3DArial size=3D2>'FAXMGRJOB',=20
"application/x-fax-manager-job",</FONT></P>
<P><FONT face=3DArial size=3D2>'FM', =
"application/x-framemaker",</FONT></P>
<P><FONT face=3DArial size=3D2>'FRAME', =
"application/x-framemaker",</FONT></P>
<P><FONT face=3DArial size=3D2>'FRM', =
"application/x-framemaker",</FONT></P>
<P><FONT face=3DArial size=3D2>'MAKER', =
"application/x-framemaker",</FONT></P>
<P><FONT face=3DArial size=3D2>'GTAR', "application/x-gtar",</FONT></P>
<P><FONT face=3DArial size=3D2>'GZ', "application/x-gzip",</FONT></P>
<P><FONT face=3DArial size=3D2>'HDF', "application/x-hdf",</FONT></P>
<P><FONT face=3DArial size=3D2>'INS', =
"application/x-insight",</FONT></P>
<P><FONT face=3DArial size=3D2>'INSIGHT', =
"application/x-insight",</FONT></P>
<P><FONT face=3DArial size=3D2>'INST', =
"application/x-install",</FONT></P>
<P><FONT face=3DArial size=3D2>'IV', =
"application/x-inventor",</FONT></P>
<P><FONT face=3DArial size=3D2>'JS', =
"application/x-javascript",</FONT></P>
<P><FONT face=3DArial size=3D2>'SKP', "application/x-koan",</FONT></P>
<P><FONT face=3DArial size=3D2>'SKD', "application/x-koan",</FONT></P>
<P><FONT face=3DArial size=3D2>'SKT', "application/x-koan",</FONT></P>
<P><FONT face=3DArial size=3D2>'SKM', "application/x-koan",</FONT></P>
<P><FONT face=3DArial size=3D2>'LATEX', =
"application/x-latex",</FONT></P>
<P><FONT face=3DArial size=3D2>'LICMGR', =
"application/x-licensemgr",</FONT></P>
<P><FONT face=3DArial size=3D2>'MAIL', =
"application/x-mailfolder",</FONT></P>
<P><FONT face=3DArial size=3D2>'MIF', =
"application/x-mailfolder",</FONT></P>
<P><FONT face=3DArial size=3D2>'NC', "application/x-netcdf",</FONT></P>
<P><FONT face=3DArial size=3D2>'CDF', "application/x-netcdf",</FONT></P>
<P><FONT face=3DArial size=3D2>'SDS', "application/x-onlive",</FONT></P>
<P><FONT face=3DArial size=3D2>'SGI-LPR', =
"application/x-sgi-lpr",</FONT></P>
<P><FONT face=3DArial size=3D2>'SH', "application/x-sh",</FONT></P>
<P><FONT face=3DArial size=3D2>'SHAR', "application/x-shar",</FONT></P>
<P><FONT face=3DArial size=3D2>'SWF', =
"application/x-shockwave-flash",</FONT></P>
<P><FONT face=3DArial size=3D2>'SPRITE', =
"application/x-sprite",</FONT></P>
<P><FONT face=3DArial size=3D2>'SPR', "application/x-sprite",</FONT></P>
<P><FONT face=3DArial size=3D2>'SIT', =
"application/x-stuffit",</FONT></P>
<P><FONT face=3DArial size=3D2>'SV4CPIO', =
"application/x-sv4cpio",</FONT></P>
<P><FONT face=3DArial size=3D2>'SV4CRC', =
"application/x-sv4crc",</FONT></P>
<P><FONT face=3DArial size=3D2>'TAR', "application/x-tar",</FONT></P>
<P><FONT face=3DArial size=3D2>'TARDIST', =
"application/x-tardist",</FONT></P>
<P><FONT face=3DArial size=3D2>'TCL', "application/x-tcl",</FONT></P>
<P><FONT face=3DArial size=3D2>'TEX', "application/x-tex",</FONT></P>
<P><FONT face=3DArial size=3D2>'TEXINFO', =
"application/x-texinfo",</FONT></P>
<P><FONT face=3DArial size=3D2>'TEXI', =
"application/x-texinfo",</FONT></P>
<P><FONT face=3DArial size=3D2>'T', "application/x-troff",</FONT></P>
<P><FONT face=3DArial size=3D2>'TR', "application/x-troff",</FONT></P>
<P><FONT face=3DArial size=3D2>'TROFF', =
"application/x-troff",</FONT></P>
<P><FONT face=3DArial size=3D2>'MAN', =
"application/x-troff-man",</FONT></P>
<P><FONT face=3DArial size=3D2>'ME', =
"application/x-troff-me",</FONT></P>
<P><FONT face=3DArial size=3D2>'MS', =
"application/x-troff-ms",</FONT></P>
<P><FONT face=3DArial size=3D2>'TVM', "application/x-tvml",</FONT></P>
<P><FONT face=3DArial size=3D2>'TVM', "application/x-tvml",</FONT></P>
<P><FONT face=3DArial size=3D2>'USTAR', =
"application/x-ustar",</FONT></P>
<P><FONT face=3DArial size=3D2>'SRC', =
"application/x-wais-source",</FONT></P>
<P><FONT face=3DArial size=3D2>'WKZ', "application/x-wingz",</FONT></P>
<P><FONT face=3DArial size=3D2>'ZIP', =
"application/x-zip-compressed",</FONT></P>
<P><FONT face=3DArial size=3D2>'ZTARDIST', =
"application/x-ztardist",</FONT></P>
<P><FONT face=3DArial=20
size=3D2>#-------------------------------------<AUDIO>----</FONT></=
P>
<P><FONT face=3DArial size=3D2>'AU', "audio/basic",</FONT></P>
<P><FONT face=3DArial size=3D2>'SND', "audio/basic",</FONT></P>
<P><FONT face=3DArial size=3D2>'ES', "audio/echospeech",</FONT></P>
<P><FONT face=3DArial size=3D2>'MID', "audio/midi",</FONT></P>
<P><FONT face=3DArial size=3D2>'KAR', "audio/midi",</FONT></P>
<P><FONT face=3DArial size=3D2>'MPGA', "audio/mpeg",</FONT></P>
<P><FONT face=3DArial size=3D2>'MP2', "audio/mpeg",</FONT></P>
<P><FONT face=3DArial size=3D2>'TSI', "audio/tsplayer",</FONT></P>
<P><FONT face=3DArial size=3D2>'VOX', "audio/voxware",</FONT></P>
<P><FONT face=3DArial size=3D2>'AIF', "audio/x-aiff",</FONT></P>
<P><FONT face=3DArial size=3D2>'AIFC', "audio/x-aiff",</FONT></P>
<P><FONT face=3DArial size=3D2>'AIFF', "audio/x-aiff",</FONT></P>
<P><FONT face=3DArial size=3D2>'MID', "audio/x-midi",</FONT></P>
<P><FONT face=3DArial size=3D2>'MP3', "audio/x-mpeg",</FONT></P>
<P><FONT face=3DArial size=3D2>'MP2A', "audio/x-mpeg2",</FONT></P>
<P><FONT face=3DArial size=3D2>'MPA2', "audio/x-mpeg2",</FONT></P>
<P><FONT face=3DArial size=3D2>'M3U', "audio/x-mpegurl",</FONT></P>
<P><FONT face=3DArial size=3D2>'MP3URL', "audio/x-mpegurl",</FONT></P>
<P><FONT face=3DArial size=3D2>'PAT', "audio/x-pat",</FONT></P>
<P><FONT face=3DArial size=3D2>'RAM', "audio/x-pn-realaudio",</FONT></P>
<P><FONT face=3DArial size=3D2>'RPM', =
"audio/x-pn-realaudio-plugin",</FONT></P>
<P><FONT face=3DArial size=3D2>'RA', "audio/x-realaudio",</FONT></P>
<P><FONT face=3DArial size=3D2>'SBK', "audio/x-sbk",</FONT></P>
<P><FONT face=3DArial size=3D2>'STR', "audio/x-str",</FONT></P>
<P><FONT face=3DArial size=3D2>'WAV', "audio/x-wav",</FONT></P>
<P><FONT face=3DArial=20
size=3D2>#-------------------------------------<VIDEO>----</FONT></=
P>
<P><FONT face=3DArial size=3D2>'MPEG', "video/mpeg",</FONT></P>
<P><FONT face=3DArial size=3D2>'MPG', "video/mpeg",</FONT></P>
<P><FONT face=3DArial size=3D2>'MPE', "video/mpeg",</FONT></P>
<P><FONT face=3DArial size=3D2>'QT', "video/quicktime",</FONT></P>
<P><FONT face=3DArial size=3D2>'MOV', "video/quicktime",</FONT></P>
<P><FONT face=3DArial size=3D2>'VIV', "video/vivo",</FONT></P>
<P><FONT face=3DArial size=3D2>'VIVO', "video/vivo",</FONT></P>
<P><FONT face=3DArial size=3D2>'MPS', "video/x-mpeg-system",</FONT></P>
<P><FONT face=3DArial size=3D2>'SYS', "video/x-mpeg-system",</FONT></P>
<P><FONT face=3DArial size=3D2>'MP2V', "video/x-mpeg2",</FONT></P>
<P><FONT face=3DArial size=3D2>'MPV2', "video/x-mpeg2",</FONT></P>
<P><FONT face=3DArial size=3D2>'AVI', "video/x-msvideo",</FONT></P>
<P><FONT face=3DArial size=3D2>'MV', "video/x-sgi-movie",</FONT></P>
<P><FONT face=3DArial size=3D2>'MOVIE', "video/x-sgi-movie",</FONT></P>
<P><FONT face=3DArial=20
size=3D2>#-------------------------------------<EXTRA>----</FONT></=
P>
<P><FONT face=3DArial size=3D2>'PDB', "chemical/x-pdb",</FONT></P>
<P><FONT face=3DArial size=3D2>'XYZ', "chemical/x-pdb",</FONT></P>
<P><FONT face=3DArial size=3D2>'CHM', =
"chemical/x-cs-chemdraw",</FONT></P>
<P><FONT face=3DArial size=3D2>'SMI', =
"chemical/x-daylight-smiles",</FONT></P>
<P><FONT face=3DArial size=3D2>'SKC', "chemical/x-mdl-isis",</FONT></P>
<P><FONT face=3DArial size=3D2>'MOL', =
"chemical/x-mdl-molfile",</FONT></P>
<P><FONT face=3DArial size=3D2>'RXN', "chemical/x-mdl-rxn",</FONT></P>
<P><FONT face=3DArial size=3D2>'SMD', "chemical/x-smd",</FONT></P>
<P><FONT face=3DArial size=3D2>'ACC', =
"chemical/x-synopsys-accord",</FONT></P>
<P><FONT face=3DArial size=3D2>'ICE', =
"x-conference/x-cooltalk",</FONT></P>
<P><FONT face=3DArial size=3D2>'SVR', "x-world/x-svr",</FONT></P>
<P><FONT face=3DArial size=3D2>'WRL', "x-world/x-vrml",</FONT></P>
<P><FONT face=3DArial size=3D2>'VRML', "x-world/x-vrml",</FONT></P>
<P><FONT face=3DArial size=3D2>'VRJ', "x-world/x-vrt",</FONT></P>
<P><FONT face=3DArial size=3D2>'VRJT', "x-world/x-vrt",</FONT></P>
<P><FONT face=3DArial size=3D2>);</FONT></P>
<P><FONT face=3DArial size=3D2>my $file =3D (pop @FILELIST);</FONT></P>
<P><FONT face=3DArial size=3D2>print "<br>File =3D =
$file";</FONT></P>
<P><FONT face=3DArial size=3D2>my ($ext) =3D $file =3D~ =
m,\.([^\.]*)$,;</FONT></P>
<P><FONT face=3DArial size=3D2>print "<br>Ext =3D =
$ext";</FONT></P>
<P><FONT face=3DArial size=3D2>$ext =3D~ tr,a-z,A-Z,;</FONT></P>
<P><FONT face=3DArial size=3D2>print "<br>Again, $ext";</FONT></P>
<P><FONT face=3DArial size=3D2>my $fext =3D $mime{$ext};</FONT></P>
<P><FONT face=3DArial size=3D2>print "---$fext\n";</FONT></P>
<P><FONT face=3DArial size=3D2>}</FONT></P>
<P><FONT face=3DArial size=3D2></FONT> </P>
<P><FONT face=3DArial size=3D2>print "<br>All=20
Done!";</FONT></P></DIV></BODY></HTML>
------=_NextPart_000_0024_01C06C96.F3BF0410--
------------------------------
Date: Sat, 23 Dec 2000 05:08:37 GMT
From: Rick Delaney <rick.delaney@home.com>
Subject: Re: Simple REGEX question
Message-Id: <3A4436F3.DE3452BF@home.com>
Randy Harris wrote:
>
> This doesn't work either. However, $str =~ s/^\s*(.*?)\s*$/$1/; does.
>
> I found this in the FAQ after reading a post by Tad McClellan elsewhere.
Good! But please read the FAQ carefully, since it recommends not to use
this and explains why.
> I still don't understand why the other doesn't.
This is because you don't understand regexps yet. Check out the perlre
manpage.
What you had:
$str =~ s/^\s*()\s*$/$1/;
This says, "substitute, from the beginning of the string 0 or more
whitespace characters (followed by nothing) followed by zero or more
whitespace characters up to the end of the string, with (nothing)".
IOW, only strings composed entirely of whitespace will be matched by the
pattern.
>
> > Or better yet,
> >
> > $str =~ s/^\s+|\s+$//g;
>
> This also works, of course. And without saving the $1 variable, which
> would certainly seem more efficient.
But not as efficient as the suggested alternative in the FAQ.
> But why is (.*) different from (.*?)
Because they are defined to be different. Again, see perlre.
" foo " =~ /^(\s*)(.*)(\s*)$/;
print "($1)($2)($3)\n";
" foo " =~ /^(\s*)(.*?)(\s*)$/;
print "($1)($2)($3)\n";
__END__
( )(foo )()
( )(foo)( )
In the first case, you can see .* matches every character after the
leading whitespace. This is called greedy matching in perlre. In the
second case, non-greedy matching was asked for so .*? matched as little
as it could. It would happily have matched nothing, except that it had
to match enough that the \s*$ following it could match.
--
Rick Delaney
rick.delaney@home.com
------------------------------
Date: Sat, 23 Dec 2000 19:32:31 +1100
From: mgjv@tradingpost.com.au (Martien Verbruggen)
Subject: Re: switch/case in Perl?
Message-Id: <slrn948oov.8i7.mgjv@martien.heliotrope.home>
On Fri, 22 Dec 2000 04:11:25 GMT,
Chris Fedde <cfedde@fedde.littleton.co.us> wrote:
> In article <47i34tgjo2mtek9433k64v64pongll8au9@4ax.com>,
> Bart Lateur <bart.lateur@skynet.be> wrote:
>>Andrew N McGuire wrote:
>>
>>>I want 'a' and 'A' to be equivalent, so the
>>>fall through is natural.
>>
>>You can't convince me, I'm too stubborn. I find C's switch syntax
>>incredibly primitive. What would have been wrong with a syntax, as in
>>(extended) BASIC:
>>
>
> What we always seem to forget, is that languages like BCPL, B, C
> and C++ were developed by people who were designing programming
> environments for digital telephone switches. Small fast languages
> for critical real time environents that bind close to the hardware
> while still supporting high level programming features.
For B and BCPL that is partly true, but I don't think you'll be able to
maintain that C and C++ were designed for digital switches, or even with
them in mind. Both of them were designed to be higher level than that,
although C was still quite close to the machine. However, the machine
was not a digital phone switch.
Even BCPL's manual (in 1967) states that
BCPL is a simple recursive programming language designed for
compiler writing and system programming.
Note that it mentions both compiler writing 9quite high level) as well
as the system programming that you mention.
C, in fact was designed as a system implementation language for Unix,
which AFAIK never ran on a telephone switch.
Yes, BCPL, B, C and C++ can all be used to program directly on hardware,
but they're not designed for that.
Martien
References available from Dennis Ritchie's home page at
http://www.cs.bell-labs.com/who/dmr/
--
Martien Verbruggen |
Interactive Media Division | Little girls, like butterflies, need
Commercial Dynamics Pty. Ltd. | no excuse - Lazarus Long
NSW, Australia |
------------------------------
Date: 23 Dec 2000 06:07:31 GMT
From: The WebDragon <nospam@nospam.com>
Subject: Re: Understanding interpolation
Message-Id: <921ff3$lo5$0@216.155.33.144>
In article <lud64tkea10sqdvangskvac8jtqs8efqs3@4ax.com>, Bart Lateur
<bart.lateur@skynet.be> wrote:
| Do integer divide by group size. Er... in Perl, that is divide, and take
| int() of the result. Then, take modulo colors. Here, both numbers are 2;
| and 3 in your other example.
|
| Here's an example with 3 colors and groupsize of 2:
|
| @color = qw(orange none green);
| my $grouped = 2;
| for(my $i = 0; $i < 3 * $grouped * @color; $i++) {
| print "Line @{[$i+1]}: $color[int($i/$grouped)%@color]\n";
| }
|
| Note that for the arithmetic, my first line is number 0; for printout,
| it's 1.
ahhh okay.. makes sense. for a larger list just start i at 0, increment
each time through the loop, and this will work for a list of any
arbitrary length & group-size, such as:
sub hash_out {
my $hashref = shift;
my @color = qw(orange none green);
my $grouped = 5;
my $i = 0;
foreach my $keys (reverse sort keys %{$hashref}) {
# do/print something with %some_hash
print "Line @{[$i+1]}: $color[int($i/$grouped)%@color]\n";
$i++;
}
return;
}
or whatever other necessary structure ..
very very slick.
--
send mail to mactech (at) webdragon (dot) net instead of the above address.
this is to prevent spamming. e-mail reply-to's have been altered
to prevent scan software from extracting my address for the purpose
of spamming me, which I hate with a passion bordering on obsession.
------------------------------
Date: Sat, 23 Dec 2000 05:21:59 GMT
From: Uri Guttman <uri@sysarch.com>
Subject: Re: Why are multiple zeroes true?
Message-Id: <x7vgsbd85k.fsf@home.sysarch.com>
>>>>> "DD" == Darren Dunham <ddunham@redwood.taos.com> writes:
DD> 1) If it's not reasonable, and we want to specify a different line,
DD> where do we draw it? Which of the following should be false? Every
DD> one of them is false when compared numerically.
comparing numerically is not the same as boolean context in perl.
$foo == 1 is not a boolean context but it generates a boolean value (see
tom's much earlier post for a subtle nicety of that value).
only tests like if, while, unless, until, and, or, ||, && create boolean
contexts. in a boolean context '00' is true.
DD> '0'
false
DD> '00'
DD> '0000000'
DD> '000000.000000'
DD> '0.0.0'
DD> '0 ' (trailing/leading space within the string)
all true
DD> '0e0'
DD> '0e50'
DD> '0e50.'
all false. they are numberic literals that compile to 0.
DD> '0elvis'
DD> '0_0._'
DD> '(0)'
DD> '+0'
DD> '-0'
all true. they are strings which are not '' or '0'
DD> 2) Does this really bust folks much? Any time I think I might be
DD> getting a string (because I'm reading a file rather than doing a
DD> calculation), I'll put in an explicit ($i != 0) test.
that is not a boolean context. you are explicitly checking against a
numeric value of 0. this has nothing to do with the false values in
perl.
DD> I can imagine that the 'right' way to do it would have been for the
DD> string '0' to also be false, but that it's just too hard to guarantee
DD> that you'll never stringify a false numeric 0. If 'fixing' this were
DD> easy, I guess I'd be all for it. But I'd rather have '0' be true than
DD> try to make some sort rule for why '00' is false.
huh? the string '0' IS false. rephrase that paragraph please.
uri
--
Uri Guttman --------- uri@sysarch.com ---------- http://www.sysarch.com
SYStems ARCHitecture, Software Engineering, Perl, Internet, UNIX Consulting
The Perl Books Page ----------- http://www.sysarch.com/cgi-bin/perl_books
The Best Search Engine on the Net ---------- http://www.northernlight.com
------------------------------
Date: Sat, 23 Dec 2000 05:43:05 GMT
From: Rick Delaney <rick.delaney@home.com>
Subject: Re: Why are multiple zeroes true?
Message-Id: <3A443F07.8FBA393F@home.com>
Uri Guttman wrote:
>
> >>>>> "DD" == Darren Dunham <ddunham@redwood.taos.com> writes:
>
> DD> '0e0'
> DD> '0e50'
> DD> '0e50.'
>
> all false. they are numberic literals that compile to 0.
They aren't numeric literals when they have quotes around them (as
shown). They are true strings. Or do you mean you think the string
'0e0' should be treated as false? (I assume no, based on your handy
derived-from-undef rule).
> DD> I can imagine that the 'right' way to do it would have been for the
> DD> string '0' to also be false, but that it's just too hard to guarantee
> DD> that you'll never stringify a false numeric 0. If 'fixing' this were
> DD> easy, I guess I'd be all for it. But I'd rather have '0' be true than
> DD> try to make some sort rule for why '00' is false.
>
> huh? the string '0' IS false. rephrase that paragraph please.
I think it's pretty clear from the context that he meant to type, "for
the string '0' to also be TRUE".
--
Rick Delaney
rick.delaney@home.com
------------------------------
Date: Sat, 23 Dec 2000 06:25:09 GMT
From: Uri Guttman <uri@sysarch.com>
Subject: Re: Why are multiple zeroes true?
Message-Id: <x7snnfd58a.fsf@home.sysarch.com>
>>>>> "RD" == Rick Delaney <rick.delaney@home.com> writes:
RD> Uri Guttman wrote:
>>
>> >>>>> "DD" == Darren Dunham <ddunham@redwood.taos.com> writes:
>>
DD> '0e0'
DD> '0e50'
DD> '0e50.'
>>
>> all false. they are numberic literals that compile to 0.
RD> They aren't numeric literals when they have quotes around them (as
RD> shown). They are true strings. Or do you mean you think the string
RD> '0e0' should be treated as false? (I assume no, based on your handy
RD> derived-from-undef rule).
bad eyeballs. i parsed them as though he was trying odd values of 0 and
not strings.
DD> I can imagine that the 'right' way to do it would have been for the
DD> string '0' to also be false, but that it's just too hard to guarantee
DD> that you'll never stringify a false numeric 0. If 'fixing' this were
DD> easy, I guess I'd be all for it. But I'd rather have '0' be true than
DD> try to make some sort rule for why '00' is false.
>>
>> huh? the string '0' IS false. rephrase that paragraph please.
RD> I think it's pretty clear from the context that he meant to type, "for
RD> the string '0' to also be TRUE".
maybe but that is why i was confused. :)
uri
--
Uri Guttman --------- uri@sysarch.com ---------- http://www.sysarch.com
SYStems ARCHitecture, Software Engineering, Perl, Internet, UNIX Consulting
The Perl Books Page ----------- http://www.sysarch.com/cgi-bin/perl_books
The Best Search Engine on the Net ---------- http://www.northernlight.com
------------------------------
Date: Sat, 23 Dec 2000 05:23:39 GMT
From: Rick Delaney <rick.delaney@home.com>
Subject: Re: Why not have lvalue subs autovivification?
Message-Id: <3A443A78.C544403D@home.com>
[posted & mailed]
John Lin wrote:
>
> IMHO, in future versions of Perl, if autovivification is applied
> on lvalue subs, this feature will be much more useful and flexible.
>
> What do you think about it?
This has already been reported as a bug to p5p. There was no discussion
for or against it. The bug id is 20001110.003, in case you'd like to
submit a patch. :-)
--
Rick Delaney
rick.delaney@home.com
------------------------------
Date: 16 Sep 99 21:33:47 GMT (Last modified)
From: Perl-Users-Request@ruby.oce.orst.edu (Perl-Users-Digest Admin)
Subject: Digest Administrivia (Last modified: 16 Sep 99)
Message-Id: <null>
Administrivia:
The Perl-Users Digest is a retransmission of the USENET newsgroup
comp.lang.perl.misc. For subscription or unsubscription requests, send
the single line:
subscribe perl-users
or:
unsubscribe perl-users
to almanac@ruby.oce.orst.edu.
| NOTE: The mail to news gateway, and thus the ability to submit articles
| through this service to the newsgroup, has been removed. I do not have
| time to individually vet each article to make sure that someone isn't
| abusing the service, and I no longer have any desire to waste my time
| dealing with the campus admins when some fool complains to them about an
| article that has come through the gateway instead of complaining
| to the source.
To submit articles to comp.lang.perl.announce, send your article to
clpa@perl.com.
To request back copies (available for a week or so), send your request
to almanac@ruby.oce.orst.edu with the command "send perl-users x.y",
where x is the volume number and y is the issue number.
For other requests pertaining to the digest, send mail to
perl-users-request@ruby.oce.orst.edu. Do not waste your time or mine
sending perl questions to the -request address, I don't have time to
answer them even if I did know the answer.
------------------------------
End of Perl-Users Digest V9 Issue 5187
**************************************