[18465] in Perl-Users-Digest
Perl-Users Digest, Issue: 633 Volume: 10
daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Thu Apr 5 06:06:25 2001
Date: Thu, 5 Apr 2001 03:05:14 -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: <986465114-v10-i633@ruby.oce.orst.edu>
Content-Type: text
Perl-Users Digest Thu, 5 Apr 2001 Volume: 10 Number: 633
Today's topics:
Re: 'system' in perl script (Damian James)
Re: 'system' in perl script <gavin@nospam.com>
Any one has a generic epoch function ? <huem@MailAndNews.com>
Re: Any one has a generic epoch function ? (Anno Siegel)
Re: array and hash presentation as text <ren@tivoli.com>
Re: Best way to save HTML form data to XML <nobody@home.com>
Re: Can module distinguish between "use" and exec invoc (Mark Jason Dominus)
ftp: get n bytes from within file paul.skeie@weather.no
Re: GD::Graph again (Martien Verbruggen)
Re: Getting hostname <ren@tivoli.com>
Re: How do I get html from a website? <todd@designsouth.net>
Re: How do I get html from a website? <chrisw+usenet@dynamite.com.au>
Re: How do I get html from a website? <joe+usenet@sunstarsys.com>
How to do Quasi search engine in Perl? <nickysantoro@yahoo.com>
Re: How to do Quasi search engine in Perl? (Logan Shaw)
maximum value of a list tt@mit.jyu.fi
Re: Most efficient way to extract unique array elements <goldbb2@earthlink.net>
Re: Multiple email send?vvp <hafner-usenet@ze.tu-muenchen.de>
Re: Multiple pages within one CGI (by way of "Scott R. Godin" <webmaster@webdragon.unmunge.net>)
Re: Newbies welcome <wyzelli@yahoo.com>
Re: OOP Question <ubl@schaffhausen.de>
Re: OOP Question (Anno Siegel)
Re: Please help (Dasdale)
Re: Please help (Damian James)
Re: PPM package version of XML::XSLT <nospamplease@thankyou.com>
Re: Remove every other character? (Philip Lees)
Restriction in subroutine calls? - what's the problem? <armin.nolte@aktion-mensch.de>
Re: Restriction in subroutine calls? - what's the probl (Anno Siegel)
Re: Restriction in subroutine calls? - what's the probl (Mark Jason Dominus)
Re: what are the new languages? <wayne.keenan@ntlworld.com>
Win32::OLE & MS Outlook <gregory.a.mccoy@worldnet.att.net>
Re: Win32::OLE & MS Outlook <ron@savage.net.au>
Digest Administrivia (Last modified: 16 Sep 99) (Perl-Users-Digest Admin)
----------------------------------------------------------------------
Date: 5 Apr 2001 01:30:40 GMT
From: damian@qimr.edu.au (Damian James)
Subject: Re: 'system' in perl script
Message-Id: <slrn9cnik7.jc9.damian@puma.qimr.edu.au>
Bing Du chose Wed, 04 Apr 2001 16:37:53 -0500 to say this:
>> ...
>> > system("cat $file|mailx -s 'test only' bing-du\@tamu.edu");
>> >
Useless use of cat. You could rewrite this as:
system("mailx -s 'test only' bing-du\@tamu.edu < $file");
But a better solution would be to open a pipe directly to mailx, as the
other two respondents have pointed out.
Cheers,
Damian
--
@:=grep!($;+=m!$/|#!),split//,<DATA>;@;=0..$#:;while(@;){for($;=@;;--$;;){;(
$:=rand$;+$|)==$;&&next;@;[$;,$:]=@;[$:,$;]}push@|,shift@;if$;[0]==@|;select
$,,$,,$,,1/80;print qq x\bxx((@;+@|)*$|++),@:[@|,@;],!@;&&$/} __END__
Just another Perl Hacker # rev 3 -- a JAPH in progress, I guess...
------------------------------
Date: Thu, 5 Apr 2001 12:53:13 +1000
From: "Gavin Cato" <gavin@nospam.com>
Subject: Re: 'system' in perl script
Message-Id: <t6Ry6.38$W37.14351@news.interact.net.au>
You havent closed your file handle before sending the mail.
Gav
"Bing Du" <bing-du@tamu.edu> wrote in message
news:3ACB8C38.C09FD4DE@tamu.edu...
> The following script does not mail the content of $file to me. It says
> the message body is null.
>
> Seems the perl script creates another shell to execute the 'system'
> command, but the child shell knows nothing in the perl script above it.
>
> Do I have to use the mail module (e.g. Net::SMTP) to handle the mail
> delivery?
>
> #!/usr/local/bin/perl
>
> $file = 'test';
> open(F,">$file");
> print F "for testing\n";
> system("cat $file|mailx -s 'test only' bing-du\@tamu.edu");
>
> Ideas?
>
> Bing
>
------------------------------
Date: Thu, 5 Apr 2001 01:39:55 -0400
From: hue micheal <huem@MailAndNews.com>
Subject: Any one has a generic epoch function ?
Message-Id: <3ACD45F1@MailAndNews.com>
Hi,
Any one has a epoch function that can convert string to epoch_seconsds and
epoch_seconds to string ? I am looking for a generic one that works accross
version of perl (from version 4 up) without the need of modules and special
date functions that dont exist in all version of perl such as str2date or
Time::Local etc.
Thanks
------------------------------
Date: 5 Apr 2001 08:12:39 GMT
From: anno4000@lublin.zrz.tu-berlin.de (Anno Siegel)
Subject: Re: Any one has a generic epoch function ?
Message-Id: <9ah9dn$jm3$2@mamenchi.zrz.TU-Berlin.DE>
According to hue micheal <huem@MailAndNews.com>:
> Hi,
>
> Any one has a epoch function that can convert string to epoch_seconsds and
> epoch_seconds to string ? I am looking for a generic one that works accross
> version of perl (from version 4 up) without the need of modules and special
> date functions that dont exist in all version of perl such as str2date or
> Time::Local etc.
The timelocal() function has been around since Perl 4. The difference
is that it used to be in timelocal.pl and is now in Time::Local.
Anno
------------------------------
Date: 04 Apr 2001 19:36:00 -0500
From: Ren Maddox <ren@tivoli.com>
Subject: Re: array and hash presentation as text
Message-Id: <m3zodwdvyn.fsf@dhcp9-175.support.tivoli.com>
On Wed, 04 Apr 2001, nashif@planux.com wrote:
> If $[] defines a hash and [] defines an array, how can I parse such
> a text structure into one perl variable:
>
> $["key1":"value1","key2":[1,2,3,4]]
>
> or
>
> [[[1,2],3,4,5],6,7,8]
>
> Any Idea?
>
> The result should be in case 1 a hash of values and arrays.
> The second is an array of arrays....
Your best bet is likely the Parse::RecDescent module.
For curiosity's sake, I started to see if I could manage to do this
with the experimental (??{ code }) feature. I came up with:
#!/usr/bin/perl
use re q/eval/;
$_=q($["key1":"value1","key2":[1,2,3,4]]);
$simple_elem = qr{ \d+ | "[^"]*" }x;
$elem = qr{ $simple_elem | (??{ $hash }) | (??{ $array }) }x;
$pair = qr{ $simple_elem \s* : \s* $elem }x;
$array_sequence = qr{ $elem | $elem \s* , \s* (??{ $array_sequence }) }x;
$hash_sequence = qr{ $pair | $pair \s* , \s* (??{ $hash_sequence }) }x;
$array = qr{ \[ \s* $array_sequence \s* \] }x;
$hash = qr{ \$\[ \s* $hash_sequence \s* \] }x;
$struct = qr{ ^ \s* (?: $array | $hash ) \s* $ }x;
print /$struct/ ? "Match\n" : "No match\n";
__END__
The problem, of course, is that assuming this even works (I only
tested a couple of very simple cases, one good string (as shown) and
then one bad string) it doesn't actually build the structure, just
verifies it. I think that could be addressed, but exploring that is
more than I wanted to do at this point, particularly since the above
is practically a grammar for Parse::RecDescent anyway -- it just needs
to be converted into the correct syntax, which I'll leave as an
exercise. :)
Oh, and $simple_elem probably needs to be improved. As is it only
matches double-quoted strings and sequences of digits. It doesn't
handle floating point values, strings containing escaped quotes, and a
whole mess of other stuff....
--
Ren Maddox
ren@tivoli.com
------------------------------
Date: Thu, 05 Apr 2001 05:24:43 GMT
From: "me" <nobody@home.com>
Subject: Re: Best way to save HTML form data to XML
Message-Id: <vkTy6.1112$J8.1234127@news1.rsm1.occa.home.com>
If you are using IE, you can do this with almost NO CODE.
Read up on "XML Data Islands", and how to bind a data island to form
elements.
"Lucient Chan" <lucie@sinden.nccom.com> wrote in message
news:9adhai$r6f@sinden.nccom.com...
>
> Hi,
>
> I'm reading data from a HTML page which contains a form, and I'm trying
> to write the user-entered data in the form to a XML file. Can anyone
> tell me the best way to accomplish this?? Does any of the perl modules
> such as XML::DOM provide an API to create a XML document??
>
> Thanks.
>
>
>
------------------------------
Date: Thu, 05 Apr 2001 08:12:18 GMT
From: mjd@plover.com (Mark Jason Dominus)
Subject: Re: Can module distinguish between "use" and exec invocations?
Message-Id: <3acc28e2.8e3$1a2@news.op.net>
In article <%4Ky6.22413$iU.4184631@news1.rdc1.md.home.com>,
Sweth Chandramouli <sweth+perl@gwu.edu> wrote:
> This only works from inside a subroutine invoked
>from outside of the module, though--right?
Right, but a smart guy like you should be able to figure it out from
this hint.
--
@P=split//,".URRUU\c8R";@d=split//,"\nrekcah xinU / lreP rehtona tsuJ";sub p{
@p{"r$p","u$p"}=(P,P);pipe"r$p","u$p";++$p;($q*=2)+=$f=!fork;map{$P=$P[$f^ord
($p{$_})&6];$p{$_}=/ ^$P/ix?$P:close$_}keys%p}p;p;p;p;p;map{$p{$_}=~/^[P.]/&&
close$_}%p;wait until$?;map{/^r/&&<$_>}%p;$_=$d[$q];sleep rand(2)if/\S/;print
------------------------------
Date: Thu, 05 Apr 2001 07:11:59 +0000
From: paul.skeie@weather.no
Subject: ftp: get n bytes from within file
Message-Id: <3ACC1ABF.26041BC0@weather.no>
Hi all,
I want to download n bytes from within a file.
Using Net::FTP I know I can start downloading
after skipping m bytes.
Can someone tell me a method to stop downloading
after n bytes?
Paul
------------------------------
Date: Thu, 05 Apr 2001 02:40:54 GMT
From: mgjv@tradingpost.com.au (Martien Verbruggen)
Subject: Re: GD::Graph again
Message-Id: <slrn9cnmpm.jrg.mgjv@verbruggen.comdyn.com.au>
On Wed, 04 Apr 2001 21:13:33 GMT,
Joseph Pepin <jdpepin@optonline.net> wrote:
> Any plans for this?
>
> "Martien Verbruggen" <mgjv@tradingpost.com.au> wrote in message
> news:slrn9cidr6.jrg.mgjv@verbruggen.comdyn.com.au...
>> On Mon, 02 Apr 2001 15:29:39 -0700,
>>
>> but rotated 90 degrees, right? GD::graph doesn't do horizontal charts
>> at the moment.
>>
Yep. I've had plans for this for a long time. Unfortunately, life
keeps throwing up all these other little things that I am forced to
give a higher priority...
Martien
--
Martien Verbruggen |
Interactive Media Division | You can't have everything, where
Commercial Dynamics Pty. Ltd. | would you put it?
NSW, Australia |
------------------------------
Date: 04 Apr 2001 18:50:09 -0500
From: Ren Maddox <ren@tivoli.com>
Subject: Re: Getting hostname
Message-Id: <m38zlgfcni.fsf@dhcp9-175.support.tivoli.com>
On Wed, 4 Apr 2001, shino_korah@yahoo.com wrote:
> What is the best way to get hostname of the current machine? I'm
> using chomp($name = `hostname'); How can I use Sys::Hostname
> module to get this?I mean which function to use? How to read help
> for functions in modules?
perldoc Sys::Hostname
gives documentation on the module, including the following synopsis,
which looks to give you your answer pretty directly:
SYNOPSIS
use Sys::Hostname;
$host = hostname;
--
Ren Maddox
ren@tivoli.com
------------------------------
Date: Thu, 05 Apr 2001 03:47:45 GMT
From: "Todd Smith" <todd@designsouth.net>
Subject: Re: How do I get html from a website?
Message-Id: <BVRy6.10837$C51.2922079@news1.rdc1.tn.home.com>
"Tony Curtis" <tony_curtis32@yahoo.com> wrote in message
news:87vgokdw68.fsf@limey.hpcc.uh.edu...
> >> On Wed, 04 Apr 2001 19:00:02 GMT,
> >> "Todd Smith" <todd@designsouth.net> said:
>
> > I'm writing a program that plays Lycos Gamesville bingo ...
>
> > I tried "$result = `lynx -dump $url`, but a result never
> > comes back. I've tried LWP::UserAgent, but it says the
> > site doesn't allow connections to it's HTTP port, and
> > sometimes i just get a "Connection timed out" error.
>
> Tony's guess: the browser has it cached on disk.
>
> LWP talks the same protocols (of course) as your browser,
> so if it can't connect then neither can your browser.
>
> The bottom-line is probably to do
>
> $ telnet remote.host 80
> GET /path/to/what/you/want HTTP/1.0 [RET] [RET]
>
> and see if anything comes back. The LWP package also
> installs a "GET" perl program which you could use (to try
> to get back on track for clpm).
>
> hth
> t
> --
> Just reach into these holes. I use a carrot.
It won't work! I can 'telnet www.yahoo.com 80', but not 'telnet
www.gamesville.com 80'
How do they block out telnets to HTTP but allow browsers?
------------------------------
Date: Thu, 5 Apr 2001 14:32:44 +1000
From: "Chris W" <chrisw+usenet@dynamite.com.au>
Subject: Re: How do I get html from a website?
Message-Id: <GBSy6.42$w57.99426@news.interact.net.au>
> "Jesse James Jensen" <jesse@uchicago.edu> wrote in message
> news:3ACB898C.30377430@uchicago.edu...
> > > I tried "$result = `lynx -dump $url`, but a result never comes back.
> I've
> > > tried LWP::UserAgent, but it says the site doesn't allow connections
to
> it's
> > > HTTP port, and sometimes i just get a "Connection timed out" error.
> > >
You don't perchance have a proxy that you're not configuring?
------------------------------
Date: 05 Apr 2001 01:10:08 -0400
From: Joe Schaefer <joe+usenet@sunstarsys.com>
Subject: Re: How do I get html from a website?
Message-Id: <m3puesszin.fsf@mumonkan.sunstarsys.com>
Keywords: nonsense, Romulans
"Todd Smith" <todd@designsouth.net> writes:
> It won't work! I can 'telnet www.yahoo.com 80', but not 'telnet
> www.gamesville.com 80'
> How do they block out telnets to HTTP but allow browsers?
You might need to use perl's telnet cloaking device then:
% perl -wle 'open STDOUT, "|telnet www.gamesville.com 80";
$| = print <<CLOAK;
GET / HTTP/1.0
Host: www.gamesville.com
Connection: close
CLOAK
wait'
Trying 209.202.206.34...
Connected to www.gamesville.com (209.202.206.34).
Escape character is '^]'.
HTTP/1.0 302 Found
Date: Thu, 05 Apr 2001 04:39:17 GMT
Server: Open-Market-Secure-WebServer/V2.1.
MIME-version: 1.0
Location: http://www.gamesville.lycos.com/cgi-bin/homePage
Content-type: text/html
<TITLE>Redirection</TITLE><H1>Redirection</H1>
This document can be found
<A HREF="http://www.gamesville.lycos.com/cgi-bin/homePage">elsewhere.</A>
<P>You see this message because your browser doesn't support
automatic redirection handling.
Connection closed by foreign host.
%
From the looks of the response, I think you are trying to pry
information out of the wrong host/domain. If so, your troubles
have nothing to do with Perl.
--
Joe Schaefer "We are all in the gutter, but some of us are looking at the
stars."
-- Oscar Wilde
------------------------------
Date: 5 Apr 2001 08:23:57 GMT
From: Nicholas <nickysantoro@yahoo.com>
Subject: How to do Quasi search engine in Perl?
Message-Id: <9aha2t$5g1$1@agate.berkeley.edu>
Hello,
I am trying to create a quasi search engine using a flat file
as an 'index'. Basically I have about 10-20 traits I classify
a list of movies in (genre, length, year, etc.) I translate these
traits into numbers, (horror=01, sci-fi=02, etc.) So each movie
has an 'index #' like 010302040104 etc. i.e., the first two digits
represent horror, the second pair (03) represents length (60-90 mins, e.g.)
and so on. Anyway, if I got a big index database of these (say, 10,000),
what's the best way to search on it. I can translate the search terms into
numbers like genre=04, so I know I want to look for an 04 in the first
position, and maybe if I don't have a term for the second position, I would
accept all, but then I want an 04 in the fifth position and so on, how
would I do this most efficiently? Are their modules out there that
can approximate and score? How about ranges around a numbner? If I write
it myself, I guess there would just be lots of while statements and loops to
match up each db entry with the query? Any suggestions?
Any help would be appreciated.
Thanks
------------------------------
Date: 5 Apr 2001 04:57:21 -0500
From: logan@cs.utexas.edu (Logan Shaw)
Subject: Re: How to do Quasi search engine in Perl?
Message-Id: <9ahfi1$an7$1@boomer.cs.utexas.edu>
In article <9aha2t$5g1$1@agate.berkeley.edu>,
Nicholas <nickysantoro@yahoo.com> wrote:
>I am trying to create a quasi search engine using a flat file
>as an 'index'. Basically I have about 10-20 traits I classify
>a list of movies in (genre, length, year, etc.) I translate these
>traits into numbers, (horror=01, sci-fi=02, etc.) So each movie
>has an 'index #' like 010302040104 etc. i.e., the first two digits
>represent horror, the second pair (03) represents length (60-90 mins, e.g.)
>and so on. Anyway, if I got a big index database of these (say, 10,000),
>what's the best way to search on it. I can translate the search terms into
>numbers like genre=04, so I know I want to look for an 04 in the first
>position, and maybe if I don't have a term for the second position, I would
>accept all, but then I want an 04 in the fifth position and so on, how
>would I do this most efficiently?
If you do it this way, you have to scan the entire
index looking for what you want, because you can
only put it in order by one of the items at best.
What I'd do, instead, is to create a separate index for
every classification. Then, you can open up each index and
find which movies match each criterion that you care about.
Once you have in-memory list of all horror movies and a second
list of all movies which are 60-90 minutes long, you can
either find all items on both lists (horror movies which are
60-90 minutes long) or find all items on either list (movies
which are either horror movies or are 60-90 minutes long).
The reason this can be an advantage is that you can then
use a binary search to look in the indices (if you store
them in sorted order), which can be alot faster, especially
if you have lots of different values in each index.
A completely different approach would be to go ahead and
build the index like you say and then scan it using a regular
expression that you build at runtime. You might build an
expression and give it to a grep statement, like this:
@movies = grep (/^(01|03)....(02)..(01)/, <SOMEFILE>)
The advantage of this is that, while Perl is an interpreted
language, this avoids making the interpreter run too much code,
and most of it is just run with internal Perl code that's pretty
efficient. So, in the particular case of Perl, this might be a
way to get some efficiency pretty easily. (You could probably
even eliminate the "grep" if you wanted to have an ugly enough
regular expression instead.) However, if you ever have
10,000,000 movies in your index, it will not be that great.
Of course, this problem is really just begging to be solved with a
real database that has had tons of effort invested into answering
this kind of query quickly. Then you could just do stuff like this:
select movie_id,movie_name from movie where
(movie_genre=horror or movie_genre=scifi)
and
(movie_length > 60 and movie_length < 83)
and the database would do it for you quickly and easily.
- Logan
--
whose? my your his her our their _its_
who's? I'm you're he's she's we're they're _it's_
------------------------------
Date: 05 Apr 2001 12:56:42 +0300
From: tt@mit.jyu.fi
Subject: maximum value of a list
Message-Id: <n6elv7k6ud.fsf@xii5.it.jyu.fi>
I'm still learning perl so please bear with me
if I've overlooked something obvious.
Is there some simple expression that returns the maximum
value of a list?
I find myself using sort for the purpose, and it
seems kind of overkill, yet it is much easier to use
than an explicit loop.
For example, if I want to print the biggest number
on every row or a file, I can do
perl -lane 'print ((sort {$b-$a} @F)[0])'
but I dislike using sort, which is O(N log N) in time
complexity, when a linear time should suffice.
The obvious alternative is an explicit loop:
perl -lane 'foreach $i (@F) {$m=$i if $i>$m} print $m'
but it is longer, needs extra variables and, more important,
cannot be used as an expression unless I turn it into a
function, or can it?
I feel there should be a list operation to pick the maximum,
perhaps using 'map', but I can't figure out how.
Any suggestions?
--
Tapani Tarvainen
------------------------------
Date: Thu, 05 Apr 2001 07:25:58 GMT
From: Benjamin Goldberg <goldbb2@earthlink.net>
Subject: Re: Most efficient way to extract unique array elements?
Message-Id: <3ACBF22D.B080211C@earthlink.net>
Thanks for doing the benchmark, but...
Since the problem is to remove duplicates, giving a list which *has* no
duplicates isn't necessarily the best way to go.
For example, how do:
@list = (1 .. 1024)
@list = (1 .. 512) x 2
@list = (1 .. 256) x 4
etc compare to each other?
What if you did a random shuffle?
@list = shuffle (1 .. 1024)
@list = shuffle (1 .. 512) x 2
etc?
Although hashes supposedly don't care about the order of the things
inserted into them it *may* make a difference in timing.
Also, a fifth way of creating the hash (if it's known that it has an
even number of elements) is this:
my %hash = @list, -1, @list; delete $hash{-1};
You could replace -1 with any scalar which is known not to exist in the
list.
If the list has an odd number of elements, then this will work:
my %hash = @list x 2;
Of course, these do have different results than the others, in that the
values are not undef, but since we are only going to look at keys of
%hash, that shouldn't matter.
--
Sometimes the journey *is* its own reward--but not when you're trying to
get to the bathroom in time.
------------------------------
Date: 05 Apr 2001 09:24:36 +0200
From: Walter Hafner <hafner-usenet@ze.tu-muenchen.de>
Subject: Re: Multiple email send?vvp
Message-Id: <srju243g66j.fsf@w3proj1.ze.tu-muenchen.de>
ted <tlav1@mediaone.net> writes:
> I deal with some very large email lists that get mailed on a weekly basis.
> Check out the Mail::Bulkmail module. It worked for me.
Since I have to do bulk-emails, too, I had a look.
Unless Mail::Bulkmail won't allow multipart/alternative AND
multipart/mixed MIME Mails, I'll stick with Mail::Mailer and construct
the MIME headers manually or use MIME::Lite for the simple cases. From a
quick glance at the Mail::Bulkmail docs it seems quite a hassle to
construct headers and matching MIME separators in the body manually.
Since my lists aren't as large (up to 10.000 recipients) I can live with
the speed penalty of using sendmail and simply send all mails overnight.
Just my 0.02 DM :-)
-Walter
------------------------------
Date: 5 Apr 2001 05:42:08 GMT
From: "Scott R. Godin" <webmaster@webdragon.unmunge.net> (by way of "Scott R. Godin" <webmaster@webdragon.unmunge.net>)
Subject: Re: Multiple pages within one CGI
Message-Id: <9ah0jg$ogu$0@216.155.32.23>
(gah, the cross-post from comp.infosystems.www.authoring.cgi didn't work
for some reason (probably me, forgetting to type it in BOTH places.
doh!) apologies.)
[follow-ups set appropriately]
In article <slrn9cnt7r.mj.efflandt@efflandt.xnet.com>,
efflandt@xnet.com (David Efflandt) wrote:
| CGI.pm is really just a script. You can put it wherever you want to and
| point to the system path of the directory containing it with a use lib
| statment (which unshifts that path on the @INC search list).
|
| use lib '/home/username/mymodules';
| use CGI;
|
| I had to do that once when I wanted to use functions that were not in the
| old CGI.pm v2.36 that was on the system. Of course it has to at least be
| Perl 5.
|
Along these lines I've been tossing an idea around in my head for the
past day or three..
Is it possible to actually include a Perl module's body copy *within*
your script and still "use" it ?
for example if I am aware of a short module that's not installed on my
ISP, and that I don't really wish to pester them about, and don't have
telnet access myself, would it be possible to copy/paste the module's
content into the main script itself, and utilize the nature of the
package of the module to separate its functionality (while still
allowing the use Module; syntax above in the main package? (or would
that even be necessary at this point?)
Curiously,
--
unmunge e-mail here:
#!perl -w
print map {chr(ord($_)-3)} split //, "zhepdvwhuCzhegudjrq1qhw";
# ( damn spammers. *shakes fist* take a hint. =:P )
------------------------------
Date: Thu, 5 Apr 2001 19:36:25 +0930
From: "Wyzelli" <wyzelli@yahoo.com>
Subject: Re: Newbies welcome
Message-Id: <MqXy6.2$8J2.1187@vic.nntp.telstra.net>
"A_Geekette" <moiraine{NOSPAM}@qwest.net> wrote in message
news:3ACB0843.24346AEE@qwest.net...
>
> "Nothing is impossible, no matter how improbable."
> -Anonymous
I'd like to see you cut down a Californian Redwod using a banana.
Wyzelli
--
#Modified from the original by Jim Menard
for(reverse(1..100)){$s=($_==1)? '':'s';print"$_ bottle$s of beer on the
wall,\n";
print"$_ bottle$s of beer,\nTake one down, pass it around,\n";
$_--;$s=($_==1)?'':'s';print"$_ bottle$s of beer on the
wall\n\n";}print'*burp*';
------------------------------
Date: Thu, 05 Apr 2001 09:36:09 +0100
From: Malte Ubl <ubl@schaffhausen.de>
Subject: Re: OOP Question
Message-Id: <3ACC2E78.26D76715@schaffhausen.de>
Jason Hurst schrieb:
>
> First, i'm pretty new to doing OOP with perl, however, i'm relativly
> experiance with perl.. I created a package which would look at a database
> and create an object with data corresponding to the database. It was a
> database of training classes. Here is a link to the code:
>
> http://www.colubs.com/perl/Classes.pm
>
> ok, it seams to work alright when i'm accessing the data directly, say i
> do the following:
> my $foo = Classes->new;
> print $foo->[101]->id;
>
> no problem. however what i want to do is somethign like this:
>
> foreach $key (@$foo) {
> print $key->id;
> }
I'm just guessing what you want to do but it might be this:
foreach my $record ($foo->records_as_array) {
print $record->id;
}
BTW: Take a look at DBIx::Recordset.
->malte
------------------------------
Date: 5 Apr 2001 09:31:27 GMT
From: anno4000@lublin.zrz.tu-berlin.de (Anno Siegel)
Subject: Re: OOP Question
Message-Id: <9ahe1f$naf$1@mamenchi.zrz.TU-Berlin.DE>
According to Jason Hurst <variant@shell.pacifier.com>:
> First, i'm pretty new to doing OOP with perl, however, i'm relativly
> experiance with perl.. I created a package which would look at a database
> and create an object with data corresponding to the database. It was a
> database of training classes. Here is a link to the code:
>
> http://www.colubs.com/perl/Classes.pm
>
> ok, it seams to work alright when i'm accessing the data directly, say i
> do the following:
> my $foo = Classes->new;
> print $foo->[101]->id;
This assumes the user knows that a Classes object is implemented as
an array ref, which isn't very object-oriented at all. There should
be an accessor method along the lines of
sub class {
my( $self, $id) = @_;
$self->[ $id];
}
Yes, it's trivial, but it makes all the difference in isolating the
implementation from the function.
> no problem. however what i want to do is somethign like this:
>
> foreach $key (@$foo) {
> print $key->id;
> }
You should have said what happens when you try it. Few people are
going to download your code, install the requisite DBI if they don't
have it, and run it just to find out what goes wrong. Not to mention
the use of AUTOLOAD (yes, I have looked), which doesn't make debugging
any easier.
I suspect that the id's ("101" above) are not an unbroken sequence
starting at 0. That means that @$foo holds real classes mixed with
undefined entries. Trying to call the id-method on one of the
undefined objects would cause an error. In any case there is the
same problem as above: Treating $foo as an array ref breaks the OO
approach. You need a method to get the list of classes from the
object, even if that method (in one implementation) just returns
the dereferenced object.
If the problem is what I suspect however, the method would have to
filter out the undefined entries (untested):
sub class_list {
my ( $self) = shift;
grep defined( $_), @$self;
}
> But i can't figure out how to create my object to support this. Any help
> would be greatly appreciated. I hope this makes sence, my head is a mess
> from looking at this problem so long.. :)
It's probably a bad idea to treat the class id's as numbers, as you
implicitly do when you use them as array indexes. A quick rule
is: Treat it as a number only if it makes sense to do arithmetic
with it. So you should probably change the implementation so that
they are hash keys. Using keys() on the underlying hash would then
give you a list of all class id's without undefined entries mixed in.
Anno
------------------------------
Date: 05 Apr 2001 04:31:27 GMT
From: dasdale@cs.com (Dasdale)
Subject: Re: Please help
Message-Id: <20010405003127.15584.00001616@ng-fa1.news.cs.com>
hi, thanks for the reply. i named the file 'hello', and have tryed running as
'hello', and hello.pl'. any other ideas? where do you go to run your scripts?
------------------------------
Date: 5 Apr 2001 05:38:17 GMT
From: damian@qimr.edu.au (Damian James)
Subject: Re: Please help
Message-Id: <slrn9co14f.ov0.damian@puma.qimr.edu.au>
Dasdale chose 05 Apr 2001 04:31:27 GMT to say this:
>hi, thanks for the reply. i named the file 'hello', and have tryed running as
>'hello', and hello.pl'. any other ideas? where do you go to run your scripts?
>
Try typing:
perl hello
You need to tell dos/your shell what program to use to interpret the plain
text file you are invoking. No easy way to have this done automatically on
dos, but on *nix, you can do the following:
-type 'man chmod' to find out about permissions
-type 'chmod 755 hello'
-type './hello'
so long as your Perl program does start with #!/path/to/perl.
To do without the './', you would need to put your program file somewhere
in your path. Or create your own private bin directory, and add that to
your path.
But this is an OS issue that has really nothing to do with Perl.
HTH,
Cheer,
Damian
[ Friends don't let friends put . in their path ]
--
@:=grep!($;+=m!$/|#!),split//,<DATA>;@;=0..$#:;while(@;){for($;=@;;--$;;){;(
$:=rand$;+$|)==$;&&next;@;[$;,$:]=@;[$:,$;]}push@|,shift@;if$;[0]==@|;select
$,,$,,$,,1/80;print qq x\bxx((@;+@|)*$|++),@:[@|,@;],!@;&&$/} __END__
Just another Perl Hacker # rev 3 -- a JAPH in progress, I guess...
------------------------------
Date: Thu, 5 Apr 2001 00:27:33 -0400
From: "null" <nospamplease@thankyou.com>
Subject: Re: PPM package version of XML::XSLT
Message-Id: <9ags64$npj$1@bob.news.rcn.net>
pls disregard
I overcame the stupidity demons, made a PPM pkg, and got it successfully
installed.
-brian
"null" <nospamplease@thankyou.com> wrote in message
news:9afuq8$4l7$1@bob.news.rcn.net...
> I'm posting to ask whether anyone knows if there is a PPM package version
of
> the XML::XSLT module available anywhere. Neither ActiveState or any of
the
> other repositories listed in their docs offers one and I need to install
the
> module locally so that I can work on some scripts.
>
> I've posted to the perl-xml mailing list and emailed Bron Gondwana (the
mod
> author), but haven't received any responses.
>
> I attempted to follow the instructions at ActiveState (and the advice at
> http://jenda.krynicky.cz/perl/PPM.html) for producing a PPM package, but
> can't get it to happen.
>
> I am a perl novice and preparing a PPM pkg for a perl mod is probably a
> trivial task for more experienced folk, but it's kicking my butt. If
there
> isn't any existing PPK pkg for XML::XSLT (and I suspect that there
probably
> isn't) but someone is willing to make one, I would be grateful.
>
> thanks,
> brian
>
>
>
>
>
>
------------------------------
Date: Thu, 05 Apr 2001 05:55:34 GMT
From: pjlees@ics.forthcomingevents.gr (Philip Lees)
Subject: Re: Remove every other character?
Message-Id: <3acc0885.61327113@news.grnet.gr>
On Wed, 04 Apr 2001 11:03:01 -0600, Dmitry Epstein
<mitiaNOSPAM@northwestern.edu.invalid> wrote:
>Philip Lees wrote:
>
>> $_ = 'some long string';
>> my $x;
>> print map{++$x%2?$_:''}split//; # odd characters
>
>$x = 0; # !!!
Yes, sorry. I meant those two lines to be alternatives, not for
consecutive execution.
>> print map{$x++%2?$_:''}split//; # even characters
>
>print grep {++$x%2} split //;
>$x = 0;
>print grep {$x++%2} split //;
Indeed, that's much better.
Phil
--
Philip Lees
ICS-FORTH, Heraklion, Crete, Greece
Ignore coming events if you wish to send me e-mail
'The aim of high technology should be to simplify, not complicate' - Hans Christian von Baeyer
------------------------------
Date: Thu, 05 Apr 2001 08:29:09 +0200
From: Armin Nolte <armin.nolte@aktion-mensch.de>
Subject: Restriction in subroutine calls? - what's the problem?
Message-Id: <3ACC10B5.CEF57A19@aktion-mensch.de>
Dies ist eine mehrteilige Nachricht im MIME-Format.
--------------E7A3DCDCFDD2C188EF742E35
Content-Type: text/plain; charset=us-ascii; x-mac-type="54455854"; x-mac-creator="4D4F5353"
Content-Transfer-Encoding: 7bit
Hi,
I send this question twice, because I'm not shure if someone got it the
first time, at least I became no
answer so I try it again (If I reached someone the first time I
apologize for this duplicate!).
I#ve got a problem with a perl-script that is supposed to search a
specifik word within all files (of any file-types like doc, xls usw.)
all under the directory and all subdirectorys beneath (in win32
environment).
it seems to run well, but when I turn on the debugger-mode, I recognize
that not all subdirectories/files have been treated. ( I can see it
because my hash '%ref_dave' should maintain only 'undef' - values to
each key after the work is finished - but it still holds some values).
Debugger gives me the notice '100 levels deep in subroutine calls!'
What does that mean?
Is this the key to my problem and can it be solved?
Hope someone can help me? (Maybe there are a lot of script's which
handle the text-search-- I'm interested in that but I want to solve it
also on my own because I'm still learning )
I posted my script to this mail and also the debugger-output
Thanks
Armin
--------------E7A3DCDCFDD2C188EF742E35
Content-Type: text/x-vcard; charset=us-ascii;
name="armin.nolte.vcf"
Content-Transfer-Encoding: 7bit
Content-Description: Visitenkarte fŸr Armin Nolte
Content-Disposition: attachment;
filename="armin.nolte.vcf"
begin:vcard
n:Nolte;Armin
tel;fax:+49-228-2092-281
tel;work:+49-228-2092-233
x-mozilla-html:FALSE
url:http://www.aktion-mensch.de
org:Deutsche Behindertenhilfe Aktion Mensch e.V.;Database Marketing
adr:;;Holbeinstrasse 15;Bonn;NRW;53175;Deutschland
version:2.1
email;internet:Armin.Nolte@aktion-mensch.de
x-mozilla-cpt:;3
fn:Armin Nolte
end:vcard
--------------E7A3DCDCFDD2C188EF742E35--
------------------------------
Date: 5 Apr 2001 08:04:35 GMT
From: anno4000@lublin.zrz.tu-berlin.de (Anno Siegel)
Subject: Re: Restriction in subroutine calls? - what's the problem?
Message-Id: <9ah8uj$jm3$1@mamenchi.zrz.TU-Berlin.DE>
According to Armin Nolte <armin.nolte@aktion-mensch.de>:
> -=-=-=-=-=-
>
>
> Hi,
>
> I send this question twice, because I'm not shure if someone got it the
> first time, at least I became no
> answer so I try it again (If I reached someone the first time I
> apologize for this duplicate!).
>
> I#ve got a problem with a perl-script that is supposed to search a
> specifik word within all files (of any file-types like doc, xls usw.)
> all under the directory and all subdirectorys beneath (in win32
> environment).
Are you using the module File::Find? It is designed for this kind
of directory traversal.
> it seems to run well, but when I turn on the debugger-mode, I recognize
> that not all subdirectories/files have been treated. ( I can see it
> because my hash '%ref_dave' should maintain only 'undef' - values to
> each key after the work is finished - but it still holds some values).
> Debugger gives me the notice '100 levels deep in subroutine calls!'
> What does that mean?
It means that one subroutine called another before it returned,
and that called another and so forth, a hundred times or more.
Subroutines are nested (verschachtelt) 100 levels deep. This is
unlikely to occur during normal processing.
> Is this the key to my problem and can it be solved?
It is very likely that it has to do with your problem, key or not.
Usually a subroutine nesting that deep is recursion run wild. You
must be recursing down a directory tree. Probably something
is going wrong there. This can either be your program's fault or
that of the directory structure you are searching.
> Hope someone can help me? (Maybe there are a lot of script's which
> handle the text-search-- I'm interested in that but I want to solve it
> also on my own because I'm still learning )
>
> I posted my script to this mail and also the debugger-output
Well, yes. You posted it as an attachment if I remember right.
That reduces your chances of someone taking the trouble to extract
and inspect it. Referring here to that other post of yours doesn't
make your chances any better. Reduce the problem to an excerpt
of 20 lines or so and post it with your problem description.
Otherwise, all you can expect is idle speculations like mine above.
Anno
------------------------------
Date: Thu, 05 Apr 2001 08:09:47 GMT
From: mjd@plover.com (Mark Jason Dominus)
Subject: Re: Restriction in subroutine calls? - what's the problem?
Message-Id: <3acc284b.8cf$396@news.op.net>
>Debugger gives me the notice '100 levels deep in subroutine calls!'
>What does that mean?
It's not a restriction; it's just a warning.
It is one of the warnings delivered by the -w option.
--
@P=split//,".URRUU\c8R";@d=split//,"\nrekcah xinU / lreP rehtona tsuJ";sub p{
@p{"r$p","u$p"}=(P,P);pipe"r$p","u$p";++$p;($q*=2)+=$f=!fork;map{$P=$P[$f^ord
($p{$_})&6];$p{$_}=/ ^$P/ix?$P:close$_}keys%p}p;p;p;p;p;map{$p{$_}=~/^[P.]/&&
close$_}%p;wait until$?;map{/^r/&&<$_>}%p;$_=$d[$q];sleep rand(2)if/\S/;print
------------------------------
Date: Thu, 05 Apr 2001 09:12:30 +0100
From: "wayne.keenan" <wayne.keenan@ntlworld.com>
Subject: Re: what are the new languages?
Message-Id: <3ACC28EE.9DAF8CF4@ntlworld.com>
Dmitry Epstein wrote:
>
> Have you used PerlMagic? How does it compare to ActivePerl (which I am
> currently using)?
>
not yet, I have downloded the GNU toolset in order to compile the Perl system.
It's a bit more bother to setup, but hopefully the ability to use (most/ 90% ?)
of the modules directly
from CPAN will be a big plus. Especially for the newly release 100% perl ones
(mostly!).
I don t know about u but the Active state repository is a bit behind for my
likings. This way
I can get Gtk up and running so I can use CSC Mail, unitl I get my linux box
back up anyway.
Wayne
------------------------------
Date: Thu, 05 Apr 2001 05:16:25 GMT
From: "Gregory McCoy" <gregory.a.mccoy@worldnet.att.net>
Subject: Win32::OLE & MS Outlook
Message-Id: <JcTy6.9009$IJ1.764952@bgtnsc05-news.ops.worldnet.att.net>
Can anyone provide a skeleton bit of code which simply creates a new Outlook
mail item and then sends it? I understand how to use the module and the
basics of COM. I just cannot seem to find what objects I need to manipulate
and what to send to them.
Thank you for any help.
I have written a CGI program which links to an Access database using ODBC to
store survey information. What I want to do is send an automatic
notification of a database modification event to 1 of 4 possible managers.
As I am eager for any help, feel free to contact me at the address below.
mccoyga@1fssg.usmc.mil
------------------------------
Date: Thu, 5 Apr 2001 20:37:24 +1000
From: "Ron Savage" <ron@savage.net.au>
Subject: Re: Win32::OLE & MS Outlook
Message-Id: <i3Xy6.2721$MM.112329@ozemail.com.au>
Tut # 2 may help: http://savage.net.au/Perl-tutorials.html
--
Cheers
Ron Savage
ron@savage.net.au
http://savage.net.au/index.html
------------------------------
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 V10 Issue 633
**************************************