[18164] in Perl-Users-Digest

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

Perl-Users Digest, Issue: 332 Volume: 10

daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Thu Feb 22 03:05:37 2001

Date: Thu, 22 Feb 2001 00:05:13 -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: <982829112-v10-i332@ruby.oce.orst.edu>
Content-Type: text

Perl-Users Digest           Thu, 22 Feb 2001     Volume: 10 Number: 332

Today's topics:
    Re: (OFF TOPIC) Re: This is driving me nuts and I need  <nospam.newton@gmx.li>
        Bug ID (20010221.010) (was: Re: \w{1} matches more than <mischief@velma.motion.net>
    Re: calling other executables from a perl script (Jayant V Rajan)
    Re: Can't be done?? <mischief@velma.motion.net>
    Re: Cannot write quatation marks to html... <mischief@velma.motion.net>
    Re: Change unknown filenames <dontspamthewebmaster@webdragon.net>
        Compiling perl sources? <meisl@amvt.tu-graz.ac.at>
    Re: Difficult Split Question (Gwyn Judd)
    Re: Difficult Split Question <joe+usenet@sunstarsys.com>
    Re: Difficult Split Question <godzilla@stomp.stomp.tokyo>
    Re: Finding multiply of prime factors (Martin Vorlaender)
    Re: Free debugger suggestions <bwalton@rochester.rr.com>
    Re: Help with ?: and ! operators  Thanks Guys <mshort@usol.com>
    Re: How to match nth occurance? <anon6111@hotmail.com>
    Re: I thought filehandles were Global? (Martin Vorlaender)
    Re: inconsistent behavior in CGI->param()? (Martin Vorlaender)
    Re: inconsistent behavior in CGI->param()? <c_clarkson@hotmail.com>
    Re: Is this taint example correct? (Michael Fuhr)
    Re: MacPerl help for a newbie <mbeards@altavista.com>
    Re: Module access to private vars in caller <bmb@ginger.libs.uga.edu>
        News::NNTPClient script resources? (Latka)
    Re: News::NNTPClient script resources? <c_clarkson@hotmail.com>
    Re: PerlScript documentation and reference ? <mischief@velma.motion.net>
        processes monitoring <hagertymitchell@[nospam]uswest.net>
    Re: Quickest way to convert all keys in a hash from upp (Garry Williams)
    Re: RegEx \w and other misunderstandings <mischief@velma.motion.net>
    Re: RegEx Help Pls <mischief@velma.motion.net>
    Re: Regexp to match Web urls? (Damian Conway)
    Re: Regexp to match Web urls? <uri@sysarch.com>
    Re: Whats wrong with this???? <mischief@velma.motion.net>
    Re: Whats wrong with this???? <c_clarkson@hotmail.com>
    Re: why do i get an unitialized value warning when read (David Efflandt)
        Digest Administrivia (Last modified: 16 Sep 99) (Perl-Users-Digest Admin)

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

Date: Thu, 22 Feb 2001 08:31:26 +0100
From: "Philip 'Yes, that's my address' Newton" <nospam.newton@gmx.li>
Subject: Re: (OFF TOPIC) Re: This is driving me nuts and I need a guru
Message-Id: <fpf99t0fgtfa08ei8tmo7tlkop2n21dh2j@4ax.com>

On Mon, 19 Feb 2001 08:07:20 GMT, Beable van Polasm <beable@my-deja.com> wrote:

> "Frank Miller" <no@email.com> writes:
> > "Randal L. Schwartz" <merlyn@stonehenge.com> writes:
> > > When you post to Usenet, you're expected to read the Usenet manual
> > > first.  "news.announce.newusers" is the location, to which you should
> > > have been already subscribed.
> >
> > FYI:  I just went and looked at news.announce.newusers.  I contains one
> > entry: "how to become a Usenet site".  If the information about how to
> > format your posts is buried in this document, then I doubt very many people
> > are going to see it.  I realise there are a lot of lazy jerks that post, but
> > just give people a little benefit of the doubt.
> 
> Randal must have meant news.newusers.questions.

I think he did mean news.announce.newusers; however, the periodical postings to
it appear to have stopped (except for a couple of postings such as "how to
become a Usenet site" that are cross-posted to news.answers).

This is unfortunate and I don't know why they no longer arrive. I'm willing to
send people copies of the documents I have archived, however, and they're
probably also available by mail from rtfm.mit.edu.

Cheers,
Philip
-- 
Philip Newton <nospam.newton@gmx.li>
That really is my address; no need to remove anything to reply.
If you're not part of the solution, you're part of the precipitate.


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

Date: Thu, 22 Feb 2001 05:05:30 -0000
From: Chris Stith <mischief@velma.motion.net>
Subject: Bug ID (20010221.010) (was: Re: \w{1} matches more than 1 character)
Message-Id: <t997gqa5o5sv26@corp.supernews.com>

Bertilo Wennergren <bertilow@chello.se> wrote:
> Csaba Raduly:

>> And so it came to pass that "Bertilo Wennergren" <bertilow@chello.se> 
>> on 18 Feb 2001 wrote <XFGj6.888$MU.8225@nntp1.chello.se>:

>> >The following two scripts do not produce the same output for me. 
>> >I think they should, as the only difference should be totally 
>> >irrelevant: [...]

>> >In the second version "\w{1}" matches all three characters,
>> >which is crazy, no?

>> >Is the "utf8" pragma bonkers?
  
>> s/(\w{2})/\U$1/;  doesn't work either (no multiplier does, apparently)

> Could anyone test this with a more recent Perl, e.g. on Unix or Linux? 
> Lots of things seem to have happened recently with Unicode. Does anyone 
> have a new test build to try this code on?

I don't have newer right now, but on 5.6.0 for Linux it gives the same
bizarre behavior. This seemed strange enough that i downloaded and built
5.6.0 fresh for testing it. I don't have anything newer than that around,
and building Perl once in a day is enough. ;-)

I submitted this as a bug, as I found no other mention of it in the groups
nor in the (admittedly, the digested version) p5p list.

Here's the info (adjusted line breaks):

#####################################
Your e-mail has been received by the Perl Bug Squashing Team.

     Original subject: perl 5.6.0, utf8, and the regex matche
mulitpliers such as /\w{2}/

A Bug ID (20010221.010) has been assigned and is shown in the
subject of this email. Please include this bug ID in the subject
line of any followup messages.

This is an automatic confirmation message.
#####################################

Chris

-- 
Christopher E. Stith
If they can get you asking the wrong questions, they don't
have to worry about the answers. -- Thomas Pynchon, Gravity's Rainbow



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

Date: 22 Feb 2001 05:20:37 GMT
From: jrajan@blue.seas.upenn.edu (Jayant V Rajan)
Subject: Re: calling other executables from a perl script
Message-Id: <9727j5$fp7$1@netnews.upenn.edu>

: What happens if you run the program where you replace the call to
: e-pcr with a trivial thing creating the file that would be created?

That's a good question. I'll check this out when I next sit down to work 
on the code. Thanks!

JR

: Abigail
: -- 
: perl -wle 'eval {die [[qq [Just another Perl Hacker]]]};; print
:            ${${${@}}[$#{@{${@}}}]}[$#{${@{${@}}}[$#{@{${@}}}]}]'


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

Date: Thu, 22 Feb 2001 04:29:13 -0000
From: Chris Stith <mischief@velma.motion.net>
Subject: Re: Can't be done??
Message-Id: <t995cp7boa903b@corp.supernews.com>

Karl Thompson <karlt@pine-grove.com> wrote:
> Hi,

> Sorry to double post, but there has been no reply to this message (posted
> Feb 8) under subject "Printing to Windows' default printer." Any ideas from
> anyone?

>>>Hi,

> I'm familiar with opening a device such as LPT1 and printing to the device.
> I don't understand how to print to Windows' default printer, whether it be a
> local printer or located on the network.

> What's the syntax for doing this please?

There's no syntax of which I'm aware that will automatically pick the default
printer.

There are Windows-specific modules that do things by interfacing with the API.
I believe, although I haven't coded for Windows in quite some time and never
professionally coded for it, that printing to the default printer can be done
through the API.

If nothing else, there's Win32:Registry or some similarly named module that
can help you find the default printer so you can print to it.

Chris

-- 
Christopher E. Stith
Get real!  This is a discussion group, not a helpdesk. You post
something, we discuss its implications. If the discussion happens to
answer a question you've asked, that's incidental. -- nobull, clp.misc



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

Date: Thu, 22 Feb 2001 04:06:16 -0000
From: Chris Stith <mischief@velma.motion.net>
Subject: Re: Cannot write quatation marks to html...
Message-Id: <t9941omvbhnl42@corp.supernews.com>

Jon Bell <jtbell@presby.edu> wrote:
> In article <mhxk6.18708$AH6.2555277@newsc.telia.net>,
> Fabian Thorbjörnsson <fabian@markisspecialisten.com> wrote:
>>
>>I'm running a perl script and I try to make i write "800" to an html-page.

> If you want to print a " literally, you must "escape" it with a '\'.  For 
> example:

>      print "Call this \"800\" number now!\n";

Or use a different quote syntax around.

   print qq{Call this "800" number now!\n};

Please don't mislead the newbies.
Please don't feed the Beanie Babies -- they're already stuffed!

Chris

-- 
Christopher E. Stith
Get real!  This is a discussion group, not a helpdesk. You post
something, we discuss its implications. If the discussion happens to
answer a question you've asked, that's incidental. -- nobull, clp.misc



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

Date: 22 Feb 2001 02:25:47 GMT
From: "Scott R. Godin" <dontspamthewebmaster@webdragon.net>
Subject: Re: Change unknown filenames
Message-Id: <971tbb$1la$0@216.155.32.245>

In article 
<35C7116C1C68EB19.2A45923C655E06E9.34023D16E0CB8CF6@lp.airnews.net>, 
"Charles K. Clarkson" <c_clarkson@hotmail.com> wrote:

 | or we could let s/// remember the old name:
 | 
 | find sub {
 |     rename $1, $_ if -f && s/^((.*\.)(pl|cgi|exe))$/$2txt/i;
 | }, $tempdir;
 | 

That's nice.. very slick. :-) 

*stuffing that one in my filefolder full of perl snippets*

-- 
unmunge e-mail here:
#!perl -w
print map {chr(ord($_)-3)} split //, "zhepdvwhuCzhegudjrq1qhw"; 
# ( damn spammers. *shakes fist* take a hint. =:P )


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

Date: 22 Feb 2001 08:23:11 +0100
From: Christian Meisl <meisl@amvt.tu-graz.ac.at>
Subject: Compiling perl sources?
Message-Id: <m3hf1n18rk.fsf@famvtpc59.tu-graz.ac.at>

I have tried to install Perl 5.6.0 at home (Win95). The sh Configure
worked perfectly, but the make aborted with an error. Is there a
general procedure how I can check what went wrong, or will I have to
dig into the source code itself?

Best regards,
Christian

-- 
Christian Meisl <meisl@amvt.tu-graz.ac.at>        www.amft.tu-graz.ac.at
   Inst. f. Apparatebau, Mech. Verfahrenstechnik und Feuerungstechnik
--- Every program is a part of some other program, and rarely fits. ----
PGP fingerprint:      DF48 2503 0411 F0EF 149C  851B 1EF0 72B9 78B6 034A


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

Date: Thu, 22 Feb 2001 03:33:44 GMT
From: tjla@guvfybir.qlaqaf.bet (Gwyn Judd)
Subject: Re: Difficult Split Question
Message-Id: <slrn99924m.7lf.tjla@thislove.dyndns.org>

I was shocked! How could Christopher Burke <craznar@hotmail.com>
say such a terrible thing:

>No - with quotes, you turn
>x,y,"pqr,st",z into ('x','y','pqr,st','z')
>
>What I want is to turn
>x,y,def(pqr,st),z into ('x','y','def(pqr,st)','z')
>
>A big enough difference to lose me in regex land...

Well you should have tried to use the one in the FAQ first. Then when
you failed, posting what you had done and mentioning that it was a
variation on the one in the FAQ would have helped you avoid people
saying "this is in the FAQ". Get it? :)

-- 
Gwyn Judd (print `echo 'tjla@guvfybir.qlaqaf.bet' | rot13`)
"My program doesn't work.""You forgot the semicolon.""But...""Line 376. Check.""But...""Trust me."


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

Date: 22 Feb 2001 00:04:59 -0500
From: Joe Schaefer <joe+usenet@sunstarsys.com>
Subject: Re: Difficult Split Question
Message-Id: <m3lmqz48as.fsf@mumonkan.sunstarsys.com>

"John Lin" <johnlin@chttl.com.tw> writes:

> Seeing you use $+, I think the last alternative should be  | (),
> 
> push @new, $+ while $text =~ m/
>      ([^(,]*\([^\)\\]*(?:\\.[^\)\\]*)*\)),? # changes in this line only
>    | ([^,]+),?
>    | (),  # <-------------- here
> /gx;
> 
> Otherwise, if $text eq 'a,,b,c' , when the last alternative matches
> $+ becomes undef.

There's more problems with it than just that (see below).

> Hmm...  Since this thread is Difficult "split" Question, what about using
> "split" to solve it?  I mean, to find out the RegEx used with split.

IMHO split() isn't feasible for splitting on quotes("), since I think 
it would require variable-width lookbehinds to see if you're inside a 
quoted region.  However I think it can be done in OP's case since a 
(negative) lookahead can accomplish this for parentheses.  

Here's one way below. Nested parentheses will fail unless the internal 
ones are escaped (which is certainly the case for a FAQ-derived answer 
as well).


#!/usr/bin/perl -wl
use strict;
while (<DATA>) {
  chomp;
  my @new;
  print"$_\t<==============";
  push @new, $+ while m/
        ([^(,]*\([^\)\\]*(?:\\.[^\)\\]*)*\)),? # changes in this line only
      | ([^,]+),?
      | (),
    /gx;
  print map {"[$_]\t"} @new;
  print map {"<$_>\t"} split /,(?! (?:[^(]|\\[(])* (?<!\\)[)] ) /x, $_;
  print "";
}

__END__
A,def(x,y,z),,b,pqr(m,n)
B,def\(x,y,z\),,b,pqr(m,n)
C(,def\(x,y,z\),),b,pqr(m,n)
D(,def\(x,y,z),\),b,pqr(m,n)
E\(,def(x,y,z\),),b,pqr(m,n)
F\(,def(x,y,z),\),b,pqr(m,n)
G(,def(x,y,z),),b,pqr(m,n)

Outputs

A,def(x,y,z),,b,pqr(m,n)        <============
[A]     [def(x,y,z)]    []      [b]     [pqr(m,n)]
<A>     <def(x,y,z)>    <>      <b>     <pqr(m,n)>

B,def\(x,y,z\),,b,pqr(m,n)      <============
[B]     [def\(x,y,z\),,b,pqr(m,n)]
<B>     <def\(x>        <y>     <z\)>   <>      <b>     <pqr(m,n)>

C(,def\(x,y,z\),),b,pqr(m,n)    <============
[C(,def\(x,y,z\),)]     [b]     [pqr(m,n)]
<C(,def\(x,y,z\),)>     <b>     <pqr(m,n)>

D(,def\(x,y,z),\),b,pqr(m,n)    <============
[D(,def\(x,y,z)]        [\)]    [b]     [pqr(m,n)]
<D(,def\(x,y,z)>        <\)>    <b>     <pqr(m,n)>

E\(,def(x,y,z\),),b,pqr(m,n)    <============
[E\(,def(x,y,z\),)]     [b]     [pqr(m,n)]
<E\(>   <def(x,y,z\),)> <b>     <pqr(m,n)>

F\(,def(x,y,z),\),b,pqr(m,n)    <============
[F\(,def(x,y,z)]        [\)]    [b]     [pqr(m,n)]
<F\(>   <def(x,y,z)>    <\)>    <b>     <pqr(m,n)>

G(,def(x,y,z),),b,pqr(m,n)      <============
[G(,def(x,y,z)] [)]     [b]     [pqr(m,n)]
<G(>    <def(x,y,z),)>  <b>     <pqr(m,n)>


Without knowing what test cases are relevant for OP's situation,
it's hard to say this is a sufficient answer.  But I certainly
think the split() solution above behaves better than the FAQ-derived 
one, and I wouldn't consider it a trivial modification of the FAQ 
answer.

HTH
-- 
Joe Schaefer   All the rest of that day, on those wild screaming beaches, 
                    The Fix-it-Up Chappie kept fixing up Sneetches.
                                               -- Dr. Seuss


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

Date: Wed, 21 Feb 2001 21:33:09 -0800
From: "Godzilla!" <godzilla@stomp.stomp.tokyo>
Subject: Re: Difficult Split Question
Message-Id: <3A94A495.930A5F6A@stomp.stomp.tokyo>

Christopher Burke wrote:
 
> I have input lines of the form :
 
> a,b,c,xyz(p,q,r),d
> a,def(x,y,z),b,pqr(m,n)
 
> I wish to split the line based on all ',' characters that are not between
> '(' and ')'.
 

You boys will be somewhat surprised to learn my basic
original method, wrapped in a do/until as I suggested,
is faster and more efficient than your complicated
regex method.


* demur smile *


Godzilla! * Just Amazing Perl Hacker *
--

(watch the word wrap - should be single lines)


TEST SCRIPT:
____________


#!perl

print "Content-type: text/plain\n\n";

use Benchmark;

timethese (100000,
 {
'name1' => '$text =
"a,b,c,def(g,h,i),j,k,lmn(o,p,q),r,stu(v,w),xyz,(1,2,3),4,5,6(7,8,9)";
            do
            {
             ($temp1) = $text =~ /(\([\w,]+\))/;
             $temp1 =~ tr/,/¿/;
             $text =~ s/\([\w,]+\)/$temp1/;
            }
            until (index ($text, "¿", rindex ($text, "(")) > -1);
            @Array = split (/,/, $text);
            foreach (@Array) { $_ =~ tr/¿/,/; }',

'name2' => '$text =
"a,b,c,def(g,h,i),j,k,lmn(o,p,q),r,stu(v,w),xyz,(1,2,3),4,5,6(7,8,9)";
            push @new, $+ while $text =~
m/([^(,]*\([^\)\\]*(?:\\.[^\)\\]*)*\)),?|([^,]+),?|(),/gx;',
});

exit;



PRINTED RESULTS:
________________

Benchmark: timing 100000 iterations of name1, name2...
name1: 19 wallclock secs (18.06 usr +  0.00 sys = 18.06 CPU) @ 5537.10/s
name2: 21 wallclock secs (20.88 usr +  0.00 sys = 20.88 CPU) @ 4789.27/s


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

Date: Thu, 22 Feb 2001 05:14:50 +0100
From: martin@radiogaga.harz.de (Martin Vorlaender)
Subject: Re: Finding multiply of prime factors
Message-Id: <3a94923a.524144494f47414741@radiogaga.harz.de>

Jonas Nilsson (jonni@ifm.liu.se) wrote:
> Heres a nice quick one that does it recursively.

And to speed it up a bit more:

sub factorize {
    use integer;  # only use integer arithmetic

    return (2, factorize($_[0] / 2))
        if $_[0] % 2 == 0;

    my $min = $_[1] || 3;  # no need to always start the loop at 3
    my $limit = int sqrt $_[0];
    for (my $i = $min; $i <= $limit; $i += 2) {
        return ($i, factorize($_[0] / $i, $i))
            if $_[0] % $i == 0;
    }

    return ($_[0]);
}

cu,
  Martin
--
One OS to rule them all       | Martin Vorlaender  |  VMS & WNT programmer
One OS to find them           | work: mv@pdv-systeme.de
One OS to bring them all      |   http://www.pdv-systeme.de/users/martinv/
And in the Darkness bind them.| home: martin@radiogaga.harz.de


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

Date: Thu, 22 Feb 2001 03:35:01 GMT
From: Bob Walton <bwalton@rochester.rr.com>
Subject: Re: Free debugger suggestions
Message-Id: <3A94895C.E636C686@rochester.rr.com>

mshort wrote:
> 
> I am currently using SynEdit for Perl editing, however, I don't like not
> have line numbers, but I like the fact that I can hit F8 and have the script
> run in dos mode.  Any suggestions on another editing tool?
 ...
> Matt
VIM is pretty good.
-- 
Bob Walton


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

Date: Wed, 21 Feb 2001 22:14:37 -0800
From: "mshort" <mshort@usol.com>
Subject: Re: Help with ?: and ! operators  Thanks Guys
Message-Id: <t991d9eclf2382@corp.supernews.com>

It took me a minute to figure this out because I try to explain to myself
what is going on in english and when you start thinking to yourself "not 1",
it's hard to equate that to False.

 I learned BASIC way back in highschool (about 10 years ago).  And wanted a
language that was a little more "english," since I tried Java and C++, but I
think Perl is a better choice for learning a first language.

The if..."then" statements of Perl take some getting used to as the "then"
part is a {.

I'll get the hang of this. Sooner or later ;)  But keep in mind I don't like
posting on flippant questions so if I have posted it's because I REALLY
CAN'T find the answer.


Sincerely,

Matt

Uri Guttman <uri@sysarch.com> wrote in message
news:x7zoffiyab.fsf@home.sysarch.com...
> >>>>> "MC" == Michael Carman <mjcarman@home.com> writes:
>
>
>   MC> ! is a boolean NOT. In Perl, the values 0, undef, and '' (the empty
>   MC> string) are boolean false. Everything else is true. The canonical
values
>   MC> for true and false are 1 and 0, respectively, and that's what you'll
get
>   MC> as a return value from ! EXPR.
>
> also '0' is false. and ! returns a special version of false that is ''
> in a string context and 0 in a numeric context. play with this:
>
> #!/usr/local/bin/perl -w
>
> $x = !1 ;
> $y = '' ;
>
> $sum = $x + 1 ;
>
> $sum2 = $y + 1 ;
>
> $string = "[$x]" ;
>
> print $sum, $sum2, $string, "\n" ;
>
>
> notice that there is a warning about the $sum2 line but not for the $sum
> line. that is because $x is both 0 and '' at the same time. you can use
> it in a numeric or string context without any warnings.
>
> 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: Thu, 22 Feb 2001 13:36:14 +1100
From: "Ash Kent" <anon6111@hotmail.com>
Subject: Re: How to match nth occurance?
Message-Id: <lX_k6.3205$v4.136908@ozemail.com.au>

Oops. I actually had a look at the regexps faq and couldn't find any
reference to this. I should have look in the data manipulation faq as well.
Sorry I posted a question that was answered in the faq.


Thanks Mahesh.



Ash.




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

Date: Thu, 22 Feb 2001 06:17:51 +0100
From: martin@radiogaga.harz.de (Martin Vorlaender)
Subject: Re: I thought filehandles were Global?
Message-Id: <3a94a0ff.524144494f47414741@radiogaga.harz.de>

tux (moot@cfl.rr.com) wrote:
> Maybe I'm delerious today. I opened a file in a package, and although
> the handle was global in the package, it wasn't scoped in main or other
> packages. I ended up doing somehting like:
 ...
> So I guess when the docs talk about a filehandle being global, it means
> global in a package?

Yes. All variables names (excluding lexical and magical ones) have a
(mostly invisible) "package::" before them. Have a look at %package::
(the package's symbol table).

cu,
  Martin
--
One OS to rule them all       | Martin Vorlaender  |  VMS & WNT programmer
One OS to find them           | work: mv@pdv-systeme.de
One OS to bring them all      |   http://www.pdv-systeme.de/users/martinv/
And in the Darkness bind them.| home: martin@radiogaga.harz.de


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

Date: Thu, 22 Feb 2001 06:30:16 +0100
From: martin@radiogaga.harz.de (Martin Vorlaender)
Subject: Re: inconsistent behavior in CGI->param()?
Message-Id: <3a94a3e8.524144494f47414741@radiogaga.harz.de>

Frank Hanny (fchanny@lbl.gov) wrote:
> In the following program, I would expect the contents of parameters 'a'
> and 'b' to be the same. Instead, 'a' contains only 3 elements, while 'b'
> contains 6. Is this a bug or a feature? 
>
> #!/usr/local/bin/perl
> use strict;
> use CGI(); 
>
> my $q;
>
> $q = CGI->new(); 
>
> $q->param( 'a', 0, undef, 1, undef, 2 );
> $q->param( -name=>'b', -value=>[ 0, undef, 1, undef, 2 ] );
>
> print
>     $q->header(),
>     $q->start_html(),
>     $q->dump(),
>     $q->end_html();

Care to tell how you would produce undefined values by "normal" means?

IMHO, param() doesn't have to deal with undefined values properly.
This is neither a bug nor a feature - it's outside of the values'
domain. Garbage in, garbage out.

cu,
  Martin
--
One OS to rule them all       | Martin Vorlaender  |  VMS & WNT programmer
One OS to find them           | work: mv@pdv-systeme.de
One OS to bring them all      |   http://www.pdv-systeme.de/users/martinv/
And in the Darkness bind them.| home: martin@radiogaga.harz.de


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

Date: Thu, 22 Feb 2001 01:21:08 -0600
From: "Charles K. Clarkson" <c_clarkson@hotmail.com>
Subject: Re: inconsistent behavior in CGI->param()?
Message-Id: <5280661D5A40C62C.13E3E76161956038.089F4E52F97713E9@lp.airnews.net>


"Frank Hanny" <fchanny@lbl.gov> wrote in message
news:3A92DF7C.CD630C3B@lbl.gov...
: In the following program, I would expect the contents of parameters 'a'
: and 'b' to be the same. Instead, 'a' contains only 3 elements, while 'b'
: contains 6. Is this a bug or a feature?
:
: Thanks,
:
: Frank Hanny
:
: #!/usr/local/bin/perl
: use strict;
: use CGI();
:
: my $q;
:
: $q = CGI->new();
:
: $q->param( 'a', 0, undef, 1, undef, 2 );

    It depends on what you call a bug.
With the above line CGI.pm (v2.74) runs:

 ($name,$value,@other) =
        rearrange([NAME,[DEFAULT,VALUE,VALUES]],@p);
        my(@values);

result:
$name is 'a', $value is 0, @other is undef, 1, undef, 2

[ some code is skipped here ]

        foreach ($value,@other) {
            push(@values,$_) if defined($_);
        }
    As you can see, the push is skipped on undef values.


: $q->param( -name=>'b', -value=>[ 0, undef, 1, undef, 2 ] );

With the above line CGI.pm runs:
 ($name,$value,@other) =
    rearrange([NAME,[DEFAULT,VALUE,VALUES]],@p);
    my(@values);

result:
$name is 'a', $value is 0, @other is undef, 1, undef, 2

[ some code is skipped here ]

    @values = defined($value) ?
             (ref($value) && ref($value) eq 'ARRAY' ?
                                     @{$value} : $value) : ();

    As you can see, no checks are don on the referenced array.

HTH,
Charles K. Clarkson





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

Date: 21 Feb 2001 22:04:11 -0700
From: mfuhr@dimensional.com (Michael Fuhr)
Subject: Re: Is this taint example correct?
Message-Id: <9726kb$jl7@flatland.dimensional.com>

Darren Dunham <ddunham@redwood.taos.com> writes:

> Michael Fuhr <mfuhr@dimensional.com> wrote:
> > Darren Dunham <ddunham@redwood.taos.com> writes:
>
> >> % perl -wT -e 'system {"/bin/echo"} "Arg0", "Arg1";'
> >> Insecure $ENV{PATH} while running with -T switch at -e line 1.
> >> % perl -wT -e 'system {"/bin/echo"} "/Arg0", "Arg1";'
> >> Arg1
> >>
> >> So even though the first element of the LIST to system is not executed
> >> or operated upon, it looks to me like it still has to pass the "relative
> >> path" test.
> >>
> >> Is this a bug?
> >>
> >> I'm using 5.005_03.
>
> > I'd guess that because the program receives the first element as
> > argv[0], that argument needs to pass the path test.  The called program
> > might use argv[0] to exec itself under certain circumstances such as
> > a configuration change (sendmail does this, for example) -- if argv[0]
> > weren't taint-clean, you could have a security problem.
>
> > Just a guess.
>
> Sure.  I have no problem with that.  But in this case argv[0] *is* taint
> clean (it came from static text in the script).  It is somehow proposing
> that argv[0] will be used to later call some program in the PATH
> directly, or the leading '/' wouldn't untaint it.
>
> I disagree with this assesment.  

Argv[0] may be supplied from static text in script, but it isn't
taint-clean if PATH could be applied to it and PATH isn't taint-clean.
By adding the leading '/' you're precluding PATH from being applied,
so the argument now passes the taint check.

As I said, this is just a guess, but it does make sense if you
understand what's going on.

> In the particular script I'm writing, I can work around this pretty
> easily, but it still confused me.  

-- 
Michael Fuhr
http://www.fuhr.org/~mfuhr/


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

Date: Wed, 21 Feb 2001 21:15:30 -0500
From: "mbb" <mbeards@altavista.com>
Subject: Re: MacPerl help for a newbie
Message-Id: <971sk8$rjr$1@merrimack.Dartmouth.EDU>

Bart,

Thank you for all your help!  The FAQ page on windows OLE stuff looks like a
great resource.  I'll see what I can accomplish.

Mike


"Bart Lateur" <bart.lateur@skynet.be> wrote in message
news:52f89to380rf48lmf0nhfbc9ikmqe4v34k@4ax.com...
> mbb wrote:
>
> >so I was hoping for an elegant solution rather than
> >using my workstudy student's time to do "Save As" for 400 some files.
>
> If Excel bieuwer really doesn't know how to handle .WK1 files, you'll
> have to do something like that, but not necessarily manually. Win32::OLE
> could probably do that for you. That's a module that uses Windows' OLE
> to control external programs, in this case, Excel. You do need Perl and
> Excel on Windows, though.
>
> For info to get started, check out the Win32::OLE FAQ includes with
> ActiveState's distribution of Perl:
>
<http://velocity.activestate.com/docs/ActivePerl/faq/Windows/ActivePerl-Winf
aq12.html>
> and, there's the module docs:
> <http://velocity.activestate.com/docs/ActivePerl/site/lib/Win32/OLE.html>.
>
> --
> Bart.




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

Date: Wed, 21 Feb 2001 23:02:52 -0500
From: Brad Baxter <bmb@ginger.libs.uga.edu>
Subject: Re: Module access to private vars in caller
Message-Id: <Pine.A41.4.21.0102212242240.11184-100000@ginger.libs.uga.edu>

On Wed, 21 Feb 2001, bdesany wrote:
> > If I understand you, the answer is probably in perlmod - Perl modules
> > (packages and symbol tables)
> >
> > e.g., perldoc perlmod
> >
> > Brad
> 
> Brad, the variables I want to access are not in any symbol table, as they
> were declared as "my" (which is Good Practice, or so I read everywhere).
> Also, the caller could be anyone (not just main), and although I could code
> for that, I was kind of hoping there was a construct/idiom I could use in
> the caller (other than using global variables) that would make it irrelevant
> to the module.
> -Brian.

Without a concrete example of what you're after, I can only guess.  My
first guess is that you may be a little too slavish to the No Globals
school.  Sometimes globals are what you want.  For example the
import/export process for modules only works with globals.  The short
answer is No, you cannot access lexically scoped values outside of their
scope (except in the case of mumble mumble ...).  You can, however, define
access methods into the scope of those variables to get at their values
via the object oriented module techniques.  All of this is described in
perlmod and the documents referred to therein.  I think you can do what
you think you want to do.  But what you want to do might not be what you
think you want to do.

:-)

Brad



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

Date: Wed, 21 Feb 2001 22:15:09 -0500
From: latkaHATES@SPAMcotse.com (Latka)
Subject: News::NNTPClient script resources?
Message-Id: <Xns904FE25D5BDBFsh6ty87s12x@63.210.103.21>

I've been searching around for scripts that make use of the 
News::NNTPClient module, but haven't had much success. What I want to do is 
somewhat specialized, so I was hoping to get a feel for using the module by 
cannibalizing some subroutines from a working script.

If anyone has any relevant links to share, it would be appreciated. (I'm 
new to OOP.)

-- 
Latka.



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

Date: Wed, 21 Feb 2001 23:59:15 -0600
From: "Charles K. Clarkson" <c_clarkson@hotmail.com>
Subject: Re: News::NNTPClient script resources?
Message-Id: <5740777155AEF3F5.24CB281239D9A843.77121AC80A611BD0@lp.airnews.net>


"Latka" <latkaHATES@SPAMcotse.com> wrote in message
news:Xns904FE25D5BDBFsh6ty87s12x@63.210.103.21...
: I've been searching around for scripts that make use of the
: News::NNTPClient module, but haven't had much success.
: What I want to do is
: somewhat specialized, so I was hoping to get a feel for
: using the module by cannibalizing some subroutines from
: a working script.
:
: If anyone has any relevant links to share, it would be
: appreciated. (I'm new to OOP.)
:

You might find some samples with this search:
http://google.yahoo.com/bin/query?p=%22use+News%3a%3aNNTPClient%22&d=y&o=i&h
=s&g=0&n=50&hc=0&hs=0


HTH,
Charles K. Clarkson





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

Date: Thu, 22 Feb 2001 03:41:01 -0000
From: Chris Stith <mischief@velma.motion.net>
Subject: Re: PerlScript documentation and reference ?
Message-Id: <t992idkm4m7c4b@corp.supernews.com>

[Jeopardectmy performed]

Michael Guenther <miguenther@lucent.com> wrote:

> John Robson <as646@FreeNet.Carleton.CA> wrote in message
> news:96ksp4$9vj$1@freenet9.carleton.ca...
>>
>> I'm looking for a comprehensive online reference and documentation
>> on PerlScript.

> http://www.perl.com/pub/v/documentation
> but this is what shoul d have this as man perldoc and perldoc when you run
> linux.

I didn't realize perldoc covered PerlScript. :-/

Really, PerlScript isn't Perl. It's not documented by the Perl documentation,
it's not interpreted by the Perl interpreter, and it's not on topic in the
Perl newsgroups.

ActiveState should have documentation on PerlScript I think.

Chris

-- 
Christopher E. Stith
Programming is a tool. A tool is neither good nor evil. It is
the user who determines how it is used and to what ends.



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

Date: Wed, 21 Feb 2001 20:50:02 -0600
From: "Mitchell B." <hagertymitchell@[nospam]uswest.net>
Subject: processes monitoring
Message-Id: <x2%k6.8323$LE1.639188@news.uswest.net>

Hello,
    I'm a novice programmer at best and  proud of this little perl
program I wrote, but it needs to do some growing up. Its fairly simply
really, grabs some info from a remote database, does some crunching,
then puts it back and grabs another chuck to chew on.

It needed to run continuously, so now its a daemon (thank you perl
cookbook) which reads from a config,  starts (n) number of itself,
starts and stops nice (sorta :) ).  This has added some problems which
are a bit out of my reach.  It need to be much more ... something.  I'm
not sure what to call it because its not more efficient but should get a
lot more work done.

What I would like it to do is start a daemon that monitors how much
physical ram is available and keep it 90% full of processes. We are
talking several hundred to several thousand depending on the size of the
data coming in and the machine it is running on.

Where to start isn't obvious to me referencing CPAN, the Camel book, and
Cookbook. The processes need to talk to the daemon so then can be exited
gracefully and not in the middle of crunching (process: should I
continue or should i stop? daemon: continue)

The question is: on a Solaris or FreeBSD box how would it monitor the
physical memory and how would  it communicate with other processes so
they continue/die gracefully?

pointing towards a reference or example is fine, a starting point is
what i need...

thanks for your time
mitch



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

Date: Thu, 22 Feb 2001 03:05:43 GMT
From: garry@zvolve.com (Garry Williams)
Subject: Re: Quickest way to convert all keys in a hash from uppercase to lowercase (or vice-versa)?
Message-Id: <bm%k6.393$C5.17941@eagle.america.net>

On Wed, 21 Feb 2001 12:05:59 -0500, Philip Obbard
<pobbard@hotresponse.com> wrote:

>At one point in my code, I wind-up with a hashref containing uppercase key
>names when I eventually need lower case key names, so I do the following
>with my hashref $results:
>
> #Put keys in lowercase
> while(my ($key, $value) = each(%$result)) {
>  $result->{lc($key)} = $value;
>  delete($result->{$key});
> }
>
>This works, 
>but I'm wondering: is there a quicker way to do this (and
>wind-up with another hashref, perhaps)?

Doug points out that your code may delete a key that you want, if it
already is an all-lowercase key.  

But no one has pointed out that you are not guaranteed to get
consistent results using this technique!  

This is from the "each" section of the perlfunc manual page: 

    If you add or delete elements of a hash while you're iterating
    over it, you may get entries skipped or duplicated, so don't.

I recall a thread a while back where someone pointed out that the
actual implementation protects against this, but the documentation
clearly says don't do it.  

(Analogous problems occur in some databases -- Oracle, for one --
where deletes done inside a loop fetching the results of a select
cause the select result to skip records.)  

One alternative is to construct another hash and simply replace the
reference with one to it.  

-- 
Garry Williams


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

Date: Thu, 22 Feb 2001 03:12:02 -0000
From: Chris Stith <mischief@velma.motion.net>
Subject: Re: RegEx \w and other misunderstandings
Message-Id: <t990s2ee7qj844@corp.supernews.com>

mike.blasberg@nc.spam.xnet wrote:
> Darren Dunham wrote:

>   > I'm trying to search through a string, taking each word (\w+) and seeing
> if it
>   > is a key
>   > in a hash (perhaps this is inefficient for my purposes). If it is a match
> I
>   > want to
>   > manipulate it.

>   What do you expect it to do?

> Manipulate $1.
> Let's say that I just want to do something as simple as change the case of the
> alpha 
> string to something different *if* it's a match in the wordlist. I know I
> could do a 
> b-zillion s// statements, but I'm generating the wordlist from another
> (lengthy) file.

You only need one, unless I'm missing something.

>   > Also, I want to search for words with just alpha chars [a-zA-
>   > Z]* to manipulate them. But I can't do that using $1. I didn't
>   > see how you can change the meaning of (\w+). Can someone help
>   > or direct me to some documentation I've missed? Thanks.

>   What's wrong with using [a-zA-Z]+ instead of \w+ if that's what you
>   want?

> I'm a newbie and didn't get [a-zA-Z]+ to give me a variable to work with like
> $1.

You don't replace $1 with [A-Za-z]+ at all. You replace \w+ with
it, and what gets captured by the surrounding parentheses still
gets assigned automagically to $1.

Let's say you really do want to change case of every word that
appears in your hash (let's say, capitalize it). Here's a perverse
but interesting way to do so:

###-------------
#!?usr/bin/perl -w
use strict;

my %hash = (
   'test' => 1,
   'hope' => 1,
   'works' => 1,
);

while( <> ) {
    s/([A-Za-z]+)/
        my $foo = 1;
        if( exists( $hash{$1} ) ) {
            $foo = uc($1)
        }$foo/eg; ### end of substitution
    print;
}
###------------


If you want to make a little nicer code, you could use something more
like the following:

###------------
#!/usr/bin/perl -w
use strict;

my %hash = (
    'test' => 1,
    'hope' => 1,
    'works' => 1,
);

while( <> ) {
    my @foo = /([A-Za-z]+)/g;
    foreach my $bar ( @foo ) {
        s/$bar/\U$bar/g if exists( $hash{$bar} );
    }
    print;
}
###------------

I hope this clarifies mors than it confuses.

Chris

-- 
Christopher E. Stith
The purpose of a language is not to help you learn the
language, but to help you learn other things by using the
language. --Larry Wall, The Culture of Perl, August 1997



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

Date: Thu, 22 Feb 2001 02:10:06 -0000
From: Chris Stith <mischief@velma.motion.net>
Subject: Re: RegEx Help Pls
Message-Id: <t98t7uordbih3e@corp.supernews.com>

Gabriel Richards <grichards@endertechnology.com> wrote:
> Here is the input string:

> <td valign=top width="50%">
> <a
> href=/Regional/U_S__States/California/Metropolitan_Areas/Los_Angeles_Metro/C
> ounties_and_Regions/South_Bay/Business_and_Shopping/><font
> face=arial><b>Business & Shopping</b></font></a>
> </td>

> Here is my RegEx:

Don't do this. Get a module, such as HTML::Parseer, and _parse_ your HTML.
Breaking it out in regexes is messy even when you get it right. Getting
it right isn't easy, either. 

Chris
-- 
Christopher E. Stith
Parking for people we like only. All other vehicles will be vandalized.



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

Date: 22 Feb 2001 06:30:04 GMT
From: damian@cs.monash.edu.au (Damian Conway)
Subject: Re: Regexp to match Web urls?
Message-Id: <972blc$pks$1@towncrier.cc.monash.edu.au>

abigail@foad.org (Abigail) writes:

	[astonishing regex deleted]

Courtesy of Abigail, this terrifying regex will be available as:

	$RE{net}{url}

in the next release of Regexp::Common.

Damian


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

Date: Thu, 22 Feb 2001 07:31:12 GMT
From: Uri Guttman <uri@sysarch.com>
Subject: Re: Regexp to match Web urls?
Message-Id: <x7vgq3i37j.fsf@home.sysarch.com>


why (?:[a-zA-Z\d]|-) instead of [a-zA-Z\d-]?

and to save a few \ you can put the - as the first or last char in a
class. you also have [a-zA-Z\d$\-_.+!*'(),] and that will interpolate
$\ and not $ and then -. i assume you want $ so escape that or put it at
the end of the class. putting - at the head will save the \.

the following has those replacements.

uri


(?:http://(?:(?:(?:(?:(?:[a-zA-Z\d](?:[a-zA-Z\d-]*[a-zA-Z\d])?)\.
)*(?:[a-zA-Z](?:[a-zA-Z\d-]*[a-zA-Z\d])?))|(?:(?:\d+)(?:\.(?:\d+)
){3}))(?::(?:\d+))?)(?:/(?:(?:(?:(?:[-a-zA-Z\d_.+!*'(),$]|(?:%[a-fA-F
\d]{2}))|[;:@&=])*)(?:/(?:(?:(?:[-a-zA-Z\d_.+!*'(),$]|(?:%[a-fA-F\d]{
2}))|[;:@&=])*))*)(?:\?(?:(?:(?:[-a-zA-Z\d_.+!*'(),$]|(?:%[a-fA-F\d]{
2}))|[;:@&=])*))?)?)|(?:ftp://(?:(?:(?:(?:(?:[-a-zA-Z\d_.+!*'(),$]|(?
:%[a-fA-F\d]{2}))|[;?&=])*)(?::(?:(?:(?:[-a-zA-Z\d_.+!*'(),$]|(?:%[a-
fA-F\d]{2}))|[;?&=])*))?@)?(?:(?:(?:(?:(?:[a-zA-Z\d](?:(?:[a-zA-Z\d]|-
)*[a-zA-Z\d])?)\.)*(?:[a-zA-Z](?:[a-zA-Z\d-]*[a-zA-Z\d])?))|(?:(?
:\d+)(?:\.(?:\d+)){3}))(?::(?:\d+))?))(?:/(?:(?:(?:(?:[a-zA-Z\d$\-_.+!
*'(),]|(?:%[a-fA-F\d]{2}))|[?:@&=])*)(?:/(?:(?:(?:[a-zA-Z\d$\-_.+!*'()
,]|(?:%[a-fA-F\d]{2}))|[?:@&=])*))*)(?:;type=[AIDaid])?)?)|(?:news:(?:
(?:(?:(?:[-a-zA-Z\d_.+!*'(),$]|(?:%[a-fA-F\d]{2}))|[;/?:&=])+@(?:(?:(
?:(?:[a-zA-Z\d](?:[a-zA-Z\d-]*[a-zA-Z\d])?)\.)*(?:[a-zA-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:[a-zA-Z\d
\$\-_.!~*'(),])|(?:%[a-fA-F\d]{2})|[:@&=+])*))*)?)))



-- 
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: Thu, 22 Feb 2001 04:21:02 -0000
From: Chris Stith <mischief@velma.motion.net>
Subject: Re: Whats wrong with this????
Message-Id: <t994tepmlldpb3@corp.supernews.com>

Bart Lateur <bart.lateur@skynet.be> wrote:
> Eric Provence wrote:

>>open (NEWPOST, ">$subject");

> You better check

>  A) What $subject is, and if you can even use it as a file name. Imagine
> a subject like "s/a/b/ doesn't work". Is it even safe? What if people
> start a new thread with an existing subject line, such as "help!"?

A fun subject wwould be: /etc/passwd
The post could contain this following lines:
toor::0:0::/bin/sh
me::0:0::/bin/sh

Or maybe a subject of: ./.profile
with the contents:
alias ls='mail president@whitehouse.gov -s "I\'m gonna get you" < /usr/bin/cc'

See a problem? You'd better use taint mode and make sure you untaint
your filenames well if they are generated based on user input.

>  B) The error code if it fails.

> 	open (NEWPOST, ">$subject")or
> 	  die "Cannot write to '$subject'": $!";

This is a must. ALways check open(). Always always always.

Chris

-- 
Christopher E. Stith
Try not. Do, or do not. The Force is binary. -- Yoda,
The Empire Strikes Back (paraphrased)



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

Date: Thu, 22 Feb 2001 00:27:35 -0600
From: "Charles K. Clarkson" <c_clarkson@hotmail.com>
Subject: Re: Whats wrong with this????
Message-Id: <8A410EE5214FEBCF.FB49D74D52742569.7FE04E83E9AED70B@lp.airnews.net>


"Eric Provence" <infinityzone@hotmail.com> wrote in message
news:t96dhve0over8a@corp.supernews.com...
: Okay, I'm writing a message board, and I've run into an error. Whats the
: error you ask? I don't know! When I go to write a file, it won't write.
: And no, i didn't open it as read. Heres the code:
:
: #!/usr/bin/perl
    #!/usr/bin/perl -w

: use strict;
: use CGI qw(:standard);

try placing this line in your program and turn on warnings:
use CGI::Carp 'fatalsToBrowser';

:
: # Variables
: my $uname = param('cname');
: my $pass = param('pass');
: my $state = param('state');
: my $rname = param('tname');
: my $i = 0;
:     . . .
: my $subject = param('subject');
: my $msg = param('msg');


    Can you tell us the param values you used when
you tested the program?

HTH,
Charles K. Clarkson





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

Date: Thu, 22 Feb 2001 07:59:18 +0000 (UTC)
From: efflandt@xnet.com (David Efflandt)
Subject: Re: why do i get an unitialized value warning when reading from a file?
Message-Id: <slrn999hmf.8mg.efflandt@efflandt.xnet.com>

On Wed, 21 Feb 2001, Igor Aptekar <igor_aptekar@programmer.net> wrote:
>I get this error in quite a few chunks eventhough i use chomp. Can someone
>explain what it mean and how to prevent it.

I image that you chomp a blank line, ending up with nothing, and then
attempt to use nothing for something without testing it.

-- 
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: 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 332
**************************************


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