[17680] in Perl-Users-Digest

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

Perl-Users Digest, Issue: 5100 Volume: 9

daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Wed Dec 13 09:05:31 2000

Date: Wed, 13 Dec 2000 06:05:09 -0800 (PST)
From: Perl-Users Digest <Perl-Users-Request@ruby.OCE.ORST.EDU>
To: Perl-Users@ruby.OCE.ORST.EDU (Perl-Users Digest)
Message-Id: <976716309-v9-i5100@ruby.oce.orst.edu>
Content-Type: text

Perl-Users Digest           Wed, 13 Dec 2000     Volume: 9 Number: 5100

Today's topics:
    Re: =~ operator <bart.lateur@skynet.be>
    Re: Better way to remove lines from output? Odd_Carnivals@yahoo.com
    Re: DBI prepare method (Abigail)
        Extracting a substring from a string dazza100@my-deja.com
    Re: Extracting a substring from a string (Bernard El-Hagin)
    Re: Extracting a substring from a string <wyzelli@yahoo.com>
        General Tool(s) for browsing/editing DB tables? <visstmbl@reading.ac.uk>
        http_referer Problem!? eurodomains@my-deja.com
    Re: http_referer Problem!? <tinamue@zedat.fu-berlin.de>
    Re: Perl 5.6, Regexp, performance problems hume.spamfilter@bofh.halifax.ns.ca
    Re: Posting Guidelines for comp.lang.perl.misc ($Revisi <bart.lateur@skynet.be>
    Re: Posting Guidelines for comp.lang.perl.misc ($Revisi <iltzu@sci.invalid>
    Re: Posting Guidelines for comp.lang.perl.misc ($Revisi (Martien Verbruggen)
    Re: Posting Guidelines for comp.lang.perl.misc ($Revisi (Tad McClellan)
    Re: Posting Guidelines for comp.lang.perl.misc ($Revisi (Tad McClellan)
    Re: Posting Guidelines for comp.lang.perl.misc ($Revisi (Tad McClellan)
    Re: Posting Guidelines for comp.lang.perl.misc ($Revisi (Abigail)
    Re: Printing Vertically <nospam.newton@gmx.li>
    Re: Printing Vertically <joe+usenet@sunstarsys.com>
    Re: scan and read mails from /var/mail (Abigail)
    Re: sighandler, and strict (Stan Brown)
    Re: sighandler, and strict (Rafael Garcia-Suarez)
    Re: sighandler, and strict <bart.lateur@skynet.be>
    Re: this cgi starts download why?? (TrainsCan)
        what should managers know about perl? <renenyffenegger@my-deja.com>
        Why no answers to offtopic questions (was: Adding a Bcc (Martien Verbruggen)
        Digest Administrivia (Last modified: 16 Sep 99) (Perl-Users-Digest Admin)

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

Date: Wed, 13 Dec 2000 11:53:12 GMT
From: Bart Lateur <bart.lateur@skynet.be>
Subject: Re: =~ operator
Message-Id: <4hoe3tobah5pp51hbjd23vd7njid1ipf4c@4ax.com>

Martin Schmidt wrote:

>What is the =~ operator called?
>I'm reading 'Learning Perl' and they just call it the
>=~ operator.

"bind" or "apply". You apply the pattern match, substitution, or
transliteration, to the scalar on the left. Or, you bind them together.

Note that currently, =~ is only used in conjuction with regexes and
(remotely) related stuff. However, there's nothing in this operator that
would prevent this from ever being used in entirely different contexts.
It is hardly necessary for syntaxes that look like functions, i.e. main
word plus parameters, but it would make some sense to be able to use it
in every situation where one of the parameters gets modified by the
function call (for example, substr or vec).

-- 
	Bart.


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

Date: Wed, 13 Dec 2000 13:48:44 GMT
From: Odd_Carnivals@yahoo.com
Subject: Re: Better way to remove lines from output?
Message-Id: <917unp$h7f$1@nnrp1.deja.com>

Thanks for the tip on chomp, that looks like the way
to go for getting rid of the linebreak.

Your code chomps the last line of the file rather than
the next-to-last (which is what my code does). Any
thoughts on the best way to chomp the next-to-last?

----------

In article <9165cc$4cg$1@nnrp1.deja.com>,
  guthrie_linck@my-deja.com wrote:
> print OUT scalar(<IN>);
>
> <IN>;
> <IN>;
>
> while (<IN>) {
>   chop if eof IN;
>   print OUT;
> }
>
> # how good is that?????
>
> In article <9163c7$2e9$1@nnrp1.deja.com>,
>   Odd_Carnivals@yahoo.com wrote:
> > Hi Perl gurus,
> >
> > Any suggestions for how the following could be improved?
> > What I'm doing is creating an output file that is identical
> > to the input file minus the second, third and last lines,
> > and with the  linebreak removed from the next-to-last line
> > (i.e. the last line of the output file).
> >
> > The following works, but I suspect there are better ways
> > to do it (I'm new to Perl).
> >
> > $prev_line = <IN>; # Keep line 1.
> > while($. < 3) {<IN>}; # Skip lines 2 & 3.
> > while($line = <IN>) {
> >     print OUT ($prev_prev_line);
> >     $prev_prev_line = $prev_line;
> >     $prev_line = $line;
> >  }
> > $prev_prev_line =~ s/\n//; #remove linebreak
> > print OUT ($prev_prev_line);
> >
> > Thanks!
> >
> > Sent via Deja.com
> > http://www.deja.com/
> >
>
> Sent via Deja.com
> http://www.deja.com/
>


Sent via Deja.com
http://www.deja.com/


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

Date: 13 Dec 2000 12:17:24 GMT
From: abigail@foad.org (Abigail)
Subject: Re: DBI prepare method
Message-Id: <slrn93eq6k.9uu.abigail@tsathoggua.rlyeh.net>

On 12 Dec 2000 23:05:02 -0200, Jorge Godoy (godoy@conectiva.com) wrote in comp.lang.perl.misc <URL: news:<kpsnnt9lmp.fsf@dagon.conectiva>>:
++ 
++ You should try $dbh->do("SELECT ...."); for your SELECT. I don't know
++ if it will work.

Well, first of all you shouldn't be using "do", that's for non-select
statements. DBI does have other methods you could use, the longish named
selecteverything_insomeformofdatastructure() and friends.

But they are just wrappers around the prepare, execute, fetch methods.


Abigail


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

Date: Wed, 13 Dec 2000 11:11:40 GMT
From: dazza100@my-deja.com
Subject: Extracting a substring from a string
Message-Id: <917lh9$ado$1@nnrp1.deja.com>

Hello,

I'm new to Perl. Could someone please tell me how
I would take a string like

message_address:[0xbd0b48] info:order_acpt

and extract the hex number between the '[' and ']'

Thanks,

Darren



Sent via Deja.com
http://www.deja.com/


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

Date: Wed, 13 Dec 2000 11:28:47 +0000 (UTC)
From: bernard.el-hagin@lido-tech.net (Bernard El-Hagin)
Subject: Re: Extracting a substring from a string
Message-Id: <slrn93enbe.7b.bernard.el-hagin@gdndev25.lido-tech>

On Wed, 13 Dec 2000 11:11:40 GMT, dazza100@my-deja.com
<dazza100@my-deja.com> wrote:
>Hello,
>
>I'm new to Perl. Could someone please tell me how
>I would take a string like
>
>message_address:[0xbd0b48] info:order_acpt
>
>and extract the hex number between the '[' and ']'

$_ = 'message_address:[0xbd0b48] info:order_acpt';

print (substr $_, 17, 8);

or, if you don't know where in the string the [] will appear:

print $1 if /\[([^\]]*)\]/;

Cheers,
Bernard
--
perl -le '$#="Just Another Perl Hacker"; print \Bernard'


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

Date: Wed, 13 Dec 2000 21:07:05 +0930
From: "Wyzelli" <wyzelli@yahoo.com>
Subject: Re: Extracting a substring from a string
Message-Id: <CbJZ5.11$fC.1293@vic.nntp.telstra.net>

<dazza100@my-deja.com> wrote in message news:917lh9$ado$1@nnrp1.deja.com...
> Hello,
>
> I'm new to Perl. Could someone please tell me how
> I would take a string like
>
> message_address:[0xbd0b48] info:order_acpt
>
> and extract the hex number between the '[' and ']'
>

$hex = $1 if m/\[([\dxa-f]+)\]/i;

$1 contains the first capturing parentheses, the i makes the match case
insensitive.  I have done it with an if statement so $hex only gets set if
the match is successful, not to the content of $1 in any possible previous
match.

check perlre, the documentaion on regular expressions.

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: Wed, 13 Dec 2000 13:51:09 +0000
From: John Stumbles <visstmbl@reading.ac.uk>
Subject: General Tool(s) for browsing/editing DB tables?
Message-Id: <Pine.WNT.4.30.0012122248580.113-100000@supc16.rdg.ac.uk>

<lazy>

	Is there a module or some ready-rolled utilit[y|ies] for browsing
and editing databases/tables/records via DBI/DBD? I'm thinking od the sort
of visual tool one gets with MS (sorry :-) Access where you can point and
drag fields from tables to indicate relations etc. I did get partway
through a homebrew effort using a CGI front end but it was slow and not
very functional, and I guess Perl/TK would be better for an interface.

</lazy> ;-)

regards,

--
John Stumbles                                      j.d.stumbles@reading.ac.uk
I.T. Services Centre,   University of Reading  http://www.rdg.ac.uk/~visstmbl
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
                            never generalise






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

Date: Wed, 13 Dec 2000 11:27:53 GMT
From: eurodomains@my-deja.com
Subject: http_referer Problem!?
Message-Id: <917mfk$b5i$1@nnrp1.deja.com>

Hello,

I do need to rewrite a perl form script. The additional lines I will
need are the lines for "http_referer"

The script has only to accept referers from 3 different class c networks
- and the script has to evaluate the IP numbers NOT the referring URL
like for example http://callingwebsite.com/form.html
The script has to know that "callingwebsite.com" is an acceptable host
(IP ) or not.

If http_referer is on an outside host, the Script has simply to exit
with " The website you have used has no permission to execute my
script!"

The script is running on IIS 5.0 ( Win2000 server )


Thanks for every help!

Thomas


Sent via Deja.com
http://www.deja.com/


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

Date: 13 Dec 2000 13:02:46 GMT
From: Tina Mueller <tinamue@zedat.fu-berlin.de>
Subject: Re: http_referer Problem!?
Message-Id: <917s1m$2mdti$1@fu-berlin.de>

hi,
eurodomains@my-deja.com wrote:

> I do need to rewrite a perl form script. The additional lines I will
> need are the lines for "http_referer"

read the environment variable HTTP_REFERER

> If http_referer is on an outside host, the Script has simply to exit
> with " The website you have used has no permission to execute my
> script!"

you must know that some environment variables can
be manipulated. NN and IE set it by themselves, and they
set it as you would expect, but i can write a browser with
LWP::UserAgent and set the referer by myself.
so that doesn't give you real security. if you want it, you
have to deal with session management.

hth,
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: Wed, 13 Dec 2000 13:59:35 +0000 (UTC)
From: hume.spamfilter@bofh.halifax.ns.ca
Subject: Re: Perl 5.6, Regexp, performance problems
Message-Id: <917vc7$98g$1@News.Dal.Ca>

guthrie_linck@my-deja.com wrote:
> performace hit here is coming from the fact that it has to recompile the
> regular expressions each time. i wouldn't use the Regexp module. i've

The Regexp module basically gave a handle to a stored, compiled regex.  I
believed the qr// in Perl 5.6 would perform the same function.  Either I'm
mistaken, or qr// has more overhead associated with it, or I'm using it in
the wrong way.

I'll give your idea a try, though it doesn't seem intuitive.  (But then again,
is anything in Perl?)

-- 
Brandon Hume    - hume -> BOFH.Halifax.NS.Ca, http://WWW.BOFH.Halifax.NS.Ca/
                       -> Solaris Snob and general NOCMonkey


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

Date: Wed, 13 Dec 2000 12:32:25 GMT
From: Bart Lateur <bart.lateur@skynet.be>
Subject: Re: Posting Guidelines for comp.lang.perl.misc ($Revision: 0.1 $)
Message-Id: <k1re3t81usob3dei3u3msd5snf92bnt70b@4ax.com>

Tad McClellan wrote:

>How about the below?

>=item Use an effective followup style
 ...
>Intersperse your comments B<following> the sections of quoted text
>that your comment applies to.

You could also mention the term "Jeopardy style", and why people don't
like it.

-- 
	Bart.


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

Date: 13 Dec 2000 12:36:16 GMT
From: Ilmari Karonen <iltzu@sci.invalid>
Subject: Re: Posting Guidelines for comp.lang.perl.misc ($Revision: 0.1 $)
Message-Id: <976710321.22736@itz.pp.sci.fi>

In article <slrn93dqsm.17v.tadmc@maxim.metronet.com>, Tad McClellan wrote:
>Jeff Zucker <jeff@vpservices.com> wrote:
>>I
>>suggest instead replacing everything after the comma with: "there are a
>>number of measures that each reader can take to make the group most
>>useable by the most number of people."  Puts it more in the realm of
>>personal responsibility rather than rules from the top.
>
>I'll reword it somehow. Can anyone recommend a way without
>the /most.*most/s in it? That sounds kinda cumbersome.

The problem is that a) "most number of" isn't English, and b) the
precise intent of that sentence really isn't that clear when one gets
down to it.  Let's see:

  ... there are a number of measures that all of us can take to make
  the group as useful as possible for everyone.

  ... there are a number of measures that all of us can take to make
  the group more useful for as many people as possible.

  ... there are a number of measures that all of us can take to make
  the group as useful as possible for as many people as possible.

The first wording emphasises usefulness, the second inclusiveness, and
the last has a semi-deliberate bit of repetition to emphasise the
equality of the two goals.  Personally, I'd prefer the last one most,
and the first one more than the second, but YMMV.

-- 
Ilmari Karonen -- http://www.sci.fi/~iltzu/
"Get real!  This is a discussion group, not a helpdesk.  You post
 something, we discuss its implications.  If the discussion happens to
 answer a question you've asked, that's incidental." -- nobull in clpm



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

Date: Wed, 13 Dec 2000 22:53:32 +1100
From: mgjv@tradingpost.com.au (Martien Verbruggen)
Subject: Re: Posting Guidelines for comp.lang.perl.misc ($Revision: 0.1 $)
Message-Id: <slrn93eops.o20.mgjv@martien.heliotrope.home>

On Tue, 12 Dec 2000 21:23:02 -0600,
	Tad McClellan <tadmc@metronet.com> wrote:
> Jeff Zucker <jeff@vpservices.com> wrote:
> 
>>I
>>suggest instead replacing everything after the comma with: "there are a
>>number of measures that each reader can take to make the group most
>>useable by the most number of people."  Puts it more in the realm of
>>personal responsibility rather than rules from the top.
> 
> I'll reword it somehow. Can anyone recommend a way without
> the /most.*most/s in it? That sounds kinda cumbersome.

 ...make the group most effective for the largest number of people.


Martien
-- 
Martien Verbruggen              | 
Interactive Media Division      | Useful Statistic: 75% of the people
Commercial Dynamics Pty. Ltd.   | make up 3/4 of the population.
NSW, Australia                  | 


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

Date: Tue, 12 Dec 2000 22:36:36 -0600
From: tadmc@metronet.com (Tad McClellan)
Subject: Re: Posting Guidelines for comp.lang.perl.misc ($Revision: 0.1 $)
Message-Id: <slrn93dv6k.1c0.tadmc@maxim.metronet.com>

Martien Verbruggen <mgjv@tradingpost.com.au> wrote:
>On Tue, 12 Dec 2000 06:43:40 -0600,
>	Tad McClellan <tadmc@metronet.com> wrote:
>> 
>>=head2 How to participate (post) in the clpm community
>> 
>>=over 4
>
>[snippage]
>
>=item Do not post binaries, HTML, or MIME


Done.


-- 
    Tad McClellan                          SGML consulting
    tadmc@metronet.com                     Perl programming
    Fort Worth, Texas


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

Date: Tue, 12 Dec 2000 23:22:49 -0600
From: tadmc@metronet.com (Tad McClellan)
Subject: Re: Posting Guidelines for comp.lang.perl.misc ($Revision: 0.1 $)
Message-Id: <slrn93e1t9.1c0.tadmc@maxim.metronet.com>

Jorge Godoy <godoy@conectiva.com> wrote:
>On Tue, 12 Dec 2000, tadmc@metronet.com wrote:
>> 
>> Try doing a word-search in the standard docs for some words/phrases 
>> taken from your problem statement or from your very carefully 
>> worded C<Subject:> header.
>
>OK... I agree with everything so far. I suggest that you add some
>examples of how to do that search. There was a post of yours from what
>you teach that was very nice here.
>
>Even some "grep" commands and also 'perldoc -q' and 'perldoc -f'
>examples. 


No, that is beyond the scope of what we're trying to do (I think).

This is not "everything you can do to help yourself with Perl problems".
This is "what you should do when posting to clpmisc".

That is, it is about the "what", not about the "how". It can
easily get so big that it will simply be ignored by its intended 
audience (like the real Perl FAQs are ignored).

We must be really hard-hearted about how we spend our "line count".

Maybe we need a series of other small articles? Let's put that
off until after we get our "list of whats" hammered out.


>> =item 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.
>
>You put an example of such archive below. It could be here
>also... Maybe with some more archives where one can get messages to
>read. 


I don't think that is valuable enough for the space it would take.

And I would rather not encourage power lurking instead of real
lurking anyway. I almost snipped that part out earlier...


>> =head1 Posting to comp.lang.perl.misc
>> 
>> There can be 200 messages in clpm in a single day. Nobody is going 
>> to read every article. So they must decide somehow which articles 
>> they are going to read, and which they will skip.
>
>I would comment on using 'clpm' in the beginning of the text. You
>should choose either 'clpmisc' or 'clpm'. I like more the latter. 


I struggled with trying to unify that (along with a 3rd candidate,
clp.misc).

I don't like clpm because there are 3 newsgroups with those initials.

   So, which does the group like?

   clpmisc or clp.misc ?


>> =item Question should be about Perl, not about the application area
>
>(SNIP)
>
>> It is understood that you may not know that the root of your problem
>> is not Perl-related (the two most frequent ones are CGI and
>> Operating System related). So off-topic postings will happen from
>> time to time.  Be gracious when someone helps you find a better
>> place to ask your question by pointing you to a more applicable
>> newsgroup.
>
>As these questions are frquently asked _wrongly_ here in clpm, it
>would be nice to have pointers to the right groups to post about
>them. 


Doesn't the initial auto-email message handle that?

   (is that even still happening?)

If we say it again, they'll just ignore it again.

Pointers to more correct places for other topics is repeating
info already "out there". Where is the "value add" in spending
lines on it again here?


>> =item Do not expect people to do a machine's work
>
>(SNIP)
>
>Maybe speaking about running 'perl -dw script.pl'? It's helpful to see
>some logical problems instead of only the lexical ones.


So are strategically placed print() statements. So we should 
mention that too? 

I don't see value for the lines that would be spent.

We can't "do it all" in a eight-page blurb. Some things that
we want to do we will have to leave undone (or make some
more 8-page articles to put them in).


>> If you are flamed for not checking when you I<did> check, then
>> just shrug it off (and take the answer that you got).
>
>"As of RFC 1855: don't get involved in flame wars. It's bad for you
> and for the whole group."


Too "legalistic" sounding.


>Nice job! I liked that. 


Thanks...


>Maybe you could borrow some parts from RFC
>1855 (netiquette) or cite it too. 


 ...now you can help too :-)


Give me a URL, I'll put it in. (and you *can* just email me that :-)


-- 
    Tad McClellan                          SGML consulting
    tadmc@metronet.com                     Perl programming
    Fort Worth, Texas


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

Date: Tue, 12 Dec 2000 23:32:24 -0600
From: tadmc@metronet.com (Tad McClellan)
Subject: Re: Posting Guidelines for comp.lang.perl.misc ($Revision: 0.1 $)
Message-Id: <slrn93e2f8.1c0.tadmc@maxim.metronet.com>

I myself <tadmc@metronet.com> wrote:
>
>Here is a start on some Posting Guidelines for our newsgroup.
>
>Please review it and _post_ your comments (no email).


A summary thus far:

Note my reluctance to let this article get "big". If you'd like
to argue for more than 4 pages worth go ahead, but I'll treat
that as a hard requirement unless convinced otherwise.

You can make conversational comments if you like, and we will
discuss it, but providing real wording that can be pasted right 
it makes it much easier to accept without discussion (hint).

There have been many very good suggestions that just don't fit
the purpose of this article, or that _do_ fit but are left out
for space considerations.

Perhaps we can have several short "primers" to refer folks to.
But we can't be autoposting 10 articles either...

For instance, I plan to make a discussion of killfiles and scoring
for those that are not familiar with real newsreading tools.

Another possibility is an article parallel to this one discussing
the "why" of the points made here. eg. asking a FAQ is bad because:
wastes time on already-answered questions, may get wrong answers
that require more followups to correct, etc...



I'll let this article "simmer" for a couple days, and then post the 
0.2 version for another go-round.


A few questions that I solicit comments on:

   How often should it be posted?

   Do we want a "flag" in the Subject for filtering purposes?

   Anybody have a host to post it from (mine will be in flux shortly).


-- 
    Tad McClellan                          SGML consulting
    tadmc@metronet.com                     Perl programming
    Fort Worth, Texas


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

Date: 13 Dec 2000 13:59:13 GMT
From: abigail@foad.org (Abigail)
Subject: Re: Posting Guidelines for comp.lang.perl.misc ($Revision: 0.1 $)
Message-Id: <slrn93f05h.9uu.abigail@tsathoggua.rlyeh.net>

On Tue, 12 Dec 2000 23:32:24 -0600, Tad McClellan (tadmc@metronet.com) wrote in comp.lang.perl.misc <URL: news:<slrn93e2f8.1c0.tadmc@maxim.metronet.com>>:
++ 
++    Do we want a "flag" in the Subject for filtering purposes?


No, not in the Subject. In the From: line, so one can filter out the
guidelines, but still see any possible followups.



Abigail


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

Date: Wed, 13 Dec 2000 12:43:16 +0100
From: "Philip 'Yes, that's my address' Newton" <nospam.newton@gmx.li>
Subject: Re: Printing Vertically
Message-Id: <66oe3t02t0nlfupgmg9i4shu359v3mm8s2@4ax.com>

On Tue, 12 Dec 2000 22:12:52 -0500, Jeff Pinyan <jeffp@crusoe.net>
wrote:

> Oh, here's the shortest I've come up with now:
> 
>   s/./$&\n/sg;print;
> 
> 18 chars.

Well, you can probably drop the final semicolon.

Cheers,
Philip
-- 
Philip Newton <nospam.newton@gmx.li>
If you're not part of the solution, you're part of the precipitate


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

Date: 13 Dec 2000 07:51:25 -0500
From: Joe Schaefer <joe+usenet@sunstarsys.com>
Subject: Re: Printing Vertically
Message-Id: <m3k894eb76.fsf@mumonkan.sunstarsys.com>

"Philip 'Yes, that's my address' Newton" <nospam.newton@gmx.li> writes:

> On Tue, 12 Dec 2000 22:12:52 -0500, Jeff Pinyan <jeffp@crusoe.net>
> wrote:
> 
> > Oh, here's the shortest I've come up with now:
> > 
> >   s/./$&\n/sg;print;
> > 
> > 18 chars.
> 
> Well, you can probably drop the final semicolon.

Since that would be cheating, here's another one

map{print}/./sg

(requires the l flag, so 15+1, or +2 if you count the - sign :)

-- 
Joe Schaefer


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

Date: 13 Dec 2000 12:52:16 GMT
From: abigail@foad.org (Abigail)
Subject: Re: scan and read mails from /var/mail
Message-Id: <slrn93es80.9uu.abigail@tsathoggua.rlyeh.net>

On Tue, 12 Dec 2000 21:55:01 GMT, jagman98@home.com (jagman98@home.com) wrote in comp.lang.perl.misc <URL: news:<3A36A115.7D8149BD@home.com>>:
++ How can I scan and read mails using perl from /var/mail.  Thanks in
++ Advance.



    #!/opt/perl/bin/perl -w
    use strict;

    opendir DIR, "/var/mail" or die "opendir: $!";
    while (my $file = readdir DIR) {
	next if $file eq "." || $file eq "..";
	$file = "/var/mail/$file";
	next unless -f $file;
	open FILE, $file or die "open: $!";
	print while <FILE>;
	close FILE;
    }
    closedir DIR;

    __END__


Abigail


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

Date: 13 Dec 2000 06:48:21 -0500
From: stanb@panix.com (Stan Brown)
Subject: Re: sighandler, and strict
Message-Id: <917nm5$kq2$1@panix3.panix.com>

In <uisc3tgp2gkkc6t2nci5d3a3h9l3g820eb@4ax.com> Bart Lateur <bart.lateur@skynet.be> writes:

>Stan Brown wrote:

>>	How should I set up a signal handler in a script where I have strict
>>	turned on?
>>
>>	The perdoc example dose not seem to work with this turned on.
>>	Specificaly the program won't precompile.

>I can't imagine what you're talking about. But at least, reference your
>subs by reference, not by name.

>	$SIG{WHATEVER} = \&mysub; #not "mysub"

	I guess the question is, where do I declare $SIG? 



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

Date: Wed, 13 Dec 2000 12:36:20 GMT
From: rgarciasuarez@free.fr (Rafael Garcia-Suarez)
Subject: Re: sighandler, and strict
Message-Id: <slrn93erc3.8qn.rgarciasuarez@rafael.kazibao.net>

Stan Brown wrote in comp.lang.perl.misc:
> 
> >	$SIG{WHATEVER} = \&mysub; #not "mysub"
>
> 	I guess the question is, where do I declare $SIG? 

$SIG needs not to be declared : it's a special variable, and as a
special variable, it's described in the perlvar section of the standard
docs. (Moreover, it's always forced into the 'main' package, as
specified in perlmod).

-- 
# Rafael Garcia-Suarez / http://rgarciasuarez.free.fr/


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

Date: Wed, 13 Dec 2000 13:53:45 GMT
From: Bart Lateur <bart.lateur@skynet.be>
Subject: Re: sighandler, and strict
Message-Id: <6sve3tc1q9efrcri4uhun5jvosebpm6986@4ax.com>

Rafael Garcia-Suarez wrote:

>> >	$SIG{WHATEVER} = \&mysub; #not "mysub"
>>
>> 	I guess the question is, where do I declare $SIG? 
>
>$SIG needs not to be declared : it's a special variable, and as a
>special variable,

Except that it's %SIG, not $SIG.

-- 
	Bart.


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

Date: Wed, 13 Dec 2000 13:56:24 GMT
From: tcg@TrainsCan.com (TrainsCan)
Subject: Re: this cgi starts download why??
Message-Id: <3a377e8b.5357829@news.maxim.ca>

On Mon, 11 Dec 2000 16:58:02 +0000, rob burnett
<kingcaller@hotmail.com> wrote:
 ...
>the above code when started with my form starts ie or netscape to start
>a download for the cgi script i'm new to all this and i can't work out
>why any help will be appreciated

Possibly the .cgi does not have execute permissions set.  With my
server/browser/whatever setup, if I forget to make the .cgi
executeable, my browser offers to download the script instead of
executing it.



######    |\^/|    Timothy C. Green, CD, PEng, MEng
###### _|\|   |/|_  tcg@TrainsCan.com
###### >         <  TrainsCan, RailWeb, TCG PEng
######  >_./|\._<  http://www.TrainsCan.com


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

Date: Wed, 13 Dec 2000 11:32:18 GMT
From: Rene Nyffenegger <renenyffenegger@my-deja.com>
Subject: what should managers know about perl?
Message-Id: <917mo2$b8d$1@nnrp1.deja.com>

Hi everyone

I thought there was a faq on www.perl.com: "What should
managers know about perl?" that dealt with issues
like support and the like. Now, I don't find it anymore.
Maybe because it had another name, maybe because I don't
recall correctly.

I am asking for this (or something similar) because we are
trying to convince some managers to use perl in our
production environment.


TIA
Rene


Sent via Deja.com
http://www.deja.com/


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

Date: Wed, 13 Dec 2000 22:45:40 +1100
From: mgjv@tradingpost.com.au (Martien Verbruggen)
Subject: Why no answers to offtopic questions (was: Adding a Bcc recipient?)
Message-Id: <slrn93eob4.o20.mgjv@martien.heliotrope.home>

[This is going to be an offtopic lecture. Skip it if you're not
interested in Usenet policies, but only in Perl]

[Note the followup. Override it only if you feel that the group should
still be involved in the discussion]

On Sun, 10 Dec 2000 23:29:46 -0700,
	Michael Cook <mikecook@cigarpool.com> wrote:
> "Martien Verbruggen" <mgjv@tradingpost.com.au> wrote in message
> news:slrn938b68.nr.mgjv@verbruggen.comdyn.com.au...
>> On Wed, 6 Dec 2000 21:56:08 -0700,
>> Michael Cook <mikecook@cigarpool.com> wrote:
> 
>> Your post contained many bad things. Whether or not you would fix
>> these in your production code is beside the point. You presented code,
>> so you should not be surprised when others criticise it, especially if
>> you know (and you claim you do) that it contains potential nasty
>> surprises for the less experienced cut-and-paster.
> 
> BTW, I am not surprised it was criticized - the point here was that someone
> asked a question & received no help - my code snippet should have been more

The reason that no help was offered was because the question had nothing
to do with perl whatsoever.  We tend to try to not answer question that
aren't about Perl. If you read Tad's post about the rules that we're
trying to lay down for this group, you might understand. There is too
much traffic here to also take on all kinds of questions about email,
CGI, operating systems, TCP/IP, DNS, or general algorithms. All those
questions get asked here, and petitioners should be redirected to more
appropriate groups. In this particular case that maybe didn't happen
gently enough, but that doesn't diminish the fact that the question was
offtopic.

We'd like to discuss Perl here. Sometimes that gets some non-Perl issues
involved, but the core of the discussion should always be Perl. The OP's
question was offtopic. It became a Perl discussion when you posted code
that could do with a bit of improvement. [1]

> complete, but it helped the original poster and I was the only one that
> offered anything other than high-handed, patronizing responses. I also wrote
> that I would be happy to help further and please email for more details. I
> never claimed to be an expert with perfect code, but the code I have written

No one said you claimed that.

> does work and has been researched extensively. I would *love* to have
> someone go over my code and (constructively) point out where I could improve
> it, but do not have those resources available.

Posting it here will almost certainly assure that someone will do
exactly that :)

> If you were a beginner and were stuck, would you rather have someone give
> you some code that works (albeit incomplete) or would you rather be told to
> buzz off? I was very frustrated in the beginning & got the brush off from

If you had a question, would you rather have someone give you an answer
that might, or might not work, most of the time, or almost always, and
that may be incomplete or not entirely correct, or would you rather be
told that you should go ask the experts somewhere else?

Most of the followups to offtopic posts come from people needing to
correct the perl code, but also often the offtopic issue at hand, when
someone else felt they should just have a stab at it. Usenet is a
peer-reviewed medium. Whenever you think you know someothing, you can be
certain someone else will know better. Especially answers that address
an offtopic issue attract extra attention, most of the time because
they're wrong, or incomplete. The reason for that is mainly that the
people who really know what the answers are, correctly, are least likely
to answer, because thay also are the people who know that this woudln't
be the place to answer it. Some people probably sent email, stating that
it was offtopic, but here's your answer, and next time please find a
better place to post. I know for a fact that many regulars here do this.
Not seeing any answers on this group to an offtopic post doesn't mean
there weren't any, just that they didn't get posted here, and correctly
so.

> many who had the ability to help and took the time to put me down instead
> (which took longer than helping would have in many cases). Sometimes I feel
> that this is an elitist, self-serving club in many aspects rather than a
> community (but I really enjoy programming {not my line of work}and helping
> others when I can).

Many people complain about this: This group being elitist and
self-serving. However, in the years that I've hung around here, I've
seen many people come and go, and some come back. Many people who knew
nothing at one point, learned a lot from the posts to this group. There
is no real elitism here, and if we were self-serving, we wouldn't even
bother to read or answer any of these questions, would we? We'd be
someowhere else, making money in the time that we spend here. The
elitism that people perceive (although I suspect it's more a matter of
grasping for a word that expresses more about the user's internal state
than about the actual motivations of this group) doesn't really exist
either. Most people here, the regulars, tend to be very helpful, in a
non-condescending way, as long as the issue is on topic, and the poster
shows that they're willing to learn, and to do the work themselves. All
therough and hard answers I've seen are to off topic posts, or to
requests that show a an unwillingness to do any work, the hand-out
begging posts. 

Sure, some answers are too harsh. It's just a case of people getting
worn down by the daily barrage of off topic and impudent requests
streaming into this group. I estimate that about 2% (if that much) of
the posts to this group are really interesting to me nowadays, or to
many other people. About 20% are posts that I wouldn't mind having a
look at. My killfile rules weed out about 40%.

When I start reading the day's posts in the morning, I get a bit ticked
off when after 10 or 20 posts I still haven't seen anything that even
comes close to being interesting. If the 21st post is another one of
those posts that really is on the wrong side of the line, I sometimes
lose patience as well. Everyone does. It wears one down. And, no, not
reading this group is not the answer. The 2% of really interesting posts
make it worthwhile. 

But, you can hardly blame us for making sure that the fraction of 2%
interesting posts doesn't dwindle to less, and that 50 offtopic posts a
day doesn't increase to 500.

Make sure your question is about Perl. Make sure you do your homework.
That way you'll find that this group isn't that hard to deal with.

Martien

[1] Which does not mean that any question becomes on topic as long as
there is Perl code. In this particular case, the format of the email,
and its headers, is still off topic. The discussion about what could be
imrpoved in your code was on topic.

-- 
Martien Verbruggen              | 
Interactive Media Division      | This matter is best disposed of from
Commercial Dynamics Pty. Ltd.   | a great height, over water.
NSW, Australia                  | 


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

Date: 16 Sep 99 21:33:47 GMT (Last modified)
From: Perl-Users-Request@ruby.oce.orst.edu (Perl-Users-Digest Admin) 
Subject: Digest Administrivia (Last modified: 16 Sep 99)
Message-Id: <null>


Administrivia:

The Perl-Users Digest is a retransmission of the USENET newsgroup
comp.lang.perl.misc.  For subscription or unsubscription requests, send
the single line:

	subscribe perl-users
or:
	unsubscribe perl-users

to almanac@ruby.oce.orst.edu.  

| NOTE: The mail to news gateway, and thus the ability to submit articles
| through this service to the newsgroup, has been removed. I do not have
| time to individually vet each article to make sure that someone isn't
| abusing the service, and I no longer have any desire to waste my time
| dealing with the campus admins when some fool complains to them about an
| article that has come through the gateway instead of complaining
| to the source.

To submit articles to comp.lang.perl.announce, send your article to
clpa@perl.com.

To request back copies (available for a week or so), send your request
to almanac@ruby.oce.orst.edu with the command "send perl-users x.y",
where x is the volume number and y is the issue number.

For other requests pertaining to the digest, send mail to
perl-users-request@ruby.oce.orst.edu. Do not waste your time or mine
sending perl questions to the -request address, I don't have time to
answer them even if I did know the answer.


------------------------------
End of Perl-Users Digest V9 Issue 5100
**************************************


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