[19903] in Perl-Users-Digest
Perl-Users Digest, Issue: 2098 Volume: 10
daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Fri Nov 9 06:05:38 2001
Date: Fri, 9 Nov 2001 03:05:12 -0800 (PST)
From: Perl-Users Digest <Perl-Users-Request@ruby.OCE.ORST.EDU>
To: Perl-Users@ruby.OCE.ORST.EDU (Perl-Users Digest)
Message-Id: <1005303911-v10-i2098@ruby.oce.orst.edu>
Content-Type: text
Perl-Users Digest Fri, 9 Nov 2001 Volume: 10 Number: 2098
Today's topics:
Re: 0 response from a DHCP client (jack)
Re: 0 response from a DHCP client nobull@mail.com
Anyone here know how to build HTML docs from Perl src d jks@saba.bass
Re: Anyone here know how to build HTML docs from Perl s (Rafael Garcia-Suarez)
Re: can you help? grabbing urls mixed in with other tex (Joe Smith)
Re: can you help? grabbing urls mixed in with other tex <comdog@panix.com>
converting ^M characters to \n <hugo@fractalgraphics.com.au>
Crazy Xah [was--Perl tool to grab websites] <slytobias@home.com>
Re: Crazy Xah [was--Perl tool to grab websites] <tony_curtis32@yahoo.com>
Re: Direct iteration over aoh (Garry Williams)
Re: file copy problems <krahnj@acm.org>
How to use PIPE in CGI? <hkyeung9@ie.cuhk.edu.hk>
Re: How to use PIPE in CGI? <thepoet@nexgo.de>
Re: incorrect logic? <krahnj@acm.org>
metacharacters and reg exps (Goatee Wearer)
Need Some Help <saUSAFirst@yahoo.com>
Re: nested foreach - how to speed up or optimize ? (Anno Siegel)
Newbie Need Help <ApriolUSA@yahoo.com>
Re: Newbie Need Help <josef.moellers@fujitsu-siemens.com>
Newbie Question <AdamYYYY@yahoo.com>
Re: Newbie Question <bernard.el-hagin@lido-tech.net>
Re: Online Perl Docs <comdog@panix.com>
Re: passing array values from perl to javascript <geoff@REMOVETHISgeoffball.net>
Re: passing array values from perl to javascript <geoff@REMOVETHISgeoffball.net>
Please Kindly Explain <JJSUSA2001@yahoo.com>
Re: Please Kindly Explain (Anno Siegel)
Re: Please Kindly Explain <bernard.el-hagin@lido-tech.net>
Digest Administrivia (Last modified: 6 Apr 01) (Perl-Users-Digest Admin)
----------------------------------------------------------------------
Date: 8 Nov 2001 18:07:25 -0800
From: jack@brainminers.net (jack)
Subject: Re: 0 response from a DHCP client
Message-Id: <90de0398.0111081807.2c1a818@posting.google.com>
nobull@mail.com wrote in message news:<u94ro5qh8j.fsf@wcl-l.bham.ac.uk>...
> jack@brainminers.net (jack) writes:
>
> > Subject: 0 response from a DHCP client
>
> "Client"?
>
> > Your insight is highly appreciate.
>
> > use IO::Socket;
>
> I suggest that you actually do! Use IO::Socket that is, don't just
> declare that you are going to use IO::Socket and then use the much
> more difficult primative socket interface instead.
>
> There's nothing in your code to attempt to construct a valid DHCP
> request. There is nothing in your code to attempt to specify the UDP
> source port as 68. This has nothing to do with Perl.
But how you go about doing that?
------------------------------
Date: 09 Nov 2001 10:17:56 +0000
From: nobull@mail.com
Subject: Re: 0 response from a DHCP client
Message-Id: <u9vggkp7sb.fsf@wcl-l.bham.ac.uk>
jack@brainminers.net (jack) writes:
> nobull@mail.com wrote in message news:<u94ro5qh8j.fsf@wcl-l.bham.ac.uk>...
> > jack@brainminers.net (jack) writes:
> >
> > > use IO::Socket;
> >
> > I suggest that you actually do! Use IO::Socket that is, don't just
> > declare that you are going to use IO::Socket and then use the much
> > more difficult primative socket interface instead.
> >
> > There's nothing in your code to attempt to construct a valid DHCP
> > request. There is nothing in your code to attempt to specify the UDP
> > source port as 68. This has nothing to do with Perl.
>
> But how you go about doing that?
Go about doing _what_?
Using IO::Socket? See "perldoc IO::Socket" (et seq).
Finding out what constitutes a valid DHCP packet? See relevant RFCs.
Constructing such a packet in Perl? See "perldoc -f pack".
Binding the local port number of a UDP socket? If using IO::Socket
see "perldoc IO::Socket::INET". If not using IO::Socket see "perldoc
-f bind"
--
\\ ( )
. _\\__[oo
.__/ \\ /\@
. l___\\
# ll l\\
###LL LL\\
------------------------------
Date: Fri, 09 Nov 2001 04:51:39 GMT
From: jks@saba.bass
Subject: Anyone here know how to build HTML docs from Perl src dist?
Message-Id: <m3hes47djv.fsf@saba.bass>
Is there anyone on this mailing list who knows a script to generate ALL of the
Perl documentation in HTML format from the source distribution of Perl 5.6.1?
Even better, is there anyone who has such a script that will generate all of
the HTML documentation without broken links?
Thanks,
John
------------------------------
Date: 9 Nov 2001 08:37:19 GMT
From: rgarciasuarez@free.fr (Rafael Garcia-Suarez)
Subject: Re: Anyone here know how to build HTML docs from Perl src dist?
Message-Id: <slrn9un5ev.7im.rgarciasuarez@rafael.kazibao.net>
jks@saba.bass wrote in comp.lang.perl.misc:
> Is there anyone on this mailing list who knows a script to generate ALL of the
> Perl documentation in HTML format from the source distribution of Perl 5.6.1?
Perl comes with a tool, pod2html, that converts, as its name suggests,
pod to html.
But if you're building perl from source, look at the installhtml utility
and at its references in the INSTALL file.
> Even better, is there anyone who has such a script that will generate all of
> the HTML documentation without broken links?
I think that broken links come also from problem with the pods.
--
Rafael Garcia-Suarez / http://rgarciasuarez.free.fr/
use lib sub{$_=$_[1];y;_.mp; ,\n;d;print;
open+0;*0};require Just_another_Perl_hacker;1
------------------------------
Date: Fri, 09 Nov 2001 06:47:41 GMT
From: inwap@best.com (Joe Smith)
Subject: Re: can you help? grabbing urls mixed in with other text
Message-Id: <h_KG7.3692$Le.89004@sea-read.news.verio.net>
In article <comdog-11646B.11232808112001@news.panix.com>,
brian d foy <comdog@panix.com> wrote:
>if the text is HTML, the HTML::SimpleLinkExtor is much easier to use
>rather than subclassing HTML::Parser. :)
I forgot about that one. The author recommends it.
One problem: I get "404 Not Found" for
http://search.cpan.org/doc/BDFOY/HTML-SimpleLinkExtor-0.71/SimpleLinkExtor.pm
-Joe
--
See http://www.inwap.com/ for PDP-10 and "ReBoot" pages.
------------------------------
Date: Fri, 09 Nov 2001 03:12:19 -0500
From: brian d foy <comdog@panix.com>
Subject: Re: can you help? grabbing urls mixed in with other text
Message-Id: <comdog-E31015.03121909112001@news.panix.com>
In article <h_KG7.3692$Le.89004@sea-read.news.verio.net>,
inwap@best.com (Joe Smith) wrote:
> One problem: I get "404 Not Found" for
> http://search.cpan.org/doc/BDFOY/HTML-SimpleLinkExtor-0.71/SimpleLinkExtor.pm
hmmm... CPAN can be wierd about that sometimes. i'm getting ready to
upload a bug fix, so maybe that will fix it. :)
--
brian d foy <comdog@panix.com> - Perl services for hire
CGI Meta FAQ - http://www.perl.org/CGI_MetaFAQ.html
Troubleshooting CGI scripts - http://www.perl.org/troubleshooting_CGI.html
------------------------------
Date: Fri, 09 Nov 2001 17:26:24 +0800
From: hugo <hugo@fractalgraphics.com.au>
Subject: converting ^M characters to \n
Message-Id: <3BEBA140.200F76C@fractalgraphics.com.au>
Hi
I have a problem with an array which I would like to write out to a
file. I would like each array element end with a \n newline character.
Instead, each array value ends with a ^M character, but not at the end
of the line (the line continues after the ^M character). Suppose I have
an array with the following data:
MyData (this, that, other );
The data for the array come from a cgi script with a TEXTAREA window - I
am using using a browser on a PC to enter the data. The data are entered
into an array as follows:
$search_file = query->param(search_file);
(this is the contents of the TEXTAREA)
@MyData = split ("\n", $search_file);
Then I would like to write @Mydata to an output file (to /tmp/ on a unix
machine) as follows (the code which follows is from my CGI script on the
unix server):
open (OUTFILE) ">/tmp/mylist || die "cannot open";
foreach $x (@MyData) {
print OUTFILE $x;
}
This gives me:
this^Mthat^Mother^M
What I want is
this
that
other
I have tried the following:
open (OUTFILE) ">/tmp/mylist || die "cannot open";
foreach $x (@MyData) {
if ($x =~ /^M/ ) {
$x =~ s/^M//;
}
print OUTFILE $x;
print "\n";
}
But this does not help - I end up with exactly the same result ie with
this^Mthat^Mother^M
Can anyone help me with this?
Any help will be greatly appreciated.
Thanks
Hugo
--
Dr Hugo Bouckaert
R&D Support Engineer, Fractal Graphics
57 Havelock Street, West Perth 6005
Western Australia 6009
Tel: +618 9211 6000 Fax: +618 9226 1299
Email:hugo@fractalgraphics.com.au
Web: http://www.fractalgraphics.com.au
------------------------------
Date: Fri, 09 Nov 2001 02:51:17 GMT
From: David Sletten <slytobias@home.com>
Subject: Crazy Xah [was--Perl tool to grab websites]
Message-Id: <3BEB51E9.8050803@home.com>
Xah Lee wrote:
> Dear all,
>
>
> Xah
> xah@xahlee.org
> http://xahlee.org/PageTwo_dir/more.html
> "The 3 characteristics of Perl programers: mundaneness, sloppiness,
> and fatuousness."
>
And what characteristics might we expect to ascribe to a moron who comes
begging for help while insulting the very community he's depending upon?
For the benefit of Perl programmers who may not be familiar with Xah the
loony I'll share his rant from 8 December 2000 on comp.lang.lisp:
---quote
Did you know that throughout history there's this things called cult? It is
a very interesting phenomenon. I don't have time to expound and teach, but
will try to brief you.
These cults, are often lead my a single person. They form a group as small
as a dozen to multinational octopuses (such as Scientology). Their creed
varies from the mild in appearance (Dianetics) to appalling (flat earth,
extraordinary life-after-death, impinging apocalypse scenarios, militant
anti-government conspiracy, diabolism with human sacrifices ...). Don't
think that i'm citing from some arcane books buried in libraries. These are
real, and not difficult to find in real life. Some of these cult leaders,
are so able to totally wash their member's brain, as to have them
autonomously swear and volunteer to die for the cause of the cult.
Occasionally, you'll even see mass suicide.
You know, the world are not made completely of rubes. Somebody somewhere,
will observe this phenomenon and study or report it as is. Big brother
organizations, such as the FBI, is keen on these and very interested in
benefiting from social psychology themselves. They are recorded in books
too. Ever wonder why the library houses so many cold volumes of paper? This
is one contributing reason. You might be interested to verify that
sometimes.
These brain-washing phenomenon, is not limited to fanatical life-and-death
or otherwise dire beliefs. You see it work in all manners of human thought
in the general sense. From culture formation to fashion to commercialism.
Surely you have heard of Adolf Hitler and his atrocities of genocide? I must
alert you, that a single person couldn't commit such a crime. You see, even
if you are superman, you can only kill few at a time. You see, it is the
people, people like you and me, who commit the killings willingly, by
Hitler's teaching. You may say: "no, i won't ever do such stupid thing",
well because you are very ignorant about social psychology. It is precisely
innocent people like you and (not) me, who were lead by the radical leaders
of supreme brain-washing abilities. The innocent mob were fervent in their
leader's vision and beliefs to commit anything. You know the concept of war,
right? We have two massive body of people committed to cut off other
people's head or otherwise stick a knife in their bodies or bomb off an arm
or leg. How did that happen? Well, it starts with patriotism for people like
you and (not) me.
Now, back to topic. In the computing world, there're also bad seed with
colorful creed taking innocent mobs forming cults. The three principal
virtues of a programmer are Laziness, Impatience, and Hubris. Yes? Mr Kent
Pitman, Yes?
How can we prevent heinous cults then? Stop bending truths. Education and
rationalism. I'm starting my own cult to exterminate morons on this earth.
Two things are on the top of my agenda: Unixism and Perl.
Xah
xah@xahlee.org
http://xahlee.org/PageTwo_dir/more.html
---quote
How's the extermination campaign going, fruitcake?
As a final treat, here's Xah insulting a prominent member of the Perl
community while insulting a prominent member of the Lisp community:
Why do you are so often so fucked up in thinking? Larry Wall is by
intention. A brainless nevertheless artistic joker of sorts. Were you by
intention too? Have you studied logic and linguistics significantly? You
surely exhibit the manipulation of English.
------------------------------
Date: Thu, 08 Nov 2001 20:59:06 -0600
From: Tony Curtis <tony_curtis32@yahoo.com>
Subject: Re: Crazy Xah [was--Perl tool to grab websites]
Message-Id: <87lmhghcp1.fsf@limey.hpcc.uh.edu>
>> On Fri, 09 Nov 2001 02:51:17 GMT,
>> David Sletten <slytobias@home.com> said:
> For the benefit of Perl programmers who may not be
> familiar with Xah the loony I'll share his rant from 8
> December 2000 on comp.lang.lisp:
I thought the name was sadly familiar. xah popped up
somwhere in the godzilla travesty.
http://groups.google.com/ shows a history of ranting, in
clpm (and elsewhere as David notes).
--
Oh! I've said too much. Smithers, use the amnesia ray.
------------------------------
Date: Fri, 09 Nov 2001 04:27:40 GMT
From: garry@ifr.zvolve.net (Garry Williams)
Subject: Re: Direct iteration over aoh
Message-Id: <slrn9ummps.17g.garry@zfw.zvolve.net>
On Thu, 08 Nov 2001 19:59:30 -0500, Benjamin Goldberg
<goldbb2@earthlink.net> wrote:
> Personally, I would have done the print with your original @array as:
>
> print $_, "\n" foreach @array;
>
> This is because if you print an undef value, it prints nothing [as you
> would expect], and it produces no warnings.
So why does this happen?
$ perl -we 'print $_'
Use of uninitialized value in print at -e line 1.
$ perl -v
This is perl, v5.6.1 built for sun4-solaris
--
Garry Williams
------------------------------
Date: Fri, 09 Nov 2001 04:52:48 GMT
From: "John W. Krahn" <krahnj@acm.org>
Subject: Re: file copy problems
Message-Id: <3BEB611C.21A133A5@acm.org>
Tad McClellan wrote:
>
> >$source = qq(C:\\mydir\\) . $name;
> ^^
>
> You should use single quotes unless you _require_ one of the
> two extra things that double quotes give you (variable interpolation
> and backslash escapes).
>
> $source = q(C:\mydir\) . $name;
Did *you* try it before posting it?
$ perl -le'$source = q(C:\mydir\) . $name'
Can't find string terminator ")" anywhere before EOF at -e line 1.
Perhaps you meant:
$source = q(C:\mydir\\) . $name;
:-)
John
--
use Perl;
program
fulfillment
------------------------------
Date: Fri, 9 Nov 2001 16:47:08 -0800
From: "Ryan" <hkyeung9@ie.cuhk.edu.hk>
Subject: How to use PIPE in CGI?
Message-Id: <9sg4p2$6kr$1@eng-ser1.erg.cuhk.edu.hk>
Hello,
I have a problem about how to do pipe in CGI. When in command mode, I can do
the following:
eg.a.pl:(perl a.pl)
...
open(PIPE, "| perl xyz.pl");
close(PIPE);
...
however, when i do as cgi, it can't works(see through browser) What's wrong
is it?
Thx~
------------------------------
Date: Fri, 9 Nov 2001 11:40:42 +0100
From: "Christian Winter" <thepoet@nexgo.de>
Subject: Re: How to use PIPE in CGI?
Message-Id: <9sgbmh$efv$1@newsread2.nexgo.de>
"Ryan" <hkyeung9@ie.cuhk.edu.hk> wrote:
> Hello,
> I have a problem about how to do pipe in CGI. When in command mode, I can
do
> the following:
> eg.a.pl:(perl a.pl)
> ...
> open(PIPE, "| perl xyz.pl");
> close(PIPE);
> ...
> however, when i do as cgi, it can't works(see through browser) What's
wrong
> is it?
Your cgi-script is run by the Webserver, thus it doesn't have a login shell
and also no appropriate PATH var. You should try giving the full path
to perl
open(PIPE,"| /usr/bin/perl xyz.pl") or die $!;
should work.
To solve those problems yourself, you should always, and especially
when implementing new scripts, try to get as much debug output
as possible.
So always start your CGIs with
#!/path/to/perl -w
use CGI;
use CGI::Carp qw(fatalsToBrowser);
# gives nice HTML-formatted debug output if anything goes wrong
and append a "or die $!" to every open()-call
HTH
Christian
------------------------------
Date: Fri, 09 Nov 2001 08:49:30 GMT
From: "John W. Krahn" <krahnj@acm.org>
Subject: Re: incorrect logic?
Message-Id: <3BEB9892.47C4ACBE@acm.org>
Jessica Bull wrote:
>
> All,
>
> I have a script which is used to copy data in an infinate loop to fill drive
> space as a test for managment software. The share I am copying from has
> about 8 gigs of data and a couple thousand files. I am copying the data in
> 100 meg chunks. The script runs great except it copies the same files over
> and over again instead of going through the entire directory. Can someone
> help? Code below.
>
> This is the piece where it seems the problem may be....Entire code below
> portion
>
> [snip code]
Maybe this will work better for you: (not tested!)
use File::Find;
use File::Copy;
use File::Basename;
use constant MIN_SIZE = 100_000_000; #least amount of data copied
use constant MAX_SIZE = 101_000_000; #most amount of data copied
my $unique = 0;
my $total_size;
my @filestocpy;
sub wanted {
return if -d or -z;
$total_size += -s;
if ( $total_size < MAX_SIZE ) {
push @filestocpy, $File::Find::name;
}
elsif ( $total_size > MIN_SIZE ) {
for my $from_file ( @filestocpy ) {
my $to_file = "$todir/" . ++$unique . basename( $from_file
);
copy( $from_file, $to_file ) or die "Cannot copy $from_file
to $to_file: $!";
print "$from_file : $to_file\n";
}
@filestocpy = ();
$total_size = 0;
sleep 10;
}
else {
$total_size -= -s;
}
}
1 while find( \&wanted, $fromdir );
__END__
John
--
use Perl;
program
fulfillment
------------------------------
Date: 9 Nov 2001 02:52:52 -0800
From: bobsmith@goateemail.org (Goatee Wearer)
Subject: metacharacters and reg exps
Message-Id: <fff8773a.0111090252.4e9bb86d@posting.google.com>
Hi,
I am parsing input from a CGI form, and so want to run everything
through regular expressions to untaint the data.
Yesterday, I grabbed the data ($data = $form->param('input') )and sent
it through a reg exp ( $data =~ /(^[\w-.\s\(\)\']+)$/ ) and whenever
metacharacters were part of $data, it would knock Perl over.
Then I used $data = "\Q$data\E" before putting it through the regexp,
which worked fine.
Today I carry on working, and suddenly the regexp was complaining
about everything. I took a look at what was happening, and it was
effectively being escaped twice. Perl wasn't complaining (I'm using
strict, warnings, CGI qw(:standard) and CGI::Carp qw/fatalsToBrowser/.
It's working now, but I don't know what would make illegal characters
knock it over yesterday and not today.
Any info would be greatly appreciated.
waspcatcher
------------------------------
Date: Fri, 9 Nov 2001 04:43:27 -0500
From: "Sophie Anderson" <saUSAFirst@yahoo.com>
Subject: Need Some Help
Message-Id: <9sg7o4$36e$1@slb7.atl.mindspring.net>
I just started learning Perl a few hours ago at www.perl.com
I have 3 databases or (files).
db1.txt has fields:
bNumber bName bPhone
db2.txt has fields:
bNumber ISBN returnDate
db3.txt has fields:
ISBN Author Title Publisher Cost Year
I need to read all files so that when I type "Enter the borrower
number: " all fields from all 3 fields are displayed.
I could do this pretty easily in C/C++ but my boss want it in Perl
claiming that Perl can handle files better.
At www.perl.com I learned how to open/close files, put each line
(record) into arrays, split the line into fields, etc. Also Perl uses
regular expression to match field/record.
My questions:
How do read 3 files together? Should I use the sleep function? But how?
Are there any Perl built in functions that I should know instead of
spending limited time figuring out the codes?
Is/are there any "worth to buy" Perl book(s) out there on files
handling? (I have spent quite a lot of money buying useless books.)
Your time and help are appreciated. Thank you very much in advance.
------------------------------
Date: 9 Nov 2001 10:20:12 GMT
From: anno4000@lublin.zrz.tu-berlin.de (Anno Siegel)
Subject: Re: nested foreach - how to speed up or optimize ?
Message-Id: <9sgaks$krq$1@mamenchi.zrz.TU-Berlin.DE>
According to Grzegorz Goryszewski <gregory@pharmag.pl>:
> Hello.
>
> My log parser runs very slowly , on my Duron 800 with 256MB RAM it
> takes about 2 hours to achieve 50% of a task.
[much code snipped]
> foreach $luser (keys %users)
> {
> foreach $zak (keys %zakoncz)
> {
> foreach $rozp (keys %rozpocz)
> {
>
> # print
> "zak,$zak,rozp,$rozp,user,$luser,strt,$rozpocz{$rozp}[0],endt,$zakoncz{$zak}[0],strdta,$rozpocz{$rozp}[1],enddta,$zakoncz{$zak}[1],$users{$luser}[0],$users{$luser}[1]\n" if ($zak eq $rozp && $luser eq $zakoncz{$zak}[2]);
> print
> "user,$luser,strt,$rozpocz{$rozp}[0],endt,$zakoncz{$zak}[0],strdta,$rozpocz{$rozp}[1],enddta,$zakoncz{$zak}[1],$users{$luser}[0],$users{$luser}[1]\n" if
> ($zak eq $rozp && $luser eq $zakoncz{$zak}[2]);
>
> # # print "found $luser in zak $zakoncz{$zak}[2]\n" if ($luser eq
> $zakoncz{$zak}[2]);
> }
> }
> }
That triple loop is wasteful. You are walking through the keys of all
three hashes, but the inner loop only rarely does something. It's like
saying
for my $i ( 1 .. 1000 ) {
if ( $i = 124 ) {
# do something
}
}
instead of simply
$i = 124;
# do something
As far as I can see, you should be able to get essentially the same
output (probably in a different sequence) with a single loop:
foreach $zak (keys %zakoncz) {
$luser = $zakoncz{$zak}[2];
$rozp = $zak
print "user,$luser,strt,$rozpocz{$rozp}[0],endt,$zakoncz{$zak}[0],strdta,$rozpocz{$rozp}[1],enddta,$zakoncz{$zak}[1],$users{$luser}[0],$users{$luser}[1]\n"
print "found $luser in zak $zakoncz{$zak}[2]\n";
}
Obviously, one of the variables $rozp or $zak can be eliminated also,
I just left it in for reference.
Anno
------------------------------
Date: Fri, 9 Nov 2001 03:42:21 -0500
From: "April Harmon" <ApriolUSA@yahoo.com>
Subject: Newbie Need Help
Message-Id: <9sg45a$cqv$1@slb3.atl.mindspring.net>
What Perl codes (or functions) should I use to execute C/C++ programs?
Thanks in advance.
------------------------------
Date: Fri, 09 Nov 2001 10:17:40 +0100
From: Josef =?iso-8859-1?Q?M=F6llers?= <josef.moellers@fujitsu-siemens.com>
Subject: Re: Newbie Need Help
Message-Id: <3BEB9F34.ECFD58DB@fujitsu-siemens.com>
April Harmon wrote:
> =
> What Perl codes (or functions) should I use to execute C/C++ programs?
> Thanks in advance.
system or fork+exec
-- =
Josef M=F6llers (Pinguinpfleger bei FSC)
If failure had no penalty success would not be a prize
-- T. Pratchett
------------------------------
Date: Fri, 9 Nov 2001 04:56:00 -0500
From: "Adam Young" <AdamYYYY@yahoo.com>
Subject: Newbie Question
Message-Id: <9sg8fd$s6c$1@slb3.atl.mindspring.net>
What does this pattern say?
/(ABC).*(XYZ).*\1.*\2/
Thanks.
------------------------------
Date: 9 Nov 2001 09:53:40 GMT
From: Bernard El-Hagin <bernard.el-hagin@lido-tech.net>
Subject: Re: Newbie Question
Message-Id: <slrn9uncvb.mi5.bernard.el-hagin@gdndev25.lido-tech>
On Fri, 9 Nov 2001 04:56:00 -0500, Adam Young <AdamYYYY@yahoo.com> wrote:
> What does this pattern say?
>
> /(ABC).*(XYZ).*\1.*\2/
ABC followed by a crapload of anything followed by XYZ followed
by a crapload of anything followed by ABC followed by another
crapload of anything followed by XYZ.
Read 'perldoc perlre' and start placing the subjects of your posts
in the cleverly named Subject fields.
Cheers,
Bernard
------------------------------
Date: Thu, 08 Nov 2001 21:40:34 -0500
From: brian d foy <comdog@panix.com>
Subject: Re: Online Perl Docs
Message-Id: <comdog-76804F.21403408112001@news.panix.com>
In article <52de739f.0111081629.55f91b41@posting.google.com>,
mark@kitfox.com (Mark McKay) wrote:
> Is there some good online HTML documentation for perl that would be
> similar to the Camel book? (I have the Camel book, but think that
> something with an electronic index and cut and paste abilities would
> be even better). I've looked at CPAN, but the only comprehensive
> documentation I could find was for the modules.
www.perldoc.com is the online Perl docs.
ORA also has the Camel book (with five other books) on CD
somewhere, but you have to buy that.
--
brian d foy <comdog@panix.com> - Perl services for hire
CGI Meta FAQ - http://www.perl.org/CGI_MetaFAQ.html
Troubleshooting CGI scripts - http://www.perl.org/troubleshooting_CGI.html
------------------------------
Date: Fri, 09 Nov 2001 02:15:47 GMT
From: "Geoff" <geoff@REMOVETHISgeoffball.net>
Subject: Re: passing array values from perl to javascript
Message-Id: <n%GG7.31308$5e2.5432564@news1.telusplanet.net>
"Samneric" <samneric@tigerriverOMIT-THIS.com> wrote in message
news:MPG.1654c8e96b65b5f19896bd@news.onemain.com...
> > print "var jsinfile = new Array();";
>
> You printed a semi-colon after "Array()", but...
>
> > for ($i = 0; $i < @data; $i++) {
> > chomp $data[$i];
> > print "jsinfile[$i] = \"$data[$i]\"";
> > }
>
> ...NO LINEFEEDS OR SEMI-COLONS IN THAT PRINT STATEMENT!
Why not? Just escape it.
print "var jsinfile = new Array()\;\n";
------------------------------
Date: Fri, 09 Nov 2001 02:14:29 GMT
From: "Geoff" <geoff@REMOVETHISgeoffball.net>
Subject: Re: passing array values from perl to javascript
Message-Id: <9_GG7.31300$5e2.5431149@news1.telusplanet.net>
"hugo" <hugo@fractalgraphics.com.au> wrote in message
news:3BEB2D58.15CCBDE4@fractalgraphics.com.au...
> Hi Geoff
>
> Excuse my ignorance, but I thought you always needed javascript to
> generate a new Window.
> Perhaps this sounds stupid, but how would you do this with perl only?
The Perl script would accept the input values, and then print them out
within the script.
print "Content-type: text/html\n\n";
print "<html>..." . $hisValues . "</html>\n";
Geoff
> Thanks
>
> Hugo
>
>
> Geoff wrote:
> >
> > "hugo" <hugo@fractalgraphics.com.au> wrote in message
> > news:3BE9E7EF.DC65BD88@fractalgraphics.com.au...
> > > Hi
> > >
> > > I am trying to pass an array with values from a perl to a javascript
> > > array, then open a new window which displays the javascript array
> > > values. I am reading in the perl array into the javascript array with
> > > print statements, and this seems to work well (when I look at thepage
> > > source). However, when I try to transfer the javascript array values
to
> > > a new window, and display them, nothing happens. An alert statement
> > > attempting to display the [0] index value of the javascript array
states
> > > that it is undefined.
> > >
> > > Here is my code:
> > >
> > > 1. First, in my perl code, I read fill in the javascript array with
> > > values from the perl array (@data is my perl array and jsinfile is my
> > > javascript array):
> > >
> > > print "<SCRIPT LANGUAGE=\"javascript\">";
> > > print "var jsinfile = new Array();";
> > > for ($i = 0; $i < @data; $i++) {
> > > chomp $data[$i];
> > > print "jsinfile[$i] = \"$data[$i]\"";
> > > }
> > > print "</SCRIPT>";
> > >
> > > Then I have a form with a button to view the new page, with an onClick
> > > statement, passing the jsinfile array to the function which opens the
> > > new page:
> > >
> > > print "<FORM METHOD=\"POST\" ENCTYPE=\"multipart/form-data\">";
> > > print "<p>View double-spaced file?";
> > > print "<INPUT TYPE=\"SUBMIT\" VALUE=\"View\"
> > > onClick=\"javascript:open_outfile1(jsinfile)\">";
> > > print "</FORM>";
> > >
> >
> > This should probably be a button, not a submit [button]. That way, it
won't
> > actually submit the form.
> >
> > > Then I have the javascript function which is activated by onClick and
> > > opens the new window. The new window is opened but no jsinfile values
> > > are displayed in the page. Note that this function occurs earlier in
the
> > > code (i.e. higher up), but that shouldn't matter. The window alert on
> > > the third line states that jsinfile is undefined.
> >
> > I think you should just write the new page with a Perl script.
> >
> > > print "<SCRIPT LANGUAGE=\"javascript\">";
> > > print "function open_outfile1(jsinfile) {";
> > > print "window.alert(\"jsinfile (in javascript function) is : \" +
> > > jsinfile[0]);";
> > > print "newWindow =
> > >
> >
window.open('','newWin','toolbar=yes,location=yes,scrollbars=yes,resizable=y
> > es,width=500,height=500,');";
> > > print "newWindow.document.write(\"<html><head><title>Double spaced
> > > file<\/title><\/head><body bgcolor=#FFFFFF>\");";
> > > print "for (i =0; i < jsinfile.length; i++) {";
> > > print " newWindow.document.writeln(jsinfile[i]);";
> > > print " newWindow.document.writeln(\"<br>\");";
> > > print "}";
> > > print "newWindow.document.write(\"<\/body></\html>\");";
> > > print "newWindow.document.close();";
> > > print "}";
> > > print "</SCRIPT>";
> > >
> > > I think I may be doing something wrong in passing the value of
jsinfile
> > > to the javascript function. Perhaps filling in values for jsinfile by
> > > printing it in the first window, does not make it follow that they can
> > > be transferred to another window? I am not very clear on that. If this
> > > is not the way to do it, how then do I open a new window and transfer
> > > array values from a perl array to the new window? Note that I do not
> > > want to do this with a FORM ACTION statement, as then my main window
> > > will be changed (not a new window opened).
> > >
> > > Any help will be greately appreciated.
> > >
> > > Thanks
> > >
> > > Hugo
> > >
> > > --
> > > Dr Hugo Bouckaert
> > > R&D Support Engineer, Fractal Graphics
> > > 57 Havelock Street, West Perth 6005
> > > Western Australia 6009
> > > Tel: +618 9211 6000 Fax: +618 9226 1299
> > > Email:hugo@fractalgraphics.com.au
> > > Web: http://www.fractalgraphics.com.au
> >
> > As I said before, why use JavaScript? Why not just do everything with
Perl?
> >
> > Geoff
>
> --
> Dr Hugo Bouckaert
> R&D Support Engineer, Fractal Graphics
> 57 Havelock Street, West Perth 6005
> Western Australia 6009
> Tel: +618 9211 6000 Fax: +618 9226 1299
> Email:hugo@fractalgraphics.com.au
> Web: http://www.fractalgraphics.com.au
------------------------------
Date: Fri, 9 Nov 2001 03:39:28 -0500
From: "James Sullivan" <JJSUSA2001@yahoo.com>
Subject: Please Kindly Explain
Message-Id: <9sg3vv$f1v$1@slb3.atl.mindspring.net>
while (defined($word = <STDIN>)) {
chop $word; # remove trailing \n
if ($word =~ /^(ABC)+(12|34)[XYZ]+(56|78)$/) {
print "match 1 $word\n";
}
if ($word =~ /(ABC)+(\d+)(XYZ)(\d+)$/) {
print "match 2 $word\n";
}
}
Why there is no match for
ABC12XYZXYZ7856
Please kindly explain, thanks in advance.
------------------------------
Date: 9 Nov 2001 08:39:33 GMT
From: anno4000@lublin.zrz.tu-berlin.de (Anno Siegel)
Subject: Re: Please Kindly Explain
Message-Id: <9sg4o5$blk$1@mamenchi.zrz.TU-Berlin.DE>
According to James Sullivan <JJSUSA2001@yahoo.com>:
>
> while (defined($word = <STDIN>)) {
> chop $word; # remove trailing \n
>
> if ($word =~ /^(ABC)+(12|34)[XYZ]+(56|78)$/) {
> print "match 1 $word\n";
> }
>
> if ($word =~ /(ABC)+(\d+)(XYZ)(\d+)$/) {
> print "match 2 $word\n";
> }
> }
>
> Why there is no match for
> ABC12XYZXYZ7856
>
> Please kindly explain, thanks in advance.
What's to explain? Your first pattern /^(ABC)+(12|34)[XYZ]+(56|78)$/
doesn't match because the string would have to end in either "56" or
"78" after the last alphabetic. The second pattern doesn't match
because it doesn't contain "XYZ" between digits.
Why did you expect a match?
Anno
------------------------------
Date: 9 Nov 2001 08:44:02 GMT
From: Bernard El-Hagin <bernard.el-hagin@lido-tech.net>
Subject: Re: Please Kindly Explain
Message-Id: <slrn9un8sp.mi5.bernard.el-hagin@gdndev25.lido-tech>
On Fri, 9 Nov 2001 03:39:28 -0500, James Sullivan <JJSUSA2001@yahoo.com> wrote:
>
> while (defined($word = <STDIN>)) {
> chop $word; # remove trailing \n
>
> if ($word =~ /^(ABC)+(12|34)[XYZ]+(56|78)$/) {
> print "match 1 $word\n";
> }
>
> if ($word =~ /(ABC)+(\d+)(XYZ)(\d+)$/) {
> print "match 2 $word\n";
> }
> }
>
> Why there is no match for
> ABC12XYZXYZ7856
In the first regex you've got [XYZ]+(56|78) anchored to the end there.
This means that after a series of Xs, Ys and Zs you want *either*
56 *or* 78. You've got both in your input. You can change (56|78) into
(56|78)+ and try again.
In the second regex you've got (XYZ) which matches exactly 'XYZ' and
does so only once, but in your input string you've got it twice. Change
that part of the regex to (XYZ)+ and try again.
Cheers,
Bernard
------------------------------
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 2098
***************************************