[8845] in Perl-Users-Digest
Perl-Users Digest, Issue: 2462 Volume: 8
daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Thu Apr 30 07:07:15 1998
Date: Thu, 30 Apr 98 04:00:31 -0700
From: Perl-Users Digest <Perl-Users-Request@ruby.OCE.ORST.EDU>
To: Perl-Users@ruby.OCE.ORST.EDU (Perl-Users Digest)
Perl-Users Digest Thu, 30 Apr 1998 Volume: 8 Number: 2462
Today's topics:
Re: 4 digit year and localtime <Tony.Curtis+usenet@vcpc.univie.ac.at>
Re: 4 digit year and localtime <qdtcall@esb.ericsson.se>
Re: backreferencing trouble <qdtcall@esb.ericsson.se>
Re: backreferencing trouble <dorr@cetrel.lu>
Re: Bible References converted into Text (Andy Wardley)
Re: Dateinamen + Datum letzte Aenderung (File, last mod <quednauf@nortel.co.uk>
Re: Defending Perl (Bart Lateur)
Re: GetOpts::Std and use strict <Tony.Curtis+usenet@vcpc.univie.ac.at>
Re: GetOpts::Std and use strict (Tom Grydeland)
getting the code of a compiled sub... gampid@hotmail.com
Re: getting the code of a compiled sub... <tchrist@mox.perl.com>
Re: Help-Perl misread Env variable <zmalino@rocketmail.com>
Re: Helping each other (was: Credit Card Verification) (Bart Lateur)
Re: How to do sort -u within perl? (Tom Grydeland)
Re: How to find the number of matches in a string <jhi@alpha.hut.fi>
Re: instruction if-elsif-elsif insert on a for loop <info@atig.fr>
Ongoing E-Mail flood by mikes@activestate.com (Marc Haber)
Re: perl guts <rootbeer@teleport.com>
Perl/CGI scripts from UNIX to Macintosh/MacPerl? <mefe@TTusa.net>
Reading Perl scripts <bashan@shani.com>
Re: Reg Exp problem sloop@mailcity.com
Retrieve HTML FORM POST info within CGI Perl Program <snay@primenet.com>
Script to parse HTML, converting img tags to text (Adam)
Re: Script to parse HTML, converting img tags to text <aas@sn.no>
Re: Simple Question regarding dates <egwong@netcom.com>
Re: Simple Question regarding dates (Tom Grydeland)
SMTP and sockets (Bart Lateur)
snoop-like util in Perl ? audttjk@dbs.com.sg
Re: snoop-like util in Perl ? (Michael Fuhr)
Re: Thank you Solutionsoft <dformosa@st.nepean.uws.edu.au>
use of soubroutines ? <cs@mechb.uni-stuttgart.de>
Re: use of soubroutines ? <perlguy@inlink.com>
Re: You people want Perl to be popular? (Bart Lateur)
Digest Administrivia (Last modified: 8 Mar 97) (Perl-Users-Digest Admin)
----------------------------------------------------------------------
Date: 30 Apr 1998 11:05:07 +0200
From: Tony Curtis <Tony.Curtis+usenet@vcpc.univie.ac.at>
Subject: Re: 4 digit year and localtime
Message-Id: <7x67jrsmrg.fsf@beavis.vcpc.univie.ac.at>
Re: 4 digit year and localtime, kevin <kevscott@juno.com>
said:
kevin> Is there a way to get perl to return a 4 digit year
kevin> from the operating system?
kevin> The only solution I know of is to parse the output of
kevin> an external programe.
Yuk :-)
use POSIX qw(strftime localtime);
my $yyyy = POSIX::strftime("%Y", POSIX::localtime(time));
--
Tony Curtis, Systems Manager, VCPC, | Tel +43 1 310 93 96 - 12; Fax - 13
Liechtensteinstrasse 22, A-1090 Wien, AT | http://www.vcpc.univie.ac.at/
"You see? You see? Your stupid minds! Stupid! Stupid!" ~ Eros, Plan9 fOS.
------------------------------
Date: 30 Apr 1998 11:17:03 +0200
From: Calle Dybedahl <qdtcall@esb.ericsson.se>
Subject: Re: 4 digit year and localtime
Message-Id: <is3eevsm7k.fsf@godzilla.kiere.ericsson.se>
kevin scott <kevscott@juno.com> writes:
> Is there a way to get perl to return a 4 digit year from the
> operating system? The only solution I know of is to parse the output
> of an external programe.
Have you tried reading the documentation for the localtime() function?
--
Calle Dybedahl, UNIX Sysadmin
qdtcall@esavionics.se http://www.lysator.liu.se/~calle/
------------------------------
Date: 30 Apr 1998 11:02:38 +0200
From: Calle Dybedahl <qdtcall@esb.ericsson.se>
Subject: Re: backreferencing trouble
Message-Id: <is67jrsmvl.fsf@godzilla.kiere.ericsson.se>
"Andreas Olsson" <seo@sorona.se> writes:
> Why doesn't $idobj hold the number of substitutions instead of the text
> within the parentethies in the following code?
I can't replicate the behaviour you describe, but unless you put a g
modifier on your substitution the number of substitutions will always
be zero (which is returned as an empty string, in this case) or one.
--
Calle Dybedahl, UNIX Sysadmin
qdtcall@esavionics.se http://www.lysator.liu.se/~calle/
------------------------------
Date: Thu, 30 Apr 1998 11:33:04 +0200
From: Denis DORR <dorr@cetrel.lu>
Subject: Re: backreferencing trouble
Message-Id: <35484550.3C12CCCB@cetrel.lu>
Andreas Olsson wrote:
>
> Why doesn't $idobj hold the number of substitutions instead of the text
> within the parentethies in the following code?
>
> ($idobj) = $srcobj =~ s#<OBJSRC$id>(.*?)</OBJSRC$id>##s;
>
> But here it's correct.
>
> ($idobj) = $srcobj =~ m#<OBJSRC$id>(.*?)</OBJSRC$id>#s;
>
> I wan't to save and erase at the same time.
>
> Please help me.
> my email is niclas@nillgraf.se
>
> Niclas Lindberg
Don't understand : your code is doing what it is supposed to do : $idobj
contains the number of substitutions.
( see perldoc perlop for the return of bind operator)
But maybe do you want to retrieve something from the matching string
into $idobj ?
So, what about :
$idobj = $1 if $srcobj =~ s#<OBJSRC$id>(.*?)</OBJSRC$id>##s;
Or did I completely misunderstand your problem ?
--
HTH.
dorr@cetrel.lu
------------------------------
Date: Thu, 30 Apr 1998 08:23:20 GMT
From: abw@cre.canon.co.uk (Andy Wardley)
Subject: Re: Bible References converted into Text
Message-Id: <Es7wMw.Eqv@cre.canon.co.uk>
Arthur Gibbs wrote:
>Yes the problem is converting the references. 1 John 3:16-18,20 means 16
>through 18 and then 20 by itself. 1 John 3:16-17;4:1-2 means 16 through 17
>and then change to chapter 4 and get verses 1 through 2. And so on.
Try this. I had something similar and quickly hacked a few changes.
The split_range() function takes a string and converts it into a
hash array which contains a breakdown of the chapters and relevant
verses, stored in lists. The sample code shows it being used on your
two examples above.
Hope this helps.
A
#!/usr/bin/perl -w
use strict;
# test data
my @sections = (
'1 John 3:16-18,20',
'1 John 3:16-17;4:1-2'
);
foreach (@sections) {
print "SPLITTING: $_\n";
my $bibref = split_ranges($_);
print "BOOK: $bibref->{ BOOK }\n";
print "EXTRACTS:\n";
foreach my $extract (@{ $bibref->{ EXTRACTS } }) {
print " CHAPTER: $extract->{ CHAPTER }\n";
foreach my $verse (@{ $extract->{ VERSES } }) {
print " VERSE: $verse->[0] -> $verse->[1]\n";
}
}
}
sub split_ranges {
my $bibref = shift;
my $self = { };
my ($verse_list);
# TODO: add error checks. Return undef on failure.
# extract the book and list of verses
($self->{ BOOK }, $verse_list) = ($bibref =~ /(\d+\s+\S+)\s+(.*)/);
# split the verse list on ';'
foreach (split(/;/, $verse_list)) {
# split chapter and verse
my ($chapter, $verses) = split(/:/);
# save chapter
my $extract = { CHAPTER => $chapter };
# split verses and account for "<n>-<n>" format
foreach (split(/,/, $verses)) {
/(\d+)(?:-(\d+))?/;
push(@{ $extract->{ VERSES } }, [ $1, $2 || $1 ]);
}
# save extract onto a list
push(@{ $self->{ EXTRACTS } }, $extract);
}
return $self;
}
Output:
SPLITTING: 1 John 3:16-18,20
BOOK: 1 John
EXTRACTS:
CHAPTER: 3
VERSE: 16 -> 18
VERSE: 20 -> 20
SPLITTING: 1 John 3:16-17;4:1-2
BOOK: 1 John
EXTRACTS:
CHAPTER: 3
VERSE: 16 -> 17
CHAPTER: 4
VERSE: 1 -> 2
--
Andy Wardley <abw@kfs.org> Signature regenerating. Please remain seated.
<abw@cre.canon.co.uk> For a good time: http://www.kfs.org/~abw/
------------------------------
Date: Thu, 30 Apr 1998 11:18:03 +0100
From: "Frank L. Quednau" <quednauf@nortel.co.uk>
Subject: Re: Dateinamen + Datum letzte Aenderung (File, last modified time)
Message-Id: <35484FDA.CEDE2AFC@nortel.co.uk>
Gott, was sind die Leute empfindlich, wenn man mal ein wenig
Deutsch redet. Also:
use File::stat;
$status = stat($fullpath) or die p("Darn, that didn't work:$!");
#$fullpath ist der gesamte Pfad, plus die Datei. $status ist ein
Objekt, der alle Eigenschaften der Datei feshaelt.
$modtime = localtime($status->mtime);
#$modtime haelt jetzt die Zeit der letzten Aenderung bereit,
localtime formatiert den $status - Wert.
Hoffe, dass das hilft. Ansonsten die File::? Dokumentation mal
durchlesen, dort sind alle Eigenschaften einer Datei, die mit dem
Modul herausgelsen werden koennen, aufgelistet.
But please write in English the next time, so other people can
enjoy the fruits of our loins :)
Arne Steinbacher wrote:
> Hallo zusammen,
> wie bekomme ich eigentlich das Datum der letzten Aederung einer
> beliebigen Datei heraus?
> Danke.
>
> Arne
--
____________________________________________________________
Frank Quednau
Phone: +44 (0)1279 402447
http://www.surrey.ac.uk/~me51fq MailTo:F.L.Quednau@bnr.co.uk
____________________________________________________________
------------------------------
Date: Thu, 30 Apr 1998 08:00:22 GMT
From: bart.mediamind@tornado.be (Bart Lateur)
Subject: Re: Defending Perl
Message-Id: <354a2ad8.2520782@news.tornado.be>
Jaime Metcher wrote:
>Win32 - download binary distribution - type one command - agree to
>everything - toast Sarathy in fine Cabernet Sauvignon - back to work.
>--
>Jaime Metcher (extremely un-guru-like, but productive nonetheless)
Which should explain to the guru's why Wintel boxes are popular, besides
the lower hardware cost.
Bart.
------------------------------
Date: 30 Apr 1998 10:30:49 +0200
From: Tony Curtis <Tony.Curtis+usenet@vcpc.univie.ac.at>
Subject: Re: GetOpts::Std and use strict
Message-Id: <7xhg3b3e4m.fsf@beavis.vcpc.univie.ac.at>
Re: GetOpts::Std and use strict, Michael
<mikemort@cadence.com> said:
Michael> If I do "use strict" with getopts, then the
Michael> variables associated with the flags (such as
Michael> $opt_v) give compile time errors since they are not
Michael> declared, but if I declare them using "my" then it
Michael> hides the getopts values of those variables.
Michael> Is there a way of using getopts while still being
Michael> able to have "use strict"?
use strict;
use Getopt::Long;
my %opt;
GetOptions("f=s" => \$opt{'file'}, "d=n" => \$opt{'delay'});
hth
tony
--
Tony Curtis, Systems Manager, VCPC, | Tel +43 1 310 93 96 - 12; Fax - 13
Liechtensteinstrasse 22, A-1090 Wien, AT | http://www.vcpc.univie.ac.at/
"You see? You see? Your stupid minds! Stupid! Stupid!" ~ Eros, Plan9 fOS.
------------------------------
Date: 30 Apr 1998 09:53:47 GMT
From: Tom.Grydeland@phys.uit.no (Tom Grydeland)
Subject: Re: GetOpts::Std and use strict
Message-Id: <slrn6kgihb.qg.Tom.Grydeland@mitra.phys.uit.no>
On Wed, 29 Apr 1998 21:51:40 -0500,
Michael mortensen <mikemort@cadence.com> wrote:
> Is there a way of using getopts while still being able
> to have "use strict"?
Yes. Two ways
1) use vars qw/ $opt_a $opt_v /;
2) pass a reference to a hash to getopts.
See the docs for details
> Thanks in advance!
You're welcome
> - Michael Mortensen -
--
//Tom Grydeland <Tom.Grydeland@phys.uit.no>
------------------------------
Date: Thu, 30 Apr 1998 03:47:40 -0600
From: gampid@hotmail.com
Subject: getting the code of a compiled sub...
Message-Id: <6i9drc$5ov$1@nnrp1.dejanews.com>
I'm working on a config system and I wanted to know if there was a way to get
code or bytecode back from a compiled sub. What i'm doing is having various
configs stored as plain old perl subs and data structures in files, when a
config needs to be used it's loaded, and evaled. I'm using data dumper to
regenerate the data structures for writing back to the file if changes have
been made but I haven't been able to find out how 'get back' a writeable
version of the subs.
Does what i'm trying to do make sense? Can I do it?
-Evan
-----== Posted via Deja News, The Leader in Internet Discussion ==-----
http://www.dejanews.com/ Now offering spam-free web-based newsreading
------------------------------
Date: 30 Apr 1998 10:38:21 GMT
From: Tom Christiansen <tchrist@mox.perl.com>
Subject: Re: getting the code of a compiled sub...
Message-Id: <6i9kat$qdl$1@csnews.cs.colorado.edu>
[courtesy cc of this posting sent to cited author via email]
In comp.lang.perl.misc,
gampid@hotmail.com writes:
:I'm working on a config system and I wanted to know if there was a way to get
:code or bytecode back from a compiled sub. What i'm doing is having various
:configs stored as plain old perl subs and data structures in files, when a
:config needs to be used it's loaded, and evaled. I'm using data dumper to
:regenerate the data structures for writing back to the file if changes have
:been made but I haven't been able to find out how 'get back' a writeable
:version of the subs.
You can't really do this directly. You'd have to maintain a data
structure, maybe like this:
%functext = (
f1 => q! sub { .... } !,
f2 => q! sub { .... } !,
f3 => q! sub { .... } !,
);
foreach $name (keys %funcs) {
$text = $funcs{$name};
$code = eval $text; die if $@;
*$name = $code;
}
Sure seems like a lot of bother, and isn't generally applicable.
--tom
--
Tom Christiansen tchrist@jhereg.perl.com
: I've tried (in vi) "g/[a-z]\n[a-z]/s//_/"...but that doesn't
: cut it. Any ideas? (I take it that it may be a two-pass sort of solution).
In the first pass, install perl. :-) Larry Wall <6849@jpl-devvax.JPL.NASA.GOV>
------------------------------
Date: Thu, 30 Apr 1998 06:32:49 GMT
From: "Zbigniew Malinowski" <zmalino@rocketmail.com>
Subject: Re: Help-Perl misread Env variable
Message-Id: <lWU11.488$j41.316253@news.tpnet.pl>
100042.2616@compuserve.com <100042.2616@compuserve.com> wrote in message
<6i87l3$973$1@nnrp1.dejanews.com>...
>When I used $ENV to obtain the value of an environment variable, the value
>came back corrupted. Well, the English text came back fine. But I have a
few
>bytes non alphabetic text and they came back wrong. Any idea why? The
>program has just three lines:
>
> ---------- the output -----------
>Environmetal variable was set to QUERY_STRING=abc<FKc;zdef
>Data obtained through Env=abc,Ea/#def
>
>The alphabetic letters "abc" and "def" came throug, but "<FKc;z" become
>",Ea/#". Seems Perl used some kind of translation. How can I disable the
>translation?
>I am using Win 95, Perl for Win32, Build 316 - Mar 13, 1998
>from ActiveStates(ActiveWare)
Hello !
I'm not sure if this could help you :
I've found that Windows NT/95 is using different codepages for windowed
applications
and for MS-DOS window. In case of polish language it's using MSWIN1250
codepage
for Windows and CP852 for MS-DOS. They aren't the same.
In Windows NT you can change the MS-DOS codepage using such a command :
mode con cp select=1250
If you didn't forget to change your MS-DOS font to Lucida Console you should
see
Polish characters exactly as you see it in Notepad (for example).
However in Windows 95 it's not the same. COMMAND.COM is much more simplier
then NT CMD.EXE and you cannot change to 1250.
So I think its rather a problem of Windows and not of PERL. And you didn't
mention
how did you set the environmental variable.
Zbigniew Malinowski
PPWK S.A.
------------------------------
Date: Thu, 30 Apr 1998 08:00:24 GMT
From: bart.mediamind@tornado.be (Bart Lateur)
Subject: Re: Helping each other (was: Credit Card Verification)
Message-Id: <354b2c13.2835558@news.tornado.be>
Tom Phoenix wrote:
>Anyone on Usenet for any length of time will meet up
>with an adolescent who will earn respect by acting in an adult fashion.
Says Tom Phoenix, aged 15.
Kidding!
Bart.
------------------------------
Date: 30 Apr 1998 09:55:55 GMT
From: Tom.Grydeland@phys.uit.no (Tom Grydeland)
Subject: Re: How to do sort -u within perl?
Message-Id: <slrn6kgilb.qg.Tom.Grydeland@mitra.phys.uit.no>
On Wed, 29 Apr 1998 15:53:39 -0400 (EDT),
David Lee Lambert <davidl@pfaffben.user.msu.edu> wrote:
> What's a simple way to do the equivalent of 'sort -u' on a list in perl?
Some questions are asked more often than others. These are called
"Frequently Asked Questions", abbreviated FAQ.
In many cases, to avoid answering the same questions over and over,
some helpful soul compiles a list of such questions with authoritative
answers. It is commonly considered a minimum effort to search for such
a list and consult it before posting your problem to the newsgroup
-- especially if you're a beginner, since your problem is then even less
likely to be new. --
With your copy of perl, you should have received extensive
documentation, and the Perl FAQ is part of this documentation.
A search for the word "unique" in the headlines of the FAQ pages gives
only three hits:
perlfaq4.pod: =head2 How can I extract just the unique elements of an array?
perlfaq4.pod: =head2 How can I get the unique keys from two hashes?
perlfaq8.pod: =head2 How can I call my system's unique C functions from Perl?
--
//Tom Grydeland <Tom.Grydeland@phys.uit.no>
------------------------------
Date: 30 Apr 1998 13:22:17 +0300
From: Jarkko Hietaniemi <jhi@alpha.hut.fi>
Subject: Re: How to find the number of matches in a string
Message-Id: <oeeemyf623q.fsf@alpha.hut.fi>
abigail@fnx.com (Abigail) writes:
: Jarkko Hietaniemi (jhi@alpha.hut.fi) wrote on MDCCII September MCMXCIII
: in <URL: news:oeed8e0o03p.fsf@alpha.hut.fi>:
: ++
: ++ > $count++ while $string =~ m/pattern/g;
: ++ >
: ++ > $count = () = $string =~ m/pattern/g;
: ++
: ++ There is of course the point that the codes are not exactly
: ++ functionally equivalent.
: ++
: ++ [clickety click]
: ++
: ++ Now they are.
: ++
: ++ for ( $count = 0; $string =~ m/pattern/g; $count++ ) { }
: ++
: ++ $count = () = $string =~ m/pattern/g;
:
:
: They aren't. In the second case, =~ is being evaluated in a list context,
Their they or my they? :-) I can argue that mine are, if you think of
the snippets as black boxes as far as the value of $count before and
after is concerned. My only actual point was that the zeroing $count
was needed for the first case to be idempotent, as the second one
already was.
: while in the first case, repeatedly in scalar context. I am not at
: all suprised that post incrementing beats building a list and throwing
: it away.
:
:
:
: Abigail
: --
: perl -wle '$, = " "; sub AUTOLOAD {($AUTOLOAD =~ /::(.*)/) [0];}
: print+Just (), another (), Perl (), Hacker ();'
--
$jhi++; # http://www.iki.fi/~jhi/
# There is this special biologist word we use for 'stable'.
# It is 'dead'. -- Jack Cohen
------------------------------
Date: Thu, 30 Apr 1998 09:02:24 +0200
From: "Stiphanie gaye" <info@atig.fr>
Subject: Re: instruction if-elsif-elsif insert on a for loop
Message-Id: <6i97qk$i2a$1@minus.oleane.net>
Gabor a icrit dans le message ...
>In comp.lang.perl.misc, Stiphanie gaye <info@atig.fr> wrote :
># hello!
>#
># is it possible to insert an instruction if-elsif-elsif in a "for" loop?
># example :
># for( ; ; ){
># if ( ){ };
># elsif ( ) { };
># elsif ( ) { };
># }
>
>Yes, why didn't you at least try it before you posted. ;)
i've done it :)
but in a program that doesn't work well,
and i wasn't sure about the error source.
thanks you for your advice :)
stephanie gaye
info@atig.fr
------------------------------
Date: Thu, 30 Apr 1998 10:10:37 GMT
From: Marc.Haber-usenet@gmx.de (Marc Haber)
Subject: Ongoing E-Mail flood by mikes@activestate.com
Message-Id: <6i9ioi$1oo$3@nz12.rz.uni-karlsruhe.de>
Hi!
Active State is sending out "Short Notes to reming everyone that there
are only a couple of days left to purchase PerlEx at the preview
prive".
I have received this notice _five_ times, the flood is still ongoing.
Can anyone confirm this?
Greetings
Marc
--
-------------------------------------- !! No courtesy copies, please !! -----
Marc Haber | " Questions are the | Mailadresse im Header
Karlsruhe, Germany | Beginning of Wisdom " | Fon: *49 721 966 32 15
Nordisch by Nature | Lt. Worf, TNG "Rightful Heir" | Fax: *49 721 966 31 29
------------------------------
Date: Thu, 30 Apr 1998 06:41:55 GMT
From: Tom Phoenix <rootbeer@teleport.com>
To: Bruce Woodward <bruce@scientia.com.au>
Subject: Re: perl guts
Message-Id: <Pine.GSO.3.96.980429232536.10138J-100000@user2.teleport.com>
On Thu, 30 Apr 1998, Bruce Woodward wrote:
> perl has a function av_fetch, in av.c, which returns a given element of
> an array. It seems that arrays, in perl are made of linked lists.
Gee, I hope not! :-) That would be terribly slow for arrays of millions
of elemens, and Perl isn't that way. A quick test with Benchmark confirms
it: Setting element 1 takes about as much time as element 1_000 or element
1_000_000 (if the array is already that long, of course).
> It also looks like this function loops through the array until it come
> to the desired element number. Is this correct?
My copy of av_fetch has lines like this one...
return &AvARRAY(av)[key];
...which looks to me as if Perl arrays are, in fact, arrays. :-) I don't
see any looping in av_fetch itself, though that may be because my C skills
are pretty rusty. :-)
There's some good information about Perl's internals in chapter 20 of
Advanced Perl Programming, and online at the PerlGuts Illustrated page, as
well as (of course) the perlguts manpage.
http://home.sol.no/~aas/perl/guts/
Hope this helps!
--
Tom Phoenix Perl Training and Hacking Esperanto
Randal Schwartz Case: http://www.rahul.net/jeffrey/ovs/
------------------------------
Date: Wed, 29 Apr 1998 22:43:14 -0700
From: "M.EFE" <mefe@TTusa.net>
Subject: Perl/CGI scripts from UNIX to Macintosh/MacPerl?
Message-Id: <35480F71.926258C9@TTusa.net>
Hello,
Can anyone help me about how to convert a Perl/Cgi script to install it
and make it work on a Mac server with MacPerl?
Is there any certain way or any guide/manuel to translate them for
MacPerl...
One of the scripts I need to convert is an online file manager...
Thanks in advance...
--
M.EFE_______________________
mailto:mefe@TTusa.net
----------------------------
>>>>! You Must Remove the 'TT'
from my address to Mail Me !<<<<
--------------------------------
------------------------------
Date: Thu, 30 Apr 1998 11:09:56 +0300
From: Guy Bashan <bashan@shani.com>
Subject: Reading Perl scripts
Message-Id: <354831D4.614F466@shani.com>
This is a multi-part message in MIME format.
--------------718836F7C5E7E7542D7069E7
Content-Type: text/plain; charset=us-ascii
Content-Transfer-Encoding: 7bit
Sorry about the questions - I'm quite new to perl, and just messing
around . . .
I'm using "Microsoft Personal Server", How can my server know how to run
the perl scripts ???
Is there a way to tell the server the location of PERL, or can it read
PERL scripts by itself ?
thanks. Bashan.
--------------718836F7C5E7E7542D7069E7
Content-Type: text/x-vcard; charset=us-ascii; name="vcard.vcf"
Content-Transfer-Encoding: 7bit
Content-Description: Card for Guy Bashan
Content-Disposition: attachment; filename="vcard.vcf"
begin: vcard
fn: Guy Bashan
n: Bashan;Guy
email;internet: bashan@shani.com
x-mozilla-cpt: ;0
x-mozilla-html: TRUE
version: 2.1
end: vcard
--------------718836F7C5E7E7542D7069E7--
------------------------------
Date: Thu, 30 Apr 1998 08:26:31 GMT
From: sloop@mailcity.com
Subject: Re: Reg Exp problem
Message-Id: <35483585.5237400@news.xmission.com>
On Wed, 29 Apr 1998 00:45:58 -0600, troxel@sammcgees.com wrote:
>
>> ++ Any pointers on an example or module that would help would be greatly
>> ++ appreciated.
>>
>> I think people who are not able to search CPAN should not be given
>> task that require more than 2 lines of code.
>>
>> Abigail
>
>Well exxxccccuuuusssee me. I did search CPAN and did not find anything
>that would even come close to helping with my specific problem.
Thanks for punctuating Abigail's point.
------------------------------
Date: 30 Apr 1998 01:58:01 -0700
From: snay <snay@primenet.com>
Subject: Retrieve HTML FORM POST info within CGI Perl Program
Message-Id: <35483CCA.40C69178@primenet.com>
Someone (Pat I belive) asked for the solution to the problem I had.
Problem: Need to contact a cgi script sending it all the parameters with
method post, then search through returned page for what I'm looking for.
In specific, I was trying to figure out how to contact UPS's site to
extract shipping costs using weight, insurance value, and to-from ZIP
codes. Here is the code I worked up: (it works by the way)
Lemme start by apologizing, my code is a little messy I wasn't planning
on posting it to a newsgroup, I just realized 12 days later that someone
wanted the solution I figured out... (BTW: I am a newbie.. so also
excuse whatever else) so here goes:
#!/usr/bin/perl
print "Content-type: text/html\n\n";
%form=(accept_UPS_license_agreement=>'yes', '10_action'=>'3',
'13_product'=>'GNDRES', '15_origPostal'=>'90804',
'19_destPostal'=>'90066', '22_destCountry'=>'US', '23_weight'=>'5',
'24_value'=>'500', '39_response'=>'1');
use URI::URL;
use LWP::UserAgent;
$ua=new LWP::UserAgent;
my $req= new HTTP::Request
'POST','http://www.ups.com/using/services/rave/qcosthtm.cgi';
$req->content_type('application/x-www-form-urlencoded');
my $curl=url("http:");
$curl->query_form(%form);
$req->content($curl->equery);
$pricing=$ua->request($req)->as_string;
($price)=$pricing=~/.*Total\sCharge\D*(\d*\.\d\d)/;
print'<HTML>';
print $price;
print'</HTML>';
------------------------------
Date: Thu, 30 Apr 1998 05:27:27 GMT
From: trickett@pacbell.net.nospam (Adam)
Subject: Script to parse HTML, converting img tags to text
Message-Id: <6i922k$gbj$1@nnrp4.snfc21.pbi.net>
Hi,
I'm looking for a script that can parse a web page in HTML, and remove all
<IMG> tags, replacing them with plain text made from the alt tag. I've seen
them mentioned, but have never been able to track on down.
I'm runing ActiveState Perl5 (most recent build), with CGI.pm and LWP running,
and I'm using a Apache server (1.3b6).
Scripts or ideas accepted, email prefered, Pacbell's News-server is a tad bit
slow - when it's working....
---
Adam <trickett at pacbell dot net>
Unsolicited e-mail will be charged a $10 proof reading
fee - by replying to this posting you are agreeing to
these terms and conditions.
------------------------------
Date: 30 Apr 1998 08:20:26 +0200
From: Gisle Aas <aas@sn.no>
Subject: Re: Script to parse HTML, converting img tags to text
Message-Id: <m3emyfbzkl.fsf@furu.g.aas.no>
trickett@pacbell.net.nospam (Adam) writes:
> I'm looking for a script that can parse a web page in HTML, and remove all
> <IMG> tags, replacing them with plain text made from the alt tag. I've seen
> them mentioned, but have never been able to track on down.
This is a task that fits perfectly for what HTML::Filter does and this
shows an implementation:
#!/usr/bin/perl
package MyFilter;
require HTML::Filter;
@ISA=qw(HTML::Filter);
sub start
{
my $self = shift;
my($tag, $attr) = @_;
if ($tag eq "img") {
$self->output($attr->{alt} || "[Image]");
} else {
$self->SUPER::start(@_);
}
}
package main;
for (@ARGV) {
MyFilter->new->parse_file($_);
}
__END__
The HTML::Filter module is found in the HTML-Parser distribution. The
program as shown does the wrong thing for <img alt=""> and <img alt="0">.
Fixing that is left as an exercise to the interested reader :-)
--
Gisle Aas
------------------------------
Date: Thu, 30 Apr 1998 05:06:23 GMT
From: Eric Wong <egwong@netcom.com>
Subject: Re: Simple Question regarding dates
Message-Id: <egwongEs7nIn.HpI@netcom.com>
Kris Davey <mivl@inquo.net> wrote:
: I am farly new to PERL and was wondering if someone could show me an
: example of 1. how to display the current date (i.e. 29 April 1998) 2. Store
: it in a scalar variable 3. create a file using the variable so the the file
: is Named 29 April 1998. Any help would be greatly appreciated. I don't know
: if it makes any difference but this script would be run on an NT box. Any
: help would be appreciated. Thanks in advance.
Something like this ought to work. It works for me, at least
(not NT, though.) It's pretty self-explanatory.
@MONTHS = qw ( January February March April May June July
August September October November December );
@date = localtime ( time );
2. $date_string = "$date[3] $MONTHS[$date[4]] ". ( 1900 + $date[5] );
1. printf $date_string."\n";
3. open ( F, ">$date_string" ) || die "open() error: $!";
... etc.
The numbers on the left refer to your tasks listed above.
There's also the Time::Local module. I'm not familiar with it,
but it sounds like it might have something to help you out.
gluck.
[ cc'd ]
------------------------------
Date: 30 Apr 1998 10:14:34 GMT
From: Tom.Grydeland@phys.uit.no (Tom Grydeland)
Subject: Re: Simple Question regarding dates
Message-Id: <slrn6kgjoa.qg.Tom.Grydeland@mitra.phys.uit.no>
On 30 Apr 1998 03:54:48 GMT,
Kris Davey <mivl@inquo.net> wrote:
> I am farly new to PERL and was wondering if someone could show me an
> example of 1. how to display the current date (i.e. 29 April 1998) 2. Store
> it in a scalar variable 3. create a file using the variable so the the file
> is Named 29 April 1998. Any help would be greatly appreciated. I don't know
> if it makes any difference but this script would be run on an NT box. Any
> help would be appreciated. Thanks in advance.
Some questions are asked more often than others. These are called
"Frequently Asked Questions", abbreviated FAQ.
In many cases, to avoid answering the same questions over and over,
some helpful soul compiles a list of such questions with authoritative
answers. It is commonly considered a minimum effort to search for such
a list and consult it before posting your problem to the newsgroup
-- especially if you're a beginner, since your problem is then even less
likely to be new. --
With your copy of perl, you should have received extensive
documentation, and the Perl FAQ is part of this documentation.
A search for the word "date" in the headlines of the FAQ pages gives
only five hits:
perlfaq4.pod: =head1 Data: Dates
perlfaq4.pod: =head2 How can I compare two date strings?
perlfaq4.pod: =head2 How do I validate input?
perlfaq5.pod: =head2 How do I randomly update a binary file?
perlfaq8.pod: =head2 How do I set the time and date?
You might also want to look at the entry for localtime in perlfunc,
for strftime in POSIX or, if that's not enough, the Date::Manip module.
Hope that helps,
> Kris Davey
--
//Tom Grydeland <Tom.Grydeland@phys.uit.no>
------------------------------
Date: Thu, 30 Apr 1998 08:26:00 GMT
From: bart.mediamind@tornado.be (Bart Lateur)
Subject: SMTP and sockets
Message-Id: <354c2fde.3807016@news.tornado.be>
Maybe this post isn't in the most appropriate newsgroup, but there isn't
a SMTP related newsgroup, I checked. Anyway, I'm trying to make this
work using a Perl script (hint, hint), and I'm trying to understand the
working of existing Perl scripts, including the Net::* modules (hint,
hint). I think the Perl docs are a bit spartan when talking about socket
related calls, AND I'm pretty sure this is not a FAQ (gnarf!).
This is the code snippet that raises some questions:
use Socket;
my $PROTOCOL = getprotobyname('tcp'); #6
socket(SOCKET,PF_INET,SOCK_STREAM,$PROTOCOL)
or die "Can't make socket:$!";
my $remote_ip = gethostbyname($mailserver); # 4 bytes, or undef
my $PORT = getservbyname('smtp','tcp'); #25
my $remote_sock = pack('Sna4x8', AF_INET, $PORT, $remote_ip);
connect(SOCKET, $remote_sock) or die "Can't connect socket: $!";
Question one: getservebyname('smtp','tcp') asks about the SMTP port. But
the result does not depend on the $mailserver, which it should.
Otherwise, it makes no sense, does it? If my computer uses the standard
25 for SMTP port, and the mailserver I'm trying to connect to uses
another port number for SMTP, this code will use the wrong port number,
right?
Question two: if the DNS lookup doesn't work (gethostbyname() returns
undef), I can STILL connect, but only to my local SMTP server. I'm not
sure this is garanteed to work, but it works on my ISP's machine.
So: why bother? Why do, for example, the Net::* modules do such an
elaborate search to find out the proper SMTP server? I can send mail
through virtually any SMTP server, and in particular, through the SMTP
server on MY machine, right?
I appreciate any light you can shed on this.
Bart.
------------------------------
Date: Thu, 30 Apr 1998 02:43:16 -0600
From: audttjk@dbs.com.sg
Subject: snoop-like util in Perl ?
Message-Id: <6i9a2k$4d$1@nnrp1.dejanews.com>
Hi,
Is it possible to write a snoop-like (sniffer) utility
in Perl ? Has anybody done it before ? I urgently need a
simple snoop-like program on Windows NT.
Thanks.
Jit Kiat
-----== Posted via Deja News, The Leader in Internet Discussion ==-----
http://www.dejanews.com/ Now offering spam-free web-based newsreading
------------------------------
Date: Thu, 30 Apr 1998 08:25:31 GMT
From: mfuhr@dimensional.com (Michael Fuhr)
Subject: Re: snoop-like util in Perl ?
Message-Id: <6i9chp$ldu@flatland.dimensional.com>
audttjk@dbs.com.sg writes:
> Is it possible to write a snoop-like (sniffer) utility
> in Perl ? Has anybody done it before ? I urgently need a
> simple snoop-like program on Windows NT.
I don't know about NT, but there's a Net::Pcap module that should
work on Unix systems that have libpcap (the same library used
by tcpdump).
--
Michael Fuhr
http://www.dimensional.com/~mfuhr/
------------------------------
Date: 30 Apr 1998 09:34:53 GMT
From: ? the platypus {aka David Formosa} <dformosa@st.nepean.uws.edu.au>
Subject: Re: Thank you Solutionsoft
Message-Id: <893928893.283379@cabal>
In <6i85ae$6ku$1@rznews.rrze.uni-erlangen.de> dr.pc@t-online.de (Dr. Fridemar Pache) writes:
[...]
>As I've never dared to open a binary {{un}secure} email-attachment,
You willing to download the program off the web but your unwilling to open
an attachement?
--
I'm a perl programer if you need perl programing hire me.
Please excuse my spelling as I suffer from agraphia see the url. Support NoCeM
http://www.cit.nepean.uws.edu.au/~dformosa/Spelling.html http://www.cm.org/
I'm sorry but I just don't consider 'because its yucky' a convincing argument
------------------------------
Date: Thu, 30 Apr 1998 11:40:22 +0200
From: Christian Scholz <cs@mechb.uni-stuttgart.de>
Subject: use of soubroutines ?
Message-Id: <35484706.4EA568EF@mechb.uni-stuttgart.de>
Hi,
Is there an easy possibility to use a subroutine in perl
like in fortran77 ? In normal case the subroutines have to
be declared in the main program. In this case my main
program extends. I would like to call the subroutines in the
main program and the subroutine itself is a separat file.
Thanks.
Chris
------------------------------
Date: Thu, 30 Apr 1998 10:37:57 GMT
From: Brent Michalski <perlguy@inlink.com>
Subject: Re: use of soubroutines ?
Message-Id: <35485485.8F2D500B@inlink.com>
Chris,
Have you read ANY documenation on Perl yet?
All you have to do is a:
require "subfile.sub";
in your Perl program and then you can call the subroutines contained in
subfile.sub.
May I suggest reading the FAQ's or a good Perl book. Most of your
answers will be found there.
HTH,
Brent
------------------------------
Date: Thu, 30 Apr 1998 08:00:20 GMT
From: bart.mediamind@tornado.be (Bart Lateur)
Subject: Re: You people want Perl to be popular?
Message-Id: <3549292e.2095004@news.tornado.be>
Chris Lambrou wrote:
>Well?
Yes, but only if for a reason. I mean, yes, popular, with people that
can value programing tools for it's merit.
Not popular with the common people, though. There's no reason/use for
it. That would be just "hype".
Bart.
------------------------------
Date: 8 Mar 97 21:33:47 GMT (Last modified)
From: Perl-Request@ruby.oce.orst.edu (Perl-Users-Digest Admin)
Subject: Digest Administrivia (Last modified: 8 Mar 97)
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.misc (and this Digest), send your
article to perl-users@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.
The Meta-FAQ, an article containing information about the FAQ, is
available by requesting "send perl-users meta-faq". The real FAQ, as it
appeared last in the newsgroup, can be retrieved with the request "send
perl-users FAQ". Due to their sizes, neither the Meta-FAQ nor the FAQ
are included in the digest.
The "mini-FAQ", which is an updated version of the Meta-FAQ, is
available by requesting "send perl-users mini-faq". It appears twice
weekly in the group, but is not distributed in the digest.
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 V8 Issue 2462
**************************************