[9934] in Perl-Users-Digest
Perl-Users Digest, Issue: 3527 Volume: 8
daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Mon Aug 24 17:02:00 1998
Date: Mon, 24 Aug 98 14:00:21 -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 Mon, 24 Aug 1998 Volume: 8 Number: 3527
Today's topics:
"protocol not supported" with socket() <gregor@novoironlight.com>
apache-perl question <anton@ce.usu.edu>
chop bug rockwell@shr.dec.com
Re: chop bug (brian d foy)
Re: chop bug (Mike Stok)
Re: chop bug (Craig Berry)
Re: Counting dots in a string (Patrick Timmins)
Re: directory chmod (David Hawker)
Is there a size limit on $ vars? (YabbaDoo)
Re: logical negation (Mark-Jason Dominus)
Re: logical negation (Abigail)
Re: Looking for Programmer/Job Opp. no.unsoliciteds@dead.end.com
Manipulating JPEG files? bryl@my-dejanews.com
Manipulating JPEG files? bryl@my-dejanews.com
Re: Perl documentation <danboo@negia.net>
Re: Perl FAR version 1.1.1 MAKE SURE YOU READ THIS BEFO (I R A Aggie)
Re: Perl FAR version 1.1.1 MAKE SURE YOU READ THIS BEFO no.unsoliciteds@dead.end.com
Re: Perl FAR version 1.1.1 MAKE SURE YOU READ THIS BEFO no.unsoliciteds@dead.end.com
Re: Perl on linux (I R A Aggie)
Re: Prime numbers [was Re: here's an implementation of (Ilya Zakharevich)
Re: Prime numbers [was Re: here's an implementation of (Abigail)
Re: Problems with chomp <nonspammers.start.after.this.period.hot_redox@hotmail.com>
Re: Q: Sliding Window Sort With Perl? (Mark-Jason Dominus)
Re: regex question: striphtml and misformed tags (Ilya Zakharevich)
Re: Simple question for doing a sort on a text file (Tad McClellan)
Re: Submitting a form from a script (David Hawker)
Re: Submitting a form from a script (brian d foy)
Why $1 not set when using next unless in a if statement (Marty M)
Re: Why $1 not set when using next unless in a if state (monty hindman)
Re: Why $1 not set when using next unless in a if state (brian d foy)
Re: Why dont people read the FAQs lvirden@cas.org
Special: Digest Administrivia (Last modified: 12 Mar 98 (Perl-Users-Digest Admin)
----------------------------------------------------------------------
Date: Mon, 24 Aug 1998 13:02:06 -0700
From: Gregor Mosheh <gregor@novoironlight.com>
Subject: "protocol not supported" with socket()
Message-Id: <35E1C6BE.2F436BCC@novoironlight.com>
I've freshly installed PERL on our new system. When I try to use the
socket() function, I get a "Protocol not supported" error at runtime.
I've tried compiling with loadable modules disabled, specifying that
Socket be statically compiled in - doesn't help. "make test" reports all
tests OK.
Any ideas?
Please post to group and cc to my mailbox: gregor@novoironlight.com
Perl: 5.004_04
Platform: Solaris 2.6 (SunOS 5.6) on SPARC
-- Gregor Mosheh
Novo/Ironlight
------------------------------
Date: Mon, 24 Aug 1998 13:59:02 -0600
From: Anton Maximov <anton@ce.usu.edu>
Subject: apache-perl question
Message-Id: <35E1C606.7B50CA2@ce.usu.edu>
i would like to call a apache's auth routine that pops up the BASIC
AuthType dialog box that prompts for the username and password and then
sends then to the server for authentication with the .htaccess file. so
i guess the question is if there is a module that will let me to pop up
that dialog box and let me use the variables later (run them through
database query or smth like that). seems like this method will be much
secure than html forms.
thank you
---
Anton
------------------------------
Date: Mon, 24 Aug 1998 19:36:06 GMT
From: rockwell@shr.dec.com
Subject: chop bug
Message-Id: <6rsfb6$hml$1@nnrp1.dejanews.com>
$str=".0123";
while ($c=chop $str) {
print "$c\n";
}
print "\n";
the above program dies when it hits the zero character, substitute some other
alphanumeric and it works as expected.
This is perl, version 5.001
Unofficial patchlevel 1m.
Copyright 1987-1994, Larry Wall
Win32 port Copyright (c) 1995 Microsoft Corporation. All rights reserved.
Developed by hip communications inc., http://info.hip.com/info/
Perl for Win32 Build 110
Built Aug 13 1996@08:18:50
-----== Posted via Deja News, The Leader in Internet Discussion ==-----
http://www.dejanews.com/rg_mkgrp.xp Create Your Own Free Member Forum
------------------------------
Date: Mon, 24 Aug 1998 16:13:11 -0400
From: comdog@computerdog.com (brian d foy)
Subject: Re: chop bug
Message-Id: <comdog-ya02408000R2408981613110001@news.panix.com>
Keywords: from just another new york perl hacker
In article <6rsfb6$hml$1@nnrp1.dejanews.com>, rockwell@shr.dec.com posted:
>$str=".0123";
>while ($c=chop $str) {
> print "$c\n";
> }
>print "\n";
>
>the above program dies when it hits the zero character, substitute some other
>alphanumeric and it works as expected.
what is $c when it hits the zero character? what does the
while condition evaluate to for that value of $c?
good luck :)
--
brian d foy <comdog@computerdog.com>
CGI Meta FAQ <URL:http://computerdog.com/CGI_MetaFAQ.html>
Comprehensive Perl Archive Network (CPAN) <URL:http://www.perl.com>
Perl Conference Quiz Show <URL:http://tpj.com/tpj/quiz-show>
------------------------------
Date: 24 Aug 1998 20:24:29 GMT
From: mike@stok.co.uk (Mike Stok)
Subject: Re: chop bug
Message-Id: <6rsi5t$hgb@news-central.tiac.net>
In article <6rsfb6$hml$1@nnrp1.dejanews.com>, <rockwell@shr.dec.com> wrote:
>$str=".0123";
>while ($c=chop $str) {
> print "$c\n";
> }
>print "\n";
>
>the above program dies when it hits the zero character, substitute some other
>alphanumeric and it works as expected.
>
> This is perl, version 5.001
That's expected behaviour as the string containing the one character 0 is
considered false by perl. One way to get the result you want is to check
that $c has a length e.g.
while (length ($c = chop $str)) {
...
}
Note that chopping an empty string gives an empty but defined string.
Hope this helps,
Mike
--
mike@stok.co.uk | The "`Stok' disclaimers" apply.
http://www.stok.co.uk/~mike/ | PGP fingerprint FE 56 4D 7D 42 1A 4A 9C
http://www.tiac.net/users/stok/ | 65 F3 3F 1D 27 22 B7 41
stok@colltech.com | Collective Technologies (work)
------------------------------
Date: 24 Aug 1998 20:11:22 GMT
From: cberry@cinenet.net (Craig Berry)
Subject: Re: chop bug
Message-Id: <6rshda$l3j$3@marina.cinenet.net>
rockwell@shr.dec.com wrote:
: $str=".0123";
: while ($c=chop $str) {
Replace with: while (length($c = chop $str)) {
(When $c was '0', this was interpreted (correctly) as a logical
false, and terminated the loop. My version checks if chop returned
an empty string, as it does on an empty-string argument.)
: print "$c\n";
: }
: print "\n";
:
: the above program dies when it hits the zero character, substitute some other
: alphanumeric and it works as expected.
My way to get the same functionality:
print join("\n", split //, reverse $str), "\n";
That is:
1. Reverse the characters in $str
2. Split the resulting string into its component characters
3. Reassemble them with a \n between each pair
4. Print the result with a trailing newline.
---------------------------------------------------------------------
| Craig Berry - cberry@cinenet.net
--*-- Home Page: http://www.cinenet.net/users/cberry/home.html
| "Ripple in still water, when there is no pebble tossed,
nor wind to blow..."
------------------------------
Date: Mon, 24 Aug 1998 19:27:45 GMT
From: ptimmins@netserv.unmc.edu (Patrick Timmins)
Subject: Re: Counting dots in a string
Message-Id: <6rserh$h9t$1@nnrp1.dejanews.com>
In article <35E18828.A6409E13@icky.pc.my.NOSPAM>,
shahada abubakar <shahada@icky.pc.my.NOSPAM> wrote:
> I'm looking for an efficient way to count the number of ocurrences of a
> particular character in a string. For example:
>
> &countch ('comp.lang.perl.announce', '.') == 3
> &countch ('comp.unix.admin', '.') == 2
> &countch ('alt.romance','.') == 1
>
> Is there a better way to implement this other than a for loop over the
> length of the string, and a substr to test and increment a counter?
>
> Regards,
>
> .sha
>
perlfaq4
How can I count the number of occurrences of a substring within a string?
Patrick Timmins
U. Nebraska Medical Center
-----== Posted via Deja News, The Leader in Internet Discussion ==-----
http://www.dejanews.com/rg_mkgrp.xp Create Your Own Free Member Forum
------------------------------
Date: Mon, 24 Aug 1998 20:11:17 GMT
From: dhawker@bigfoot.com (David Hawker)
Subject: Re: directory chmod
Message-Id: <35f8c898.22683986@news.cableol.net>
If you're running the script over the web, as would seem to be the case if
you're using QUERY_STRING, then is it running as 'nobody' and so doesn't
have permission to chmod the directory? I think the permissions of the
parent directory should be looked at.
Does anyone else get error message from their news server, "more included
text than new text"? I've heard this is in fact produced by the newsreader
not the server??
On Mon, 24 Aug 1998 13:08:42 +0100, "Daniel Adams" <dan@fearsome.net> felt
the need to post:
>Still no luck!
>
>chmod 0777, "/foo/$bar" or die "Can't chmod /foo/$bar: $!";
>doesn't seem to work any better than
>chmod 0777, '/foo/$bar' or die "Can't chmod /foo/$bar: $!";
>
>I'm pretty certain now that the problem is with getting the script to
>interpret the $bar variable, but nothing seems to work. Surely someone in
>this ng has used chmod on a directory path which contains a variable and can
>thus help out??? Please? ;-)
--
dhawker@bigfoot.com | ICQ 7222349
http://dhawker.home.ml.org
------------------------------
Date: 24 Aug 1998 20:45:31 GMT
From: send.spam.only@this.address (YabbaDoo)
Subject: Is there a size limit on $ vars?
Message-Id: <6rsjdb$251$1@ruby.digisys.net>
The line of code in question is;
$ls = `ls $file`;
$file="*.*" and this is a command to list all matching files into the $ls
variable.
It has been working fine until I added some files to be listed into $ls. There
are now approximately 3400 files. Each file name is 13 chrs.
Is there a limit as to the size of the $ls variable?
I have found 2 sets of online doco but no indication of *size limits* on any
vars of any type. If you know of better doco please point me at it.
Be gentile, I am fairly new to perl.
TIA, any help appreciated. Use email below.
DJ
--
yabba
yabbadoo<at>bigfoot<dot>com
------------------------------
Date: 24 Aug 1998 15:42:59 -0400
From: mjd@op.net (Mark-Jason Dominus)
Subject: Re: logical negation
Message-Id: <6rsfo3$rdm$1@monet.op.net>
In article <6rs591$eja@nwd2nws1.analog.com>,
David McLaurin <david.mclaurin@analog.com> wrote:
>When using the ! operator, if the operand evaluates to be non-zero,
>should nothing be returned?
It doesn't return nothing. It returns the empty string, which Perl
also considers false.
> The behavior that I would expect is for a "0" to be returned
Whatever.
>Is there a logical not operator that will return a "1" when the
>operand is "0" and a "0" when the operand is "1"?
0+!x
x?0:1
------------------------------
Date: 24 Aug 1998 20:29:35 GMT
From: abigail@fnx.com (Abigail)
Subject: Re: logical negation
Message-Id: <6rsiff$qj4$1@client3.news.psi.net>
Jonathan Feinberg (jdf@pobox.com) wrote on MDCCCXIX September MCMXCIII in
<URL: news:af4uxmq6.fsf@joshua.panix.com>:
++ david.mclaurin@analog.com (David McLaurin) writes:
++
++ > The behavior that I would expect is for a "0" to be returned. Is
++ > there a logical not operator that will return a "1" when the operand
++ > is "0" and a "0" when the operand is "1"?
++
++ The interesting question, I think, is "why do you need something that
++ behaves that way in particular?". You could always
++
++ $foo = $foo ? 0 : 1;
Or even:
$foo &&= 1; $foo ||= 0;
or
$foo = $foo && 1 || 0;
Abigail
--
perl -MLWP::UserAgent -MHTML::TreeBuilder -MHTML::FormatText -wle'print +(HTML::FormatText -> new -> format (HTML::TreeBuilder -> new -> parse (LWP::UserAgent -> new -> request (HTTP::Request -> new ("GET", "http://work.ucsd.edu:5141/cgi-bin/http_webster?isindex=perl")) -> content)) =~ /(.*\))[-\s]+Addition/s) [0]'
------------------------------
Date: Tue, 25 Aug 1998 06:04:33 +0900
From: no.unsoliciteds@dead.end.com
Subject: Re: Looking for Programmer/Job Opp.
Message-Id: <35E1D562.ECD65498@dead.end.com>
FixingHole wrote:
>
> Need estimate for the following script...
>
> Free subdomain script, in where the users page is loaded in the bottom frame,
> in the top frame, an advertisement is loaded and traked, easy new user sign up,
> and a cheat proof interface so that they cannot bust out of the frame...
>
> For signup record the following info...
> E-mail
> Site Title
> Site URL
> Subdomain (whatever.domain.com)
> and if they agreed to the TOS.
>
> Please send your estimates, by e-mail to FixingHole@aol.com
> Maxium amount I will pay over estimate is $40, so please be accurate
you do know the going rate for custom perl stuff is $50 dollars an hour don't
you ?
maybe you should just buy a good book on HTML and go visit Matts script
archive - that way you'd get stuff for free and know what to do with it, and
not have to worry about getting overcharged by unscrupulous perl scripters.
------------------------------
Date: Mon, 24 Aug 1998 19:56:30 GMT
From: bryl@my-dejanews.com
Subject: Manipulating JPEG files?
Message-Id: <6rsghe$j6n$1@nnrp1.dejanews.com>
Howdy - Is there a module like GD.pm for creating/altering JPEG or
PICT files? I have searched CPAN and found only a sizing function,
and a tk-library. I'd like something that doesn't require tk, and
behaves like GD.
Thanks..
-L. Bry
________________________________
Admin, The MAD Scientist Network
http://www.madsci.org/
-----== Posted via Deja News, The Leader in Internet Discussion ==-----
http://www.dejanews.com/rg_mkgrp.xp Create Your Own Free Member Forum
------------------------------
Date: Mon, 24 Aug 1998 20:00:50 GMT
From: bryl@my-dejanews.com
Subject: Manipulating JPEG files?
Message-Id: <6rsgpk$joq$1@nnrp1.dejanews.com>
Howdy - Is there a module like GD.pm for creating/altering JPEG or
PICT files? I have searched CPAN and found only a sizing function,
and a tk-library. I'd like something that doesn't require tk, and
behaves like GD.
Thanks..
-L. Bry
________________________________
Admin, The MAD Scientist Network
http://www.madsci.org/
-----== Posted via Deja News, The Leader in Internet Discussion ==-----
http://www.dejanews.com/rg_mkgrp.xp Create Your Own Free Member Forum
------------------------------
Date: Mon, 24 Aug 1998 15:18:49 -0400
From: Dan Boorstein <danboo@negia.net>
Subject: Re: Perl documentation
Message-Id: <35E1BC99.DB8A8D43@negia.net>
David Hawker wrote:
>
> On Sun, 23 Aug 1998 17:35:01 -0400, Dan Boorstein <danboo@negia.net> felt
> the need to post:
>
> >David Hawker wrote:
> >>
> >> I'm glad you're using proper sig markers! It's amazing, the majority of
> >> people I email don't have them.
> >>
> >> --
> >> dhawker@bigfoot.com | ICQ 7222349
> >> http://dhawker.home.ml.org
> >
> >i thought the .sig marker was "-- ". note the extra space. yours is
> >only "--".
>
> Does it matter? Don't both do? As long as you got two lines.
well, now that i think of it, i guess i should have expressed the
difference as "\n-- \n" and "\n--\n". otherwise there'd be .sig
markers in the middle of this message.
and yes, i do think it matters. since i would be expecting "\n-- \n",
i might write in a program something to the effect of:
$sig = (split /\n-- \n/, $message)[1];
and yes, i realize it is trivial to modify this to incorporate your
variation, but the point is that it wasn't within my original
expectations. it is these surprises, due to disagreement over
a spec, standard or convention, that i would like to avoid.
cheers,
--
Dan Boorstein home: danboo@negia.net work: danboo@y-dna.com
"THERE IS AS YET INSUFFICIENT DATA FOR A MEANINGFUL ANSWER."
- Cosmic AC
------------------------------
Date: Mon, 24 Aug 1998 15:22:35 -0500
From: fl_aggie@thepentagon.com (I R A Aggie)
Subject: Re: Perl FAR version 1.1.1 MAKE SURE YOU READ THIS BEFORE POSTING
Message-Id: <fl_aggie-2408981522350001@aggie.coaps.fsu.edu>
In article <35f5a953.14677674@news.cableol.net>,
david.hawker@cableol.co.uk wrote:
+ On Mon, 24 Aug 1998 09:45:03 -0500, fl_aggie@thepentagon.com (I R A Aggie)
+ felt the need to post:
+ >Learning Perl, Randal L. Schwartz, ISBN 1-56592-042-2.
+ Books are always gonna be out of date,
Even the first edition Llama book will teach you perl suitable for perl v5.
Does it cover _everything_? no. But then again, in the introductory class,
you don't really need to know about modules and OO programming...
+ they might cost a lot of money,
Considering what you pay for the interpreter, the price of a book is
trivial. If it isn't, well, how can you afford a computer??
+ they may be unavailable in the small library in the quiet country corner one
+ lives in,
print qq(Excuse me, but could you order this book for me? I know the author's
name, the publisher, and the ISBN number. Does that help?\n);
+ there's always the latest perl documentation available on the net...
And the knock on that documentation is that it often times requires a
knowledge of perl.
+ OTOH a book may be the very thing your average newbie can get to grips
+ with. :)
And I do believe that was the gripe..."where is the beginners class"...
James
------------------------------
Date: Tue, 25 Aug 1998 04:51:56 +0900
From: no.unsoliciteds@dead.end.com
Subject: Re: Perl FAR version 1.1.1 MAKE SURE YOU READ THIS BEFORE POSTING
Message-Id: <35E1C45C.F9B5F1A4@dead.end.com>
Alan J. Flavell wrote:
> This suggests that you can't conceive of any other way of learning how
> to program, or the details of a particular programming language, or
> elementary problem-solving techniques, than to locate a usenet group and
> immediately start posting random questions to it, without bothering
> about the FAQ nor even taking a look at what the recent discussions were
> about.
What do _you_ think this news group exists for? So well informed practiced
perl programmers can chat with other well informed practiced perl programmers
about the books they read to become what they are and their accomplishments to
date? Or will you conceed that not every poster will have the same level of
experience. I doubt you will conceed this as you would then have to consider
where to draw the line when you start to talk about levels of experience, I
mean do you stop the lesser practiced perl programmers from getting in because
they didn't read such and such a book ? And why on earth would they be coming
_here_? They won't have accomplished anything of any consequence. Or perhaps
you feel safe enough with what you know to call yourself a well seasoned
practiced perl programmer. But if you can't call yourself a well seasoned
practiced perl programmer, what are you doing in a news group where you don't
do anything but just talk about the books you've already read to become a well
seasoned practiced perl programmer and your accomplishments to date?
If you aren't a well practiced seasoned perl programmer then I would hazard a
guess that you subscribe to this news group to LEARN. But from what source,
what makes the NG any different from the man pages or a good book. At this
point it becomes clear you need to have people for something but what? Certain
people only live to show anyone who'll watch just what and how much they know,
they are the gurus. There's nothing sadder than a guru who doesn't have anyone
to amaze with his/her technical wizardry. For this reason despite the
continued presence of ignorant computer illiterates who ask such boringly
trivial questions, the gurus are still here. It's a symbyosis - the gurus need
an audience they can impress and the audience needs the gurus to better their
own skills. I just don't think they should be allowed to be crass and
arrogant, or rather I don't think a small minority of them should be allowed
to continue to be persistently crass and arrogant.
------------------------------
Date: Tue, 25 Aug 1998 04:43:03 +0900
From: no.unsoliciteds@dead.end.com
Subject: Re: Perl FAR version 1.1.1 MAKE SURE YOU READ THIS BEFORE POSTING
Message-Id: <35E1C247.D34D37A5@dead.end.com>
Alan J. Flavell wrote:
> This suggests that you can't conceive of any other way of learning how
> to program, or the details of a particular programming language, or
> elementary problem-solving techniques, than to locate a usenet group and
> immediately start posting random questions to it, without bothering
> about the FAQ nor even taking a look at what the recent discussions were
> about.
What do _you_ think this news group exists for? So well informed practiced
perl programmers can chat with other well informed practiced perl programmers
about the books they read to become what they are and their accomplishments to
date? Or will you conceed that not every poster will have the same level of
experience. I doubt you will conceed this as you would then have to consider
where to draw the line when you start to talk about levels of experience, I
mean do you stop the lesser practiced perl programmers from getting in because
they didn't read such and such a book ? And why on earth would they be coming
_here_? They won't have accomplished anything of any consequence. Or perhaps
you feel safe enough with what you know to call yourself a well seasoned
practiced perl programmer. But if you can't call yourself a well seasoned
practiced perl programmer, what are you doing in a news group where you don't
do anything but just talk about the books you've already read to become a well
seasoned practiced perl programmer and your accomplishments to date?
If you aren't a well practiced seasoned perl programmer then I would hazard a
guess that you subscribe to this news group to LEARN. But from what source,
what makes the NG any different from the man pages or a good book. At this
point it becomes clear you need to have people for something but what? Certain
people only live to show anyone who'll watch just what and how much they know,
they are the gurus. There's nothing sadder than a guru who doesn't have anyone
to amaze with his/her technical wizardry. For this reason despite the
continued presence of ignorant computer illiterates who ask such boringly
trivial questions, the gurus are still here. It's a symbyosis - the gurus need
an audience they can impress and the audience needs the gurus to better their
own skills. I just don't think they should be allowed to be crass and
arrogant, or rather I don't think a small minority of them should be allowed
to continue to be persistently crass and arrogant.
------------------------------
Date: Mon, 24 Aug 1998 15:31:50 -0500
From: fl_aggie@thepentagon.com (I R A Aggie)
Subject: Re: Perl on linux
Message-Id: <fl_aggie-2408981531500001@aggie.coaps.fsu.edu>
In article <Ey6rD2.59K@csc.liv.ac.uk>, ijg@csc.liv.ac.uk (I.J. Garlick) wrote:
+ Or imagine the destruction you could wreck with an inadvertant
+
+ system (rm -rf *);
+
+ as root. :-(
As long as you're not in /, the damage is managable.
Make that: system (/bin/rm -rf /)
Now you've got a live one...and just think that a certain manufacturer of
a certain httpd-which-shall-remain-nameless suggested putting 'perl.exe'
on Win32 systems in /cgi-bin/...
James
------------------------------
Date: 24 Aug 1998 19:19:00 GMT
From: ilya@math.ohio-state.edu (Ilya Zakharevich)
Subject: Re: Prime numbers [was Re: here's an implementation of diff in perl]
Message-Id: <6rseb4$6nr$1@mathserv.mps.ohio-state.edu>
[A complimentary Cc of this posting was sent to Craig Berry
<cberry@cinenet.net>],
who wrote in article <6rsbgn$egn$2@marina.cinenet.net>:
> : False. All modern (and even some quite ancient) methods use quite
> : different approaches to determine primality or to factorise.
>
> Yes, but don't they all reduce to culling the list of potential factors,
> which I mentioned as the only available optimization? (That's my
> understanding, but I'm not a mathematician; if not, I'll do my Emily
> Latella imitation.)
Witness the following (which is infinitely faster than Abigail's,
though prints only one half of the primes), pipe through
perl -x
#! perl
# Print primes of the form 4n+1
use 5.005;
$\ = "\n";
$_ = 'x';
m{^
(?= # a^2 + b^2, a > b
( # 1: a^2
((?(2)\2..|.))+
)
(?! \1 ) # Ensure a > b
( # 3: b^2
((?(4)\4..|.))+
)
$
)
(?! # not c^2 + d^2, c > d, d != b
( # 5: c^2
((?(6)\6..|.))+
)
(?! \5 ) # Ensure c > d
(?! \3 $ ) # Ensure d != b
((?(7)\7..|.))+
$
)
}sx and print length while $_ .= 'xx';
__END__
Enjoy,
Ilya
------------------------------
Date: 24 Aug 1998 20:37:06 GMT
From: abigail@fnx.com (Abigail)
Subject: Re: Prime numbers [was Re: here's an implementation of diff in perl]
Message-Id: <6rsiti$qj4$2@client3.news.psi.net>
Ilya Zakharevich (ilya@math.ohio-state.edu) wrote on MDCCCXIX September
MCMXCIII in <URL: news:6rseb4$6nr$1@mathserv.mps.ohio-state.edu>:
++
++ Witness the following (which is infinitely faster than Abigail's,
++ though prints only one half of the primes)
Yeah, but mine makes for better .sigs.
Abigail
--
perl -wle 'print "Prime" if (1 x shift) !~ /^1?$|^(11+?)\1+$/'
------------------------------
Date: 24 Aug 1998 19:58:39 GMT
From: "Sabre Taylor" <nonspammers.start.after.this.period.hot_redox@hotmail.com>
Subject: Re: Problems with chomp
Message-Id: <01bdcf99$59f33960$c1620c8a@lnxcompaq.lexis-nexis.com>
Jim Zoetewey <zoetewey@iserv.net> wrote in article
<35E174D6.6904D5D8@iserv.net>...
> #!/usr/bin/perl -w
> print "What is your name?";
> $name = <STDIN>;
> chomp ($name);
> print "Hello, $name!\n";
works fine for me.
> "chomp" may clash with future reserved word at ./your_name line 4 syntax
> error in file ./your_name at line 4, next 2 tokens "chomp ($name)"
do perl -v to make sure that you have the latest version of perl.
most likely you are using perl 4, which doesn't have the chomp
function.
------------------------------
Date: 24 Aug 1998 15:36:07 -0400
From: mjd@op.net (Mark-Jason Dominus)
Subject: Re: Q: Sliding Window Sort With Perl?
Message-Id: <6rsfb7$i7u$1@monet.op.net>
In article <5q1zq6bdp8.fsf@prometheus.frii.com>,
Nathan Torkington <gnat@frii.com> wrote:
>> The built-in sort is usually `qsort',
>
>I believe this is system dependent,
Sorry; I meant to write `quicksort',not `qsort'. And it certainly is
system-dependent (whence `usually'), but it is still usually
quicksort.
> and not the case in 5.005_02.
Still quickort, though.
>If you're running 5.004 or earlier, then you'll be using your system's C
>library qsort().
Also probably quicksort.
> My system (FreeBSD 2.2.6) says that qsort() uses median selection to
> avoid worst-case behaviour.
I don't think this always works, but someone with more expertise
should correct me. I have the Jon, John, and Jarkko book two feet
away, and it explains all about it, but I'm too lazy to bend over.
Whatever it does, a slow sort in C (such as you might get from Perl's
built-in sort) is probably still faster than a fast sort in Perl (such
as you might write yourself), so my advice probably wasn't very good.
In any event, sorting time is probably dominated by the time to parse
the records and figure out the dates.
>The qsort() in 5.005 is well worth reading. It's one of the few parts
>of the Perl source code that is heavily commented, and it's
>enlightening and informative.
Ohboy. I didn't know Tom had made good on his promise. Thanks!
------------------------------
Date: 24 Aug 1998 19:22:16 GMT
From: ilya@math.ohio-state.edu (Ilya Zakharevich)
Subject: Re: regex question: striphtml and misformed tags
Message-Id: <6rseh8$9an$1@mathserv.mps.ohio-state.edu>
[A complimentary Cc of this posting was sent to Abigail
<abigail@fnx.com>],
who wrote in article <6rk7re$d9s$1@client3.news.psi.net>:
> Too bad there isn't an operator that says: be as greedy as you can, and
> *never* give back what you once took.
What made you think so?
Ilya
------------------------------
Date: Mon, 24 Aug 1998 14:28:34 -0500
From: tadmc@metronet.com (Tad McClellan)
Subject: Re: Simple question for doing a sort on a text file
Message-Id: <2tesr6.g7a.ln@metronet.com>
Gavin Cato (gavinc@geko.net.au) wrote:
: I'm having probs trying to do a very simple thing with a text file.
: I have a awk script that generates to STDOUT (or a file) a listing that
: looks like this,
: user1 6555
: user2 545
: user3 10885
: user4 65757
: etc..
: I need to code a perl script that takes all these into a array then only
: print out the ones that exceed the number 10000.
: I'm quite a newbie with perl and just bought my "
: Learning Perl 2nd edition" yesterday but ain't quite there yet :)
: Any ideas? :) I'm sure it's only a 5-10 line piece of code but I can't
: see my way through it (whilst I am reading this book)
while (<>) {
print if (split)[1] > 10000;
}
--
Tad McClellan SGML Consulting
tadmc@metronet.com Perl programming
Fort Worth, Texas
------------------------------
Date: Mon, 24 Aug 1998 20:19:57 GMT
From: dhawker@bigfoot.com (David Hawker)
Subject: Re: Submitting a form from a script
Message-Id: <35f9ca18.23067793@news.cableol.net>
On 24 Aug 1998 14:02:58 GMT, andlin-7@jota.sm.luth.se (Anders Lindgren)
felt the need to post:
>
>I'd like to know if (I'm sure it is, so how?) I can open a URL from a perl
>script... I don't need to take care of the output as I just need to submit
>a form, so I would need to open something like
>http://host.domain/script.cgi?name=value
Sockets. Get a socket module that will open a socket to a remote host on a
given port.
>Also, is it possible to set the env variables before opening the URL so I
>can make the CGI script believe I come from a certain page or so
>(HTTP_REFERRER or something like that...)
Yes, these are passed as HTTP headers, like this:
GET /script.cgi?name=value HTTP/1.0
Referrer: http://wherever.you.came.from
Try a HTTP FAQ or RFC.
--
dhawker@bigfoot.com | ICQ 7222349
http://dhawker.home.ml.org
------------------------------
Date: Mon, 24 Aug 1998 16:44:45 -0400
From: comdog@computerdog.com (brian d foy)
Subject: Re: Submitting a form from a script
Message-Id: <comdog-ya02408000R2408981644450001@news.panix.com>
Keywords: from just another new york perl hacker
In article <35f9ca18.23067793@news.cableol.net>, david.hawker@cableol.co.uk posted:
>On 24 Aug 1998 14:02:58 GMT, andlin-7@jota.sm.luth.se (Anders Lindgren)
>felt the need to post:
>>I'd like to know if (I'm sure it is, so how?) I can open a URL from a perl
>>script... I don't need to take care of the output as I just need to submit
>>a form, so I would need to open something like
>>http://host.domain/script.cgi?name=value
>Try a HTTP FAQ or RFC.
try the LWP module and save yourself the trouble of learning
everything there is to know about HTTP just to do a simple task. :)
--
brian d foy <comdog@computerdog.com>
CGI Meta FAQ <URL:http://computerdog.com/CGI_MetaFAQ.html>
Comprehensive Perl Archive Network (CPAN) <URL:http://www.perl.com>
Perl Mongers needs volunteers! <URL:http://www.pm.org/to-do.html>
------------------------------
Date: Mon, 24 Aug 1998 20:11:50 GMT
From: oshmis1@pacbell.net (Marty M)
Subject: Why $1 not set when using next unless in a if statement?
Message-Id: <35e1c7ec.15673496@news.pacbell.net>
If you call the following program "a" and run it $1 is not set when
the pattern match is wrapped in an "if". Anybody know why?
#!/opt/perl5/bin/perl
open(A,'a') or die;
while ($b = <A>) {
next unless $b =~ /(T...)/;
print "-> $1 <-\n";
}
close A;
$a = 'testTESTtest';
$c = 1;
open(A,'a') or die;
while ($b = <A>) {
if ($c) {
next unless $b =~ /(T...)/;
}
print "-> $1 <-\n";
}
Outputs :
-> T... <-
-> TEST <-
-> T... <-
-> <-
-> <-
-> <-
This is for version 5.001m and 5.004_04. Thanks for any info.
Marty
------------------------------
Date: Mon, 24 Aug 1998 20:30:35 GMT
From: montyh@umich.edu (monty hindman)
Subject: Re: Why $1 not set when using next unless in a if statement?
Message-Id: <L3kE1.1913$QT4.9393459@newbabylon.rs.itd.umich.edu>
Marty M (oshmis1@pacbell.net) wrote:
: If you call the following program "a" and run it $1 is not set when
: the pattern match is wrapped in an "if". Anybody know why?
[snip]
: while ($b = <A>) {
: if ($c) {
: next unless $b =~ /(T...)/;
: }
: print "-> $1 <-\n";
: }
Pattern matching vars like $n and $& are limited in scope to the enclosing
block. $1 will print fine inside the if{} structure, but once you leave
that block, $1 is gone. If you need the pattern matching results to
survive longer than the current block, save them to your own variables.
Monty Hindman
------------------------------
Date: Mon, 24 Aug 1998 16:35:48 -0400
From: comdog@computerdog.com (brian d foy)
Subject: Re: Why $1 not set when using next unless in a if statement?
Message-Id: <comdog-ya02408000R2408981635480001@news.panix.com>
Keywords: from just another new york perl hacker
In article <35e1c7ec.15673496@news.pacbell.net>, oshmis1@pacbell.net (Marty M) posted:
>If you call the following program "a" and run it $1 is not set when
>the pattern match is wrapped in an "if". Anybody know why?
the memory variables $1, $2, and so on are block scoped.
--
brian d foy <comdog@computerdog.com>
CGI Meta FAQ <URL:http://computerdog.com/CGI_MetaFAQ.html>
Comprehensive Perl Archive Network (CPAN) <URL:http://www.perl.com>
Perl Mongers needs volunteers! <URL:http://www.pm.org/to-do.html>
------------------------------
Date: 24 Aug 1998 18:13:06 GMT
From: lvirden@cas.org
Subject: Re: Why dont people read the FAQs
Message-Id: <6rsafi$t2v$1@srv38s4u.cas.org>
According to Jeffrey Drumm <drummj@mail.mmc.org>:
:lvirden's post, as quoted in your reply:
:>>I sure wish folk WOULD wait a few weeks instead of sending 7, 8 or more
:>>copies of the same posting to this newsgroup.
:
:Now, *I* read this, and saw lvirden making a general comment about posting
:multiple copies of articles, and *I* chose to believe he either didn't
:check the headers or was uneducated as to the workings of Usenet. Not a
:crime in my book, and certainly nothing to warrant something like "stfu."
and from lvirden's point of view...
I was reading thru comp.lang.perl.misc. I see lots of copies of the
same msg by the same person.
I look at headers. They all look like they are coming from the same
place. I am unaware of any way to determine whether this location has
anything to do with the original poster or not - lots of folk have
a posting address of one thing and a nntp host site somewhere else.
So, after seeing more and more of this type of thing from the same user,
I check around, find out that the poster's site doesn't know what's
causing the problem. Then, later, I finally see the same phenom relating
to a poster whom I a) know is experienced with usenet and b) know would
appreciate knowing what is going on. I contact the poster directly along
with the postmaster of the site thru which the duplicates are coming,
asking if anyone knows what is going on.
I get a nice thank you note back from the clpm poster, letting me know
how much he appreciates finding this out.
I certainly would not have expected any such reply from a number of
others on this newsgroup.
And I _still_ would prefer to see folk read a thread for a few
weeks instead of sending multiple copies of the same posting. Has
nothing to do with the thread in question - I see the phenom around
usenet on many groups. They get errors back from their poster, start
hitting send several more times, then realize a few days later what
they have done - and then post nasty msgs or apologies...
--
<URL:mailto:lvirden@cas.org> Quote: In heaven, there is no panic,
<*> O- <URL:http://www.teraform.com/%7Elvirden/> only planning.
Unless explicitly stated to the contrary, nothing in this posting
should be construed as representing my employer's opinions.
------------------------------
Date: 12 Jul 98 21:33:47 GMT (Last modified)
From: Perl-Request@ruby.oce.orst.edu (Perl-Users-Digest Admin)
Subject: Special: Digest Administrivia (Last modified: 12 Mar 98)
Message-Id: <null>
Administrivia:
Special notice: in a few days, the new group comp.lang.perl.moderated
should be formed. I would rather not support two different groups, and I
know of no other plans to create a digested moderated group. This leaves
me with two options: 1) keep on with this group 2) change to the
moderated one.
If you have opinions on this, send them to
perl-users-request@ruby.oce.orst.edu.
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 3527
**************************************