[16761] in Perl-Users-Digest
Perl-Users Digest, Issue: 4173 Volume: 9
daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Wed Aug 30 06:05:34 2000
Date: Wed, 30 Aug 2000 03:05:17 -0700 (PDT)
From: Perl-Users Digest <Perl-Users-Request@ruby.OCE.ORST.EDU>
To: Perl-Users@ruby.OCE.ORST.EDU (Perl-Users Digest)
Message-Id: <967629917-v9-i4173@ruby.oce.orst.edu>
Content-Type: text
Perl-Users Digest Wed, 30 Aug 2000 Volume: 9 Number: 4173
Today's topics:
Re: Any chance of a little more explanation? (Eric Bohlman)
Re: calling CGI programs <nickco3@yahoo.co.uk>
CGI Scripts Needed <support@online-cgi.co.uk>
Re: check and save random number (TOD TAYLOR)
Re: Checking the IP and reverse <wecke@my-deja.com>
Could we export templates from module? <paul@pco.iis.nsk.su>
Re: Could we export templates from module? (Hasanuddin Tamir)
Re: Could we export templates from module? <paul@pco.iis.nsk.su>
Re: Could we export templates from module? <paul@pco.iis.nsk.su>
Re: Creating seperate HTML files via CGI script <taboo@comcen.com.au>
Distributed System <ntw6maja@fht-esslingen.de>
Emulating a browser. <erik@solidcode.net>
error displaying with Perl compilator daniele7029@my-deja.com
file locking not working <lincolnmarr@nospam.europem01.nt.com>
Re: get newsfeeds from a content site with perl? <isc80031@nus.edu.sg>
Re: Get own machine's dial-up IP address? mexicanmeatballs@my-deja.com
Re: Getting the greedy RegEx, wanting the Lazy - help? (Daniel Chetlin)
Re: Glob errors? <taboo@comcen.com.au>
help in newfeeds <isc80031@nus.edu.sg>
Re: help in newfeeds <Peter.Dintelmann@dresdner-bank.com>
Re: hour difference between localtime and POSIX::mktime (Villy Kruse)
Re: How can I sort using two fields? (Abigail)
Re: How to Unzip a .tar.gz file (BUCK NAKED1)
I can't execute Perlscript on ServerSide <gtinti@datalogic.it>
Re: I can't execute Perlscript on ServerSide <Peter.Dintelmann@dresdner-bank.com>
Re: I can't execute Perlscript on ServerSide <Peter.Dintelmann@dresdner-bank.com>
Digest Administrivia (Last modified: 16 Sep 99) (Perl-Users-Digest Admin)
----------------------------------------------------------------------
Date: 30 Aug 2000 07:01:26 GMT
From: ebohlman@netcom.com (Eric Bohlman)
Subject: Re: Any chance of a little more explanation?
Message-Id: <8oibg6$472$1@slb6.atl.mindspring.net>
Mark McCarthy (markmccarthy1@home.com) wrote:
: Would it be too much to ask Larry for you to explain the GRT sort for me -
: not in abstraction but - say for this particular example. I understand the
: ST pretty well (mostly because of Tom's article). But GRT just blows my mind
: despite having read the paper you co-authored with Uri and other examples
: that use this method eg at http://www.perlfaq.com/faqs/id/162.
:
: Even like three or four lines would be nice if you have time; Any insights
: will be much appreciated. Thanks for the most instructive replies that you
: give in this group. Im pretty much a newbie myself but I learn a tremendous
: amount from you...
I'm not Larry, but here's my attempt:
The basic idea of the GRT sort is that you make a pre-pass over the data
to be sorted, grabbing from each item the information needed for the sort.
You format that information into a sort key so that the lexicographic
order of the keys is the desired sort order and stick the key onto the
beginning of each item. You then sort the items, using Perl's standard
lexicographic sort (avoiding the need for a user-defined comparison
function which would slow things down). Finally, you make a post-pass
over the now-sorted items to strip off the prepended sort keys.
------------------------------
Date: Wed, 30 Aug 2000 10:35:08 +0100
From: Nick Condon <nickco3@yahoo.co.uk>
Subject: Re: calling CGI programs
Message-Id: <39ACD54C.CCD43167@yahoo.co.uk>
Jonathan Palley wrote:
> I'm not sure i'm following you....i don't know how to capitalize PERL, but
> i'm talking about the language being discussed here. I can probably broaden
> my question, if it helps to just how do you open a webpage in a browser from
> a perl cgi script?
This is a Perl newsgroup, not CGI one. Perl is not CGI, they are two separate
subjects, but lots and lots and lots of people come here and post the same dumb
CGI questions over and over, drowning out the Perl discussions that we come here
for. It is the quickest way to earn lots of hate mail from the regulars.
Your question belongs in one of the comp.infosystems.www groups.
------------------------------
Date: Wed, 30 Aug 2000 11:04:05 +0100
From: "Online CGI" <support@online-cgi.co.uk>
Subject: CGI Scripts Needed
Message-Id: <39acdc17@news.telinco.net>
Have you designed a script & want to let everyone use it?
Well Online CGI can help you. This soon to be online site is currently
looking for more CGI scripts to add to it's already growing database. So if
you have designed a
script that you think deserves exposure, then e-mail your script to,
scripts@online-cgi.co.uk.
Please include contact details and full installation details.
----------------------------------------------------------------------------
------------------
Online CGI is a 100% free service dedicated to giving your scripts their
deserved exposure &
will allow anyone to download them.
There will be many other features on Online CGI, including the following:
. Database of CGI scripts
. CGI Tutorials
. Monthly e-mail providing details of new scripts
. CGI Helpdesk (Post a problem to other users)
. Plus many other features
If you have any questions about the site, or you have a suggestion, please
e-mail support@online-cgi.co.uk.
Thank you.
Online-CGI
----------------------------------------------------------------------------
-----------------
------------------------------
Date: 30 Aug 2000 08:49:13 GMT
From: todtaylor@aol.com (TOD TAYLOR)
Subject: Re: check and save random number
Message-Id: <20000830044913.25579.00000104@ng-fa1.aol.com>
Thanks for the comments and suggestions. After reading your reply I
scraped that script and looked in for search routines.
Amazing how simple it really was.
figured it out after 20 mintutes
Thank you
------------------------------
Date: Wed, 30 Aug 2000 04:16:23 GMT
From: Hermann <wecke@my-deja.com>
Subject: Re: Checking the IP and reverse
Message-Id: <8oi1qa$571$1@nnrp1.deja.com>
I donīt know why but this subroutine below is not generating
the "TIMEOUT" info.
In other words, everything is "ok" or "no reverse registered", and even
with a "timeout" response the script will return a "no reverse".
Am I doing something wrong?
I can see this on the screen:
10.0.0.1: TIMEOUT at ./check-ip-2.cgi line 108, <NAS_FILE> chunk 728.
but the log file is reporting as "NO REVERSE".
Any clues???
(the original was "die" instead of "warn"... I changed because I am
testing a long file with several hundreds ips...
In article <4Wcl5.101$DT4.3363214@nnrp2.clara.net>,
newsgroups@ckeith.clara.net (Colin Keith) wrote:
> # And the workhorse fn
> sub fwd_or_rev {
> my($type) = $_[1]?'PTR':'A';
> $SIG{ALRM} = sub { warn 'TIMEOUT'; };
> eval {
> alarm(6); # time out if we don't get a response in 6 secs
> $query = $resolver->query($_[0], $type);
> alarm(0);
> };
> return -1 if($@ =~ /TIMEOUT/); # ugly
> return 0 if(!$query || !(@_ = $query->answer())); # bad
> return $type eq 'A' ? $_[0]->address() : $_[0]->ptrdname(); # good
> }
Sent via Deja.com http://www.deja.com/
Before you buy.
------------------------------
Date: Wed, 30 Aug 2000 11:20:10 +0600
From: "Paul Dortman" <paul@pco.iis.nsk.su>
Subject: Could we export templates from module?
Message-Id: <8oi25e$dce$1@news.itfs.nsk.su>
Hello!
Now, I'm writing my own *.pm module. And I wonder, How can I export
templates' names from it
Or it is impossible? Please, help.
Thank you.
Paul
------------------------------
Date: Wed, 30 Aug 2000 21:43:50 GMT
From: hasant@trabas.co.id (Hasanuddin Tamir)
Subject: Re: Could we export templates from module?
Message-Id: <slrn8qpfav.d75.hasant@borg.intern.trabas.co.id>
On Wed, 30 Aug 2000 11:20:10 +0600, paul@pco.iis.nsk.su wrote:
> Hello!
>
> Now, I'm writing my own *.pm module. And I wonder, How can I export
> templates' names from it
> Or it is impossible? Please, help.
What you mean by "export templates' names"?
Do you have fix names and you want them available to the caller in certain
way? If this is the case you can store them in variable(s) or in constants
or in ordinary subroutines.
If you want them in variables, you can use array, hash or scalar. This
*example* just shows usage of scalar variables, and they must be in
package global scope to be exportable.
package YourModule;
use strict;
use vars qw($VERSION @ISA @EXPORT_OK $Header $Footer $Table);
use Exporter ();
@ISA = 'Exporter';
@EXPORT_OK = qw($Header $Footer $Table);
$Header = 'header.html';
$Footer = 'footer.html';
$Table = 'table.html';
So, the caller can then say,
use YourModule qw($Header $Footer); # or whatever symbol they want
my $tmpl_file = "/path/to/whatever/$Header";
Or, you can use constants,
package YourModule;
use strict;
use constant HEADER => 'header.html';
use constant FOOTER => 'footer.html';
use constant TABLE => 'table.html';
use Exporter ();
@YourModule::ISA = 'Exporter';
@YourModule::EXPORT_OK = qw(HEADER FOOTER TABLE);
# the caller
use YourModule qw(HEADER);
my $tmpl_file = '/path/to/whatever/'. HEADER;
You may also use "tags" (see perldoc Exporter). Or if you think it's
necessary to pollute the caller's namespace, you can store your
exportable symbols in @EXPORT instead of @EXPORT_OK (againsts general
rule for namespace consideration.) More detail in manual perlmod.
Then which way to choose? Well, it depends on your need and the
design of your module. Hope this will get you start up.
HTH
san
--
trabasLabs * hasant@trabas.com * http://www.trabas.com
Zero Point * hasant@zp.f2s.com * http://www.zp.f2s.com
------------------------------
Date: Wed, 30 Aug 2000 14:56:54 +0600
From: "Paul Dortman" <paul@pco.iis.nsk.su>
Subject: Re: Could we export templates from module?
Message-Id: <8oierp$kus$1@news.itfs.nsk.su>
Sorry, I told not clear what I mean. :(
I ment format for writing to file by write function. I took mistake when
call it 'template'. :(
For example:
#format for file
format k=
@<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<< |
$f_name
@<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<< |
$f_passw
@<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<< |
$f_time
.
Thanks for your help.
Paul
Hasanuddin Tamir wrote in message ...
>What you mean by "export templates' names"?
>
>Do you have fix names and you want them available to the caller in certain
>way? If this is the case you can store them in variable(s) or in constants
>or in ordinary subroutines.
>
>If you want them in variables, you can use array, hash or scalar. This
>*example* just shows usage of scalar variables, and they must be in
>package global scope to be exportable.
>
> package YourModule;
> use strict;
> use vars qw($VERSION @ISA @EXPORT_OK $Header $Footer $Table);
> use Exporter ();
> @ISA = 'Exporter';
> @EXPORT_OK = qw($Header $Footer $Table);
> $Header = 'header.html';
> $Footer = 'footer.html';
> $Table = 'table.html';
>
>So, the caller can then say,
>
> use YourModule qw($Header $Footer); # or whatever symbol they want
> my $tmpl_file = "/path/to/whatever/$Header";
>
>Or, you can use constants,
>
> package YourModule;
> use strict;
> use constant HEADER => 'header.html';
> use constant FOOTER => 'footer.html';
> use constant TABLE => 'table.html';
> use Exporter ();
> @YourModule::ISA = 'Exporter';
> @YourModule::EXPORT_OK = qw(HEADER FOOTER TABLE);
>
> # the caller
> use YourModule qw(HEADER);
> my $tmpl_file = '/path/to/whatever/'. HEADER;
>
>You may also use "tags" (see perldoc Exporter). Or if you think it's
>necessary to pollute the caller's namespace, you can store your
>exportable symbols in @EXPORT instead of @EXPORT_OK (againsts general
>rule for namespace consideration.) More detail in manual perlmod.
>
>Then which way to choose? Well, it depends on your need and the
>design of your module. Hope this will get you start up.
>
>
>HTH
>san
>--
>trabasLabs * hasant@trabas.com * http://www.trabas.com
>Zero Point * hasant@zp.f2s.com * http://www.zp.f2s.com
------------------------------
Date: Wed, 30 Aug 2000 15:20:57 +0600
From: "Paul Dortman" <paul@pco.iis.nsk.su>
Subject: Re: Could we export templates from module?
Message-Id: <8oig92$llg$1@news.itfs.nsk.su>
Oh!!!
It's really easy!!! Thank you for help!
Paul
Paul Dortman wrote in message <8oierp$kus$1@news.itfs.nsk.su>...
>Sorry, I told not clear what I mean. :(
>
>I ment format for writing to file by write function. I took mistake when
>call it 'template'. :(
>For example:
>
>#format for file
>format k=
>@<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<< |
>$f_name
>@<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<< |
>$f_passw
>@<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<< |
>$f_time
>.
>
>Thanks for your help.
>
>Paul
>
------------------------------
Date: 30 Aug 2000 04:08:18 +1100
From: "Kiel Stirling" <taboo@comcen.com.au>
Subject: Re: Creating seperate HTML files via CGI script
Message-Id: <39abee02$1_1@nexus.comcen.com.au>
gallantknave <gallantknave@my-deja.com> wrote:
>Hello,
>I would like to know if it's possible for a cgi script to automatically
>create seperate HTML files for each message posted on a bulletin board
>so as to create a link to the individual message when listed in a index
>page of the message entries.
As each post is submited print to to a file
ie,
$post="The MSG from the form";
open FILE_HANDLE, "path-to-file";
print FILE_HANDEL "<html>\n<body>\n$post\n</body>\n</html>";
close FILE_HANDEL;
#then maybe redirect then to the file
print "Location: http://new.file.url\n\n";
-Kiel Stirling
------------------------------
Date: Wed, 30 Aug 2000 11:31:09 +0200
From: Matthias Jaekle <ntw6maja@fht-esslingen.de>
Subject: Distributed System
Message-Id: <39ACD45D.9547C195@fht-esslingen.de>
Hello,
I am using the Perlmodules RPC::PlServer and Client to source
out some big calculating functions to other computers.
Now I am looking for an possibility, that all PlServers on the
different computers register at a main server, tell them which
functions their PlServer offers and their current workload.
On the basis of this information the main server should pass
its tasks to a low occupied PlServer.
Are there allready Perl modules for this tasks, or perl
modules which make it simple to programm a load distributing
system like this ?
Thanks for your reply
Bye
Matthias Jaekle
------------------------------
Date: Wed, 30 Aug 2000 11:24:17 +0200
From: Erik Terpstra <erik@solidcode.net>
Subject: Emulating a browser.
Message-Id: <39ACD2C1.A560FBC1@solidcode.net>
Hi,
I am using the source below to emulate a browser (I know there are
already lots of tools doing this, I also have seen LWP, but this is just
for educational purposes).
The problem is when I try to connect to my local web server using:
./browser localhost 80
I get a useful response, but when I try to access any other domain name
like:
./browser www.google.com 80
I don't get anything back at all. I have a direct connection to the
internet and I get a ping reply from those domain names.
Does anybody know what I am doing wrong here?
TIA,
Erik.
------ sourcecode for 'browser' ----------------------------------
#!/usr/bin/perl
use Socket;
$SIG{'INT'}='suicide';
socket(S,2,1,6) || die "socket: $!";
connect(S,sockaddr_in($ARGV[1],inet_aton($ARGV[0]))) || die("connect:
$!");
select(S);$|=1;select(STDOUT);
print S "GET / HTTP/1.0\n\n";
print '-'x80;print "\n";
foreach(<S>){
print;
}
print '-'x80;print "\n";
&suicide;
sub suicide{
defined(S) && close(S);
print "Exiting now...\n";
exit;
}
------------------------------
Date: Wed, 30 Aug 2000 08:36:22 GMT
From: daniele7029@my-deja.com
Subject: error displaying with Perl compilator
Message-Id: <8oih25$mas$1@nnrp1.deja.com>
Hi,
I m newly Perl programmer and I had downloaded ActivePerl.
When I running compilator into Dos session (I have also window 98)
lot of errors appears, as commun, but I can t cath the beginning
of errors.
I fact I d like to know how to send errors into a file like error.txt.
I try use perl my_program.txt | more or perl my_program.txt > error.txt
or use STDERR=error.txt but I doesn t work...
I will very happy of your help.
Thanks a lot.
Daniele
Sent via Deja.com http://www.deja.com/
Before you buy.
------------------------------
Date: Wed, 30 Aug 2000 11:14:57 +0200
From: "Lincoln Marr" <lincolnmarr@nospam.europem01.nt.com>
Subject: file locking not working
Message-Id: <8oijbu$jdi$1@qnsgh006.europe.nortel.com>
I'm on HP-UX 10 and using Perl's flock function doesn't seem to be working
for me. I have the O'Reilly CD bookshelf which comments that flock behaves
like a traffic light - it's signals to stop don't have to be obeyed.
What I have is a CGI script, and I have the usual:
$EXCLUSIVE=2;
$UNLOCK=8;
open(FILE,">>$file") || die "Can't open file, $!\n";
flock FILE, $EXCLUSIVE;
seek FILE, 0, 2;
print FILE "$record\n";
flock FILE, $UNLOCK;
close(FILE);
My thinking is that flock only works if another process tries to use the
file outside of my script... so the problem is that if two or more people
simultaneously press the submit button on my form (invoking the above code)
then the file structure risks corruption.
I know this may be more of a unix question but I'm stumped at the moment and
was wondering if there's any other perl command to firmly lock a file?? If
not does anybody know what's going on here?
Thanks
--Lincoln
------------------------------
Date: Wed, 30 Aug 2000 16:13:30 +0800
From: "Mo Jiazhou" <isc80031@nus.edu.sg>
Subject: Re: get newsfeeds from a content site with perl?
Message-Id: <22E71DAEC504D111B78100805FFE9DC73E8EA089@pfs21.ex.nus.edu.sg>
well, i may misunderstand what u wanted to mean, my english
is bad. so, i want to say sorry to u.
i am not a newbie in perl, but, still get a lot to learn.
thx.
"Martien Verbruggen" <mgjv@verbruggen.comdyn.com.au> wrote in message
news:slrn8qot2l.ra.mgjv@verbruggen.comdyn.com.au...
> [please in the future, put your reply after the suitably shortened
> text you reply to. It makes reading messages much easier. Thanks]
>
> On Wed, 30 Aug 2000 10:32:11 +0800,
> Wowo <mojiazho@hotmail.com> wrote:
> > Martien Verbruggen <mgjv@verbruggen.comdyn.com.au> wrote in message
> > news:slrn8qmhp9.ra.mgjv@verbruggen.comdyn.com.au...
> > > On Tue, 29 Aug 2000 12:42:43 +0800,
> > > Mo Jiazhou <isc80031@nus.edu.sg> wrote:
> > > > hi, people:
> > > >
> > > > how to get newsfeeds from another site, eg, a newspaper's site,
> > > > with perl scripts? is there any place i can find sample code? or
> > > > i can learn more about this?
> > >
> > > I suppose you mean you want to read HTML pages from a Web site?
> > >
> > > You want to have a look at the LWP modules. You can get them from
> > > CPAN: http://www.cpan.org/
> >
> > oh, i guess u don't even know what it is newsfeeds.
>
> I know what _I_ mean by newsfeed. I can come up with lots of other
> possible interpretations of the same word. I also know what 99% of the
> posters mean when they say 'other site' on this group. That's what I
> went on. Your question was unclear, you got an answer from someone who
> misunderstood it. If you don't like that, you should be more precise.
>
> > but never mind, i have work it out by myself.
>
> Well.. I'm still not 100% clear on what you mean. Do you mean you want
> to write a client that accesses a news server using the NNTP protocol?
> You probably discovered that there are a few modules for that. I
> personally don't bother writing this stuff myself, and use slrnpull or
> more ideally, leafnode. To get a real newsfeed, you'll have to install
> a real local newsserver, and talk to the admin of the site you want
> the feed from.
>
> > do u mean that my question is stupid? oh, it may be. but
> > u got a wrong answer. and, there are other more stupid
> > question in this group, don't u think so?
>
> I didn't think it was stupid. I just misunderstood, and therefore
> obviously thought it was unclear.
>
> > u will know if u read all the post carefully.
>
> Nope. Reread it, several times. It's still ambiguous and unclear to
> me. Part of it may be the language problem, but I honestly just simply
> misunderstood the first time, and am still not entirely clear on what
> you want.
>
> > thanks for your replay:-)
>
> No problem.
>
> Martien
> --
> Martien Verbruggen |
> Interactive Media Division | If at first you don't succeed, try
> Commercial Dynamics Pty. Ltd. | again. Then quit; there's no use
> NSW, Australia | being a damn fool about it.
------------------------------
Date: Wed, 30 Aug 2000 08:55:39 GMT
From: mexicanmeatballs@my-deja.com
Subject: Re: Get own machine's dial-up IP address?
Message-Id: <8oii65$nif$1@nnrp1.deja.com>
In article <MPG.1415bd89286c779d9898f5@news.onlynews.com>,
Randall Parker <rgparker@west.net> wrote:
> Okay, what is IPPROTO_IP? Is it suppose to be your own IP address?
*Embarrased look*
Erm.. should read:
#!/usr/bin/perl -w
use strict;
use Socket;
my $proto = getprotobyname("udp");
socket(SOCKET, PF_INET, SOCK_DGRAM, $proto);
connect(SOCKET, sockaddr_in(0, inet_aton('27.0.0.1')));
my ($port, @addr) = unpack_sockaddr_in(getsockname(SOCKET));
print join("\n", map {inet_ntoa($_)} @addr);
This works for me, however I only have one adapter here to try it on,
so I have no idea what you will actually get back.
The getsockname says it returns the address of this end of the
connection. I expect (Although I can't try it) that since each adapter
has a different netmask associated with it (What happens with
multi-ppp?) you would have to specify an address that would exist
outside the adapter you are interested in.
This holds true for loopback, if I change the '27.0.0.1' to 127.0.0.1
it gives 127.0.0.1 with the fictional 27.0.0.1 above it gives the ip
address of my ethernet adapter.
> > This is pretty grim I only post it because I couldn't find another
way.
> > (Probably staring me in the face)
> Well, no one else seems to know either. So it can't be all that
obvious.
>
> I tihnk maybe I should go and make a socket connection to something on
> the internet in order to find out which of my addresses is the address
I
> present to the internet. But how would I query a socket I create to
ask
> it what my own address is on that socket?
That's almost exactly what the code above is intended to do, using a
UDP (connectionless) socket it shouldn't matter if the remote host
exists or not.
These two lines extract the local IP address associated with a socket:
my ($port, @addr) = unpack_sockaddr_in(getsockname(SOCKET));
print join("\n", map {inet_ntoa($_)} @addr);
I haven't tried this on NT either but it's all standard calls so it
should work. YMMV
--
Jon
perl -e '$_="MrqEdunhuClqdph1frp"; print map {chr(ord($_)-3)} split //;'
Sent via Deja.com http://www.deja.com/
Before you buy.
------------------------------
Date: Wed, 30 Aug 2000 04:20:14 GMT
From: daniel@chetlin.com (Daniel Chetlin)
Subject: Re: Getting the greedy RegEx, wanting the Lazy - help?
Message-Id: <2Y%q5.10112$D7.437538@news-west.usenetserver.com>
On Wed, 30 Aug 2000 02:57:00 GMT,
ptomsic@my-deja.com <ptomsic@my-deja.com> wrote:
> Okay:
> You're requesting a better spec of what I'm trying to do..
[snip]
> then parse it apart for two flags, a <!-- BEGIN STUFF--> and an
> <!---END STUFF--> marker. Whatever is in-between, is exactly what I
> need, but those markers are not consistent across each file
[snip]
> I'm looking for that combo (at least one less than, one bang, at
> least one hyphen, the word BEGIN followed by the word STUFF, at
> least one hyphen, and a greater than) to START The DESIRED content,
> then it will be terminated by the same thing, but END STUFF is the
> key words.
[snip]
> <TD><T><TH><TABLE><B><B>/<B>blahblahblah</B></Table><!--- BEGIN
> STUFF-->this\n\n\t
> is the desired TEXT<!END><!--END stuff-->ALL this can be disregarded<!--
> END STUFF-->
>
> So the end result would be simply the string containing
>
> this is the desired TEXT
Here's what I just hacked up; I tested it on some data but not too much.
use HTML::Parser;
sub begin_comment {
my ($self,$token) = @_;
goto &{$self->handler(default)} unless $token =~ /begin\s+stuff/i;
$self->handler(default => sub {print shift}, "text");
$self->handler(comment => \&end_comment, "self,token0");
}
sub end_comment {
my ($self,$token) = @_;
goto &{$self->handler(default)} unless $token =~ /end\s+stuff/i;
$self->eof;
}
my $p = HTML::Parser->new(api_version=>3);
$p->handler(comment => \&begin_comment,"self,token0");
$p->handler(default => "");
$p->parse($_);
$p->eof;
__END__
I'm fairly sure that what you specified for the 'begin stuff' and 'end stuff'
markers falls into the category of a "valid" HTML comment in that it's not
really RFC compliant but HTML::Parser will grok it anyways.
Basically what we do is wait to install a useful default handler until we see
the 'begin stuff' comment, and then we continue to produce exactly what we see
(C<print shift>) until we see 'end stuff'.
I'll leave the whitespace munging up to you; you should be able to drop into
place whatever s/// or tr/// you want to do in the sub that is installed on
line 3 of &begin_comment.
Let me know if this doesn't work on any given input; like I said above, it's
far from well tested.
-dlc
------------------------------
Date: 30 Aug 2000 04:21:35 +1100
From: "Kiel Stirling" <taboo@comcen.com.au>
Subject: Re: Glob errors?
Message-Id: <39abf11f_3@nexus.comcen.com.au>
"Mike Mesarch" <mmesarch@wcom.net> wrote:
>I am running perl on an NT box and this glob line is causing a problem. As>a note I stole the code from a script I wrote in Solaris which worked fine.
>I am essentially just running a script to recurse through directories. If
>it is a directory I want it to do something special and recurse through it.
>The problem lies when a directory has a space in the name. For example the
>directory M:\Compaq Support now becomes M:./Compaq. Below is the line and
>the sub causing the problem. Any help would be appreciated. As you can
>tell by the code I am no guru.
>Thanks!
>-Mike
>
><line causing problems>
>foreach $file (glob("$dir\\*"))
>
><the entire sub>
>sub printcontents {
> my $dir = shift;
> foreach $file (glob("$dir\\*"))
> {
> next if ($file eq ".");
> next if ($file eq "..");
>
>($dev,$ino,$mode,$nlink,$uid,$gid,$rdev,$size,$atime,$mtime,$ctime,$blksize,
>$blocks) = stat($file);
> if (substr($mode, 0, 2) == 16)
> {
> printcontents($file);
> }
> }
>}
>
I would try replacing any white spaces with %20 or maybe an _.
Not to clear on the sprintf function but I think it could do it.
-Kiel Stirling
------------------------------
Date: Wed, 30 Aug 2000 16:13:29 +0800
From: "Mo Jiazhou" <isc80031@nus.edu.sg>
Subject: help in newfeeds
Message-Id: <22E71DAEC504D111B78100805FFE9DC73E8EA085@pfs21.ex.nus.edu.sg>
hi, people, how do i draw news feed from another content site by perl?
any one is familiar with this? where can i find some sample code? or where
can i know more about it?
thx in advance!
regards,
wowo
------------------------------
Date: Wed, 30 Aug 2000 10:39:38 +0200
From: "Dr. Peter Dintelmann" <Peter.Dintelmann@dresdner-bank.com>
Subject: Re: help in newfeeds
Message-Id: <8oih8r$d571@intranews.bank.dresdner.net>
Hi,
Mo Jiazhou schrieb in Nachricht
<22E71DAEC504D111B78100805FFE9DC73E8EA085@pfs21.ex.nus.edu.sg>...
>hi, people, how do i draw news feed from another content site by perl?
I am not sure, but maybe a look
at the Net::NNTP module might help.
Best regards,
Peter Dintelmann
------------------------------
Date: 30 Aug 2000 08:17:46 GMT
From: vek@pharmnl.ohout.pharmapartners.nl (Villy Kruse)
Subject: Re: hour difference between localtime and POSIX::mktime
Message-Id: <slrn8qpgop.d2n.vek@pharmnl.ohout.pharmapartners.nl>
On Tue, 29 Aug 2000 17:37:17 GMT,
steinra@my-deja.com <steinra@my-deja.com> wrote:
>My main mistake was that I forgot I was in daylight savings time and
>need to set the flag to mktime appropriately. Anywhere where daylight
>savings time is not used this would have worked just fine. So I am glad
>I caught it now rather than coding the program and getting hit with a
>problem in spring when daylight savings time kicks in.
>
>Thank you for you input!
>
>Randy
>
>
That raises the question, what is the codifed POSIX behaviour of tm_isdst
when used as input to mktime? I tested on two systems; one ignores
tm_isdst and the other don't when calling mktime.
The default of 0 for the isdst argument seems not to be the most useful
choice; the value -1, I would think, would a better default. Thus, if
you don't make an explicit decission you will get the time zone flag
which will normally be in effect for the time you try to convert.
This relates to the recent discussion of standardizing Perl, where some
people find inconsistencies between releases of perl.
--
Villy
------------------------------
Date: 30 Aug 2000 06:13:27 GMT
From: abigail@foad.org (Abigail)
Subject: Re: How can I sort using two fields?
Message-Id: <slrn8qp9em.bbg.abigail@alexandra.foad.org>
Abigail (abigail@foad.org) wrote on MMDLVI September MCMXCIII in
<URL:news:slrn8qoukg.bbg.abigail@alexandra.foad.org>:
``
`` One could use a simple radix sort.
``
`` foreach my $k (reverse (4, 2)) {
`` my $key = $k - 1;
`` my %radix;
`` foreach (@data) {push @{$radix {(split /\|/)[$key]}} => $_}
`` @links = map {@{$radix {$_}}} sort keys %radix;
`` }
That should be:
foreach my $k (reverse (4, 2)) {
my $key = $k - 1;
my %radix;
foreach (@links) {push @{$radix {(split /\|/)[$key]}} => $_}
@links = map {@{$radix {$_}}} sort keys %radix;
}
Abigail
--
$; # A lone dollar?
=$"; # Pod?
$; # The return of the lone dollar?
{Just=>another=>Perl=>Hacker=>} # Bare block?
=$/; # More pod?
print%; # No right operand for %?
------------------------------
Date: Tue, 29 Aug 2000 23:46:30 -0500 (CDT)
From: dennis100@webtv.net (BUCK NAKED1)
Subject: Re: How to Unzip a .tar.gz file
Message-Id: <26879-39AC91A6-97@storefull-242.iap.bryant.webtv.net>
>>dennis100@webtv.net (BUCK >>NAKED1) wrote:
>>PS to Keith: FWIW, whataman is
>>my pc addy and bucknaked is my
>>webtv addy. It depends on which >>machine that I am posting from.
>kcivey@cpcug.org (Keith=A0Calvert
>Ivey) wrote:
>Have you considered that people
>might respond better if you used names >that made you appear to be more
than >12 years old? It's your decision,
>of course.
Of course it's my decision, and I don't think they make me sound like a
12-yr-old. But, since you brought it up...
I chose those names to be humorous, and many people have acknowledged
getting a good laugh out of them. There are also valued personal stories
behind choosing each of those usernames. Further, I won't change names
just for a certain newsgroup, or to try and appease the judgmental folk
on the net.
Would I use them in business? Of course not, but this is just the
internet. Your OT comment reminds me of a college professor I had 30
years ago. He was really boring... a real stick-in-the-mud, ya know.
Enough about my name... Now can we please get back to perl?
--Regards,
from What A Bucknaked Man! :)
------------------------------
Date: Wed, 30 Aug 2000 10:25:16 +0200
From: "Gabo" <gtinti@datalogic.it>
Subject: I can't execute Perlscript on ServerSide
Message-Id: <8oigbp$a29$1@zamboni.dsnet.it>
HI,
I install Apache 1.3 and ActivePerl 5.6 with PerlScript support.
My cgis writing in Perl run correctly, but I can't execute a Hello World
script in PerlScript runnning on server.
I hope in a idea
Thanks
Gabo
------------------------------
Date: Wed, 30 Aug 2000 10:45:01 +0200
From: "Dr. Peter Dintelmann" <Peter.Dintelmann@dresdner-bank.com>
Subject: Re: I can't execute Perlscript on ServerSide
Message-Id: <8oihiu$d501@intranews.bank.dresdner.net>
Hi,
Gabo schrieb in Nachricht <8oigbp$a29$1@zamboni.dsnet.it>...
>HI,
> I install Apache 1.3 and ActivePerl 5.6 with PerlScript support.
>
>My cgis writing in Perl run correctly, but I can't execute a Hello World
i.e. 'print "Hello World\n";'?
Make sure you send at least a Content-type header.
>script in PerlScript runnning on server.
you had of course a look at the webserver's
error log. What did it tell you?
Make sure you have execute permission on
your script for the user running the httpd.
BTW: On the Apache website you will find
excellent documentation on Apache+Perl.
Best regards,
Peter Dintelmann
------------------------------
Date: Wed, 30 Aug 2000 11:01:14 +0200
From: "Dr. Peter Dintelmann" <Peter.Dintelmann@dresdner-bank.com>
Subject: Re: I can't execute Perlscript on ServerSide
Message-Id: <8oiihb$d5b1@intranews.bank.dresdner.net>
to clarify things:
>Gabo schrieb in Nachricht <8oigbp$a29$1@zamboni.dsnet.it>...
>>HI,
>> I install Apache 1.3 and ActivePerl 5.6 with PerlScript support.
I should read more carefully. It's ASP...
>>My cgis writing in Perl run correctly, but I can't execute a Hello World
it is _not_ cgi.
"hello world" is...
<%@ LANGUAGE = PerlScript %>
<HTML><HEAD><TITLE>First ASP in PerlScript</TITLE></HEAD>
<BODY bgcolor="#CCFFFF" text="#330099"><H1>
<SCRIPT LANGUAGE="PerlScript" RUNAT=Server>
$Response->write("Hello world!");
</SCRIPT>
</H1></BODY></HTML>
Peter
------------------------------
Date: 16 Sep 99 21:33:47 GMT (Last modified)
From: Perl-Users-Request@ruby.oce.orst.edu (Perl-Users-Digest Admin)
Subject: Digest Administrivia (Last modified: 16 Sep 99)
Message-Id: <null>
Administrivia:
The Perl-Users Digest is a retransmission of the USENET newsgroup
comp.lang.perl.misc. For subscription or unsubscription requests, send
the single line:
subscribe perl-users
or:
unsubscribe perl-users
to almanac@ruby.oce.orst.edu.
| NOTE: The mail to news gateway, and thus the ability to submit articles
| through this service to the newsgroup, has been removed. I do not have
| time to individually vet each article to make sure that someone isn't
| abusing the service, and I no longer have any desire to waste my time
| dealing with the campus admins when some fool complains to them about an
| article that has come through the gateway instead of complaining
| to the source.
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 V9 Issue 4173
**************************************