[18706] in Perl-Users-Digest
Perl-Users Digest, Issue: 874 Volume: 10
daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Fri May 11 03:05:44 2001
Date: Fri, 11 May 2001 00:05:12 -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: <989564712-v10-i874@ruby.oce.orst.edu>
Content-Type: text
Perl-Users Digest Fri, 11 May 2001 Volume: 10 Number: 874
Today's topics:
Re: 1 billion seconds bug <pne-news-20010511@newton.digitalspace.net>
Re: CGI and printing vars <andras@mortgagestats.com>
Delete on NET::FTP no@spam.com
Re: Delete on NET::FTP (Eric Bohlman)
dynamischer download - CGI <thorsten@stueben.de>
Existing Script To Add Time <grasshopper99[no-spam]@hotmail.com>
finding all uses of a file or module at runtime james.h.anderson@ssmb.com
Re: format Question <pne-news-20010511@newton.digitalspace.net>
Is there an easy way to parse a MIME-encoded message? <bernie@fantasyfarm.com>
Re: Javascript or Perl ? (BUCK NAKED1)
Re: Local Time <AgitatorsBand@yahoo.com>
need a simple script created please <druid@eoe-magical.org>
Re: Pattern matching using variable ... <vsen@interrainc.com>
Re: Pattern matching using variable ... <vsen@interrainc.com>
Re: Posting Guidelines for comp.lang.perl.misc ($Revisi <andras@mortgagestats.com>
Re: Posting Guidelines for comp.lang.perl.misc ($Revisi (Eric Bohlman)
Re: Posting Guidelines for comp.lang.perl.misc ($Revisi <pne-news-20010511@newton.digitalspace.net>
Re: regexp to expand variables (Craig Berry)
Re: regexp to expand variables <joe+usenet@sunstarsys.com>
Re: RTF -> PDF <andras@mortgagestats.com>
secure file download? <dave@colquhoun.org>
times function (Mark Lybrand)
Re: Tuning Perl application <AgitatorsBand@yahoo.com>
Re: Tuning Perl application (Gwyn Judd)
Using PERL to submit data to JavaScript <donotreply@interbulletin.bogus>
WWW-search engine - link popularity number <michael_of_neb@MailAndNews.com>
Re: WWW-search engine - link popularity number <andras@mortgagestats.com>
Digest Administrivia (Last modified: 6 Apr 01) (Perl-Users-Digest Admin)
----------------------------------------------------------------------
Date: Fri, 11 May 2001 09:01:07 +0200
From: Philip Newton <pne-news-20010511@newton.digitalspace.net>
Subject: Re: 1 billion seconds bug
Message-Id: <bg3nftsc1eq4ke5ikqoli8mvl29beckqjq@4ax.com>
On Thu, 10 May 2001 18:57:01 -0000, Chris Stith
<mischief@velma.motion.net> wrote:
> It's localtime() which applies a timezone offset to the
> return value to give you hours, minutes, and seconds.
>
> The 'if your clock is correctly set'
> assumes too much. Mainly, it assumes that people are concerned
> with the difference. I've seen many machines installed with
> no thought of time zone at all,
Ah, thanks. Yes, I think you're right.
Cheers,
Philip
--
Philip Newton <nospam.newton@gmx.li>
Yes, that really is my address; no need to remove anything to reply.
If you're not part of the solution, you're part of the precipitate.
------------------------------
Date: Thu, 10 May 2001 16:51:20 -0400
From: Andras Malatinszky <andras@mortgagestats.com>
Subject: Re: CGI and printing vars
Message-Id: <3AFAFF48.93EADE23@mortgagestats.com>
Todd Smith wrote:
> when I use CGI, sometimes I need to print some of the variables back out on
> the page. Or if I'm sending email to a few people based on input, like a
> feedback form, I like to make the body of the email all at once and store it
> in a variable for later. So, I wish I could do this:
>
> ------------
> use CGI;
> $cgi = new CGI;
>
> $send = <<SEND;
> Name: $cgi->param{Name}<br>
> Email: $cgi->param{Email}<br>
> SEND
>
> print "Content-type: text/html\n\n";
> print $send;
> ---------------
>
> But of course that prints
>
> Name: CGI=HASH(0x80c6fdc)->param{Name}
> Email: CGI=HASH(0x80c6fdc)->param{Email}
>
> And I hate typing $a = "stuff", $cgi->param(Name), "eqfefge",
> $cgi->param(Email}, "aefeafeag"- because that's ugly.
>
> So I've been resorting to making a quick hash from $cgi ---
>
> for ($cgi->param) {
> $c{$_} = $cgi->param($_);
> }
>
> But writing a whole 'for' loop just for convenience? There's got to be a
> better way. How do you guys deal with printing out vars passed in to CGI?
Suppose your parameters are fee, fie, foe and fum.
You can do something like
$cgi->import_names('foo');
This will automagically create the variables
$foo::fee
$foo::fie
$foo::foe
and
$foo::fum
and assign the appropriate values to them. You can obviously work out the rest.
This, by the way, is described in the CGI.pm documentation. Read it, there is
lot's of good stuff in there.
------------------------------
Date: 10 May 2001 15:01:26 GMT
From: no@spam.com
Subject: Delete on NET::FTP
Message-Id: <9deag6$ehr$1@news.netmar.com>
I'm having problems going through a list of files and deleting some of them.
This is the code...
while(<FTP_NLST>) # Go through filename by
filename.
{
$filename=$_;
chomp($filename); # Remove carriage return from end.
if($filename!~/^\w{8}\.(\w)$/) # Something we shouldn't touch?
{
&write_log("| [$filename] doesn't match, leaving on FTP
site.",0);
next;
}
if($1 ne "P" && $1 ne "E") # Something we
know is useless?
{
&write_log("- [$filename] boring name, deleting from
FTP
site.",0);
$ftp->delete($filename) or &write_log("|
[$filename] error
deleting from FTP site, skipping - ".$ftp->message,0);
next;
}
&write_log("+ [$filename] interesting name, moving to incoming
directory.",0);
[etc]
}
What's supposed to happen is that 8 character filenames that don't end in .E
or .P get deleted. What happens is some don't. I think it's because the
FTP server (through a filewall) is adding a 257 every so often when it feels
like it which confuses things. This is the debug output...
Net::FTP=GLOB(0x11eccc)>>> DELE 01260510.C
Net::FTP=GLOB(0x11eccc)<<< 250 Deleted.
Net::FTP=GLOB(0x11eccc)>>> DELE 01260510.O
Net::FTP=GLOB(0x11eccc)<<< 257 "/" is cwd.
Net::FTP=GLOB(0x11eccc)>>> DELE 01270429.O
Net::FTP=GLOB(0x11eccc)<<< 250 Deleted.
And eventually I get chucked off with this error even though I've been
deleting files left right and centre...
Net::FTP=GLOB(0x11e8dc)<<< 421 Disconnecting you since you didn't
do
anything productive for 300 seconds.
How do I go about soaking up useless replies in between each delete and
avoiding the timeout?
Cheers,
Dan.
----- Posted via NewsOne.Net: Free (anonymous) Usenet News via the Web -----
http://newsone.net/ -- Free reading and anonymous posting to 60,000+ groups
NewsOne.Net prohibits users from posting spam. If this or other posts
made through NewsOne.Net violate posting guidelines, email abuse@newsone.net
------------------------------
Date: 11 May 2001 06:43:11 GMT
From: ebohlman@omsdev.com (Eric Bohlman)
Subject: Re: Delete on NET::FTP
Message-Id: <9dg1lv$q6c$1@bob.news.rcn.net>
no@spam.com wrote:
> I'm having problems going through a list of files and deleting some of them.
> This is the code...
> while(<FTP_NLST>) # Go through filename by
> filename.
> {
> $filename=$_;
> chomp($filename); # Remove carriage return from end.
> if($filename!~/^\w{8}\.(\w)$/) # Something we shouldn't touch?
> {
> &write_log("| [$filename] doesn't match, leaving on FTP
> site.",0);
> next;
> }
> if($1 ne "P" && $1 ne "E") # Something we
> know is useless?
This is probably your problem; if you arrive here, the regex in your
previous if statement *must* have failed (since if it succeeded, you'd
have next'd out), and therefore $1 won't be set to the last letter of the
*current* filename; it will be set to the last letter of the last filename
that "shouldn't have been touched."
You should never, I mean *never*, use the $n variables in a context where
you don't know if the last regex match with capturing parens succeeded.
------------------------------
Date: Fri, 11 May 2001 08:49:59 +0200
From: "Thorsten Stueben" <thorsten@stueben.de>
Subject: dynamischer download - CGI
Message-Id: <9dg1t4$eao$1@donald.stueben.inka.de>
Hallo,
ich habe folgendes vor: Ich möchte gerne Freunden, bestimmte Bilder die ich
auf meiner Homepage habe zum downloaden via FTP anbieten. Dabei soll es
möglich sein nur bestimmte Bilder auszuwählen, die ich anschließend über ein
Perl-Script per zip in ein File komprimiere. Der Rückgabewert des
Perl-Scripts bzw. CGI-Script soll das komprimierte File sein.
Ist das möglich? Und wenn ja, wie schaffe ich es die Files per zip zu
komprimieren und anschließend zurückzugeben?
Gruß und Danke
Thorsten
------------------------------
Date: Fri, 11 May 2001 04:21:27 GMT
From: "grasshopper" <grasshopper99[no-spam]@hotmail.com>
Subject: Existing Script To Add Time
Message-Id: <bNJK6.22617$Hk4.384649@news1.rdc1.ab.home.com>
Wondering if anyone has a script (bourne or perl) available which can
calculate the elapsed time between two given times such as: 08:00 16:30
which would be an elapsed time of 08:30.
Any and all help appreciated.
Appologies for the xpost.
Pete
grasshopper99[no-spam]@hotmail.com
------------------------------
Date: 10 May 2001 14:05:47 GMT
From: james.h.anderson@ssmb.com
Subject: finding all uses of a file or module at runtime
Message-Id: <9de77r$and$1@news.netmar.com>
The problem:
Starting with a main program, I need to find all "use'd" modules and
"required"
programs that use or require some module or program, say "MP". The
search
needs
to be recursive and driven by the currently enforce "use lib".
I'm sure this code must be out there somewhere :)
Thanks,
jim
----- Posted via NewsOne.Net: Free (anonymous) Usenet News via the Web -----
http://newsone.net/ -- Free reading and anonymous posting to 60,000+ groups
NewsOne.Net prohibits users from posting spam. If this or other posts
made through NewsOne.Net violate posting guidelines, email abuse@newsone.net
------------------------------
Date: Fri, 11 May 2001 09:03:56 +0200
From: Philip Newton <pne-news-20010511@newton.digitalspace.net>
Subject: Re: format Question
Message-Id: <0l3nftoe5nda29riraqungq1b5d6lhl8e4@4ax.com>
On Thu, 10 May 2001 19:45:49 GMT, mjd@plover.com (Mark Jason Dominus)
wrote:
> $pwd =~ y/a-z/22233344455566677788899900/;
> # abcdefghijklmnopqrstuvwxyz
>
> The first time I saw your y/// line, I had to grovel over it to make
> sure that the two halves were the same. With my version, you don't
> need to do that.
How about
$pwd =~ y[abcdefghijklmnopqrstuvwxyz]
[22233344455566677788899900];
, then?
Cheers,
Philip
--
Philip Newton <nospam.newton@gmx.li>
Yes, that really is my address; no need to remove anything to reply.
If you're not part of the solution, you're part of the precipitate.
------------------------------
Date: Fri, 11 May 2001 00:32:46 -0400
From: Bernie Cosell <bernie@fantasyfarm.com>
Subject: Is there an easy way to parse a MIME-encoded message?
Message-Id: <rrpmft8l25mpp77cbcm8cjtr5kvjifa2r6@news.supernews.net>
I'm looking at the docs for MIME-tools and I'm *stunned* by the complexity
as I read about the entity objects and the nested parts and on and on.. Is
it *really* that hard/complicated to parse a MIME email message? [taking
the additional loading of eight or nine other packages, a seven-stage
decoding process... WHEW!] If that's what it takes, well I'll have to deal
with it, but if so, it is astounding how much more complicated it is to
deal with a MIME message than a uuencoded one... No wonder uuencoding
doesn't go away on usenet... there's a lot to be said for simplicity..:o)
Is there a MIME-Lite-decoder hiding someplace..:o)
Meta question: why is the MIME stuff in the "World Wide Web" category on
CPAN? Took me a surprisingly long time to find it... shouldn't it be in
the Mail and Usenet News category [after all, MIME is "Multipurpose
Internet Mail Extensions"]?
tnx...
/Bernie\
--
Bernie Cosell Fantasy Farm Fibers
bernie@fantasyfarm.com Pearisburg, VA
--> Too many people, too few sheep <--
------------------------------
Date: Fri, 11 May 2001 01:31:54 -0500 (CDT)
From: dennis100@webtv.net (BUCK NAKED1)
Subject: Re: Javascript or Perl ?
Message-Id: <17601-3AFB875A-71@storefull-246.iap.bryant.webtv.net>
ECMA is the standard that few follow. Netscape's is Javascript. MS's
version is called JScript, WebTV's uses JellyScript, etc. So, there is
inconsistency in so-called Javascripts, and that's another good reason
to avoid it. JS codes that work on one browser often do not work on
another. I don't even think Netscape who invented Javascript is
supporting it anymore. Last time I looked at their Javascript docs, they
haven't been updated in years. ... not the case with perl.
--Dennis
------------------------------
Date: Fri, 11 May 2001 02:48:40 GMT
From: Scratchie <AgitatorsBand@yahoo.com>
Subject: Re: Local Time
Message-Id: <cqIK6.326$du2.31520@news.shore.net>
Alan J. Flavell <flavell@mail.cern.ch> wrote:
: The web is littered with insecure scripts that are damaging folks'
: systems day in and day out. Sometimes they're just an irritation,
: somtimes they're a major incident. When there are recognised
: techniques for avoiding many of those insecurities, why are you so
: determined to shout-down the advice?
I was just about to ask you the same thing. Someone pointed out that there
was an alternative way to get the local time and you went out of your way
to insult him in a particularly self-righteous, smug manner. It might have
been appropriate to point out that there were security considerations to
using backticks that didn't exist when using the native localtime
function, but to imply that the original poster was a complete idiot for
not providing a complete security briefing on the implications of spawning
external processes and the proper use of taint checking is beyond the
pale and does nothing to improve either the conversational or the
intellectual tenor of this newsgroup.
Newsgroups exist to share information among users of all levels of ability
and experience. By bringing up backticks, the original poster may have
inspired some newbie to read the documentation on that feature and
introduce a new piece of perl's feature set into her toolbox (even if, in
all likelihood, she would never use it to get the local time). It might
inspire someone to think "Why the hell would a crazy language have two
completely different ways to do the same thing" and do some research into
the "perl culture" and the unix culture that spawned it.
Yet your biggest concern was that someone might actually use this code in
their own perl program and thus endanger their security. Well, forgive me
if I feel that the intelligent, mutually respectful sharing of ideas and
knowledge about the perl language is more in keeping with the intent (if
not the spirit) of this newsgroup and that anyone whose site is hacked
because they used backticks to get the local time probably shouldn't be
getting all their security instruction & training from Usenet.
--Art
------------------------------
Date: Fri, 11 May 2001 14:34:59 -0700
From: Donald Dahlman <druid@eoe-magical.org>
Subject: need a simple script created please
Message-Id: <3AFC5B03.597F7950@eoe-magical.org>
I need a perl script
that allows a user to fill in some information
select a local file on there machine a jpg or gif only
click a button and have the contents added to an html file
and have the graphic file added to a separate directory.
when the html file is opened the links will also show the photos
have a little money can some one help. I can do a little of the work
like creating the basic html headers and footers
druid@nift.net
------------------------------
Date: Thu, 10 May 2001 19:34:12 -0700
From: Vishwanath Sen <vsen@interrainc.com>
Subject: Re: Pattern matching using variable ...
Message-Id: <3AFB4FA4.EA4E3CF2@interrainc.com>
Thanks Tina. m/\Q$pattern/ worked for me.
Regards,
- Vishwanath.
Tina Mueller wrote:
> Bart Lateur <bart.lateur@skynet.be> wrote:
> > Vishwanath Sen wrote:
>
> >>$pattern = "abc";
> >>
> >>if ($tmp1 =~ /$pattern/) {
> >> print "match found \n";
> >>}
>
> > Oh, and the *contents* of $pattern should look like what you'd enter in
> > a normal regex. That needn't be the same as what you enter in the
> > string. For example, in order to match a backslash, you need two
> > backslashes in the pattern:
>
> > /\\/
>
> > but in order to get two backslashes into a string, you generally need 4
> > backslashes:
>
> or better, just type
> m/\Q$pattern/
>
> perldoc -f quotemeta
>
> regards,
> tina
>
> --
> http://tinita.de \ enter__| |__the___ _ _ ___
> tina's moviedatabase \ / _` / _ \/ _ \ '_(_-< of
> search & add comments \ \ _,_\ __/\ __/_| /__/ perception
> please don't email unless offtopic or followup is set. thanx
------------------------------
Date: Thu, 10 May 2001 19:38:00 -0700
From: Vishwanath Sen <vsen@interrainc.com>
Subject: Re: Pattern matching using variable ...
Message-Id: <3AFB5088.9414A666@interrainc.com>
Thanks Bart and everyone else for so many suggestions. It really helped me.
Regards,
- Vishwanath.
Bart Lateur wrote:
> Vishwanath Sen wrote:
>
> >$pattern = "abc";
> >
> >if ($tmp1 =~ /$pattern/) {
> > print "match found \n";
> >}
> >
> >Basically in the pattern matching if condition I want to use pattern
> >defined in $pattern. So what will that if condition look like ?
>
> That's it.
>
> Also check out the /o option, if $pattern won't ever change during the
> life of the script. It might speed up the match a bit.
>
> But I think that recent versions of perl have a bit of an optimizer
> built in, so that it doesn't recompile the regex if the scalar hasn't
> changed, so the time difference with or without /o needn't be that big
> any more.
>
> Oh, and the *contents* of $pattern should look like what you'd enter in
> a normal regex. That needn't be the same as what you enter in the
> string. For example, in order to match a backslash, you need two
> backslashes in the pattern:
>
> /\\/
>
> but in order to get two backslashes into a string, you generally need 4
> backslashes:
>
> $pattern = '\\\\';
> print $pattern; # --> \\
> /$pattern/; # matches a backslash
>
> --
> Bart.
------------------------------
Date: Thu, 10 May 2001 22:00:22 -0400
From: Andras Malatinszky <andras@mortgagestats.com>
Subject: Re: Posting Guidelines for comp.lang.perl.misc ($Revision: 1.1 $)
Message-Id: <3AFB47B6.F870E68B@mortgagestats.com>
tadmc@augustmail.com wrote:
[snip]
Tad, I think what you are doing is great and much needed. I hope you don't mind
some suggestions.
>
> Outline
> Before posting to comp.lang.perl.misc
> Must
Should.
You are talking to adults. If you start off on a bossy tone you are going to
alienate your audience. That's not what we want.
Maybe you could try the angle of "if you don't want to embarrass yourself and
make yourself the target of scorn, you should..."
>
> - Check the Perl Frequently Asked Questions (FAQ)
You might want to include a URL here. I know that theoretically you should be
able to find the FAQ on your own machine, but in practice this doesn't seem to
work for newbies.
>
> - Check the other standard Perl docs (*.pod)
What is pod? Again, if I know, I probably don't need this piece of advice. If I
am new to the game, I may not know.
>
>
> It is *not* required, or even expected, that you actually *read* all of
> Perl's standard docs, only that you spend a few minutes searching them
> before posting.
Very good point.
>
>
> Try doing a word-search in the standard docs for some words/phrases
> taken from your problem statement or from your very carefully worded
> `Subject:' header.
>
> Really Really Should
>
> This section describes things that you *really should* do before posting
> to clpmisc.
>
> Lurk for a while before posting
> It is standard netiquette to monitor (lurk) a newsgroup for a few
> days or weeks before posting. By doing so you will be able to see
> what is socially acceptable in the newsgroup.
>
> You can "power lurk" by reading 20-30 posts a day for the last
> several days at a Usenet archive.
>
> Search a Usenet archive
> There are tens of thousands of Perl programmers. It is very likely
> that your question has already been asked (and answered). See if you
> can find where it has already been answered.
>
> One such searchable archive is
> <URL:http://www.deja.com/home_ps.shtml>.
How 'bout
http://groups.google.com/groups?hl=en&lr=&safe=off&group=comp.lang.perl.misc
instead?
>
>
> If You Like
>
> This section describes things that you *can* do before posting to
> clpmisc.
>
> Check Other Resources
> You may want to check in books or on web sites to see if you can
> find the answer to your question.
>
> But you need to consider the source of such information, there are a
> lot of very poor Perl books and web sites, and several good ones
> too, of course.
The logical question at this point is "like for instance?"
>
>
> Posting to comp.lang.perl.misc
> There can be 200 messages in clpmisc in a single day. Nobody is going to
> read every article. They must decide somehow which articles they are
> going to read, and which they will skip.
>
> Your post is in competition with 199 other posts. You need to "win"
> before a person who can help you will even read your question.
>
> These sections describe how you can help keep your article from being
> one of the "skipped" ones.
Very, very good approach.
[snip]
>
>
> Social faux pas to avoid
>
What *is* the plural of faux pas?
:-)
>
>
> Count to ten before composing a followup when you are upset
> This is recommended in all Usenet newsgroups. Here in clpmisc, most
> flaming sub-threads are not about any feature of Perl at all! They
> are most often for what was seen as a breach of netiquette. If you
> have lurked for a bit, then you will know what is expected and won't
> make such posts in the first place.
>
> But if you get upset, wait a while before writing your followup. I
> recommend waiting at least 30 minutes.
>
> Count to ten after composing and before posting when you are upset
> After you have written your followup, wait *another* 30 minutes
> before committing yourself by posting it. You cannot take it back
> once it has been said.
This is very good advice. It is amazing how much space, time and energy is
wasted complaining about the waste of space, time and energy. If you see
something that bothers you, nine times out of ten, it's better for the poster
and for the community if you just let it go and move on to the next post.
>
>
> AUTHOR
> Tad McClellan <tadmc@augustmail.com>
Good job, Tad!
------------------------------
Date: 11 May 2001 03:51:34 GMT
From: ebohlman@omsdev.com (Eric Bohlman)
Subject: Re: Posting Guidelines for comp.lang.perl.misc ($Revision: 1.1 $)
Message-Id: <9dfnk6$q9k$1@bob.news.rcn.net>
Andras Malatinszky <andras@mortgagestats.com> wrote:
> tadmc@augustmail.com wrote:
> [snip]
> Tad, I think what you are doing is great and much needed. I hope you don't mind
> some suggestions.
>>
>> Outline
>> Before posting to comp.lang.perl.misc
>> Must
> Should.
> You are talking to adults. If you start off on a bossy tone you are going to
> alienate your audience. That's not what we want.
> Maybe you could try the angle of "if you don't want to embarrass yourself and
> make yourself the target of scorn, you should..."
I think Tad is using "must," "should," etc. in the very particular (some
would say "peculiar") sense that they have in specs like RFCs. I'm not
entirely sure whether that's a good idea here (at least not without some
explanation, which would take up valuable space) because:
1) Many or most of the people reading guidelines won't yet be familiar
with reading formal specs and
2) Stark imperatives make sense when you're saying what a *computer* is
supposed to do (as does a spec) but are rather objectifying and
defense-inducing when you're describing what a *person* is supposed to do.
------------------------------
Date: Fri, 11 May 2001 08:54:29 +0200
From: Philip Newton <pne-news-20010511@newton.digitalspace.net>
Subject: Re: Posting Guidelines for comp.lang.perl.misc ($Revision: 1.1 $)
Message-Id: <e43nftsqf5831r415vakfbhav5kveonr3s@4ax.com>
On Thu, 10 May 2001 22:00:22 -0400, Andras Malatinszky
<andras@mortgagestats.com> wrote:
> tadmc@augustmail.com wrote:
>
> > Social faux pas to avoid
>
> What *is* the plural of faux pas?
> :-)
Faux pas, the way he wrote.
Cheers,
Philip
--
Philip Newton <nospam.newton@gmx.li>
Yes, that really is my address; no need to remove anything to reply.
If you're not part of the solution, you're part of the precipitate.
------------------------------
Date: Fri, 11 May 2001 01:20:21 -0000
From: cberry@cinenet.net (Craig Berry)
Subject: Re: regexp to expand variables
Message-Id: <tfmfilr2i3ouae@corp.supernews.com>
Mario Rizzuti (diab.lito@usa.net) wrote:
: Could someone please make a regexp that substitutes a variable name with its
: value? there is one in the FAQ but doesn't match hashes and arrays
: elements.Thanks anyone.
The FAQ answer is:
$text =~ s/(\$\w+)/$1/eeg;
Easy enough to extend that:
$s = 'scalar';
$h{foo} = 'hash element';
@a = qw(one two three);
$text = '$s, $h{foo}, $a[1] are the values';
$text =~ s/(\$\w+(?:\[.*?\]|\{.*?\})?)/$1/eeg;
print "$text\n";
Output:
scalar, hash element, two are the values
--
| Craig Berry - http://www.cinenet.net/~cberry/
--*-- "God becomes as we are that we may be as he is."
| - William Blake
------------------------------
Date: 11 May 2001 02:41:21 -0400
From: Joe Schaefer <joe+usenet@sunstarsys.com>
Subject: Re: regexp to expand variables
Message-Id: <m3lmo4fkvi.fsf@mumonkan.sunstarsys.com>
cberry@cinenet.net (Craig Berry) writes:
> The FAQ answer is:
>
> $text =~ s/(\$\w+)/$1/eeg;
>
> Easy enough to extend that:
>
> $s = 'scalar';
> $h{foo} = 'hash element';
> @a = qw(one two three);
>
> $text = '$s, $h{foo}, $a[1] are the values';
>
> $text =~ s/(\$\w+(?:\[.*?\]|\{.*?\})?)/$1/eeg;
Although this is a nice and simple solution, in light of the
recent discussions of security here I'd like to point out
that, unlike the FAQ answer, passing tainted data through this
s///eeg regexp is IMHO far worse than backticking `date`. I think
it would be safer and better to avoid the regexp stuff altogether
and just use eval:
$text = eval "qq{$text}"; die $@ if $@;
That way taint-checks are not subverted should OP choose to use them.
Otherwise subtle and wicked things can happen:
% perl -Mstrict -wTpe 's/(\$\w+(?:\[.*?\]|\{.*?\})?)/$1/eeg'
$ENV{ENV}
/home/joe/.bashrc
$ENV{ (ENV=>undef%ENV)[0] }
Use of uninitialized value in substitution iterator at -e line 1, <> line 2.
$ENV{ print `date` }
Fri May 11 02:17:08 EDT 2001
Use of uninitialized value in substitution iterator at -e line 1, <> line 3.
Joe Schaefer
--
Quintessential Williams: strategize viral initiatives
------------------------------
Date: Thu, 10 May 2001 23:21:44 -0400
From: Andras Malatinszky <andras@mortgagestats.com>
Subject: Re: RTF -> PDF
Message-Id: <3AFB5AC7.AC1A22E6@mortgagestats.com>
Barry Trottier wrote:
> Is there anything out there that converts from RTF to PDF?
Try this CPAN search:
http://search.cpan.org/search?mode=module&query=pdf
I don't see anything that directly converts RTF to PDF, but you can
probably tweak PDF::Create to do what you want.
While you are at it, you might want to do a search for RTF as well.
------------------------------
Date: Thu, 10 May 2001 22:39:52 -0700
From: Dave Calhoun <dave@colquhoun.org>
Subject: secure file download?
Message-Id: <dave-5C9C92.22395210052001@news.isp.giganews.com>
I have a linux webserver that I need to transfer file from to a Win98
pc. I've heard this is possible using perl but don't know how. Also, the
files need to be transfered securely since they contain sensitive data.
I do have a ssl certificate. Can anyone point me in the right direction?
Thanks,
Dave
------------------------------
Date: Fri, 11 May 2001 01:11:01 GMT
From: markyesme@home.com (Mark Lybrand)
Subject: times function
Message-Id: <Xns909DB8E8A771Bmarkyesmehomecom@24.7.143.114>
Hello,
Just need a bit of clarification on the times function.
Okay. I understand that times returns an array of four elements:
$user = which is the cpu time that the process uses
$system = which is the cpu time where the process interacts with the system
$cuser = which is the cpu time that the child process uses.
$csystem = which is the cpu time where the child process interacts with the
system
I am probably a bit mistaken on the $system and $csystem elements, hence my
confusion.
Am I correct? What about idle time? Should I use the POSIX times
function, which provides the fifth element $realtime, so I can calculate
idle time (which I take to be that the process and system wait for networks
or other processes to respond).
Please let me know if I have completely mis-interpreted the information
that this function provides.
TIA,
Mark :)
------------------------------
Date: Fri, 11 May 2001 02:35:33 GMT
From: Scratchie <AgitatorsBand@yahoo.com>
Subject: Re: Tuning Perl application
Message-Id: <VdIK6.324$du2.31552@news.shore.net>
Paul Dembry <pade@trifox.com> wrote:
: I need to determine where time is being spent within my application. Is
: there a profiling type of function/module that I can use to do this? There
: are no command line options for this nor have I found anything in several
: Perl books. I would like to know which subroutines are taking the most time
: to execute.
Benchmark module.
--Art
------------------------------
Date: Fri, 11 May 2001 04:28:20 GMT
From: tjla@guvfybir.qlaqaf.bet (Gwyn Judd)
Subject: Re: Tuning Perl application
Message-Id: <slrn9fmqj3.md6.tjla@thislove.dyndns.org>
"Mein Lufkissenfahrzeug ist voller Aale"
said Scratchie (AgitatorsBand@yahoo.com) in
<VdIK6.324$du2.31552@news.shore.net>:
>Paul Dembry <pade@trifox.com> wrote:
>: I need to determine where time is being spent within my application. Is
>: there a profiling type of function/module that I can use to do this? There
>: are no command line options for this nor have I found anything in several
>: Perl books. I would like to know which subroutines are taking the most time
>: to execute.
>
>Benchmark module.
I'd use the built in profiler:
perl -d:DProf myscript.pl
dprofpp
Read all about it:
perldoc Devel::DProf
perldoc -q 'profile'
--
Gwyn Judd (print `echo 'tjla@guvfybir.qlaqaf.bet' | rot13`)
Children seldom misquote you. In fact, they usually repeat word forword what you shouldn't have said.
------------------------------
Date: Fri, 11 May 2001 01:38:17 +0000
From: Ventura <donotreply@interbulletin.bogus>
Subject: Using PERL to submit data to JavaScript
Message-Id: <3AFB4289.57C74ACA@interbulletin.com>
Is it possible to submit a data to a JavaScript trought the usage of LWP module, or with any other module.
What i have is a simple feedback form written in JavaScript, and I would like to sumbit the information to it from a PERL script...
_______________________________________________
Submitted via WebNewsReader of http://www.interbulletin.com
------------------------------
Date: Thu, 10 May 2001 21:22:08 -0400
From: Michael <michael_of_neb@MailAndNews.com>
Subject: WWW-search engine - link popularity number
Message-Id: <3AFF1834@MailAndNews.com>
Hi.
Recently, I have begun to look for a Perl tool to investigate the various
numeric site link popularity numbers for the various search engines and
their
databases.
A "link popularity number" is the number of links that the various search
engines have found for a given url. It is a key number in the determination
of
search engine ranking, and placement success.
Unfortunately, the WWW.Search module does not seem to return the top of the
first returned search page for the query for the popularity numbers.
The "raw" hash word doesn't do this job. It seems to only be aimed (when it
is supported) at the given urls listed in the body of the returned page.
Does anybody know the best Perl module tool to just look at the whole first
returned page that one gets for a visit to a given search engine with a
subsequent appropriate query ?
Is there just a simple submission method into which I could put the
constructed name of the page and the query for the "popularity" (such as
"link:url") and then just look at the result from this ?
Hope someone can help.
Mike
------------------------------------------------------------
Get your FREE web-based e-mail and newsgroup access at:
http://MailAndNews.com
Create a new mailbox, or access your existing IMAP4 or
POP3 mailbox from anywhere with just a web browser.
------------------------------------------------------------
------------------------------
Date: Thu, 10 May 2001 21:27:27 -0400
From: Andras Malatinszky <andras@mortgagestats.com>
Subject: Re: WWW-search engine - link popularity number
Message-Id: <3AFB3FFF.FB837F26@mortgagestats.com>
Michael wrote:
Does anybody know the best Perl module tool to just look at the whole first
returned page that one gets for a visit to a given search engine with a
> subsequent appropriate query ?
>
> Is there just a simple submission method into which I could put the
> constructed name of the page and the query for the "popularity" (such as
> "link:url") and then just look at the result from this ?
>
> Hope someone can help.
>
> Mike
Sure, use the LWP module. Be sure to read lwpcook.
------------------------------
Date: 6 Apr 2001 21:33:47 GMT (Last modified)
From: Perl-Users-Request@ruby.oce.orst.edu (Perl-Users-Digest Admin)
Subject: Digest Administrivia (Last modified: 6 Apr 01)
Message-Id: <null>
Administrivia:
The Perl-Users Digest is a retransmission of the USENET newsgroup
comp.lang.perl.misc. For subscription or unsubscription requests, send
the single line:
subscribe perl-users
or:
unsubscribe perl-users
to almanac@ruby.oce.orst.edu.
To submit articles to comp.lang.perl.announce, send your article to
clpa@perl.com.
To request back copies (available for a week or so), send your request
to almanac@ruby.oce.orst.edu with the command "send perl-users x.y",
where x is the volume number and y is the issue number.
For other requests pertaining to the digest, send mail to
perl-users-request@ruby.oce.orst.edu. Do not waste your time or mine
sending perl questions to the -request address, I don't have time to
answer them even if I did know the answer.
------------------------------
End of Perl-Users Digest V10 Issue 874
**************************************