[9757] in Perl-Users-Digest

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

Perl-Users Digest, Issue: 3351 Volume: 8

daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Wed Aug 5 01:06:05 1998

Date: Tue, 4 Aug 98 22:00:23 -0700
From: Perl-Users Digest <Perl-Users-Request@ruby.OCE.ORST.EDU>
To: Perl-Users@ruby.OCE.ORST.EDU (Perl-Users Digest)

Perl-Users Digest           Tue, 4 Aug 1998     Volume: 8 Number: 3351

Today's topics:
    Re: Abigail's sig makes me wanna smoke Crack ! <gwynne@utkux.utk.edu>
    Re: Array or hash question ? <rick.delaney@shaw.wave.ca>
    Re: comp.lang.perl.announce redux (Tad McClellan)
    Re: danger/oddness of $[=1 <rootbeer@teleport.com>
    Re: Excel-Chart OLE Perl Scripts <rootbeer@teleport.com>
        File upload <cary.g.siemers@state.or.us>
    Re: File upload <rootbeer@teleport.com>
    Re: Getting some weird problems. <rootbeer@teleport.com>
    Re: Help! Stuck with an array assignment problem <rootbeer@teleport.com>
    Re: hiding user input <rootbeer@teleport.com>
    Re: hiding user input <sp@m.block>
    Re: hiding user input <sp@m.block>
    Re: hiding user input <sp@m.block>
    Re: hiding user input (Gary L. Burnore)
    Re: How to delete the last column (Larry Rosler)
    Re: Interesting Question needs Quick Answer (nobody)
    Re: MacPerl fully compatible? (directory problems) (John Moreno)
        mem usage of flat array vs. lol and loh? <sidi@angband.org>
    Re: Need to upload files to web server under NT 4.0 <rootbeer@teleport.com>
        Perl & CGI Courses in the UK <->
    Re: Perl recipes <rick.delaney@shaw.wave.ca>
    Re: perl5 bug? <rootbeer@teleport.com>
        Problems with File::Find (Mark Thompson)
    Re: Q:How to "mkdir -p"? (nobody)
    Re: Reading from and writing to the serial port <rootbeer@teleport.com>
    Re: Regexp question (Charles DeRykus)
    Re: Running a shell from perl? <rootbeer@teleport.com>
    Re: Running a shell from perl? tigger@io.nospaam.com
    Re: Single word ouptu from aa array (Tad McClellan)
    Re: Single word ouptu from aa array (Patrick Timmins)
    Re: Taking out sections of a file?  How do I do this? <rootbeer@teleport.com>
        TEST edwardv@jps.net
        Special: Digest Administrivia (Last modified: 12 Mar 98 (Perl-Users-Digest Admin)

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

Date: Tue, 4 Aug 1998 22:53:21 -0400
From: "Bob Gwynne" <gwynne@utkux.utk.edu>
Subject: Re: Abigail's sig makes me wanna smoke Crack !
Message-Id: <6q8hm1$ar7$1@gaia.ns.utk.edu>

I've looked this up and may be able to shed some light on ?= with,
hopefully, not getting flamed too badly.

To begin, my source (liberally quoted) is Mastering Regular Expressions by
Jeffrey Friedl, pp. 228-229.

?=subexpression is true if the subexpression matches. "The twist is that the
subexpression does not actually "consume" any of the target
string--lookahead matches a position in the string similar to the way a word
boundary does.  This means that it doesn't add to what ... any closing
capturing parentheses contain. It's a way of peeking ahead without taking
responsibility for it."

In this case, (.*) substitutes for $' (which returns everything after the
matched string). The use of $' is to be avoided.

"Lookahead parentheses do not capture text, so they do not count as a set of
parentheses for numbering purposes. "

BTW: Abigails sig would look a lot better if it were written:

   for (@arr) { print "$_"; }

instead of :

  for (@arr) { print "elem:$_"; }

"elem:" screws it up so that it comes out:

elem:Jelem:ust another Perl Hacker
elem:uelem:st another Perl Hacker
elem:selem:t another Perl Hacker
elem:telem: another Perl Hacker

whereas it would be better if it were:
Just another Perl Hacker
ust another Perl Hacker
st another Perl Hacker
t another Perl Hacker
 another Perl Hacker
another Perl Hacker
 .

However, I copied the code from below--which may not be correct.

Bob Gwynne
Speech Comm,
University of Tennessee
gwynne@utkux.utk.edu



F.Quednau wrote in message <35C6F74D.B89D9A3B@nortel.co.uk>...
>@arr =  split /(?=(.*))/s , "Just another Perl Hacker\n";
>for (@arr) { print "elem:$_"; }
>
>Now this showed me what was actually happening. The first character is
>always split off, and that fills array element 0, with element 1 being
>filled with the remaining string. Now the string miraculously seems to
>have lost the first character, and the split now operates on that.
>Without the ?= the regexp would match the whole line, what does the ?=
>do ? Thing is, I read the documentation on ?=, and I didn't understand
>it really. I usually don't have that many problems with the docs, but
>what is actually a 'zero width positive lookahead assertion' ? The
>example given is somehow a bit lame and didn't help me understand
>Abigail's sig whatsoever. Basically I was thinking about that 'insert
>first line' program earlier on, and I've got this feeling that if I
>understand this, I could make some glorious optimization to the code
>*smiles at his own naivity*
>
>PS
>The ones offended by the subject, please imagine thousands of smileys. I
>just can't be asked to write them right now, as language seems to loose
>out when doing so.
>
>
>--
>____________________________________________________________
>Frank Quednau
>http://www.surrey.ac.uk/~me51fq
>________________________________________________




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

Date: Wed, 05 Aug 1998 04:37:56 GMT
From: Rick Delaney <rick.delaney@shaw.wave.ca>
Subject: Re: Array or hash question ?
Message-Id: <35C7E308.13320A6C@shaw.wave.ca>

Larry Rosler, kindly correcting my oversight, wrote:
> 
> In article <35C67443.7784C576@shaw.wave.ca> on Tue, 04 Aug 1998 
> 02:32:57 GMT, Rick Delaney <rick.delaney@shaw.wave.ca> says...
> ...
> > Okay, you've read a row of data into these variables:
> >
> > $itemNum = 'SKU_1';
> > $price = '30.00';
> > $description = 'Widget';
> > $size = '10';
> > $color = 'Blue';
> >
> > # Now set up your hash:
> >
> > %hash = (
> >     itemNum => $itemNum,
> >     price   => $price,
> >     desc    => $description,
> >     size    => $size,
> >     color   => $color,
> > );
> >
> > # and push a reference to it onto your array:
> >
> > push @rows, \%hash;
> >
> > # Repeat for the other rows.
> > # Then, to do something like total the prices:
> >
> > my $total = 0;
> > foreach $row (@rows) {
> >     $total += $row->{price};
> > }
> > print "Total price is $total\n";
> 
> Sorry, that won't work.  What you will get is the number of rows 
> times the last value of $price.  The reason is that each of the 
> references  that you push onto the array points to the same, the 
> one-and-only, hash.
> 

[Summarizing the rest]

To fix this, you can scope the hash to the loop where you're reading
rows, like:

    while(rows_left_to_read){
        my %hash = (...); # round brackets
        push @rows, \%hash;
    }

Or you can create references to anonymous hashes, like:

    while(rows_left_to_read){
        my $href = {...}; # curly braces
        push @rows, $href;
    }

Either way, each element of @rows contains a reference to a different
hash, unlike my example.

-- 
Rick Delaney
rick.delaney@shaw.wave.ca


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

Date: Tue, 4 Aug 1998 17:56:35 -0500
From: tadmc@flash.net (Tad McClellan)
Subject: Re: comp.lang.perl.announce redux
Message-Id: <3j38q6.kc4.ln@localhost>

Abigail (abigail@fnx.com) wrote:

: I'n not saying you should know every language. You don't have a right
: to be able to read every posting in clpa. But I find it ridiculous
: every poster in clpa should be able to write English.


   clpa is moderated.

   The moderator only (I dunno, really) speaks English.

   How can he evaluate if an article in a foreign language is
   appropriate for posting when he cannot read it?

   Should there be a roll of clpa translators that he can consult
   for a translation or something?



   He certainly can't just approve it without knowing what it says.

   How will he know what it says?


--
    Tad McClellan                          SGML Consulting
    tadmc@metronet.com                     Perl programming
    Fort Worth, Texas


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

Date: Wed, 05 Aug 1998 02:59:29 GMT
From: Tom Phoenix <rootbeer@teleport.com>
Subject: Re: danger/oddness of $[=1
Message-Id: <Pine.GSO.4.02.9808041958130.2396-100000@user2.teleport.com>

On Tue, 4 Aug 1998, postmaster wrote:

> Subject: danger/oddness of $[=1
> 
> OK, now I know why I'm not supposed to do this 

Then I don't have to tell you again.

> is this the expected results?

You did something weird, and something weird happened. That's what I'd
expect. :-)

-- 
Tom Phoenix       Perl Training and Hacking       Esperanto
Randal Schwartz Case:     http://www.rahul.net/jeffrey/ovs/



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

Date: Wed, 05 Aug 1998 03:17:44 GMT
From: Tom Phoenix <rootbeer@teleport.com>
Subject: Re: Excel-Chart OLE Perl Scripts
Message-Id: <Pine.GSO.4.02.9808042011360.2396-100000@user2.teleport.com>

On Tue, 4 Aug 1998, Taylor Frith wrote:

> Newsgroups: comp.lang.perl.modules, comp.lang.perl.tk, comp.lang.perl.misc

Please don't post to inappropriate newsgroups. (This message doesn't seem
to have anything to do with c.l.p.tk.) And, when you do cross-post, try
not to forget to set follow-ups to just one group, as I've done here.

> I've been trying to make this Perl script work properly.  It generates
> the chart but some reason its not picking up the Legend names from the
> A2 row (A2, B2, C2).  It just labels them Series 1, 2, 3. 

[ 40K(!) of program text snipped ]

It's generally helpful to cut your program down to the smallest example
which shows the behavior. If you can cut yours down to, say, under a dozen
lines of code, you'll have a much better chance of getting an answer. Good
luck!

-- 
Tom Phoenix       Perl Training and Hacking       Esperanto
Randal Schwartz Case:     http://www.rahul.net/jeffrey/ovs/



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

Date: Tue, 04 Aug 1998 14:35:17 -0700
From: cary siemers <cary.g.siemers@state.or.us>
Subject: File upload
Message-Id: <35C77E95.ADBF6FC7@state.or.us>

I had been having some problems lately with only being able to upload a
file of 60K in size. I did the following and so far it works with 200K+
in size... and I'm still testing.

Hope this might help some....

It reads the STDIN in 1024 size chunks... then outputs those "chunks" to
$tempFile on the server.

$tempFile = "/web/test.dat";
open( X, ">$tempFile" );
while (read(STDIN, $tempBuffer, 1024) ) {
    print X $tempBuffer;
}
close X;

To finish processing I open the $tempFile and process it to it's final
location.





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

Date: Wed, 05 Aug 1998 03:21:33 GMT
From: Tom Phoenix <rootbeer@teleport.com>
Subject: Re: File upload
Message-Id: <Pine.GSO.4.02.9808042020580.2396-100000@user2.teleport.com>

On Tue, 4 Aug 1998, cary siemers wrote:

> open( X, ">$tempFile" );

Even when your script is "just an example" (and perhaps especially in that
case!) you should _always_ check the return value after opening a file.
Thanks!

-- 
Tom Phoenix       Perl Training and Hacking       Esperanto
Randal Schwartz Case:     http://www.rahul.net/jeffrey/ovs/



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

Date: Wed, 05 Aug 1998 02:54:17 GMT
From: Tom Phoenix <rootbeer@teleport.com>
Subject: Re: Getting some weird problems.
Message-Id: <Pine.GSO.4.02.9808041953340.2396-100000@user2.teleport.com>

On Tue, 4 Aug 1998, BJ Kim wrote:

> I'm using a perl script to change settings for a database-like
> software, restart the database, and add some entires. When I do this
> manually, everything works fine.  I've narrowed it down to the fact
> that restarting the database using the script isn't working properly
> even though output is saying that the database is being restarted.

Are you checking the return codes for anything which could return a
failure signal? Hope this helps!

-- 
Tom Phoenix       Perl Training and Hacking       Esperanto
Randal Schwartz Case:     http://www.rahul.net/jeffrey/ovs/



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

Date: Wed, 05 Aug 1998 02:44:37 GMT
From: Tom Phoenix <rootbeer@teleport.com>
Subject: Re: Help! Stuck with an array assignment problem
Message-Id: <Pine.GSO.4.02.9808041943520.2396-100000@user2.teleport.com>

On Tue, 4 Aug 1998, Planet News wrote:

> if you assign a variable like that: $a[0]= @b;
> 
> in $a[0] you get the size of the array @b like if you where using $#b.

Well, yes, in the way that zero is "like" negative one. :-)

-- 
Tom Phoenix       Perl Training and Hacking       Esperanto
Randal Schwartz Case:     http://www.rahul.net/jeffrey/ovs/



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

Date: Wed, 05 Aug 1998 02:38:30 GMT
From: Tom Phoenix <rootbeer@teleport.com>
Subject: Re: hiding user input
Message-Id: <Pine.GSO.4.02.9808041935310.2396-100000@user2.teleport.com>

On Tue, 4 Aug 1998 b_redeker@hotmail.com wrote:

> * I am a experienced developer (VB, VC, Delphi, etc) and have for a
> long time followed several newsgroups;

Then you certainly know how frustrating it is to see a FAQ such as yours
posted yet again.

> * I have several times posted stupid questions, and sometimes stupid
> answers;

As evidenced by this occasion, in which you posted the same question (at
least) three times under different subject lines.

> * I have never seen flaming like Abigail's in most newsgroups (hackers
> newsgroups are the exception)

You have now. Ask another FAQ and you will again. :-) :-) :-)

-- 
Tom Phoenix       Perl Training and Hacking       Esperanto
Randal Schwartz Case:     http://www.rahul.net/jeffrey/ovs/



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

Date: Wed, 05 Aug 1998 13:13:03 +0900
From: "B. Oiledanimalbyproducts" <sp@m.block>
Subject: Re: hiding user input
Message-Id: <35C7DBDB.D11F4122@m.block>

Greg Bacon wrote:
 
> I'll invoke Thoreau:
> 
>     "If a man is more right than his neighbor, then that constitutes a
>      majority of one."

This argument also works against you - all the newbie posters who haven't done
any research and want a ready made solution are right because they think they
are. Or were you alluding to the gut feeling of what's "right". For me the gut
feeling of "right" is that it doesn't cost you anything to be polite, even if
you think yourself to be above others which is (for me) the basis of this
thread - certain individuals who seem to think their knowlegability justifies
their being rude. IRL if I see some one setting about another person I will
try to stop it and here is no different. On several occasions I have seen
Abigail use the same tone on postings and I don't think it's right. Once could
be a slip, but repeatedly seems like a habit. 

In some of the other postings I read that perhaps the experts will leave if we
don't put up with their foilbles - to be honest who needs an expert who treats
you like dirt for their own lack of tollerance, I'd rather do without even if
it costs me more time in the learning curve.


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

Date: Wed, 05 Aug 1998 13:25:32 +0900
From: "B. Oiledanimalbyproducts" <sp@m.block>
Subject: Re: hiding user input
Message-Id: <35C7DEC8.26B2A1AD@m.block>

Daniel Grisinger wrote:
 
>  No one should have the right to come in here, attack
> the regulars who form the nucleus of our community

No-one should have the right to work out their frustrations on another poster,
whether they've been memebers of the list since the Arc or not. Common
courtesy exists to stop people falling into the kind of venom that you accuse
Gary of. And while I don't agree with the methods he chose to deal with the
follow up emails I at least understand enough of what prompted him to start
this. Abbigail didn't treat Mr Burnmore badly but she did consistently treat
other posters with rudeness and IMHO merits all she gets in this thread - more
rudeness to bring home the point that her actions are unaccetable behaviour
and to make her bite her tongue in future postings.


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

Date: Wed, 05 Aug 1998 13:47:13 +0900
From: "B. Oiledanimalbyproducts" <sp@m.block>
Subject: Re: hiding user input
Message-Id: <35C7E3DE.3117BB6F@m.block>

Greg Bacon wrote:

> 
> "No one knows so much as he who knows he knows nothing."
> 
> : gbacon@cs.uah.edu (Greg Bacon) writes:
> : > When one fails to use common sense, one gets what one deserves.
> 
> When one ass_u_mes one knows what's going on, one is taking a risk.
> People should come to the table with a solid idea of what's going on.
> What is to blame for the clue shortage?

[quoting the content of a posting containing a quote fron ome of his denoted
by ": >"
> : > "But, officer, I didn't *know* the speed limit was 35!  You can't give
> : > me a ticket!"
> 
> [ snip irrelevant anecdote ]

> : > [ ... ] That is nothing
> : > short of a pile of bullshit.  If you or anyone doesn't like Abigail's
> : > response, then feel free to give what you think is a better response!
> : > Nothing is holding you or anyone back.

> This isn't about me.  I myself probably wouldn't followup to a FAQ in
> quite the same style as Abigail.  However, I do feel she's justified.

However as can be seen by your self included quotes you do seem to share the
same ideology. What makes "the Elite" (self elected) so special that they
don't have to pass over what they know doesn't interest them. Does it really
cost so much _not_ to berate and insult. Why can't the potential breater just
avoid posting stupid replies - if you are more enlightened than someone else
coming down to their level means a conscious choice and IMHO that's what the
problem is - newbies unconscious, Abbigail conscious. She consciously and
consistently breated newbies rather than just say nothing or point them to the FAQ.


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

Date: Wed, 05 Aug 1998 04:52:50 GMT
From: gburnore@databasix.com (Gary L. Burnore)
Subject: Re: hiding user input
Message-Id: <35c7e38c.91789316@nntpd.databasix.com>

On Wed, 05 Aug 1998 13:25:32 +0900, in article <35C7DEC8.26B2A1AD@m.block>,
"B. Oiledanimalbyproducts" <sp@m.block> wrote:

>Daniel Grisinger wrote:
> 
>>  No one should have the right to come in here, attack
>> the regulars who form the nucleus of our community
>
>No-one should have the right to work out their frustrations on another poster,
>whether they've been memebers of the list since the Arc or not. Common
>courtesy exists to stop people falling into the kind of venom that you accuse
>Gary of. And while I don't agree with the methods he chose to deal with the
>follow up emails 

Again I'd like to note that in only one other group I read/post do so many
people pop into email so quickly and so often.  That group was news.groups
during the RFD for .moderated.   At that time I was only a "lurker" here. I
had posted maybe once in the previous 8 months.  I was already familiar with
all but one of those who emailed me.

>I at least understand enough of what prompted him to start this.

Many do. 

>Abbigail didn't treat Mr Burnmore badly but she did consistently treat
>other posters with rudeness and IMHO merits all she gets in this thread - more
>rudeness to bring home the point that her actions are unaccetable behaviour
>and to make her bite her tongue in future postings.

That was why I posted _how_ I did.  I don't usually swear in a comp group.
The why was coming for a long time.


-- 
      I DO NOT WISH TO RECEIVE EMAIL IN REGARD TO USENET POSTS
---------------------------------------------------------------------------
                  How you look depends on where you go.
---------------------------------------------------------------------------
Gary L. Burnore                       |  ][3:]3^3:]33][:]3^3:]3]3^3:]3]][3
                                      |  ][3:]3^3:]33][:]3^3:]3]3^3:]3]][3
DOH!                                  |  ][3:]3^3:]33][:]3^3:]3]3^3:]3]][3
                                      |  ][3 3 4 1 4 2  ]3^3 6 9 0 6 9 ][3
Special Sig for perl groups.          |     Official Proof of Purchase
===========================================================================


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

Date: Tue, 4 Aug 1998 20:30:50 -0700
From: lr@hpl.hp.com (Larry Rosler)
Subject: Re: How to delete the last column
Message-Id: <MPG.103171c7b51682ba9897ba@nntp.hpl.hp.com>

[Posted to comp.lang.perl.misc and copy mailed.]

In article <6q8b39$o9n$1@strato.ultra.net> on Wed, 05 Aug 1998 01:01:52 
GMT, Bob Trieger <sowmaster@juicepigs.com> says...
 ...
> untested (may even be totally off the wall)
> 
> undef $/;
> $foo = <FILE>;
> $foo =~ s!(</TD>.*)<TD.*?</TD>.*?(</TR>)!$1$2!gsmi;

Untested, but noting that the 'm' modifier doesn't do anything, because 
there are no ^ or $ anchors in the RE.

> $foo =~ s!(COLSPAN=)(\d+)!$1($2-1)!;

Clearly wrong, because you can't put that arithmetic into the HTML.  You 
must do it during the substitution.

  $foo =~ s!(COLSPAN=)(\d+)!$1 . ($2-1)!ei;

There are also things you should do about matching optional spaces and 
double-quotes around each of the tokens, but as Tom C points out, there 
isn't much interesting Perl in that.

-- 
Larry Rosler
Hewlett-Packard Laboratories
http://www.hpl.hp.com/personal/Larry_Rosler/
lr@hpl.hp.com


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

Date: 5 Aug 1998 02:10:10 GMT
From: ac1@fspc.netsys.itg.telecom.com.au (nobody)
Subject: Re: Interesting Question needs Quick Answer
Message-Id: <6q8eu2$8l4@newsserver.trl.OZ.AU>

That is one ugly mother.  It seems to follow the credo of the best virii
(real, not computer) in that it serves NO other purpose than to reproduce.
Unfortunately, our perl is in /opt/perl5/bin/ so I have to reverse-engineer
it to make it function again.  I'll get back to you in a couple of months :)

AllanC (Just Another Perl Apprentice).

Greg Bacon (gbacon@cs.uah.edu) wrote:
: In article <Ewuutr.Ip3@csc.liv.ac.uk>,
: 	sm8plh@csc.liv.ac.uk (P.L. Hegarty) writes:
: : I want to write a perl script which produces as its output an exact copy of
: : itself.

: I guess no one's run Russ's .signature:

: #!/usr/bin/perl -- Russ Allbery, Just Another Perl Hacker
: $^=q;@!>~|{>krw>yn{u<$$<[~||<Juukn{=,<S~|}<Jwx}qn{<Yn{u<Qjltn{ > 0gFzD gD,
:  00Fz, 0,,( 0hF 0g)F/=, 0> "L$/GEIFewe{,$/ 0C$~> "@=,m,|,(e 0.), 01,pnn,y{
: rw} >;,$0=q,$,,($_=$^)=~y,$/ C-~><@=\n\r,-~$:-u/ #y,d,s,(\$.),$1,gee,print

: Greg


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

Date: Wed, 5 Aug 1998 00:36:10 -0400
From: phenix@interpath.com (John Moreno)
Subject: Re: MacPerl fully compatible? (directory problems)
Message-Id: <1dd9io4.17k77hp6nq2pN@roxboro0-006.dyn.interpath.net>

Matthias Neeracher <neeri@iis.ee.ethz.ch> wrote:

> > Is MacPerl fully compatible?
-snip-
> Compatible with what?

Python.

-- 
John Moreno


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

Date: 5 Aug 1998 02:59:23 GMT
From: Chris Sidi <sidi@angband.org>
Subject: mem usage of flat array vs. lol and loh?
Message-Id: <6q8hqb$rkk$1@news-int.gatech.edu>

Hi,

Is there a way to measure the memory usage of the below structures?  Can
anyone take a guess as to the overhead of the lol or loh over the
flattened list? 

  @flat_list = (1, 4, 2, 7, 6, 9 ...);
  @lol = ([1,4], [2,7], [6,9] ...);
  @loh = ( {begin=>1, end=>4}, {begin=>2, end=>7}, {begin=>6, end=>9}...);

(Relax, I won't be using the flat list just to save a few bytes when the
lol or loh structure my data better.  I'm trying to gain a more through
understanding of perl and it's internals.)

I tried the perl -d debugger's UsageOnly but like perlrun warns, it didn't
see to reflect the true memory use.  (the loh was reported to take less
space than the lol, probably because HASH is less letters than SCALAR).

I tried perl -D's memory allocation, but I didn't see any particular
mallocs that looked like the answer.  (I was using much larger lists) 

Thanks,
Chris Sidi
sidi@gt.ed.net


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

Date: Wed, 05 Aug 1998 02:40:31 GMT
From: Tom Phoenix <rootbeer@teleport.com>
Subject: Re: Need to upload files to web server under NT 4.0
Message-Id: <Pine.GSO.4.02.9808041939320.2396-100000@user2.teleport.com>

On Tue, 4 Aug 1998, Bill Morgan wrote:

> I'm trying to implement a simple file upload capability on our web
> server.

Are you using the proper protocols? Of course, if that's the problem, it's
not a Perl problem; the docs, FAQs, and newsgroups about the protocols and
suchlike should be of help to you. Good luck!

-- 
Tom Phoenix       Perl Training and Hacking       Esperanto
Randal Schwartz Case:     http://www.rahul.net/jeffrey/ovs/



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

Date: Tue, 4 Aug 1998 22:36:04 +0100
From: "Jim" <->
Subject: Perl & CGI Courses in the UK
Message-Id: <35c77efe.0@news.netcom.co.uk>

Does anybody know of any courses available in the UK,
preferably the Midlands, that teach perl and/or cgi upto
a professional level.

I have tried a few organisations I found in the back of .net
magazine but they are only 1 - 3 day courses. Would be
grateful for any feedback....

Regards
Jim




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

Date: Wed, 05 Aug 1998 02:46:31 GMT
From: Rick Delaney <rick.delaney@shaw.wave.ca>
Subject: Re: Perl recipes
Message-Id: <35C7C8F1.EA6B5761@shaw.wave.ca>

Steve Linberg wrote:
> 
> In article <35C6444E.4DC5@oreilly.com>, lisam@oreilly.com wrote:
> 
> > The Perl Cookbook, by Tom Christiansen & Nathan
> > Torkington, is a collection of problems, solutions,
> > and examples for anyone programming in Perl. It contains
> > hundreds of Perl "recipes," including recipes for parsing
> > strings, doing matrix multiplication, working witharrays
> > and hashes, and performing complex regular expressions.
> > Over the next three weeks, O'Reilly will provide two new
> > recipes a day free on the web site:
> > http://perl.oreilly.com/cookbook/
> 
> This is very nice!

Agreed.  But because I like to nitpick...

The first recipe shows how you can replace '$debt' with its value in
something like:

    $text = 'You owe $debt to me.';

by using either:

    $text =~ s/\$(\w+)/${$1}/g;# or
    $text =~ s/(\$\w+)/$1/gee;

And then explains it very well.

However, if you have something like:

    $text = 'You owe $$debt to me, plus $2.00 S&H.';

you have to make sure the regex won't try to replace $2.

    $text =~ s/\$([A-Za-z_]\w*)/${1}/g;
    $text =~ s/(\$[A-Za-z_]\w*)/${1}/gee;

This, of course, is not the point of the recipe.  But I thought I'd point
it out anyway.

-- 
Rick Delaney
rick.delaney@shaw.wave.ca


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

Date: Wed, 05 Aug 1998 03:09:33 GMT
From: Tom Phoenix <rootbeer@teleport.com>
Subject: Re: perl5 bug?
Message-Id: <Pine.GSO.4.02.9808042005340.2396-100000@user2.teleport.com>

On Tue, 4 Aug 1998, Mission A/V wrote:

> Subject: perl5 bug?

Please check out this helpful information on choosing good subject
lines. It will be a big help to you in making it more likely that your
requests will be answered.

    http://www.perl.com/CPAN/authors/Dean_Roehrich/subjects.post

>                         ($name,$value) = split(/=/,$inline);
>                         local (*GLOB) = $name;
>                         $GLOB = $value;

It's not likely that that's really what you need or want. You're using the
wrong tools for the job. I'd recode this to use a hash instead. (Or, if
you're doing something with CGI scripting, I'd use one of the existing,
debugged modules.)

> Modification of a read-only value attempted at /pathdeleted/ line 1284.
> 
> the funny thing is that it works 31 times before it somehow becomes
> read-only. 

Maybe you'll know what's happening when you see what the value of $name is
at the time that it fails. But the real solution is (almost certainly) to
stop using a hammer to install screws. Hope this helps!

-- 
Tom Phoenix       Perl Training and Hacking       Esperanto
Randal Schwartz Case:     http://www.rahul.net/jeffrey/ovs/



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

Date: Wed, 05 Aug 1998 04:06:54 GMT
From: mark-lists@webstylists.com (Mark Thompson)
Subject: Problems with File::Find
Message-Id: <35c7d7fb.5103571@news.supernews.com>

Hi,

I'm having problems getting an example program working that uses File::Find.
The problem is that I end up with an $_ but $dir and $name are never
initialized in &wanted.  I've included the source code as well as a partial
result set.  

Thanks,

Mark Thompson


Here's the source code:

#!/usr/local/bin/perl5 -w 

# Purpose
#       Lists all the files under a directory tree.

use Getopt::Long;
use File::Find;

# Set up the command line to accept a filename.
my $ret = GetOptions ("d|directory:s");
my $directory = $opt_d || die "Usage: $0 -d directory\n";

#
# This performs actions on the files we have found.
#
sub wanted 
{
   print "Dir =<$dir>\n";
   print "Name=<$name>\n";
   print "File=<$_>\n";
}

find(\&wanted, $directory);



Partial results:

Use of uninitialized value at /u/mwt/bin/listtree.pl line 18.
Dir =<>
Use of uninitialized value at /u/mwt/bin/listtree.pl line 19.
Name=<>
File=<w3mir>
Use of uninitialized value at /u/mwt/bin/listtree.pl line 18.
Dir =<>
Use of uninitialized value at /u/mwt/bin/listtree.pl line 19.
Name=<>
File=<w3mfix>
Use of uninitialized value at /u/mwt/bin/listtree.pl line 18.
Dir =<>
Use of uninitialized value at /u/mwt/bin/listtree.pl line 19.
Name=<>
File=<.redirs>
Use of uninitialized value at /u/mwt/bin/listtree.pl line 18.
Dir =<>
Use of uninitialized value at /u/mwt/bin/listtree.pl line 19.
Name=<>
File=<.referers>


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

Date: 5 Aug 1998 02:02:43 GMT
From: ac1@fspc.netsys.itg.telecom.com.au (nobody)
Subject: Re: Q:How to "mkdir -p"?
Message-Id: <6q8eg3$8l4@newsserver.trl.OZ.AU>

This is a (very) rough first draft from an apprentice Perler.  Comments
welcome (especially on the gross method of handling the mode).

=== BEGIN CUT ===
#!/opt/perl5/bin/perl -w

$#ARGV == 1 || die "Usage: $0 <dir-name> <mode>";

$dirName = "$ARGV[0]//";
$dirName =~ s./+$./.;

$modeBits = $ARGV[1];
$modeBits1 = int ($modeBits / 100); $modeBits -= $modeBits1 * 100;
$modeBits2 = int ($modeBits / 10); $modeBits -= $modeBits2 * 10;
$modeBits3 = $modeBits;
(($modeBits1 >= 0) && ($modeBits1 <= 7)) || die "Invalid mode $modeBits";
(($modeBits2 >= 0) && ($modeBits2 <= 7)) || die "Invalid mode $modeBits";
(($modeBits3 >= 0) && ($modeBits3 <= 7)) || die "Invalid mode $modeBits";
$modeBits = (($modeBits1 * 8) + $modeBits2) * 8 + $modeBits3;

MkDir ($dirName, $modeBits);

sub MkDir {
    my $curDirName = shift;
    my $nxtDirName = $curDirName;
    $nxtDirName =~ s.[^/]*/$..;

    if (! -d $nxtDirName) {
        MkDir ($nxtDirName, $modeBits);
    }
    mkdir ("$curDirName", $modeBits) || die "Can't make $curDirName: $!";
}
=== END CUT ===

Derek (dereks@fc.hp.com) wrote:
: Folks,

: I want to do the equivalent of mkdir -p (i.e. greate all directories in
: the path at once) in Perl.  Obviously, I could just use backticks, but I
: prefer to use stuff that's native to perl if possible.  Also I could
: write some iterative thing, but I'm sure there's already a tidy solution
: somewhere.

: Any ideas?
: Derek.



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

Date: Wed, 05 Aug 1998 02:50:33 GMT
From: Tom Phoenix <rootbeer@teleport.com>
Subject: Re: Reading from and writing to the serial port
Message-Id: <Pine.GSO.4.02.9808041949010.2396-100000@user2.teleport.com>

On Tue, 4 Aug 1998, Tim Vann wrote:

> Subject: Reading from and writing to the serial port

I skimmed the body of your post only well enough to be pretty sure that
you haven't seen the FAQ's entry on this topic. (Please forgive me if I've
made a mistake about that.) 

> open (DEV, '+< /dev/tty0');

Even when your script is "just an example" (and perhaps especially in that
case!) you should _always_ check the return value after opening a file.

Hope this helps!

-- 
Tom Phoenix       Perl Training and Hacking       Esperanto
Randal Schwartz Case:     http://www.rahul.net/jeffrey/ovs/



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

Date: Wed, 5 Aug 1998 01:31:28 GMT
From: ced@bcstec.ca.boeing.com (Charles DeRykus)
Subject: Re: Regexp question
Message-Id: <Ex708H.1xu@news.boeing.com>

In article <6q7tj5$nkh$3@marina.cinenet.net>,
Craig Berry <cberry@cinenet.net> wrote:
>Tony Galway (tony@engr.mun.ca) wrote:
>
>  ...
>A lot easier to write as
>
>  ($host) = $string =~ m!(.*)/result/.*!;
>
>...but even that is a bit wasteful compared to (for example)
>
>  ($host) = $string =~ m!^([^/]*)/result/!;
>

functions do suprisingly well though lots more typing: 

use Benchmark;
timethese(50_000,
{
  'class' => sub { $string = 'hostname/result/data';
                   ($host) = $string =~ m!^([^/]*)/result/!;
                 },
  'dot'   => sub { $string = 'hostname/result/data';
                   ($host) = $string =~ m!^(.*)/result/.*!;
                 },
  'substr'   => sub { $string = 'hostname/result/data';
                   $host = substr $string, 0, index($string, '/result');
                 }

Benchmark: timing 50000 iterations of class, dot, substr...
     class:  7 secs ( 7.02 usr  0.00 sys =  7.02 cpu)
       dot:  9 secs ( 8.27 usr  0.00 sys =  8.27 cpu)
    substr:  4 secs ( 3.37 usr  0.00 sys =  3.37 cpu)


--
Charles DeRykus


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

Date: Wed, 05 Aug 1998 03:04:14 GMT
From: Tom Phoenix <rootbeer@teleport.com>
Subject: Re: Running a shell from perl?
Message-Id: <Pine.GSO.4.02.9808042002350.2396-100000@user2.teleport.com>

On Wed, 5 Aug 1998, Arran Price wrote:

> I have a menu that runs as soon as the user logs in, One of the
> options on this menu should allow the user to get to the command
> shell.

> This works in ksh, but in perl I try to run the shell and it just
> returns to my menu straight away.

Have you read the docs for the method you're using to start the shell?

> should I be using 
> `shell`;
> system(shell);

No, not like that. But the documentation should straighten you out. Good
luck!

-- 
Tom Phoenix       Perl Training and Hacking       Esperanto
Randal Schwartz Case:     http://www.rahul.net/jeffrey/ovs/



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

Date: 5 Aug 1998 03:15:47 GMT
From: tigger@io.nospaam.com
Subject: Re: Running a shell from perl?
Message-Id: <6q8ip3$4fc$1@hiram.io.com>

Well, I am pretty new to perl myself, but I have seen that the Comm.pl module 
will allow exactly this sort of connection. Hint: There is a sample script
at the bottom of the Comm.pl file itself that does this.

Paul Archer


Arran Price <arranp@datamail.co.nz> spewed forth with:
> I have a menu that runs as soon as the user logs in,
> One of the options on this menu should allow the user to get to the
> command shell.  When the user has finished exit should return to the
> menu.  This works in ksh, but in perl I try to run the shell and it just
> returns to my menu straight away.
> should I be using 
> `shell`;
> system(shell);

> any ideas what Im doing wrong?

-- 
     _________________________________________________________________

     * Tech Support: "I need you to boot the computer."
     * Customer: (THUMP! Pause.) "No, that didn't help."
     _________________________________________________________________


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

Date: Tue, 4 Aug 1998 20:13:06 -0500
From: tadmc@flash.net (Tad McClellan)
Subject: Re: Single word ouptu from aa array
Message-Id: <2jb8q6.jt4.ln@localhost>

Kelly Hirano (hirano@Xenon.Stanford.EDU) wrote:
: In article <0%Mx1.338$ML4.1093024@news4.mia.bellsouth.net>,
: MSmith <Msmith@notes.net> wrote:
: >Im new to Perl. I'M trying to place a file, a txt file, into an array..then
: >print out the first character of the first line..and then the second
: >character....etc..but IM having a bit of trouble.  IM only able to print out
: >a line at a time:
: >
: >open (INFILE, "c:\\csv\\cpu_in\\test.txt");
: >@csvfiles = <INFILE>;
: >close (INFILE);
: >print @csvfiles[0];

: i would strongly recommend that you get a book to help you out (_programming
: perl_ is by far the best). 

   Most excellent advice!


: change the last line to: print $csvfiles[0]

  Less excellent advice, as it still won't do what the poster 
  said he wanted to do (print one CHAR at a time, your change
  prints one LINE at a time)...


----------------
#!/usr/bin/perl -w

@csvfiles = qw(one two three four);

foreach $line (@csvfiles) {
   foreach $char (split //, $line) {
      print "$char\n";
   }
}
----------------


--
    Tad McClellan                          SGML Consulting
    tadmc@metronet.com                     Perl programming
    Fort Worth, Texas


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

Date: Wed, 05 Aug 1998 04:19:44 GMT
From: ptimmins@netserv.unmc.edu (Patrick Timmins)
Subject: Re: Single word ouptu from aa array
Message-Id: <6q8mh0$b0u$1@nnrp1.dejanews.com>

In article <0%Mx1.338$ML4.1093024@news4.mia.bellsouth.net>,
  "MSmith" <Msmith@notes.net> wrote:
> Im new to Perl. I'M trying to place a file, a txt file, into an array..then
> print out the first character of the first line..and then the second
> character....etc..but IM having a bit of trouble.  IM only able to print out
> a line at a time:
>
> open (INFILE, "c:\\csv\\cpu_in\\test.txt");
> @csvfiles = <INFILE>;
> close (INFILE);
> print @csvfiles[0];
>
>

open (INFILE, "c:\\csv\\cpu_in\\test.txt");
while (<INFILE>) {
    while (/(.)/g) { push @csvfiles, $1; }
}
close (INFILE);
foreach $character ( @csvfiles ) {
    print "$character\n";
}


You might also try "/csv/cpu_in/test.txt" for the INFILE name (as opposed
to the c: and escaped backslashes) ... works on my system ... Gurusamy Sarathy
Perl 5.004_02 for win32

Patrick Timmins
U. Nebraska Medical Center

-----== Posted via Deja News, The Leader in Internet Discussion ==-----
http://www.dejanews.com/rg_mkgrp.xp   Create Your Own Free Member Forum


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

Date: Wed, 05 Aug 1998 02:26:50 GMT
From: Tom Phoenix <rootbeer@teleport.com>
Subject: Re: Taking out sections of a file?  How do I do this?
Message-Id: <Pine.GSO.4.02.9808041925100.2396-100000@user2.teleport.com>

On Tue, 4 Aug 1998, Andrew Collington wrote:

> I have a file with a lot of news articles in it.  What I would like to
> do is be able to delete blocks of these articles 

Maybe you want to re-write the file with only the data you want to keep.
There's information on doing that in the FAQ. Hope this helps!

-- 
Tom Phoenix       Perl Training and Hacking       Esperanto
Randal Schwartz Case:     http://www.rahul.net/jeffrey/ovs/



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

Date: Wed, 05 Aug 1998 04:44:55 GMT
From: edwardv@jps.net
Subject: TEST
Message-Id: <6q8o07$dat$1@nnrp1.dejanews.com>

TEST MESSAGE

-----== Posted via Deja News, The Leader in Internet Discussion ==-----
http://www.dejanews.com/rg_mkgrp.xp   Create Your Own Free Member Forum


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

Date: 12 Jul 98 21:33:47 GMT (Last modified)
From: Perl-Request@ruby.oce.orst.edu (Perl-Users-Digest Admin) 
Subject: Special: Digest Administrivia (Last modified: 12 Mar 98)
Message-Id: <null>


Administrivia:

Special notice: in a few days, the new group comp.lang.perl.moderated
should be formed. I would rather not support two different groups, and I
know of no other plans to create a digested moderated group. This leaves
me with two options: 1) keep on with this group 2) change to the
moderated one.

If you have opinions on this, send them to
perl-users-request@ruby.oce.orst.edu. 


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.  

To submit articles to comp.lang.perl.misc (and this Digest), send your
article to perl-users@ruby.oce.orst.edu.

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.

The Meta-FAQ, an article containing information about the FAQ, is
available by requesting "send perl-users meta-faq". The real FAQ, as it
appeared last in the newsgroup, can be retrieved with the request "send
perl-users FAQ". Due to their sizes, neither the Meta-FAQ nor the FAQ
are included in the digest.

The "mini-FAQ", which is an updated version of the Meta-FAQ, is
available by requesting "send perl-users mini-faq". It appears twice
weekly in the group, but is not distributed in the digest.

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 V8 Issue 3351
**************************************

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