[23391] in Perl-Users-Digest

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

Perl-Users Digest, Issue: 5610 Volume: 10

daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Fri Oct 3 14:13:06 2003

Date: Fri, 3 Oct 2003 11:10:12 -0700 (PDT)
From: Perl-Users Digest <Perl-Users-Request@ruby.OCE.ORST.EDU>
To: Perl-Users@ruby.OCE.ORST.EDU (Perl-Users Digest)

Perl-Users Digest           Fri, 3 Oct 2003     Volume: 10 Number: 5610

Today's topics:
        LWP:UserAgent not working ??? (Gaurav)
    Re: LWP:UserAgent not working ??? <noreply@gunnar.cc>
    Re: LWP:UserAgent not working ??? (Bill)
    Re: Order of attachments in Multipart POST <twhu@lucent.com>
    Re: Perl CGI executing command line functions (Bill)
    Re: Perl CGI executing command line functions (Nick)
    Re: Perl CGI executing command line functions (Tad McClellan)
    Re: regex behavior <michael.p.broida@boeing_oops.com>
    Re: regex behavior <michael.p.broida@boeing_oops.com>
    Re: regex behavior <pinyaj@rpi.edu>
    Re: Send two documents to browser? <jboes@nexcerpt.com>
    Re: Send two documents to browser? <jurgenex@hotmail.com>
    Re: Unexpected alteration of array's content (Roy Johnson)
    Re: Unexplained Multiple Lauches of Script with NetBack <waltman@pobox.com>
    Re:  <bwalton@rochester.rr.com>
        Digest Administrivia (Last modified: 6 Apr 01) (Perl-Users-Digest Admin)

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

Date: 3 Oct 2003 07:25:09 -0700
From: bansal2425@hotmail.com (Gaurav)
Subject: LWP:UserAgent not working ???
Message-Id: <42983cb.0310030625.fa12d98@posting.google.com>

Hello,

i have a perl script that i last used early this year i guess. It was running fine. 

Now if i try to run it, i get this error message. 
***********************************
perl data.pl 4 1 2002 6 30 2002
Can't locate LWP/UserAgent.pm in @INC (@INC contains:
/usr/perl5/5.00503/sun4-so
laris /usr/perl5/5.00503 /usr/perl5/site_perl/5.005/sun4-solaris
/usr/perl5/site
_perl/5.005 .) at Web.pm line 12.
BEGIN failed--compilation aborted at data.pl line 10.
***********************************



File: data.pl
*****************************************************
#! /usr/local/bin/perl

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

#importing package Web
use Web;                             //LINE 10

-----
*************************************************


FILE: Web.pm
******************************************
package Web;

#LWP::UserAgent class implements WWW user agent in perl refer this website
#for more details , http://www.perldoc.com/perl5.6/lib/LWP/UserAgent.html
 ------
require LWP::UserAgent;             //LINE 12
-------
*******************************************************


Can someone tell me whats wrong? 
what is @INC ? 

thank you in advance. 

Gaurav


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

Date: Fri, 03 Oct 2003 17:01:36 +0200
From: Gunnar Hjalmarsson <noreply@gunnar.cc>
Subject: Re: LWP:UserAgent not working ???
Message-Id: <blk323$d82j0$1@ID-184292.news.uni-berlin.de>

Gaurav wrote:
> i have a perl script that i last used early this year i guess. It
> was running fine.
> 
> Now if i try to run it, i get this error message.
> ***********************************
> perl data.pl 4 1 2002 6 30 2002
> Can't locate LWP/UserAgent.pm in @INC

<snip>

> Can someone tell me whats wrong?

I suppose that it is a CGI script that you are running on a shared
server somewhere, and that your hosting provider has made some changes
since last time you run it.

You should ask your provider to reinstall the libwww-perl package.

> what is @INC ?

     http://learn.perl.org/

-- 
Gunnar Hjalmarsson
Email: http://www.gunnar.cc/cgi-bin/contact.pl



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

Date: 3 Oct 2003 10:46:02 -0700
From: wherrera@lynxview.com (Bill)
Subject: Re: LWP:UserAgent not working ???
Message-Id: <239ce42f.0310030946.66fedbec@posting.google.com>

bansal2425@hotmail.com (Gaurav) wrote in message news:<42983cb.0310030625.fa12d98@posting.google.com>...
> Hello,
> 
> i have a perl script that i last used early this year i guess. It was running fine. 

Was this on the samer server setup? Or was the installation changed?


> 
> Now if i try to run it, i get this error message. 
> ***********************************
> perl data.pl 4 1 2002 6 30 2002
> Can't locate LWP/UserAgent.pm in @INC (@INC contains:
> /usr/perl5/5.00503/sun4-so
> laris /usr/perl5/5.00503 /usr/perl5/site_perl/5.005/sun4-solaris
> /usr/perl5/site
> _perl/5.005 .) at Web.pm line 12.
> BEGIN failed--compilation aborted at data.pl line 10.
> ***********************************
> 
> 
> Can someone tell me whats wrong? 
> what is @INC ? 
> 

@INC is the list of places where a module might be stored on disk.

> thank you in advance. 
> 
> Gaurav

Usually this means LWP is not installed properly--check this via

perl -e "use LWP::UserAgent;"

at the command line--does it tell you it cannot find the module?


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

Date: Fri, 3 Oct 2003 09:58:52 -0400
From: "Tulan W. Hu" <twhu@lucent.com>
Subject: Re: Order of attachments in Multipart POST
Message-Id: <bljvcc$ak9@netnews.proxy.lucent.com>

"David Wake" <dwake.no.spam@alumni.stanford.org> wrote in message...
> Does anyone know of a way to control the order of file attachments
> sent in a multipart POST statement?  They seem to be sent in a random
> order each time.
>
>
> use HTTP::Request::Common;
> use LWP::UserAgent;
> my $ua = LWP::UserAgent->new;
>
> my $response = $ua->request(POST 'http://www.foo.com/forminput.cgi,
>        Content_Type => 'form-data',
>        Content      => [
>                          file1   => ["/home/dwake/file1"],
>                          file2   => ["/home/dwake/file2"],
>                        ]  );
>
> The order in which file1 and file2 are attached seems to vary each
> time this script is run.  I would like to always send them in the same
> order if possible.

Why do you need to care about the order of the files?
Use CGI module in the forminput.cgi and
$query->param('file1') and $query->param('file2') will allow
you to get the individual files. The order is not important.




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

Date: 3 Oct 2003 06:27:46 -0700
From: wherrera@lynxview.com (Bill)
Subject: Re: Perl CGI executing command line functions
Message-Id: <239ce42f.0310030527.38cf22d3@posting.google.com>

ko <kuujinbo@hotmail.com> wrote in message news:<bljf8i$bg1$1@pin3.tky.plala.or.jp>...
> Phil Meyer wrote:
> 

> I have a question about whether an input field is any more secure than a 
> pull-down list/checkbox. Even though the form is hard-coded can't 
> aynyone submit pretty much anything they want, for example with LWP?
> 
> > Collecting process accounting for individual accounts is MUCH safer than
> > trying to figure out which IP was connected to the web server at the time
> > of the 'problem'.
> > 

(OT)

Linux has Webmin to do all that you are asking in its CGI 'shell'
feature:

http://www.webmin.com

--and I think that some of their code can be adapted to do what you
want.

However, this is not really Perl, and, I think allowing anyone out
there on the Web to use either Webmin or your equivalent of an
arbitrary command line is __very very__ unwise. IMHO, Webmin is best
confined _behind_ a firewall.


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

Date: 3 Oct 2003 07:07:57 -0700
From: kvetchv@yahoo.com (Nick)
Subject: Re: Perl CGI executing command line functions
Message-Id: <3eb8c8ea.0310030607.47defaff@posting.google.com>

Thanks for all your comments.  I will definitely look into all the
possibilities before I commit to anything, everyone has given me a lot
to look into.  Even though there will be someone that reviews and
corrects any flaws in my CGI script (that person just doesn't have the
time right now to write the script so I thought I would try it and
learn a little Perl in the meantime) I will study up on some Perl
before I attempt to jump into this.  A friend gave me a Perl book to
read, so I will study up on that and then come back with some more
questions.

Thanks,
Nick


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

Date: Fri, 3 Oct 2003 10:05:11 -0500
From: tadmc@augustmail.com (Tad McClellan)
Subject: Re: Perl CGI executing command line functions
Message-Id: <slrnbnr417.371.tadmc@magna.augustmail.com>

Nick <kvetchv@yahoo.com> wrote:

> A friend gave me a Perl book to
> read


Which one?

There are lots of poor Perl books.

Tell us which one you have, and we'll tell you if it's good or not.


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


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

Date: Fri, 3 Oct 2003 17:17:13 GMT
From: "Michael P. Broida" <michael.p.broida@boeing_oops.com>
Subject: Re: regex behavior
Message-Id: <3F7DAF19.BFE80D39@boeing_oops.com>

Jeff 'japhy' Pinyan wrote:
> 
> On Wed, 1 Oct 2003, Michael P. Broida wrote:
> 
> >       Now why isn't the () part of that getting the FIRST of those
> >       characters?
> 
> It does... but then the + modifier causes $1 to be repopulated with the
> NEXT character \w matches, and so on.

	(I e-mailed a different response, then thought about it more.)

	Hmm, that explains it pretty well.  I guess my only remaining
	question would be:  why does it actually "repopulate"??

	It seems as though, once it matches that single character, it
	would/should save it in $1 as the () directs, and the NEXT
	matched character would go into $2 instead of being thrown
	away, and the next in $3, etc.  I mean, the + seems to be
	telling it to repeat the entire (\w) operation, and THAT
	is saving characters.

	Is there an operator precedence kinda thing going on??  Maybe
	the + has to "FINISH" before the () can save a value??  That
	would make it completely understandable to me.  <grin>

	Thanks for the answers!
		Mike


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

Date: Fri, 3 Oct 2003 17:24:13 GMT
From: "Michael P. Broida" <michael.p.broida@boeing_oops.com>
Subject: Re: regex behavior
Message-Id: <3F7DB0BD.235BE046@boeing_oops.com>

David Oswald wrote:
> 
> > > So, 'a bb ccc dddd' =~ /(\w)+/g; returns for each substring of
> > > consecutive word characters the last one, resulting in 'a', 'b', 'c' and
> 'd'.
> >
> > That tests out as you said, so it's MY thinking that's off.  :)
> > Hopefully, you can clue me in.  :)
> >
> > I expected it to result in "a,bb,ccc,dddd". Now I realize that
> > it's the positioning of the + that causes it to get a single
> > character from each group.  If the + is inside the (), it
> > prints what I expected.
> >
> > But...  What is causing the original /(\w)+/ to get the LAST
> > character from each group instead of the FIRST character from
> > each group?
> 
> Because, walking through your string of "a bb ccc dddd" look at what your
> regexp is doing:
> Pass one, step one.  Find and capture "a".  Return "a".
> Pass 2, step 1: Find and capture first 'b'.
> Pass2, step 2: Find 2nd 'b', and replace the first 'b' with the second one.
> Return 2nd 'b'.
> Pass3, step 1: Find first 'c' and capture it.
> Pass3, step 2: Find second 'c' and put it where first 'c' had been captured.
> Pass3, step 3: Find third 'c' and put it where the 2nd 'c' had been
> captured.  Return 3rd 'c'.
> Pass4..... you should get the idea by now.
> 
> Think of the capturing parens as your pocket, and it only has room for one
> thing.  The regexp puts the first thing it matches into the pocket.  When it
> finds (due to the quantifier) that it matches the 2nd thing, take the first
> one out and put the 2nd one in.  And so on.

	See my answer to Jeff 'japhy" Pinyan.

	Your explanation makes sense, especially since the results are
	just what (all of) you are espousing.  <grin>

	But I guess the part about "replacing" the value doesn't sit well
	with me.  I don't see any operator telling it to "replace" things.

	It looks to me as though the (\w) part should save EACH char
	that is matched into a separate $n variable.  The + tells the
	matching part to continue, but why doesn't the next pass through
	(\w) save a NEW character in a NEW $n variable ($1,$2,etc)??

	As I said in the other response: if the + operation must FINISH
	before the () can save anything (one char), that would make it
	all understandable to me.  Operator precedence would cover that.

	I'm not trying to argue here.  :)  It undeniably works as you've
	said it does: test results bear that out.  But I'm trying to
	understand WHY it works that way and not another way that seems
	to make as much sense to me.

		Mike


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

Date: Fri, 3 Oct 2003 14:02:09 -0400
From: Jeff 'japhy' Pinyan <pinyaj@rpi.edu>
To: "Michael P. Broida" <michael.p.broida@boeing.com>
Subject: Re: regex behavior
Message-Id: <Pine.SGI.3.96.1031003135651.1160440A-100000@vcmr-64.server.rpi.edu>

[posted & mailed]

On Fri, 3 Oct 2003, Michael P. Broida wrote:

>> It does... but then the + modifier causes $1 to be repopulated with the
>> NEXT character \w matches, and so on.
>
>	It seems as though, once it matches that single character, it
>	would/should save it in $1 as the () directs, and the NEXT
>	matched character would go into $2 instead of being thrown
>	away, and the next in $3, etc.  I mean, the + seems to be
>	telling it to repeat the entire (\w) operation, and THAT
>	is saving characters.

But you're ignoring how a regex is compiled.  Watch:

  perl -mre=debug -e 'qr/(a+)/'
  ...
  Compiling REx `(a+)'
  ...
   1: OPEN1(3)
   3:   PLUS(6)
   4:     EXACT <a>(0)
   6: CLOSE1(8)
   8: END(0)

versus:

  perl -mre=debug -e 'qr/(a)+/'
  ...
  Compiling REx `(a)+'
  ...
   1: CURLYN[1] {1,32767}(11)
   3:   NOTHING(5)
   5:   EXACT <a>(0)
   9:   WHILEM(0)
  10: NOTHING(11)
  11: END(0)

A regex is compiled into an array of instructions, opcodes.  Some opcodes
have additional data stored with them, such as the OPEN and CLOSE opcodes,
which have a number stored telling them WHICH $<DIGIT> variable to store
the matched content to.  You can't change that.  Each pair of capturing
parentheses refers to a SPECIFIC, SINGLE $<DIGIT>.

-- 
Jeff Pinyan            RPI Acacia Brother #734            2003 Rush Chairman
"And I vos head of Gestapo for ten     | Michael Palin (as Heinrich Bimmler)
 years.  Ah!  Five years!  Nein!  No!  | in: The North Minehead Bye-Election
 Oh.  Was NOT head of Gestapo AT ALL!" | (Monty Python's Flying Circus)



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

Date: Fri, 03 Oct 2003 13:43:09 GMT
From: Jeff Boes <jboes@nexcerpt.com>
Subject: Re: Send two documents to browser?
Message-Id: <54465ca61f9d30112875135971e93be5@news.teranews.com>

Mark wrote:
> Hi All, 
> 
> I have a commercial website search script which is slow in returning
> its results. The consequence is that for a short period the screen is
> white until the results are returned. 
> 
> Is there a simple way to make the script return a temporary document
> to the browser which is then replaced by the search results? 
> 

Yes, there are simple ways to do this. However, they are no more 
Perl-specific than they are Cobol-specific. Rather than give you a whole 
solution here (and encourage more non-Perl-specific questions, drowning 
out those with Perl questions), I'll mention "interstitial pages", 
"browser redirects", and point you toward Google and the 
comp.infosystems.www.authoring.cgi newsgroup.

-- 
Jeff Boes                                      vox 269.226.9550 ext 24
Database Engineer                                     fax 269.349.9076
Nexcerpt, Inc.                                 http://www.nexcerpt.com
            ...Nexcerpt... Extend your Expertise



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

Date: Fri, 03 Oct 2003 13:50:00 GMT
From: "Jürgen Exner" <jurgenex@hotmail.com>
Subject: Re: Send two documents to browser?
Message-Id: <c8ffb.39703$Wd7.8634@nwrddc03.gnilink.net>

Mark wrote:
> I have a commercial website search script which is slow in returning
> its results. The consequence is that for a short period the screen is
> white until the results are returned.
>
> Is there a simple way to make the script return a temporary document
> to the browser which is then replaced by the search results?

I am guessing you are talking about a CGI program (you forgot to mention)?
Then sure, no problem. In Perl you do it the same way  as in any other
programming language, none of your question is Perl-specific in any way.

Actually this Question is Asked Frequently (hint, hint!) ... in the proper
CGI newsgroups.

jue




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

Date: 3 Oct 2003 10:49:16 -0700
From: rjohnson@shell.com (Roy Johnson)
Subject: Re: Unexpected alteration of array's content
Message-Id: <3ee08638.0310030949.3b503ce0@posting.google.com>

Matija Papec <mpapec@yahoo.com> wrote in message news:<hdronv01mtn2q3gke24vakffnf8j5i88h9@4ax.com>...
> Brian McCauley <nobull@mail.com> wrote:
> >> for my $line (map $_, @lines){
> >
> >Personally I'm supprised that works.  

What's surprising about it? map() generates a new array, which is used
in the loop. It would be equivalent to say

for my $line (my @copy = @array) {

except, of course, that this names the copy. If you want to avoid new
names, you can say

for my $line (my @array = @array) {

which might cause people to blink. I can tell you like code that makes
people blink. :-)

> >But even though it does [...] I still prefer:
> >
> >  for my $line (@{[@lines]}){

This also generates a new copy of the entire array (into an anonymous
ref, which is then dereferenced). It has a somewhat higher blink
factor than the earlier examples.

But why not just copy the element you're playing with? Save a little
memory.

for (@lines) {
  my $line = $_;
 ...

Or re-define the loop variable inside the loop. Then you've protected
the loop variable from possible modification, and you haven't
cluttered your namespace. This is actually rather slick, and after a
blink, it's actually apparent what you're doing: working on a local
copy.

for my $line (@array) {
    my $line = $line;
    $line++;
print "Affected $line\n";
}
print join('', @array), "\n";

If you want to use $_, you'll need to make it local, rather than my:

for (@array) {
    local $_ = $_;
    $_++;
print "Affected $_\n";
}
print join('', @array), "\n";


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

Date: Fri, 3 Oct 2003 10:11:23 -0400
From: Walt Mankowski <waltman@pobox.com>
Subject: Re: Unexplained Multiple Lauches of Script with NetBackup ... could it be PERL?
Message-Id: <slrnbnr0s9.1ki.waltman@waltman.dnsalias.org>

In article <8_2cnfo5-731-uCiXTWJig@comcast.com>, Jay W wrote:
> I have a PERL script that is executed by NetBackup "bpstart". From within
> the script two different lines are launched depending on the Policy passed
> to bpstart in %2. Only one of the two lines should be launched at any given
> time.
> 
> The problem is that shortly after launching the script (about 5 minutes), a
> second occurrance starts, then a 3rd, then a 4th .... up to 29 occurances in
> some cases. Usually this scenario ends with a Dr Watson abort. The odd thing
> is that I use about 7 command line parameters that are identical in each
> launch, so a full command line is being "re-executed"  :
> 
> function: Perl_dounwind
>         280363f1 b903010000       mov     ecx,0x103
>         280363f6 7417             jz      Perl_sv_compile_2op+0x6fa0
> (2803ef0f)
> 
> *----> Stack Back Trace <----*
> 
> FramePtr ReturnAd Param#1  Param#2  Param#3  Param#4  Function Name
> 0140FD9C 2805D784 01B31308 015D41C4 28024499 015D41C4 !Perl_dounwind
> 0140FE24 280862DE 015D41C4 00000000 00000000 505C3A43 !Perl_runops_standard
> 0140FF3C 00401012 0000000C 015D24B0 015D2AF8 004010F9 !RunPerl
> 0140FFC0 77E9CA90 00000000 00000000 7FFDF000 C0000005 !<nosymbols>
> 0140FFF0 00000000 00401016 00000000 000000C8 00000100
> kernel32!CreateProcessW
> 
> I guess, the questions are :
> 
> 1. Has anyone else run into this?
> 2. Is there a syntax that may inadvertantly start another instance of the
> command that was originally launched? (I'm 1st year PERL)
> 
> I'm trying to prove through debug code that it is NetBackup's fault and not
> PERL
> 
> Env :
> 
> W2K AS - SP4
> ActiveState PERL 5.8.1

If the problem is on the Perl end and not the NetBackup end, it's much
more likely that it's something in the script and not the Perl
executable itself.  What's your script doing?  Is it maybe doing
something like fork or system that would kick off another process?

Walt


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

Date: Sat, 19 Jul 2003 01:59:56 GMT
From: Bob Walton <bwalton@rochester.rr.com>
Subject: Re: 
Message-Id: <3F18A600.3040306@rochester.rr.com>

Ron wrote:

> Tried this code get a server 500 error.
> 
> Anyone know what's wrong with it?
> 
> if $DayName eq "Select a Day" or $RouteName eq "Select A Route") {

(---^


>     dienice("Please use the back button on your browser to fill out the Day
> & Route fields.");
> }
 ...
> Ron

 ...
-- 
Bob Walton



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

Date: 6 Apr 2001 21:33:47 GMT (Last modified)
From: Perl-Users-Request@ruby.oce.orst.edu (Perl-Users-Digest Admin) 
Subject: Digest Administrivia (Last modified: 6 Apr 01)
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.  

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 5610
***************************************


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