[25068] in Perl-Users-Digest

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

Perl-Users Digest, Issue: 7318 Volume: 10

daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Wed Oct 27 06:05:45 2004

Date: Wed, 27 Oct 2004 03:05:07 -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           Wed, 27 Oct 2004     Volume: 10 Number: 7318

Today's topics:
    Re: Compiling or Hiding Perl <tintin@invalid.invalid>
    Re: Compiling or Hiding Perl <do-not-use@invalid.net>
    Re: Compiling or Hiding Perl <usenet@morrow.me.uk>
    Re: Compiling or Hiding Perl (Anno Siegel)
        FAQ 8.14: How do I modify the shadow password file on a <comdog@panix.com>
    Re: Fast random string generation <bik.mido@tiscalinet.it>
        Finding the size of a rather complicated hash-structure <na@na.no>
        help in parsing xml messages (Julie)
    Re: how to fix code running old perl version? <abigail@abigail.nl>
    Re: how to fix code running old perl version? <tassilo.von.parseval@rwth-aachen.de>
    Re: HTTP Watcher <usenet@morrow.me.uk>
    Re: Inter Program Communication ... <stoill@unixsol.org>
    Re: Inter Program Communication ... <stoill@unixsol.org>
    Re: Inter Program Communication ... <stoill@unixsol.org>
    Re: Linux vs. Windows: different behaviour [re rand()] <kalinaubears@iinet.net.au>
    Re: MAIL recommendation <nospam@nospam.com>
    Re: Modify program to write just data to a text file. <abigail@abigail.nl>
    Re: open-perl-ide qustion <do-not-use@invalid.net>
    Re: open-perl-ide qustion <nospam@nospam.com>
    Re: regex trick needed <do-not-use@invalid.net>
    Re: regex trick needed <usenet@morrow.me.uk>
        Digest Administrivia (Last modified: 6 Apr 01) (Perl-Users-Digest Admin)

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

Date: Wed, 27 Oct 2004 21:22:45 +1300
From: "Tintin" <tintin@invalid.invalid>
Subject: Re: Compiling or Hiding Perl
Message-Id: <2u944dF28akduU1@uni-berlin.de>


"daniel kaplan" <nospam@nospam.com> wrote in message 
news:1098854700.79485@nntp.acecape.com...
>> It is very easy to tell to whom I am referring because I do not, unlike
>> you, snip attributions. So, I am asking you not to snip attributions.
>
> ok, still totally lost...

An attribution is what you'll see as the first line of this post, ie: the 
line that tells everyone else that the last comments were made by "daniel 
kaplan".




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

Date: 27 Oct 2004 10:37:27 +0200
From: Arndt Jonasson <do-not-use@invalid.net>
Subject: Re: Compiling or Hiding Perl
Message-Id: <yzdd5z44kvs.fsf@invalid.net>


"daniel kaplan" <nospam@nospam.com> writes:
> > It is very easy to tell to whom I am referring because I do not, unlike
> > you, snip attributions. So, I am asking you not to snip attributions.
> 
> ok, still totally lost...

What he is telling you is that you should keep (or tell your news
posting software to start inserting) the attribution lines that look
like "Foo bar <somewhere.net> wrote:", so that one can easily see who
wrote what.


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

Date: Tue, 26 Oct 2004 22:36:22 +0100
From: Ben Morrow <usenet@morrow.me.uk>
Subject: Re: Compiling or Hiding Perl
Message-Id: <mjs252-43c.ln1@osiris.mauzo.dyndns.org>


Quoth "daniel kaplan" <nospam@nospam.com>:
> which by the way is one problem with patenting something.  you just
> look at the patent and devise a different way to do it.  i am sure we
> will all be dead and buried before they figure out the right way to
> protect works like this..

This is not a problem with patents, it's the *whole* *point*. Unlike
copyright, which is there to protect the interests of the creator,
patents are there for the public interest. Look up the word: 'patent'
comes from the Latin 'patere' meaning 'lie open', and originally meant
'open to general knowledge or use; public'; compare 'patently obvious'.

They were invented at a time when reverse-engineering was extremely hard
and unlikely to happen, and many useful ideas were being lost to
posterity through their inventors keeping them secret. The solution was
to make a deal with the inventor: you tell the public how to do whatever
it is you've invented, and we'll agree to give you free reign with it
for enough time to make your fortune. That's why they're only for (IIRC)
17 years, instead of the 'life of the creator plus however many years
have expired since Walt Disney died' [:)] that copyright is for.

In this day and age when reverse-engineering is the norm rather than the
exception, and especially in the realm of software, I would say there is
an *extremely* good case for dropping the concept altogether; but
particularly the USPTO is so tied up to big business that I don't see as
this is that likely to happen <sigh>.

Ben

-- 
  The cosmos, at best, is like a rubbish heap scattered at random.
                                                         - Heraclitus
  ben@morrow.me.uk


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

Date: 27 Oct 2004 09:20:59 GMT
From: anno4000@lublin.zrz.tu-berlin.de (Anno Siegel)
Subject: Re: Compiling or Hiding Perl
Message-Id: <clnp9r$m3u$1@mamenchi.zrz.TU-Berlin.DE>

daniel kaplan <nospam@nospam.com> wrote in comp.lang.perl.misc:
> > Don't take this personally, but this is a newsgroup, and as along as it is
> not off-topic, don't police.
> 
> boy are you barking up the wrong tree...i tried to be free form here a few
> days ago and i have lost three pints of blood so far.  you either goose-step
> to the fuehrer...i mean FAQ, or you are wrong...

These Nazi silmiles do nothing but play down Nazism.  Nazism is
about power.  Nobody on Usenet has any power over anyone.  You are
disqualifying your own argument.

Anno


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

Date: Wed, 27 Oct 2004 10:03:00 +0000 (UTC)
From: PerlFAQ Server <comdog@panix.com>
Subject: FAQ 8.14: How do I modify the shadow password file on a Unix system?
Message-Id: <clnrok$a3v$1@reader1.panix.com>

This message is one of several periodic postings to comp.lang.perl.misc
intended to make it easier for perl programmers to find answers to
common questions. The core of this message represents an excerpt
from the documentation provided with Perl.

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

8.14: How do I modify the shadow password file on a Unix system?

    If perl was installed correctly and your shadow library was written
    properly, the getpw*() functions described in perlfunc should in theory
    provide (read-only) access to entries in the shadow password file. To
    change the file, make a new shadow password file (the format varies from
    system to system--see passwd for specifics) and use pwd_mkdb(8) to
    install it (see pwd_mkdb for more details).



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

Documents such as this have been called "Answers to Frequently
Asked Questions" or FAQ for short.  They represent an important
part of the Usenet tradition.  They serve to reduce the volume of
redundant traffic on a news group by providing quality answers to
questions that keep coming up.

If you are some how irritated by seeing these postings you are free
to ignore them or add the sender to your killfile.  If you find
errors or other problems with these postings please send corrections
or comments to the posting email address or to the maintainers as
directed in the perlfaq manual page.

Note that the FAQ text posted by this server may have been modified
from that distributed in the stable Perl release.  It may have been
edited to reflect the additions, changes and corrections provided
by respondents, reviewers, and critics to previous postings of
these FAQ. Complete text of these FAQ are available on request.

The perlfaq manual page contains the following copyright notice.

  AUTHOR AND COPYRIGHT

    Copyright (c) 1997-2002 Tom Christiansen and Nathan
    Torkington, and other contributors as noted. All rights 
    reserved.

This posting is provided in the hope that it will be useful but
does not represent a commitment or contract of any kind on the part
of the contributers, authors or their agents.


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

Date: Wed, 27 Oct 2004 11:56:40 +0200
From: Michele Dondi <bik.mido@tiscalinet.it>
Subject: Re: Fast random string generation
Message-Id: <m66tn0t774a6npv2jjp2nsk74pl0ak6ia4@4ax.com>

On Tue, 26 Oct 2004 09:55:40 GMT, Bart Lateur <bart.lateur@pandora.be>
wrote:

>I can think of a caveat: I seem to recall that at least some random
>generators only had 24 significant bits. Now if you plan on using 32, it
>won't be completely random. Instead, I expect the lowest byte to always
>be the same, or at least, close to the same few values. (taking odd
>rounding into account)

Well, as I wrote, this doesn't seem to be the case. At least under
Linux, but then see the "Linux vs. Windows: different behaviour [re
rand()]" thread started anew about this very topic...


Michele
-- 
{$_=pack'B8'x25,unpack'A8'x32,$a^=sub{pop^pop}->(map substr
(($a||=join'',map--$|x$_,(unpack'w',unpack'u','G^<R<Y]*YB='
 .'KYU;*EVH[.FHF2W+#"\Z*5TI/ER<Z`S(G.DZZ9OX0Z')=~/./g)x2,$_,
256),7,249);s/[^\w,]/ /g;$ \=/^J/?$/:"\r";print,redo}#JAPH,


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

Date: 27 Oct 2004 11:26:53 +0200
From: Fred <na@na.no>
Subject: Finding the size of a rather complicated hash-structure
Message-Id: <opsgiu63tdzgaswl@frodepc>

Hi group

Ok, so I've got a rather complicated hash-structure that I'd like to find  
the size of. Size in consumed bytes of memory. Just because I'm curious.  
And I've done the obligatory searches for finding sizes of stuff, and I'm  
not much the wiser. Exept I've come to understand that there isn't any  
bult-in functionality to do this for such structures.

So here I am then. Needing help!

My hash-structure looks something like this:

$tree = {
   <key> => {
     'name' => <str>,
     'file' => <str>,
     'architectures' => {
       <key> => {
         'name' => <str>,
         'file' => <str>,
         'components' => {
           <key> = {
             'name' => <str>,
             'lib'  => <str>
           }
         }
       }
     }
   }
};

Actually it's much bigger, but this gives you a general idea of what it's  
like. For each anonymous hash, the '<key>' have several elements,  
typically around a hundred in $tree, one or two in  
$tree->{<key>}->{'architectures'} and none or a couple in  
$tree->{<key>}->{'architectures'}->{<key>}->{'components'}.

I suppose I could loop through tree, pushing name and file to an array,  
looping through the architectures for each element in tree, and pushing  
name and file to the same array, and doing the same with the components.  
And then just flattening the array and use length(). But...that's kinda  
dirty.....

(Not that I don't like my gals dirty...and perl's my bitch...so I guess I  
might as well go for it...hehe! :-D )

But anyway...any good suggestions on how I can find out how many bytes of  
memory my Frankenstein-hash is consuming, without writing a whole program  
to find it? Or doing it the 'dirty' way?


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

Date: 27 Oct 2004 02:45:47 -0700
From: nagoba@rediffmail.com (Julie)
Subject: help in parsing xml messages
Message-Id: <22810328.0410270145.2c85b40@posting.google.com>

Hi,

I have an xml string like so.....


<q path="bugs/bug/bugs/@bug_id=3" match="endswith" true="true" op="and">
  <q path="bugs/bug/reports/@id=57" match="binary" true="true" op="and">
    <q path="bugs/bug/reports/@id=21" match="partial" true="true" op="or"/>
  </q>
</q>



I want to parse it so that I can then 
create a query via
reading the innermost loop and then the outer loop and then the outer loop,
and creating sql queries with each pass.


like.....

SELECT * from reports r,bugs b where r.id=21 and r.id= 57 and b.bug_id = 3;

how do I parse the xml to do this ?

any help will be appreciated.
thanks.
Julie


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

Date: 27 Oct 2004 07:24:13 GMT
From: Abigail <abigail@abigail.nl>
Subject: Re: how to fix code running old perl version?
Message-Id: <slrncnuj8s.3ac.abigail@alexandra.abigail.nl>

Tassilo v. Parseval (tassilo.von.parseval@rwth-aachen.de) wrote on
MMMMLXXV September MCMXCIII in <URL:news:slrncnubir.qo.tassilo.von.parseval@localhost.localdomain>:
//  Also sprach Abigail:
//  
// > Paul Lalli (mritty@gmail.com) wrote on MMMMLXXIV September MCMXCIII in
// ><URL:news:UOsfd.3113$Xq3.2993@trndny01>:
//  
// > !!  No no no!  Wrong solution!  Keep use strict, and use our's predecessor:
// > !!  use vars qw/$opt_v/;  #this replaces our $opt_v;
// >
// >
// > Considering that his script runs fine *with* use strict on 5.6 and 5.8,
// > I don't see any harm in removing the use strict, and the other change
// > he proposes.
// >
// > What benefit does keeping 'use strict' have? 
//  
//  Strictures still have one runtime-effect: That is detecting and barfing
//  on symbolic references. So strictures shouldn't automatically be removed
//  once a program passes 'perl -Mstrict -c'. One never knows under which
//  contrived circumstances things could still go wrong.


Did I say it should be removed automatically once it passes -Mstrict -c?


Abigail
-- 
perl -wleprint -eqq-@{[ -eqw\\- -eJust -eanother -ePerl -eHacker -e\\-]}-


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

Date: Wed, 27 Oct 2004 09:34:54 +0200
From: "Tassilo v. Parseval" <tassilo.von.parseval@rwth-aachen.de>
Subject: Re: how to fix code running old perl version?
Message-Id: <slrncnujsu.1tk.tassilo.von.parseval@localhost.localdomain>

Also sprach Abigail:

> Tassilo v. Parseval (tassilo.von.parseval@rwth-aachen.de) wrote on
> MMMMLXXV September MCMXCIII in <URL:news:slrncnubir.qo.tassilo.von.parseval@localhost.localdomain>:
> //  Also sprach Abigail:
> //  
> // > Paul Lalli (mritty@gmail.com) wrote on MMMMLXXIV September MCMXCIII in
> // ><URL:news:UOsfd.3113$Xq3.2993@trndny01>:
> //  
> // > !!  No no no!  Wrong solution!  Keep use strict, and use our's predecessor:
> // > !!  use vars qw/$opt_v/;  #this replaces our $opt_v;
> // >
> // >
> // > Considering that his script runs fine *with* use strict on 5.6 and 5.8,
> // > I don't see any harm in removing the use strict, and the other change
> // > he proposes.
> // >
> // > What benefit does keeping 'use strict' have? 
> //  
> //  Strictures still have one runtime-effect: That is detecting and barfing
> //  on symbolic references. So strictures shouldn't automatically be removed
> //  once a program passes 'perl -Mstrict -c'. One never knows under which
> //  contrived circumstances things could still go wrong.
>
>
> Did I say it should be removed automatically once it passes -Mstrict -c?

You made the assumption that his script runs fine and it's not clear on
which basis you made it. It isn't so easy to judge whether a program of
reasonable complexity really works.

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: Tue, 26 Oct 2004 22:43:54 +0100
From: Ben Morrow <usenet@morrow.me.uk>
Subject: Re: HTTP Watcher
Message-Id: <q1t252-43c.ln1@osiris.mauzo.dyndns.org>


Quoth nospamhillmw@ram.lmtas.lmco.com:
> I was looking for some tricks to see HTTP Requests using my cgi scripts
> and stumbled across this:
> 
> http://www.httpwatch.com/moreinfo.htm
> 
> I downloaded it and it functions pretty good. I like the output it
> provides. I didn't like the price.
> 
> I was wondering it there were any cgi methods for proividing a
> comprehensive HTTP Request output or even non-comprehensive.

This Is Not A Perl Question. Please ask in a CGI group.

However, mozilla has an HTTP headers plugin.

Ben

-- 
I've seen things you people wouldn't believe: attack ships on fire off
the shoulder of Orion; I watched C-beams glitter in the dark near the
Tannhauser Gate. All these moments will be lost, in time, like tears in rain.
Time to die.                                                   ben@morrow.me.uk


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

Date: Wed, 27 Oct 2004 11:10:04 +0300
From: Stoill Barzakov <stoill@unixsol.org>
Subject: Re: Inter Program Communication ...
Message-Id: <2u93etF26k0ssU1@uni-berlin.de>

Tad McClellan wrote:


>    perldoc -q HTML
> 
>        How do I fetch an HTML file?
> 
>        How do I automate an HTML form submission?

I've already been through most of the *simple* docs .  What I need is to get
Exactly what the current user is Konquering and IF it is Invoice screen
(I've got some marks that will define this) to grab the page from It and
process It .  Bitmap will not do .  I need pure text or pure html .

-- 
      ___     
     (o o)     Still confused ...
--ooO-(_)-Ooo--------------------------------------------------


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

Date: Wed, 27 Oct 2004 11:15:42 +0300
From: Stoill Barzakov <stoill@unixsol.org>
Subject: Re: Inter Program Communication ...
Message-Id: <2u93peF26k0ssU2@uni-berlin.de>

Ben Morrow wrote:

> I doubt it... you would almost certainly need Perl XPCOM bindings, which
> AFAIK haven't been written yet :). I am sort-of semi-considering looking
> at it, but it looks to be *quite* a job.
> 
> At least in Moz/Firefox, you can set the 'printer' to be a pipe to any
> process (which will receive postscript): can you not write a (or use a
> pre-written) PS->Fiscal Printer converter there?
> 
> Ben
> 

This could work :-| but Mozilla haz a really mean Cyrillic support . It's
not even little WYSIWYG, an if I see cyrillic on screen when I print It's
all boxes instead of chars :-/ therefore It will just eat my time writting
a filter . 

 ... anyway, is there a way to get ONLY the url currently Konquered by user ? 
If I can fetch It from the browser, a conversion and print can be
arranged .

-- 
      ___     
     (o o)     Still confused ...
--ooO-(_)-Ooo--------------------------------------------------


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

Date: Wed, 27 Oct 2004 11:19:04 +0300
From: Stoill Barzakov <stoill@unixsol.org>
Subject: Re: Inter Program Communication ...
Message-Id: <2u93voF26k0ssU3@uni-berlin.de>

<posted & mailed>

Laura wrote:

> 
> why not have the html form submit to a perl cgi program which will in turn
> execute your 'already made perl code' with the appropriate data?

I CAN'T touch the server :( I can only work from billing/client side . And
sorry to say - never wrote good cgi script myself .

-- 
      ___     
     (o o)     Still confused ...
--ooO-(_)-Ooo--------------------------------------------------


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

Date: Wed, 27 Oct 2004 17:55:37 +1000
From: Sisyphus <kalinaubears@iinet.net.au>
Subject: Re: Linux vs. Windows: different behaviour [re rand()]
Message-Id: <417f55be$0$13748$5a62ac22@per-qv1-newsreader-01.iinet.net.au>

A. Sinan Unur wrote:

> 
> C:\Home> perl -MConfig -e"print qq{$Config{randbits}}
> 15
> 

Or:
perl -V:randbits

On my Linux (Mandrake-9.1) I have 48 random bits. I don't know if this 
accounts for the different behaviour. (I'm not real comfortable with 
'pack' either :-)

Cheers,
Rob

-- 
To reply by email u have to take out the u in kalinaubears.



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

Date: Wed, 27 Oct 2004 03:34:43 -0400
From: "daniel kaplan" <nospam@nospam.com>
Subject: Re: MAIL recommendation
Message-Id: <1098862523.432979@nntp.acecape.com>

"Scott Bryce" <sbryce@scottbryce.com> wrote in message
news:10nugt6isjlpcf5@corp.supernews.com...
> So try them out and reach your own conclusions. I would guess that most
> of the regulars here use text editors, not IDEs.
no need to try out six different ones, thanks to one or two people i was
able to cut my chase down to two...

> This isn't a community. It is a technical newsgroup. You still haven't
> read the posting guidelines, have you?
yes i have....let's try and understand them together, shall we?

"is a technical newsgroup intended to be used for discussion of Perl related
issues (except job postings), whether it be comments or questions."

although you said it isn't a community....i could argue that any place where
programmers discuss is a community, or i could just quote the guidlines:
"How to participate (post) in the clpmisc community"
funny, the guidlines say it is a community.  would this be like the FAQ?
It's in there so it must be right.

further backed up by:  "Asking for emailed answers:  Emailed answers benefit
one person. Posted answers benefit the entire community"

i think clpmisc is a community.  for the benefit of all levels of
programmers.  if it's just technical discussion, then all you would need is
the FAQ, cause it's all in there....and no postings...

"Scott Bryce" I LOVE YOU!...i read the guidelines before and missed
something so great.  scott, you may curse me out till the day i die....and i
will still love you...because of you i went back and was about to post one
more thing:

and finally a rule we ALL have not followed, i would say,
"But if you get upset, wait a while before writing your followup. I
recommend waiting at least 30 minutes. Count to ten after composing and
before posting when you are upset  After you have written your followup,
wait another 30 minutes before committing yourself by posting it. You cannot
take it back once it has been said. "

and i just realized who wrote the guideline...AUTHOR: Tad McClellan ...and
when i think of tad's posts, which i finally had to stop reading....wow...i
needed that laugh seriosuly...

so, to stop making debates, and light of...and even when the guidlelines
call it such...just being serious....any discussion of a subject, in this
case perl, makes it a community thing. if you dont wish it to be so, take
this offline, make it moderated, and let in only those you wish...and you
have your group.

my two cents




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

Date: 27 Oct 2004 07:30:30 GMT
From: Abigail <abigail@abigail.nl>
Subject: Re: Modify program to write just data to a text file.
Message-Id: <slrncnujkm.3ac.abigail@alexandra.abigail.nl>

Gunnar Hjalmarsson (noreply@gunnar.cc) wrote on MMMMLXXV September
MCMXCIII in <URL:news:2u8hu9F27vmlbU1@uni-berlin.de>:
-:  A. Sinan Unur wrote:
-: > Ahem ... so, you want us to violate the license for this code and do
-: > so in public?
-: > 
-: >>##########################################################
-: >># EZscripting.co.uk © 1999 - 2004 Copyright Darren Deans
-: > 
-: > ...
-: > 
-: >># The redistribution of modified versions of the scripts is
-: >># prohibited. 
-: > 
-: > ...
-:  
-:  Does that really mean that you are not allowed to modify the script for
-:  your own use, i.e. as long as you don't distribute the modified version
-:  to somebody else?

That doesn't matter. 

It certainly prohibits any reader from this script to add the features
the OP wants and return the modified script to the OP.



Abigail
-- 
A perl rose:  perl -e '@}-`-,-`-%-'


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

Date: 27 Oct 2004 09:32:03 +0200
From: Arndt Jonasson <do-not-use@invalid.net>
Subject: Re: open-perl-ide qustion
Message-Id: <yzdhdog4nws.fsf@invalid.net>


"daniel kaplan" <nospam@nospam.com> writes:
> >>He didn't respond to your post.  But you've obviously never really used
> >>Usenet, so you wouldn't know that.
> 
> no i repsonded, different thread, fell into it...
> 
> >>But you've obviously never really used
> > Usenet, so you wouldn't know that.
> 
> no, i've been around for quite a while...but your group is the first one to
> show me such a bitter group of people

You haven't read comp.lang.c, I assume.


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

Date: Wed, 27 Oct 2004 03:45:35 -0400
From: "daniel kaplan" <nospam@nospam.com>
Subject: Re: open-perl-ide qustion
Message-Id: <1098863175.265022@nntp.acecape.com>

"Arndt Jonasson" <do-not-use@invalid.net> wrote in message
news:yzdhdog4nws.fsf@invalid.net...
> > no, i've been around for quite a while...but your group is the first one
to
> > show me such a bitter group of people
>
> You haven't read comp.lang.c, I assume.

actaully i was told it was comp.lang.c++...the quote was:
"It doesn't even have to be a stupid question -- any question will do.  Make
sure your bunker is secure before you do."

so obviously my early post, must be Perl people, was an obviosu error....
i was about to ask, why can't there be a microsoft.public.*.perl group...but
that woudl be like asking for the department of redundancy dept.  sort
of....




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

Date: 27 Oct 2004 11:03:09 +0200
From: Arndt Jonasson <do-not-use@invalid.net>
Subject: Re: regex trick needed
Message-Id: <yzd8y9s4joy.fsf@invalid.net>


Tad McClellan <tadmc@augustmail.com> writes:
> Patrick Drouin <patrick.drouin@umontreal.ca> wrote:
> > Although the description of my problem was not very clear, you guys 
> > pointed me in the right direction. Here's what I used:
> > 
> > $rule =~ s/\$(\w+)/${$1}/g;
> 
> 
> You should put "use strict;" in all of your Perl programs!

Sorry for being dense, but what would "use strict" complain about in
the above statement? Putting it inside a plausible-looking function
gave me no warnings at all. Placing it as the only statement in a file
gave me

"Global symbol "$rule" requires explicit package name at ./foo.pl line 9 (#1)".

Is that what you meant?


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

Date: Tue, 26 Oct 2004 22:40:58 +0100
From: Ben Morrow <usenet@morrow.me.uk>
Subject: Re: regex trick needed
Message-Id: <ass252-43c.ln1@osiris.mauzo.dyndns.org>


Quoth patrick.drouin@umontreal.ca:
> Although the description of my problem was not very clear, you guys 
> pointed me in the right direction. Here's what I used:
> 
> $rule =~ s/\$(\w+)/${$1}/g;
> 
> This expans the variable used inside the rule I read from text files.

Gah, yuck!

Why haven't you got strictures on?

Use a hash of common patterns instead:

my %Patterns = (
    pnoun => qr/(?:Common\s+)Noun/,
);

my $rule = get_rule_from_file;

$rule =~ s/\$(\w+)/$Patterns{$1}/g;

And if you're going to be matching these a lot, it's probably worth
compiling them:

$rule = qr/$rule/;

Ben

-- 
   Razors pain you / Rivers are damp
   Acids stain you / And drugs cause cramp.                    [Dorothy Parker]
Guns aren't lawful / Nooses give
  Gas smells awful / You might as well live.                   ben@morrow.me.uk


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

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


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