[8688] in Perl-Users-Digest

home help back first fref pref prev next nref lref last post

Perl-Users Digest, Issue: 2305 Volume: 8

daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Sun Apr 12 23:07:48 1998

Date: Sun, 12 Apr 98 20:00:26 -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           Sun, 12 Apr 1998     Volume: 8 Number: 2305

Today's topics:
    Re: ANSI Colour in Perl <c..bojswbo@98.usenet.us.com>
        compressing objects before storing? otis@POPULUS.net
        DB suitable for Solaris and Win'95 <andrew@boothman.easynet.co.uk>
    Re: How do I cut off the first word of a string? (Abigail)
        How to create a bidirection socket? <qh2@cec.wustl.edu>
        JPL: call Java from Perl? gemerson@vizdom.com
    Re: keys in hashs <lr@hpl.hp.com>
    Re: MacPerl Book Online in HTML (Chris Nandor)
        Mail forms <kinmich1@lycoming.edu>
    Re: Numeric validation (Abigail)
    Re: Perl-y Scripts [apologies to Don Ho] (Chris Nandor)
    Re: Profiling resource use <ebohlman@netcom.com>
    Re: Profiling resource use (Ilya Zakharevich)
    Re: Project involving Word (Mark-Jason Dominus)
    Re: Q: Getting the browsers local time? (Abigail)
        Question concerning reg exp's in a while statement (Louie)
    Re: Question concerning reg exp's in a while statement <rootbeer@teleport.com>
    Re: Relevance flames considered harmful (was Re: Q: For <jbc@west.net>
    Re: Relevance flames considered harmful (was Re: Q: For (Abigail)
    Re: Relevance flames considered harmful (was Re: Q: For (Mark-Jason Dominus)
    Re: Script URL <gwynne@utkux.utk.edu>
    Re: Script URL <watkins@mailexcite.com>
        Sockets within a loop problem cblack@qni.com
    Re: Sockets within a loop problem <rootbeer@teleport.com>
    Re: Test <andrew@boothman.easynet.co.uk>
    Re: wc -l in perl is?????? <lr@hpl.hp.com>
    Re: Why am I getting an error with @_  ? (Tom Mornini)
        Digest Administrivia (Last modified: 8 Mar 97) (Perl-Users-Digest Admin)

----------------------------------------------------------------------

Date: 12 Apr 1998 23:13:05 GMT
From: Anirvan Chatterjee <c..bojswbo@98.usenet.us.com>
Subject: Re: ANSI Colour in Perl
Message-Id: <6grhq1$eee$1@hustle.rahul.net>

Karl Hanmore <avatar@ultra.net.au> wrote:
> 	I was wondering if anyone knows of any code / modules for printing
>  ANSI colour in Perl.  I have had a snoop through CPAN to no avail, and I
>  really want to avoid re-inventing the wheel.   Anyone got any ideas? 
>  If so, can you email me, as I rarely have time to read newsgroups :)

Try Term::ANSIColor.

_____________________________________________________________________
Anirvan Chatterjee  . anirvan @ chatterjee.net .  PGP 2048/0xE2D13BA9
Fast & free new/used multi-bookstore searching @ http://www.mxbf.com/


------------------------------

Date: Sun, 12 Apr 1998 18:27:48 -0600
From: otis@POPULUS.net
Subject: compressing objects before storing?
Message-Id: <6grilj$m4p$1@nnrp1.dejanews.com>

Hello,

I'm writing an application that will need to store a large number of perl
objects (I'm currently using MLDBM for that) and later retrieve those objects
and do something with them (call some methods on them to get values of
objects' attributes, etc.).

Since the # of objects will be large, I am afraid the DBM created will also
become (too) large very quickly.  I am wondering if it is possible to
_compress_ objects somehow, before storing them on the disk via MLDBM?

Disk space is cheap, but the number of objects in my application very high,
and I'd like to save as much disk space as possible....

Thanks!

Otis

-----== Posted via Deja News, The Leader in Internet Discussion ==-----
http://www.dejanews.com/   Now offering spam-free web-based newsreading


------------------------------

Date: Mon, 13 Apr 1998 00:14:20 +0100
From: Andrew Boothman <andrew@boothman.easynet.co.uk>
Subject: DB suitable for Solaris and Win'95
Message-Id: <35314ACC.44C739F@boothman.easynet.co.uk>

Hi!

After someone in this newsgroup suggested that a system relying on text
files to contain the information for my Internet Reference Tool (It's
sort of like Yahoo, only better), I started looking into databases and
perl.

The only trouble is: which one?! I'm confused about DBI, DBD,...! What
do they all mean? Plus, I want to develop the script on win'95 and then
move it to a Solaris Ultra server afterwards.

Can someone please explain the basics of using databases in perl, and
perhaps point me in the right direction of a solution that would suit my
script.

The script holds websites in a hierarchical fashion, along with other
information like how many people have been to it, and the rating that
it's been given. I'd also like to be able to do searches across
hierarchies, or restrict searches to just one section.

Obviously I'm not looking for an off-the-shelf, turnkey solution to all
of this and I know it will require a lot of development. But I already
have a beta version of the database working (without the search
facility) using text files to store the information. However, once the
script is deployed I want to be a robust and as easily maintainable as
possible, and someone told me that a database was the best way to do
this and to keep my solution scalable.

Thank you very much for your help!
(I'm still very much a perl newbie, so please keep your answers fairly
simple. Thanks.)
--
Andrew Boothman : andrew@boothman.easynet.co.uk 
(http://easyweb.easynet.co.uk/~boothman/andrew/)
"Yahoo is a search engine.
 Netanyahoo is an Israeli search engine"
            -Robin Williams



------------------------------

Date: 13 Apr 1998 02:20:22 GMT
From: abigail@fnx.com (Abigail)
Subject: Re: How do I cut off the first word of a string?
Message-Id: <6grsp6$cnd$3@client2.news.psi.net>

Martin Vorlaender (martin@RADIOGAGA.HARZ.DE) wrote on MDCLXXXV September
MCMXCIII in <URL: news:3530ab4c.524144494f47414741@radiogaga.harz.de>:
++ [posted & mailed]
++ 
++ Bryan T Hoch (bth@acsu.buffalo.edu) wrote:
++ : 	I want to have the user pass in a string (assuming through <STDIN>
++ : to a varaiable $whatever). The problem now is analyzing the first word of
++ : the string, and then passing the remainder of the string on to another sub
++ : routine. Does anyone know how to do that?
++ 
++ $whatever =~ /^(\w*?)(.*)$/;
++ $first_word = $1;
++ $remainder  = $2;
++ 
++ will do what you want. This presumes you have the same notion of what a
++ "word character" (\w) is as perl has.
++ What perl's notion is, you ask? Read about it in perlre.pod.

I don't think so.

   $_ = "The quick brown fox";
   /^(\w*?)(.*)$/;
   $first_word = $1;
   $remainder  = $2;
   print "<$first_word><$remainder>\n";

prints:

   <><The quick brown fox>


Please read perlre.pod about the meaning of *?


The best solution depends on what Bryan's definition of a word is.
A string of letters? Letters and digits? Underscores as well?
Or just anything delimited by whitespace?

Perhaps:
   
   ($first, $remainder) = split /\b/, $string, 2;

will do, depending on what is a 'word'.


See: perldoc -f split
     perldoc perlre

Abigail
-- 
perl -e '$a = q 94a75737420616e6f74686572205065726c204861636b65720a9;
         ${qq$\x5F$} = q 97265646f9; s g..gqq e\x63\x68\x72\x20\x30\x78$&eggee;
         {eval if $a =~ s e..eqq qprint chr 0x$& and \x71\x20\x71\x71qeexcess}'


------------------------------

Date: Sun, 12 Apr 1998 21:53:16 -0500
From: tree <qh2@cec.wustl.edu>
Subject: How to create a bidirection socket?
Message-Id: <35317E1C.2A1C7955@cec.wustl.edu>

I have just learnt perl for several hours on the net. What I need to do
is to implement a bidirection socket with which I can write to and read
from a server.  It should not be difficult but I do not have time to
find a book tommorrow. Hope to get help soon. Thanks.

Here is my codes. I can write to the server but can not get any reply. I
know these should be some reply.
Is there any thing wrong? By the way I can not use socketpair.
-------------------------
use Socket;

$hostname = 'myhost';
$port = 1234;

$iaddr = inet_aton($hostname) or die "No host: $hostname\n";
$paddr = sockaddr_in ($port, $iaddr);
$proto = getprotobyname('tcp');

socket (sock, PF_INET, SOCK_STREAM, $proto) || die "cannot create
socket\n";
connect (sock, $paddr) || die "cannot connect socket\n";

# parent: write, child: read
if (fork) {
    select(sock); $|=1; select(STDOUT);
    $request = "http://myhost.wustl.edu/test.html?request=401";
    syswrite (sock, $request, length $request, 0);
}
else {
    while(<sock>) {
     print;
    }
}




------------------------------

Date: 12 Apr 1998 20:19:47 -0400
From: gemerson@vizdom.com
Subject: JPL: call Java from Perl?
Message-Id: <x2n2dqefoc.fsf@poe.vizdom.com>


Has anyone succeeded in calling Java from Perl? The Perl
Utilities Guide implies that there's a problem with the lack of
native thread support in the JDK. The native threads package is
now available for Solaris, so I was hoping that that would fix
it. I can't seem to get it to work, but I'm willing to believe
that it's just me. The Perl-from-Java examples work, but that
direction isn't interesting to me at the moment.

The problems I've run into: JNI.pm wasn't passing the right
classpath to CreateJavaVM, so my classes weren't being
found. After fixing that (sort of), I was able to find the
classes, but I can't get very far with method calls. I was
getting an invalid method ID error on a method whose id seems
correct to me; getmeth didn't complain, as it did when I tried to
get method signatures I knew were bad, but actually calling the
method failed. When I tried to use straight JNI calls, rather
than JPL::Class calls, I got segmentation violation errors.

If you've gotten this to work, any suggestions? Do I need to
recompile perl, re-install JPL with some other set of options,
circle the cpu three times widdershins waving a stuffed Duke toy?

Thanks.

Gennis


------------------------------

Date: Sun, 12 Apr 1998 15:17:32 -0700
From: Larry Rosler <lr@hpl.hp.com>
To: stvhoof@netvision.net.il
Subject: Re: keys in hashs
Message-Id: <35313D7C.2372E7FE@hpl.hp.com>

stvhoof@netvision.net.il wrote:
> 
 ...
> 
> Sorry, strike 2!  Single quoted does NOT interpret backslashes on anything
> except the single quote itself.  For example:
> 
>    print "It costs \$10\n";
> 
> will print:
> 
>    It costs $10
> 
> whereas:
> 
>    print 'It costs \$10\n';
> 
> will print:
> 
>    It costs \$10\n
> 
> Oh well, at least you're still at bat...   :)
> 
> -----== Posted via Deja News, The Leader in Internet Discussion ==-----
> http://www.dejanews.com/   Now offering spam-free web-based newsreading

Not quite right.  Single quoting also interprets backslashes on
backslashes (as it must, in order to allow a backslash as the last
character in a single-quoted string).  Try:

   print 'It costs \$10\n\\';

which will print:

   It costs \$10\n\

Then try this:

   print 'It costs \$10\n\';

Larry Rosler
Hewlett-Packard Laboratories
lr@hpl.hp.com


------------------------------

Date: Sun, 12 Apr 1998 22:19:15 GMT
From: pudge@pobox.com (Chris Nandor)
Subject: Re: MacPerl Book Online in HTML
Message-Id: <pudge-1204981819050001@dynamic283.ply.adelphia.net>

In article <6gqdik$5r4$1@gaia.ns.utk.edu>, "Bob Gwynne"
<gwynne@utkux.utk.edu> wrote:

# Since there are so many books about Perl, Chris's should be the best.  Why
# not take a look at it and post suggestions about how it might be improved?
# I vote for inclusion of exercises.

Well, your vote, would it to count for anything, would go to the second
edition, because this one is at the printers.  Yay!

-- 
Chris Nandor          mailto:pudge@pobox.com         http://pudge.net/
%PGPKey=('B76E72AD',[1024,'0824 090B CE73 CA10  1FF7 7F13 8180 B6B6'])
#==               New Book:  MacPerl: Power and Ease               ==#
#==    Publishing Date: Early 1998. http://www.ptf.com/macperl/    ==#


------------------------------

Date: Sun, 12 Apr 1998 20:55:51 -0400
From: Michael King <kinmich1@lycoming.edu>
Subject: Mail forms
Message-Id: <35316296.750395B7@lycoming.edu>


I am trying to write an online form which gets information from a user
on the web and then mails it to a recipient in a neat, form-like
structure via email. I have all the forms set up on the page, and have
access to a /cgi-bin on my account. All I need is the script to recieve
the info from the user and mail it to me in a formatted letter. Any help
would be appreciated. Also, any web sites you can point me to will be
helpful.
--
**********************************************************************
* Michael King                                   kinmich1@lycoming.edu
* Web Page Design and Programming                ICQ: 1716752
* http://www2.lycoming.edu/~kinmich1             AIM: LunaBoy4
**********************************************************************




------------------------------

Date: 13 Apr 1998 02:01:06 GMT
From: abigail@fnx.com (Abigail)
Subject: Re: Numeric validation
Message-Id: <6grrl2$cnd$1@client2.news.psi.net>

ppp-support (ppp-support@canelle.telecom.uqam.ca) wrote on MDCLXXXV
September MCMXCIII in <URL: news:3531047D.B569FA7C@canelle.telecom.uqam.ca>:
++ Ok, it's so simple! The email suggestion work with my code, the results is wh
++ want, multiple testing shows everythings works fine, etc... and all your answ
++ not.You simply want to prove that you know the Faq more than a beginner like 
++ you want to help, its fine... but if you just look for an argument, no time f
++ that thank you.


Care to explain why the emailed suggestion /^[0-9]+$/ works and
the /^\d+$/ from the faq doesn't?



Abigail
-- 
perl -wle 'print "Prime" if ("m" x shift) !~ m m^\m?$|^(\m\m+?)\1+$mm'


------------------------------

Date: Sun, 12 Apr 1998 22:28:25 GMT
From: pudge@pobox.com (Chris Nandor)
Subject: Re: Perl-y Scripts [apologies to Don Ho]
Message-Id: <pudge-1204981828150001@dynamic283.ply.adelphia.net>

Wow, you scare me.  :)

-- 
Chris Nandor          mailto:pudge@pobox.com         http://pudge.net/
%PGPKey=('B76E72AD',[1024,'0824 090B CE73 CA10  1FF7 7F13 8180 B6B6'])
#==               New Book:  MacPerl: Power and Ease               ==#
#==    Publishing Date: Early 1998. http://www.ptf.com/macperl/    ==#


------------------------------

Date: Sun, 12 Apr 1998 21:52:06 GMT
From: Eric Bohlman <ebohlman@netcom.com>
Subject: Re: Profiling resource use
Message-Id: <ebohlmanErBM2u.IC4@netcom.com>

Richard Karpinski <dick@moreinfo.com> wrote:
: So far, I'd like to be able to track down usage of three resources by my
: Perl programs: CPU time, I/O requests, RAM consumption.  Are there known
: ways either to profile Perl scripts or even to get access to the raw data?

I'd say that the Benchmark module is "known," given that it comes with 
the standard distribution.  Is there anything you want to do that you 
can't do with it?



------------------------------

Date: 12 Apr 1998 22:41:17 GMT
From: ilya@math.ohio-state.edu (Ilya Zakharevich)
Subject: Re: Profiling resource use
Message-Id: <6grfud$eea$1@mathserv.mps.ohio-state.edu>

[A complimentary Cc of this posting was sent to Richard Karpinski
<dick@moreinfo.com>],
who wrote in article <dick-1204981339290001@rdm.dial.idiom.com>:
> So far, I'd like to be able to track down usage of three resources by my
> Perl programs: CPU time, I/O requests, RAM consumption.  Are there known
> ways either to profile Perl scripts or even to get access to the raw data?

a) DProf and friends;
b) trace/whatever-is-the-name-on-your-system
c) PERL_DEBUG_MSTATS and -DL (both with strings attached)

Ilya


------------------------------

Date: 12 Apr 1998 22:30:55 -0400
From: mjd@op.net (Mark-Jason Dominus)
Subject: Re: Project involving Word
Message-Id: <6grtcv$h47$1@monet.op.net>

In article <352E5687.979438B0@mail.mcoe.k12.ca.us>,
Mcoe NT  <root@mail.mcoe.k12.ca.us> wrote:
>[...]
>Does any one know of any modules that will allow me to
>control [Microsoft] word in this way.

I don't think there are any, because Microsoft never tells anyone what
their file formats are.

Sorry.

If you do come across anything useful, maybe you could post about it here.
I know I'd be interested.



------------------------------

Date: 13 Apr 1998 02:26:32 GMT
From: abigail@fnx.com (Abigail)
Subject: Re: Q: Getting the browsers local time?
Message-Id: <6grt4o$cnd$5@client2.news.psi.net>

Rosemary I H Powell (Rosie@dozyrosy.demon.co.uk) wrote on MDCLXXXV
September MCMXCIII in <URL: news:C4XXWEAcSLM1Ew$l@dozyrosy.demon.co.uk>:
++ In article <Pine.SGI.3.96.980411235156.1222A-
++ 100000@foxtrot.gl.umbc.edu>, Stephen Mubita <smubit1@gl.umbc.edu> writes
++ >On Sat, 11 Apr 1998, Drake Cleary wrote:
++ >
++ >=> Is there any way (ie: Env variable) to get the local time of the user
++ >=> of a perl script on the web?
++ >=> 
++ >The time ? Try localtime. I'm not sure if it helps.
++ >
++ But localtime will give the time on YOUR server, will it not, and not
++ that of the user who may be in a different time zone?


You won't get it. It's not part of the HTTP protocol, and would be 
a total waste of bandwidth anyway. Just assume your user knows
how to read the time.

What does this have to do with Perl anyway?

(Followups set)


Abigail
-- 
perl -we '$_ = q ;4a75737420616e6f74686572205065726c204861636b65720as;;
          for (s;s;s;s;s;s;s;s;s;s;s;s)
              {s;(..)s?;qq qprint chr 0x$1 and \161 ssq;excess;}'


------------------------------

Date: Sun, 12 Apr 1998 21:01:33 GMT
From: $louie@visca.com (Louie)
Subject: Question concerning reg exp's in a while statement
Message-Id: <35312b7d.13598104@news.jet.es>

Greetings:

The purpose of my script is to remove unwanted newlines (resulting
from a copy/paste operation from a text editor) from between the <p>
and </p> tags that were added later. There is also whitespace in front
of the <p> tag that I want to get rid of. Here's a snippet from the
target text:

-------BEGIN SNIPPET-------
  <p>Dear Ballpark Frank:
</p>
  <p>As I think I told you at the end of my last letter, you may be
seeing me sooner
than either of us had planned. If I had any money, I'd be swatting
mosquitos there
with you in Brooklyn instead of swilling <i>cervesa</i> with Pilar the
scorekeeper
on the terraces in Manresa. It seems that every time the Manly Mens
win a game a
new complication arises; it would all be great fun if my big mouth
hadn't put me
right in the middle of it.
</p>
  <p>Since last I wrote, the Manly Mens have won two (one easily, but
the other,
against the second-worst team in the league, a real thriller) and have
thus (etc.)
-----------END-----------

And here is the code:

--------BEGIN CODE----------
1   #!/usr/local/bin/perl/ -w
2
3   use strict;
4  
5   my $infile = 'c:/www/visca/test/bpfrank.html';
6   my $outfile = 'c:/www/visca/texts/out.txt';
7   my $out2file = 'c:/www/visca/texts/out2.txt';
8  
9   open(OUT, ">$outfile") or die "Can't open $outfile $!\n";
10  open(IN, "$infile")  or die "Can't open $infile $!\n";
11  
12  while (<IN>) {
13    s/\n/ /g; # Replace unwanted newlines with space.
14    s{</p>}{</p>\n\n}g; # Make paragraphs after closing </p>...
15    s{(</h\d>)}{$1\n\n}g; # ...and after all header tags.
16    print OUT "$_";
17  }
18  close IN;
19  close OUT;
20  
21  open(OUT, "$outfile") or die "Can't open $outfile $!\n";
22  open(OUT2, ">$out2file") or die "Can't open $out2file $!\n";
23  
24  while (<OUT>) {
25    s/^ +<p/<p/g; # Eliminate whitespace before <p> tags.
26    print OUT2 "$_";
27  }
28  close OUT; close OUT2;
----END CODE------------

My question is why line 25 won't work if it's within the initial while
(<IN>) statement. It works if line 13 is a simple chomp, but then, of
course, some of the text runs together. I don't understand why
substituting a newline for a space then makes it impossible to
eliminate leading whitespace later on within the while statement.

Many thanks for your help.

-- 
Louie
louie@visca.com
http://www.visca.com/


------------------------------

Date: Sun, 12 Apr 1998 21:54:16 GMT
From: Tom Phoenix <rootbeer@teleport.com>
To: Louie <$louie@visca.com>
Subject: Re: Question concerning reg exp's in a while statement
Message-Id: <Pine.GSO.3.96.980412144658.25673Q-100000@user2.teleport.com>

On Sun, 12 Apr 1998, Louie wrote:

> 12  while (<IN>) {
> 13    s/\n/ /g; # Replace unwanted newlines with space.

Nothing wrong with that, but it would almost certainly be faster
with tr///. 

> 24  while (<OUT>) {
> 25    s/^ +<p/<p/g; # Eliminate whitespace before <p> tags.

That doesn't do what the comment says. Maybe you meant this:

    s/\s+<p/<p/gi;

 ...which is different in three important ways. (So, maybe you only want
one or two of those differences.) 

> My question is why line 25 won't work if it's within the initial while
> (<IN>) statement.

In what way does it not work?

Hope this helps!

-- 
Tom Phoenix       Perl Training and Hacking       Esperanto
Randal Schwartz Case:     http://www.rahul.net/jeffrey/ovs/



------------------------------

Date: Sun, 12 Apr 1998 17:16:03 -0700
From: John Callender <jbc@west.net>
Subject: Re: Relevance flames considered harmful (was Re: Q: Form CGI script...)
Message-Id: <35315943.8471E58C@west.net>

Randal Schwartz wrote:
> 
> John> The
> original
> John> poster wanted to know how to modify a Perl script to put a
> particular
> John> string in the "From: " header of an E-mail.
> 
> If it was /bin/mail, he couldn't have.  Hence, the information is
> relevant.

Noted. Thanks for pointing that out. The response that bugged me,
though, didn't ask for further information. After pointing out that the
mailer program hadn't been identified, it instructed the questioner not
to post the question to the group again, on the grounds that it had
nothing to do with Perl. As I read the question, though, he actually
*did* have a question (albeit a very basic one) about Perl: How do I
stick a given E-mail address into the From: field of the message via
this script?

> John> It's ironic that those who are especially rude to newcomers in
> this
> John> group tend to justify their hostility by painting their victims
> as
> John> intellectually lazy: "They don't bother to research the
> available
> John> documentation before posting, so I'm justified in publicly
> humiliating
> John> them."
> 
> But in this case, we truely *were* missing information.  I suggest you
> check your facts before you flame a response again.

Granted that I erred on the issue of whether or not the question could
be answered with the provided information. That wasn't my main beef,
though. What upset me was the knee-jerk "that's not a Perl question,
don't post that kind of thing here" response he got.

More and more frequently I see responses here that (to my mind) jump the
gun in slamming someone for being off-topic. Just because someone's
question is boringly repetitive, or betrays ignorance of some really
basic aspect of the language, doesn't mean it's not a Perl question.
Even if there are other, non-Perl issues (like mailer syntax, or
CGI-related stuff) that the questioner will have to grapple with en
route to a solution, shouldn't a person still be able to come to this
group for pointers on how to solve those parts of the problem that *are*
directly related to Perl?

The "off-topic" slam seems especially suspect to me, as I said before,
given the large amounts of off-topic chatter in this group. How is an
ignorant newcomer supposed to know that "My CEO can beat up your CEO" is
on-topic, while "How do I interpolate a variable into a string?" is not?

It seems obvious (to me at least) that what's really going on is that
there are people who would just as soon see all the newbie discussion
disappear, so they look for any excuse to classify a question as having
"nothing to do with Perl," even when it clearly does.

With all that said, I have to acknowledge that if your (Randal's) honest
opinion is that the original post really did have nothing to do with
Perl, then I'm wrong and you're right, and I apologize for taking up
everyone's time with my ignorant spouting.

Actually, I'll go beyond that. Even if the post did have something to do
with Perl, if you, Randal, think it deserved to be slammed as off-topic
and the poster sent packing from the group, for whatever reason,
non-relevance or insufficient prior homework or funky capitalization or
using the wrong newsreader or *whatever*, then again, I'm wrong and
you're right. All the animals in this group may be equal, but some are
far more equal than others. I'd much rather have a c.l.p.m. that is run
according to your notions of relevance than mine, even if that means the
rules look somewhat arbitrary from my perspective.

--
John Callender
jbc@west.net
http://www.west.net/~jbc/


------------------------------

Date: 13 Apr 1998 02:07:58 GMT
From: abigail@fnx.com (Abigail)
Subject: Re: Relevance flames considered harmful (was Re: Q: Form CGI script...)
Message-Id: <6grs1u$cnd$2@client2.news.psi.net>

John Callender (jbc@west.net) wrote on MDCLXXXVI September MCMXCIII in
<URL: news:35315943.8471E58C@west.net>:
++ Randal Schwartz wrote:
++ > 
++ > John> The
++ > original
++ > John> poster wanted to know how to modify a Perl script to put a
++ > particular
++ > John> string in the "From: " header of an E-mail.
++ > 
++ > If it was /bin/mail, he couldn't have.  Hence, the information is
++ > relevant.
++ 
++ Noted. Thanks for pointing that out. The response that bugged me,
++ though, didn't ask for further information. After pointing out that the
++ mailer program hadn't been identified, it instructed the questioner not
++ to post the question to the group again, on the grounds that it had
++ nothing to do with Perl. As I read the question, though, he actually
++ *did* have a question (albeit a very basic one) about Perl: How do I
++ stick a given E-mail address into the From: field of the message via
++ this script?

The proper answer would have been: "perldoc -f print"; that's the only
Perl aspect of the question. 



Abigail
-- 
perl -wle '$, = " "; sub AUTOLOAD {($AUTOLOAD =~ /::(.*)/) [0];}
           print+Just (), another (), Perl (), Hacker ();'


------------------------------

Date: 12 Apr 1998 22:18:12 -0400
From: mjd@op.net (Mark-Jason Dominus)
Subject: Re: Relevance flames considered harmful (was Re: Q: Form CGI script...)
Message-Id: <6grsl4$h0n$1@monet.op.net>

Mark-Jason Dominus wrote:
> It depends on your mail program, and since you didn't say what that
> is, we can't help you.  Try reading the documentation for whatever
> program is named in $mailprogram.  

In article <35310C12.6D64AADC@west.net>, John Callender  <jbc@west.net> wrote:
>Oh, come off it. The mailer syntax is implicit in the snippet he posted.

Well, maybe I misinterpreted the question, but I honestly thought he
was asking how to change the envelope-sender, and in that case, well,
no, it isn't implicit; it depends on the mailer like I said.  I gave
the best answer I honestly could [dto the question I thought he was
asking.  I seriously and gravely considered saying `You use the
-taddress command line option' (correct for `sendmail') but then I
decided that it would be a bad idea to say that, more likely to be
unhelpful and misleading than to be correct.  Maybe that was bad
judgement, but that's all it was, not genuine nastiness...

>I've noticed lately that this kind of knee-jerk relevance flame (even

 ...So you can take your knee-jerk `knee-jerk' and stick it up your knee.

>The answer (the likely answer, at least) is immediately obvious to
>anyone with any Perl experience:

All I can say is that it sure wasn't obvious to me.  Rereading the
original article with your remarks in mind, I find that it *still*
isn't obvious to me that your interpretation is correct.  I *still*
think that he is most likely asking how to set the envelope-sender, in
which case I did give him the best advice he was going to get, and
your advice is useless.  

That's not important, though.  Maybe I'm wrong about what the question
was, but I don't think I deserve all the crap you're dumping on me for
what was an honest mistake, and I don't think I deserve the
accusations you're making that I'm especially rude to newcomers, a
knee-jerk flamer, intellectually lazy, and I ``pour thousands of words
a day into rambling discussions that have nothing to do with the
language''.

Come off it, yourself.

Followups to alt.flame.



------------------------------

Date: Sun, 12 Apr 1998 19:12:06 -0400
From: "Bob Gwynne" <gwynne@utkux.utk.edu>
Subject: Re: Script URL
Message-Id: <6grifo$l1$1@gaia.ns.utk.edu>


Ken wrote in message <6gp38e$70u$1@ha2.rdc1.bc.wave.home.com>...
>I am new to perl programming (3 days) so please excuse me if my question is
>a little simplistic. Is there a way to find out the URL that was used to
>access a CGI script? Let's say someone enters
>http://mysite.com/refer.cgi?4325 (fictional url)
>I then need just the 4325


You would be well off to invest in a copy of Web Client Programming with
Perl by Clinton Wong. You can identify it by the drawing of Abigail
devouring a newbie on the cover.

You might also want to look at Randal Schwartz's Learning Perl and Jon
Ormont's Perl 5 (certified course.)

Bob Gwynne




------------------------------

Date: Sun, 12 Apr 1998 16:43:13 -0700
From: "Ken" <watkins@mailexcite.com>
Subject: Re: Script URL
Message-Id: <6grjhv$dkf$1@ha2.rdc1.bc.wave.home.com>



Thank you for the assistance, it is much appreciated.

My apologies to those I offend by posting to this newsgroup, I thought it
was the most appropriate one.






------------------------------

Date: Sun, 12 Apr 1998 19:53:59 -0400
From: cblack@qni.com
Subject: Sockets within a loop problem
Message-Id: <MPG.f9b1e1ff391c7999896b8@news.interport.net>

Hey there,

I have a newbie type question that I haven't been able to solve via the 
FAQs Docs or the newsgroups.

I'm writing an IRC gamebot and need to check the socket for commands for 
a specific amount of time. The problem is, the while loop doesn't 
complete unless there is something coming in on <S>. It'll just hang 
there within the loop until I send something to the socket, then and only 
then will the while loop complete. I read in the perl documentation that 
$| = 1; can be used to avoid socket stalls within loops, but it doesn't 
seem to work. What am I doing wrong here? Thanks in advance.

Chris.

sub checkforcommand {
  ($timelimit) = @_;
  $totime = time() + $timelimit;
  while (time() le $totime) {
    $_ = <S>;
    ((/^:(\S*)\!(\S*) PRIVMSG prog :(.*)/i) && &command($1,$2,$3));
  }
}


------------------------------

Date: Mon, 13 Apr 1998 00:06:39 GMT
From: Tom Phoenix <rootbeer@teleport.com>
To: cblack@qni.com
Subject: Re: Sockets within a loop problem
Message-Id: <Pine.GSO.3.96.980412170549.25673X-100000@user2.teleport.com>

On Sun, 12 Apr 1998 cblack@qni.com wrote:

>   while (time() le $totime) {

You probably don't want a string comparator there, even though it may
(seem to) work.

Hope this helps!

-- 
Tom Phoenix       Perl Training and Hacking       Esperanto
Randal Schwartz Case:     http://www.rahul.net/jeffrey/ovs/



------------------------------

Date: Mon, 13 Apr 1998 00:10:27 +0100
From: Andrew Boothman <andrew@boothman.easynet.co.uk>
Subject: Re: Test
Message-Id: <353149E3.9D797A03@boothman.easynet.co.uk>

mikep wrote:
> 
> This is a test

Test failed. You a missed a *.test newsgroup by at least half a click.




------------------------------

Date: Sun, 12 Apr 1998 16:09:16 -0700
From: Larry Rosler <lr@hpl.hp.com>
To: Tom Mornini <tmornini@netcom.com>
Subject: Re: wc -l in perl is??????
Message-Id: <3531499C.3A3B58B5@hpl.hp.com>

Tom Mornini wrote:
> 
> Matt Taylor (nospam@rnoc.com) wrote:
> 
> : I need a function like the unix wc (aka wordcount function) that
> : allows me to print out how many lines there are in a file. Is there
> : something like this built into perl?  The idea is to randomly read a
> : line from a file which is basicly a pointer to a url.
> 
> ----------
> #!/usr/bin/perl -w
> 
> # the most obvious way, to me
> 
> use strict;
> 
> my $line=0;
> 
> while (<>)
>  {
>   $line++;
>  }
> 
> print "$line\n";
> ----------
> 
> or
> 
> ----------
> #!/usr/bin/perl -w
> 
> # almost certainly faster. Certainly uses more memory.
> 
> use strict;
> 
> my $line=my @file=<>;
> 
> print "$line\n";
> ----------
> 
> Interesting! The "obvious" way is much faster than the "almost
> certainly faster" method. That'll teach me to make any assumptions!
> 
> Perhaps I shouldn't even assume that it uses more memory... :-)
> 
> Talk about a lose/lose situation!
> 
> Does anyone know why this might be?
>
> LONG SNIP OF timex results
> 
> -- Tom Mornini
> -- InfoMania

I can guess why slurping the entire file into an array is slower than
reading it line by line.  Probably the overhead involves appending line
after line to an array that has not been preallocated.

But if you don't mind having the entire file in memory at once, there is
a *much* faster way yet.  It is an excellent way of counting characters
from a set in a string.  As the books are in the office, I can't recall
where I saw it first.  See below (L3):

#!/usr/local/bin/perl -w
use strict;
use diagnostics;
use Benchmark;

timethese (1 << 4, {
    L1 => q{
	open IN, 'file' or die $!;
	my $lines = my @file = <IN>;
    },
    L2 => q{
	open IN, 'file' or die $!;
	my $lines = 0;
	while (<IN>) { ++$lines }
    },
    L3 => q{
	open IN, 'file' or die $!;
	local $/;
	my $file = <IN>;
	$lines = $file =~ tr/\n//;
    },
} );

Benchmark: timing 16 iterations of L1, L2, L3...
        L1:  4 secs ( 3.77 usr  0.16 sys =  3.93 cpu)
        L2:  3 secs ( 2.68 usr  0.12 sys =  2.80 cpu)
        L3:  1 secs ( 0.94 usr  0.23 sys =  1.17 cpu)

Larry Rosler
Hewlett-Packard Laboratories
lr@hpl.hp.com


------------------------------

Date: Sun, 12 Apr 1998 21:03:55 GMT
From: tmornini@netcom.com (Tom Mornini)
Subject: Re: Why am I getting an error with @_  ?
Message-Id: <tmorniniErBJuJ.AIA@netcom.com>

Bryan T Hoch (bth@acsu.buffalo.edu) wrote:
: 	Hi all.
: 	This may seem like a really dumb question, but to me it's not (I'm
:       still just learning Perl).
: 	When I run a sub routine I get an error involving @_ . The error I
:       get says this:

: syntax error at database.pl line 78, near "sub drop_table_1"
: Can't use global @_ in "my" at database.pl line 80.

I re-enter your code like this:

#!/usr/bin/perl -w

use strict;

&drop_table_1('testing...');

sub drop_table_1
 {
   my($table_tablename) = @_ ; #parameter being passed in.
   print $table_tablename;
 }

and it worked fine. From the error message, I would guess it's some
sort of packaging issue, but it could be something as simple as a
missing semicolon to a switch of parenthesis and braces in the code
above the subroutine.

You might want to try the -w switch and use strict. In addition,
use diagnostics will give you more wordy error messages that are
occasionally more meaningful.

-- Tom Mornini
-- InfoMania


------------------------------

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 2305
**************************************

home help back first fref pref prev next nref lref last post