[24289] in Perl-Users-Digest
Perl-Users Digest, Issue: 6480 Volume: 10
daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Tue Apr 27 21:05:38 2004
Date: Tue, 27 Apr 2004 18:05:06 -0700 (PDT)
From: Perl-Users Digest <Perl-Users-Request@ruby.OCE.ORST.EDU>
To: Perl-Users@ruby.OCE.ORST.EDU (Perl-Users Digest)
Perl-Users Digest Tue, 27 Apr 2004 Volume: 10 Number: 6480
Today's topics:
Re: a warning <robin @ infusedlight.net>
Re: Is Perl *that* good? (was: How's ruby compare to it <tadmc@augustmail.com>
Re: Newbie: Looking for comments on this (working) scri <robin @ infusedlight.net>
Re: other perl groups <matthew.garrish@sympatico.ca>
Re: Perl newbie q: trying to access array using variabl <tadmc@augustmail.com>
Regex Matching Strings WITHOUT Chars <hal@thresholddigital.com>
Re: Regex Matching Strings WITHOUT Chars <noreply@gunnar.cc>
Re: Regex Matching Strings WITHOUT Chars <ittyspam@yahoo.com>
Re: Regex Matching Strings WITHOUT Chars (Sam Holden)
Re: Regex Matching Strings WITHOUT Chars <invalid-email@rochester.rr.com>
Regex to format 1234 to 1,234 (pembed2003)
Re: Regex to format 1234 to 1,234 <tadmc@augustmail.com>
Re: RFC: Text similarity <tore@aursand.no>
Re: sending data from one program to a perl prog <noreply@gunnar.cc>
Re: sending data from one program to a perl prog <noreply@gunnar.cc>
Re: sending data from one program to a perl prog (Walter Roberson)
Re: what I was doing (originally textarea problem) <matthew.garrish@sympatico.ca>
Re: what I was doing (originally textarea problem) <spamtrap@dot-app.org>
Digest Administrivia (Last modified: 6 Apr 01) (Perl-Users-Digest Admin)
----------------------------------------------------------------------
Date: Tue, 27 Apr 2004 18:40:07 -0800
From: "Robin" <robin @ infusedlight.net>
Subject: Re: a warning
Message-Id: <c6mv6g$2esa$1@news.f.de.plusline.net>
> Well, I don't know this product you're talking about, so I cannot
> exclude a priori and with absolute certainty that what you're saying
> is true, but taking into account your recent posts... I'd say that
> you'd better ask first if by any means you did something wrong and be
> sure that you didn't and *then* possibly, advise people not to install
> "that software"...
actually I tried the default install for both activeperl and perl builder so
I don't think I was doing something wrong, that's why I posted it. I know
about win32 systems pretty well, so I know I didn't do something wrong,
sorry to appear irate, but it's true, this product needs work before it
stops screwing people's systems. Some people here tell me that I don't know
much about perl, this may be true, but I do know win32.
Has anyone else experienced this problem with perl builder?
One last thing, all that needs to be done to correct the problem is a
lengthy re-install of activeperl.
--
Regards,
-Robin
--
[ webmaster @ infusedlight.net ]
www.infusedlight.net
------------------------------
Date: Tue, 27 Apr 2004 16:52:07 -0500
From: Tad McClellan <tadmc@augustmail.com>
Subject: Re: Is Perl *that* good? (was: How's ruby compare to it older brother python)
Message-Id: <slrnc8tlg7.v22.tadmc@magna.augustmail.com>
Michele Dondi <bik.mido@tiscalinet.it> wrote:
> łOn Mon, 26 Apr 2004 16:55:02 -0400, "Ruby Tuesdays"
><NoSpamPlease_rubytuzdaiz@yahoo.com> wrote:
>
>>Would this super perl program of yours can convert the massive amount of
>>perl script to ruby or python?
>>
>>If it could, it would be great so ruby/python programmers does not have to
>>learn those cryptic perl-ish syntax and the non-OOish scripting language.
>
> Huh?!?
Simply make a killfile entry and move on.
--
Tad McClellan SGML consulting
tadmc@augustmail.com Perl programming
Fort Worth, Texas
------------------------------
Date: Tue, 27 Apr 2004 18:51:02 -0800
From: "Robin" <robin @ infusedlight.net>
Subject: Re: Newbie: Looking for comments on this (working) script
Message-Id: <c6mv6j$2esa$3@news.f.de.plusline.net>
"Paul Lalli" <ittyspam@yahoo.com> wrote in message
news:20040427154701.S1107@dishwasher.cs.rpi.edu...
> On Tue, 27 Apr 2004, Robin wrote:
>
> > > > > sub run_id3v2 (@)
> > > >
> > > > what's this supposed to do? Which perldoc can I find out in?
> > > >
> > >
> > > Do you even *try* before posting here? Gee, it's having to do with a
> > > subroutine, you think *maybe* it might be in the documentation for
> > > subroutines?
> > >
> > > perldoc perlsub
> > > it's called a prototype, although this particular one is rather
useless.
> > > Can you read the documentation and tell us why, Robin?
> >
> > because he really isn't using any references? I scanned the perlsub
docs,
> > and this is probably wrong, but I have to write a paper.
> > -Robin
>
> Almost correct, actually. A prototype of (@) tells perl "Only accept a
> list of arguments" (as opposed to something like ($\@), which says "accept
> a scalar value followed by an actual named array". But accepting a list
> of arguments is the default behavior for Perl subroutines. Therefore,
> using a prototype of (@) is no different than not using a prototype at
> all. (it is very different, however, from using an empty prototype, like
> sub myfunc() )
>
> To clarify, prototypes do not have to have anything to do with references.
> They can be used to restrict the number and type of arguments passed to
> subroutines. For example:
>
> sub myfunc($$) {
>
> This function will only accept two scalar values. They can be any scalar
> values you want, be them strings literals, numeric literals, named scalar
> variables, or yes, references. But the following function calls are all
> permitted:
>
> myfunc("foo", 'bar');
> myfunc(1, $string);
> myfunc('', 0);
>
> none of which do any conversions to references. In this case, the
> prototype could be in place to cause fatal errors for any of these
> function calls:
>
> myfunc ("foo", "bar", "baz");
> myfunc (42);
> myfunc ();
> @ten = (1..10);
> myfunc (@ten);
>
>
> Paul Lalli
Thanks, that's way more clear than the perldoc, in my humble opinion.
Basically to clarify your intitial question, this prototype doesn't do
anything because the arguments for a subroutine are already an array, @_,
correct?
One question, and I don't think this is in the perldoc perlsub, although I
still haven't fully covered it, but can a subroutine, with strict in use, be
called without parantheses in a script that's not a module after it has it's
prototype? Or that's not a subroutine imported from a module?
Thanks,
--
Regards,
-Robin
--
[ webmaster @ infusedlight.net ]
www.infusedlight.net
------------------------------
Date: Tue, 27 Apr 2004 19:04:42 -0400
From: "Matt Garrish" <matthew.garrish@sympatico.ca>
Subject: Re: other perl groups
Message-Id: <dGBjc.25013$OU.555724@news20.bellglobal.com>
"Paul Lalli" <ittyspam@yahoo.com> wrote in message
news:20040426155233.K1107@dishwasher.cs.rpi.edu...
> On Mon, 26 Apr 2004, pfancy wrote:
>
> P.S. I did a groups.google search to find what thread you were referring
> to - your email exists only in this thread. Did you use a different
> address when you claim to have been 'insulted'? Can you point us to the
> insulting message(s)?
>
I remember he got a little flame in alt.perl a while back. Made some
misguided claims about Linux being a bigger resource hog than XP. He needs a
much thicker skin if that's what's eating at him:
http://tinyurl.com/2gc7w
Matt
------------------------------
Date: Tue, 27 Apr 2004 17:34:13 -0500
From: Tad McClellan <tadmc@augustmail.com>
Subject: Re: Perl newbie q: trying to access array using variable name
Message-Id: <slrnc8tnv5.v22.tadmc@magna.augustmail.com>
m <mpepple@hotmail.com> wrote:
> i have a set of 100 lists:
>
> @list1 = ...
> @list2 = ...
> @list3 = ...
> @list4 = ...
> @list5 = ...
> ...
> @list 99 = ...
> @list100 = ...
Then you have made a poor choice of data structure.
A 2-D array would have made it easy to solve your problem.
I'd redesign it to use a LoL if I were you.
$list[0] = [ stuff that used to be in @list1 ];
$list[1] = [ stuff that used to be in @list2 ];
...
$list[99] = [ stuff that used to be in @list100 ];
> i want to then check a value to see what list it's in. instead of
> writing 100 of these:
>
> foreach $list1 (@list1) {
> if $value =~ /$list1/ {
Errr, when did you put something into $value?
I think you have that backwards.
Don't you want $value in the pattern instead of being the string
that is searched?
> print "found the value in list1\n";
> }
> }
>
> i want to put that in a loop that runs 100 times.
# untested
foreach my $i ( 0 .. 99 ) {
foreach my $elem ( @{ $list[$i] } ) {
if ( $elem =~ /$value/ ) {
print "found the value in list[$i]\n";
}
}
}
--
Tad McClellan SGML consulting
tadmc@augustmail.com Perl programming
Fort Worth, Texas
------------------------------
Date: Wed, 28 Apr 2004 00:40:21 GMT
From: Hal Vaughan <hal@thresholddigital.com>
Subject: Regex Matching Strings WITHOUT Chars
Message-Id: <V3Djc.32459$cF6.1484961@attbi_s04>
I'm using Archive::Zip and I can specify, with a regex, the filenames that
are added to an archive. I have two types of log files, distinguishable by
name types. One ends with "-web-SL0" and the other ends with
"-server-SL0". How can I specify, in a regex, to NOT match "web-SL0", but
to match all else?
I tried a few ideas, like specifying to match it 0 times:
/(web-SL0){0}/
but it didn't work. I also tried various combinations, like match all chars
OR zero occurances of web-SL0, but nothing worked. I've looked through all
my references, but I can't find a way to specify to NOT match a pattern in
a regex. Is it possible?
Thanks!
Hal
------------------------------
Date: Wed, 28 Apr 2004 02:52:29 +0200
From: Gunnar Hjalmarsson <noreply@gunnar.cc>
Subject: Re: Regex Matching Strings WITHOUT Chars
Message-Id: <c6mvf3$damc8$1@ID-184292.news.uni-berlin.de>
Hal Vaughan wrote:
> How can I specify, in a regex, to NOT match "web-SL0", but to match
> all else?
!/web-SL0$/
--
Gunnar Hjalmarsson
Email: http://www.gunnar.cc/cgi-bin/contact.pl
------------------------------
Date: Tue, 27 Apr 2004 20:56:10 -0400
From: Paul Lalli <ittyspam@yahoo.com>
Subject: Re: Regex Matching Strings WITHOUT Chars
Message-Id: <20040427204942.G25280@dishwasher.cs.rpi.edu>
On Wed, 28 Apr 2004, Hal Vaughan wrote:
> I'm using Archive::Zip and I can specify, with a regex, the filenames that
> are added to an archive. I have two types of log files, distinguishable by
> name types. One ends with "-web-SL0" and the other ends with
> "-server-SL0". How can I specify, in a regex, to NOT match "web-SL0", but
> to match all else?
>
> I tried a few ideas, like specifying to match it 0 times:
>
> /(web-SL0){0}/
>
> but it didn't work. I also tried various combinations, like match all chars
> OR zero occurances of web-SL0, but nothing worked. I've looked through all
> my references, but I can't find a way to specify to NOT match a pattern in
> a regex. Is it possible?
>
There's a few ways. In this case, I'd say a negative lookbehind assertion
is your best bet:
/(?<!web-SL0)$/
This says "Match the end of the string so long as it is NOT preceeded by
"web-SL0".
You can read up on this feature by searching for 'look-behind' in
perldoc perlre
Hope this helps,
Paul Lalli
------------------------------
Date: 28 Apr 2004 00:58:29 GMT
From: sholden@flexal.cs.usyd.edu.au (Sam Holden)
Subject: Re: Regex Matching Strings WITHOUT Chars
Message-Id: <slrnc8u0dl.fgu.sholden@flexal.cs.usyd.edu.au>
On Wed, 28 Apr 2004 00:40:21 GMT, Hal Vaughan <hal@thresholddigital.com> wrote:
> I'm using Archive::Zip and I can specify, with a regex, the filenames that
> are added to an archive. I have two types of log files, distinguishable by
> name types. One ends with "-web-SL0" and the other ends with
> "-server-SL0". How can I specify, in a regex, to NOT match "web-SL0", but
> to match all else?
>
> I tried a few ideas, like specifying to match it 0 times:
>
> /(web-SL0){0}/
That will just match everything, after all all strings contain a substring
(of zero length) containing no copies of 'web-SL0'.
>
> but it didn't work. I also tried various combinations, like match all chars
> OR zero occurances of web-SL0, but nothing worked. I've looked through all
> my references, but I can't find a way to specify to NOT match a pattern in
> a regex. Is it possible?
If the "end with" statement in the description is correct then:
/(?<!-web-SL0)$/
See the
perldoc perlre
documentation - search for "look-behind" for the description of the syntax.
--
Sam Holden
------------------------------
Date: Wed, 28 Apr 2004 01:03:38 GMT
From: Bob Walton <invalid-email@rochester.rr.com>
Subject: Re: Regex Matching Strings WITHOUT Chars
Message-Id: <408F0292.3070602@rochester.rr.com>
Hal Vaughan wrote:
...
> "-server-SL0". How can I specify, in a regex, to NOT match "web-SL0", but
> to match all else?
...
> my references, but I can't find a way to specify to NOT match a pattern in
> a regex. Is it possible?
...
> Hal
Check out:
perldoc perlre
in particular looking for text that says "zero-width negative look-ahead
assertion" and "zero-width negative look-behind assertion". By properly
applying one of those, you should be able to accomplish your task.
--
Bob Walton
Email: http://bwalton.com/cgi-bin/emailbob.pl
------------------------------
Date: 27 Apr 2004 15:35:15 -0700
From: pembed2003@yahoo.com (pembed2003)
Subject: Regex to format 1234 to 1,234
Message-Id: <db593abd.0404271435.50c2d173@posting.google.com>
Hi all,
I am trying to come up with a regex to format number like:
1234
-1234
1234567
to:
1,234
-1,234
1,234,567
The numbers will always be interger. So far, I have the following:
#1:
while(<>){
chomp;
$_ = reverse split //;
s/(\d{3})\B/$1,/g;
$_ = reverse split //;
print "$_\n";
}
#2:
while(<>){
chomp;
my $n = $_ =~ s/^-// ? '-' : '';
$_ = 'x' . $_ while(length($_) % 3);
s/(.{3})\B/$1,/g;
s/^[x,]+//;
print "$n$_\n";
}
#3:
while(<>){
chomp;
my $n = '';
while(s/\B(\d{3})$//g){
$n = ",$1" . $n;
}
$n = $_ . $n if length;
print "$n\n";
}
All three methods seems to be a bit too "long", is there a better way?
I am trying to do this as a way for me to learn regex so I would like
not to use a module if possible. Thanks!
------------------------------
Date: Tue, 27 Apr 2004 17:41:59 -0500
From: Tad McClellan <tadmc@augustmail.com>
Subject: Re: Regex to format 1234 to 1,234
Message-Id: <slrnc8todn.v6e.tadmc@magna.augustmail.com>
pembed2003 <pembed2003@yahoo.com> wrote:
> I am trying to come up with a regex to format number like:
> 1,234
> -1,234
> 1,234,567
You are expected to check the Perl FAQ *before* posting to
the Perl newsgroup you know...
perldoc -q commas
How can I output my numbers with commas added?
--
Tad McClellan SGML consulting
tadmc@augustmail.com Perl programming
Fort Worth, Texas
------------------------------
Date: Wed, 28 Apr 2004 01:35:11 +0200
From: Tore Aursand <tore@aursand.no>
Subject: Re: RFC: Text similarity
Message-Id: <pan.2004.04.27.22.53.20.750391@aursand.no>
On Tue, 27 Apr 2004 23:12:40 +0200, Michele Dondi wrote:
>>> I know that this may seem naive, but in a popular science magazine I
>>> read that a paper has been published about a technique that indeed
>>> identifies the (natural) language some documents are written in by
>>> compressing (e.g. LZW) them along with some more text from samples
>>> taken from a bunch of different languages and comparing the different
>>> compressed sizes. You may try some variation on this scheme...
>> I really don't have the opportunity to categorize any of the documents;
>> Everything must be 100% automatic without human interference.
> Well, you may try matching limited-sized portions of the documents
> (after having converted them to pure text) against each other (I mean
> across documents, not within the *same* document) and average the result
> over a document.
Because there will be _a lot_ of documents - where each document can be
quite big - I have to have in mind:
* Processing power is limited, so the matching must be as light-
weight as possible, but at the same time as good as possible. Yeah, I
know how that sentence sounds. :)
* Data storage is also limited; I can't store each document (and
all its contents) in the database. I can only store meta data and
data related to the task of finding related documents.
The latter brings me to the point of extracting all the words from each
document, removing single characters, stopwords and numbers, and then
store these words (and their frequency) in a document/word-mapped data
table. Quite simple, really.
--
Tore Aursand <tore@aursand.no>
"To cease smoking is the easiset thing I ever did. I ought to know,
I've done it a thousand times." (Mark Twain)
------------------------------
Date: Wed, 28 Apr 2004 00:51:28 +0200
From: Gunnar Hjalmarsson <noreply@gunnar.cc>
Subject: Re: sending data from one program to a perl prog
Message-Id: <c6moc1$dqm1n$1@ID-184292.news.uni-berlin.de>
Andrew Wheeler wrote:
> Gunnar Hjalmarsson wrote:
>>
>>my $maxsize = 131072;
>
> what is the significance of 131072 as a max size ?
None, AFAIK. It's up to you to decide what's a reasonable value (if
you want to include such a check).
--
Gunnar Hjalmarsson
Email: http://www.gunnar.cc/cgi-bin/contact.pl
------------------------------
Date: Wed, 28 Apr 2004 00:56:01 +0200
From: Gunnar Hjalmarsson <noreply@gunnar.cc>
Subject: Re: sending data from one program to a perl prog
Message-Id: <c6mokj$dj12l$1@ID-184292.news.uni-berlin.de>
Gunnar Hjalmarsson wrote:
> Andrew Wheeler wrote:
>> Gunnar Hjalmarsson wrote:
>>>
>>> my $maxsize = 131072;
>>
>> what is the significance of 131072 as a max size ?
>
> None, AFAIK. It's up to you to decide what's a reasonable value (if
> you want to include such a check).
Besides the obvious, of course, i.e. prevent that your program
processes and forwards an unreasonably large message.
--
Gunnar Hjalmarsson
Email: http://www.gunnar.cc/cgi-bin/contact.pl
------------------------------
Date: 27 Apr 2004 23:21:08 GMT
From: roberson@ibd.nrc-cnrc.gc.ca (Walter Roberson)
Subject: Re: sending data from one program to a perl prog
Message-Id: <c6mpt4$j2l$1@canopus.cc.umanitoba.ca>
In article <pan.2004.04.27.21.52.48.848028@localhost.localdomain>,
Andrew Wheeler <andrew@localhost.localdomain> wrote:
:On Mon, 26 Apr 2004 23:42:43 +0200, Gunnar Hjalmarsson wrote:
:> my $maxsize = 131072;
:what is the significance of 131072 as a max size ?
128 kilobytes = 131072 bytes.
64 Kb is one of the magic numbers in TCP, I seem to recall;
128 Kb allows for two buffer's worth of the maximum size.
--
"Meme" is self-referential; memes exist if and only if the "meme" meme
exists. "Meme" is thus logically a meta-meme; but until the existance
of meta-memes is more widely recognized, "meta-meme" is not a meme.
-- A Child's Garden Of Memes
------------------------------
Date: Tue, 27 Apr 2004 19:09:54 -0400
From: "Matt Garrish" <matthew.garrish@sympatico.ca>
Subject: Re: what I was doing (originally textarea problem)
Message-Id: <4LBjc.25019$OU.557007@news20.bellglobal.com>
"Robin" <robin @ infusedlight.net> wrote in message
news:c6kmrv$16n9$1@news.f.de.plusline.net...
>
> "Matt Garrish" <matthew.garrish@sympatico.ca> wrote in message
> news:bvhjc.18190$OU.359798@news20.bellglobal.com...
> >
> > "Robin" <robin @ infusedlight.net> wrote in message
> > news:c6k5ii$uhj$2@news.f.de.plusline.net...
> > >
> > > I'm stupid.
> > >
> >
> > No need to state the obvious when posting here...
> >
> > Matt
>
> thanks a lot....
> jesus.
>
I'm no Jesus, but I can turn water into brine...
Matt
------------------------------
Date: Tue, 27 Apr 2004 19:41:27 -0400
From: Sherm Pendley <spamtrap@dot-app.org>
Subject: Re: what I was doing (originally textarea problem)
Message-Id: <c4OdnbHdUvc6chPdRVn-vA@adelphia.com>
Matt Garrish wrote:
> I can turn water into brine...
I'm skeptical - I'll take that claim with a grain of salt. ;-)
*duck*
sherm--
--
Cocoa programming in Perl: http://camelbones.sourceforge.net
Hire me! My resume: http://www.dot-app.org
------------------------------
Date: 6 Apr 2001 21:33:47 GMT (Last modified)
From: Perl-Users-Request@ruby.oce.orst.edu (Perl-Users-Digest Admin)
Subject: Digest Administrivia (Last modified: 6 Apr 01)
Message-Id: <null>
Administrivia:
#The Perl-Users Digest is a retransmission of the USENET newsgroup
#comp.lang.perl.misc. For subscription or unsubscription requests, send
#the single line:
#
# subscribe perl-users
#or:
# unsubscribe perl-users
#
#to almanac@ruby.oce.orst.edu.
NOTE: due to the current flood of worm email banging on ruby, the smtp
server on ruby has been shut off until further notice.
To submit articles to comp.lang.perl.announce, send your article to
clpa@perl.com.
#To request back copies (available for a week or so), send your request
#to almanac@ruby.oce.orst.edu with the command "send perl-users x.y",
#where x is the volume number and y is the issue number.
#For other requests pertaining to the digest, send mail to
#perl-users-request@ruby.oce.orst.edu. Do not waste your time or mine
#sending perl questions to the -request address, I don't have time to
#answer them even if I did know the answer.
------------------------------
End of Perl-Users Digest V10 Issue 6480
***************************************