[24307] in Perl-Users-Digest

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

Perl-Users Digest, Issue: 6498 Volume: 10

daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Sat May 1 08:05:48 2004

Date: Sat, 1 May 2004 04:16:17 -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           Sat, 1 May 2004     Volume: 10 Number: 6498

Today's topics:
    Re: comparing decimal numbers <mark.clements@kcl.ac.uk>
    Re: comparing decimal numbers (Anno Siegel)
    Re: Finding all open filehandles and closing them befor <vilmos@vilmos.org>
    Re: free source search engine (simple) ## comments? <tassilo.parseval@rwth-aachen.de>
    Re: free source search engine (simple) ## comments? (Anno Siegel)
    Re: free source search engine (simple) ## comments? <mark.clements@kcl.ac.uk>
    Re: free source search engine (simple) ## comments? <gnari@simnet.is>
    Re: hope this is easy, passing a url as a parameter <dannywork5@hotmail.com>
    Re: hope this is easy, passing a url as a parameter <nospam@bigpond.com>
    Re: How to define a sub on the fly? <socyl@987jk.com>
    Re: How to define a sub on the fly? <uri@stemsystems.com>
    Re: How to define a sub on the fly? (Anno Siegel)
    Re: How to define a sub on the fly? <mark.clements@kcl.ac.uk>
    Re: Improving Robin's blogger <Joe.Smith@inwap.com>
    Re: OSs with Perl installed <matthew.garrish@sympatico.ca>
    Re: OSs with Perl installed <cwilbur@mithril.chromatico.net>
    Re: OSs with Perl installed <jtc@shell.dimensional.com>
    Re: Parsing Path Data into Tree Structure (Dale)
    Re: Performance implications of using the Switch module <tassilo.parseval@rwth-aachen.de>
        perl program <anonymous@disneyland.com>
    Re: perl program <mark.clements@kcl.ac.uk>
    Re: print $query->scrolling_list (Chris)
    Re: reducing a regex <g-preston1@ti.com>
    Re: reducing a regex (Anno Siegel)
    Re: reducing a regex <noreply@gunnar.cc>
    Re: search.pl <mark.clements@kcl.ac.uk>
    Re: use constant and BEGIN don't mix? (Anno Siegel)
    Re: what is purpose of 1; at end of scripts <nospam@bigpond.com>
    Re: what is purpose of 1; at end of scripts (Sam Holden)
    Re: what is purpose of 1; at end of scripts <tadmc@augustmail.com>
        Digest Administrivia (Last modified: 6 Apr 01) (Perl-Users-Digest Admin)

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

Date: Sat, 01 May 2004 09:50:03 +0100
From: Mark Clements <mark.clements@kcl.ac.uk>
Subject: Re: comparing decimal numbers
Message-Id: <409364bb$1@news.kcl.ac.uk>

Tad McClellan wrote:

> Thens <thens@NOSPAMti.com> wrote:
>>I have to compare two decimals numbers 1.5.0 and 2.1.1.
  > Those are not decimal numbers...

brave, very brave :)


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

Date: 1 May 2004 09:09:31 GMT
From: anno4000@lublin.zrz.tu-berlin.de (Anno Siegel)
Subject: Re: comparing decimal numbers
Message-Id: <c6vpgb$sc5$1@mamenchi.zrz.TU-Berlin.DE>

Mark Clements  <mark.clements@kcl.ac.uk> wrote in comp.lang.perl.misc:
> Tad McClellan wrote:
> 
> > Thens <thens@NOSPAMti.com> wrote:
> >>I have to compare two decimals numbers 1.5.0 and 2.1.1.
>   > Those are not decimal numbers...
> 
> brave, very brave :)

Indeed!

It is true that "Dewey Decimal" notation refers to exactly this kind of
string.  But numbers they aren't.  Sufficiently new Perl's could compare
them as version strings, but I'm not sure if that's a good suggestion.

Anno


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

Date: 30 Apr 2004 23:19:58 -0700
From: Vilmos Soti <vilmos@vilmos.org>
Subject: Re: Finding all open filehandles and closing them before exiting
Message-Id: <874qr0vfch.fsf@localhost.localdomain>

rook_5150@yahoo.com (Bryan Castillo) writes:

>>>> I have a signal handler which tries to unmount the disk in
>>>> the case of a sigint, but it will fail if copy from File::Copy
>>>> has an open filehandle on the mounted disk.
>> 
>> ...
>> 
>> > Try this: (worked on my system Fedora Core 1)
>> 
>> ...
>> 
>>> eval {
>>>   copy ("/tmp/mountpoint/devzero", "/tmp/mountpoint/devnull");
>>> };
>> 
>> Thanks for the idea, but it didn't work for me. Our system
> 
> What didn't work?  The device was still busy?  Or there was something
> wrong with the script?  Do you have the output?

The device was busy. I added an extra line to the program (not
at hand now) before the 'system ("umount ...")' command which was
nothing more than a 'system ("ls -l /proc/$$/fd/")' to see
if the file was still open. Indeed, it was still open.

On Monday I can post the actual output. The box is not available
now.

Thanks for your help, Vilmos


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

Date: Sat, 1 May 2004 09:21:34 +0200
From: "Tassilo v. Parseval" <tassilo.parseval@rwth-aachen.de>
Subject: Re: free source search engine (simple) ## comments?
Message-Id: <c6vj60$ggp2q$1@ID-231055.news.uni-berlin.de>

Also sprach Sherm Pendley:

> Robin wrote:
> 
>> btw, unless I change newsreaders which I haven't had much success with,
>> I've downloaded like 5 and none seem to work for me cause they don't work
>> with my mail server my indenting is gonna be screwed up, so please bear
>> with me.
> 
> You mentioned earlier about spaces and tabs getting screwed up. I've seen
> that happen many times - the problem is that everyone has their own idea
> where the "right" place to put tab stops is. Some folks put them at every 4
> columns, some every 8, some every 2, etc. If you use tabs in your file, and
> someone with different tab settings views the file, the formatting gets
> totally hosed.
> 
> The solution is to avoid using tabs. I'm *not* saying don't indent your
> code! :-) I'm just saying to use spaces to do it, instead of tabs. Most
> programmer's editors have an option to insert spaces when you hit the tab
> key, so you'll hardly notice a difference when typing.

Actually - and I was told about that on perl5-porters - using tabs is
the right thing to do. Or at least partly, as the perl source
conventions are a little more complicated. The first level of
indentation is four spaces (no tab there). The second level would be
eight spaces and is then transformed into one tab. The third level would
then be one tab plus four spaces, and so on.

Any proper editor can be told to follow this convention automatically.
They also have settings for setting the visual tab width so that your
code will looks as though there are only spaces.

In the end, your editor will display these files correctly. But when you
look at it through a pager or so, it will look strange, depending on how
many spaces it uses per tab (I have an alias which maps 'less' to
'less -x4 -r' which would be four spaces per tab).

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: 1 May 2004 08:13:24 GMT
From: anno4000@lublin.zrz.tu-berlin.de (Anno Siegel)
Subject: Re: free source search engine (simple) ## comments?
Message-Id: <c6vm74$qtm$1@mamenchi.zrz.TU-Berlin.DE>

Tassilo v. Parseval <tassilo.parseval@post.rwth-aachen.de> wrote in comp.lang.perl.misc:
> Also sprach Sherm Pendley:
> 
> > Robin wrote:
> > 
> >> btw, unless I change newsreaders which I haven't had much success with,
> >> I've downloaded like 5 and none seem to work for me cause they don't work
> >> with my mail server my indenting is gonna be screwed up, so please bear
> >> with me.
> > 
> > You mentioned earlier about spaces and tabs getting screwed up. I've seen
> > that happen many times - the problem is that everyone has their own idea
> > where the "right" place to put tab stops is. Some folks put them at every 4
> > columns, some every 8, some every 2, etc. If you use tabs in your file, and
> > someone with different tab settings views the file, the formatting gets
> > totally hosed.
> > 
> > The solution is to avoid using tabs. I'm *not* saying don't indent your
> > code! :-) I'm just saying to use spaces to do it, instead of tabs. Most
> > programmer's editors have an option to insert spaces when you hit the tab
> > key, so you'll hardly notice a difference when typing.
> 
> Actually - and I was told about that on perl5-porters - using tabs is

Just waitaminute.  We're talking about formatting Perl, not the perl
source.

> the right thing to do. Or at least partly, as the perl source
> conventions are a little more complicated. The first level of
> indentation is four spaces (no tab there). The second level would be
> eight spaces and is then transformed into one tab. The third level would
> then be one tab plus four spaces, and so on.

I have noticed this strange convention.  If there is a reason for it, I
don't want to know...

> Any proper editor can be told to follow this convention automatically.
> They also have settings for setting the visual tab width so that your
> code will looks as though there are only spaces.

I guess so.

> In the end, your editor will display these files correctly. But when you
> look at it through a pager or so, it will look strange, depending on how
> many spaces it uses per tab (I have an alias which maps 'less' to
> 'less -x4 -r' which would be four spaces per tab).

Well, that's fine when the source requires that format, as the Perl source
seems to do.  But you're not recommending it for new sources (C, Perl
or otherwise), are you?

Tabs where introduced with mechanical typewriters to save typing time.
In a programming environment they have the additional advantage of saving
space, so early programmers adopted them eagerly.  But they never worked
really well, because every bit of hard- or software has its own ideas of
what a tab really means.

These days, editors do the time-saving, and byte-counting has ceased
to be profitable.  Tabs might have been useful with more standardization, 
but they aren't now.

Anno


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

Date: Sat, 01 May 2004 10:31:52 +0100
From: Mark Clements <mark.clements@kcl.ac.uk>
Subject: Re: free source search engine (simple) ## comments?
Message-Id: <40936e88$1@news.kcl.ac.uk>

Robin wrote:

> with my 
>>>mail server my indenting is gonna be screwed up, so please bear with me.
perltidy is your friend.

Mark


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

Date: Sat, 1 May 2004 09:15:04 -0000
From: "gnari" <gnari@simnet.is>
Subject: Re: free source search engine (simple) ## comments?
Message-Id: <c6vpo2$eh1$1@news.simnet.is>

"Robin" <webmaster @ infusedlight . net> wrote in message
news:c6v3qu$nls$1@reader2.nmix.net...
>
> "gnari" <gnari@simnet.is> wrote in message
> news:c6utlj$ao4$1@news.simnet.is...
> > "Robin" <webmaster @ infusedlight . net> wrote in message
> > news:c6usr4$lje$1@reader2.nmix.net...
> > >
> > > how can this one be used to hack my site? I'm curious...
> >
> > it is a consequence of your habit of keeping securty related files
> > in your web directory. in the same directory where your
> > 'search engine' is reading. do you see the implications of that ?
> >
>
> what's your definition of a security related file? My stuff is mainly just
> my personal site and zip files for various scripts and doc files...

well a password file for your blogger would qualify, as long as you do not
want other people to make unauthorized entries.

do you want a demonstration ?

gnari





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

Date: Sat, 01 May 2004 04:12:08 GMT
From: "Danny" <dannywork5@hotmail.com>
Subject: Re: hope this is easy, passing a url as a parameter
Message-Id: <ssFkc.66972$Gd3.16063010@news4.srv.hcvlny.cv.net>


"John Bokma" <postmaster@castleamber.com> wrote in message
news:40931fc8$0$198$58c7af7e@news.kabelfoon.nl...
> Danny wrote:
> > I am trying to pass a parameter to a cgi script,  it is a URL that has
its
> > own call to a cgi script with ? in statement.
> > for example
> >
> > so my cgi (load.cgi) is getting confused because of the extra ? in the
> > statement.
> > my cgi redirects to the passed url
> >
> > I call it like this:
> >
www.domain.com/cgi-bin/load.cgi?url=http://www.anotherdomain.com/cgi-bin/pro
> > ducts.cgi?search=volvo
>
> Encode the URL, this is wrong.
>
> -- 
> John                               MexIT: http://johnbokma.com/mexit/
>                             personal page:       http://johnbokma.com/
>     Experienced Perl programmer available:     http://castleamber.com/

Thanks

How can I encode the URL.?





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

Date: Sat, 01 May 2004 15:11:58 +1000
From: Gregory Toomey <nospam@bigpond.com>
Subject: Re: hope this is easy, passing a url as a parameter
Message-Id: <1513682.d3x1Bjo0rK@GMT-hosting-and-pickle-farming>

Danny wrote:

> 
> "John Bokma" <postmaster@castleamber.com> wrote in message
> news:40931fc8$0$198$58c7af7e@news.kabelfoon.nl...
>> Danny wrote:
>> > I am trying to pass a parameter to a cgi script,  it is a URL that has
> its
>> > own call to a cgi script with ? in statement.
>> > for example
>> >
>> > so my cgi (load.cgi) is getting confused because of the extra ? in the
>> > statement.
>> > my cgi redirects to the passed url
>> >
>> > I call it like this:
>> >
> www.domain.com/cgi-bin/load.cgi?url=http://www.anotherdomain.com/cgi-bin
pro
>> > ducts.cgi?search=volvo
>>
>> Encode the URL, this is wrong.
>>
>> --
>> John                               MexIT: http://johnbokma.com/mexit/
>>                             personal page:       http://johnbokma.com/
>>     Experienced Perl programmer available:     http://castleamber.com/
> 
> Thanks
> 
> How can I encode the URL.?

Its a faq.

http://www.perldoc.com/perl5.8.0/pod/perlfaq9.html
How do I decode or create those %-encodings on the web?


But its better to use the cgi.pm module

gtoomey


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

Date: Sat, 1 May 2004 05:18:23 +0000 (UTC)
From: kj <socyl@987jk.com>
Subject: Re: How to define a sub on the fly?
Message-Id: <c6vbuu$q11$1@reader2.panix.com>

In <x73c6l3t27.fsf@mail.sysarch.com> Uri Guttman <uri@stemsystems.com> writes:

>>>>>> "WR" == Walter Roberson <roberson@ibd.nrc-cnrc.gc.ca> writes:

>  WR> In article <c6uipi$inb$1@reader2.panix.com>, kj  <socyl@987jk.com> wrote:  
>  WR> :Can someone please show me how to define a sub Foo::Bar::baz on
>  WR> :the fly (i.e. when the module is loaded)?

>but i would ask the OP what they mean by creating a sub on the fly and
>why does he think it is needed? it isn't hard to do but i won't help if
>it is not even needed.

OK, here's the situation.  The module in question has the simple
task of serving information contained in a *variable* collection
of data flat-files (data/A, data/B, ..., data/X, etc.).  For me,
the most natural way to code this would be to have a sub/method
that took a filename as argument (e.g. get_data("$path/data/B")),
but for reasons that have to do with the software framework in
which this module will operate, it is necessary, instead, to have
several separate subroutines named after the data files (e.g. sub
A { ...  }, etc., which could simply call get_data("$path/data/A").
And since the names of these files cannot be known until runtime,
these subroutines can only be defined then.

Thanks,

kj
-- 
NOTE: In my address everything before the period is backwards.


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

Date: Sat, 01 May 2004 05:45:04 GMT
From: Uri Guttman <uri@stemsystems.com>
Subject: Re: How to define a sub on the fly?
Message-Id: <x765bg3dls.fsf@mail.sysarch.com>

>>>>> "k" == kj  <socyl@987jk.com> writes:

  k> In <x73c6l3t27.fsf@mail.sysarch.com> Uri Guttman
  k> <uri@stemsystems.com> writes:

  >> but i would ask the OP what they mean by creating a sub on the fly and
  >> why does he think it is needed? it isn't hard to do but i won't help if
  >> it is not even needed.

  k> OK, here's the situation.  The module in question has the simple
  k> task of serving information contained in a *variable* collection of
  k> data flat-files (data/A, data/B, ..., data/X, etc.).  For me, the
  k> most natural way to code this would be to have a sub/method that
  k> took a filename as argument (e.g. get_data("$path/data/B")), but
  k> for reasons that have to do with the software framework in which
  k> this module will operate, it is necessary, instead, to have several
  k> separate subroutines named after the data files (e.g. sub A { ...
  k> }, etc., which could simply call get_data("$path/data/A").  And
  k> since the names of these files cannot be known until runtime, these
  k> subroutines can only be defined then.

then how do you determine which method to call? i mean how does the
driving code select the method? is based on the filename itself? what is
the class this object is in? could it have an attribute that is the
filename? one way to solve this is via polymophism. you create a set of
classes named for the file (e.g. MyData::A) which all implement the
get_data method. the framework then builds a class name based on the
file name and uses that to create a new object. then it calls get_data
(remember, the same method name in all the classes) and voila, you have
your data. but it all sounds like too much work in any case. what kind
of framework can't handle simple args or a dispatch table.

uri

-- 
Uri Guttman  ------  uri@stemsystems.com  -------- http://www.stemsystems.com
--Perl Consulting, Stem Development, Systems Architecture, Design and Coding-
Search or Offer Perl Jobs  ----------------------------  http://jobs.perl.org


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

Date: 1 May 2004 07:43:34 GMT
From: anno4000@lublin.zrz.tu-berlin.de (Anno Siegel)
Subject: Re: How to define a sub on the fly?
Message-Id: <c6vkf6$puk$1@mamenchi.zrz.TU-Berlin.DE>

Uri Guttman  <uri@stemsystems.com> wrote in comp.lang.perl.misc:
> >>>>> "k" == kj  <socyl@987jk.com> writes:
> 
>   k> In <x73c6l3t27.fsf@mail.sysarch.com> Uri Guttman
>   k> <uri@stemsystems.com> writes:
> 
>   >> but i would ask the OP what they mean by creating a sub on the fly and
>   >> why does he think it is needed? it isn't hard to do but i won't help if
>   >> it is not even needed.
> 
>   k> OK, here's the situation.  The module in question has the simple
>   k> task of serving information contained in a *variable* collection of
>   k> data flat-files (data/A, data/B, ..., data/X, etc.).  For me, the
>   k> most natural way to code this would be to have a sub/method that
>   k> took a filename as argument (e.g. get_data("$path/data/B")), but
>   k> for reasons that have to do with the software framework in which
>   k> this module will operate, it is necessary, instead, to have several
>   k> separate subroutines named after the data files (e.g. sub A { ...
>   k> }, etc., which could simply call get_data("$path/data/A").  And
>   k> since the names of these files cannot be known until runtime, these
>   k> subroutines can only be defined then.
> 
> then how do you determine which method to call? i mean how does the

I'm not sure the OP's framework is OO at all.

> driving code select the method? is based on the filename itself?

That's the question, whether OO or not.  Making the names of subroutines
dependent on exterior filenames breaks the program/data separation.
Making the sub calls later may break it again.

> the class this object is in? could it have an attribute that is the
> filename? one way to solve this is via polymophism. you create a set of
> classes named for the file (e.g. MyData::A) which all implement the
> get_data method. the framework then builds a class name based on the
> file name and uses that to create a new object.

What is the object for?  The get_data method doesn't need one, it might
as well be a class method and be called as such.  You would need to call
a class method to create the object in any case, it might as well do
the actual job.  IOW, instead of doing

    my $class = 'MyData::' . $filename;
    my $obj = $class->new;
    my $data = $obj->get_data;

say

    my $class = 'MyData::' . $filename;
    my $data = $class->get_data;

>                                                 then it calls get_data
> (remember, the same method name in all the classes) and voila, you have
> your data. but it all sounds like too much work in any case. what kind
> of framework can't handle simple args or a dispatch table.

I'm wondering that too...

Anno


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

Date: Sat, 01 May 2004 09:49:20 +0100
From: Mark Clements <mark.clements@kcl.ac.uk>
Subject: Re: How to define a sub on the fly?
Message-Id: <40936490$1@news.kcl.ac.uk>

Walter Roberson wrote:
> In article <c6uipi$inb$1@reader2.panix.com>, kj  <socyl@987jk.com> wrote:
> :Can someone please show me how to define a sub Foo::Bar::baz on
> :the fly (i.e. when the module is loaded)?
> 
> Try constructing it inside a BEGIN block. BEGIN blocks are executed
> as the module is loaded.
Sidestepping the rest of the thread (ie the validity of doing this), you 
can use the autoloader and/or eval. Creation of subs (or any code on the 
fly) can be done with eval $definition.

eg
eval<<EOF;
	sub newsub(){
		return "from newsub";
	};
EOF

You may well want to take this step within a BEGIN block. Bear in mind 
prototypes are meaningless when a sub is called as a class or object method.

There are many examples of using the autoloader available so I won't 
give one here, but you probably want to use it to intercept calls to eg 
get_filename1(), get_filename2() and take it from there.

Mark


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

Date: Sat, 01 May 2004 07:48:27 GMT
From: Joe Smith <Joe.Smith@inwap.com>
Subject: Re: Improving Robin's blogger
Message-Id: <fDIkc.6645$Ik.592430@attbi_s53>

Robin wrote:

> so, what would you do to the blogger.pl script to make it "work"? I don't
> need code, just some friendly advice

There are many other free blogger scripts, why would anyone use yours?

That is a serious question.

Back in 1994, anything that "worked" in a CGI environment was snapped up
as there was nothing else to compare with.  This gave rise to code
that appeared to work at first glance, but did not scale well when its
database grew or the number of hits per second increased.  (Matt Wright's
deservedly critisized scripts being case in point.)

But now you have things like the Slashcode running http://slashdot.org
and fully functional blogging code like Moveable Type.  A new programmer
may be quite proud of his/her first working program, but that by itself
does not make it worthwhile for anyone else to use.

My advice is to investigate the competition.  Document how your code
compares to the others.  In addition to listing the features your
program has that the others don't, include the known limitations or
deficiencies.  "I'm giving away this code as an example for Perl
beginners and non-programmers" belongs in the minus column.

Create professional-quality user documenation.  Accurately describe
what the program is expected to do and what it is not expected to do.
If the response time doubles after the one hundred and first username
is added to the password file, document that.

Tidy up the code.  Imagine that your code was going to be presented
as a case study near the end of the semester in an intermediate level
Perl programming class.  Picture 30 students, after having had several
weeks exposure to good programming practices, nitpicking each line and
giving ratings like "typical newbie mistake" or "great idiom!".

I would also recommend taking the time to read a large number of the
modules that come bundled with with Perl, to get a feel for how
professional hobbyists and/or paid programmers write.

	-Joe


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

Date: Sat, 1 May 2004 00:24:05 -0400
From: "Matt Garrish" <matthew.garrish@sympatico.ca>
Subject: Re: OSs with Perl installed
Message-Id: <zDFkc.54087$OU.1263583@news20.bellglobal.com>


"John Bokma" <postmaster@castleamber.com> wrote in message
news:40931ffc$0$198$58c7af7e@news.kabelfoon.nl...
> Matt Garrish wrote:
>
> > If I worked for Microsoft I would be very afraid of Linux...
>
> Why?
>

Because I can't see Windows in the workplace as anything more than a
temporary solution to the difficulty imposed by unix on average users. The
best of both worlds would be an easy to use system that can be extended and
developed to meet a business's needs. Windows is not that. Linux is also not
that, but is much closer to becoming it than Windows. M$ can come up with
all the "revolutionary" new layers of abstraction it wants, but what's under
the hood is still a shambles.

To cut to the chase, though, the faster revenues drop the faster heads get
chopped. Linux is a powerful, secure, cheap and quickly becoming easy-to-use
OS. You do the math...

Matt




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

Date: Sat, 01 May 2004 04:59:23 GMT
From: Charlton Wilbur <cwilbur@mithril.chromatico.net>
Subject: Re: OSs with Perl installed
Message-Id: <873c6kiwkr.fsf@mithril.chromatico.net>

>>>>> "JC" == Jim Cochrane <jtc@shell.dimensional.com> writes:

    JC> You have a point.  On the other hand, other commercial OSs
    JC> (such as, I believe, Mac OS X and Solaris 9) come with several
    JC> well established free software packages, including several GNU
    JC> utilities and Perl.  Companies like Sun and Apple also don't
    JC> have control over Perl, so why do they include it?  

Microsoft already *has* a language aimed at the same problem space as
Perl: Visual Basic.  If they provided Perl, they'd be weakening Visual
Basic's position on the Windows platform.  Beyond that, by providing
Windows-specific tools, they lock people into the Windows platform: if
you want to do scripting on Windows, you need to learn Visual Basic;
and that Visual Basic knowledge is not transferable to Linux or
Solaris or OS X at all.

By contrast, there's little benefit to Apple to create an Apple-only
general-purpose scripting language[1]: the amount of effort necessary
to be specifically contrarian in this could give much greater returns
elsewhere.  The same can be said for Sun: the benefits of including
Perl are *much* greater than the benefits of not including it,
especially since many people would likely just install Perl anyway.

Charlton

[1] AppleScript doesn't really count - it's an extremely high-level
glue language that plays well with the Cocoa framework.



-- 
cwilbur at chromatico dot net
cwilbur at mac dot com


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

Date: 1 May 2004 00:49:07 -0600
From: Jim Cochrane <jtc@shell.dimensional.com>
Subject: Re: OSs with Perl installed
Message-Id: <slrnc96i34.4t6.jtc@shell.dimensional.com>

In article <zDFkc.54087$OU.1263583@news20.bellglobal.com>, Matt Garrish wrote:
> 
> "John Bokma" <postmaster@castleamber.com> wrote in message
> news:40931ffc$0$198$58c7af7e@news.kabelfoon.nl...
>> Matt Garrish wrote:
>>
>> > If I worked for Microsoft I would be very afraid of Linux...
>>
>> Why?
>>
> 
> Because I can't see Windows in the workplace as anything more than a
> temporary solution to the difficulty imposed by unix on average users. The
> best of both worlds would be an easy to use system that can be extended and
> developed to meet a business's needs. Windows is not that. Linux is also not

Hmm, I thought such an OS already existed.  I haven't used it, so I can't
say for sure if it meets these criteria, but from what I've heard about it,
it does.  (In case you haven't guessed yet what I'm talking about, it's
OS X.)

> that, but is much closer to becoming it than Windows. M$ can come up with
> all the "revolutionary" new layers of abstraction it wants, but what's under
> the hood is still a shambles.
> 
> To cut to the chase, though, the faster revenues drop the faster heads get
> chopped. Linux is a powerful, secure, cheap and quickly becoming easy-to-use
> OS. You do the math...
> 
> Matt
> 
> 


-- 
Jim Cochrane; jtc@dimensional.com
[When responding by email, include the term non-spam in the subject line to
get through my spam filter.]


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

Date: 1 May 2004 00:35:37 -0700
From: desau@aisc.ac.cy (Dale)
Subject: Re: Parsing Path Data into Tree Structure
Message-Id: <f748e986.0404302335.78f5283e@posting.google.com>

Thanks. Will give this a shot.

DRE

Tad McClellan <tadmc@augustmail.com> wrote in message news:<slrnc95j8m.5o4.tadmc@magna.augustmail.com>...
> David K. Wall <dwall@fastmail.fm> wrote:
> > Dale <desau@aisc.ac.cy> wrote:
> > 
> >> What I am trying
> >> to do is take a very plain text string describing a path and parse
> >> that into a tree to display in html.
> 
> 
> > Search Google groups for Message-ID 
> ><slrnbhtb7u.4o7.tadmc@magna.augustmail.com> and you'll find an 
> > algorithm you can adapt.
> 
> 
> Or adapt this shell one-liner (good luck!).   :-)
> 
> 
>    find . -print | sed -e 's,[^/]*/\([^/]*\)$,`--\1,' -e 's,[^/]*/,|  ,g'


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

Date: Sat, 1 May 2004 09:10:39 +0200
From: "Tassilo v. Parseval" <tassilo.parseval@rwth-aachen.de>
Subject: Re: Performance implications of using the Switch module
Message-Id: <c6vihh$gphgs$1@ID-231055.news.uni-berlin.de>

Also sprach GreenLight:

> I hate looking at rows and rows of elsif statements as much as the
> next person, but using the Switch module just doesn't cut it. I wrote:
> 
> use strict;
> use warnings;
> use Benchmark;
> use Switch;
> 
> sub use_if() {
[...]
> 		if ($tag eq 'TAG001') { push @parsed, $value }
> 		elsif ($tag eq 'TAG002') { push @parsed, $value }
> 		elsif ($tag eq 'TAG003') { push @parsed, $value }
> 		elsif ($tag eq 'TAG004') { push @parsed, $value }
> 		elsif ($tag eq 'TAG005') { push @parsed, $value }
> 		elsif ($tag eq 'TAG006') { push @parsed, $value }
> 		elsif ($tag eq 'TAG007') { push @parsed, $value }
> 		elsif ($tag eq 'TAG008') { push @parsed, $value }
> 		elsif ($tag eq 'TAG009') { push @parsed, $value }
> 		elsif ($tag eq 'TAG010') { push @parsed, $value }
> 		else { die "Bad tag!" }
> 	}
> }
> 
> sub use_switch() {
[...]
> 		switch ($tag) {
> 			case "TAG001" { push @parsed, $value }
> 			case "TAG002" { push @parsed, $value }
> 			case "TAG003" { push @parsed, $value }
> 			case "TAG004" { push @parsed, $value }
> 			case "TAG005" { push @parsed, $value }
> 			case "TAG006" { push @parsed, $value }
> 			case "TAG007" { push @parsed, $value }
> 			case "TAG008" { push @parsed, $value }
> 			case "TAG009" { push @parsed, $value }
> 			case "TAG010" { push @parsed, $value }
> 			else { die "Bad tag!" }
> 		}
> 	}
> }
> 
> timethese (100000, {
> 		"Using 'if'" => \&use_if,
> 		"Using 'switch'" => \&use_switch
> 	});
> 
> __END__
> 
> These subroutines adequately represent tasks performed thousands of
> times per day at my client's site.
> And the results:
> 
> Benchmark: timing 100000 iterations of Using 'if', Using 'switch'...
> Using 'if': 17 wallclock secs (16.48 usr +  0.00 sys = 16.48 CPU) @
> 6066.49/s (n=100000)
> Using 'switch': 153 wallclock secs (150.68 usr +  0.00 sys = 150.68
> CPU) @ 663.68/s (n=100000)
> 
> Using "switch" was nearly an order of magnitude slower.
> 
> Now my real question: Does anyone know if the "forthcoming" Perl6
> version (given/when, as described in "perldoc switch") will offer
> better performance (that is, is anyone actually using any early
> release and can comment upon the performance)?

Perl6 will have switch/case built into the language and it'll be part of
the Perl6's grammar. Perl5's switch, however, is done through cheating.
A source filter makes a preliminary run through your code at compile
time and translates it into code Perl5 can handle. Apparently, the
generated code is not very efficient. You can have a look at it by using
B::Deparse:

    ethan@ethan:~$ perl -MSwitch -MO=Deparse
    switch($var) {
    case "bla" { print "bla\n" }
    case "blu" { print "blu\n" }
    }
    ^D
    S_W_I_T_C_H: while (1) {
        local $_S_W_I_T_C_H;
        &Switch::switch($var);
        if (&Switch::case('bla')) {
            while (1) {
                print "bla\n";
                last S_W_I_T_C_H;
            }
            continue {
                goto C_A_S_E_1;
            }
            last S_W_I_T_C_H;
            C_A_S_E_1: ;
        }
        if (&Switch::case('blu')) {
            while (1) {
                print "blu\n";
                last S_W_I_T_C_H;
            }
            continue {
                goto C_A_S_E_2;
            }
	    last S_W_I_T_C_H;
            C_A_S_E_2: ;
        }
    }
    continue {
        last;
    }

This is much slower than simple if/elsif/else chains because very
condition is handled through function calls (which itself are rather
slow in perl). Switch::case() then calls a codereference that does the
actual comparison, based upon the type of the 'case' condition. For a
simple string, as in your case, the codereference called from case()
looks like this:

    $::_S_W_I_T_C_H =
          sub { my $c_val = $_[0];
                my $c_ref = ref $c_val;
                return $s_val eq $c_val      if $c_ref eq "";
                return in([$s_val],$c_val)   if $c_ref eq 'ARRAY';
                return $c_val->($s_val)      if $c_ref eq 'CODE';
                return $c_val->call($s_val)  if $c_ref eq 'Switch';
                return scalar $s_val=~/$c_val/
                                             if $c_ref eq 'Regexp';
                return scalar $c_val->{$s_val}
                                             if $c_ref eq 'HASH';
                return;        
              };

It stands to reason that this has to be slow.

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: Sat, 01 May 2004 08:02:35 GMT
From: "luc" <anonymous@disneyland.com>
Subject: perl program
Message-Id: <vQIkc.92224$RL6.5878817@phobos.telenet-ops.be>

How can you start another program(perl program) from within the excel vba
code.




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

Date: Sat, 01 May 2004 10:35:56 +0100
From: Mark Clements <mark.clements@kcl.ac.uk>
Subject: Re: perl program
Message-Id: <40936f7d@news.kcl.ac.uk>

luc wrote:

> How can you start another program(perl program) from within the excel vba
> code.
> 
how about looking in the vba docs?

Mark


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

Date: 1 May 2004 00:54:44 -0700
From: chris_12003@yahoo.com (Chris)
Subject: Re: print $query->scrolling_list
Message-Id: <7f746dd.0404302354.49041a32@posting.google.com>

I found the answer I was looking for.  Thanks.

my %lables = (''=>'No',
              's'=>'Yes');

print $query->scrolling_list (
     -name=>'for_sale',
     -value=>['','s'],
     -default=>[''],
     -size=>2,
     -multiple=>'false',
     -labels=>\%lables);


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

Date: Fri, 30 Apr 2004 23:07:25 -0500
From: "Jerry Preston" <g-preston1@ti.com>
Subject: Re: reducing a regex
Message-Id: <c6v7qq$ons$1@home.itg.ti.com>

Sorry!

Basically I am looking a line with the following:



+: word : word word word : x-xxxxxxx-xx : = x word word [ x.xxx, xx.xx ]

Word can be any text with or with out numbers.

X are number only.

Jerry

"Jerry Preston" <g-preston1@ti.com> wrote in message
news:c6v4q9$m7j$1@home.itg.ti.com...
> Hi!
>
> I am trying to figure out how to reduce or simplify the following:
>
>
>
/\+:\s+(\w+)\s+:\s+(\w+)\s+(\w+)\s+(\w+)\s+:\s+(\d)-(\d+)-(\d+)\s+:\s+=\s+(\
> d+)\s+(\w+)\s+(\w+)\s+\[\s+(-?\d+.\d+),\s+(-?\d+.\d+)/;
>
> Any ideas?
>
> Thanks,
>
> Jerry
>
>




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

Date: 1 May 2004 07:05:01 GMT
From: anno4000@lublin.zrz.tu-berlin.de (Anno Siegel)
Subject: Re: reducing a regex
Message-Id: <c6vi6t$ol0$2@mamenchi.zrz.TU-Berlin.DE>

Jerry Preston <g-preston1@ti.com> wrote in comp.lang.perl.misc:
> Sorry!
> 
> Basically I am looking a line with the following:
> 
> +: word : word word word : x-xxxxxxx-xx : = x word word [ x.xxx, xx.xx ]
> 
> Word can be any text with or with out numbers.
> 
> X are number only.

Then why don't you give an example that your regex actually matches?

'+: word : word word word : 9-9999999-99 : = 9 word word [ 9.999, 99.99 ]'

would have worked.  What is still missing is any specification of what
in the example is variable and what is fixed, and which properties
you want the regex to check.

> > I am trying to figure out how to reduce or simplify the following:
> >
> /\+:\s+(\w+)\s+:\s+(\w+)\s+(\w+)\s+(\w+)\s+:\s+(\d)-(\d+)-(\d+)\s+:\s+=\s+(\
> > d+)\s+(\w+)\s+(\w+)\s+\[\s+(-?\d+.\d+),\s+(-?\d+.\d+)/;

You forgot to quote the two periods towards the end of the regex.  They
would match any character.

   my @matches =  /([\w.]+)/g;

extracts the same fields.  If it does what you want, I don't know.

Anno



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

Date: Sat, 01 May 2004 09:19:02 +0200
From: Gunnar Hjalmarsson <noreply@gunnar.cc>
Subject: Re: reducing a regex
Message-Id: <c6vjd7$fl68r$1@ID-184292.news.uni-berlin.de>

Jerry Preston wrote:
> Jerry Preston wrote:
>> I am trying to figure out how to reduce or simplify the
>> following:
>> 
>> /\+:\s+(\w+)\s+:\s+(\w+)\s+(\w+)\s+(\w+)\s+:\s+(\d)-(\d+)-(\d+)\s+:\s+=\s+(\
>>  d+)\s+(\w+)\s+(\w+)\s+\[\s+(-?\d+.\d+),\s+(-?\d+.\d+)/;
> 
> Basically I am looking a line with the following:
> 
> +: word : word word word : x-xxxxxxx-xx : = x word word [ x.xxx, xx.xx ]
> 
> Word can be any text with or with out numbers.
> 
> X are number only.

Okay. This would match:

     /^\+:.+\d\d\.\d\d \]$/

and it's simpler. But is it sufficient? I don't know.

If you want to capture all that, you *should* probably not try to
simplify it very much. But, as Sherm said, it can be written more clearly:

     my @array = m{
         \+:\s+
         (\w+)                 # First word
         \s+:\s+
         (\w+)\s+(\w+)\s+(\w+) # group of 3 words
         \s+:\s+
         (\d)-(\d+)-(\d+)      # article No.
         \s+:\s+=\s+
         (\d+)\s+(\w+)\s+(\w+) # ...
         \s+\[\s+
         (-?\d+.\d+)           # number
         ,\s+
         (-?\d+.\d+)           # last number
     }x;

HTH

-- 
Gunnar Hjalmarsson
Email: http://www.gunnar.cc/cgi-bin/contact.pl



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

Date: Sat, 01 May 2004 10:57:22 +0100
From: Mark Clements <mark.clements@kcl.ac.uk>
Subject: Re: search.pl
Message-Id: <40937483$1@news.kcl.ac.uk>

Robin wrote:


> I'll keep it in mind, I've never used either one, I tend to work with
> minimal modules because it's sometimes a compatibility issue with some
> servers using scripts that don't have the modules that I'm using...but
> thanks.
you could always install them... You don't need to have root access to 
install and use CPAN modules: they can be installed into eg ~/lib and 
used from there.

>>As far as the indenting goes, check out perltidy.
> I will check it out. See above.
ditto.

Mark


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

Date: 1 May 2004 08:42:43 GMT
From: anno4000@lublin.zrz.tu-berlin.de (Anno Siegel)
Subject: Re: use constant and BEGIN don't mix?
Message-Id: <c6vnu3$rq6$1@mamenchi.zrz.TU-Berlin.DE>

J Krugman  <jkrugman@yahbitoo.com> wrote in comp.lang.perl.misc:
> 
> 
> 
> If I try
> 
>   my %x;
>   BEGIN {
>     %x = %{ do '/path/to/some/file' };
>   }
> 
> ...where the file '/path/to/some/file' consists of the string
> "+{ A => 1}\n", then everything is fine, but if instead I do
> 
>   my %x;
>   BEGIN {
>     use constant DO_FILE => '/path/to/some/file';
>     %x = %{ do DO_FILE };
>   }
> 
> ...I get an error ("Can't use an undefined value as a HASH reference").
> (I get this error whether I place the "use constant" statement
> inside or before the BEGIN block.)
> 
> Is there no way to perform a do operation in a BEGIN block using
> a constant?  Can someone explain to me, please, what's going on?
> (Yes, I did read perlmod; it didn't help me with this one.)

The problem has to do with Perl's parsing of "do" statements.  With the
BLOCK and EXPR forms, plus the deprecated SUBROUTINE form, there is
a bit of ambiguity to resolve, and Perl gets it wrong here.  I'm not
sure what exactly is going on, but writing "do" with parentheses will
keep Perl on track:

    use constant DO_FILE => '/tmp/x';
    %x = %{ do( DO_FILE) };

will work, with or without BEGIN.

Anno


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

Date: Sat, 01 May 2004 15:19:16 +1000
From: Gregory Toomey <nospam@bigpond.com>
Subject: Re: what is purpose of 1; at end of scripts
Message-Id: <4284849.VjtD07nAih@GMT-hosting-and-pickle-farming>

Danny wrote:

> I notice a lot of scripts that have a 1; at the bottom.
> I am new to perl and trying to understand.
> 
> Usually at bottom of scripts that do something but do not print to a web
> page or print this 1;
> 
> Thanks in advance

Basicly, the last "executed statement" of a script should evaluate to true,
ie 1.

gtoomey


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

Date: 1 May 2004 05:29:20 GMT
From: sholden@flexal.cs.usyd.edu.au (Sam Holden)
Subject: Re: what is purpose of 1; at end of scripts
Message-Id: <slrnc96ddg.h89.sholden@flexal.cs.usyd.edu.au>

On Sat, 01 May 2004 15:19:16 +1000, Gregory Toomey <nospam@bigpond.com> wrote:
> Danny wrote:
> 
>> I notice a lot of scripts that have a 1; at the bottom.
>> I am new to perl and trying to understand.
>> 
>> Usually at bottom of scripts that do something but do not print to a web
>> page or print this 1;
>> 
>> Thanks in advance
> 
> Basicly, the last "executed statement" of a script should evaluate to true,
> ie 1.

Why?

That is the case for a module or a library, since otherwise it won't work,
but for a script it makes no difference at all what the result of the last
executed statement was.

-- 
Sam Holden


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

Date: Fri, 30 Apr 2004 23:44:14 -0500
From: Tad McClellan <tadmc@augustmail.com>
Subject: Re: what is purpose of 1; at end of scripts
Message-Id: <slrnc96aou.1k5.tadmc@magna.augustmail.com>

Danny <dannywork5@hotmail.com> wrote:

> I notice a lot of scripts that have a 1; at the bottom.


It is not needed in programs, it is needed in libraries.

Is that where you saw them?


> I am new to perl and trying to understand.


   perldoc -f require


      ... The file must return true as the last statement 
      to indicate successful execution of any initialization
      code, so it's customary to end such a file with "1;" unless
      you're sure it'll return true otherwise.  But it's better just
      to put the "1;", in case you add more statements.


> Usually at bottom of scripts that do something but do not print to a web
> page or print this 1;
          ^^^^^^^^^^^^

Oh. You must be talking about something else then...

 ... can't tell what else unless you show us the code you are asking about.


-- 
    Tad McClellan                          SGML consulting
    tadmc@augustmail.com                   Perl programming
    Fort Worth, Texas


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

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


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