[22745] in Perl-Users-Digest

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

Perl-Users Digest, Issue: 4966 Volume: 10

daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Fri May 9 18:06:04 2003

Date: Fri, 9 May 2003 15: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           Fri, 9 May 2003     Volume: 10 Number: 4966

Today's topics:
        2nd RFD: comp.databases.berkeley-db <philip@tildesoftware.com>
    Re: Bloody Java Proselytisers!!! <goedicke@goedsole.com>
    Re: Bloody Java Proselytisers!!! <p.lord@russet.org.uk>
    Re: Bloody Java Proselytisers!!! ctcgag@hotmail.com
        DBD for postgres? <bing-du@tamu.edu>
    Re: DBD for postgres? <wsegrave@mindspring.com>
    Re: DBD for postgres? <nobull@mail.com>
    Re: dont match this pattern <goedicke@goedsole.com>
    Re: dont match this pattern <skuo@mtwhitney.nsc.com>
    Re: dont match this pattern <nobull@mail.com>
    Re: dont match this pattern <skuo@mtwhitney.nsc.com>
    Re: Help: Need nifty idea for efficiently linking objec ctcgag@hotmail.com
    Re: ignore first line of input file <krahnj@acm.org>
    Re: Insecure $ENV{PATH} error under mod_perl <matthew@weierophinney.net>
    Re: Insecure $ENV{PATH} error under mod_perl (Michael Pohl)
    Re: pattern match A or B with Y or Z ctcgag@hotmail.com
    Re: pattern match A or B with Y or Z <usenet@dwall.fastmail.fm>
    Re: pattern match A or B with Y or Z <usenet@dwall.fastmail.fm>
        Question about News::NNTPClient Method (a bit long) <anthony@nospam.safferconsulting.com>
        regex patterns, match this and that in any order <user@someserver123abc.com>
    Re: regex patterns, match this and that in any order <nobull@mail.com>
    Re: regex patterns, match this and that in any order <user@someserver123abc.com>
    Re: Sorting book list <wksmith@optonline.net>
    Re: Total Utter Just Delivered Perl Newbie with a Pigna (Anno Siegel)
        Digest Administrivia (Last modified: 6 Apr 01) (Perl-Users-Digest Admin)

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

Date: Fri, 09 May 2003 19:04:37 +0000
From: Philip Greer <philip@tildesoftware.com>
Subject: 2nd RFD: comp.databases.berkeley-db
Message-Id: <1052507077.18420@isc.org>

                     REQUEST FOR DISCUSSION (RFD)
             unmoderated group comp.databases.berkeley-db

This is a formal Request For Discussion (RFD) for the creation of a
world-wide unmoderated Usenet newsgroup comp.databases.berkeley-db.
This is not a Call for Votes (CFV); you cannot vote at this time.
Procedural details are below.

CHANGES from previous RFD:

* The rationale has been re-written to more aptly state the reasons
  why the group is needed by the berkeley-db user community.
* The charter has been re-written to be more specific, less vague and
  overall better defines what this group is for, as well as defines
  what is allowed, and not allowed within it.
* The distribution groups have been updated to include those where it
  has been found to have had frequent past berkeley-db discussions.

Newsgroup line:
comp.databases.berkeley-db	Berkeley database and related topics.

RATIONALE: comp.databases.berkeley-db

There is not a specific Usenet location for discussions on berkeley
database management software (from this point forward I'll refer to as
just 'berkeley-db'). Discussion pertaining to the library occurs on
many other other Usenet forums. Often writings are specific to
berkeley-db itself and does not pertain to the subject matter of the
group the discussion falls within. Not only would a berkeley-db
specific forum provide a central location for todays frequent Usenet
users, it would also provide an on-line research tool for those
seeking on-line issue assistance with the library. Entities such as
Google will provide archives of group postings, and search tools for
those seeking answers to berkeley-db questions - drawing those on-line
that were not aware of the Usenet group (or of net news as a whole).

>From the "Berkeley DB Reference Guide: Introduction": '[berkeley-db]
runs under almost all UNIX and Linux variants, Windows, and a number
of embedded real-time operating systems. It runs on both 32-bit and
64-bit systems. It has been deployed on high-end Internet servers,
desktop machines, and on palmtop computers, set-top boxes, in network
switches, and elsewhere.' As well, berkeley-db has been a tool
available to the programming community for over ten years and
is used on a global scale with over 200 million installations. The
need for an on-line, central location for community discussions has
been long standing. Usenet is the best tool to fulfill this need and
allows addressing this need on a global scale.

CHARTER: comp.databases.berkeley-db

The newsgroup comp.databases.berkeley-db is a news forum devoted to
the discussion of the berkeley database management library. Discussion
entails, but is not limited to: its usage in all programming languages
that can utilize it, bugs, patches, tricks, techniques, support,
announcements; all in a free and open atmosphere.

All postings should be in ordinary text format only. Postings of
binaries (or encoding thereof) is highly discouraged. Cross-posting of
articles irrelevant to the berkeley database library is also
discouraged. The berkeley-db newsgroup is not moderated. Therefore it
is up to the global user base to police its usage.

END CHARTER.

PROCEDURE:

This is a request for discussion, not a call for votes.  In this phase
of the process, any potential problems with the proposed newsgroups
should be raised and resolved.  The discussion period will continue
for a minimum of 21 days (starting from when the first RFD for this
proposal is posted to news.announce.newgroups), after which a Call For
Votes (CFV) may be posted by a neutral vote taker if the discussion
warrants it.  Please do not attempt to vote until this happens.

All discussion of this proposal should be posted to news.groups.

This RFD attempts to comply fully with the Usenet newsgroup creation
guidelines outlined in "How to Create a New Usenet Newsgroup" and "How
to Format and Submit a New Group Proposal".  Please refer to these
documents (available in news.announce.newgroups) if you have any
questions about the process.

DISTRIBUTION:

This RFD has been posted to the following newsgroups:

news.groups, news.announce.newgroups, comp.databases, comp.lang.python,
comp.lang.perl.misc

Pointers will be posted to the following newsgroups:

comp.lang.perl.modules, comp.mail.sendmail, comp.mail.imap,
alt.perl, comp.unix.programmer, comp.lang.java.databases

Pointers will also be sent to the following gatewayed mailing lists:

mailing.database.mysql, mailing.postfix.users, mailing.freebsd.questions

Proponent: Philip Greer <philip@tildesoftware.com>
Proponent: Dave Segleau <dave@sleepycat.com>


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

Date: Fri, 09 May 2003 18:52:42 GMT
From: William Goedicke <goedicke@goedsole.com>
Subject: Re: Bloody Java Proselytisers!!!
Message-Id: <m3d6isuf4g.fsf@mail.goedsole.com>

Dear Y'all - 

Charlton Wilbur <cwilbur@mithril.chromatico.net> writes:

> William Goedicke <goedicke@goedsole.com> writes:
> 
> > Of course, projects can be completed with mediocre programmers in any
> > language.  What characteristic does java have that makes it better at
> > this than other languages?
> 
> Bondage and discipline syntax: there's often only one way to do it,

Good point.

> An enormous standard library

This doesn't strike me as a differentiating point from perl.

> Consistent support from Sun

What?  Are you being sarcastic?  And what about the myriad other JDEs,
JVMs...

> Object orientation, corporate mindset, and mindshare, principally.

Come on, object orientation doesn't preclude spaghetti logic it's
simply expressed in a chaotic object hierarchy instead of convoluted
control flow.

> > > you can get the job done with mediocre programmers, which is not the
> > > case for a lot of other languages.
> > 
> > Please name one and explain why.
> 
> Perl.  Because there's more than one way to do it, you need to have a
> project manager with an extremely firm hand to keep the project
> under control and maintainable...

Can't the mediocre programmer still play havoc by not doing adequate
file and socket error handling or input data validation?

Generically isn't the existance of so many buggy and poor performing
programs written in java an empirical proof that it doesn't preclude
bad programming practices?

> If there are multiple right ways, this isn't a
> problem; in a case where some ways are better than others, it is a
> huge problem.

Another excellent point.

> My point was not to argue language advocacy, but to point out the
> reasons that Java is so popular.

And and enlightening discussion it's proving to be.

     Yours -      Billy

============================================================
     William Goedicke     goedicke@goedsole.com            
                          http://www.goedsole.com:8080      
============================================================

          Lest we forget:

Whan labling cabling use a unique identifier of the 
connection at the far end.

		- William Goedicke


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

Date: 09 May 2003 19:01:45 +0100
From: Phillip Lord <p.lord@russet.org.uk>
Subject: Re: Bloody Java Proselytisers!!!
Message-Id: <vfhe84knhy.fsf@rpc71.cs.man.ac.uk>



>>>>> "Charlton" == Charlton Wilbur <cwilbur@mithril.chromatico.net> writes:

  Charlton> My point was not to argue language advocacy,
  Charlton> but to point out the reasons that Java is so popular.  It
  Charlton> doesn't give the good programmer anything that he can't
  Charlton> find in Perl or C++ *spit* or C or Ruby or Python, but it
  Charlton> does have real benefits for mediocre programmers.


As far as I could tell from your post, many, or most, of the benefits
would also cover talented programmers as well surely?

Phil


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

Date: 09 May 2003 19:10:39 GMT
From: ctcgag@hotmail.com
Subject: Re: Bloody Java Proselytisers!!!
Message-Id: <20030509151039.033$nF@newsreader.com>

Charlton Wilbur <cwilbur@mithril.chromatico.net> wrote:

> A dominant approach to design: I have yet to encounter a Java
> programmer who has not at least heard of Model-View-Controller.

Neither have I.  But I have met several who can't identify a Model,
a View, or a Controller if it jumps up and bites them.  They seem
to think of MVC as a talisman to be bandied rather than a concept to
be implemented.

I think the private variables in Java are a big defense against
mediocre programmers (and a big offense to good programmers.)

I always liked Perl's philosophy that you can muck with the internals
if you want, but you shouldn't do it without very good reason.  Alas,
mediocre programmers can't tell very good reasons from not good at all
reasons.

Xho

-- 
-------------------- http://NewsReader.Com/ --------------------
Usenet Newsgroup Service              New Rate! $9.95/Month 50GB


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

Date: Fri, 09 May 2003 14:56:39 -0500
From: Bing Du Test <bing-du@tamu.edu>
Subject: DBD for postgres?
Message-Id: <3EBC07F7.46FDF2BD@tamu.edu>

I don't see one for postgres on
http://search.cpan.org/modlist/Database_Interfaces/DBD.

Anybody know how I should access postgres database from within Perl?

Thanks in advance for any ideas.

Bing



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

Date: Fri, 9 May 2003 15:22:58 -0500
From: "William Alexander Segraves" <wsegrave@mindspring.com>
Subject: Re: DBD for postgres?
Message-Id: <b9h2sb$7uo$1@slb4.atl.mindspring.net>

"Bing Du Test" <bing-du@tamu.edu> wrote in message
news:3EBC07F7.46FDF2BD@tamu.edu...
> I don't see one for postgres on
> http://search.cpan.org/modlist/Database_Interfaces/DBD.

DBD::Pg

Bill Segraves




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

Date: 09 May 2003 21:14:43 +0100
From: Brian McCauley <nobull@mail.com>
Subject: Re: DBD for postgres?
Message-Id: <u9ptmrubbg.fsf@wcl-l.bham.ac.uk>

Bing Du Test <bing-du@tamu.edu> writes:

> I don't see one for postgres on
> http://search.cpan.org/modlist/Database_Interfaces/DBD.

Widen your search.

> Anybody know how I should access postgres database from within Perl?

There is a DBD for Postgress.

Can't recall where I got it... Hmmm now where did a leave that seach
engine...?  Oh yes I remember Google.com... Let me see...  "DBD
Postgres"... Oh so it was on CPAN after all!

The morals of our story:

1) CPAN indexes are not great.

2) Search engines are often a quicker wa to get answers than posting to
newsgroups.

-- 
     \\   ( )
  .  _\\__[oo
 .__/  \\ /\@
 .  l___\\
  # ll  l\\
 ###LL  LL\\


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

Date: Fri, 09 May 2003 18:55:31 GMT
From: William Goedicke <goedicke@goedsole.com>
Subject: Re: dont match this pattern
Message-Id: <m38ytguezr.fsf@mail.goedsole.com>

Dear Stinky - 

stinkbomb <user@someserver123abc.com> writes:

> I'm able to !match a single character, but what about a longer string?
> 
> $str =~ s/(match this)(exclude this)(match this)/something/;

$str !~ s/(match this)(exclude this)(match this)/something/;

O'Reilly's "Perl Pocket Reference" is a handy little document.

     Yours -      Billy

============================================================
     William Goedicke     goedicke@goedsole.com            
                          http://www.goedsole.com:8080      
============================================================

          Lest we forget:

Never ascribe to malevolence that which can be explained by
incompetence.

	- Glenn Pierce


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

Date: Fri, 9 May 2003 12:34:43 -0700
From: Steven Kuo <skuo@mtwhitney.nsc.com>
Subject: Re: dont match this pattern
Message-Id: <Pine.GSO.4.21.0305091232400.9840-100000@mtwhitney.nsc.com>

On Fri, 9 May 2003, stinkbomb wrote:

> I'm able to !match a single character, but what about a longer string?
> 
> /[^x]/ in 
> $str =~ s/[^x]/something/g;
> will match a string that's not x.
> I cant seem to do that with a string. 
> 
> I want to be able to incorporate this into a more complex regex
> like:
> 
> $str =~ s/(match this)(exclude this)(match this)/something/;
> 


I believe you're looking for the negative look-ahead assertion.
See:

perldoc perlre


Something like this?


#!/usr/local/bin/perl

while (<DATA>) {
    s/dentist(?! exception) endorsement/chew gum/i;
    print;
}

# Four out of five dentists agree:


__DATA__
Dentist endorsement
denTist endorseMent
denTIST exception
dentist endorsement
DENTIST ENDORSEMENT


-- 
Hope this helps,
Steven



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

Date: 09 May 2003 20:23:45 +0100
From: Brian McCauley <nobull@mail.com>
Subject: Re: dont match this pattern
Message-Id: <u97k8zvs8u.fsf@wcl-l.bham.ac.uk>

stinkbomb <user@someserver123abc.com> writes:

> I'm able to !match a single character, but what about a longer string?
> 
> /[^x]/ in 
> $str =~ s/[^x]/something/g;
> will match a string that's not x.

No it will match a single character that is not 'x' so it'll match 'z'
but not 'banana'.  The patten /[^x]/ will, of course, match each
character of 'banana' but it will not match the whole string.

> I cant seem to do that with a string. 

The concept does not easily extend to strings.

There is, however, a negative look-ahead assertion and most things you
could want to do could be achieved with that.

> I want to be able to incorporate this into a more complex regex
> like:
> 
> $str =~ s/(match this)(exclude this)(match this)/something/;

What semantics would you like that to have?  I'll guess you want match
/(match this)(.*)(match this)/ except where $2 would match 
/exclude this/.

What I'd like to know, is who decided that (?{...}) assrertions should
always succede?  Surely the natural thing would be for them to succede
only if they return true!

If this were the case you could say:

 s/(match this)(.*)(match this)(?{$2!~m{exclude this}})/something/;

Unfortunately it is not the case, you have to use the (?{...}) as the
condition in a (?(...)...|...) an it gets uglier still:

s/(match this)(.*)(match this)(?(?{$2!~m{exclude this}})|(?!))/something/;

The (?!) is an always false assertion.

The empty pattern is always matched.

Therefore (?(?{expression})|(?!)) is a zero-width assertion that
succedes iff expression is true.

-- 
     \\   ( )
  .  _\\__[oo
 .__/  \\ /\@
 .  l___\\
  # ll  l\\
 ###LL  LL\\


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

Date: Fri, 9 May 2003 12:48:07 -0700
From: Steven Kuo <skuo@mtwhitney.nsc.com>
Subject: Re: dont match this pattern
Message-Id: <Pine.GSO.4.21.0305091246480.9840-100000@mtwhitney.nsc.com>

On Fri, 9 May 2003, Steven Kuo wrote:

> On Fri, 9 May 2003, stinkbomb wrote:
> 
> > I'm able to !match a single character, but what about a longer string?
> > 
> > /[^x]/ in 
> > $str =~ s/[^x]/something/g;
> > will match a string that's not x.
> > I cant seem to do that with a string. 
> > 
> > I want to be able to incorporate this into a more complex regex
> > like:
> > 
> > $str =~ s/(match this)(exclude this)(match this)/something/;
> > 
> 
> 
> I believe you're looking for the negative look-ahead assertion.
> See:
> 
> perldoc perlre
> 
> 
> Something like this?
> 
> 
> #!/usr/local/bin/perl
> 
> while (<DATA>) {
>     s/dentist(?! exception) endorsement/chew gum/i;
>     print;
> }
> 
> # Four out of five dentists agree:
> 
> 
> __DATA__
> Dentist endorsement
> denTist endorseMent
> denTIST exception
> dentist endorsement
> DENTIST ENDORSEMENT
> 
 


Sorry, that last example was not particularly illustrative.

Try:

while (<DATA>) {
    s/dentist(?! exception endorsement).*?endorsement/chew gum/i;
    print;
}

# Four out of five dentists agree:


__DATA__
Dentist endorsement
denTist endorseMent
denTIST exception endorsement
dentist endorsement
DENTIST ENDORSEMENT

-- 
Regards,
Steven



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

Date: 09 May 2003 19:22:32 GMT
From: ctcgag@hotmail.com
Subject: Re: Help: Need nifty idea for efficiently linking objects together and making comparisons,,,
Message-Id: <20030509152232.241$Nb@newsreader.com>

email_entropy123@yahoo.com (entropy123) wrote:
> Hey all,
>
> I'm working on molecules and am trying to come up with a connectivity
> routine.
>
> For example, starting with the knowledge of the bonds each atom has

In what format?  Connectivity matrix?  Adjacency lists?

> I
> need to figure out if there is a ring structure. So, for a six carbon
> molecule is it something like C-C-C-C-C-C or a ring structure.

There are more possibilities than that.


> My idea is to take the bonding information and - starting with an
> individual atom - create an array.

An array of what?

> If the array ever has the starting
> atom as an element then I know I have a ring..

> Does perl have any routines which might make this an easier job? :)

Well, there's dayperl, at least.

> All those if/then statements make my head spin....

I can envision implementing this with only a couple ifs (and no thens)

Xho

-- 
-------------------- http://NewsReader.Com/ --------------------
Usenet Newsgroup Service              New Rate! $9.95/Month 50GB


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

Date: Fri, 09 May 2003 18:08:07 GMT
From: "John W. Krahn" <krahnj@acm.org>
Subject: Re: ignore first line of input file
Message-Id: <3EBBEE63.D998728@acm.org>

kderaedt wrote:
> 
>     This is probably a dummy question.  What is the easiest way to ignore
> the first line of a input file.

Probably the easiest way is to test the input line number variable.

> Used code:
> # Global configuration parameters
> my $INPUTFILE = "wsp.out";
> my $OUTPUTFILE = "wsp.new";
> my $MSISDN_START = 2;
> 
> # File handeling
> open (IN, "< $INPUTFILE") or die "Couldn't open $INPUTFILE for reading:
> $!\n";
> open (OUT, "> $OUTPUTFILE") or die "Couldn't open $OUTPUTFILE for writing:
> $!\n";
> 
> while(<IN>) {

      next if $. == 1;

> }


John
-- 
use Perl;
program
fulfillment


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

Date: Fri, 09 May 2003 18:08:20 GMT
From: Matthew Weier O'Phinney <matthew@weierophinney.net>
Subject: Re: Insecure $ENV{PATH} error under mod_perl
Message-Id: <slrnbbnrkl.12j.matthew@kavalier.weierophinney.net>

* Michael Pohl <google@newtopia.com>:
> I'm apparently misinterpreting something from perldoc perlsec.  Under
> mod_perl, with PerlTaintCheck On server-wide, the following code in a
> use()'d module:
> 
> $ENV{PATH} = '';
> $rc = `/usr/local/ghostscript/bin/gs -dNODISPLAY -sNOPAUSE $code_file
         ^^^^^^^^^^^^^^^^^^^^^^^^^^

> -c quit`;
> 
> throws the following error:
> 
> [Fri May  9 12:58:52 2003] [error] Insecure $ENV{PATH} while running
> with -T switch at /home/michaelp/dev/cp/cgi-bin/eps.pm line 2077.
> 
> I also have PATH set in my Apache conf:
> 
> PerlSetEnv PATH "/bin:/usr/bin:/usr/local/bin"
> PerlPassEnv PATH

Add '/usr/local/ghostscript/bin' to your PATH (either in your script or
in your Apache conf), and you should be good.

-- 
Matthew Weier O'Phinney
matthew@weierophinney.net
http://matthew.weierophinney.net


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

Date: 9 May 2003 14:06:21 -0700
From: google@newtopia.com (Michael Pohl)
Subject: Re: Insecure $ENV{PATH} error under mod_perl
Message-Id: <da4ea47.0305091306.42285722@posting.google.com>

Matthew Weier O'Phinney <matthew@weierophinney.net> wrote in message news:<slrnbbnrkl.12j.matthew@kavalier.weierophinney.net>...
> 
> Add '/usr/local/ghostscript/bin' to your PATH (either in your script or
> in your Apache conf), and you should be good.

Thanks Matthew, I had tried that (and other variations) for the
$ENV{PATH} assignment directly preceding the backtick call, but I had
failed to modify the PATH in the Apache config.  The former did not
work, but the latter did.

So apparently under mod_perl $ENV{PATH} assignments in the code are
ignored in favor of the PerlSetEnv PATH value in the Apache conf.  I
had not realized that.

thanks again,

michael


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

Date: 09 May 2003 18:11:26 GMT
From: ctcgag@hotmail.com
Subject: Re: pattern match A or B with Y or Z
Message-Id: <20030509141126.427$wg@newsreader.com>

"David K. Wall" <usenet@dwall.fastmail.fm> wrote:
> Gunnar Hjalmarsson <noreply@gunnar.cc> wrote:
>
> > stinkbomb wrote:
> >> how would you find pattern A or B and replace it with Y or Z?
> >> If we find A, we replace it with Y.
> >> If we find B, we replace it with Z.
> >>
> >> I *think* I've seen this before but don't remember.
> >>
> >> I can imagine:
> >> $var =~ s/(a)|(b)/a|b/g;
> >> but that does not work like I want it to.
> >
> >      $var =~ s/(a)|b/$1 ? 'x' : 'y'/eg;
>
> Not that there's anything particularly wrong with that, but in my
> opinion it would be easier to read if it were in two lines of code.
>
>     $var =~ s/A/Y/g;
>     $var =~ s/B/Z/g;
>
> Same effect, but you don't have to trace the logic.

But it isn't (necessarily) the same effect.  Using the two lines of code
might give wrong answers, as it allows overlapping substitutions.  (The
Data::Table module had a bug due to this at one time.)


> Also, if pattern A is logically false, you won't get what you want.
> For example,
>
>     my $var = '0011';
>     $var =~ s/(0)|1/$1 ? 'Y' : 'Z'/eg;
>     print $var;
>
> will print 'ZZZZ' instead of 'YYZZ'.

How about $var =~ s/(0)|1/defined $1 ? 'Y' : 'Z'/eg  ?

Xho

-- 
-------------------- http://NewsReader.Com/ --------------------
Usenet Newsgroup Service              New Rate! $9.95/Month 50GB


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

Date: Fri, 09 May 2003 18:41:55 -0000
From: "David K. Wall" <usenet@dwall.fastmail.fm>
Subject: Re: pattern match A or B with Y or Z
Message-Id: <Xns9376958613F5Bdkwwashere@216.168.3.30>

stinkbomb <user@someserver123abc.com> wrote:

> "David K. Wall" wrote:
>> 
>>     $var =~ s/A/Y/g;
>>     $var =~ s/B/Z/g;
>> 
> in your example,
> 
> if the pattern is:
> $var="<>";
> 
> and I decided to:
> $var =~ s/</<font color="#ff0000">&lt;<\/font>/g;
> $var =~ s/>/<font color="#ff0000">&gt;<\/font>/g;
> 
> we would have a problem.
> see why I have to do one line in one shot?

Yeah, although I might argue with you about using font tags at all 
instead of CSS.  But that's a discussion for another newsgroup, not 
clpm.  :-)

You *could* do it like this

    for ($var) {
        s/</&lt;/g;
        s/>/&gt;/g;
        s|&lt;|<font color="#ff0000">&lt;</font>|g;
        s|&gt;|<font color="#ff0000">&gt;</font>|g;
    }

but that's arguably a horribly ugly way to do it.  :-)

I'd probably modify the single statement a bit to fit my preferences:

    $var =~ s!
        ([<>])
        !
        $1 eq '<' ? 
            '<font color="#ff0000">&lt;</font>' : 
            '<font color="#ff0000">&gt;</font>'
        !egx;


YMMV, though. 


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

Date: Fri, 09 May 2003 18:44:06 -0000
From: "David K. Wall" <usenet@dwall.fastmail.fm>
Subject: Re: pattern match A or B with Y or Z
Message-Id: <Xns937695E433E5Ddkwwashere@216.168.3.30>

 <ctcgag@hotmail.com> wrote:

> "David K. Wall" <usenet@dwall.fastmail.fm> wrote:
>> Gunnar Hjalmarsson <noreply@gunnar.cc> wrote:
>>
>> >
>> >      $var =~ s/(a)|b/$1 ? 'x' : 'y'/eg;
>>
>>     $var =~ s/A/Y/g;
>>     $var =~ s/B/Z/g;
>>
>> Same effect, but you don't have to trace the logic.
> 
> But it isn't (necessarily) the same effect.  Using the two lines
> of code might give wrong answers, as it allows overlapping
> substitutions.

Obviously I didn't think of that. :-)


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

Date: Fri, 9 May 2003 13:25:22 -0500
From: "Anthony Saffer" <anthony@nospam.safferconsulting.com>
Subject: Question about News::NNTPClient Method (a bit long)
Message-Id: <3ebbf2e7_1@nntp2.nac.net>

Hello Everyone,

I'm writing a program that will search through all newsgroups on a given
server looking for a particular person. I've got this working for the most
part but I am stuck on the ->next() method as it's impelemted in the
NNTPClient module. Here's my situation:

First, I get my first article and last article from a given newsgroup. These
are assigned to the variables $first_article and $last_article respectively.
Then, I set the value of $current_article = $first_article. I then enter a
while loop and search through every article. The declaration of the while
loop is as such:

while($current_article <= $last_article){}

Between my brackets I search and parse each articles header. When I reach
the end of the header I execute the ->next method as such:

$current_article = $conn->next();

It all works fine. The problem is when there IS no "next" article (for
example groups with no articles). I get an error telling me there is no next
article but the program continues to try to get the next article and thereby
enters an infinate loop. Now, I know that the ->next method returns false if
there is no article ID returned. But how can I structure my while statement
so that it breaks out when $current_article = $conn->next() returns false?
Is there a 'break' command in Perl? If so I can't find any doc on it. Can
anyone offer help?

Thanks!
Anthony





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

Date: Fri, 09 May 2003 15:04:47 -0400
From: stinkbomb <user@someserver123abc.com>
Subject: regex patterns, match this and that in any order
Message-Id: <3EBBFBCF.88E62DC4@someserver123abc.com>

how would I match two patterns in any order?

a variable equals to this:
$var=<<HERE;
<!--//textColor=red//-->
<!--//textSize=3//-->
<!--//bold=checked//--><!--//alignCenter=checked//--><!--//hide=checked//-->
<!--//message=testing<br>hello world<br>goodby world<br>//-->
HERE

$var =~ s/(!--\/\/)(\=|[^<]*)(\/\/--)/$1<font
color="#0000ff">$2<\/font>$3/g;
this tries change font color of name=value pairs to perhaps blue (each
line can contain one or many of those)
it must be sandwiched between this <!--//  and  that //-->
the variable can contain < or > between this <!--//  and  that //-->
the variable must contain = between this <!--//  and  that //-->


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

Date: 09 May 2003 20:36:09 +0100
From: Brian McCauley <nobull@mail.com>
Subject: Re: regex patterns, match this and that in any order
Message-Id: <u93cjnvro6.fsf@wcl-l.bham.ac.uk>

stinkbomb <user@someserver123abc.com> writes:

> how would I match two patterns in any order?

/pat1/ && /pat2/

> a variable equals to this:
> $var=<<HERE;
> <!--//textColor=red//-->
> <!--//textSize=3//-->
> <!--//bold=checked//--><!--//alignCenter=checked//--><!--//hide=checked//-->
> <!--//message=testing<br>hello world<br>goodby world<br>//-->
> HERE
> 
> $var =~ s/(!--\/\/)(\=|[^<]*)(\/\/--)/$1<font color="#0000ff">$2<\/font>$3/g;
> this tries change font color of name=value pairs to perhaps blue (each
> line can contain one or many of those)
> it must be sandwiched between this <!--//  and  that //-->
> the variable can contain < or > between this <!--//  and  that //-->
> the variable must contain = between this <!--//  and  that //-->

You appear to have changed the subject.  This question is unrelated to
the first.

/<!--\/\/(.*?=.*?)\/\/-->/

I belive this does what you said.

I doubt it actually does what you want.

You probably want to use a proper Parser.

-- 
     \\   ( )
  .  _\\__[oo
 .__/  \\ /\@
 .  l___\\
  # ll  l\\
 ###LL  LL\\


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

Date: Fri, 09 May 2003 16:45:46 -0400
From: stinkbomb <user@someserver123abc.com>
Subject: Re: regex patterns, match this and that in any order
Message-Id: <3EBC137A.247F5583@someserver123abc.com>



Brian McCauley wrote:
> 
 ....
> 
> /<!--\/\/(.*?=.*?)\/\/-->/
> 
> I belive this does what you said.
> 
> I doubt it actually does what you want.


lets change that example, i'm having delusions and a headache
this is simpler to look at:

$var="(a)(b)(c=d)(e$%f)";
$var=~ s/\((.*?=.*?)\)/\[$1\]/g; #this doesn't work
print $var;

get name=value pair that's inside the ()
put it inside < and > so that we have (<c=d>)
(match '(' )     (  match '=' but not '(' or ')' )       ( match ')' )
and do this for every (...)
and we have four (...)


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

Date: Fri, 09 May 2003 20:56:20 GMT
From: "Bill Smith" <wksmith@optonline.net>
Subject: Re: Sorting book list
Message-Id: <UBUua.34915$AG6.8625399@news4.srv.hcvlny.cv.net>


"Gopi Sundaram" <gopalan@cs.sc.edu> wrote in message
news:Pine.GSO.4.55.0305090005300.6075@rigel...
> On Fri, 9 May 2003, Bill Smith wrote:
>
> > As Jay pointed out, the desired order should be fully specified
before
> > designing the sort.  In this case it may make sense to let the
simple
> > solution dictate the spec.
>
> True. I hadn't even thought of the scenario Jay described. So I heeded
> your advice, and here's what my sort looks like (leaving out the parts
> to massage the data):
>
>     my $by_author = $author1 cmp $author2;
>
>     my $by_series = 0;
>
>     if ($series1 eq $series2) {
>         $by_series = $series_ord1 <=> $series_ord2;
>     }
>     else {
>         $by_series = $series1 cmp $series2;
>     }
>
>     return $by_author || $by_series;

You did not show the code for spliting the series field into name and
ordinal.  Remember that defaults are needed for both to avoid
uninitialized variable errors.

I believe that your new sort is equivalent to the last one that I
proposed.  Mine would be slightly faster because it is not necessary to
split the series field and because the series cmp is made only when the
authors are the same.  You probably find your own code clearer.  Go for
it!

BTW, when I tried to access your raw data, I received a rude message
about permission denied.

Good Luck
Bill










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

Date: 9 May 2003 18:16:40 GMT
From: anno4000@lublin.zrz.tu-berlin.de (Anno Siegel)
Subject: Re: Total Utter Just Delivered Perl Newbie with a Pignant Question
Message-Id: <b9gra8$e3p$1@mamenchi.zrz.TU-Berlin.DE>

Rod <roderick991@yahoo.com> wrote in comp.lang.perl.misc:
> 
> Anno Siegel <anno4000@lublin.zrz.tu-berlin.de> wrote in message

[big snip]

> :     my $num =
> :         ( 'no arguments',  'one argument', 'two arguments')[ scalar
> @ARGV];
> :     print defined $num ? "$num @ARGV\n" : "bugger\n";
> :
> so 'my' is similar in that it is like arguments to main in C ???

Similar to what?  No, my() doesn't declare arguments to the main program.

You'd better start at the beginning.  Get a good tutorial and start reading
instead of jumping in in the middle.

Anno


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

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.  

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


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