[18249] in Perl-Users-Digest

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

Perl-Users Digest, Issue: 417 Volume: 10

daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Mon Mar 5 09:05:38 2001

Date: Mon, 5 Mar 2001 06:05:15 -0800 (PST)
From: Perl-Users Digest <Perl-Users-Request@ruby.OCE.ORST.EDU>
To: Perl-Users@ruby.OCE.ORST.EDU (Perl-Users Digest)
Message-Id: <983801115-v10-i417@ruby.oce.orst.edu>
Content-Type: text

Perl-Users Digest           Mon, 5 Mar 2001     Volume: 10 Number: 417

Today's topics:
    Re: #ifndef ???? <bruno.montagnac@renault.com>
    Re: #ifndef ???? (Anno Siegel)
        acronym <broertje@pandora.be>
    Re: acronym <aulbert@aei-potsdam.mpg.de>
    Re: acronym <rick.miller@cwusa.com>
    Re: acronym <bart.lateur@skynet.be>
    Re: check open files ? <gellyfish@gellyfish.com>
    Re: Convert dates in format "3/1/2001" to dd-Month-yy (Peter J. Acklam)
    Re: flock and close   with  empty read strangeness <bart.lateur@skynet.be>
    Re: flock and close   with  empty read strangeness (Martien Verbruggen)
    Re: flock and close   with  empty read strangeness (Ilya Zakharevich)
    Re: flock and close   with  empty read strangeness (Kevin Reid)
        Graphs in perl <rtavares@tec.dsr.telecom.pt>
    Re: Graphs in perl <gellyfish@gellyfish.com>
        How to list installed modules (MD5) <borge.haga@nextra.spamno.com.invalid>
    Re: How to list installed modules (MD5) (Anno Siegel)
    Re: How to list installed modules (MD5) <sam@illuminated.co.uk>
        https redirect in perl? <howard_morgenstern@hp.com>
    Re: Is Perl right for me? <bruno.montagnac@renault.com>
    Re: Magic Marker <Anonymous_Account>" <remailer@anon.xg.nu>
        non greedy regex <ducateg@info.bt.co.uk>
    Re: non greedy regex <bart.lateur@skynet.be>
    Re: non greedy regex <ducateg@info.bt.co.uk>
        Objects in Perl <jon_rew@learn-it.demon.co.uk>
    Re: Objects in Perl <gellyfish@gellyfish.com>
    Re: Objects in Perl (Rafael Garcia-Suarez)
    Re: perl-ize and optimize <krahnj@acm.org>
    Re: perl-ize and optimize <bart.lateur@skynet.be>
        perlcc on modules <aulbert@aei-potsdam.mpg.de>
    Re: Problem with #! line using RedHat 7 mwhyte@pmds.com
        Digest Administrivia (Last modified: 16 Sep 99) (Perl-Users-Digest Admin)

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

Date: Mon, 05 Mar 2001 14:13:41 +0100
From: Montagnac Bruno <bruno.montagnac@renault.com>
Subject: Re: #ifndef ????
Message-Id: <3AA39104.A399D43E@renault.com>

paul wrote:

> Does Perl have anything like the #ifndef from C++? I want to be sure
> that once a certain very large hash is never loaded more than once. I
> want to load it once and make a reference available to it globally. I
> seemed to be having a problem with it being loaded more than once which
> was really impacting preformance. Thanks
>
> Paul

u can try to use defined(@array)...
see perldoc -f defined for more detailed help

my 2 cents

--
 //\  Bruno Montagnac         ____/Alias\____     /et c'est bien\_
// \\ Technocentre RENAULT   /le Bib (A.O.C.)\    \ suffisant.../ |
\\ // DTSI/Service:18741    /le seul, l'unique\                   |
 \//  Les opinions exprimees dans ce post n'engagent que moi... <-+





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

Date: 5 Mar 2001 13:40:12 GMT
From: anno4000@lublin.zrz.tu-berlin.de (Anno Siegel)
Subject: Re: #ifndef ????
Message-Id: <9804vs$9j8$2@mamenchi.zrz.TU-Berlin.DE>

According to Montagnac Bruno  <bruno.montagnac@renault.com>:
> paul wrote:
> 
> > Does Perl have anything like the #ifndef from C++? I want to be sure
> > that once a certain very large hash is never loaded more than once. I
> > want to load it once and make a reference available to it globally. I
> > seemed to be having a problem with it being loaded more than once which
> > was really impacting preformance. Thanks
> >
> > Paul
> 
> u can try to use defined(@array)...
> see perldoc -f defined for more detailed help

When you looked last at the documentation of defined(), did you see
the following?

               Use of `defined' on aggregates (hashes and arrays)
               is deprecated.  It used to report whether memory
               for that aggregate has ever been allocated.  This
               behavior may disappear in future versions of Perl.
               You should instead use a simple test for size:
> my 2 cents

Inflation...

Anno


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

Date: Mon, 05 Mar 2001 10:21:05 GMT
From: "Tim Fooy" <broertje@pandora.be>
Subject: acronym
Message-Id: <lMJo6.63176$Ut1.5340549@afrodite.telenet-ops.be>

I know this has nothing to do with Perl, but since I can't find a newsgroup
on PHP I hope I can post the question here:  can anyone tell me what the
letters of PHP stand for?  I looked everywhere on the official php site but
couldn't find it.

Thanks for any suggestions!

Tim




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

Date: Mon, 05 Mar 2001 11:27:27 +0100
From: Carsten Aulbert <aulbert@aei-potsdam.mpg.de>
Subject: Re: acronym
Message-Id: <3AA36A0F.AD480D88@aei-potsdam.mpg.de>

Tim Fooy wrote:
> 
> I know this has nothing to do with Perl, but since I can't find a newsgroup
> on PHP I hope I can post the question here:

indeed
>   can anyone tell me what the
> letters of PHP stand for?  I looked everywhere on the official php site but
> couldn't find it.

if you'd had a closer look at the manual, you might have found it:
 ...named PHP/FI Version 2. The FI came from another package Rasmus had
written which
interpreted html form data. He combined the Personal Home Page tools
scripts with the Form Interpreter ...
(from : http://www.php.net/manual/en/html/intro-history.html)

Carsten


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

Date: Mon, 05 Mar 2001 10:34:54 GMT
From: Rick Miller <rick.miller@cwusa.com>
Subject: Re: acronym
Message-Id: <3AA36B3D.76F4B0CA@cwusa.com>

Tim Fooy wrote:
> 
> I know this has nothing to do with Perl, but since I can't find a newsgroup
> on PHP I hope I can post the question here:  can anyone tell me what the
> letters of PHP stand for?  I looked everywhere on the official php site but
> couldn't find it.

Check these links:

http://lists.omnipotent.net/php3/199804/msg01015.html
http://www.acronymfinder.com/af-query.asp?acronym=PHP&string=exact


Looks like noone can decide on one single acronym

--Rick


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

Date: Mon, 05 Mar 2001 10:58:24 GMT
From: Bart Lateur <bart.lateur@skynet.be>
Subject: Re: acronym
Message-Id: <b2s6atgl8s03icbvg5r2dg3tvlgvov10ur@4ax.com>

Tim Fooy wrote:

>I know this has nothing to do with Perl, but since I can't find a newsgroup
>on PHP I hope I can post the question here:  can anyone tell me what the
>letters of PHP stand for?  I looked everywhere on the official php site but
>couldn't find it.

Go to the "Hall of Fame" pages on <www.zend.com>. There, you'll find a
short biography of the founding father of PHP, Rasmus Lerdorf. You'll
learn that "PHP" originally stood for "Personal Home Page", and that it
was written in Perl.

-- 
	Bart.


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

Date: Mon, 05 Mar 2001 10:34:53 GMT
From: Jonathan Stowe <gellyfish@gellyfish.com>
Subject: Re: check open files ?
Message-Id: <hZJo6.65$Bs1.7964@news.dircon.co.uk>

On 4 Mar 2001 13:05:34 -0000, Jonathan Stowe Wrote:
> On Sat, 03 Mar 2001 16:19:53 +0100 Joel Nyholm wrote:
>> Hello,
>> 
>> How can i check if a file is open with perl ?
>> 
> 
> I am assuming you mean 'check if a file is open with a Perl program' rather
> than 'check if a file is opened by a Perl program'.  If I assume right
> then you will want something like the Unix command fuser - this is a
> simple version of fuser in Perl that is rehashed from an earlier one I
> had that stopped working with the linux 2.2.12 /proc filesystem :
> 

For anyone who might be interested I encapsulated this code as a module and
have uploaded it to CPAN as Linux::Fuser ...

/J\


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

Date: 05 Mar 2001 13:09:58 +0100
From: jacklam@math.uio.no (Peter J. Acklam)
Subject: Re: Convert dates in format "3/1/2001" to dd-Month-yy
Message-Id: <wklmqkzqrn.fsf@math.uio.no>

John Smith <creafin1998@yahoo.com> wrote:

> Does anyone know the most efficient way to convert dates in the
> format "m/d/yyyy" to dd-Month-yy using pattern matching?

garry@zvolve.com (Garry Williams) writes:
 
> Don't know about efficiency, but this is short: 
> 
>   my @m = qw(January February March April
>              May June July August September
>              October November December);
> 
>   s!(\d+)/(\d+)/\d\d(\d\d)!$2-$m[$1-1]-$3!;

It doesn't pad with leading zeros though.

Peter

-- 
sub int2roman{@x=split//,sprintf'%04d',shift;@r=('','I','V','X','L','C','D'
,'M');@p=([],[1],[1,1],[1,1,1],[1,2],[2],[2,1],[2,1,1],[2,1,1,1],[1,3],[3])
;join'',@r[map($_+6,@{$p[$x[0]]}),map($_+4,@{$p[$x[1]]}),map($_+2,@{$p[$x[2
]]}),map($_+0,@{$p[$x[3]]})];}print "@{[map{int2roman($_)}@ARGV]}\n";#JAPH!


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

Date: Mon, 05 Mar 2001 08:19:41 GMT
From: Bart Lateur <bart.lateur@skynet.be>
Subject: Re: flock and close   with  empty read strangeness
Message-Id: <90j6atcl9berv4rd0sg6dqr7pbqgtrh4eq@4ax.com>

ZepHead wrote:

>how about <<
>
>this would read only and create and not truncate

What's the purpose of creating a file that you can't write to? No, sis,
creating of and writing to a file are connected. No create without
write.

-- 
	Bart.


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

Date: Mon, 5 Mar 2001 22:08:14 +1100
From: mgjv@tradingpost.com.au (Martien Verbruggen)
Subject: Re: flock and close   with  empty read strangeness
Message-Id: <slrn9a6sst.9kp.mgjv@martien.heliotrope.home>

On Mon, 05 Mar 2001 02:34:40 -0500,
	ZepHead <groovyt@erols.com> wrote:
> In article <6r94at02303mce70v55o8jcc5608ef95bp@4ax.com>,
>  Bart Lateur <bart.lateur@skynet.be> wrote:
> 
> 
>> least, there should be at least one file mode that DOES create a file if
>> it didn't exist, DOES NOT truncate the file, and leaves the seek pointer
>> at the start of the file. Like "+<", but with built-in
>> create-if-missing. And which is garanteed to work across platforms.
>> You'd still have to truncate by hand, or maybe, just maybe, the file
>> could be automatically be truncated as soon as you write to the file.
>> 
> 
> yep      
> 
> IMHO   any function  that messes with a file (in any sway)
> should never mess with that file unless there is a lock. 
> (I guess NT has this part right)
> 
> Yes i realize some systems only run one proccess at a time etc....
> but in this day and age ........  that is rare.

Unices traditionally have no mandatory locking. Unices traditionally are
multi-user, multi-process systems.

Mandatory locking can be a good thing, as long as it doesn't get crazy.
On NT, you can't move or delete files when some other process has them
open. I find that terrible. It's a real pain to get some process to
rotate a log file on systems like that, unless they can do it
themselves.

Mandatory LOCK_EX is a bad thing, because it would prevent anyone from
even reading the file (which would happen with a LOCK_SH, if locking
always happened).

Every locking sheme has its advanages and disadvantages. Perl was born
on Unix, and therefore uses the Unix model of (cooperative) locking.
Whether you like it or not, that's just how it is. I personally don't
believe that an OS should always put locks on everything, and am much
more in favour of cooperative than mandatory locking. However, it would
be nice to be able to instruct an OS to lock a file without needing
cooperation (and many file systems support this sort of operation
nowadays).

What Perl does, and supports internally when a file gets opened is a
different matter, apart from the fact that it has a history based on the
Unix Way(TM). It would be possible to come up with some modes for open
that would in one operation, and from the programmer's point of view,
atomically, open and lock a file. Somewhere upthread I suggested some
notations and possible actions for these.

However, I do _not_ believe that this should ever be made mandatory.

Maybe a pragma is an idea...

use flock qw(mandatory);

I suspect that this might actually not be too intrusive....

We would still need an equivalent mode for open of sysopen with the
O_CREAT|O_WRONLY (open for write, position at start, create if not
exists) and O_CREAT|O_RDWR (open file for read/write, position at start,
create when not exists).

+<< could be used for O_CREAT|O_RDWR, but I can't think of anything
logical for the other one. An addition of another symbol could control
locking (as I suggested earlier), and maybe one of &%* are choices that
could work. or maybe !.

But again, you should probably take this to p5p, to see if there is any
willingness to listen to this. If there isn't, it's never going to be
implemented, and you can keep talking about it until you're blue in the
face :). Check whether they think the idea might work. If so, supply a
patch.

Oh, and maybe search the p5p archives to see if it has already come up
at some time. And maybe the p6 RFCs and p6p list.

> as always just my opinion  : P

Understood.

Martien
-- 
Martien Verbruggen              | 
Interactive Media Division      | Useful Statistic: 75% of the people
Commercial Dynamics Pty. Ltd.   | make up 3/4 of the population.
NSW, Australia                  | 


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

Date: 5 Mar 2001 11:29:30 GMT
From: ilya@math.ohio-state.edu (Ilya Zakharevich)
Subject: Re: flock and close   with  empty read strangeness
Message-Id: <97vtaq$c7h$1@charm.magnus.acs.ohio-state.edu>

[A complimentary Cc of this posting was NOT sent to Martien Verbruggen
<mgjv@tradingpost.com.au>],
who wrote in article <slrn9a6sst.9kp.mgjv@martien.heliotrope.home>:
> Every locking sheme has its advanages and disadvantages. Perl was born
> on Unix, and therefore uses the Unix model of (cooperative) locking.

Nope.

> Whether you like it or not, that's just how it is.

??!!!  What makes you think so?  Perl uses the model of locking which
is "native" on the architecture it is running.

Ilya


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

Date: Mon, 5 Mar 2001 08:40:03 -0500
From: kpreid@attglobal.net (Kevin Reid)
Subject: Re: flock and close   with  empty read strangeness
Message-Id: <1epprnq.8z9vyh1am8vggN%kpreid@attglobal.net>

Martien Verbruggen <mgjv@tradingpost.com.au> wrote:

>  The current end-of-file can be moved around with the truncate function:

I got bitten by this assumption once. There is some operating system (I
don't remember which) that doesn't change the file position after a
truncate(), which resulted in nulls being written to the file from the
truncated-to location to the current file position.

The file was a text file, and the text editor I was using didn't show
nulls, so the result was a mysteriously growing file.

-- 
 Kevin Reid: |    Macintosh:      
  "I'm me."  | Think different.


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

Date: Mon, 5 Mar 2001 11:14:39 -0000
From: "Raquel" <rtavares@tec.dsr.telecom.pt>
Subject: Graphs in perl
Message-Id: <97vslf$e1o$1@venus.telepac.pt>


Hello

 How can i make a graph in perl?

 Thanks

          Raquel





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

Date: Mon, 05 Mar 2001 12:12:45 GMT
From: Jonathan Stowe <gellyfish@gellyfish.com>
Subject: Re: Graphs in perl
Message-Id: <1pLo6.5$i43.661@news.dircon.co.uk>

On Mon, 5 Mar 2001 11:14:39 -0000, Raquel Wrote:
> 
> Hello
> 
>  How can i make a graph in perl?
> 

yep :


   http://search.cpan.org/search?mode=module&query=Graph


/J\


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

Date: Mon, 5 Mar 2001 13:59:39 -0800
From: "Břrge Haga" <borge.haga@nextra.spamno.com.invalid>
Subject: How to list installed modules (MD5)
Message-Id: <R7Mo6.3317$LD5.22092@news1.oke.nextra.no>

1) This is probably a stupid question, but is there an easy way to detect
which modeules have been installed for a Perl installation? I need to
have MD5 installed, but I'm not sure if it's part of the standard
distribution and I don't even know which distribution have been
installed on the machine in question.

2) If it's not installed, where is the correct place to go and get it?

Boerge




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

Date: 5 Mar 2001 13:31:52 GMT
From: anno4000@lublin.zrz.tu-berlin.de (Anno Siegel)
Subject: Re: How to list installed modules (MD5)
Message-Id: <9804g8$9j8$1@mamenchi.zrz.TU-Berlin.DE>

According to Břrge Haga <borge.haga@nextra.spamno.com.invalid>:
> 1) This is probably a stupid question, but is there an easy way to detect
> which modeules have been installed for a Perl installation? I need to
> have MD5 installed, but I'm not sure if it's part of the standard
> distribution and I don't even know which distribution have been
> installed on the machine in question.

"perldoc perllocal" gives you a list of modules that have been
installed via the CPAN module.  This excludes modules that come
with the standard distribution and those that have been installed
by other means than CPAN (even if they are distributed on CPAN).

The only way to find all installed modules is to check @INC
with whatever means your OS (or Perl) give you.
 
> 2) If it's not installed, where is the correct place to go and get it?

That'd be CPAN again.  Call "perl -MCPAN -e shell" from the command
line as a user who can do installations.  Type "h" for help.

Anno


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

Date: Mon, 05 Mar 2001 13:39:56 +0000
From: Sam Kington <sam@illuminated.co.uk>
Subject: Re: How to list installed modules (MD5)
Message-Id: <3AA3972B.20278693@illuminated.co.uk>

"Břrge Haga" wrote:
> 
> 1) This is probably a stupid question, but is there an easy way to detect
> which modeules have been installed for a Perl installation? I need to
> have MD5 installed, but I'm not sure if it's part of the standard
> distribution and I don't even know which distribution have been
> installed on the machine in question.

One way is
eval {
    use MD5;
};
if ($@) {
	print "MD5 not installed\n";
} else {
	print "MD5 installed at ",$INC{"MD5.pm"},"\n";
}

Sam
-- 
Home page: http://www.illuminated.co.uk/
Convert ZIPs to Mac format: http://www.illuminated.co.uk/macifyzip/
In Nomine Cookbook: http://www.illuminated.co.uk/innomine/
Boycott shampoo! Demand the *real* poo!


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

Date: Sun, 4 Mar 2001 17:33:03 +0200
From: "Howard Morgenstern" <howard_morgenstern@hp.com>
Subject: https redirect in perl?
Message-Id: <97vsjk$d46$1@web1.cup.hp.com>

hey there,

I am trying to do a GET from a https server, which has some kind of security
mechanism that no matter what URL you give it (even the redirected page) ,
it sends you a page with a has javascript function that is basically a
redirect to the login page. The only way to get to the login page is through
the javascript redirect.

Is there a way to write a perl client script, using whatever modules
(currently I am using lwp with Crypt-SSLeay, I also have Net::SSLeay) to
read the reply of the page and get redirected?

thanks
-howard




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

Date: Mon, 05 Mar 2001 14:10:06 +0100
From: Montagnac Bruno <bruno.montagnac@renault.com>
Subject: Re: Is Perl right for me?
Message-Id: <3AA3902D.557CFA3F@renault.com>

bowman wrote:

> Bart Lateur <bart.lateur@skynet.be> wrote in message
> news:e2g4atgl5ek67e37quvv6h0t48cem12b5i@4ax.com...
> > Holly Bortfeld wrote:
> >
> > >I can write HTML
> > >from scratch without an editor.
> >
> > Wow, that is strong. So how do you write HTML? Using a speech
> > recognition system?
>
> real men write web pages with
>
> cat > foo.html

and what about servicing in industrial environments ?
are u meaning that you're "cat > foo.html" is easier to maintain for
updates than one script written with the right CGI API ?

--
 //\  Bruno Montagnac         ____/Alias\____     /et c'est bien\_
// \\ Technocentre RENAULT   /le Bib (A.O.C.)\    \ suffisant.../ |
\\ // DTSI/Service:18741    /le seul, l'unique\                   |
 \//  Les opinions exprimees dans ce post n'engagent que moi... <-+





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

Date: Mon, 5 Mar 2001 05:32:42 -0600
From: "Public <Anonymous_Account>" <remailer@anon.xg.nu>
Subject: Re: Magic Marker
Message-Id: <632effb886156f071aed551266024167@anon.xg.nu>


W Scott Joynes <wayne@joynes.fsbusiness.co.uk> wrote:


>Why am I getting so wound up.............. ?


cuz yer a fucken idiot who thinks he's the cops?

HTH



---
This message did not originate from the Sender address above.
It was posted with the use of anonymizing software at 
http://anon.xg.nu
---




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

Date: Mon, 5 Mar 2001 10:37:12 -0000
From: "Géry" <ducateg@info.bt.co.uk>
Subject: non greedy regex
Message-Id: <97vqgj$hsv$1@pheidippides.axion.bt.co.uk>

Hi

with the following pattern:
bart<simpson=1>=eat;homer<simpson=2>=dough;lisa<simpson=3>=sax; ...

I would like to change the '=' sign inside all <> signs to %. The pattern
above is to become:

bart<simpson%1>=eat;homer<simpson%2>=dough;lisa<simpson%3>=sax; ...

my regex started like this:

$cartoon =~ s/<(.+)=(.+)>/<$1%$2>/g;

but this returns only the last pattern right, the rest has not changed,
simply because the $1 and $2 match the last two backeted patterns. The
problem is that I never know how many repetitions of the pattern I can be
sorting out.

I thought of using something like (and various alternatives)
while ($cartoon =~ /<(.+)=(.+)>/<$1%$2>/)
{
  $cartoon =~ s/<(.+)=(.+)>/<$1%$2>/;
}

but this does not work because the algorithm is greedy and patterns like
<simpson=1> are as valid as:
<simpson=1>=eat;homer<simpson=2>
when used with my regex: <(.+)=(.+)>

Any hints welcome
 ...

>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
Géry
<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<





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

Date: Mon, 05 Mar 2001 10:51:41 GMT
From: Bart Lateur <bart.lateur@skynet.be>
Subject: Re: non greedy regex
Message-Id: <jnr6at8ss0vj560e57eeu56bads1cfk5or@4ax.com>

Géry wrote:

>with the following pattern:
>bart<simpson=1>=eat;homer<simpson=2>=dough;lisa<simpson=3>=sax; ...
>
>I would like to change the '=' sign inside all <> signs to %. The pattern
>above is to become:
>
>bart<simpson%1>=eat;homer<simpson%2>=dough;lisa<simpson%3>=sax; ...
>
>my regex started like this:
>
>$cartoon =~ s/<(.+)=(.+)>/<$1%$2>/g;
>
>but this returns only the last pattern right, the rest has not changed,
>simply because the $1 and $2 match the last two backeted patterns.

The solution can be simple. You pinpointed the problem to the fact that
your subpatterns are greedy. Well, make them nongreedy, by adding a '?'
right after the star.

	s/<(.*?)=(.*?)>/<$1%$2>/g;

To be on the safe side, I think it's better to replace the ".*" with
something less of a catch-all:

	s/<([^<>]*)=([^<>]*)>/<$1%$2>/g;

because that won't match anything you don't want, in case you have a
really odd-looking string.

-- 
	Bart.


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

Date: Mon, 5 Mar 2001 13:51:39 -0000
From: "Géry" <ducateg@info.bt.co.uk>
Subject: Re: non greedy regex
Message-Id: <9805t6$nq0$1@pheidippides.axion.bt.co.uk>

Perfect, Thanks a lot

Géry

--
>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
Géry Ducatel
<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<

"Bart Lateur" <bart.lateur@skynet.be> wrote in message
news:jnr6at8ss0vj560e57eeu56bads1cfk5or@4ax.com...
> Géry wrote:
>
> >with the following pattern:
> >bart<simpson=1>=eat;homer<simpson=2>=dough;lisa<simpson=3>=sax; ...
> >
> >I would like to change the '=' sign inside all <> signs to %. The pattern
> >above is to become:
> >
> >bart<simpson%1>=eat;homer<simpson%2>=dough;lisa<simpson%3>=sax; ...
> >
> >my regex started like this:
> >
> >$cartoon =~ s/<(.+)=(.+)>/<$1%$2>/g;
> >
> >but this returns only the last pattern right, the rest has not changed,
> >simply because the $1 and $2 match the last two backeted patterns.
>
> The solution can be simple. You pinpointed the problem to the fact that
> your subpatterns are greedy. Well, make them nongreedy, by adding a '?'
> right after the star.
>
> s/<(.*?)=(.*?)>/<$1%$2>/g;
>
> To be on the safe side, I think it's better to replace the ".*" with
> something less of a catch-all:
>
> s/<([^<>]*)=([^<>]*)>/<$1%$2>/g;
>
> because that won't match anything you don't want, in case you have a
> really odd-looking string.
>
> --
> Bart.




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

Date: Mon, 5 Mar 2001 12:35:27 -0000
From: "Jonathan Rew" <jon_rew@learn-it.demon.co.uk>
Subject: Objects in Perl
Message-Id: <983795813.17481.0.nnrp-12.c2def305@news.demon.co.uk>

Hi

I've been using Perl just as a procedural language for all my programs
to date. I'm certain that it is much more efficient to use objects in Perl,
but can't make head or tail of them. Can anyone suggest a good place to
look, book to read, etc?

Thanks

--
Jon








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

Date: Mon, 05 Mar 2001 13:14:49 GMT
From: Jonathan Stowe <gellyfish@gellyfish.com>
Subject: Re: Objects in Perl
Message-Id: <djMo6.6$i43.898@news.dircon.co.uk>

On Mon, 5 Mar 2001 12:35:27 -0000, Jonathan Rew Wrote:
> Hi
> 
> I've been using Perl just as a procedural language for all my programs
> to date. I'm certain that it is much more efficient to use objects in Perl,
> but can't make head or tail of them. Can anyone suggest a good place to
> look, book to read, etc?
> 

These manpages might be a good start :


    perlobj
    perltoot
    perlboot
    perlmod
    perlref

Are probably the ones you will want to read in the first instance - the book
of choice is almost without question "Object Oriented Programming in Perl"
by Damian Conway, published by Manning.

/J\


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

Date: Mon, 05 Mar 2001 13:15:58 GMT
From: rgarciasuarez@free.fr (Rafael Garcia-Suarez)
Subject: Re: Objects in Perl
Message-Id: <slrn9a74bv.ehr.rgarciasuarez@rafael.kazibao.net>

Jonathan Rew wrote in comp.lang.perl.misc:
> 
> I've been using Perl just as a procedural language for all my programs
> to date. I'm certain that it is much more efficient to use objects in Perl,
> but can't make head or tail of them. Can anyone suggest a good place to
> look, book to read, etc?

A good place to start is the perl standard docs :
  perlboot
  perltoot
  perltootc
  perlobj
  perltie
  perlbot

Also, the source of widely used modules OO-programmed.

You can also look at D. Conway's book about OO programming with Perl.

-- 
Rafael Garcia-Suarez / http://rgarciasuarez.free.fr/
Much programming is best done with techniques that do not fall within a
narrow definition of "object-oriented." -- Bjarne Stroustrup


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

Date: Mon, 05 Mar 2001 08:42:23 GMT
From: "John W. Krahn" <krahnj@acm.org>
Subject: Re: perl-ize and optimize
Message-Id: <3AA352C7.6A9F16F0@acm.org>

"Charles K. Clarkson" wrote:
> 
>     I'm not sure what 'more perlish' means but:
> 
> #!/usr/bin/perl -w
> 
> use strict;
> use diagnostics;
> srand;
> 
> print shuffle('the quick brown fox hopped like a bunny'), "\n";
> 
> sub shuffle {
>     my $string = shift;
>     $string =~ s/^(\w+?)\s(.+)$/$2 $1/ for 0 .. rand 1 + $string =~ tr/ /
> /s;
>     return $string;
> }
> 
> __END__
> A million iterations produced a nice even distribution:


Try it with this sentence and see how even the distribution is. :-)

print shuffle( q{I calculated O'Brian's pay at $15.00 per hour.} ),
"\n";


John


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

Date: Mon, 05 Mar 2001 09:56:39 GMT
From: Bart Lateur <bart.lateur@skynet.be>
Subject: Re: perl-ize and optimize
Message-Id: <7eo6atc4a4379s3jccsf0cjfkdks02j0mu@4ax.com>

Bart Lateur wrote:

>Cut the string into words with split, pick a random position to rotate,
>and rejoin the array into a string. That's the ticket.

And now... the code.

	sub randomly_rotate {
	    my @words = split / /, shift;
	    push @words, splice @words, 0, int rand @words;
	    return join ' ', @words;
	}

I admit, pushing what you cut out of an array back onto the end, is a
bit obscure. This is less confusing:

	sub randomly_rotate {
	    my @words = split / /, shift;
	    my @cut = splice @words, 0, int rand @words;
	    return join ' ', @words, @cut;
	}

-- 
	Bart.


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

Date: Mon, 05 Mar 2001 09:42:51 +0100
From: Carsten Aulbert <aulbert@aei-potsdam.mpg.de>
Subject: perlcc on modules
Message-Id: <3AA3518B.557FD0A@aei-potsdam.mpg.de>

Hi there, 

I've to build a binary file on either Unix and Windoze boxes and tried
perlcc. It works fine for scripts, buthas problems with scripts using
modules. For example, when trying to compile IO::Socket it compiles it,
but throws out a lot of warnings about undefined things (usually
constants), secondly you have to scan these modules again for modules
they rely on (Carp et al.). 

So my questions is, which way is the way to go? Either try to compile
each modules on its own and hope the best for linking (which I was also
unseccessful with) or just try to put things together into a huge script
that should be compiled fine (hopefully)?

Thanks a lot for any question

Carsten

PS: If I raised a question here which already has been answered I'd
appreciate just a link to the answer since (obviously) I haven't found
one yet.

-- 
--------------------------------------------------------------------
 Carsten Aulbert                       <aulbert@aei-potsdam.mpg.de>
 Max-Planck-Institut fuer Gravitationsphysik       +49-331-567-7253
 Albert Einstein Institut, Am MuehlenBerg 5, D-14476, Golm, Germany


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

Date: 5 Mar 2001 13:31:20 GMT
From: mwhyte@pmds.com
Subject: Re: Problem with #! line using RedHat 7
Message-Id: <9804f8$t17$1@news.netmar.com>

In article <97ovnq$5hm$1@news.netmar.com>, <mwhyte@pmds.com> writes:
>
>I was hoping someone might help me.  I've got a very simple Hello World
script
>written (the script follows):
>
>#!/usr/bin/perl -w     
>                       
>use strict;            
>use diagnostics;       
>                       
>print "Hello World\n"; 
>
>When I run "perl hello.pl", everything works fine.  I've changed the
>permissions of the file hello.pl to be 777, but I am unable to run the
>program by simply typing "hello".  When I do, I get this message:
>
>bash: hello: command not found
>
>Is there a step I'm missing?  I'm reading a freebie online course and it
says
>all I need to make the script itself executable is to change the
permissions,
>and to have the #! as the first line.  I'd appreciate any help anyone can
>provide.
>
>Thanks,
>
>Mark
>
> -----  Posted via NewsOne.Net: Free (anonymous) Usenet News via the Web 
-----
>  http://newsone.net/ -- Free reading and anonymous posting to 60,000+
groups
>   NewsOne.Net prohibits users from posting spam.  If this or other posts
>made through NewsOne.Net violate posting guidelines, email abuse@newsone.net

Thanks for the assistance - I was using the wrong filename.  What a brain
fart!

 -----  Posted via NewsOne.Net: Free (anonymous) Usenet News via the Web  -----
  http://newsone.net/ -- Free reading and anonymous posting to 60,000+ groups
   NewsOne.Net prohibits users from posting spam.  If this or other posts
made through NewsOne.Net violate posting guidelines, email abuse@newsone.net


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

Date: 16 Sep 99 21:33:47 GMT (Last modified)
From: Perl-Users-Request@ruby.oce.orst.edu (Perl-Users-Digest Admin) 
Subject: Digest Administrivia (Last modified: 16 Sep 99)
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: The mail to news gateway, and thus the ability to submit articles
| through this service to the newsgroup, has been removed. I do not have
| time to individually vet each article to make sure that someone isn't
| abusing the service, and I no longer have any desire to waste my time
| dealing with the campus admins when some fool complains to them about an
| article that has come through the gateway instead of complaining
| to the source.

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


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