[30145] in Perl-Users-Digest
Perl-Users Digest, Issue: 1388 Volume: 11
daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Tue Mar 25 00:10:08 2008
Date: Mon, 24 Mar 2008 21:09:32 -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 Mon, 24 Mar 2008 Volume: 11 Number: 1388
Today's topics:
Re: Inserting new line to a string <benkasminbullock@gmail.com>
Re: passing filename path with spaces to subs <joe@inwap.com>
Re: Perl code to fill-in online form <minhaztuhin@hotmail.com>
Re: Perl code to fill-in online form <glex_no-spam@qwest-spam-no.invalid>
Re: Perl code to fill-in online form <cartercc@gmail.com>
Re: Perl code to fill-in online form <minhaztuhin@hotmail.com>
perl pack string <jsahiwal@gmail.com>
Re: perl pack string xhoster@gmail.com
Re: perl pack string <someone@example.com>
Re: perl pack string <jsahiwal@gmail.com>
Re: Redirecting to my own login page instead of Apache <cartercc@gmail.com>
The huge amount response data problem <falconzyx@gmail.com>
use base and @ISA with package re-definition bigmattstud@gmail.com
Re: use base and @ISA with package re-definition <uri@stemsystems.com>
Digest Administrivia (Last modified: 6 Apr 01) (Perl-Users-Digest Admin)
----------------------------------------------------------------------
Date: Mon, 24 Mar 2008 17:43:31 -0700 (PDT)
From: Ben Bullock <benkasminbullock@gmail.com>
Subject: Re: Inserting new line to a string
Message-Id: <93d79e80-1d79-4f78-8fd7-09200f7a7696@e6g2000prf.googlegroups.com>
On Mar 24, 5:58 pm, Deepan Perl XML Parser <deepan...@gmail.com>
wrote:
> I am having a string like below:
> I want to insert new line at the end of every end tag[ex:- </
> responseStatus>].
$mystring =~ s/<\//<\/\n/g;
------------------------------
Date: Mon, 24 Mar 2008 12:06:31 -0700
From: Joe Smith <joe@inwap.com>
Subject: Re: passing filename path with spaces to subs
Message-Id: <K9KdnWWG0OEnZnranZ2dnUVZ_o3inZ2d@comcast.com>
news2003@wanadoo.es wrote:
> % cat test_spaces.txt
>
> sandbox/noSpaces/63.jpg
> sandbox/with\ Spaces/63.jpg
From the command line, you would enter one of the following:
'sandbox/with Spaces/63.jpg'
"sandbox/with Spaces/63.jpg"
sandbox/with\ Spaces/63.jpg
Some form of quoting is needed to protect the embedded space such
that the command line parser won't split arguments ($IFS).
From inside a file, you would have:
sandbox/with Spaces/63.jpg
After chomp()ing that string, what is left is the exact string to be
passed to open().
Get rid of the errant backslash from the line in the file and it will work.
-Joe
------------------------------
Date: Mon, 24 Mar 2008 15:01:45 -0700 (PDT)
From: Babul <minhaztuhin@hotmail.com>
Subject: Re: Perl code to fill-in online form
Message-Id: <11f68d6a-5dfc-4d9d-8104-10118aa590b4@a70g2000hsh.googlegroups.com>
On Mar 21, 5:53=A0pm, Ben Bullock <benkasminbull...@gmail.com> wrote:
> On Sat, 22 Mar 2008 01:05:32 +0100, Joost Diepenmaat wrote:
> >Babul<minhaztu...@hotmail.com> writes:
>
> >> Hello everyone,
>
> > hi!
>
> >> I am trying to write a program in perl (windows) that I will use to
> >> fill out online form.
>
> >> 2. I fill in the Login form and submit that form. Then a page open with=
> >> a link "Choose a period". When I click on that link, a small window
> >> pops up with links for different weeks. I click on my desired week.
>
> > ok
>
> >> I tried WWW::Mechanize to get the contents of the web page.
>
> > That's usually the best module to use for this, yes. but it sounds like
> > the popup is opened via javascript and WWW::Mechanize doesn't support
> > javascript.
>
> It's possible but highly unlikely. I think you didn't read where the
> poster said that he keeps getting the source code for the login window
> when he tries to access the page he wants. The problem is lack of
> authentication. If he has the URL for the popup window, window 3, which
> he said that he does:
>
> $mech->get("web address from the 3rd step above");
>
> it doesn't matter how window 2 opens window 3. Being opened with
> JavaScript has nothing to do with it.
>
> > You either have to figure out how to get at the popup's url via
> > WWW::Mechanize (probably using some hand-written rules), and/or you'll
> > need to "mechanize" a javascript capable browser. Since you're on
> > windows, you may want to try Win32::IE::Mechanize.
>
> No, no, no, this is really bad advice. You didn't read the poster's
> question properly.- Hide quoted text -
>
> - Show quoted text -
Thanks everyone for the guidance and useful thought.
The reason I am using Perl, I already developed a program in Perl to
keep track of my time spend on any project. The program is working
fine and basically it is create a pipe delimited text file with the
following information:
Project name|Task name|Date|Amount of time spent
Now my intention is to add a button in that program so that when I
will click that button it will grab the information from the pipe
delimited file and will fill-out the online form.
------------------------------
Date: Mon, 24 Mar 2008 17:16:12 -0500
From: "J. Gleixner" <glex_no-spam@qwest-spam-no.invalid>
Subject: Re: Perl code to fill-in online form
Message-Id: <47e8282d$0$33219$815e3792@news.qwest.net>
Babul wrote:
[...]
> The reason I am using Perl, I already developed a program in Perl to
> keep track of my time spend on any project. The program is working
> fine and basically it is create a pipe delimited text file with the
> following information:
> Project name|Task name|Date|Amount of time spent
>
> Now my intention is to add a button in that program so that when I
> will click that button it will grab the information from the pipe
> delimited file and will fill-out the online form.
Thanks for sharing your intentions. If you have questions, then post
your code and ask, otherwise no one really needs to know your
intentions.
------------------------------
Date: Mon, 24 Mar 2008 16:08:20 -0700 (PDT)
From: ccc31807 <cartercc@gmail.com>
Subject: Re: Perl code to fill-in online form
Message-Id: <857d666f-28fd-448a-9c41-9f9c21e41e2a@u69g2000hse.googlegroups.com>
On Mar 21, 7:57 pm, Babul <minhaztu...@hotmail.com> wrote:
> Hello everyone,
>
> I am trying to write a program in perl (windows) that I will use to
> fill out online form.
I assume that since you can write scripts on the server that you have
access to the httpd. This is how I would do it.
1. Configure your httpd for cgi. Then, write a test script to make
sure it works. You can configure your web server a couple of different
ways, so pick the one you like.
2. On the client side, make your html form the way you normally do.
<html><body>
<form action='post' method='/myurl/cgi-bin/form.cgi'>
<input type='text' name='week' />
<input type='submit' value='OK' />
</form>
</body></html>
3. On the server side use CGI.
#!/usr/bin/perl;
use CGI;
use strict;
my $week = param('week');
print "Content-type: text/html\n\n";
print "<html><body>My week is $week</body></html>
exit();
CC
------------------------------
Date: Mon, 24 Mar 2008 17:47:43 -0700 (PDT)
From: Babul <minhaztuhin@hotmail.com>
Subject: Re: Perl code to fill-in online form
Message-Id: <f5075af4-4244-4feb-94c0-f46e4968d7fe@m36g2000hse.googlegroups.com>
On Mar 24, 3:16=A0pm, "J. Gleixner" <glex_no-s...@qwest-spam-no.invalid>
wrote:
> Babulwrote:
>
> [...]
>
> > The reason I am using Perl, I already developed a program in Perl to
> > keep track of my time spend on any project. The program is working
> > fine and basically it is create a pipe delimited text file with the
> > following information:
> > Project name|Task name|Date|Amount of time spent
>
> > Now my intention is to add a button in that program so that when I
> > will click that button it will grab the information from the pipe
> > delimited file and will fill-out the online form.
>
> Thanks for sharing your intentions. =A0If you have questions, then post
> your code and ask, otherwise no one really needs to know your
> intentions.
If you think that you are really helpful, please see my code at the
beginning of the discussion. Ben Bullock suggested me to use
greasemonkey, so I explained here why I am using Perl.
------------------------------
Date: Mon, 24 Mar 2008 13:21:10 -0700 (PDT)
From: unxl3arn3r <jsahiwal@gmail.com>
Subject: perl pack string
Message-Id: <c3ae8ee9-12a8-43b0-af49-481800358b92@u72g2000hsf.googlegroups.com>
Gurus
I seem to be unable to pack a string padded with nulls and containing
the length of the string prepended to it. This is my code snippet,
where am i going wrong ?
$message1 = pack("l! a*",1, "This is a test,This program is free
software,you can redistribute it terms as Perl network, This is why I
said to talk");
msgsnd($queue,$message1,0);
In my msgrcv i only want to recieve upto 100 characters. If i send a
string greater than 100 my script receiving the message fails.
Thanks
Perl Monger
------------------------------
Date: 24 Mar 2008 20:57:02 GMT
From: xhoster@gmail.com
Subject: Re: perl pack string
Message-Id: <20080324165704.661$gc@newsreader.com>
unxl3arn3r <jsahiwal@gmail.com> wrote:
> Gurus
> I seem to be unable to pack a string padded with nulls and containing
> the length of the string prepended to it. This is my code snippet,
> where am i going wrong ?
>
> $message1 = pack("l! a*",1, "This is a test,This program is free
> software,you can redistribute it terms as Perl network, This is why I
> said to talk");
l! packs the "1", and a* packs the message. No where in there does the
length of the message enter into it.
I see that that is copied from the perldoc -f msgsnd. I can only
assume that that documentation is hosed.
Perhaps it should be this, instead?
pack("l! l!/a*",1,"foo")
Here l! packs the message type (1), l!/ packs the length of the message,
and a* packs the message itself.
> msgsnd($queue,$message1,0);
Xho
--
-------------------- http://NewsReader.Com/ --------------------
The costs of publication of this article were defrayed in part by the
payment of page charges. This article must therefore be hereby marked
advertisement in accordance with 18 U.S.C. Section 1734 solely to indicate
this fact.
------------------------------
Date: Mon, 24 Mar 2008 22:29:28 GMT
From: "John W. Krahn" <someone@example.com>
Subject: Re: perl pack string
Message-Id: <cXVFj.122864$C61.76309@edtnps89>
unxl3arn3r wrote:
> Gurus
> I seem to be unable to pack a string padded with nulls and containing
> the length of the string prepended to it. This is my code snippet,
> where am i going wrong ?
>
> $message1 = pack("l! a*",1, "This is a test,This program is free
> software,you can redistribute it terms as Perl network, This is why I
> said to talk");
> msgsnd($queue,$message1,0);
>
> In my msgrcv i only want to recieve upto 100 characters. If i send a
> string greater than 100 my script receiving the message fails.
$ perl -le'
use Data::Dumper;
$Data::Dumper::Useqq = 1;
my $x = pack q[l!/Z*], "This is a test,This program is free software,you
can redistribute it terms as Perl network, This is why I said to talk";
print Dumper $x;
'
$VAR1 = "w\0\0\0This is a test,This program is free software,you can
redistribute it terms as Perl network, This is why I said to talk\0";
And then to unpack:
$ perl -le'
use Data::Dumper;
$Data::Dumper::Useqq = 1;
my $x = unpack q[l!/Z*], "w\0\0\0This is a test,This program is free
software,you can redistribute it terms as Perl network, This is why I
said to talk\0";
print Dumper $x;
'
$VAR1 = "This is a test,This program is free software,you can
redistribute it terms as Perl network, This is why I said to talk";
If you want to limit the size of the string to 100 characters:
perldoc -f substr
John
--
Perl isn't a toolbox, but a small machine shop where you
can special-order certain sorts of tools at low cost and
in short order. -- Larry Wall
------------------------------
Date: Mon, 24 Mar 2008 19:23:14 -0700 (PDT)
From: unxl3arn3r <jsahiwal@gmail.com>
Subject: Re: perl pack string
Message-Id: <a7056bb2-2edd-42cd-a4d3-bc34257e61f0@d21g2000prf.googlegroups.com>
On Mar 24, 4:57 pm, xhos...@gmail.com wrote:
> unxl3arn3r <jsahi...@gmail.com> wrote:
> > Gurus
> > I seem to be unable to pack a string padded with nulls and containing
> > the length of the string prepended to it. This is my code snippet,
> > where am i going wrong ?
>
> > $message1 = pack("l! a*",1, "This is a test,This program is free
> > software,you can redistribute it terms as Perl network, This is why I
> > said to talk");
>
> l! packs the "1", and a* packs the message. No where in there does the
> length of the message enter into it.
>
> I see that that is copied from the perldoc -f msgsnd. I can only
> assume that that documentation is hosed.
>
> Perhaps it should be this, instead?
>
> pack("l! l!/a*",1,"foo")
>
> Here l! packs the message type (1), l!/ packs the length of the message,
> and a* packs the message itself.
>
> > msgsnd($queue,$message1,0);
>
> Xho
>
> --
> --------------------http://NewsReader.Com/--------------------
> The costs of publication of this article were defrayed in part by the
> payment of page charges. This article must therefore be hereby marked
> advertisement in accordance with 18 U.S.C. Section 1734 solely to indicate
> this fact.
why do I need to have the second variable in pack ? All I need to do
is pack my outgoing string and prepad its length in front of it. Since
I am doing a* doesn't it already mean its a string of characters, then
why do i need to define the $type = 1 ?
------------------------------
Date: Mon, 24 Mar 2008 06:45:52 -0700 (PDT)
From: ccc31807 <cartercc@gmail.com>
Subject: Re: Redirecting to my own login page instead of Apache Login
Message-Id: <b800a249-f307-4d00-93f6-5efc4cb2a540@m36g2000hse.googlegroups.com>
On Mar 24, 12:22 am, nahan...@gmail.com wrote:
> Now I want to prevent the Apache web server User authentication page
> to display and use my login page instead.
Replace the standard Apache index.html file in the document root with
your own index.html. In RedHat Linux you will find this in /var/www/
html/. I would tell you where it is in Windows but unfortunately I do
not currently have access to a Windows machine.
If you are using virtual hosts, create a symbolic link to your
homepage. For example, create your web directory like this:
/home/myhomedir/www/index.html
and create a symlink like this in the http document root (again, this
is Unix/Linx):
ln -s /home/myhomedir/www myhomedir
Alternatively, edit your httpd.conf file. See the documentation.
CC
------------------------------
Date: Mon, 24 Mar 2008 19:44:40 -0700 (PDT)
From: "falconzyx@gmail.com" <falconzyx@gmail.com>
Subject: The huge amount response data problem
Message-Id: <75d183c2-08cf-4b8b-848c-1b17633e964a@d21g2000prf.googlegroups.com>
I have a issue:
1. I want to open a file and use the data from the file to construct
the url.
2. After I constructed the url and sent it, I got the response html
data and some parts are what I want store inot the files.
It seems like a very easy thing, however, the issue is that the data
from the file that I have to open are too huge, which I have to
consturct almost 200000 url address to send and parse response data.
And the speed is very very slow.
I have no idea with thread or db cache, so I want some help .
Please give me some advices that what I should do to improve the speed
Thanks very much.
------------------------------
Date: Mon, 24 Mar 2008 18:34:07 -0700 (PDT)
From: bigmattstud@gmail.com
Subject: use base and @ISA with package re-definition
Message-Id: <a559443b-a27d-46c8-af36-06a0c4e1a6b8@s37g2000prg.googlegroups.com>
I'm trying to load multiple classes with the same name from different
directories in order to implement a pluggable deployment system. I
have managed to get the classes to be redefined by playing with the
global symbol table, and it seems to be behaving the way I want except
for the definition of @ISA. Here's some sample code:
Here's the driving script:
# Create a class and instantiate it from the first directory
print "Constructing MyMod from D:/Data/Perl/Module1\n" ;
push @INC,'D:/Data/Perl/Module1' ;
require MyMod ;
print "MyMod is a ",join(',',@MyMod::ISA),"\n" ;
$build = MyMod->new() ;
print "\n" ;
# Clean out the previous definition of MyMod by deleting the entries
from the INC hash and the global symbol
# table
delete $INC{"MyMod.pm"} ;
delete $main::{'MyMod::'} ;
pop @INC ;
# Create a class and instantiate it from the second directory
print "Constructing MyMod from D:/Data/Perl/Module2\n" ;
push @INC,"D:/Data/Perl/Module2" ;
require MyMod ;
print "MyMod is a ",join(',',@MyMod::ISA),"\n" ;
$build = MyMod->new() ;
Here's the definition of MyMod from the D:/Data/Perl/Module1 directory
package MyMod;
use strict;
use base qw(BaseBuild1) ;
sub new {
my $class = shift ;
my $self = $class->SUPER::new();
return $self;
}
1;
and the base class for this is:
package BaseBuild1;
use strict;
sub new {
print "Inside BaseBuild1 constructor\n" ;
my $class = shift;
my $self = bless {}, $class;
return $self;
}
1;
Here's the definition of MyMod from the D:/Data/Perl/Module2 directory
package MyMod;
use strict;
use base qw(BaseBuild2) ;
sub new {
my $class = shift ;
my $self = $class->SUPER::new();
return $self;
}
1;
and here's the base class
package BaseBuild2;
use strict;
sub new {
print "Inside BaseBuild2 constructor\n" ;
my $class = shift;
my $self = bless {}, $class;
return $self;
}
1;
This is the output:
Constructing MyMod from D:/Data/Perl/Module1
MyMod is a BaseBuild1
Inside BaseBuild1 constructor
Constructing MyMod from D:/Data/Perl/Module2
MyMod is a BaseBuild1
Inside BaseBuild2 constructor
So the behaviour seems correct (in that it's doing what I want), but
Perl seems to be stubbornly holding onto the definition of MyMod as a
BaseBuild1 (even though the call to SUPER::new goes to the correct
constructor). So my questions are:
* Does this matter at all ?
* Is there any way to fix it ?
* Is there a better way to do what I want to do ?
------------------------------
Date: Tue, 25 Mar 2008 03:57:04 GMT
From: Uri Guttman <uri@stemsystems.com>
Subject: Re: use base and @ISA with package re-definition
Message-Id: <x7iqzbtq0f.fsf@mail.sysarch.com>
>>>>> "b" == bigmattstud <bigmattstud@gmail.com> writes:
b> I'm trying to load multiple classes with the same name from different
b> directories in order to implement a pluggable deployment system. I
b> have managed to get the classes to be redefined by playing with the
b> global symbol table, and it seems to be behaving the way I want except
b> for the definition of @ISA. Here's some sample code:
you seem to be going about this in a very bizarre and tricky way. it is
much easier to dynamically load modules with different names (maybe
under the same higher level namespace) and use OO polymorphism to call
into them as needed. no muss no fuss!
b> Here's the driving script:
b> # Create a class and instantiate it from the first directory
b> print "Constructing MyMod from D:/Data/Perl/Module1\n" ;
b> push @INC,'D:/Data/Perl/Module1' ;
b> require MyMod ;
b> print "MyMod is a ",join(',',@MyMod::ISA),"\n" ;
b> $build = MyMod->new() ;
b> print "\n" ;
what decides which of these modules (or more than one?) to load?
b> # Clean out the previous definition of MyMod by deleting the entries
b> from the INC hash and the global symbol
b> # table
b> delete $INC{"MyMod.pm"} ;
b> delete $main::{'MyMod::'} ;
b> pop @INC ;
ewww.
b> So the behaviour seems correct (in that it's doing what I want), but
b> Perl seems to be stubbornly holding onto the definition of MyMod as a
b> BaseBuild1 (even though the call to SUPER::new goes to the correct
b> constructor). So my questions are:
b> * Does this matter at all ?
b> * Is there any way to fix it ?
b> * Is there a better way to do what I want to do ?
yes. drop all your conceptions about how to do this (call delete on this
idea in your brain! :).
it is MUCH easier than you realize to do it with method calls. this is a
bit of pseudo code but it should be very easy to make it real.
in Foo/Module1.pm:
package Foo::Module1 ;
use base Foo ;
sub new {
#construct away
}
in Foo/Module2.pm:
package Foo::Module2 ;
use base Foo ;
sub new {
#construct away
}
now you have two sibling modules ready to be loaded. you just decide to
load one (or both) and instantiate them via their different names:
my $variation = 'Module1' ; # this can be set from anywhere
my $class = "Foo::$variation" ;
# this is a rare use of string eval that is very useful
eval "require $class" or die "can't load $class $@" ;
my $foo_type = $class->new( @args ) ;
# and now we want an object of the other variation. just do the same
# code and set $variation to Module2. or make that code into a sub and
# you can construct variant objects on the fly:
sub make_foo_obj {
my( $variantion, @args ) = @_ ;
my $class = "Foo::$variation" ;
# this is a rare use of string eval that is very useful
eval "require $class" or die "can't load $class $@" ;
return $class->new( @args ) ;
}
see, simple and effective. this works because perl does late binding and
can use a dynamically made class name to both load modules and to call
their constructors. this is the best and easiest way to support variant
modules. your way will lead to insanity (or has led you there already! :)
uri
--
Uri Guttman ------ uri@stemsystems.com -------- http://www.sysarch.com --
----- Perl Code Review , Architecture, Development, Training, Support ------
--------- Free Perl Training --- http://perlhunter.com/college.html ---------
--------- Gourmet Hot Cocoa Mix ---- http://bestfriendscocoa.com ---------
------------------------------
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 1388
***************************************