[23782] in Perl-Users-Digest
Perl-Users Digest, Issue: 5986 Volume: 10
daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Sun Dec 28 18:05:33 2003
Date: Sun, 28 Dec 2003 15:05:06 -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 Sun, 28 Dec 2003 Volume: 10 Number: 5986
Today's topics:
Re: A Challenge... <bik.mido@tiscalinet.it>
Building Perl for Win32 as a static library <tmohr@s.netic.de>
Re: Determine if a process was spawed by screen <usenet@morrow.me.uk>
looking for help with a counting algorithm <news3@earthsong.null.free-online.co.uk>
Re: newbie: multi-screen CGI script <uri@stemsystems.com>
Re: newbie: multi-screen CGI script <groups@donstefani.com>
Re: newbie: multi-screen CGI script <uri@stemsystems.com>
Re: newbie: multi-screen CGI script <groups@donstefani.com>
Re: newbie: multi-screen CGI script <uri@stemsystems.com>
Re: newbie: multi-screen CGI script <groups@donstefani.com>
Re: problems associated with CPAN module installation (lin ying)
Re: problems associated with CPAN module installation <noreply@gunnar.cc>
Quick Regex Subst question <marv@mister.com>
Re: Quick Regex Subst question <usenet@morrow.me.uk>
Re: Quick Regex Subst question <eric-amick@comcast.net>
retrieve webpage with POST <dean.banko@globalnet.hr>
Re: retrieve webpage with POST <noreply@gunnar.cc>
Digest Administrivia (Last modified: 6 Apr 01) (Perl-Users-Digest Admin)
----------------------------------------------------------------------
Date: Mon, 29 Dec 2003 20:34:31 +0100
From: Michele Dondi <bik.mido@tiscalinet.it>
Subject: Re: A Challenge...
Message-Id: <k3v0vvsvecqovpkor6r7cgog99b1lmqpt8@4ax.com>
On Mon, 29 Dec 2003 12:45:02 +0100, Michele Dondi
<bik.mido@tiscalinet.it> wrote:
> -l print$"x-$_,$x=-$_.$x.($x&&-$_)for-9..0
>
>and would score 44 and 42 strokes respectively. Notwithstanding my
>(limited!) experience with Perlgolf gurus popping out with solutions
>you wouldn't have ever imagined about, I doubt that one can do
>anything better than the last one...
OTOH soon after writing these words of wisdom I read that
On Sat, 27 Dec 2003 20:07:24 -0000, "Ragnar Hafstaš" <gnari@simnet.is>
wrote:
>one more character:
>perl -le'print$"x-$_,$x=$x?-$_.$x.-$_:9for-9..0'
i.e.
-l print$"x-$_,$x=$x?-$_.$x.-$_:9for-9..0
41 strokes.D'Oh!
Michele
--
# This prints: Just another Perl hacker,
seek DATA,15,0 and print q... <DATA>;
__END__
------------------------------
Date: Sun, 28 Dec 2003 22:29:54 +0100
From: Torsten Mohr <tmohr@s.netic.de>
Subject: Building Perl for Win32 as a static library
Message-Id: <bsni0i$4ni$1@schleim.qwe.de>
Hi,
i compiled and installed Perl for Win32 successfully, but i'd like
to build own programs with perl as an internal script language
and i don't want to ship a DLL with that program.
Therefor i'd like to build perl as a static library.
Has anybody got a hint on how to build perl as a static library
on Windows 2000?
Thanks for any hints,
Torsten.
------------------------------
Date: Sun, 28 Dec 2003 19:39:57 +0000 (UTC)
From: Ben Morrow <usenet@morrow.me.uk>
Subject: Re: Determine if a process was spawed by screen
Message-Id: <bsnbid$i45$1@wisteria.csv.warwick.ac.uk>
"Travis Spencer" <travislspencer@hotmail.com> wrote:
> I guess I should have mentioned that my solution needs to
> run on Solaris 8+
> and Redhat 9.
Try using Proc::ProcessTable form CPAN.
Ben
--
If you put all the prophets, | You'd have so much more reason
Mystics and saints | Than ever was born
In one room together, | Out of all of the conflicts of time.
ben@morrow.me.uk |----------------+---------------| The Levellers, 'Believers'
------------------------------
Date: Sun, 28 Dec 2003 22:32:11 +0000
From: Andy Baxter <news3@earthsong.null.free-online.co.uk>
Subject: looking for help with a counting algorithm
Message-Id: <pan.2003.12.28.22.32.08.635583@earthsong.null.free-online.co.uk>
I'm working on a web-based database project written in perl, which is a
virtual library for people in the town where I live to share details of
books and videos they have - the idea is if you find a book you like you
click on 'borrow', and you are given details of how to contact the person
who owns it.
I'm not sure exactly where to ask for this, as I'm looking for help with
finding a good algorithm, rather than details of coding, but I've chosen
this group as it's written in perl, and more of a coding problem than a
cgi problem.
I have decided on a categorisation system for the items, where each item
can belong to many categories, and each category can also be grouped as a
subcategory under one or more higher level categories. Everything is
stored in a mysql database, and the links between books and categories,
and between categories and higher level categories are done through two
linking tables, which have entries like:
CategoryMembership
------------------
CatID ItemId
1 1
2 1
1 2
1 3
3 3
1 4
4 4
7 5
CategoryGrouping
----------------
CatID SubCatId SortOrder Stop
1 2 1
1 3 2
1 4 3
3 4 1 1 (yes.)
4 5 1
4 6 2
4 7 3
I.e. item 1 is in cats 1 & 2, item 2 is in cat 1, item 3 is in cat 3, and
item 4 is in cats 1 & 4. Categories 2 and 3 are in Cat 1, and Category 4
is in cat 3 and cat 1 etc.
I want any set of category memberships or groupings of categories that can
be represented like this without leading to loops to be allowed. (I.e. the
only thing that isn't allowed is things like category 1 is grouped under
cat 2 which is grouped under cat 3 which is grouped under cat 1, and more
complex variations on this.)
I have written some code which reads these tables and generates a
tree-like data structure, where each category is represented by a hash
like this:
{Name=>"category name",
Id=>"Id on database",
DownList=>ref of array with list of links to subcategories,
UpList=>ref of array with list of links to higher categories
}
The links between categories are hashes like this:
{Up=>ref to category hash,
Down=>ref to (sub) category hash,
Stop=>stop listing subcategories at this point?,
Sort=>sort order when displaying this subcategory}
This structure is then used by the scripts which render the pages
displaying the categories. This bit is working fine.
The bit I'm finding difficult is how to count how many items there are
under a given category, so that a count can be shown in the category index
page.
The code I have at the moment is here: (This code is in a module called
LibMod.pm)
sub CountCatItems($$) {
# Count how many items there are under this category, either directly or indirectly.
my ($mod,$pCat, # pointer to the category hash.
$pStack # pointer to stack which
)= @_;
my ($query, # query handle.
$catId, # category Id no.
$pLink # ref to link between cats.
);
$catId=${$pCat}{Id};
DPrint "counting ${$pCat}{Name} - $catId = ";
$query=$db->prepare("select count(ItemId) from CategoryMembership where " .
"CategoryId=$catId group By CategoryId");
$query->execute;
my ($dCount) = $query->fetchrow_array();
$query->finish;
${$pCat}{CountDirect}=$dCount;
DPrint "$dCount<br>"; # debug print.
foreach $pLink ( @{${$pCat}{DownList}} ) {
LibMod->CountCatItems(${$pLink}{Down}); # call self recursively
};
};
This works, but only counts the number of items directly included in a
category, not the ones which belong to a subcategory.
The thing that makes it hard is the multiple category membership plus
multiple category grouping, but I want to keep this if I possibly can,
because one of the problems with traditional non-computerised indexes is
that you can't do this even though books can be relevant to several
different topics.
My thoughts at the moment are either:
- give each category a hash where the keys are all the items included in
the category. Read these in from the database, then each time a
subcategory is counted, the code goes back up the tree to the root, adding
the items that belong to it to all the higher level categories. When the
recursive calls to subcategories return, (i.e. end of this code fragment),
then count the keys in the hash. This would work I think, but it would
involve retrieving all the category memberships from the database, rather
than just the counts, and it might cause speed and memory problems if a
lot of items were added to the system.
- or when you put an item in a category, category memberships are
automatically created in the database for all the higher level categories.
This would be quicker to count, but I'm thinking that if someone has
chosen to put an item in a given subcategory, and then later on I decide
to move that subcategory to a different group, the category memberships
should shift to follow this, whereas with this system the item would stay
in the old top-level categories.
Finally - my questions are:
- does anyone know of an algorithm for working out the counts just from
the counts in each category - i.e. without having to get details of
exactly which items belong to each category? (I have a feeling this may be
impossible)
- or generally, and maybe more useful in the long run, a good place to
start looking on the web for answers to problems like this when they crop
up.
- also if you have any thoughts on either of the solutions I've
described, or can think of a better way of doing it, I'd appreciate it.
andy.
--
http://www.niftybits.ukfsn.org/
remove 'n-u-l-l' to email me. html mail or attachments will go in the spam
bin unless notified with [html] or [attachment] in the subject line.
------------------------------
Date: Sun, 28 Dec 2003 19:07:19 GMT
From: Uri Guttman <uri@stemsystems.com>
Subject: Re: newbie: multi-screen CGI script
Message-Id: <x73cb469so.fsf@mail.sysarch.com>
>>>>> "DS" == Don Stefani <groups@donstefani.com> writes:
> I'm trying to do this:
it is called a dispatch table.
> <code>
> %States = (
> 'Default' => \&front_page,
> 'Shirt' => \&shirt,
> 'Sweater' => \&sweater,
> 'Checkout' => \&checkout,
> 'Card' => \&credit_card,
> 'Order' => \&order,
> 'Cancel' => \&front_page,
> );
> if ($States{$page}) {
> $States{$page}->(); # call the correct subroutine
> } else {
> no_such_page();
> }
i prefer to save a hash lookup like this:
if (my $page_sub = $States{$page}) {
$page_sub->(); # call the correct subroutine
}
else {
no_such_page();
}
and don't cuddle elses! (read perlstyle :).
> But I can get the following to work. just fine, but 'The Cookbook'
> calls my method, "tedious and clumsy". I'm trying to work away from
> that! ;-)
> #!/usr/bin/perl -w
> use strict;
> use CGI;
good start
> use Lib::AccountMgrGeneral;
> use Lib::MysqlModule;
> use Lib::WebForms;
> my $q = new CGI;
> my $amg = new AccountMgrGeneral;
> my $mysql = new MysqlModule;
> my $wf = new WebForms;
my $obj = Class->new() ;
direct object calls are safer. i think the issue is covered in perlobj.
> my $view = $q->param('view') || 'srch';
> # HTML top-------------------------
> print "Content-type:text/html\n\n";
> print $amg->header();
> if ($view eq 'nsi')
> {
> print $wf->NameServerInput();
> }
> else
> {
> print $wf->SearchForm();
> }
you showed us the dispatch table and here is the working if/else
code. but you haven't stated what happens with your broken code. also
you haven't posted the entire broken script. if you just dropped the
dispatch code into this, it should work but we can't see why it doesn't
from this. note: make sure the dispatch hash is lexical (my) and is
declared and assigned before it is used and outside any sub that uses
it. it is static so doing it inside a sub would be slower (maybe not in
the simple cgi case, but i have seen code where it was in a sub that is
called repeatedly and that is not good).
so put in your dispatch table (2 entries is fine) and tell us what
happens when you run it. also the dispatch table didn't have the same
vars as your code so they have to match. $page needs to become
$view. the cookbook is not written to have its code used literally, you
have to edit names and such to fit your needs.
uri
--
Uri Guttman ------ uri@stemsystems.com -------- http://www.stemsystems.com
--Perl Consulting, Stem Development, Systems Architecture, Design and Coding-
Search or Offer Perl Jobs ---------------------------- http://jobs.perl.org
------------------------------
Date: Sun, 28 Dec 2003 20:31:08 GMT
From: Don Stefani <groups@donstefani.com>
Subject: Re: newbie: multi-screen CGI script
Message-Id: <g4HHb.2822$5I2.477@newssvr27.news.prodigy.com>
Uri Guttman wrote:
the cookbook is not written to have its code used literally, you
> have to edit names and such to fit your needs.
New, yes, but not that new! :)
>my $obj = Class->new() ;
>direct object calls are safer. i think the issue is covered in perlobj.
Thanks, I'll be looking into that directly.
OK, here's the code with the dispatch table followed by the errors.
<code>
#!/usr/bin/perl -w
use strict;
use CGI;
use Lib::AccountMgrGeneral;
use Lib::MysqlModule;
use Lib::WebForms;
my $q = new CGI;
my $amg = new AccountMgrGeneral;
my $mysql = new MysqlModule;
my $wf = new WebForms;
my $view = $q->param('view') || 'srch';
# HTML top-------------------------
print "Content-type:text/html\n\n";
print $amg->header();
### the subroutines in the table are in WebForms.pm
my %states = {
'srch' => \&SearchForm,
'nsi' => \&NameServerInput
};
if (my $page_sub = $states{$view})
{
$page_sub->(); # call the correct subroutine
}
else
{
print "no such page\n";
}
# HTML Bottom------------
print $amg->footer();
</code>
<errors>
command line:
(NOTE: HTML output good until the good stuff is supposed to happen, then
die.)
>perl test2.cgi
Reference found where even-sized list expected at test2.cgi line 18, <>
line 1.
no such page
Browser:
At default page ($views = 'srch')
I get my "no such page" msg.
when I send a param, $views = 'nsi', I get a 500 error.
</errors>
Thanks for your help, I just got a request for this small app and I'm in
the first stages of switching from PHP to Perl. I'm trying to resist the
urge to just do it in PHP. I'm hoping to learn from this project,
although I feel a bit presumptuous. I hope I'm not "asking you to do my
homework" if you know what I mean. My gut tells me the problem is that
the way the table or the $page_sub test is written, it's looking for the
subroutine in the main script. (?)
Thanks,
Don
------------------------------
Date: Sun, 28 Dec 2003 20:58:03 GMT
From: Uri Guttman <uri@stemsystems.com>
Subject: Re: newbie: multi-screen CGI script
Message-Id: <x7isk04q3o.fsf@mail.sysarch.com>
>>>>> "DS" == Don Stefani <groups@donstefani.com> writes:
> Uri Guttman wrote:
> the cookbook is not written to have its code used literally, you
>> have to edit names and such to fit your needs.
> New, yes, but not that new! :)
well, we have to make sure! :)
> ### the subroutines in the table are in WebForms.pm
> my %states = {
> 'srch' => \&SearchForm,
> 'nsi' => \&NameServerInput
> };
>> perl test2.cgi
> Reference found where even-sized list expected at test2.cgi line 18,
> <> line 1.
look carefully at the code in the cookbook and your hash
assignment. there is a distinct (but subtle difference). i will let you
do this first before i (or someone else) gives you the answer. it is a
good excercise to compare code with a microscope (char by char). and you
will learn a valuable lesson about hashes and how to initialize them.
> no such page
> Browser:
> At default page ($views = 'srch')
> I get my "no such page" msg.
> when I send a param, $views = 'nsi', I get a 500 error.
> </errors>
fix the first problem and maybe these will go away. many times early
problems cause phony later ones that will magically go away when you fix
the former.
> Thanks for your help, I just got a request for this small app and I'm
> in the first stages of switching from PHP to Perl. I'm trying to
> resist the urge to just do it in PHP. I'm hoping to learn from this
> project, although I feel a bit presumptuous. I hope I'm not "asking
> you to do my homework" if you know what I mean. My gut tells me the
> problem is that the way the table or the $page_sub test is written,
> it's looking for the subroutine in the main script. (?)
it is in your dispatch table for sure.
and i gave you homework and didn't do yours! :)
uri
--
Uri Guttman ------ uri@stemsystems.com -------- http://www.stemsystems.com
--Perl Consulting, Stem Development, Systems Architecture, Design and Coding-
Search or Offer Perl Jobs ---------------------------- http://jobs.perl.org
------------------------------
Date: Sun, 28 Dec 2003 21:27:34 GMT
From: Don Stefani <groups@donstefani.com>
Subject: Re: newbie: multi-screen CGI script
Message-Id: <aVHHb.3241$dQ4.2607@newssvr29.news.prodigy.com>
Uri Guttman wrote:
>look carefully at the code in the cookbook
() not {} duh! That actully crossed my mind (quickly I guess)
But here's the new error on the command line: (dieing at the sub in
question.
<error>
Undefined subroutine &main::SearchForm called at test2.cgi line 25, <>
line 1.
</error>
I made a comment in the code, that the subs are in WebForms.pm,
I need to get at them either in the table or the test?
Thanks,
Don
<code>
#!/usr/bin/perl -w
use strict;
use CGI;
use Lib::AccountMgrGeneral;
use Lib::MysqlModule;
use Lib::WebForms;
my $q = new CGI;
my $amg = new AccountMgrGeneral;
my $mysql = new MysqlModule;
my $wf = new WebForms;
my $view = $q->param('view') || 'srch';
# HTML top-------------------------
print "Content-type:text/html\n\n";
print $amg->header();
# the subroutines in the table are in WebForms.pm
my %states = (
'srch' => \&SearchForm,
'nsi' => \&NameServerInput
);
if (my $page_sub = $states{$view})
{
$page_sub->(); # call the correct subroutine
}
else
{
print "no such page\n";
}
# HTML Bottom------------
print $amg->footer();
------------------------------
Date: Sun, 28 Dec 2003 21:37:20 GMT
From: Uri Guttman <uri@stemsystems.com>
Subject: Re: newbie: multi-screen CGI script
Message-Id: <x7wu8g39ps.fsf@mail.sysarch.com>
>>>>> "DS" == Don Stefani <groups@donstefani.com> writes:
> Uri Guttman wrote:
>> look carefully at the code in the cookbook
> () not {} duh! That actully crossed my mind (quickly I guess)
good, you found it. did you learn the lesson? :)
> But here's the new error on the command line: (dieing at the sub in
> question.
> <error>
> Undefined subroutine &main::SearchForm called at test2.cgi line 25, <>
> line 1.
> </error>
> I made a comment in the code, that the subs are in WebForms.pm,
> I need to get at them either in the table or the test?
you need to export them into main:: or fully qualify them in the
dispatch table. i assume the module has its own package so those subs
won't be seen by the code refs in the dispatch table as they are not in
main::
the simplest solution is to fully qualify them.
> # the subroutines in the table are in WebForms.pm
> my %states = (
> 'srch' => \&SearchForm,
> 'nsi' => \&NameServerInput
> );
'nsi' => \&WebForms::NameServerInput
uri
PS. have you gotten my emails? you sent me one and i haven't heard back
since i replied.
--
Uri Guttman ------ uri@stemsystems.com -------- http://www.stemsystems.com
--Perl Consulting, Stem Development, Systems Architecture, Design and Coding-
Search or Offer Perl Jobs ---------------------------- http://jobs.perl.org
------------------------------
Date: Sun, 28 Dec 2003 22:08:38 GMT
From: Don Stefani <groups@donstefani.com>
Subject: Re: newbie: multi-screen CGI script
Message-Id: <GvIHb.3246$Ei5.3244@newssvr29.news.prodigy.com>
Uri Guttman wrote:
> PS. have you gotten my emails? you sent me one and i haven't heard back
> since i replied.
Emails sent.
That got rid of the command line error, but I get nothing as output in
the browser. Not even my default subroutine. I'm ready to be "tedious
and clumsy" for now in the name of progress! Break-time for bonzo.
I'll get back at this later.
Thanks,
Don
------------------------------
Date: 28 Dec 2003 11:19:34 -0800
From: sir_linying@hotmail.com (lin ying)
Subject: Re: problems associated with CPAN module installation
Message-Id: <1f7463ce.0312281119.639cc872@posting.google.com>
Gunnar Hjalmarsson <noreply@gunnar.cc> wrote in message news:<bsmi22$ecuhd$1@ID-184292.news.uni-berlin.de>...
> Chris Mattern wrote:
> > lin ying wrote:
> >> How can I once for all download all required modules in their
> >> correct calling hierarchy?
> >>
> > CPAN will download and install all the required dependencies if you
> > let it.
>
> I.e. CPAN.pm will. Check out the documentation for that module.
Thanks for this information. Because I don't have root permission to
install modules to perl path, I can't use CPAN to install the required
dependencies for me.
Any other way to bypass this permission restriction? Thanks!
Ying
------------------------------
Date: Sun, 28 Dec 2003 23:18:30 +0100
From: Gunnar Hjalmarsson <noreply@gunnar.cc>
Subject: Re: problems associated with CPAN module installation
Message-Id: <bsnl7j$e84op$1@ID-184292.news.uni-berlin.de>
lin ying wrote:
> Gunnar Hjalmarsson wrote:
>> Chris Mattern wrote:
>>> lin ying wrote:
>>>> How can I once for all download all required modules in their
>>>> correct calling hierarchy?
>>>
>>> CPAN will download and install all the required dependencies if
>>> you let it.
>>
>> I.e. CPAN.pm will. Check out the documentation for that module.
>
> Thanks for this information. Because I don't have root permission
> to install modules to perl path, I can't use CPAN to install the
> required dependencies for me.
What made you reach that conclusion? Did you study the POD for
CPAN.pm? Did you follow the advice in item 5) in the POD FAQ? Did you
fail when doing so?
--
Gunnar Hjalmarsson
Email: http://www.gunnar.cc/cgi-bin/contact.pl
------------------------------
Date: Sun, 28 Dec 2003 19:16:53 GMT
From: Marv <marv@mister.com>
Subject: Quick Regex Subst question
Message-Id: <3iauuv8qo634e0i3dpirdpjma9f39j294i@4ax.com>
Hello,
I'm new to regex and hoping someone can give me a quick answer to this
question as I can't seem to find it anywhere.
I'm trying to parse a line and subsitute any one charactor followed by
a $ and surrounded by a front slash on both sides with the same
charactor followed by a space and "(Drive)". This also must occur at
the beginning of the line. So basically substitute "$" for "(Drive)".
Ex.
/C$/path/path/
ends up as:
/C (Drive)/path/path
I've got the following so far:
$test = '/C$/path/path/';
$test =~ s/^\/.\$/\/.\(Drive\)/;
But when I do: printf "$test\n";
I get:
/.(Drive)/account/test/
I know the dot is wrong, but how do I carry the "C" over in the
substituion.
Thanks in advance.
Marv
------------------------------
Date: Sun, 28 Dec 2003 19:52:31 +0000 (UTC)
From: Ben Morrow <usenet@morrow.me.uk>
Subject: Re: Quick Regex Subst question
Message-Id: <bsnc9v$ip2$1@wisteria.csv.warwick.ac.uk>
Marv <marv@mister.com> wrote:
> Hello,
>
> ends up as:
>
> /C (Drive)/path/path
>
> I've got the following so far:
>
> $test = '/C$/path/path/';
>
> $test =~ s/^\/.\$/\/.\(Drive\)/;
Bleech! Use some other delimiter to avoid all those backwhacks. Use /x
to clean things up a bit. The second half of an s/// is not a regex,
just a double-quotey string, so () don't need escaping.
$test =~ s|^/ (.) \$ /|/$1 (Drive)/|x;
See perldoc perlretut "Extracting matches" for how the () abd the $1
join up.
I would be tempted to use look{ahead,behind} here, just because it
feels cleaner; viz.:
$test =~ s|(?<= ^/) (.) \$ (?= /)|$1 (Drive)|x;
but it's probably too complex to be worth bothering with here.
> But when I do: printf "$test\n";
Don't use printf when you men print. I don't think I have ever used
printf in perl... even when it would be useful, I instinctively use
'print sprintf ...' instead :).
Ben
--
$.=1;*g=sub{print@_};sub r($$\$){my($w,$x,$y)=@_;for(keys%$x){/main/&&next;*p=$
$x{$_};/(\w)::$/&&(r($w.$1,$x.$_,$y),next);$y eq\$p&&&g("$w$_")}};sub t{for(@_)
{$f&&($_||&g(" "));$f=1;r"","::",$_;$_&&&g(chr(0012))}};t # ben@morrow.me.uk
$J::u::s::t, $a::n::o::t::h::e::r, $P::e::r::l, $h::a::c::k::e::r, $.
------------------------------
Date: Sun, 28 Dec 2003 16:40:16 -0500
From: Eric Amick <eric-amick@comcast.net>
Subject: Re: Quick Regex Subst question
Message-Id: <lqiuuvccgun21pjn8lbum06k7co85ah7m4@4ax.com>
On Sun, 28 Dec 2003 19:16:53 GMT, Marv <marv@mister.com> wrote:
>I'm trying to parse a line and subsitute any one charactor followed by
>a $ and surrounded by a front slash on both sides with the same
>charactor followed by a space and "(Drive)". This also must occur at
>the beginning of the line. So basically substitute "$" for "(Drive)".
>
>Ex.
>
>/C$/path/path/
>
>ends up as:
>
>/C (Drive)/path/path
>
>I've got the following so far:
>
>$test = '/C$/path/path/';
>
>$test =~ s/^\/.\$/\/.\(Drive\)/;
If you surround a portion of a regex with parentheses, you can refer to
the text it matches with $1 later.
$test =~ s!^/(.)\$/!/$1 (Drive)/!;
Note that you can use just about any character to surround the regex and
substitution string, which makes working with slashes a lot less
painful.
See perldoc perlretut, particularly the section called "Extracting
Matches".
--
Eric Amick
Columbia, MD
------------------------------
Date: Sun, 28 Dec 2003 21:20:46 +0100
From: "Dean Banko" <dean.banko@globalnet.hr>
Subject: retrieve webpage with POST
Message-Id: <bsndv0$kh1$1@ls219.htnet.hr>
Hello!
Does anyone know how to retreive a page generated as form request?
I need to post some data like in the row:
my $req=HTTP::Request->new(POST=>$url);
but there are also some parameters that I must put into POST, but I don't
know the syntax :-(
I know that must be something like:
my $req=HTTP::Request->new(POST=>$url, [field=>'1', valid=>'yes');
$url=http://www.somelink.com"
my $ua=LWP::UserAgent->new();
my $req=HTTP::Request->new(POST=>$url);
my $response=$ua->request($req);
if ($response->is_error()){$response->error_as_HTML()}
$content=$response->content();
Can anyone help me?
Regards,
Dean
------------------------------
Date: Sun, 28 Dec 2003 23:55:10 +0100
From: Gunnar Hjalmarsson <noreply@gunnar.cc>
Subject: Re: retrieve webpage with POST
Message-Id: <bsnnce$ekeav$1@ID-184292.news.uni-berlin.de>
Dean Banko wrote:
> Does anyone know how to retreive a page generated as form request?
> I need to post some data like in the row:
> my $req=HTTP::Request->new(POST=>$url);
> but there are also some parameters that I must put into POST, but I
> don't know the syntax :-(
> I know that must be something like:
> my $req=HTTP::Request->new(POST=>$url, [field=>'1', valid=>'yes');
Assuming you are talking about two fields named 'field' and 'valid',
and whose values you want to be '1' respective 'yes', I'd try:
my $req=HTTP::Request->new(POST=>$url);
$req->content_type('application/x-www-form-urlencoded');
$req->content('field=1&valid=yes');
(untested)
--
Gunnar Hjalmarsson
Email: http://www.gunnar.cc/cgi-bin/contact.pl
------------------------------
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 5986
***************************************