[25149] in Perl-Users-Digest
Perl-Users Digest, Issue: 7398 Volume: 10
daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Fri Nov 12 14:10:54 2004
Date: Fri, 12 Nov 2004 11:10:09 -0800 (PST)
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, 12 Nov 2004 Volume: 10 Number: 7398
Today's topics:
Perl golf: lowercasing all path names (A. Farber)
Re: Perl golf: lowercasing all path names (Anno Siegel)
Re: Perl golf: lowercasing all path names <do-not-use@invalid.net>
Re: Perl golf: lowercasing all path names <mritty@gmail.com>
Re: Perl golf: lowercasing all path names <jurgenex@hotmail.com>
Re: PERL+CGI+PLUG-IN architecture <colo@megapolis.pl>
Re: PERL+CGI+PLUG-IN architecture <jurgenex@hotmail.com>
Script to pass info to GET string <blislecp@hotmail.com>
Re: Script to pass info to GET string <mritty@gmail.com>
Re: Script to pass info to GET string <jurgenex@hotmail.com>
Re: Script to pass info to GET string <blislecp@hotmail.com>
Re: Script to pass info to GET string <jurgenex@hotmail.com>
Re: Script to pass info to GET string <blislecp@hotmail.com>
Re: simple perl script for automatic form submission. <and11@rol.ru>
Re: simple perl script for automatic form submission. <ioneabu@yahoo.com>
Re: simple perl script for automatic form submission. <ioneabu@yahoo.com>
unix perl module install errors (James Marquez)
Writing a Perl Debugger - problems with xsloader (Volker Nicolai)
Digest Administrivia (Last modified: 6 Apr 01) (Perl-Users-Digest Admin)
----------------------------------------------------------------------
Date: 12 Nov 2004 05:06:20 -0800
From: Alexander.Farber@t-online.de (A. Farber)
Subject: Perl golf: lowercasing all path names
Message-Id: <c9ccaf83.0411120506.72024b60@posting.google.com>
Hi,
I need to lowercase all files and directories in the current
directory on Linux and have come up with the following script:
bolinux72:bin {74} cat lowercase.sh
#!/bin/sh
# Lowercase the files and sub-directores in the current directory
# BUGS: does not escape quotes, backslashes and dollars in path names
# Note: for Unix change -print0 to -print, -n0e to -ne, mv -v to mv
find . -depth -print0 | perl -n0e '
$old = $_;
s,([^/]+)$,\L$1,;
next if $old eq $_;
die qq{Can not move "$old" to "$_"\n} if -e;
print qq{mv -v "$old" "$_"\n}' | sh
And 1 line more for the same task, but with uppercased first letter:
bolinux72:bin {75} cat upfirst.sh
#!/bin/sh
# Uppercase the first letter and lowercase the rest for
# all files and sub-directores in the current directory
find . -depth -print0 | perl -n0e '
$old = $_;
s,([^/]+)$,\L$1,;
s,([^/]+)$,\u$1,;
next if $old eq $_;
die qq{Can not move "$old" to "$_"\n} if -e;
print qq{mv -v "$old" "$_"\n}' | sh
I wonder, if someone has a nicer solution and what
would be the best way to handle funny path names?
Regards
Alex
------------------------------
Date: 12 Nov 2004 13:30:45 GMT
From: anno4000@lublin.zrz.tu-berlin.de (Anno Siegel)
Subject: Re: Perl golf: lowercasing all path names
Message-Id: <cn2du5$sar$1@mamenchi.zrz.TU-Berlin.DE>
A. Farber <Alexander.Farber@t-online.de> wrote in comp.lang.perl.misc:
> Hi,
>
> I need to lowercase all files and directories in the current
> directory on Linux and have come up with the following script:
That isn't what we call a golf problem, and advertising it a such
comes right next to announcing a "challenge" in your subject.
What you present is mostly not Perl at all, but a rendition of a shell
script with Perl used for string processing. Do it all in Perl and
we can talk.
IOW, use File::Find (or the newer File::Find::Rule, which I haven't
looked at) to gather the file names. Use Perl's rename() to do the
renaming (and check for success instead of making a guess with -e).
That way you won't have to worry about escaping weird path names
because no shell tries to interpret them. It won't make the
script shorter, but it will make it correcter.
Anno
> bolinux72:bin {74} cat lowercase.sh
> #!/bin/sh
>
> # Lowercase the files and sub-directores in the current directory
> # BUGS: does not escape quotes, backslashes and dollars in path names
> # Note: for Unix change -print0 to -print, -n0e to -ne, mv -v to mv
>
> find . -depth -print0 | perl -n0e '
> $old = $_;
> s,([^/]+)$,\L$1,;
> next if $old eq $_;
> die qq{Can not move "$old" to "$_"\n} if -e;
> print qq{mv -v "$old" "$_"\n}' | sh
>
> And 1 line more for the same task, but with uppercased first letter:
>
> bolinux72:bin {75} cat upfirst.sh
> #!/bin/sh
>
> # Uppercase the first letter and lowercase the rest for
> # all files and sub-directores in the current directory
>
> find . -depth -print0 | perl -n0e '
> $old = $_;
> s,([^/]+)$,\L$1,;
> s,([^/]+)$,\u$1,;
> next if $old eq $_;
> die qq{Can not move "$old" to "$_"\n} if -e;
> print qq{mv -v "$old" "$_"\n}' | sh
>
> I wonder, if someone has a nicer solution and what
> would be the best way to handle funny path names?
>
> Regards
> Alex
------------------------------
Date: 12 Nov 2004 14:46:02 +0100
From: Arndt Jonasson <do-not-use@invalid.net>
Subject: Re: Perl golf: lowercasing all path names
Message-Id: <yzdr7mzch9h.fsf@invalid.net>
anno4000@lublin.zrz.tu-berlin.de (Anno Siegel) writes:
> A. Farber <Alexander.Farber@t-online.de> wrote in comp.lang.perl.misc:
> > I need to lowercase all files and directories in the current
> > directory on Linux and have come up with the following script:
>
> That isn't what we call a golf problem, and advertising it a such
> comes right next to announcing a "challenge" in your subject.
What is a golf problem?
------------------------------
Date: Fri, 12 Nov 2004 13:50:06 GMT
From: "Paul Lalli" <mritty@gmail.com>
Subject: Re: Perl golf: lowercasing all path names
Message-Id: <ic3ld.4320$Bj2.3229@trndny01>
"Arndt Jonasson" <do-not-use@invalid.net> wrote in message
news:yzdr7mzch9h.fsf@invalid.net...
> What is a golf problem?
http://perlgolf.sourceforge.net/
Paul Lalli
------------------------------
Date: Fri, 12 Nov 2004 17:12:24 GMT
From: "Jrgen Exner" <jurgenex@hotmail.com>
Subject: Re: Perl golf: lowercasing all path names
Message-Id: <Y96ld.12$d96.4@trnddc01>
[What does your question have to do with Perl golf?]
A. Farber wrote:
> I need to lowercase all files and directories in the current
> directory on Linux and have come up with the following script:
>
> bolinux72:bin {74} cat lowercase.sh
> #!/bin/sh
>
> # Lowercase the files and sub-directores in the current directory
> # BUGS: does not escape quotes, backslashes and dollars in path names
> # Note: for Unix change -print0 to -print, -n0e to -ne, mv -v to mv
>
> find . -depth -print0 | perl -n0e '
> $old = $_;
> s,([^/]+)$,\L$1,;
> next if $old eq $_;
> die qq{Can not move "$old" to "$_"\n} if -e;
> print qq{mv -v "$old" "$_"\n}' | sh
That's not Perl!
[...]
> I wonder, if someone has a nicer solution and what
What about something along the line of (untested! just as a sketch of an
idea!):
use warnings; use strict;
use File::Find;
finddepth (\&wanted, '.');
sub wanted{
if (-e (lc)){
print "Target file name ". lc $_ . " in directory " .
$File::Find::dir . " already exists, can't rename $_\n";
} else {
rename $_, lc;
}
}
> would be the best way to handle funny path names?
If we would just know what _you_ mean by "funny path names".
jue
------------------------------
Date: Fri, 12 Nov 2004 13:39:54 +0000
From: Colombo <colo@megapolis.pl>
Subject: Re: PERL+CGI+PLUG-IN architecture
Message-Id: <cn2anl$2qv$1@achot.icm.edu.pl>
Colombo wrote:
> Hi,
> I'm looking for any information (or example programs) about writing
> programs in perl (cgi) in plug-in architecture. I was searching almost
> everywhere with no result :(.
>
> Colombo
In other way, I'm looking for mechanism in perl to load and use new
modules while running program.
I hope this is clear because I don't know how to explain it in other way.
Colombo
------------------------------
Date: Fri, 12 Nov 2004 12:47:08 GMT
From: "Jrgen Exner" <jurgenex@hotmail.com>
Subject: Re: PERL+CGI+PLUG-IN architecture
Message-Id: <gh2ld.1261$fc.752@trnddc06>
Colombo wrote:
> Colombo wrote:
>> I'm looking for any information (or example programs) about writing
>> programs in perl (cgi) in plug-in architecture. I was searching
>> almost everywhere with no result :(.
>
> In other way, I'm looking for mechanism in perl to load and use new
> modules while running program.
> I hope this is clear because I don't know how to explain it in other
> way.
Ah, ok, why didnt' you say so in the first place?
Most likely you are looking for
perldoc -f require
but you should also check
perldoc -f do
perldoc -f eval
jue
------------------------------
Date: Fri, 12 Nov 2004 07:59:20 -0800
From: "Shabam" <blislecp@hotmail.com>
Subject: Script to pass info to GET string
Message-Id: <hcSdnc3upp6EQAncRVn-oA@adelphia.com>
I need to create a perl script that basically loads a web page, asks for a
Username and stores it as "Username". Also, it takes the domain name of the
site (that runs the script) and stores that in "Domain".
Next it does a substition:
http://www.anothersite.com/whatever.cgi?var1=Username&var2=Domain
And forwards the user to that url.
I'm a total newbie here. Can someone hack up a quick script based on this
requirement? I'm going to do some string limits later, but I need some
template to start with as I'm completely stuck. Thanks!
------------------------------
Date: Fri, 12 Nov 2004 16:20:50 GMT
From: "Paul Lalli" <mritty@gmail.com>
Subject: Re: Script to pass info to GET string
Message-Id: <Cp5ld.4$2V4.0@trndny06>
[removed non-existant groups, set followups to c.l.p.m]
"Shabam" <blislecp@hotmail.com> wrote in message
news:hcSdnc3upp6EQAncRVn-oA@adelphia.com...
> I need to create a perl script that basically loads a web page, asks
for a
Define "loads a web page". Are you running a script that will retrieve
a webpage, or are you creating a CGI script running on some web server?
Option 1: perldoc LWP::Simple
Option 2: perldoc CGI
> Username and stores it as "Username". Also, it takes the domain name
of the
> site (that runs the script) and stores that in "Domain".
>
> Next it does a substition:
perldoc perlre
>
> http://www.anothersite.com/whatever.cgi?var1=Username&var2=Domain
>
> And forwards the user to that url.
perldoc LWP::Simple
> I'm a total newbie here.
http://learn.perl.org
> Can someone hack up a quick script based on this
> requirement?
http://jobs.perl.org
> I'm going to do some string limits later, but I need some
> template to start with as I'm completely stuck. Thanks!
You're quite welcome.
Paul Lalli
------------------------------
Date: Fri, 12 Nov 2004 17:01:29 GMT
From: "Jrgen Exner" <jurgenex@hotmail.com>
Subject: Re: Script to pass info to GET string
Message-Id: <J%5ld.323$BX4.57@trnddc08>
Shabam wrote:
> I need to create a perl script that basically loads a web page,
perldoc LWP
> asks
> for a Username
perldoc -f print
perldoc perlop (pretty far down in the section about "I/O Operators")
> and stores it as "Username". Also, it takes the
Now, where and how do you want to store that? In a file? In a database? What
kind of database? Just not enough information...
> domain name of the site (that runs the script) and stores that in
> "Domain".
>
> Next it does a substition:
> http://www.anothersite.com/whatever.cgi?var1=Username&var2=Domain
I suppose this is meant to be result of the substitution? What is the
original string? Not enough information...
> And forwards the user to that url.
???
Do you mean you want to open a browser program and load that page?
perldoc -f system
perldoc -f exec
> I'm a total newbie here. Can someone hack up a quick script based on
> this requirement?
Can probably yes, want to unlikely.
If you are looking for ready-made scripts you came to the wrong place.
Show us what you have and many people here will be happy to help you with
the next step.
jue
------------------------------
Date: Fri, 12 Nov 2004 09:11:12 -0800
From: "Shabam" <blislecp@hotmail.com>
Subject: Re: Script to pass info to GET string
Message-Id: <PvSdnYvsJJNvcAncRVn-uw@adelphia.com>
> Now, where and how do you want to store that? In a file? In a database?
What
> kind of database? Just not enough information...
Very basic. Just in memory is fine.
> > domain name of the site (that runs the script) and stores that in
> > "Domain".
> >
> > Next it does a substition:
> > http://www.anothersite.com/whatever.cgi?var1=Username&var2=Domain
>
> I suppose this is meant to be result of the substitution? What is the
> original string? Not enough information...
I just need it to substitute the "Username" and "Domain" into the string,
and redirect the user to that url. The
"http://www.anothersite.com/whatever.cgi" part of it is hardcoded.
> Do you mean you want to open a browser program and load that page?
> perldoc -f system
> perldoc -f exec
No. I mean this whole script is running as a cgi on a web page. It takes
the username that the user enters, and based on the domain name that the cgi
script is running from, gets the other variable (Domain). Then, it
redirects the user to the url
http://www.anothersite.com/whatever.cgi?var1=Username&var2=Domain.
------------------------------
Date: Fri, 12 Nov 2004 17:15:29 GMT
From: "Jrgen Exner" <jurgenex@hotmail.com>
Subject: Re: Script to pass info to GET string
Message-Id: <Rc6ld.13$d96.4@trnddc01>
Shabam wrote:
[...]
> No. I mean this whole script is running as a cgi on a web page.
Oh, a stealth CGI question.
Good by then.
jue
------------------------------
Date: Fri, 12 Nov 2004 09:56:34 -0800
From: "Shabam" <blislecp@hotmail.com>
Subject: Re: Script to pass info to GET string
Message-Id: <5_adne5qes0EZQncRVn-qQ@adelphia.com>
> Oh, a stealth CGI question.
> Good by then.
What are you talking about? It's a simple web page cgi. User enters
"Username", and the page takes that, along with the domain name from the
server, and redirects the user to another script. This is being used for an
order system for hosting, so that the user gets http://username.domain.com
as their address. The billing system I'm using now doesn't support such a
mechanism natively, as it accepts full domain names only. Thus I need to do
it this way.
I'm guessing you think I'm trying to do something bad. Don't assume,
without any basis.
------------------------------
Date: Fri, 12 Nov 2004 19:02:19 +0000
From: Andrew Tkachenko <and11@rol.ru>
Subject: Re: simple perl script for automatic form submission.
Message-Id: <cn2mv2$ls3$1@news.rol.ru>
Lots of 'dirty' work may be done by HTML::Form
module. You won't need to find all hidden etc. fields in forms,
this module will do it for you.
Regards,
Andrew
wana wrote on 12 Ноябрь 2004 11:59:
> try LWP::UserAgent from CPAN (actually it already came with my Linux
> installation).
>
> I just started playing with it and was able to get into a site I created
but
> I then tried submitting data to some commercial sites and my script was
> rejected with the same form data I was able to submit legitimately through
> their webpage. I am not sure how to 'trick' the site into not knowing if
> it is a web browser or a Perl script trying to submit form data. I can
get
> as far as looking at the html source, finding the form, identifying POST
or
> GET, and finding the field names.
>
> Since I was able to log into my own homemade site, I know it works and is
> not a Perl issue. 'Perl Cookbook' has a brief section on LWP and there is
> probably more in Lincoln Stein's book on Perl networking.
>
> wana
--
Andrew
------------------------------
Date: Fri, 12 Nov 2004 12:30:15 -0500
From: wana <ioneabu@yahoo.com>
Subject: Re: simple perl script for automatic form submission.
Message-Id: <10p9peqs0grjc73@news.supernews.com>
Andrew Tkachenko wrote:
> Lots of 'dirty' work may be done by HTML::Form
> module. You won't need to find all hidden etc. fields in forms,
> this module will do it for you.
>
> Regards,
> Andrew
Thanks for the tip!
It turns out that 'Network Programming with Perl' by Lincoln Stein does have
a chapter (9) on LWP. He says:
For an exhaustive treatment, see LWP's POD documentation,
or the excellent, but now somewhat dated 'Web Client
Programming with Perl [Wong 1999].
I will definitely take a look at HTML::Form now. Thanks.
wana
>
>
> wana wrote on 12 Ноябрь 2004 11:59:
>
>> try LWP::UserAgent from CPAN (actually it already came with my Linux
>> installation).
>>
>> I just started playing with it and was able to get into a site I created
> but
>> I then tried submitting data to some commercial sites and my script was
>> rejected with the same form data I was able to submit legitimately
>> through
>> their webpage. I am not sure how to 'trick' the site into not knowing if
>> it is a web browser or a Perl script trying to submit form data. I can
> get
>> as far as looking at the html source, finding the form, identifying POST
> or
>> GET, and finding the field names.
>>
>> Since I was able to log into my own homemade site, I know it works and is
>> not a Perl issue. 'Perl Cookbook' has a brief section on LWP and there
>> is probably more in Lincoln Stein's book on Perl networking.
>>
>> wana
>
------------------------------
Date: Fri, 12 Nov 2004 14:43:48 -0500
From: wana <ioneabu@yahoo.com>
Subject: Re: simple perl script for automatic form submission.
Message-Id: <10pa197ou5oll7b@news.supernews.com>
wana wrote:
> sam wrote:
>
>> Hi,
>>
>> I m not a perl expert.
>> I would like to write a simple perl script to automatically login my
>> email account that hosted by a commerical webmail server.
>>
>> Is there any sample script I can follow?
>>
>> Thanks
>> Sam
>
> try LWP::UserAgent from CPAN (actually it already came with my Linux
> installation).
>
> I just started playing with it and was able to get into a site I created
> but I then tried submitting data to some commercial sites and my script
> was rejected with the same form data I was able to submit legitimately
> through
> their webpage. I am not sure how to 'trick' the site into not knowing if
> it is a web browser or a Perl script trying to submit form data. I can
> get as far as looking at the html source, finding the form, identifying
> POST or GET, and finding the field names.
>
> Since I was able to log into my own homemade site, I know it works and is
> not a Perl issue. 'Perl Cookbook' has a brief section on LWP and there is
> probably more in Lincoln Stein's book on Perl networking.
>
> wana
Turns out I simply had to include a single hidden field to make things work.
Wow what a poor hacker deterrent, using a hidden field.
wana
------------------------------
Date: 11 Nov 2004 21:12:38 -0800
From: jamturtle@hotmail.com (James Marquez)
Subject: unix perl module install errors
Message-Id: <8e120ba9.0411112112.7522089c@posting.google.com>
Hello I am trying to install a few modules I downloaded from CPAN but
I keep getting errors from "make". I upgraded to perl 5.8.5 this
seemed to go fine. The Makefile.PL file seems to work but when I run
"make' I get these errors:
gcc -B/usr/ccs/bin/ -c -fno-strict-aliasing -pipe
-I/usr/local/include -O -DVERSION=\"2.10\" -DXS_VERSION=\"2.10\"
-fPIC "-I/usr/local/lib/perl5/5.8.5/sun4-solaris/CORE" SHA1.c
cc1: Invalid option `-fno-strict-aliasing'
make: *** [SHA1.o] Error 1
I am running Solaris and GNU make 3.80 [I upgraded this too].
Has anyone seen this error, please let me know what I might be
missing. It also seems to me that maybe my gcc does not understand
"-fno-strict-aliasing"
I have tried several modules [Digest::SHA1, HTML::Parser] with all
very much the same error. Any clues would be helpful.
cheers
-James
------------------------------
Date: 12 Nov 2004 05:04:32 -0800
From: volker.nicolai@philips.com (Volker Nicolai)
Subject: Writing a Perl Debugger - problems with xsloader
Message-Id: <861f3588.0411120504.6ae9959d@posting.google.com>
Hi,
I have written a nice little debugger routine, to generate a
trace of subs,(just a bit more than in man perldebguts)
put it into the DB package, told Perl via env vars to use it
and ran some scripts. Looked fine.
Then I typed
[237] hh10s068% perldoc -l Devel::Trace
and got that:
3 at /opt/perl/lib/5.6.1/Carp.pm line 121.
Undefined subroutine &main::2 called at
/opt/perl/lib/5.6.1/PA-RISC1.1-thread-multi/XSLoader.pm line 97.
Compilation failed in require at /opt/perl/bin/perldoc line 22.
BEGIN failed--compilation aborted at /opt/perl/bin/perldoc line 22.
My code looks as follows:
---------------------------------------
package DB;
my $callno = 0;
my $hierarchy = 0;
my $DEBUG_TRACE_FH;
my $DEBUG_TRACE_FILENAME = "PERL_DEBUG_TRACE_FILE.log";
open ($DEBUG_TRACE_FH, "> $DEBUG_TRACE_FILENAME");
sub DB {} # Define DB::DB() to be empty.
sub sub {
my $indent = ""; # Indentation string.
my $act_file; # File name of the actual sub.
my $i;
for ($i = 0; $i < $hierarchy; $i++) {
$indent .= " "; # generate indent
}
++$hierarchy;
++$callno;
$act_file = $0;
#print "DB: $callno $indent->& SUB: ($act_file) $sub (@_)\n";
print ($DEBUG_TRACE_FH "$callno $indent|--& SUB: $sub (@_)
{$act_file}\n");
&$sub;
--$hierarchy;
}
1;
-------------------------------------------
So what's up there?? I don't get it.
The xsloader line is that:
return &$xs(@_);
Seems as if Perl tries to invoke "main::" with the current value of
$hierarchy
which is 2 at that time but why?
Sorry for stupidety &
Thanks for helping in advance!
Volker
------------------------------
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.
NOTE: due to the current flood of worm email banging on ruby, the smtp
server on ruby has been shut off until further notice.
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 7398
***************************************