[22356] in Perl-Users-Digest
Perl-Users Digest, Issue: 4577 Volume: 10
daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Mon Feb 17 21:05:50 2003
Date: Mon, 17 Feb 2003 18:05:07 -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 Mon, 17 Feb 2003 Volume: 10 Number: 4577
Today's topics:
Re: Bad Output from Perldoc (James E Keenan)
Re: Bad Output from Perldoc (James E Keenan)
Re: call subroutines from a different file <nobull@mail.com>
Re: Compiling Msql-Perl adapter <eric.ehlers@btopenworld.com.nospam>
conditional operator "?:" <nospam@nospam.org>
Re: conditional operator "?:" (Christopher J. White)
Re: conditional operator "?:" (Tad McClellan)
Re: Error in Perl Query <nobull@mail.com>
Re: Error in Perl Query <goldbb2@earthlink.net>
Re: How to trim a field in a data line? <usenet@dwall.fastmail.fm>
Re: join or .= -- which is faster? <monty@NOSPAM.globalcrossing.net>
Re: join or .= -- which is faster? <flavell@mail.cern.ch>
Re: PL_defstash and segfault (for geeks only) <goldbb2@earthlink.net>
Re: Problems with embedding Perl in C++ (Ryan McAvoy)
Re: Reading Nested HTML Tables <will@com.yahoo>
Re: Reading Nested HTML Tables <KevinMyers@austin.rr.com>
Regular Expression Noob (Z)
Return a value to a browser textbox <garry.hayne@gmx.net>
Re: Return a value to a browser textbox <mothra@nowhereatall.com>
Re: Return a value to a browser textbox <abigail@abigail.nl>
Re: Returning the field list from DBI <nobull@mail.com>
Re: Returning the field list from DBI <mbudash@sonic.net>
Script to fetch IMAP unread / unseen message counts? <jjl@pobox.com>
Re: Script to fetch IMAP unread / unseen message counts <mbudash@sonic.net>
Re: Socket command <bongie@gmx.net>
Tk::Notebook corks Expect.pm!! <phlipcpp@yahoo.com>
Re: use lib Apache->server_root_relative('lib/perl'); (Jay Tilton)
Digest Administrivia (Last modified: 6 Apr 01) (Perl-Users-Digest Admin)
----------------------------------------------------------------------
Date: 17 Feb 2003 15:01:00 -0800
From: jkeen@concentric.net (James E Keenan)
Subject: Re: Bad Output from Perldoc
Message-Id: <b955da04.0302171501.66bd788b@posting.google.com>
"Rick Clary" <rbclary@cox-internet.com> wrote in message news:<v4h1t43keah2a7@corp.supernews.com>...
> >
>
> I had the same experience when I went from 5.6.1 to 5.8.0 on two Win98
> boxes. In each case, I removed 5.6.1 before installing 5.8.0.
>
> Rather than adding white space, it appears to me that the lines are
> terminated with a linefeed, but no carriage return so the more pager is
> dropping straight down without going back to the left of the window.
>
This makes sense.
------------------------------
Date: 17 Feb 2003 15:05:27 -0800
From: jkeen@concentric.net (James E Keenan)
Subject: Re: Bad Output from Perldoc
Message-Id: <b955da04.0302171505.5af9c85f@posting.google.com>
"--Rick" <no_trick@my-de(remove the obvious)ja.com> wrote in message news:<pUx3a.54466$zF6.3661609@bgtnsc04-news.ops.worldnet.att.net>...
>
> Here is a solution. Go to this link for the complete discussion.
>
> http://rt.perl.org/rt2/Ticket/Display.html?id=19682
>
> ==============================================
>
>
> If I understand correctly, v5.8.0 perldoc writes it's temp file as
> binary, so the end of line isn't adapted to the platform.
>
> Win98's more.com can't handle this, but NT's more.com can. It's not
> as simple as copying NT's more.com.
>
This makes sense. As it turns out, I was upgraded from Win95 to Win2K
on the box where I was experiencing the problem. After the upgrade, I
successfully installed ActivePerl 8. Perl, perldoc and ppm now DWIW.
So I don't need the workaround on my work computer (but it may force
me to upgrade to Win2K if I want an easily configured Perl 5.8).
Thanks for all who took the time here and at rt.perl.org to look into
this problem.
------------------------------
Date: 17 Feb 2003 17:42:00 +0000
From: Brian McCauley <nobull@mail.com>
Subject: Re: call subroutines from a different file
Message-Id: <u9bs1apzx3.fsf@wcl-l.bham.ac.uk>
"David" <perl-dvd@darklaser.com> writes:
> "Daniel Bird" <dbird@no-spam.sghms.ac.uk> wrote in message
> news:3E48D3CF.1050208@no-spam.sghms.ac.uk...
> > Dear all,
> > I wish to call subroutines from a 'file'. eg:
> >
> > script1.pl calls subroutine 'printlogo' from the file 'subroutines'.
> Can
> > anybody assist me in what is probably quite simple?
>
> try
>
> require subroutines.pl;
You mean:
require 'subroutines.pl';
But I think that unless you have a special reason to use a Perl4-style
library then is is better to take the Perl5 approach (an Exporter
module).
--
\\ ( )
. _\\__[oo
.__/ \\ /\@
. l___\\
# ll l\\
###LL LL\\
------------------------------
Date: Mon, 17 Feb 2003 20:53:13 +0000 (UTC)
From: "eric" <eric.ehlers@btopenworld.com.nospam>
Subject: Re: Compiling Msql-Perl adapter
Message-Id: <b2ri3p$l2p$1@venus.btinternet.com>
"Jared Subman" <jaredsubman@removethis.yahoo.com> wrote in message
news:Xns9321595E7683Djaredsubmannospamyah@127.0.0.1...
> I am trying to compile the Msql-Perl 1.17 adapter on a Solaris 8
> Sunfire 880 and I got the following error message when I tried to run
> "make". The "perl Makefile.pl" command worked fine.
>
> I received this message when trying run 'make':
> cc -c -I/usr/local/msql3/include -xO3 -xdepend -DVERSION=\"1.1702\"
> -D XS_VERSION=\"1.1702\" -KPIC
> -I/usr/perl5/5.00503/sun4-solaris/CORE
> Msql.c
> sh: cc: not found
there is no compiler (cc binary) in your $PATH. if you can't run the above
command at the command line then make won't be able to run it either.
> *** Error code 1
> make: Fatal error: Command failed for target `Msql.o'
>
> I then read that you need to use the same version of gcc which you
> compiled Perl with to compile the adapter, so I downloaded and
> compiled 5.6.1, but now I am getting this message when running "make"
> on the adapter.
well done for downloading and compiling perl - always a good thing to be
able to do - why not go with 5.8 as it's the most recent stable release.
> gcc -c -I/usr/local/msql3/include -fno-strict-aliasing -
> D_LARGEFILE_SOURCE -D_FILE_OFFSET_BITS=64 -O -DVERSION=\"1.1702\"
> -DXS_VERSION=\"1.1702\" -fPIC "-I/usr/local/lib/perl5/5.8.0/sun4-
> solaris/CORE" Msql.c
> Msql.xs: In function `XS_Msql__Statement_fetchinternal':
> Msql.xs:274: `sv_undef' undeclared (first use in this function)
sv_undef has been replaced with PL_sv_undef in perl versions 5.6 and later.
the package you are trying to install is out of date, try getting a more
recent version from CPAN. if you must compile old XS code under perl 5.6+,
either replace "sv_undef" with "PL_sv_undef" in the xs file, or instead of
the "perl Makefile.pl" command do:
perl Makefile.PL POLLUTE=1
HTH
-eric
------------------------------
Date: Mon, 17 Feb 2003 14:49:16 -0500
From: "Christian Caron" <nospam@nospam.org>
Subject: conditional operator "?:"
Message-Id: <b2rebs$5ed4@nrn2.NRCan.gc.ca>
Hi everyone,
I'm trying to check a variable for validity. If positive, it will keep it's
value, if not, the variable will be emptied (or undefined, or assigned with
something else).
Here's what I have:
#################################
#!/usr/local/bin/perl -w
use strict;
my ($empty1, $empty2);
my $test = "it contains |";
my $empty = ( ($test =~ /\|+/) ? $test : "" );
my $test1 = "it contains |";
($test1 =~ /\|+/) ? $empty1 = $test : undef $empty1;
my $test2 = "it contains |";
($test2 =~ /\|+/) ? $empty2 = $test : $empty2 = "it doesn't contain |";
print "$empty, $empty1, $empty2\n";
#################################
It prints: "it contains |, it contains |, it doesn't contain |"
The first two tests did work ok.
I just don't understand why the third test doesn't work as expected.
I looked for "perldoc -q operators" and found out:
Although it has the same precedence as in C, Perl's "?:"
operator produces an lvalue. This assigns $x to either $a
or $b, depending on the trueness of $maybe:
($maybe ? $a : $b) = $x;
But it doesn't talk about the way I did it for the second and third test.
Christian
------------------------------
Date: Mon, 17 Feb 2003 16:58:59 -0500
From: posts@grierwhite.com (Christopher J. White)
Subject: Re: conditional operator "?:"
Message-Id: <m2adgufu1o.fsf@bluesteel.grierwhite.com>
>>>>> "cc" == Christian Caron <nospam@nospam.org> writes:
cc> my $test2 = "it contains |";
cc> ($test2 =~ /\|+/) ? $empty2 = $test : $empty2 = "it doesn't contain |";
cc> print "$empty, $empty1, $empty2\n";
cc> #################################
cc> It prints: "it contains |, it contains |, it doesn't contain |"
cc> The first two tests did work ok.
cc> I just don't understand why the third test doesn't work as expected.
Parentheses are always helpful...what you've got is being
evaluated as:
($test2 =~ /\|+/) ? ($empty2 = ($test : $empty2 = "it doesn't contain |"));
To be sure, add parens:
($test2 =~ /\|+/) ? ($empty2 = $test) : ($empty2 = "it doesn't contain |");
...cj
--
------------------------
-- Christopher J. White
--
-- chris @
-- grierwhite.com
------------------------
------------------------------
Date: Mon, 17 Feb 2003 16:11:25 -0600
From: tadmc@augustmail.com (Tad McClellan)
Subject: Re: conditional operator "?:"
Message-Id: <slrnb52ngd.keq.tadmc@magna.augustmail.com>
Christian Caron <nospam@nospam.org> wrote:
> my $test2 = "it contains |";
> ($test2 =~ /\|+/) ? $empty2 = $test : $empty2 = "it doesn't contain |";
> I just don't understand why the third test doesn't work as expected.
Precedence.
You can override it with parens to get what you want:
($test2 =~ /\|+/) ? $empty2 = $test2 : ($empty2 = "it doesn't contain |");
But I would count that use an abuse of the ?: operator, because
it contains side effects (assignment).
> I looked for "perldoc -q operators" and found out:
perldoc perlop
is where the precedence table is.
Note that ?: is higher precedence than assignment.
--
Tad McClellan SGML consulting
tadmc@augustmail.com Perl programming
Fort Worth, Texas
------------------------------
Date: 17 Feb 2003 17:46:26 +0000
From: Brian McCauley <nobull@mail.com>
Subject: Re: Error in Perl Query
Message-Id: <u97kbypzpp.fsf@wcl-l.bham.ac.uk>
jwcane@enw-ltd.com (Jack Cane) rudely vomits TOFU in our faces:
> I tried the following. Received the error message shown below.
[ snip code that does not mention $database_handle ]
> my $statement_handle = $database_handle->prepare($querystring);
> Can't call method "prepare" on an undefined value at
> c:\inetpub\wwwroot\cgi-bin\LTselectNew-1.pl line 8.
Well, um, like, yes you would. Actually you _should_ have got 'Global
symbol "$database_handle" requires explicit package name' but you also
forgot to 'use strict'.
Looks, from context, like it should be a DBI database handle.
--
\\ ( )
. _\\__[oo
.__/ \\ /\@
. l___\\
# ll l\\
###LL LL\\
------------------------------
Date: Mon, 17 Feb 2003 18:22:11 -0500
From: Benjamin Goldberg <goldbb2@earthlink.net>
Subject: Re: Error in Perl Query
Message-Id: <3E516EA3.DD57D9E6@earthlink.net>
Jack Cane wrote:
>
> I tried the following. There are no errors, but I do not see my print
> "<p>... statements. Nothing is written to the screen after "<p>Query
> is "...
Not surprising, since the $DBH->prepare(...) produces an error, since
you never define the $DBH variable or assign anything to it.
> tks,
>
> jwc
>
> ======================
>
> use Win32::ODBC;
Although you have 'use Win32::ODBC', your code below uses the type of
interface provided by DBI, not Win32::ODBC.
> use CGI qw/:standard/;
use strict;
use warnings;
> my $querystring = "select LastName, FirstName, MidInitial, UserName
> from MemberNames where MbrNr > 333 and mbrNr < 359";
>
> print header;
>
> print "<p>Query is ".$querystring."<p>";
>
> $DSN = "LTmembers";
You should be declaring this with my(), not just assigning to it.
> $SQL = $DBH->prepare($querystring);
You seem to be missing some code here, like $DBH = DBI->connect(....).
> print "<p> Success thus far1 </p>";
>
> $result = $SQL->execute();
You assign to $result, but never examine it. Furthermore, it would be
more accurate for the variable to be named $success.
> print "<p> Success thus far2 </p>";
If the ->prepare succeeded, but the ->execute failed, you would still
reach this line (unless you had done $DBH->{RaiseError} = 1 earlier, or
set that property when constructing $DBH).
I would suggest that you rewrite your code to be as follows:
use strict;
use warnings;
use CGI qw(header param escapeHTML);
use CGI::Carp qw(fatalsToBrowser);
use DBI;
sub fail($) {
print header("text/plain");
print "\u@_ failed: $DBI::errstr\n";
exit;
}
my $dbh = DBI->connect( DBI:ODBC:LTmembers", "user", "password" )
or fail "connect";
my $sth = $dbh->prepare( q[
SELECT LastName, FirstName, MidInitial, UserName
FROM MemberNames
WHERE MbrNr > ? AND MbrNr <= ?] )
or fail "prepare";
my $row1 = param( "ROWSTART" );
my $row2 = param( "ROWEND" );
$sth->execute( $row1, $row2 )
or fail "execute";
print header("text/html");
print "<HTML><HEAD><TITLE>Member Names</TITLE></HEAD>\n";
print "<BODY><TT><TABLE><TR>\n";
print "<TH>", escapeHTML($_), "</TH>" for @{ $sth->{NAME} };
while( my @row = $sth->fetchrow ) {
print "\n</TR><TR>\n";
print "<TD>", escapeHTML($_), "</TD>" for @row;
}
print "\n</TR></TABLE>";
print "<p>Error in fetch: $DBI::errstr\n" if $DBI::errstr";
print "</TT></BODY></HTML>\n";
__END__
[untested]
--
$;=qq qJ,krleahciPhueerarsintoitq;sub __{0 &&
my$__;s ee substr$;,$,&&++$__%$,--,1,qq;;;ee;
$__>2&&&__}$,=22+$;=~y yiy y;__ while$;;print
------------------------------
Date: Mon, 17 Feb 2003 19:33:00 GMT
From: "David K. Wall" <usenet@dwall.fastmail.fm>
Subject: Re: How to trim a field in a data line?
Message-Id: <Xns93259402141A3dkwwashere@216.148.227.77>
simonyeats@hotmail.com (SYeats) wrote:
> Hi,
> this is got me beat, i was wondering if anyone could help.
> I wish to replace the 94th field in a semi-colon delimited text file
> with a modified version of the same field.
> This field can have values like A+ BB+ CCC-, and i wish to remove the
> +/-, so its just A BB CCC.
> I am trying something like
>
> #!/bin/perl
>
> while (<>) {
> @F=split/;/;
> $F[-18]=~ m/([A-Z]{1,3})/;
> print "$1\n";
> }
>
> but i cant figure out how to do the replacement, just the match.
When you're changing or removing all occurrences of single characters,
what you (usually) need is the transliteration operator:
tr/SEARCHLIST/REPLACEMENTLIST/cds. See perlop for details (under "Quote
and Quote-like Operators"), but something like this will remove + and -
from a string:
$string =~ tr/+-//d;
So you could just say
$F[-18] =~ tr/+-//d;
--
David Wall - me@dwall.fastmail.fm
"Oook."
------------------------------
Date: Mon, 17 Feb 2003 19:30:17 +0000 (UTC)
From: Jim Monty <monty@NOSPAM.globalcrossing.net>
Subject: Re: join or .= -- which is faster?
Message-Id: <b2rd89$1b94$1@node21.cwnet.roc.gblx.net>
Eric J. Roode <REMOVEsdnCAPS@comcast.net> wrote:
> Did you know that you can read an entire file into a string, without
> looping, by setting $/ to undef?
>
> # bad
> $str = '';
> while (<IN>)
> {
> $str .= $_;
> }
>
> # good
> $/ = undef;
> $str = <IN>;
>
> # better
> {
> local $/ = undef;
> $str = <IN>;
> }
I'm reading Perl & XML <http://safari.oreilly.com/?XmlId=0-596-00205-X>
and it's full of "bad" line looping and concatenating. Drives my nuts,
and causes me to mistrust the Perl it's trying to teach me.
--
Jim Monty
------------------------------
Date: Mon, 17 Feb 2003 21:14:26 +0100
From: "Alan J. Flavell" <flavell@mail.cern.ch>
Subject: Re: join or .= -- which is faster?
Message-Id: <Pine.LNX.4.53.0302172104060.8768@lxplus072.cern.ch>
On Mon, Feb 17, Jim Monty inscribed on the eternal scroll:
> I'm reading Perl & XML <http://safari.oreilly.com/?XmlId=0-596-00205-X>
> and it's full of "bad" line looping and concatenating.
As I first heard it said many years back, "physicists write
FORTRAN in any language". Similarly, there are folks who write
their Perl while thinking in C.
> Drives my nuts,
sounds painful!
> and causes me to mistrust the Perl it's trying to teach me.
Just to take the devil's advocate position for a moment, a program
that has all the scaffolding showing but yet is transparently coded to
do the job it's meant to do, could be a safer piece of code to put out
there into the real world, than the most elegant looking construct
which happens to rely on some obscure quirk of the programming
language. One false move by a maintenance programmer, or a glitch in
a new language version, could cause the whole thing to collapse, and
none but the original programmer (who has long since emigrated, or
joined a monastery) could understand why.
Which is not to imply for a moment that I've any objection to
elegant code, when it can be done without creating obscurity.
------------------------------
Date: Mon, 17 Feb 2003 18:29:47 -0500
From: Benjamin Goldberg <goldbb2@earthlink.net>
Subject: Re: PL_defstash and segfault (for geeks only)
Message-Id: <3E51706B.F81F2C2D@earthlink.net>
Pavel Hlavnicka wrote:
>
> Hi all,
>
> I've met a segmentation fault using mod_perl 1.27, apache 1.3.27 and
> perl 5.8. Some debugging pointed to the following piece of code (see
> the whole backtrace at the end)
[snip]
A better place to ask this kind of question would be the perl5porters
mailing list -- the easiest thing to do would be to use the 'perlbug'
program which comes with perl to send a bug report. Alternatively, you
can send an email to <perl5porters@perl.org>. Include everything you've
included here.
--
$;=qq qJ,krleahciPhueerarsintoitq;sub __{0 &&
my$__;s ee substr$;,$,&&++$__%$,--,1,qq;;;ee;
$__>2&&&__}$,=22+$;=~y yiy y;__ while$;;print
------------------------------
Date: 17 Feb 2003 09:14:12 -0800
From: ted017@yahoo.com (Ryan McAvoy)
Subject: Re: Problems with embedding Perl in C++
Message-Id: <d72bd836.0302170914.65c90be1@posting.google.com>
Benjamin Goldberg <goldbb2@earthlink.net> wrote in message news:<3E4BE7F2.5A69F8E9@earthlink.net>...
> Ryan McAvoy wrote:
> >
> > Hello:
> >
> > I'm having some problems with embedding PERL into my C++ code, a
> > functional problem and a memory problem.
> >
> > 1. I parse a file into my perl interpreter as follows:
> >
> > PerlInterpreter *my_perl;
> > my_perl = perl_alloc();
> > perl_construct( my_perl );
> >
> > ...
> >
> > perl_parse( my_perl, NULL, 2, perlArgs, (char**) NULL ) );
> >
> > I then proceed to make calls on the subroutines found in the file
> > using call_pv. As the program runs, new files are parsed.
>
> Err, parsed how? By calling perl_parse again?
>
yes
> > I would like the subroutines from all parsed files to be available.
> > I find, however, that only the subroutines from the last parsed file
> > are available.
>
> Hmm, definitely sounds like you're calling perl_parse again. Don't do
> that. Instead, use require_pv.
Yeah. That works a lot better. Thanks
Ryan McAvoy
------------------------------
Date: Mon, 17 Feb 2003 20:39:01 GMT
From: w i l l <will@com.yahoo>
Subject: Re: Reading Nested HTML Tables
Message-Id: <01i25vcl8fb3gee4l65iuhhs772qnfbn33@4ax.com>
this is what you want dude, read the doc first!!!!
http://search.cpan.org/author/MSISK/HTML-TableExtract-1.08/lib/HTML/TableExtract.pm
HTML::TableExtract
good luck
- w i l l
On Mon, 17 Feb 2003 13:35:59 GMT, "Kevin Myers"
<KevinMyers@austin.rr.com> wrote:
>Hi folks,
>
>I'm new to this newgroup, and a relative amateur where perl is concerned.
>So, if I'm posting to the wrong list or asking an ignorant question then I
>hope that you'll bear with me...
>
>I'm trying to use perl to walk some web pages and extract some data. I've
>done this successfully in the past, and have the basics down.
>
>However, I presently have a situation where I need to create a list of the
>outermost level of tables on the web pages, where there may be nested levels
>of tables, and I can't seem to come up with a simple way to handle this.
>I'm wondering if I am missing some tricks...
>
>To extract a list of tables from a web page in the past, I have merely used
>perl's regular expression handling to create a list of text items that are
>delimited by the <table> and </table> tags, e.g :
>
>my (@tables) = $pageContent =~ m!(<table.*?>.*?</table>)!gs;
>
>However, now I am running into
>problems because the first </table> tag encountered after a <table> tag may
>be the end of a nested inner level table, rather than the end of the
>outermost level table that I want. I need some way to tell perl to only
>search for a </table> tag at the outermost nesting level. Is there some
>easy way to do this that I am missing?
>
>Thanks greatly in advance for any help.
>
>s/KAM
>
>
>
------------------------------
Date: Mon, 17 Feb 2003 22:33:04 GMT
From: "Kevin Myers" <KevinMyers@austin.rr.com>
Subject: Re: Reading Nested HTML Tables
Message-Id: <Aqd4a.33624$Lm5.1300846@twister.austin.rr.com>
Chris and all -
HTML::TreeBuilder does look like it would be helpful in extracting lists of
tables at various levels. Just one problem: I can't figure out how to get
the list of child element nodes for a given parent element. I'm sure there
must be something very simple here that I am missing, as that functionality
is the main purpose of the whole class. I see a method to get the parent
element, but no method to get a list of child elements???
Thanks in advance for any help.
s/KAM
"Chris Lowth" <dont@want.spam> wrote in message
news:fG54a.778$QF6.205272@newsfep2-win.server.ntli.net...
> Kevin Myers wrote:
>
> > Hi folks,
> >
> > I'm new to this newgroup, and a relative amateur where perl is
concerned.
> > So, if I'm posting to the wrong list or asking an ignorant question then
I
> > hope that you'll bear with me...
> >
> > I'm trying to use perl to walk some web pages and extract some data.
I've
> > done this successfully in the past, and have the basics down.
> >
> > However, I presently have a situation where I need to create a list of
the
> > outermost level of tables on the web pages, where there may be nested
> > levels of tables, and I can't seem to come up with a simple way to
handle
> > this. I'm wondering if I am missing some tricks...
> >
> > To extract a list of tables from a web page in the past, I have merely
> > used perl's regular expression handling to create a list of text items
> > that are delimited by the <table> and </table> tags, e.g :
> >
> > my (@tables) = $pageContent =~ m!(<table.*?>.*?</table>)!gs;
> >
> > However, now I am running into
> > problems because the first </table> tag encountered after a <table> tag
> > may be the end of a nested inner level table, rather than the end of the
> > outermost level table that I want. I need some way to tell perl to only
> > search for a </table> tag at the outermost nesting level. Is there some
> > easy way to do this that I am missing?
> >
> > Thanks greatly in advance for any help.
> >
> > s/KAM
>
> The HTML::Parse (now deprecated) or HTML::TreeBuilder modules are probably
> what you want - available on www.cpan.org
>
> Chris
> --
> My real e-mail address is
> chris <at> lowth <dot> com
------------------------------
Date: 17 Feb 2003 17:57:57 -0800
From: ztamir@yahoo.com (Z)
Subject: Regular Expression Noob
Message-Id: <93a2d462.0302171757.77778911@posting.google.com>
I'm new to regular expressions and need a little help. What regular
expression do I use within the PHP function split() to create an array
of all the substrings located between ANI="TheNumberIwantIsHere"&
The string I'm trying to parse looks like the following:
ANI=1114875732&NAME=Albert&EXT=3030&LOGIN=LoggedIn&TALK=Unavailable&PRIORITY=2003-02-17
12:22:40 **==+==**ANI=222650654&NAME=Ami&EXT=3034&LOGIN=Logged
In&TALK=Unavailable&PRIORITY=2003-02-17 12:35:08
**==+==**ANI=3336600734&NAME=Louisa&EXT=3035&LOGIN=Logged
In&TALK=Unavailable&PRIORITY=2003-02-17 12:37:20
**==+==**ANI=4443830235&NAME=Roxanne&EXT=3032&LOGIN=Logged
In&TALK=Unavailable&PRIORITY=2003-02-17 12:39:33
**==+==**ANI=5556235414&NAME=Tia&EXT=3031&LOGIN=Logged
In&TALK=Unavailable&PRIORITY=2003-02-17 12:38:13 **==+==**Total
Agents=5 FINISHED
So, in other words, starting from the first ANI I want to create an
array that looks like this
1114875732
222650654
3336600734
4443830235
5556235414
------------------------------
Date: Mon, 17 Feb 2003 21:11:16 +0100
From: "Garry Hayne" <garry.hayne@gmx.net>
Subject: Return a value to a browser textbox
Message-Id: <b2rfjh$2ba$05$1@news.t-online.com>
How can I assign a value of browser textbox with a CGI call using Perl. I
am trying to show the user ip in a text box.
Regards, Garry Hayne
------------------------------
Date: Mon, 17 Feb 2003 12:57:13 -0800
From: "Mothra" <mothra@nowhereatall.com>
Subject: Re: Return a value to a browser textbox
Message-Id: <3e514b86$1@usenet.ugs.com>
"Garry Hayne" <garry.hayne@gmx.net> wrote in message
news:b2rfjh$2ba$05$1@news.t-online.com...
> How can I assign a value of browser textbox with a CGI call using Perl. I
> am trying to show the user ip in a text box.
Hi Garry,
try specifing a default value for the text box
print $query->textfield('field_name','starting value',50,80);Mothra
------------------------------
Date: 17 Feb 2003 22:31:22 GMT
From: Abigail <abigail@abigail.nl>
Subject: Re: Return a value to a browser textbox
Message-Id: <slrnb52olq.9mc.abigail@alexandra.abigail.nl>
Garry Hayne (garry.hayne@gmx.net) wrote on MMMCDLVII September MCMXCIII
in <URL:news:b2rfjh$2ba$05$1@news.t-online.com>:
:) How can I assign a value of browser textbox with a CGI call using Perl. I
:) am trying to show the user ip in a text box.
:) Regards, Garry Hayne
You'd do it the same way as in C, except that you leave off the parens
in your call to printf.
Do you actually have a Perl related question?
Abigail
--
Now why do you want to show the users intellectual property in a text box?
------------------------------
Date: 17 Feb 2003 17:39:45 +0000
From: Brian McCauley <nobull@mail.com>
Subject: Re: Returning the field list from DBI
Message-Id: <u9fzqmq00u.fsf@wcl-l.bham.ac.uk>
genericax@hotmail.com (Sara) bottom-posts (which is not nearly as
lazy, confusing or annoying as top-posting but is still confusing):
[ Text re-orders so that Sara's responses follow the OP questions to
which they refer ]
> jsn@microlib.co.uk (Jason Singleton) wrote in message news:<f34f7dc6.0302170354.9e96ac4@posting.google.com>...
> > Well I think the subject says it all here :) but basically I just need
> > to know the fields returned from a query when I don't name them eg
> > using *
>
> Perhaps..
> my $fields = $handle->fetchrow_hashref();
>
> my $fieldNames = keys %$fields;
You mean @fieldNames surely! Of course you don't need to use
fetchrow_hashref() you can get at the information directly.
> Note that the "as" clause in the sql statement can be useful for
> "steering" your field-names to perhaps more friendly ones.
A valid point.
> Also note the the names will always come back uppercase.
Are you sure? In my experience they come back as_is. Although I not
that in recent DBI there's a FetchHashKeyName attribute that can be
used to say you want them upcased or downcased.
> > Also how do I change the read position in the returned data? I don't
> > want to return all records to the user at once I want it to display
> > the returned data in pages like a search engine.
>
>
> By "read position" I'm not sure what you mean. If you mean that one
> user has multiple records, then continue to fetch until you get them
> all.
The OP means he wants to be able to get the n-th page full of
results.
perldoc DBI actually mentions the absense of support for this
explicitly:
Non-sequential record reads are not supported in this ver-
sion of the DBI. In other words, records can only be
fetched in the order that the database returned them, and
once fetched they are forgotten.
--
\\ ( )
. _\\__[oo
.__/ \\ /\@
. l___\\
# ll l\\
###LL LL\\
------------------------------
Date: Mon, 17 Feb 2003 17:52:36 GMT
From: Michael Budash <mbudash@sonic.net>
Subject: Re: Returning the field list from DBI
Message-Id: <mbudash-76334B.09523717022003@typhoon.sonic.net>
In article <776e0325.0302170726.29c767ce@posting.google.com>,
genericax@hotmail.com (Sara) wrote:
> jsn@microlib.co.uk (Jason Singleton) wrote in message
> news:<f34f7dc6.0302170354.9e96ac4@posting.google.com>...
> > Well I think the subject says it all here :) but basically I just need
> > to know the fields returned from a query when I don't name them eg
> > using *
perldoc DBI suggests that @{$handle->{NAME}} will contain what you want.
there are variants mentioned there as well:
"NAME" (array-ref, read-only)
Returns a reference to an array of field names for
each column. The names may contain spaces but should
not be truncated or have any trailing space. Note that
the names have the letter case (upper, lower or mixed)
as returned by the driver being used. Portable appli-
cations should use "NAME_lc" or "NAME_uc".
print "First column name: $sth->{NAME}->[0]\n";
"NAME_lc" (array-ref, read-only)
Like "NAME" but always returns lowercase names.
"NAME_uc" (array-ref, read-only)
Like "NAME" but always returns uppercase names.
"NAME_hash" (hash-ref, read-only)
"NAME_lc_hash" (hash-ref, read-only)
"NAME_uc_hash" (hash-ref, read-only)
The "NAME_hash", "NAME_lc_hash", and "NAME_uc_hash"
attributes return column name information as a refer-
ence to a hash.
The keys of the hash are the names of the columns.
The letter case of the keys corresponds to the letter
case returned by the "NAME", "NAME_lc", and "NAME_uc"
attributes respectively (as described above).
The value of each hash entry is the perl index number
of the corresponding column (counting from 0). For
example:
$sth = $dbh->prepare("select Id, Name from table");
$sth->execute;
@row = $sth->fetchrow_array;
print "Name $row[ $sth->{NAME_lc_hash}{name} ]\n";
hth-
------------------------------
Date: Mon, 17 Feb 2003 20:51:49 +0000
From: John J Lee <jjl@pobox.com>
Subject: Script to fetch IMAP unread / unseen message counts?
Message-Id: <Pine.LNX.4.44.0302172047080.1592-100000@alice>
Anybody have one?
Google found a couple on a newsgroup, but the URLs given are broken.
Thanks for any pointers
John
------------------------------
Date: Mon, 17 Feb 2003 23:38:44 GMT
From: Michael Budash <mbudash@sonic.net>
Subject: Re: Script to fetch IMAP unread / unseen message counts?
Message-Id: <mbudash-055FC6.15384317022003@typhoon.sonic.net>
In article <Pine.LNX.4.44.0302172047080.1592-100000@alice>,
John J Lee <jjl@pobox.com> wrote:
> Anybody have one?
>
> Google found a couple on a newsgroup, but the URLs given are broken.
>
> Thanks for any pointers
>
>
> John
>
http://search.cpan.org/search?query=imap&mode=all
------------------------------
Date: Mon, 17 Feb 2003 20:15:18 +0100
From: "Harald H.-J. Bongartz" <bongie@gmx.net>
Subject: Re: Socket command
Message-Id: <1064154.gSdCNXuiSg@nyoga.dubu.de>
Catharsis wrote:
> print SOCKET "hello" || die "argh I couldnt say hello";
Catching up on unread articles, I couldn't leave that uncommented.
This statement is parsed as
print SOCKET ("hello" || die "argh ...");
which for sure is not what you want.
Either use "or" instead of "||":
print SOCKET "hello" or die "argh...";
or use parentheses:
print (SOCKET "hello") || die "argh...";
I would prefer the lower-precedence "or", but that's just a matter of
personal style. Of course, you can also combine both changes.
Ciao,
Harald
--
Harald H.-J. Bongartz <bongie@gmx.net>
-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-
Applying computer technology is simply finding the right wrench to
pound in the correct screw.
------------------------------
Date: 18 Feb 2003 00:18:39 GMT
From: Phlip <phlipcpp@yahoo.com>
Subject: Tk::Notebook corks Expect.pm!!
Message-Id: <b2ru4v$r8c@dispatch.concentric.net>
Phlip wrote:
> Perlies:
>
> I thought I had grown immune to the kinds of surprises Perl
> specializes in. Nope.
>
> The rig: www.cygwin.com, with its perl v5.6.1 built for cygwin-multi.
>
> The libs: Expect-1.15, and IO-Tty-1.02
>
> The platform: MS Windows XP, factory-installed.
>
> The source:
>
> use strict;
> use Expect;
> my $Perl = $^X;
> my $exp = Expect->spawn("$Perl -v");
> use Tk::NoteBook;
>
> The symptom:
>
> C:\cygwin\bin\perl.exe: *** unable to remap
>
C:\cygwin\lib\perl5\site_perl\5.6.1\cygwin-multi\auto\Tk\NBFrame\NBFrame.dll
> to same address as parent(0xD30000) != 0x1160000
> 5 [main] perl 5640 sync_with_child: child 5148(0x65C) died
> before initialization with status code 0x1
> 56525 [main] perl 5640 sync_with_child: *** child state child
> loading dlls
> Cannot fork: Resource temporarily unavailable at
> /usr/lib/perl5/site_perl/5.6.1/Expect.pm line 111.
>
> The library source (the warn line is 111, natch):
>
> my $pid = fork;
>
> unless (defined ($pid)) {
> warn "Cannot fork: $!" if $^W;
> return undef;
> }
>
> The irony is "use Tk" does not cork Expect.pm. Only "use
> Tk::Notebook". If you comment that line out, the expect works!
Thanks in advance to anyone about to tell me to use Tk::IO, but it gives
essentially the same error, but this time without the Tk::Notebook.
--
Phlip
http://www.greencheese.org/LucidScheming
-- Just think: Four billion people in the
world have never received Spam... --
------------------------------
Date: Mon, 17 Feb 2003 17:15:37 GMT
From: tiltonj@erols.com (Jay Tilton)
Subject: Re: use lib Apache->server_root_relative('lib/perl');
Message-Id: <3e510fb0.77604275@news.erols.com>
"Papa Oohmawmaw" <Pop@goesthe.net> wrote:
: Why do all you guys reply at the bottom of every email?
What email? This is Usenet.
: You have to scroll
: down to the bottom of every post you read even though you know everything
: that's been said.
If people know everything that's been said, why quote anything at all?
Your premise is faulty. Readers may be participating in or monitoring
dozens of threads at once, and cannot be expected to instantly recall
the salient points of each.
: Tradition, I guess.
A tradition rooted in pragmatism. Ages ago, the style of interleaved
quotes and replies was found to be the most effective method of
emulating a live discussion among many people.
: Maybe you can't remember and need to read everything again.
As Dr. Henry Jones said, "I wrote it down so I wouldn't _have_ to
remember."
: Also, what does PLOINK mean?
A variation on "plonk." You have been introduced to another Usenet
tradition. Congratulations.
: I've seen that signature a couple of times in this particular
: thread. Group thing, I suppose.
I've seen these bullet holes a couple of times in this particular
foot. Gun thing, I suppose.
------------------------------
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 4577
***************************************