[30088] in Perl-Users-Digest
Perl-Users Digest, Issue: 1331 Volume: 11
daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Tue Mar 4 11:10:13 2008
Date: Tue, 4 Mar 2008 08:09: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 Tue, 4 Mar 2008 Volume: 11 Number: 1331
Today's topics:
Re: Does LWP::UserAgent download images <ben@morrow.me.uk>
Re: Does LWP::UserAgent download images <jurgenex@hotmail.com>
Re: evaluating shared rescources on remote system. <ben@morrow.me.uk>
Re: evaluating shared rescources on remote system. <ramakrishnadeepak@gmail.com>
help with LWP and log in after redirect <eatmoreoats@gmail.com>
inquiry for bioperl <rose@russ.org>
Re: Rename File Using Strring Found in File? <tadmc@seesig.invalid>
Re: Rename File Using Strring Found in File? <tadmc@seesig.invalid>
Re: Rename File Using Strring Found in File? <Entwadumayla@HyenaKiller.com>
Re: Rename File Using Strring Found in File? <Entwadumayla@HyenaKiller.com>
Re: Rename File Using Strring Found in File? <josef.moellers@fujitsu-siemens.com>
sorting index-15, index-9, index-110 "the human way"? <tch@nospam.syneticon.net>
Re: sorting index-15, index-9, index-110 "the human way <peter@makholm.net>
Re: sorting index-15, index-9, index-110 "the human way <peter@makholm.net>
Re: sorting index-15, index-9, index-110 "the human way <tch@nospam.syneticon.net>
Re: sorting index-15, index-9, index-110 "the human way <bugbear@trim_papermule.co.uk_trim>
Re: sorting index-15, index-9, index-110 "the human way <devnull4711@web.de>
Re: sorting index-15, index-9, index-110 "the human way <devnull4711@web.de>
Re: sorting index-15, index-9, index-110 "the human way <abigail@abigail.be>
Re: Two perl-specific postings on Codeaholic <bik.mido@tiscalinet.it>
Digest Administrivia (Last modified: 6 Apr 01) (Perl-Users-Digest Admin)
----------------------------------------------------------------------
Date: Tue, 4 Mar 2008 11:26:07 +0000
From: Ben Morrow <ben@morrow.me.uk>
Subject: Re: Does LWP::UserAgent download images
Message-Id: <f7ov95-5g4.ln1@osiris.mauzo.dyndns.org>
Quoth himanshu.garg@gmail.com:
>
> Will the following code also download the images on
> search.cpan.org, if any :-
>
> require LWP::UserAgent;
> my $ua = LWP::UserAgent->new;
> my $response = $ua->get('http://search.cpan.org/');
No. LWP doesn't follow links to images, it just gets the URI you ask
for.
Ben
------------------------------
Date: Tue, 04 Mar 2008 14:19:25 GMT
From: Jürgen Exner <jurgenex@hotmail.com>
Subject: Re: Does LWP::UserAgent download images
Message-Id: <ckmqs3daps5g079aae3blbg4s64ub7741f@4ax.com>
himanshu.garg@gmail.com wrote:
> Will the following code also download the images on
>search.cpan.org, if any :-
It will get whatever resource you ask it to get. If you ask for an HTML page
then it will get that HTML page, if you ask for a picture then it will get
that picture. It doesn't care about the different content types.
jue
------------------------------
Date: Tue, 4 Mar 2008 11:23:31 +0000
From: Ben Morrow <ben@morrow.me.uk>
Subject: Re: evaluating shared rescources on remote system.
Message-Id: <j2ov95-5g4.ln1@osiris.mauzo.dyndns.org>
Quoth deepak <ramakrishnadeepak@gmail.com>:
>
> Is there any perl module through which we can find the shared files
> on a remote XP system.If not is there any idea how to get the shared
> files on the remote system.
Win32::NetResource (in libwin32, so supplied with ActivePerl) will let
you enumerate the shares exported by a given machine.
Ben
------------------------------
Date: Tue, 4 Mar 2008 07:28:09 -0800 (PST)
From: deepak <ramakrishnadeepak@gmail.com>
Subject: Re: evaluating shared rescources on remote system.
Message-Id: <872407bd-56a7-456a-abd0-94894c5b46fa@e6g2000prf.googlegroups.com>
thanks Ben it worked for me, similarly is there any module for
accessing remote registry and remote desktop.
------------------------------
Date: Tue, 4 Mar 2008 06:57:51 -0800 (PST)
From: eatmoreoats <eatmoreoats@gmail.com>
Subject: help with LWP and log in after redirect
Message-Id: <4cf08b83-fef8-47c6-ab80-a825fc0ba018@u10g2000prn.googlegroups.com>
I'm trying to automate the log in to a website, which I've done before
successfully with lwp. However in this case I'm having problems and
need some help. After posting the username/password, a redirect
occurs to a new url where the username and password have been encoded.
With post redirects enabled, I end up back at the log in page, rather
than following the redirect.
Here are the request and response headers, as observed with Firefox
plugins (HTTP LIve Headers, and Tamper Data). These are observed
during a successful login with my firefox browser.
REQUEST HEADER
Host=www.mywebsite.com
User-Agent=Mozilla/5.0 (Windows; U; Windows NT 5.0; en-US; rv:
1.8.1.12) Gecko/20080201 Firefox/2.0.0.12
Accept=text/xml,application/xml,application/xhtml+xml,text/
html;q=0.9,text/plain;q=0.8,image/png,*/*;q=0.5
Accept-Language=en-us,en;q=0.5
Accept-Encoding=gzip,deflate
Accept-Charset=ISO-8859-1,utf-8;q=0.7,*;q=0.7
Keep-Alive=300
Connection=keep-alive
Referer=http://www.mywebsite.com/newmywebsite/logon.aspx
Cookie=MyCookie=; mysrv=abc;
JSESSIONID=DC638726E6831E7D6EEE996823FEECA0; JOSSO_SESSIONID=-
Content-Type=application/x-www-form-urlencoded
Content-Length=171
POSTDATA=username=theusername&password=thepassword
RESPONSE HEADER
Status=Moved Temporarily - 302
Server=Apache-Coyote/1.1
X-Powered-By=Servlet 2.4; JBoss-4.0.2 (build: CVSTag=JBoss_4_0_2
date=200505022023)/Tomcat-5.5
X-Node-Name=abc
Set-Cookie=SERVER-X=abc; Domain=.website.com; Expires=Tue, 04-Mar-2008
15:03:03 GMT; Path=/
NewMywebsite=null; Expires=Thu, 01-Jan-1970 00:00:10 GMT
Location=http://www.mywebsite.com/newmywebsite/somenewurl/
somenewscript.wotever?
cmd=login&username=YWR2YW5jZWludGVybmV0&password=c2FuaXR5
Content-Type=text/html
Content-Length=0
Date=Tue, 04 Mar 2008 14:03:03 GMT
Notice the Location in the response - if I take that url and do a get
request on it, I'm logged in. However, I can't seem to get the code to
follow the redirect down this url path. If I disable redirects, and
grab the Location header value, it is Location=http://
www.mywebsite.com/newmywebsite/somenewurl/somenewscript.wotever?cmd=login&username=null.
I'd like the script to just follow the redirect to the new location
but its not clear why thats not working. Any ideas how to make this
work ?
Here is the code example :
use HTTP::Cookies;
use LWP::UserAgent;
$ua = LWP::UserAgent->new;
$cookies = new HTTP::Cookies();
$ua->cookie_jar($cookies);
$ua->timeout(300);
$ua->requests_redirectable (['GET', 'HEAD', 'POST']);
# step 1 - hit the login page first
$response = $ua->get('http://www.mywebsite.com/newmywebsite/
logon.aspx');
# step 2 - post in the username/password
$response = $ua->post('http://www.mywebsite.com/newmywebsite/
logonvalidate.aspx',
[
username=>"theusername",
password=>"thepassword",
]
);
if ($response->is_success) { print $response->content; } else { print
$response->status_line; }
# the content at this point is the same as the logon.aspx page in step
1 - why is the redirect not working here ?
Thanks
-emo
------------------------------
Date: Tue, 4 Mar 2008 22:35:25 +0800
From: "Rose" <rose@russ.org>
Subject: inquiry for bioperl
Message-Id: <fqjmne$4uv$1@ijustice.itsc.cuhk.edu.hk>
Dear all,
Since I'm unable to identify a newsgroup at bioperl, i post a message here.
Please tell me if I should post this somewhere else. Are bioperl modules
capable of handling genomes (characters of larger than 4M or even giga)?
------------------------------
Date: Tue, 04 Mar 2008 12:10:16 GMT
From: Tad J McClellan <tadmc@seesig.invalid>
Subject: Re: Rename File Using Strring Found in File?
Message-Id: <slrnfsqe2f.ni1.tadmc@tadmc30.sbcglobal.net>
He Who Greets With Fire <Entwadumayla@HyenaKiller.com> wrote:
> On Tue, 04 Mar 2008 04:01:28 GMT, He Who Greets With Fire
><Entwadumayla@HyenaKiller.com> wrote:
>
>
>>I have a file directory named E:/personalinjury.
>
> Oops! it should be a BACKslash: E:\personalinjury
Slashes that lean either way will work fine if there is no
"shell" involved.
--
Tad McClellan
email: perl -le "print scalar reverse qq/moc.noitatibaher\100cmdat/"
------------------------------
Date: Tue, 04 Mar 2008 12:10:16 GMT
From: Tad J McClellan <tadmc@seesig.invalid>
Subject: Re: Rename File Using Strring Found in File?
Message-Id: <slrnfsqec1.ni1.tadmc@tadmc30.sbcglobal.net>
He Who Greets With Fire <Entwadumayla@HyenaKiller.com> wrote:
> I have a file directory named E:/personalinjury. In the file directory
> are 821 files named from 1.htm to 821.htm
>
> I want to access each file in turn,
foreach my $file ( glob 'E:/personalinjury/*.htm' ) { # untested
> and use a regex to parse the file
> contents to see if a string similar to this one is found in it:
> Citation: 20-333 Dorsaneo, Texas Litigation Guide § 333.103
open my $PI, '<', $file or die "could not open '$file' $!";
while ( <$PI> ) {
next unless /Citation: [\d-]+.*([\d.]+)/;
my $newfile = $1;
> So, I want to rename that file to 333.103 from whatever it was before
rename $file, "$newfile.htm" or die "could not mv '$file' $!";
last;
}
close $PI;
--
Tad McClellan
email: perl -le "print scalar reverse qq/moc.noitatibaher\100cmdat/"
------------------------------
Date: Tue, 04 Mar 2008 15:21:19 GMT
From: He Who Greets With Fire <Entwadumayla@HyenaKiller.com>
Subject: Re: Rename File Using Strring Found in File?
Message-Id: <kepqs3h600utadq7vf953kb2nfinu8lgt6@4ax.com>
OK, thanks, but the script does not seem to rename the files.
I added some troubleshooting code, most of which I commented out. I
also moved a copy of the personalinjury folder and all its files
inside the C:\Perl directory so it can access it directly.
See below for my additional comments.
#!/bin/perl
#sleep 2;
print "here I am! \n";
#sleep 2;
my $counter =1;
foreach my $file ( glob 'personalinjury/*.htm' ) {
# print "here I am A \n";
# sleep 1;
open my $PI, '<', $file or die "could not open '$file' $!";
# print "here I am! B \n";
# sleep 1;
print $counter;
print "\n";
while ( <$PI> ) {
# print "\n inside whileloop";
I AM getting to this point here.
next unless /Citation: [\d-]+.*([\d.]+)/;
but I never get to this point here--apparently the regex never sees a
match for the "Citation:" etc string.
Here is a screen shot of the typical file, with a red arrow pointing
to the string in this particular file that I want to match.
I do not know why the regex does not see a match, because it looks
like it matches it???
See here:
http://img225.imageshack.us/img225/91/citationue2.jpg
my $newfile = $1;
rename $file, "$newfile.htm" or die "could not mv '$file' $!";
print "\n renamed a file";
sleep 1;
last;
}#end while
$counter++;
print "\n count is ";
print $counter;
print "\n";
#sleep 1;
close $PI;
} #end foreach
I think the script would work ok except that it never sees a match for
the regex pattern inside the file. I am seeing the script go through
each substring of all 821 files, but it never sees a match.
------------------------------
Date: Tue, 04 Mar 2008 15:37:50 GMT
From: He Who Greets With Fire <Entwadumayla@HyenaKiller.com>
Subject: Re: Rename File Using Strring Found in File?
Message-Id: <4uqqs3dogu0pndf5frf94icoeaketo0d8b@4ax.com>
On Tue, 04 Mar 2008 15:21:19 GMT, He Who Greets With Fire
<Entwadumayla@HyenaKiller.com> wrote:
> next unless /Citation: [\d-]+.*([\d.]+)/;
I think it has to be something to do with the colon or the white
spaces between the colon and the first of the digits. Is the colon a
special character in perl? One white space is in the regex, but there
appears to be two white spaces in the screen shot of the file I linked
to above....
------------------------------
Date: Tue, 04 Mar 2008 16:59:04 +0100
From: Josef Moellers <josef.moellers@fujitsu-siemens.com>
Subject: Re: Rename File Using Strring Found in File?
Message-Id: <fqjril$6gd$1@nntp.fujitsu-siemens.com>
He Who Greets With Fire wrote:
> On Tue, 04 Mar 2008 15:21:19 GMT, He Who Greets With Fire
> <Entwadumayla@HyenaKiller.com> wrote:
>
>> next unless /Citation: [\d-]+.*([\d.]+)/;
>
> I think it has to be something to do with the colon or the white
> spaces between the colon and the first of the digits. Is the colon a
> special character in perl? One white space is in the regex, but there
> appears to be two white spaces in the screen shot of the file I linked
> to above....
I usually replace any white space to be matched by "\s+". That catches
TABs *and* blanks, so maybe
next unless /Citation:\s+[\d-]+.*([\d.]+)/;
will do?
--
These are my personal views and not those of Fujitsu Siemens Computers!
Josef Möllers (Pinguinpfleger bei FSC)
If failure had no penalty success would not be a prize (T. Pratchett)
Company Details: http://www.fujitsu-siemens.com/imprint.html
------------------------------
Date: Tue, 04 Mar 2008 13:52:12 +0100
From: Tomasz Chmielewski <tch@nospam.syneticon.net>
Subject: sorting index-15, index-9, index-110 "the human way"?
Message-Id: <fqjgls$cnj$1@online.de>
Let's say I have an array consisting of:
some-name-10
some-name-9
some-name-102
some-name-89
I would like to sort it the "human way", with the result:
some-name-9
some-name-10
some-name-89
some-name-102
What would be the suggested way to do it?
I would use 'split', but "some-name" is not static, and can be
"some-other-name" or just "name" a task later.
For the same reason, using 'substr' won't work.
Unless I write a subroutine to it.
What do you guys use to sort such things?
--
Tomasz Chmielewski
http://wpkg.org
------------------------------
Date: Tue, 04 Mar 2008 12:59:01 +0000
From: Peter Makholm <peter@makholm.net>
Subject: Re: sorting index-15, index-9, index-110 "the human way"?
Message-Id: <87bq5u1w8a.fsf@hacking.dk>
Tomasz Chmielewski <tch@nospam.syneticon.net> writes:
> I would use 'split', but "some-name" is not static, and can be
> "some-other-name" or just "name" a task later.
>
> For the same reason, using 'substr' won't work.
>
> Unless I write a subroutine to it.
Yes, you have to tell us (and perl) how to extract the number you want
to sort the lines after.
And the you sorting is trivial:
@sorted = sort { extract($a) <=> extract($b) } @unsorted
or by using some of the standard optimizations
@sorted = map { $_->[0] }
sort { $a->[0] <=> $b->[0] }
map { [ extract($_), $_ ] } @unsorted
or one of the orthers Sort::Maker can do for you.
//Makholm
------------------------------
Date: Tue, 04 Mar 2008 12:59:59 +0000
From: Peter Makholm <peter@makholm.net>
Subject: Re: sorting index-15, index-9, index-110 "the human way"?
Message-Id: <877igi1w6o.fsf@hacking.dk>
Peter Makholm <peter@makholm.net> writes:
> @sorted = map { $_->[0] }
> sort { $a->[0] <=> $b->[0] }
> map { [ extract($_), $_ ] } @unsorted
Yes, this code contains some obvious errors.
//Makholm
------------------------------
Date: Tue, 04 Mar 2008 14:14:17 +0100
From: Tomasz Chmielewski <tch@nospam.syneticon.net>
Subject: Re: sorting index-15, index-9, index-110 "the human way"?
Message-Id: <fqjhv9$e48$1@online.de>
Peter Makholm schrieb:
> Tomasz Chmielewski <tch@nospam.syneticon.net> writes:
>
>> I would use 'split', but "some-name" is not static, and can be
>> "some-other-name" or just "name" a task later.
>>
>> For the same reason, using 'substr' won't work.
>>
>> Unless I write a subroutine to it.
>
> Yes, you have to tell us (and perl) how to extract the number you want
> to sort the lines after.
>
> And the you sorting is trivial:
>
> @sorted = sort { extract($a) <=> extract($b) } @unsorted
I guess I'll just use something like, it does not have to be
super-efficient:
sub extract() {
my $name = shift;
my @columns = split /-/, $name;
my $last_column = $columns[$#columns];
}
--
Tomasz Chmielewski
http://wpkg.org
------------------------------
Date: Tue, 04 Mar 2008 13:29:49 +0000
From: bugbear <bugbear@trim_papermule.co.uk_trim>
Subject: Re: sorting index-15, index-9, index-110 "the human way"?
Message-Id: <13sqjme3d9fr7e@corp.supernews.com>
Tomasz Chmielewski wrote:
> Peter Makholm schrieb:
>> Tomasz Chmielewski <tch@nospam.syneticon.net> writes:
>>
>>> I would use 'split', but "some-name" is not static, and can be
>>> "some-other-name" or just "name" a task later.
>>>
>>> For the same reason, using 'substr' won't work.
>>>
>>> Unless I write a subroutine to it.
>>
>> Yes, you have to tell us (and perl) how to extract the number you want
>> to sort the lines after.
>>
>> And the you sorting is trivial:
>>
>> @sorted = sort { extract($a) <=> extract($b) } @unsorted
>
> I guess I'll just use something like, it does not have to be
> super-efficient:
>
> sub extract() {
> my $name = shift;
> my @columns = split /-/, $name;
> my $last_column = $columns[$#columns];
> }
or specifically go for trailing digits?
sub extract {
my $name = shift;
$name =~ m/(\d+)$/;
return $1;
}
------------------------------
Date: Tue, 04 Mar 2008 14:35:41 +0100
From: Frank Seitz <devnull4711@web.de>
Subject: Re: sorting index-15, index-9, index-110 "the human way"?
Message-Id: <6351hfF25rikvU1@mid.individual.net>
Tomasz Chmielewski wrote:
>
> What do you guys use to sort such things?
$ perldoc -q 'sort an array'
Frank
--
Dipl.-Inform. Frank Seitz; http://www.fseitz.de/
Anwendungen für Ihr Internet und Intranet
Tel: 04103/180301; Fax: -02; Industriestr. 31, 22880 Wedel
------------------------------
Date: Tue, 04 Mar 2008 14:47:18 +0100
From: Frank Seitz <devnull4711@web.de>
Subject: Re: sorting index-15, index-9, index-110 "the human way"?
Message-Id: <635278F25rikvU3@mid.individual.net>
Tomasz Chmielewski wrote:
>
> What do you guys use to sort such things?
@arr = map { $_->[2] }
sort { $a->[0] cmp $b->[0] || $a->[1] <=> $b->[1] }
map { [/(.*)-(\d+)/,$_] } @arr;
$ perldoc -q 'sort an array'
Frank
--
Dipl.-Inform. Frank Seitz; http://www.fseitz.de/
Anwendungen für Ihr Internet und Intranet
Tel: 04103/180301; Fax: -02; Industriestr. 31, 22880 Wedel
------------------------------
Date: 04 Mar 2008 16:07:08 GMT
From: Abigail <abigail@abigail.be>
Subject: Re: sorting index-15, index-9, index-110 "the human way"?
Message-Id: <slrnfsqstb.pah.abigail@alexandra.abigail.be>
_
Tomasz Chmielewski (tch@nospam.syneticon.net) wrote on VCCXCIX September
MCMXCIII in <URL:news:fqjgls$cnj$1@online.de>:
@@ Let's say I have an array consisting of:
@@
@@ some-name-10
@@ some-name-9
@@ some-name-102
@@ some-name-89
@@
@@ I would like to sort it the "human way", with the result:
@@
@@ some-name-9
@@ some-name-10
@@ some-name-89
@@ some-name-102
@@
@@
@@ What would be the suggested way to do it?
@@
@@ I would use 'split', but "some-name" is not static, and can be
@@ "some-other-name" or just "name" a task later.
@@
@@ For the same reason, using 'substr' won't work.
@@
@@ Unless I write a subroutine to it.
@@
@@
@@ What do you guys use to sort such things?
Well, that depends. Your specification, or rather lack of specification,
allows multiple interpretations. If you have:
sort-name-20
sort-name-7
name-15
name-8
do you want:
name-8
name-15
sort-name-7
sort-name-20
or
sort-name-7
name-8
name-15
sort-name-20
?
Abigail
--
perl -we '$_ = q ;4a75737420616e6f74686572205065726c204861636b65720as;;
for (s;s;s;s;s;s;s;s;s;s;s;s)
{s;(..)s?;qq qprint chr 0x$1 and \161 ssq;excess;}'
------------------------------
Date: Tue, 04 Mar 2008 15:44:53 +0100
From: Michele Dondi <bik.mido@tiscalinet.it>
Subject: Re: Two perl-specific postings on Codeaholic
Message-Id: <h2oqs3hi7pn1fo8p13t0q7o0lefio8oqkd@4ax.com>
On Tue, 04 Mar 2008 06:40:27 GMT, "John W. Krahn"
<someone@example.com> wrote:
>Ouch! Use a dispatch table instead of string eval().
>
>my %rule = (
> 1 => sub {
> ( my $arg = shift ) =~ tr/s//d;
> return $arg;
> },
> 2 => sub {
> return join '', sort split //, shift;
> },
Since the keys are numbers, an array may be appropriate.
Michele
--
{$_=pack'B8'x25,unpack'A8'x32,$a^=sub{pop^pop}->(map substr
(($a||=join'',map--$|x$_,(unpack'w',unpack'u','G^<R<Y]*YB='
.'KYU;*EVH[.FHF2W+#"\Z*5TI/ER<Z`S(G.DZZ9OX0Z')=~/./g)x2,$_,
256),7,249);s/[^\w,]/ /g;$ \=/^J/?$/:"\r";print,redo}#JAPH,
------------------------------
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 V11 Issue 1331
***************************************