[24277] in Perl-Users-Digest
Perl-Users Digest, Issue: 6468 Volume: 10
daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Mon Apr 26 14:06:02 2004
Date: Mon, 26 Apr 2004 11:05:08 -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 Mon, 26 Apr 2004 Volume: 10 Number: 6468
Today's topics:
Re: backslash in hash keys (Marko Riedel)
Re: backslash in hash keys <tadmc@augustmail.com>
Re: backslash in hash keys (Anno Siegel)
Re: backslash in hash keys <thepoet_nospam@arcor.de>
Re: backslash in hash keys <mr@sandman.net>
Re: backslash in hash keys <mr@sandman.net>
Re: backslash in hash keys <jtc@shell.dimensional.com>
Re: Difficult regular expression problem! (Fritz Bayer)
Re: Difficult regular expression problem! (Fritz Bayer)
Re: Difficult regular expression problem! <xx087@freenet.carleton.ca>
Re: Difficult regular expression problem! <noreply@gunnar.cc>
Re: free source blogger (works) <uri@stemsystems.com>
Re: free source blogger (works) <dwall@fastmail.fm>
Re: Help! How to find memory leak? ctcgag@hotmail.com
Re: How can I create a PDF page with only Images (EPS & <Kyler@news.Lairds.org>
Re: How can I create a PDF page with only Images (EPS & <remorse@partners.org>
Re: is there a way ..... any way <andries@zilz.nl>
Re: is there a way ..... any way (Walter Roberson)
Re: is there a way ..... any way (Randal L. Schwartz)
Re: is there a way ..... any way <dwall@fastmail.fm>
NEed your help with yahoo and dynamic URL <dannywork5@hotmail.com>
Re: noob question: Trying to extract part of a string i <remorse@partners.org>
Re: noob question: Trying to extract part of a string i <xx087@freenet.carleton.ca>
Re: other perl groups ctcgag@hotmail.com
regular expression error <nospam@nospam.com>
Re: regular expression error <remorse@partners.org>
Re: regular expression error <ittyspam@yahoo.com>
special regular expression problem (Christian Meilke)
Re: special regular expression problem <jurgenex@hotmail.com>
Re: special regular expression problem <xx087@freenet.carleton.ca>
Re: special regular expression problem <tore@aursand.no>
Re: Tripod wont find my lib files <jwkenne@attglobal.net>
Re: Where is PL_stack_base defined??? (Anno Siegel)
Re: Where is PL_stack_base defined??? <tassilo.parseval@rwth-aachen.de>
Digest Administrivia (Last modified: 6 Apr 01) (Perl-Users-Digest Admin)
----------------------------------------------------------------------
Date: 26 Apr 2004 15:23:00 +0200
From: mriedel@neuearbeit.de (Marko Riedel)
Subject: Re: backslash in hash keys
Message-Id: <m2ekqavpor.fsf@linuxsexi.nasttg>
Hello again,
my apologies: I didn't use grep properly. That said, the problem persists.
[PROMPT]> perl -e '%h=qw/\A 1 \B 2/; print "yes\n" if grep(/\\B/, keys %h);'
yes
[PROMPT]> perl -e '%h=qw/\A 1 \B 2/; print "yes\n" if grep(/\\C/, keys %h);'
[PROMPT]> perl -e '%h=qw/\A 1 \B 2/; print "yes\n" if exists($h{\B});'
[PROMPT]>
Best regards,
--
+------------------------------------------------------------+
| Marko Riedel, EDV Neue Arbeit gGmbH, mriedel@neuearbeit.de |
| http://www.geocities.com/markoriedelde/index.html |
+------------------------------------------------------------+
------------------------------
Date: Mon, 26 Apr 2004 08:31:19 -0500
From: Tad McClellan <tadmc@augustmail.com>
Subject: Re: backslash in hash keys
Message-Id: <slrnc8q3p7.p54.tadmc@magna.augustmail.com>
Marko Riedel <mriedel@neuearbeit.de> wrote:
> it seems that "exists" does not work on hash keys that begin with a
> backslash,
> Would someone explain, please?
Sure.
> [PROMPT]> perl -e '%h=qw/\A 1 \B 2/; print "yes\n" if exists($h{\B});'
^^
^^
Where are the quotes for your hash key?
You don't get auto-quoting for keys that don't look like identifiers.
perl -e '%h=qw/\A 1 \B 2/; print "yes\n" if exists($h{ q/\B/ });'
--
Tad McClellan SGML consulting
tadmc@augustmail.com Perl programming
Fort Worth, Texas
------------------------------
Date: 26 Apr 2004 13:36:39 GMT
From: anno4000@lublin.zrz.tu-berlin.de (Anno Siegel)
Subject: Re: backslash in hash keys
Message-Id: <c6j397$nbi$1@mamenchi.zrz.TU-Berlin.DE>
Marko Riedel <mriedel@neuearbeit.de> wrote in comp.lang.perl.misc:
>
> Hi folks,
>
> it seems that "exists" does not work on hash keys that begin with a
> backslash, but grep on the keys finds the key. (These keys occur
> e.g. when working with IMAP message flags.)
Autoquoting doesn't work with backslashes (as documented), exists()
works fine.
>
> Would someone explain, please?
>
> [PROMPT]> perl -e '%h=qw/A 1 B 2/; print "yes\n" if exists($h{B});'
> yes
> [PROMPT]> perl -e '%h=qw/\A 1 \B 2/; print "yes\n" if exists($h{\B});'
Apparently you're not running under warnings, or Perl would have
complained. Write that "exists{ '\B'}".
Anno
------------------------------
Date: Mon, 26 Apr 2004 15:37:20 +0200
From: Christian Winter <thepoet_nospam@arcor.de>
Subject: Re: backslash in hash keys
Message-Id: <408d1090$0$10908$9b4e6d93@newsread2.arcor-online.net>
Marko Riedel schrieb:
> Hi folks,
>
> it seems that "exists" does not work on hash keys that begin with a
> backslash, but grep on the keys finds the key. (These keys occur
> e.g. when working with IMAP message flags.)
>
> Would someone explain, please?
>
> [PROMPT]> perl -e '%h=qw/A 1 B 2/; print "yes\n" if exists($h{B});'
> yes
> [PROMPT]> perl -e '%h=qw/\A 1 \B 2/; print "yes\n" if exists($h{\B});'
> [PROMPT]> perl -e '%h=qw/\A 1 \B 2/; print "yes\n" if grep('\B', keys %h);'
> yes
Using the "\" outside of quotes lets perl interprete it
as reference operator. "use strict;" would have made that
obvious. Try
perl -e '%h=qw/\A 1 \B 2/; print "yes\n" if exists($h{q/\B/});'
perl -e '%h=qw/\A 1 \B 2/; print "yes\n" if exists($h{"\\B"});'
which both work, as does your grep-example that also uses
quotes.
HTH
-Christian
------------------------------
Date: Mon, 26 Apr 2004 15:44:34 +0200
From: Sandman <mr@sandman.net>
Subject: Re: backslash in hash keys
Message-Id: <mr-48A02E.15443426042004@news.fu-berlin.de>
In article <m2llkivr3e.fsf@linuxsexi.nasttg>,
mriedel@neuearbeit.de (Marko Riedel) wrote:
> Hi folks,
>
> it seems that "exists" does not work on hash keys that begin with a
> backslash, but grep on the keys finds the key. (These keys occur
> e.g. when working with IMAP message flags.)
>
> Would someone explain, please?
>
> [PROMPT]> perl -e '%h=qw/A 1 B 2/; print "yes\n" if exists($h{B});'
> yes
> [PROMPT]> perl -e '%h=qw/\A 1 \B 2/; print "yes\n" if exists($h{\B});'
> [PROMPT]> perl -e '%h=qw/\A 1 \B 2/; print "yes\n" if grep('\B', keys %h);'
> yes
The \B need to be treated literally, not interpolated. This works:
#!/usr/bin/perl
use strict;
use warnings;
my %foo = qw/\A 1 \B 2/;
print exists($foo{'\B'}) ? "Yes" : "No";
__END__
Output: Yes
But this doesn't work:
print exists($foo{"\B"}) ? "Yes" : "No";
perl is trying to treat \B as an escaped character in interpolated context, and
you get this warning:
Unrecognized escape \B passed through
--
Sandman[.net]
------------------------------
Date: Mon, 26 Apr 2004 15:48:02 +0200
From: Sandman <mr@sandman.net>
Subject: Re: backslash in hash keys
Message-Id: <mr-B6A250.15480226042004@news.fu-berlin.de>
In article <m2ekqavpor.fsf@linuxsexi.nasttg>,
mriedel@neuearbeit.de (Marko Riedel) wrote:
> Hello again,
>
> my apologies: I didn't use grep properly. That said, the problem persists.
>
> [PROMPT]> perl -e '%h=qw/\A 1 \B 2/; print "yes\n" if grep(/\\B/, keys %h);'
> yes
> [PROMPT]> perl -e '%h=qw/\A 1 \B 2/; print "yes\n" if grep(/\\C/, keys %h);'
> [PROMPT]> perl -e '%h=qw/\A 1 \B 2/; print "yes\n" if exists($h{\B});'
Either:
perl -e '%h=qw/\A 1 \B 2/; print "yes\n" if exists($h{"\\B"});'
or
perl -e '%h=qw/\A 1 \B 2/; print "yes\n" if exists($h{q/\B/});'
works fine.
--
Sandman[.net]
------------------------------
Date: 26 Apr 2004 10:23:49 -0600
From: Jim Cochrane <jtc@shell.dimensional.com>
Subject: Re: backslash in hash keys
Message-Id: <slrnc8qdsl.tjn.jtc@shell.dimensional.com>
In article <m2llkivr3e.fsf@linuxsexi.nasttg>, Marko Riedel wrote:
>
> Hi folks,
>
> it seems that "exists" does not work on hash keys that begin with a
> backslash, but grep on the keys finds the key. (These keys occur
> e.g. when working with IMAP message flags.)
>
> Would someone explain, please?
>
> [PROMPT]> perl -e '%h=qw/A 1 B 2/; print "yes\n" if exists($h{B});'
> yes
> [PROMPT]> perl -e '%h=qw/\A 1 \B 2/; print "yes\n" if exists($h{\B});'
> [PROMPT]> perl -e '%h=qw/\A 1 \B 2/; print "yes\n" if grep('\B', keys %h);'
> yes
>
> perl -v
And if you tell perl, in the 2nd program to "use strict", you get:
yes
Bareword "B" not allowed while "strict subs" in use at -e line 1.
Execution of -e aborted due to compilation errors.
yes
which gives you a clue as to why what you expected is not happening.
--
Jim Cochrane; jtc@dimensional.com
[When responding by email, include the term non-spam in the subject line to
get through my spam filter.]
------------------------------
Date: 26 Apr 2004 09:39:46 -0700
From: fritz-bayer@web.de (Fritz Bayer)
Subject: Re: Difficult regular expression problem!
Message-Id: <a9c0aa9e.0404260839.53a011f1@posting.google.com>
Christian Winter <thepoet_nospam@arcor.de> wrote in message news:<408cdb2a$0$26353$9b4e6d93@newsread4.arcor-online.net>...
> Fritz Bayer wrote:
> > $context = "This is a very simple sentence. Always, the second up to
> > the last word of this sentence should be captured!"
> >
> > $content =~ s/(simple|easy|plain|simplitic)?.*Always(.*)captured!/
> > print($1 . "\n")/iesg;
>
> Is it intentionally that one scalar is called $context,
> whereas you apply your regex-substitution to $content?
>
> -Christian
Sorry, this is a mistake, of course they should be equivalent. This
meant to be an ilustrative example.
------------------------------
Date: 26 Apr 2004 10:14:05 -0700
From: fritz-bayer@web.de (Fritz Bayer)
Subject: Re: Difficult regular expression problem!
Message-Id: <a9c0aa9e.0404260914.39e8e5dc@posting.google.com>
Gunnar Hjalmarsson <noreply@gunnar.cc> wrote in message news:<c6io62$c4icl$1@ID-184292.news.uni-berlin.de>...
> Fritz Bayer wrote:
> > I have the problem that the regular expression (word1|word2|word3)?
> > is not being recalled when later being referenced using $1.
> >
> > Here a very simple example:
> >
> > $context = "This is a very simple sentence. Always, the second up
> > to the last word of this sentence should be captured!"
> >
> > $content =~ s/(simple|easy|plain|simplitic)?.*Always(.*)captured!/
> > print($1 . "\n")/iesg;
>
> If capturing things is what you want to do, why are you using the s///
> operator?
>
> > Now, I would expect this to be printing out "simple" followed by ",
> > the second up to the last word of this sentence should be " to the
> > console.
>
> Why would it print $2 if you don't tell it to do so?
>
> > However, this does not happen. I used $& to look at what gets
> > matched and it seems nothing at all.
>
> I would disagree. The regex matches, and $2 has content.
>
> > If I take the question mark out - then the expresson matches, but
> > the problem is, that I also want the the following variation of the
> > above sentence to match:
> >
> > "$context = "This is a very STUPID sentence. Always, the second up
> > to the last word of this sentence should be captured!"
>
> Okay. Using ? in combination with .* seems not to be a good idea.
> Maybe you should use two regexes, testing the presence of "simple"
> etc. separately:
>
> my ($word) = $content =~ /(simple|easy|plain|simplitic).*Always/;
> print "Found ", ($word ? "'$word'" : 'nothing'),
> " before 'Always'.\n";
You are right. I'm sorry not having set up the example correctly. Of
course, $1 and $2 should be printed out and the scalar namens should
be the same.
So let me try to explain the problem using words. What I'm trying to
achieve can be summarized as follows:
1. I'm looking for a pattern (lets call it A), which I want to capture
and print out to standard output. It reocurs several times in the
text.
2. If I find the pattern A in the text, then I want to know, whether
or not a certain word (lets call it B) out of a word list (lets call
it C) preceeds pattern A.
3. In the end I want the following result: If A is found, preceeded by
a word out of C, then print A;C;. If A is found, but none of the words
out of C preceed A, the just print A;;.
For example:
"This is an example, which hopefully helps me and you to solve my
problem. I would buy a used computer for 50 Dollars but I wouldn' buy
it for 1000 Dollars. I definitely would by an apartment for 3000
Dollars or a Miro for 1500 Dollars but not for 5000000 Dollars. For 50
Dollars you can hire me as a perl programmer - but I guess I'm not
worth the Dollar:)"
Here the regex, which of course is not working (just to give you an
idea):
/.*?(computer|apartment|miro|somethingelsemissing).*?(\d+)\s+Dollars?/
print ($1 . ";" . $2 . ";\n")/gies
I would like the following result:
50;computer;
1000;;
3000;apartment;
1500;Miro;
5000000;;
50;;
------------------------------
Date: 26 Apr 2004 17:45:07 GMT
From: Glenn Jackman <xx087@freenet.carleton.ca>
Subject: Re: Difficult regular expression problem!
Message-Id: <slrnc8qil3.7o8.xx087@smeagol.ncf.ca>
Fritz Bayer <fritz-bayer@web.de> wrote:
[...]
> 1. I'm looking for a pattern (lets call it A), which I want to capture
> and print out to standard output. It reocurs several times in the
> text.
>
> 2. If I find the pattern A in the text, then I want to know, whether
> or not a certain word (lets call it B) out of a word list (lets call
> it C) preceeds pattern A.
>
> 3. In the end I want the following result: If A is found, preceeded by
> a word out of C, then print A;C;. If A is found, but none of the words
> out of C preceed A, the just print A;;.
>
> For example:
>
> "This is an example, which hopefully helps me and you to solve my
> problem. I would buy a used computer for 50 Dollars but I wouldn' buy
> it for 1000 Dollars. I definitely would by an apartment for 3000
> Dollars or a Miro for 1500 Dollars but not for 5000000 Dollars. For 50
> Dollars you can hire me as a perl programmer - but I guess I'm not
> worth the Dollar:)"
>
> Here the regex, which of course is not working (just to give you an
> idea):
> /.*?(computer|apartment|miro|somethingelsemissing).*?(\d+)\s+Dollars?/
> print ($1 . ";" . $2 . ";\n")/gies
>
> I would like the following result:
>
> 50;computer;
> 1000;;
> 3000;apartment;
> 1500;Miro;
> 5000000;;
> 50;;
I don't think regular expressions can do it.
You can split on the dollar value and look at the preceding piece of
text for the item:
my $text = <<EXAMPLE;
This is an example, which hopefully helps me and you to solve my
problem. I would buy a used computer for 50 Dollars but I wouldn' buy
it for 1000 Dollars. I definitely would by an apartment for 3000
Dollars or a Miro for 1500 Dollars but not for 5000000 Dollars. For 50
Dollars you can hire me as a perl programmer - but I guess I'm not
worth the Dollar:)
EXAMPLE
my @list = split /(\d+)\s+Dollars?/, $text;
my $item_re = qr{(computer|apartment|miro|somethingelsemissing)}io;
while (1) {
my $piece = shift @list;
my $amount = shift @list;
last unless defined $amount;
my ($thing) = ($piece =~ $item_re);
$thing ||= '';
print "$amount;$thing;\n";
}
--
Glenn Jackman
NCF Sysadmin
glennj@ncf.ca
------------------------------
Date: Mon, 26 Apr 2004 19:49:01 +0200
From: Gunnar Hjalmarsson <noreply@gunnar.cc>
Subject: Re: Difficult regular expression problem!
Message-Id: <c6ji7g$ccroo$1@ID-184292.news.uni-berlin.de>
Fritz Bayer wrote:
> 1. I'm looking for a pattern (lets call it A), which I want to
> capture and print out to standard output. It reocurs several times
> in the text.
>
> 2. If I find the pattern A in the text, then I want to know,
> whether or not a certain word (lets call it B) out of a word list
> (lets call it C) preceeds pattern A.
>
> 3. In the end I want the following result: If A is found, preceeded
> by a word out of C, then print A;C;. If A is found, but none of the
> words out of C preceed A, the just print A;;.
>
> For example:
>
> "This is an example, which hopefully helps me and you to solve my
> problem. I would buy a used computer for 50 Dollars but I wouldn'
> buy it for 1000 Dollars. I definitely would by an apartment for
> 3000 Dollars or a Miro for 1500 Dollars but not for 5000000
> Dollars. For 50 Dollars you can hire me as a perl programmer - but
> I guess I'm not worth the Dollar:)"
>
> Here the regex, which of course is not working (just to give you an
> idea):
> /.*?(computer|apartment|miro|somethingelsemissing).*?(\d+)\s+Dollars?/
> print ($1 . ";" . $2 . ";\n")/gies
>
> I would like the following result:
>
> 50;computer;
> 1000;;
> 3000;apartment;
> 1500;Miro;
> 5000000;;
> 50;;
As I indicated in my previous reply, I believe that you'd better
capture respective pattern in two steps. This would do it:
while (/(.*?)(\d+)\s+Dollar?/igs) {
print "$2;",
$1 =~ /(computer|apartment|miro|somethingelsemissing)/i,
";\n";
}
--
Gunnar Hjalmarsson
Email: http://www.gunnar.cc/cgi-bin/contact.pl
------------------------------
Date: Mon, 26 Apr 2004 13:50:10 GMT
From: Uri Guttman <uri@stemsystems.com>
Subject: Re: free source blogger (works)
Message-Id: <x7ekqadf1q.fsf@mail.sysarch.com>
define 'works' in 500 words or less
uri
--
Uri Guttman ------ uri@stemsystems.com -------- http://www.stemsystems.com
--Perl Consulting, Stem Development, Systems Architecture, Design and Coding-
Search or Offer Perl Jobs ---------------------------- http://jobs.perl.org
------------------------------
Date: Mon, 26 Apr 2004 14:08:16 -0000
From: "David K. Wall" <dwall@fastmail.fm>
Subject: Re: free source blogger (works)
Message-Id: <Xns94D76720A4176dkwwashere@216.168.3.30>
Uri Guttman <uri@stemsystems.com> wrote:
> define 'works' in 500 words or less
The opposite of "doesn't work".
Alternatively, a product marketed by a certain Seattle-based company.
The product's full name is considered by many to be an oxymoron. See
above.
------------------------------
Date: 26 Apr 2004 16:47:53 GMT
From: ctcgag@hotmail.com
Subject: Re: Help! How to find memory leak?
Message-Id: <20040426124753.177$La@newsreader.com>
Amanda <aman_DO_da345@al_THE_ter_OBVIOUS_n.org> wrote:
> I am using a Perl program that must process a large number (10**7)
> of items.
Are all the items processed independently?
> As the program runs, I've noticed that it becomes less
> and less efficient in its processing, and at the same time, it
> consumes more and more memory. Reading over the program's voluminous
> code (not written by me), I can't find what causes this growth in
> memory consumption. Are there any tools that could help figure
> out where/how this is coming about?
I find "next", "return", and "#" to be the most useful tools. Use them
to do a binary-like search of the code. Also, Data::Dumper can be useful:
if you have a few suspect variables in mind, run a "print length Dumper
\%suspect" every now and then. Devel::Leak can also be helpful, mostly if
the program is working with complex data structures or XS.
Finally, you could force a core-dump and use strings or vi to inspect the
guts for familiar looking data.
Xho
--
-------------------- http://NewsReader.Com/ --------------------
Usenet Newsgroup Service $9.95/Month 30GB
------------------------------
Date: Mon, 26 Apr 2004 14:08:27 GMT
From: Kyler Laird <Kyler@news.Lairds.org>
Subject: Re: How can I create a PDF page with only Images (EPS & TIFF)
Message-Id: <5aevl1-1i8.ln1@snout.lairds.org>
junk@dlink.org (Aqua) writes:
>I have lot of EPS and TIFF images that needs to be manually verified.
>So I wanted to create a PDF with those images.
I recently learned to do this with iText as a first step toward another
goal. My code follows.
>System: Windows 2000
>Packages available: Perl 5.8, Image magick and Ghost Script.
I don't know of any reason you shouldn't be able to install iText
http://www.lowagie.com/iText/
and Jython
http://www.jython.org/
on such a system.
--kyler
========================================================================
#!/usr/bin/env jython
import sys
sys.path.append('/usr/share/java/itext.jar')
import com.lowagie
import java
document = com.lowagie.text.Document(
com.lowagie.text.PageSize.LETTER.rotate(),
page_size,
0, 0, 0, 0
)
com.lowagie.text.pdf.PdfWriter.getInstance(document, java.io.FileOutputStream('foo.pdf'));
document.open()
image_filenames = [
'/home/kyler/common/images/disk0022/img_1279.jpg',
'/home/kyler/common/images/disk0022/img_1284.jpg',
'/home/kyler/common/images/disk0022/img_1304.jpg',
]
width = document.getPageSize().width()
height = document.getPageSize().height()
for image_filename in image_filenames:
print 'adding %s' % (image_filename)
image = com.lowagie.text.Image.getInstance(image_filename)
#image.scalePercent(40)
image.scaleToFit(width, height)
document.add(image)
document.close()
------------------------------
Date: Mon, 26 Apr 2004 13:40:42 -0400
From: Richard Morse <remorse@partners.org>
Subject: Re: How can I create a PDF page with only Images (EPS & TIFF)
Message-Id: <remorse-31EBE3.13404226042004@plato.harvard.edu>
In article <55d7995c.0404252131.7cfec5bd@posting.google.com>,
junk@dlink.org (Aqua) wrote:
> Hello Group,
>
> I have lot of EPS and TIFF images that needs to be manually verified.
> So I wanted to create a PDF with those images.
>
> I appreciate any help in this regard.
>
> System: Windows 2000
> Packages available: Perl 5.8, Image magick and Ghost Script.
Can you install PDF::API2?
This should allow you to create a PDF with all the images...
HTH,
Ricky
--
Pukku
------------------------------
Date: Mon, 26 Apr 2004 17:38:51 +0200
From: Andries <andries@zilz.nl>
Subject: Re: is there a way ..... any way
Message-Id: <gvaq80denmg83kppra7o3gf8ek3scoc6mv@4ax.com>
People,
Your comment to my statements is heartwarming and helps a lot.
Thank you (and i'm not cynical)
The tips on learning how is very usefull.
I lurk on in this newsgroup and will study.
Gunnar helped me a lot by giving me code. This is experimental
material for me. Learning material!
I'll undestand the meaning of this newsgroup and understand your
frustration.
And remember: I"LL BE THERE (even if you don't see me :-))
Andries
------------------------------
Date: 26 Apr 2004 16:36:10 GMT
From: roberson@ibd.nrc-cnrc.gc.ca (Walter Roberson)
Subject: Re: is there a way ..... any way
Message-Id: <c6jdpq$li8$1@canopus.cc.umanitoba.ca>
In article <28ced4fb1ea82f83080303c3a68e0e89@news.teranews.com>,
Randal L. Schwartz <merlyn@stonehenge.com> wrote:
:I really want to answer every question here. I answer as many as I
:can. I know many of the other experts here (and the experts who have
:already left) feel the same. But when I have to keep answering the
:same questions week after week, I get a bit bored, and wonder why
:people don't type "perldoc" or "www.google.com" or "groups.google.com"
:often enough. And then there's the group of lazy bas**rds who want me
:to debug their program for them, a job better done by someone for
:hire, not a free resource.
Randal, I have, to use the cliche, "Been there. Done that." I (amongst
others) have put a lot of work into some of the other technical
hierarchies, and have faced the same challenges (though not to the same
scale.) I know that I have sometimes gotten frustrated myself at
answering the same question for the 4th time on one day, when it has
been obvious that the posters haven't done even preliminary checking
around to find the answers. And I know that from time to time, I have
ranted when I have felt that someone was trying to take advantage of me
(e.g., a time when someone said outright that they never bothered to
even try to read the manual pages because it was 'faster' to post and
let other people answer the question for him.)
And I've had to learn how to "let go" of wanting to answer every
question, because there are too many questions for one person [and when
there are not so many questions and I could handle them all
comfortably, I would have a tendancy to expand into more and more
newsgroups, with more and more complex topics. ] My boss calls it
"delegation", and says that I need to learn how to delegate more.
And it's *hard* for an old perfectionist like me to just let things
sit undone, unanswered, or to hand them off to someone who is going
to spend weeks doing what I could do in a single evening... if only
I didn't have 35 other "top priority" "Do by Yesterday" self-imposed
tasks on my to-do-list.
I am, as some might say, the classic recipie for workaholic burnout.
And oh, did I burn out! and was nearly completely useless for 10 months
before I -started- to recover (I'm still very much recovering, and
still having bad tendancies to slip back into doing too much, wanting
to do everything, wanting to answer every question....)
But for all of that, for the load and stresses, internal and external,
those other technical hierarchies that I'm involved with still come off as
"nicer" places than clpm. [Unless someone mentions Linux -- but the
regulars know better than to encourage the inevitable resulting troll
posting.] We've worked out wordless agreements -- one of the regulars
answers any given repeated question politely (but usually not in detail) if
they feel like it, and if the question is still sitting unanswered after
a few days or a week, then one of the irregular posters will probably
eventually answer it. And if no-one answers it, then we save our
sanity by just letting it go unanswered. When we're getting cranky
from answering over and over again, we back off; someone will either
step in and take our place or they won't. We're not miracle workers,
we're people, and we do what we -reasonably- can, and retire to the
sidelines for a rest when we need to. (And if someone then starts
*demanding* answers, *then* we flame them ;-) )
--
Rump-Titty-Titty-Tum-TAH-Tee -- Fritz Lieber
------------------------------
Date: Mon, 26 Apr 2004 16:56:59 GMT
From: merlyn@stonehenge.com (Randal L. Schwartz)
Subject: Re: is there a way ..... any way
Message-Id: <d2023fafe9023c1392d48909b2c9e19a@news.teranews.com>
>>>>> "Walter" == Walter Roberson <roberson@ibd.nrc-cnrc.gc.ca> writes:
Walter> And if no-one answers it, then we save our sanity by just
Walter> letting it go unanswered.
Maybe you can afford that luxury in other areas, but there's a lot of
cargo-culted junk in the semi-answers all over the web, and everyone
seems to consider themselves an expert after reading some random web
tutorial. So, what happens in the Perl community is that the absence
of good answers from experts gets filled up with crap answers from
answerer-wannabes. Eeek. And this contributes to the burnout from
the experts.
Perl has an odd learning curve. Because you can accomplish something
so quickly (hello world is one line), you think you can answer
complicated questions about everything (hint: you can't, and should
better be quiet). Also, Perl has had an interesting history, with the
radical change in design styles between Perl4 and Perl5 (and I fear
Perl6 will only make it worse :-).
So, we get script kiddies that are trying to make a popular Perl4 script
working today, answerers who have only seen such scripts and consider
themselves experts, people who defy authority who won't listen when
an expert tells them they're in one of those first two categories,
and then a few of us that may be burned out from the whole game.
Welcome to Perl. A unique experience, a unique community. Not
nastier, just a bit more polarized. :)
print "Just another Perl hacker,"; # the first
--
Randal L. Schwartz - Stonehenge Consulting Services, Inc. - +1 503 777 0095
<merlyn@stonehenge.com> <URL:http://www.stonehenge.com/merlyn/>
Perl/Unix/security consulting, Technical writing, Comedy, etc. etc.
See PerlTraining.Stonehenge.com for onsite and open-enrollment Perl training!
------------------------------
Date: Mon, 26 Apr 2004 17:58:44 -0000
From: "David K. Wall" <dwall@fastmail.fm>
Subject: Re: is there a way ..... any way
Message-Id: <Xns94D78E33A157dkwwashere@216.168.3.30>
Randal L. Schwartz <merlyn@stonehenge.com> wrote:
>>>>>> "Walter" == Walter Roberson <roberson@ibd.nrc-cnrc.gc.ca>
>>>>>> writes:
>
> Walter> And if no-one answers it, then we save our sanity by just
> Walter> letting it go unanswered.
>
> Maybe you can afford that luxury in other areas, but there's a lot
> of cargo-culted junk in the semi-answers all over the web, and
> everyone seems to consider themselves an expert after reading some
> random web tutorial. So, what happens in the Perl community is
> that the absence of good answers from experts gets filled up with
> crap answers from answerer-wannabes. Eeek. And this contributes
> to the burnout from the experts.
>
> Perl has an odd learning curve. Because you can accomplish
> something so quickly (hello world is one line), you think you can
> answer complicated questions about everything (hint: you can't,
> and should better be quiet).
"Better no answer than a wrong one" is a maxim I've been following
lately. It doesn't stop me from being wrong, but does stop me from
posting when I'm uncertain and don't want to mislead someone.
Even that maxim doesn't stop someone if they're too ignorant to know
they're ignorant. (And that unfortunately can include me. :-)
When I know an answer I sometimes hold off on posting because it
often turns out that someone else will post something that adds
information or a viewpoint I hadn't been aware of. I'm sure there are
plenty of other lurkers who benefit similarly. On behalf of them (or
us), thanks to all of you for what must often seem a thankless task.
One reason not to post much, though, is that some of you seem to be
hooked up to a life-support system that allows you to never leave the
computer, constantly answering posts regardless of the time of day or
day of the week. Do you all ever sleep?
------------------------------
Date: Mon, 26 Apr 2004 16:10:59 GMT
From: "Danny" <dannywork5@hotmail.com>
Subject: NEed your help with yahoo and dynamic URL
Message-Id: <nwajc.32290$t26.9917602@news4.srv.hcvlny.cv.net>
Hello
I am having trouble loading some products onto yahoo product submit.
These are dynamic URL's that point to product pages
I am lost becuase the tech deparments do not seem to know what is going on
and have never heard of product submit and the merchants do not have access
to the index.cgi file.
for example look at this merchants site.
go to www.mymetalcanvas.com and enter DL01 into the search field.
This brings you to the product page which works fine.
Now i duplicated the url to do what the Search button did, so this link
below does the same thing as above and it works fine:
http://www.mymetalcanvas.com/index.cgi?Merchant=gspenterprises&PageToView=search&SearchVal=DL01
This URL works fine in froogle product submit. I do not put in the cartid
which is a session variable, but it seems to recreate one.
Now why wouldnt this link work in Yahoo stores using the yahoo product
submit.
IT gives an error "unable to create session id, please try again later."
But if you copy and paste the yahoo link back into the URL while still at
yahoo, it will work as it finds the landing page. IT is so strange.
PS. The link in yahoo does actually work if you click within results, ie
"see more items from this merchant", but if you enter a search keyword that
brings you to a listing from the same merchant, it will fail.
Thanks
Danny
------------------------------
Date: Mon, 26 Apr 2004 12:40:06 -0400
From: Richard Morse <remorse@partners.org>
Subject: Re: noob question: Trying to extract part of a string in a variable to another variable
Message-Id: <remorse-79A20D.12400626042004@plato.harvard.edu>
In article <2deb3d1.0404250759.7676bbb5@posting.google.com>,
chilecayenne@yahoo.com (cayenne) wrote:
> I have $mail_address = 'fred jones <fred_jones@somewhere.com>'
>
> I want to use regular expressions to just parse out the userid here of
> fred_jones
>
> I'm trying things like this:
>
> $mail_address =~ /\w+@/;
What you seem to be asking for is this:
my ($user_id) = ($mail_address =~ m/(\w+)@/);
However, please note that \w doesn't really have the complete set of
valid characters to prefix the '@' sign in an email address.
Just off the top of my head, I know that '.', '-', '?', '=', and more
are valid. Possibly any unicode character other than whitespace and '@'
are valid. It might even be valid to have '<' in an email address.
At the very least, you probably want
my ($user_id) = ($mail_address =~ m/([\w.-+=]+)@/);
HTH,
Ricky
--
Pukku
------------------------------
Date: 26 Apr 2004 16:59:51 GMT
From: Glenn Jackman <xx087@freenet.carleton.ca>
Subject: Re: noob question: Trying to extract part of a string in a variable to another variable
Message-Id: <slrnc8qg08.7o8.xx087@smeagol.ncf.ca>
Richard Morse <remorse@partners.org> wrote:
> At the very least, you probably want
>
> my ($user_id) = ($mail_address =~ m/([\w.-+=]+)@/);
Be careful where you use '-' inside a range:
Invalid [] range ".-+" before HERE mark in regex m/([\w.-+ << HERE =]+)@/
Put the hyphen last: [\w.+=-]
--
Glenn Jackman
NCF Sysadmin
glennj@ncf.ca
------------------------------
Date: 26 Apr 2004 17:23:29 GMT
From: ctcgag@hotmail.com
Subject: Re: other perl groups
Message-Id: <20040426132329.927$1l@newsreader.com>
"pfancy" <pfancy@bscn.com> wrote:
> Are the any other perl groups who will actually help out people who are
> NEW to perl.
I was new to perl not that long ago, and I found
this group extremely helpful.
Xho
--
-------------------- http://NewsReader.Com/ --------------------
Usenet Newsgroup Service $9.95/Month 30GB
------------------------------
Date: Mon, 26 Apr 2004 20:41:09 +0500
From: Roman Kaganovich <nospam@nospam.com>
Subject: regular expression error
Message-Id: <408d49bd@news.barak.net.il>
Hello ,
I wrote a program based an example from "Perl Cookbook".
I run it at file test that contain this text:
blah blah (22.34 215.645)
something (1978 404)
opla 1234
When I use code:
#!/usr/bin/perl -w
my $x=$ARGV[1];
open FILE,$ARGV[0] or die "$!";
while (<FILE>){
chomp;
s/\((\d+)/$x * $1/e;
$x=$ARGV[1];
print "$_\n";
}
I got no errors.
But if I modify a code to:
#!/usr/bin/perl -w
my $x=$ARGV[1];
my $y=$ARGV[2];
open FILE,$ARGV[0] or die "$!";
while (<FILE>){
chomp;
s/\((\d+\.\d+|\d+?)(\s+?)(\d+\.\d+|\d+?)/$x * $1 $y * $3/ex;
$x=$ARGV[1];
$y=$ARGV[2];
print "$_\n";
}
I got next output:
> ./col.pl test 10 2
Scalar found where operator expected at ./col.pl line 10, near "$1 $y"
(Missing operator before $y?)
syntax error at ./col.pl line 10, near "$1 $y"
Execution of ./col.pl aborted due to compilation errors.
------------------------------
Date: Mon, 26 Apr 2004 13:57:47 -0400
From: Richard Morse <remorse@partners.org>
Subject: Re: regular expression error
Message-Id: <remorse-546502.13574726042004@plato.harvard.edu>
In article <408d49bd@news.barak.net.il>,
Roman Kaganovich <nospam@nospam.com> wrote:
> s/\((\d+\.\d+|\d+?)(\s+?)(\d+\.\d+|\d+?)/$x * $1 $y * $3/ex;
>
> Scalar found where operator expected at ./col.pl line 10, near "$1 $y"
> (Missing operator before $y?)
> syntax error at ./col.pl line 10, near "$1 $y"
In your substitute, you are using the 'e' flag. This causes the
substituted value to be treated as an expression. If you run the
following program:
#!/usr/bin/perl
use strict;
use warnings;
my $x = 5;
$1 = 6;
my $y = 7;
$3 = 8;
my $z = $x * $1 $y * $3;
print $z;
__END__
you get the same error. This is because your haven't told perl how to
combine $1 and $y -- perhaps you meant:
($x * $1) * ($y * $3)
or
($x * $1) + ($y * $3)
or
($x * $1) . ($y * $3)
or even
($x * $1) x ($y * $3)
How is perl to know?
You probably (based on the context, and my guess) want
($x * $1) . ' ' . ($y * $3)
HTH,
Ricky
--
Pukku
------------------------------
Date: Mon, 26 Apr 2004 13:53:39 -0400
From: Paul Lalli <ittyspam@yahoo.com>
Subject: Re: regular expression error
Message-Id: <20040426134826.X1107@dishwasher.cs.rpi.edu>
On Mon, 26 Apr 2004, Roman Kaganovich wrote:
> #!/usr/bin/perl -w
>
> my $x=$ARGV[1];
> my $y=$ARGV[2];
> open FILE,$ARGV[0] or die "$!";
> while (<FILE>){
> chomp;
> s/\((\d+\.\d+|\d+?)(\s+?)(\d+\.\d+|\d+?)/$x * $1 $y * $3/ex;
^^^^^^^^^^^^^^^
> $x=$ARGV[1];
> $y=$ARGV[2];
>
> print "$_\n";
> }
>
>
> I got next output:
>
> > ./col.pl test 10 2
> Scalar found where operator expected at ./col.pl line 10, near "$1 $y"
> (Missing operator before $y?)
> syntax error at ./col.pl line 10, near "$1 $y"
^^^^^
> Execution of ./col.pl aborted due to compilation errors.
Perl is telling you exactly what's wrong. What are you thinking your code
is going to do? That underlined portion in your regexp is a syntax error,
as you provided the /e modifier and:
$x * $1 $y * $3
is not a valid expression. It looks like *maybe* you're trying to print
the results of both operations to standard output? In that case, you need
to tell Perl to concatenate the two values:
($x * $1) . ' ' . ($y * $3)
Or are you trying to do something else?
Paul Lalli
------------------------------
Date: 26 Apr 2004 06:47:12 -0700
From: christian.meilke@gmx.net (Christian Meilke)
Subject: special regular expression problem
Message-Id: <508ce2b.0404260547.65fa93a9@posting.google.com>
here's a a special problem that i need quick help on (thanks in
advance):
i've got a number which has more than 4 digits. now i need a reg exp
for determining if this number starts with "1220" and a complementary
reg exp!
with that i don't mean doing it with " !~ " or any other expression
with " not " or " ! ".
------------------------------
Date: Mon, 26 Apr 2004 13:55:27 GMT
From: "Jürgen Exner" <jurgenex@hotmail.com>
Subject: Re: special regular expression problem
Message-Id: <jx8jc.40020$Aq.16978@nwrddc03.gnilink.net>
Christian Meilke wrote:
> here's a a special problem that i need quick help on (thanks in
> advance):
>
> i've got a number which has more than 4 digits. now i need a reg exp
> for determining if this number starts with "1220" and a complementary
> reg exp!
>
> with that i don't mean doing it with " !~ " or any other expression
> with " not " or " ! ".
TIMTOWTDI:
if (/^1220/) {
print 'Match found';
} else {
print 'Does not start with 1220';
}
Or a simple
print 'Does not start with 1220' unless /^1220/;
That doesn't use a not or !, either.
jue
------------------------------
Date: 26 Apr 2004 14:04:15 GMT
From: Glenn Jackman <xx087@freenet.carleton.ca>
Subject: Re: special regular expression problem
Message-Id: <slrnc8q5mv.7o8.xx087@smeagol.ncf.ca>
Christian Meilke <christian.meilke@gmx.net> wrote:
> i've got a number which has more than 4 digits. now i need a reg exp
> for determining if this number starts with "1220" and a complementary
> reg exp!
number starts with 1220: $number =~ /^1220\d+$/
number doesn't start with 1220: $number =~ /^(?!1220)\d{5,}$/
--
Glenn Jackman
NCF Sysadmin
glennj@ncf.ca
------------------------------
Date: Mon, 26 Apr 2004 18:53:14 +0200
From: Tore Aursand <tore@aursand.no>
Subject: Re: special regular expression problem
Message-Id: <pan.2004.04.26.16.52.57.840797@aursand.no>
On Mon, 26 Apr 2004 06:47:12 -0700, Christian Meilke wrote:
> i've got a number which has more than 4 digits. now i need a reg exp for
> determining if this number starts with "1220" and a complementary reg
> exp!
Why do you need a regular expression to do this?
if ( substr($str,0,4) eq '1220' ) {
print "Match!\n";
}
else {
print "Does not match!\n";
}
Put this in a loop and you'll eventually see that 'substr()' is faster for
this kind of work. At least I think so - never bothered to benchmark this
one, really.
--
Tore Aursand <tore@aursand.no>
"Why shouldn't truth be stranger than fiction? Fiction, after all, has
to make sense." (Mark Twain)
------------------------------
Date: Mon, 26 Apr 2004 16:22:43 GMT
From: "John W. Kennedy" <jwkenne@attglobal.net>
Subject: Re: Tripod wont find my lib files
Message-Id: <nHajc.32391$t26.9949401@news4.srv.hcvlny.cv.net>
Bob Walton wrote:
> javatiger wrote:
>
>> Every time I upload a library file into my cgi bin, tripod refuses to
>
>
> -------------------------------------^^^^^^^^^^^^^^^
>
> What's "tripod"?
>
>
>> find it and comes up with an error.
>>
>> It looks like there was an error:
>> Your script produced this error: Can't locate File/Glob.pm in @INC
>> (@INC contains: . / /lib /site_perl)
>
>
> ----------------------------------------------------^^^^^^^^^^^^^^^^^^^
>
> Is your "cgi bin" one of the above directories? (hint: your web server
> may not start your CGI routines with the current directory being the
> directory in which the CGI routines reside). If not, loading a "library
> file" there will do no good, as Perl is only searching the directories
> in @INC for library routines. Maybe you should instead load the
> "library file" into one of those directories. Or put a "use lib ..."
> statement into your program which tells Perl to search the place where
> you put the files.
Tripod provides _no_ Perl library modules, requiring everything to be in
the user's cgi-bin directory. They supply an obsolete version of perl5,
an even more obsolete version of CGI.pm, and about four modules of their
own composition. All of these you have to download from them and then
upload into your cgi-bin directory.
File/Glob.pm, of course, would have to put into a subdirectory of
cgi-bin named File.
--
John W. Kennedy
"Sweet, was Christ crucified to create this chat?"
-- Charles Williams. "Judgement at Chelmsford"
------------------------------
Date: 26 Apr 2004 13:06:28 GMT
From: anno4000@lublin.zrz.tu-berlin.de (Anno Siegel)
Subject: Re: Where is PL_stack_base defined???
Message-Id: <c6j1gk$maf$1@mamenchi.zrz.TU-Berlin.DE>
Tassilo v. Parseval <tassilo.parseval@post.rwth-aachen.de> wrote in comp.lang.perl.misc:
> Also sprach J Krugman:
>
> > I'm going blind reading the Perl source! It's chaos!!!
>
> There are rumours that perl has initially really just been an
> experiment to prove that a program can be written only by using the
> preprocessor. It eventually failed and that's the reason why you'll
> occasionally find a few lines of C code sprinkled in between the
> preprocessor directives.
>
> > Where is PL_stack_base defined???
[...]
> > I know about perlguts, but it is of no help with questions like
> > this. Is there any other guide to the Perl source code?
>
> Maybe
>
> <http://gisle.aas.no/perl/illguts/>
>
> can help a bit.
>
> Other than that, there is no real guide to the source that I know of.
As someone who only occasionally ventures into XS programming, I
find _Extending and Embedding Perl_ by Tim Jenness and Simon Cozens
useful. It doesn't appear to contain anything that isn't available
elsewhere, but it has it in one place.
Anno
------------------------------
Date: Mon, 26 Apr 2004 19:38:24 +0200
From: "Tassilo v. Parseval" <tassilo.parseval@rwth-aachen.de>
Subject: Re: Where is PL_stack_base defined???
Message-Id: <c6jhei$cfhpl$1@ID-231055.news.uni-berlin.de>
Also sprach Anno Siegel:
> Tassilo v. Parseval <tassilo.parseval@post.rwth-aachen.de> wrote in comp.lang.perl.misc:
>> Also sprach J Krugman:
>> > Where is PL_stack_base defined???
>
> [...]
>
>> > I know about perlguts, but it is of no help with questions like
>> > this. Is there any other guide to the Perl source code?
>>
>> Maybe
>>
>> <http://gisle.aas.no/perl/illguts/>
>>
>> can help a bit.
>>
>> Other than that, there is no real guide to the source that I know of.
>
> As someone who only occasionally ventures into XS programming, I
> find _Extending and Embedding Perl_ by Tim Jenness and Simon Cozens
> useful. It doesn't appear to contain anything that isn't available
> elsewhere, but it has it in one place.
I don't have this book but I generally heard good things about it.
I suppose that learning XS first might be a good way to approach the
perl source anyway. Just trying to understand the innards by reading the
source is a very tall order. It's also more fun.
Tassilo
--
$_=q#",}])!JAPH!qq(tsuJ[{@"tnirp}3..0}_$;//::niam/s~=)]3[))_$-3(rellac(=_$({
pam{rekcahbus})(rekcah{lrePbus})(lreP{rehtonabus})!JAPH!qq(rehtona{tsuJbus#;
$_=reverse,s+(?<=sub).+q#q!'"qq.\t$&."'!#+sexisexiixesixeseg;y~\n~~dddd;eval
------------------------------
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 6468
***************************************