[17907] in Perl-Users-Digest

home help back first fref pref prev next nref lref last post

Perl-Users Digest, Issue: 67 Volume: 10

daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Mon Jan 15 21:05:36 2001

Date: Mon, 15 Jan 2001 18:05:11 -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: <979610711-v10-i67@ruby.oce.orst.edu>
Content-Type: text

Perl-Users Digest           Mon, 15 Jan 2001     Volume: 10 Number: 67

Today's topics:
    Re: "Decimal to IP" golf anyone? <srmalloy@home.com>
    Re: Can't associate .PL files in Win98 <efflandt@xnet.com>
    Re: Can't get Apache, Win98, and Mod_Perl working. <randy@theory.uwinnipeg.ca>
    Re: exit sandywadkins123@my-deja.com
    Re: Forward engineering Perl from Dia <collin.starkweather@collinstarkweather.com>
    Re: Help me append <eddyneal@earthlink.net>
    Re: Limits on array and hash storage (Greg Bacon)
    Re: Passing a parameter to a "sort" sub? <joe+usenet@sunstarsys.com>
    Re: Pattern Matching <hafateltec@hotmail.com>
    Re: Pattern Matching <hafateltec@hotmail.com>
    Re: Perl 5.6.0 and File::Basename <randy.galbraith@pegs.com>
    Re: Perl 5.6.0 and File::Basename (Greg Bacon)
    Re: Perl 5.6.0 and File::Basename (Greg Bacon)
    Re: Perl 5.6.0 and File::Basename (Tad McClellan)
        RegEx , matching ? <ricky@mymail.faq>
    Re: simple newbie question <illusi0n@REMOVEspeakeasy.net>
    Re: simple newbie question (Craig Berry)
    Re: Using hash arrays (?) (Tad McClellan)
    Re: ZIp Code Perl Program <elijah@workspot.net>
        Digest Administrivia (Last modified: 16 Sep 99) (Perl-Users-Digest Admin)

----------------------------------------------------------------------

Date: Tue, 16 Jan 2001 00:45:23 GMT
From: Sean Malloy <srmalloy@home.com>
Subject: Re: "Decimal to IP" golf anyone?
Message-Id: <0u576tglefo7a1cfn965rdf449lv2rbd2i@4ax.com>

Russ Jones <russ_jones@rac.ray.com> wrote:
>I have an IP address that's stored in Oracle as number(12). For
>example, the number
>	2467918155
>converted to hex is
>	93 19 71 4b
>which, converted back to decimal a byte at a time, is
>	147.25.113.75 (viola, my IP address!)
>So to get it formatted as a dotted IP, I'm using this:
>	$dotted = sprintf("%vd",pack('N',$number));
>
>Works fine, but does anyone have any better ways? Or just different?
>Just curious, I learn a lot from these golf matches

There's always the brute-force method: 

	$IP = $decaddr % 256;
	for ($i=1;$i<4;$i++)
	{
	    $decaddr = $decaddr >> 8;
	    $IP = ($decaddr % 256) . "." . $IP;
	}

It may be crude, but it works.

-- 
Sean R. Malloy               | American Non Sequitur
    Naval Medical Center     |       Society
    San Diego, CA 92134-5000 |
srmalloy@home.net            | "We may not make sense,
srmalloy@nmcsd.med.navy.mil  |  but we do like pizza"
FORMAL NOTICE: unsolicited commercial email will be read
at a charge of $500 per item. Receipt of such email shall
be considered to constitute acceptance of contract, and 
will be billed immediately.


------------------------------

Date: Mon, 15 Jan 2001 19:01:49 -0600
From: David Efflandt <efflandt@xnet.com>
To: Gary Burton <glburton@mindspring.com>
Subject: Re: Can't associate .PL files in Win98
Message-Id: <Pine.LNX.4.21.0101151808160.30204-100000@efflandt.xnet.com>

On Sun, 14 Jan 2001, Gary Burton wrote:

> The association still would not work in Windows 98.  An opinion on one
> of the discussion groups was that it can't be done for shell
> (DOS) programs in Win95 or Win98, although it works fine in Windows
> NT.  Unfortunately, that seems to be correct because I carefully
> reviewed the instructions in ActiveState's perlwin32faq4 FAQ called "How
> do I associate Perl scripts with Perl?" and followed them precisely.

While the file association does not work from the DOS shell, it does work
from Windows Explorer (see below).  From the DOS shell you either run the
script as a commandline parameter to Perl, or use pl2bat to convert it to
a .bat file.  This requires that Perl and pl2bat are in your PATH (usually
C:\PERL\BIN).  The pl2bat worked for me.

> It acts like it isn't even finding the Perl executable.  I tried putting
> "Sleep 10" and <stdin> in my script, and neither kept the window open.

Perl is case sensitive and those are invalid.  To see results of your
script in a popup window end it with one of (precisely):

sleep 10;
<STDIN>;
 
> I did find a solution, although I don't like it much.  I created a batch
> file called perl.bat in my c:\bat\ folder.  Then I associated the .plx
> extension with c:\bat\perl.bat.  Perl.bat only contains one line:
>     c:\Perl\bin\perl5.6.0.exe %1 %2
> That works, but I don't like it because I don't like throwing programs
> in just to run programs, and the window doesn't close after the
> application finishes.
> 
> Related questions:
> *   Have you ever actually SEEN the association work in Windows 98?  If
>     so, I will continue to fight the battle.  By the way, I have the
>     first edition of Win98; but I don't think that matters.

I had not used Perl in Windows since the original Perl5 that succeeded
perl4 and predated Activestate.  Just to see how it worked, I installed
the latest Activestate .msi Win installer version (not .zip version).  
There were checkboxes to add Perl in my path and associate PL with Perl.  
I had to reboot before it worked, but the file association works fine in
Win98se.  I wrote a simple script with DOS EDIT called mytest.pl on the
desktop and it executed when I clicked on it, and I was able to read the
result with either a sleep 5; or <STDIN>; at the end.  I didn't even begin
the script with a shebang line (which might be required for apache).

> *   My c:\Perl\bin folder contains both Perl.exe and perl5.6.0.exe.  Is
>     there a difference?  If so, what is it?

I imagine it is just so if you have more than one perl version installed,
you can use a specific one.

> *   "Learning Perl on Win32 Systems" recommends assigning a .PLX
>     extension to the scripts as opposed to the .PL extension to avoid
>     confusion with the Perl libraries.  Yet, the FAQ "How do I associate
>     Perl scripts with Perl?" and all the examples show the .PL
>     extension.  What do you think?

Activestate set up the PL file association for "Open" to run:
C:\PERL\BIN\PERL.EXE "%1 %"
 
> David Efflandt wrote:
> > 
> > On Sat, 13 Jan 2001 12:39:37 -0800, Gary Burton <glburton@mindspring.com> wrote:
> > > I am a newbie using Win98.  I am using ActivePerl v5.6, and working from
> > > the ActivePerl online documentation.  I can run my example programs from
> > > a DOS window by typing in "Perl filename"; but when I associate the .PL
> > > extension as the literature suggest, all I get is a DOS window that
> > > closes so quickly that I can't read the error message.
> > 
> > Your computer is too fast.  8^)  Seriously it has been awhile since I have
> > done Perl in Windows (Perl5 before Activestate), but file association
> > should work.  If you want to see the result, you either need to put a
> > sleep at the end or something that waits for input like this:
> > 
> > <STDIN>;
> > 
> > Then just hit the enter key after reading the result.

-- 
David Efflandt  efflandt@xnet.com  http://www.de-srv.com/
http://www.autox.chicago.il.us/  http://www.berniesfloral.net/
http://cgi-help.virtualave.net/  http://hammer.prohosting.com/~cgi-wiz/



------------------------------

Date: Mon, 15 Jan 2001 18:31:35 -0600
From: "Randy Kobes" <randy@theory.uwinnipeg.ca>
Subject: Re: Can't get Apache, Win98, and Mod_Perl working.
Message-Id: <94054d$nu8$1@canopus.cc.umanitoba.ca>

<shiloam@my-deja.com> wrote in message
    news:93vhco$sre$1@nnrp1.deja.com...
> I am running Windows 98 and have successfully configured Apache 1.3.12
> to run just fine. I have recently installed ActivePerl and have been
> teaching myself the language. I have Perl 5.6.0 and I have downloaded
> the Mod_Perl apache from the Perl site as well. I cannot seem to get it
> working however. Everytime I try to use the LoadModule perl_module
> modules/ApacheModulePerl or LoadModule perl_module
> modules/ApacheModulePerl.dll it doesn't work, and gives me a can't load
> module error. When I try to register this dll using regsrv32 it says
> that it can't load the dll as well.

Are you using the mod_perl ppm package and the
ApacheModulePerl.dll that matches your Apache version?
And is the ActivePerl perl binary included in your PATH
when you start Apache?

best regards,
randy kobes





------------------------------

Date: Mon, 15 Jan 2001 23:01:21 GMT
From: sandywadkins123@my-deja.com
Subject: Re: exit
Message-Id: <93vvfs$a2a$1@nnrp1.deja.com>

Sorry I was struggling when I typed question.

Have program like a shopping cart, when user comes in I give them a
tempxxx.dat file, when they order I delete tempxxx.dat.

Problem: if they don't complete order and just get out of site I have a
 tempxxx.dat file left out there. I need to be able to capture when
 they get out of site.

Question: How can I capture when user gets out of site?

thanks sandy




In article <87n1cslfyh.fsf@limey.hpcc.uh.edu>,
  Tony Curtis <tony_curtis32@yahoo.com> wrote:
> >> On Mon, 15 Jan 2001 18:46:12 GMT,
> >> sandywadkins123@my-deja.com said:
>
> > Perl 5, HTML, little java script.  Ok I wrote scripts
> > making each user have a temp. file (xxx.dat). When they
> > sumit it updates a file, then gets deleted.
>
> > Question: if they don't submit and close it the file is
> > hanging out there. So how can I capture when they exit?
>
> Sorry, too many dangling referents.  I appreciate English
> may not be your first language, but more details are
> required here to help people understand what you are
> trying to do.  There are too many "it"s and missing nouns
> to allow someone to know what does what and to what.
>
> hth
> t
> --
> Eih bennek, eih blavek.
>


Sent via Deja.com
http://www.deja.com/


------------------------------

Date: Mon, 15 Jan 2001 17:56:35 -0800
From: Collin Starkweather <collin.starkweather@collinstarkweather.com>
To: Terrence Brannon <brannon@lnc.usc.edu>
Subject: Re: Forward engineering Perl from Dia
Message-Id: <3A63AA53.424A822A@collinstarkweather.com>

On 15 Jan 2001, Terrence Brannon wrote:

> Collin Starkweather <collin.starkweather@collinstarkweather.com> writes:
>
> > I have written basic Perl forward-engineering for Dia
> 
> What is meant by Perl forward-engineering?
> 
> > (http://www.lysator.liu.se/~alla/dia) into Javier O'Hara's dia2code
> > (http://sourceforge.net/projects/dia2code) (authored in C), but now that
> > I've accomplished the basics, I would like to solicit some comments from
> > anyone out there who may be interested.
> 
> Is what you did documented? Does it have examples? I went to the URLs   
> above and saw 2 other people's projects. I still have no idea what you
> did and how it relates to the above 2 things.
> 
> My guess is you have come up with some way of programming perl visually?

Should have given more background.
  
Dia is a diagramming tool with UML diagramming facilities.  It was
originally __just__ intended to be used for diagramming, but since folks
put UML into the mix, it seems there is interest in adding some of the
basic features normally associated with CASE tools.

dia2code is a code generation program which currently generates C++ and
Java code from UML diagrams generated in dia.  I am interested in
expanding the set of languages to enable dia2code to generate Perl
classes from UML diagrams specified in dia.

Though I have some primitive (but working) code, nothing has been
documented or posted yet because I'm still ruminating on the scope of
the contribution.  However, there are examples on dia2code's homepage

	http://dia2code.sourceforge.net/index.html

of the C++ and Java code generation capabilities.

> > There are four basic approaches I'm considering, and any comments or   
> > advice would be appreciated.
> > 
> > 1)  Generate all of the Perl explicitly from dia2code.  This would
> > retain dia2code intact as a standalone app.  Additionally, the C could
> > potentially be used via XS to facilitate a generic Perl code generation
> > module.
> >
> > 2)  Generate skeletons with h2xs and modify them as necessary.
>
> Well, XS is supposed to be thrown out with Perl 6. Correct me if I'm wrong.

I didn't realize that.  Thanks.

-Collin

-- 
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Collin Starkweather                           (303) 428-0100 x 112
Senior Architect                    collin.starkweather@active.com
Active.com, Inc.                 http://www.collinstarkweather.com
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~


------------------------------

Date: Tue, 16 Jan 2001 01:27:12 GMT
From: "E.Neal" <eddyneal@earthlink.net>
Subject: Re: Help me append
Message-Id: <QrN86.38053$U4.1100631@newsread1.prod.itd.earthlink.net>

Thanks for the help all.  Turns out that all I needed to do was change the
permissions of the text file.
Neal
"E.Neal" <eddyneal@earthlink.net> wrote in message
news:N2586.8300$U4.402153@newsread1.prod.itd.earthlink.net...
> I'm trying to update a text.  For some reason the way I'm trying to
> append doesn't work.  I have scoured the net and my local help files for
the
> answer, but I haven't been able to find it.  I can append when running
local
> scripts, but through the browser is where I'm running into trouble.  I
would
> appreciate any help.
>   Thanks,
>         Neal
>
> #!perl
>
> use CGI ':standard';
>
> print header();
> print start_html();
>
> $firstname = param(firstname);
> $lastname = param(lastname);
> $telephone = param(telephone);
>
> open (APPEND, '>> contact.txt');
> print APPEND $firstname," ",$lastname," ",$telephone;
> close APPEND;
>
> print end_html();
>
>
>
>
>
>




------------------------------

Date: Tue, 16 Jan 2001 00:57:19 -0000
From: gbacon@HiWAAY.net (Greg Bacon)
Subject: Re: Limits on array and hash storage
Message-Id: <t6773fjfmueice@corp.supernews.com>

In article <slrn966uqn.bbn.abigail@tsathoggua.rlyeh.net>,
    Abigail <abigail@foad.org> wrote:

: Really? There are operating systems that have swap that's located in
: memory that cannot be randomly accessed? Swap on punch cards does exist?

Damn that low unemployment. :-)

Greg
-- 
I am like a cigar: you have to suck on the end to get me going.
    -- Gustave Flaubert


------------------------------

Date: 15 Jan 2001 18:12:28 -0500
From: Joe Schaefer <joe+usenet@sunstarsys.com>
Subject: Re: Passing a parameter to a "sort" sub?
Message-Id: <m3snmkxvdv.fsf@mumonkan.sunstarsys.com>

tadmc@augustmail.com (Tad McClellan) writes:

> Mary Ellen Foster <mef@cogsci.ed.ac.uk> wrote:
> >Is it possible to pass parameters to a sort subroutine?
> 
> Nope.
> 

Maybe so.  You can try wrapping the sub in a block like this:

#!/usr/bin/perl -wl
my @list = reverse 0 .. 9;
sub order {
    print shift;
    $a <=> $b;
}

print sort { order("pizza") } @list;

HTH
-- 
Joe Schaefer


------------------------------

Date: Tue, 16 Jan 2001 10:43:37 +1000
From: "Mike McPherson" <hafateltec@hotmail.com>
Subject: Re: Pattern Matching
Message-Id: <9405gb$g0t$1@brokaw.wa.com>

Ok I have somwhat figured it out.  The match below chacks for a
xxx.xxx.xxx.xxx pattern allowing for only 0,1 or 2 on the first character
and on the first character after each "." and the rest checks to make sure
that the second and third character are each 0 thru 5 but now my delema.
How to make it match if the ip is input as 10.12.12.12 which I want to
return as a valid ip ???

unless ($validip =~
/^[012][012345]{2}.[012][012345]{2}.[012][012345]{2}.[012][012345]{2}/) {
print "\nNot a valid ip\n";
}




Mike McPherson <hafateltec@hotmail.com> wrote in message
news:93bdo4$duv$1@brokaw.wa.com...
> I am having some difficulty figuring out how to set up a pattern match to
> evaluate a ip address in the xxx.xxx.xxx.xxx format.
>
> Please help
>
> $patern_match_ip =
> $patern_match_name =
> if ($Webaddress = $patern_match_ip || $patern_match_name) {
> print "\nGood address\n";
> }else{
> print "\nBad address\n";
> }
>
> Thanks
>
>




------------------------------

Date: Tue, 16 Jan 2001 11:30:34 +1000
From: "Mike McPherson" <hafateltec@hotmail.com>
Subject: Re: Pattern Matching
Message-Id: <94088d$i1v$1@brokaw.wa.com>

Belay this last post... After testing I found this only validates up to
000,111,222,233,244,255 but not addresses like 239 etc...


Mike McPherson <hafateltec@hotmail.com> wrote in message
news:9405gb$g0t$1@brokaw.wa.com...
> Ok I have somwhat figured it out.  The match below chacks for a
> xxx.xxx.xxx.xxx pattern allowing for only 0,1 or 2 on the first character
> and on the first character after each "." and the rest checks to make sure
> that the second and third character are each 0 thru 5 but now my delema.
> How to make it match if the ip is input as 10.12.12.12 which I want to
> return as a valid ip ???
>
> unless ($validip =~
> /^[012][012345]{2}.[012][012345]{2}.[012][012345]{2}.[012][012345]{2}/) {
> print "\nNot a valid ip\n";
> }
>
>
>
>
> Mike McPherson <hafateltec@hotmail.com> wrote in message
> news:93bdo4$duv$1@brokaw.wa.com...
> > I am having some difficulty figuring out how to set up a pattern match
to
> > evaluate a ip address in the xxx.xxx.xxx.xxx format.
> >
> > Please help
> >
> > $patern_match_ip =
> > $patern_match_name =
> > if ($Webaddress = $patern_match_ip || $patern_match_name) {
> > print "\nGood address\n";
> > }else{
> > print "\nBad address\n";
> > }
> >
> > Thanks
> >
> >
>
>




------------------------------

Date: Mon, 15 Jan 2001 17:06:48 -0700
From: "Randy Galbraith" <randy.galbraith@pegs.com>
Subject: Re: Perl 5.6.0 and File::Basename
Message-Id: <9403ah$vt2$1@freepress.anasazi.com>

Ted, (and Greg),

Thank you!  That has got to be it (I take it your compare is the _complete_
diff between the modules).

- Randy

Tad McClellan wrote in message ...
>Randy Galbraith <randy.galbraith@pegs.com> wrote:
>>
>>I'm seeing a difference between Perl 5.005 and Perl 5.6.0 in how the
>>basename function works.  Here is the code snippet that demonstrates the
>>difference...
>
>[snip]
>
>>With perl v5.005_03 I get...
>>4 bn=>TICK<
>>
>>With perl v5.6.0 I get...
>>5 bn=>TICK
>><
>
>I get the same results. Looks like a bug in v5.005_03 has been fixed.
>
>
>>Is this a known issue?
>
>I don't know. Let's go find out for ourselves...
>
>   cd /usr/lib/perl5
>   find . -name Basename.pm
>   diff ./5.00503/File/Basename.pm ./5.6.0/File/Basename.pm | more
>
>...
>165c175
><       ($dirpath,$basename) = ($fullname =~ /^(.*[:>\]])?(.*)/);
>---
>>       ($dirpath,$basename) = ($fullname =~ /^(.*[:>\]])?(.*)/s);
>...
>
>
>Looks like filenames are suddenly allowed to contain newlines again.
>
>"Looks like" isn't very satisfying though, let's keep looking:
>
>   cd /unpacked/tarball/perl-5.6.0/
>   grep Basename Changes
>
>this one looks promising:
>
>      these insidious errors in File::Basename, File::Find and find2perl
>
>better have a closer look:
>
>   vi Changes
>
>___________________________________________________________________________
_
>[  5296] By: gsar                                  on 2000/02/28  00:00:05
>        Log: m/.*$/ etc should be m/.*\z/s in many file handling modules;
fix
>             these insidious errors in File::Basename, File::Find and
find2perl
>             (from Tom Christiansen)
>
>             TODO: many other modules need to be fixed as well!
>     Branch: perl
>           ! lib/File/Basename.pm lib/File/Find.pm x2p/find2perl.PL
>___________________________________________________________________________
_
>
>
>What a bunch those p5p, always looking out for us :-)
>
>
>--
>    Tad McClellan                          SGML consulting
>    tadmc@augustmail.com                   Perl programming
>    Fort Worth, Texas




------------------------------

Date: Tue, 16 Jan 2001 00:49:48 -0000
From: gbacon@HiWAAY.net (Greg Bacon)
Subject: Re: Perl 5.6.0 and File::Basename
Message-Id: <t676lcoct3iped@corp.supernews.com>

In article <9403ah$vt2$1@freepress.anasazi.com>,
    Randy Galbraith <randy.galbraith@pegs.com> wrote:

: Thank you!  That has got to be it (I take it your compare is the
: _complete_ diff between the modules).

It's not.  In the File::Basename's regular expressions, the following
two changes were made:

  - change $ (for end-of-string) to \z
  - add /s to each regular expression containing . (for any character)

Here's the complete diff:

--- perl5.005_03/lib/File/Basename.pm	Wed Jul 29 20:31:24 1998
+++ perl-5.6.0/lib/File/Basename.pm	Sun Feb 27 18:56:50 2000
@@ -37,10 +37,10 @@
 "VMS", "MSDOS", "MacOS", "AmigaOS" or "MSWin32", the file specification 
 syntax of that operating system is used in future calls to 
 fileparse(), basename(), and dirname().  If it contains none of
-these substrings, UNIX syntax is used.  This pattern matching is
+these substrings, Unix syntax is used.  This pattern matching is
 case-insensitive.  If you've selected VMS syntax, and the file
 specification you pass to one of these routines contains a "/",
-they assume you are using UNIX emulation and apply the UNIX syntax
+they assume you are using Unix emulation and apply the Unix syntax
 rules instead, for that function call only.
 
 If the argument passed to it contains one of the substrings "VMS",
@@ -73,7 +73,7 @@
 
 =head1 EXAMPLES
 
-Using UNIX file syntax:
+Using Unix file syntax:
 
     ($base,$path,$type) = fileparse('/virgil/aeneid/draft.book7',
 				    '\.book\d+');
@@ -102,7 +102,7 @@
 The basename() routine returns the first element of the list produced
 by calling fileparse() with the same arguments, except that it always
 quotes metacharacters in the given suffixes.  It is provided for
-programmer compatibility with the UNIX shell command basename(1).
+programmer compatibility with the Unix shell command basename(1).
 
 =item C<dirname>
 
@@ -111,8 +111,8 @@
 second element of the list produced by calling fileparse() with the same
 input file specification.  (Under VMS, if there is no directory information
 in the input file specification, then the current default device and
-directory are returned.)  When using UNIX or MSDOS syntax, the return
-value conforms to the behavior of the UNIX shell command dirname(1).  This
+directory are returned.)  When using Unix or MSDOS syntax, the return
+value conforms to the behavior of the Unix shell command dirname(1).  This
 is usually the same as the behavior of fileparse(), but differs in some
 cases.  For example, for the input file specification F<lib/>, fileparse()
 considers the directory name to be F<lib/>, while dirname() considers the
@@ -124,12 +124,22 @@
 
 
 ## use strict;
-use re 'taint';
+# A bit of juggling to insure that C<use re 'taint';> always works, since
+# File::Basename is used during the Perl build, when the re extension may
+# not be available.
+BEGIN {
+  unless (eval { require re; })
+    { eval ' sub re::import { $^H |= 0x00100000; } ' }
+  import re 'taint';
+}
+
+
 
+use 5.005_64;
+our(@ISA, @EXPORT, $VERSION, $Fileparse_fstype, $Fileparse_igncase);
 require Exporter;
 @ISA = qw(Exporter);
 @EXPORT = qw(fileparse fileparse_set_fstype basename dirname);
-use vars qw($VERSION $Fileparse_fstype $Fileparse_igncase);
 $VERSION = "2.6";
 
 
@@ -162,23 +172,23 @@
   if ($fstype =~ /^VMS/i) {
     if ($fullname =~ m#/#) { $fstype = '' }  # We're doing Unix emulation
     else {
-      ($dirpath,$basename) = ($fullname =~ /^(.*[:>\]])?(.*)/);
+      ($dirpath,$basename) = ($fullname =~ /^(.*[:>\]])?(.*)/s);
       $dirpath ||= '';  # should always be defined
     }
   }
   if ($fstype =~ /^MS(DOS|Win32)/i) {
-    ($dirpath,$basename) = ($fullname =~ /^((?:.*[:\\\/])?)(.*)/);
-    $dirpath .= '.\\' unless $dirpath =~ /[\\\/]$/;
+    ($dirpath,$basename) = ($fullname =~ /^((?:.*[:\\\/])?)(.*)/s);
+    $dirpath .= '.\\' unless $dirpath =~ /[\\\/]\z/;
   }
-  elsif ($fstype =~ /^MacOS/i) {
-    ($dirpath,$basename) = ($fullname =~ /^(.*:)?(.*)/);
+  elsif ($fstype =~ /^MacOS/si) {
+    ($dirpath,$basename) = ($fullname =~ /^(.*:)?(.*)/s);
   }
   elsif ($fstype =~ /^AmigaOS/i) {
-    ($dirpath,$basename) = ($fullname =~ /(.*[:\/])?(.*)/);
+    ($dirpath,$basename) = ($fullname =~ /(.*[:\/])?(.*)/s);
     $dirpath = './' unless $dirpath;
   }
   elsif ($fstype !~ /^VMS/i) {  # default to Unix
-    ($dirpath,$basename) = ($fullname =~ m#^(.*/)?(.*)#);
+    ($dirpath,$basename) = ($fullname =~ m#^(.*/)?(.*)#s);
     if ($^O eq 'VMS' and $fullname =~ m:/[^/]+/000000/?:) {
       # dev:[000000] is top of VMS tree, similar to Unix '/'
       ($basename,$dirpath) = ('',$fullname);
@@ -190,7 +200,7 @@
     $tail = '';
     foreach $suffix (@suffices) {
       my $pat = ($igncase ? '(?i)' : '') . "($suffix)\$";
-      if ($basename =~ s/$pat//) {
+      if ($basename =~ s/$pat//s) {
         $taint .= substr($suffix,0,0);
         $tail = $1 . $tail;
       }
@@ -228,30 +238,30 @@
     }
     if ($fstype =~ /MacOS/i) { return $dirname }
     elsif ($fstype =~ /MSDOS/i) { 
-        $dirname =~ s/([^:])[\\\/]*$/$1/;
+        $dirname =~ s/([^:])[\\\/]*\z/$1/;
         unless( length($basename) ) {
 	    ($basename,$dirname) = fileparse $dirname;
-	    $dirname =~ s/([^:])[\\\/]*$/$1/;
+	    $dirname =~ s/([^:])[\\\/]*\z/$1/;
 	}
     }
     elsif ($fstype =~ /MSWin32/i) { 
-        $dirname =~ s/([^:])[\\\/]*$/$1/;
+        $dirname =~ s/([^:])[\\\/]*\z/$1/;
         unless( length($basename) ) {
 	    ($basename,$dirname) = fileparse $dirname;
-	    $dirname =~ s/([^:])[\\\/]*$/$1/;
+	    $dirname =~ s/([^:])[\\\/]*\z/$1/;
 	}
     }
     elsif ($fstype =~ /AmigaOS/i) {
-        if ( $dirname =~ /:$/) { return $dirname }
+        if ( $dirname =~ /:\z/) { return $dirname }
         chop $dirname;
-        $dirname =~ s#[^:/]+$## unless length($basename);
+        $dirname =~ s#[^:/]+\z## unless length($basename);
     }
     else { 
-        $dirname =~ s:(.)/*$:$1:;
+        $dirname =~ s:(.)/*\z:$1:s;
         unless( length($basename) ) {
 	    local($File::Basename::Fileparse_fstype) = $fstype;
 	    ($basename,$dirname) = fileparse $dirname;
-	    $dirname =~ s:(.)/*$:$1:;
+	    $dirname =~ s:(.)/*\z:$1:s;
 	}
     }
 
End of Patch.
-- 
Working in groups is difficult when you're omnipotent.
    -- Q


------------------------------

Date: Tue, 16 Jan 2001 00:55:53 -0000
From: gbacon@HiWAAY.net (Greg Bacon)
Subject: Re: Perl 5.6.0 and File::Basename
Message-Id: <t6770p7i4p5lcc@corp.supernews.com>

In article <t66tovlvt1ad04@corp.supernews.com>,
    Greg Bacon <gbacon@hiwaay.net> wrote:

: [...] I'll post a link to the p5p thread when I find it.

Tom posted an analysis of the issue to p5p, but after digging through
the archive, I'm unable to find it. :-(

Greg
-- 
A lawyer is an expert on justice in the same way that a whore is an expert on
love.


------------------------------

Date: Mon, 15 Jan 2001 18:02:55 -0500
From: tadmc@augustmail.com (Tad McClellan)
Subject: Re: Perl 5.6.0 and File::Basename
Message-Id: <slrn9670cu.djg.tadmc@tadmc26.august.net>


[ Please put your comments *following* the quoted text that you
  are commenting on.

  Please do not quote an entire article.

  Please do not quote .sigs.

  Please see:     http://www.geocities.com/nnqweb/nquote.html

  Thank you.

  Jeopardectomy performed.
]


Randy Galbraith <randy.galbraith@pegs.com> wrote:
>Tad McClellan wrote in message ...
>>Randy Galbraith <randy.galbraith@pegs.com> wrote:
>>>
>>>I'm seeing a difference between Perl 5.005 and Perl 5.6.0 in how the
>>>basename function works.


>>I don't know. Let's go find out for ourselves...
>>
>>   cd /usr/lib/perl5
>>   find . -name Basename.pm
>>   diff ./5.00503/File/Basename.pm ./5.6.0/File/Basename.pm | more
>>
>>...
>>165c175
>><       ($dirpath,$basename) = ($fullname =~ /^(.*[:>\]])?(.*)/);
>>---
>>>       ($dirpath,$basename) = ($fullname =~ /^(.*[:>\]])?(.*)/s);


>Ted, (and Greg),


Yes Brandy?


>Thank you!  


You're welcome.


>That has got to be it (I take it your compare is the _complete_
>diff between the modules).


No, it is only a small snippet. That is why I showed how to
generate it, so that you could go see for yourself.


-- 
    Tad McClellan                          SGML consulting
    tadmc@augustmail.com                   Perl programming
    Fort Worth, Texas


------------------------------

Date: Tue, 16 Jan 2001 00:57:50 GMT
From: "Ricky" <ricky@mymail.faq>
Subject: RegEx , matching ?
Message-Id: <i0N86.62194$eB2.5281991@news.infostrada.it>

I've just read a post on regex that made curios about the following thing:

Suppose I have :
$string = 'abc ab abcde abcDef abc 123 ab';

the regex : /([A-Za-z]+)/ returns me ($1) 'abc' which is 3 char long.
Imagine now I want that regexp to return me 'abcDef' which is 6 char long.

I thought of this example:

##########################
# this part prints 'abc'
$string = 'abc ab abcde abcDef abc 123 ab';
$string =~ /([A-Za-z]+)/;
print length($1)." characters -> ".$1;
print "\n";

# this part prints 'abcDef'
$string = 'abc ab abcde abcDef abc 123 ab';
$biggest="";
foreach ($string =~ /([A-Za-z]+)/g){
 $biggest=$_ if(length($biggest)<length($_));
}
print length($biggest)." characters -> ".$biggest;
##########################

My example prints :
3 characters -> abc
6 characters -> abcDef

Now, I got what I wanted to get, but not in the way I wanted. In other
words, is there a way to get abcDef with just a line, so in just a regex,
without using a loop ?
I'd like a thing like $string =~ /([A-Za-z]+)/; easy and clean, is it
possible ?

I thank you all very much in advance,

Ricky





------------------------------

Date: Mon, 15 Jan 2001 18:09:45 -0500
From: "illusion" <illusi0n@REMOVEspeakeasy.net>
Subject: Re: simple newbie question
Message-Id: <OpL86.1944$Q06.39802@e420r-atl2.usenetserver.com>

thanks to both.. i guess i didnt search hard enough in the docs. i
appreciate the help



Eric Bohlman <ebohlman@omsdev.com> wrote in message
news:93vm04$g1h$1@bob.news.rcn.net...
> illusion <illusi0n@removespeakeasy.net> wrote:
> > whats the difference between 'for' and 'foreach'?
>
> > im sorry for sounding dumb.. im learning. =\
>
> The perlsyn document that came with your copy of Perl will explain the
> "difference."  When learning, it's *really* important to familiarize
> yourself with Perl's built-in documentation.
>
>
>




------------------------------

Date: Mon, 15 Jan 2001 23:39:57 -0000
From: cberry@cinenet.net (Craig Berry)
Subject: Re: simple newbie question
Message-Id: <t672idpnmrlm07@corp.supernews.com>

illusion (illusi0n@REMOVEspeakeasy.net) wrote:
: whats the difference between 'for' and 'foreach'?

Four letters. :)  Seriously, no semantic difference, merely two alternate
ways to express exactly the same thing.  Some people use the former for
C-style for loops and the latter for list iteration loops, but this is
purely a matter of style.

: im sorry for sounding dumb.. im learning. =\

Then the doc is your friend.

  perldoc perlsyn | grep foreach

yields only 15 lines of output, two of which are

     The `foreach' keyword is actually a synonym for the `for'
     keyword, so you can use `foreach' for readability or `for'

-- 
   |   Craig Berry - http://www.cinenet.net/~cberry/
 --*--  "The hills are burning, and the wind is raging; and the clock
   |   strikes midnight in the Garden of Allah." - Don Henley


------------------------------

Date: Mon, 15 Jan 2001 17:18:45 -0500
From: tadmc@augustmail.com (Tad McClellan)
Subject: Re: Using hash arrays (?)
Message-Id: <slrn966tq5.dhd.tadmc@tadmc26.august.net>

William Cardwell <EUSWMCL@am1.ericsson.se> wrote:
>I want each hash to be an array and handle elements in loops to print
>each array element in a column and each hash key as a row. Doing it
>laboriously for known no. of rows and columns I can do this:
>
>$a[1]{x}='a1x';


What happened to $a[0]?


>$a[1]{y}='a1y';
>$a[1]{z}='a1z';
>$a[2]{x}='a2x';
>$a[2]{y}='a2y';
>$a[2]{z}='a2z';

>yielding this:
>
>a1x     a2x
>a1y     a2y
>a1z     a2z
>
>How do I put the print in a loop for each row for each column of unknown
>dimensions?


The dimensions may be unknown to you, but they aren't unknown to perl,
so ask it.

Assuming you always have the same keys:

----------------
foreach my $key ( sort keys %{$a[1]} ) {
   my $indent = '';
   foreach my $i ( 1..$#a ) {
      print $indent;
      print $a[$i]{$key};
      $indent = ' ' x 5;  # indent all but first one
   }
   print "\n";
}
----------------


-- 
    Tad McClellan                          SGML consulting
    tadmc@augustmail.com                   Perl programming
    Fort Worth, Texas


------------------------------

Date: 16 Jan 2001 00:02:08 GMT
From: Eli the Bearded <elijah@workspot.net>
Subject: Re: ZIp Code Perl Program
Message-Id: <eli$0101151856@qz.little-neck.ny.us>

In comp.lang.perl.misc, Phallicity  <phallicity_2000@yahoo.com> wrote:
> I am looking for a perl (cgi) script that will automatically enter a
> users city & state given a zip code, maybe one that I could simply
> implement using the require (".."); function call.  If anyone can tell
> me where to find one and how to implement it I would appreciate it.
> Please be as specific as possible for I am fairly new to Perl
> programming and am still learning.

If such a beast exists, it would probably be at CPAN. Did you
check CPAN? (www.cpan.org)

If you want to write such a thing, you'll need a listing of zips
and places. The only free one I know about is an old (1990) one
offered by the Census Bureau as a public service.

http://ftp.census.gov/geo/www/gazetteer/places.html

Rural areas may pose problems judging by the FAQ for the data.

Elijah
------
has it bookmarked since it takes so long to navigate to that page


------------------------------

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 V10 Issue 67
*************************************


home help back first fref pref prev next nref lref last post