[31176] in Perl-Users-Digest

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

Perl-Users Digest, Issue: 2421 Volume: 11

daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Sat May 16 03:09:44 2009

Date: Sat, 16 May 2009 00:09:08 -0700 (PDT)
From: Perl-Users Digest <Perl-Users-Request@ruby.OCE.ORST.EDU>
To: Perl-Users@ruby.OCE.ORST.EDU (Perl-Users Digest)

Perl-Users Digest           Sat, 16 May 2009     Volume: 11 Number: 2421

Today's topics:
        bug fuss to print the time including zone jidanni@jidanni.org
    Re: bug fuss to print the time including zone <someone@example.com>
    Re: comma operator <yankeeinexile@gmail.com>
    Re: comma operator <tadmc@seesig.invalid>
    Re: comma operator <ben@morrow.me.uk>
    Re: comma operator <jurgenex@hotmail.com>
    Re: DBI and fork <glex_no-spam@qwest-spam-no.invalid>
    Re: DBI and fork <hjp-usenet2@hjp.at>
    Re: Define alarm in threads <ben@morrow.me.uk>
    Re: Help with rename function <jurgenex@hotmail.com>
    Re: Help with rename function <tadmc@seesig.invalid>
    Re: My error log is growing dangerously large... <nospam@somewhere.com>
        new CPAN modules on Sat May 16 2009 (Randal Schwartz)
    Re: perl 5 grammar <tadmc@seesig.invalid>
    Re: perl 5 grammar <ben@morrow.me.uk>
    Re: perl 5 grammar <jurgenex@hotmail.com>
    Re: perl 5 grammar <nat.k@gm.ml>
    Re: perl 5 grammar (Randal L. Schwartz)
    Re: perl 5 grammar <mikesamuel@gmail.com>
        Digest Administrivia (Last modified: 6 Apr 01) (Perl-Users-Digest Admin)

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

Date: Sat, 16 May 2009 04:19:17 +0000 (UTC)
From: jidanni@jidanni.org
Subject: bug fuss to print the time including zone
Message-Id: <gules4$a7m$1@news.datemas.de>

Geez, to print the time including the timezone offset, it's either
print localtime() . " +0800\n"; #Hardwire it, or
print `date -R`;                #Expensive
Any other solution and were talking at least a three lines of code,
"use", etc. no?


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

Date: Fri, 15 May 2009 23:15:46 -0700
From: "John W. Krahn" <someone@example.com>
Subject: Re: bug fuss to print the time including zone
Message-Id: <mSsPl.41588$CN5.31628@newsfe23.iad>

jidanni@jidanni.org wrote:
> Geez, to print the time including the timezone offset, it's either
> print localtime() . " +0800\n"; #Hardwire it, or
> print `date -R`;                #Expensive
> Any other solution and were talking at least a three lines of code,
> "use", etc. no?

$ perl -le'use POSIX; print strftime "%F %T %z %Z", localtime'
2009-05-15 23:15:10 -0700 PDT


John
-- 
Those people who think they know everything are a great
annoyance to those of us who do.        -- Isaac Asimov


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

Date: Fri, 15 May 2009 15:15:25 -0500
From: Lawrence Statton <yankeeinexile@gmail.com>
Subject: Re: comma operator
Message-Id: <m1y6syazs2.fsf@mac.gateway.2wire.net>

Franken Sense <frank@example.invalid> writes:

>
>> and finally WTF is franken sense asking dumb sidebar questions and
>> getting answers. he needs to focus on learning perl and not obscure side
>> issues like comma ops and lvalues (i bet he doesn't even know what the term
>> lvalue means)
>
> Fuck off, Uri.  I'll bet you're an asshole in every time zone.

And to think I could have killfiled this clown this morning and not seen this.

*plonk*


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

Date: Fri, 15 May 2009 15:11:49 -0500
From: Tad J McClellan <tadmc@seesig.invalid>
Subject: Re: comma operator
Message-Id: <slrnh0rj45.f5h.tadmc@tadmc30.sbcglobal.net>

Franken Sense <frank@example.invalid> wrote:

> Fuck off


So long potty mouth.


-- 
Tad McClellan
email: perl -le "print scalar reverse qq/moc.noitatibaher\100cmdat/"


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

Date: Fri, 15 May 2009 23:19:18 +0100
From: Ben Morrow <ben@morrow.me.uk>
Subject: Re: comma operator
Message-Id: <6c61e6-9n1.ln1@osiris.mauzo.dyndns.org>


Quoth "Uri Guttman" <uri@PerlOnCall.com>:
> >>>>> "R" == RedGrittyBrick  <RedGrittyBrick@spamweary.invalid> writes:
> 
>   R> Franken Sense wrote:
>   >> 
>   >> 100) A comma operator does not yield an lvalue.
>   >> 
>   >> Is this also true in perl?
> 
>   C> perl -e "$x,$y = 42; print qq(x=$x, y=$y)"
>   R> x=, y=42
> 
> there is no lvalue in that first statement. comma binds lower than = so
> that was $x followed by $y = 42 which works. the problem is finding a
> way to have a comma operator which binds tighter than =. using parens
> won't work since that makes a list and it isn't a comma op anymore but a
> list element separator.

    ~% perl -E'my $x = "foo"; substr( (1, $x), 0, 1 ) = "g"; say $x'
    goo

So yes, the comma operator returns an lvalue.

Ben



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

Date: Fri, 15 May 2009 17:36:26 -0700
From: Jürgen Exner <jurgenex@hotmail.com>
Subject: Re: comma operator
Message-Id: <ej2s05p8gigi1506e9s4korjps6u94l1c2@4ax.com>

Franken Sense <frank@example.invalid> wrote:
>In Dread Ink, the Grave Hand of Uri Guttman Did Inscribe:
>
>> and finally WTF is franken sense asking dumb sidebar questions and
>> getting answers. he needs to focus on learning perl and not obscure side
>> issues like comma ops and lvalues (i bet he doesn't even know what the term
>> lvalue means)
>
>Fuck off, Uri.  I'll bet you're an asshole in every time zone.

Your request for entry into the killfile has been approved.

jue


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

Date: Fri, 15 May 2009 15:13:41 -0500
From: "J. Gleixner" <glex_no-spam@qwest-spam-no.invalid>
Subject: Re: DBI and fork
Message-Id: <4a0dccf5$0$87068$815e3792@news.qwest.net>

J. Gleixner wrote:
> shurikgefter@gmail.com wrote:
>> I create a DBI connection and after that run fork() command
>>
>> In the child process I close the DBI connection.
>>
>> Does it affected on parent process?
> 
> What happened whey you tried it?

s/whey/when/;

> 
> You should be able to answer that by actually taking the time
> to run your code.


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

Date: Sat, 16 May 2009 08:39:23 +0200
From: "Peter J. Holzer" <hjp-usenet2@hjp.at>
Subject: Re: DBI and fork
Message-Id: <slrnh0snst.97s.hjp-usenet2@hrunkner.hjp.at>

On 2009-05-15 19:53, J. Gleixner <glex_no-spam@qwest-spam-no.invalid> wrote:
> shurikgefter@gmail.com wrote:
>> I create a DBI connection and after that run fork() command
>> 
>> In the child process I close the DBI connection.
>> 
>> Does it affected on parent process?
>
> What happened whey you tried it?
>
> You should be able to answer that by actually taking the time
> to run your code.

No. If the test program crashes immediatly you know that the parent
process is affected. But what if works ok? You still don't know that a
more complex program will work, maybe under higher load.

What you should do is read perldoc DBI and search for "fork". You will
find this section:

       "InactiveDestroy" (boolean)

       The default value, false, means a handle will be fully destroyed as
       normal when the last reference to it is removed, just as you’d expect.

       If set true then the handle will be treated by the DESTROY as if it was
       no longer Active, and so the database engine related effects of
       DESTROYing a handle will be skipped.

       Think of the name as meaning ’treat the handle as not-Active in the
       DESTROY method’.

       For a database handle, this attribute does not disable an explicit call
       to the disconnect method, only the implicit call from DESTROY that
       happens if the handle is still marked as "Active".

       This attribute is specifically designed for use in Unix applications
       that "fork" child processes. Either the parent or the child process,
       but not both, should set "InactiveDestroy" true on all their shared
       handles.  (Note that some databases, including Oracle, don’t support
       passing a database connection across a fork.)

	hp


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

Date: Fri, 15 May 2009 23:23:09 +0100
From: Ben Morrow <ben@morrow.me.uk>
Subject: Re: Define alarm in threads
Message-Id: <dj61e6-9n1.ln1@osiris.mauzo.dyndns.org>


Quoth =?ISO-8859-1?Q?S=E9bastien_Cottalorda?= <scottalorda@libello.com>:
> I need to define an alarm like this.
> 
> eval {
>     my $thr = threads->new(\&run_cmd, params);
> };
> if ($@){
>     print "$@\n";
> }
> blah blah blah
> 
> 
> sub run_cmd {
>    blah blah blah
>    threads->detach();

If you detach the thread then the eval {} above will return before the
backticks are even tried. You won't see any errors. If you want to wait
in order to check for errors, you need to join the thread inside the
eval rather than detaching it.

>    eval {
>         local $SIG{ALRM} = sub { die "TIMEOUT\n" };

Which thread receives a signal is not, in general, defined. On some
systems it is possible to specify which thread gets a signal, but I
don't believe perl provides any interface to that functionality.

Use a separate thread that sleeps and then kills the first instead (be
careful about what happens if the first thread returns before the
timeout).

Ben



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

Date: Fri, 15 May 2009 13:09:11 -0700
From: Jürgen Exner <jurgenex@hotmail.com>
Subject: Re: Help with rename function
Message-Id: <rmir0554ir9dif5cc84aqgm3ml5l0f9nnk@4ax.com>

"mparker@ygptech.com" <mparker@ygptech.com> wrote:
>Hi all,
>
>I have a perl script that ftp's to a server and downloads a file
>everyday.  The file name is currently called ag051509.txt(051509 is
>the date and changes daily).  I need to rename that file to agents.txt
>using a script.  Since the name changes everyday I need to do
>something that is equivalent to ag*.txt in unix.  Is there something I
>can write that is close to -
>
>rename(ag*.txt, agents.txt)

Assuming there is exactly one matching file name

	($name) = glob('ag*.txt');
	rename($name, 'agents.txt');

jue


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

Date: Fri, 15 May 2009 15:23:20 -0500
From: Tad J McClellan <tadmc@seesig.invalid>
Subject: Re: Help with rename function
Message-Id: <slrnh0rjpo.f5h.tadmc@tadmc30.sbcglobal.net>

mparker@ygptech.com <mparker@ygptech.com> wrote:


> I have a perl script that ftp's to a server and downloads a file
> everyday.  The file name is currently called ag051509.txt(051509 is
> the date and changes daily).  


How do you know what filename to ask for when you do the FTP request?

Save that name in a variable and then use that variable later
to rename the file.


> I need to rename that file to agents.txt
> using a script.


Why "using a script"?

Why not "using the ftp program itself"?

    ftp -o agents.txt daboss@example.net/path/to/ag051509.txt


> I need to do


You think you need to, but you do not need to.


> something that is equivalent to ag*.txt in unix.  


The technical name for those ag*.txt thingies in unix is a "glob",
or more accurately, a "filename glob".


> Is there something I
> can write that is close to -
>
> rename(ag*.txt, agents.txt)


No, because rename() takes only 2 arguments, and ag*.txt may expand
to more than 1 filename.

Also no because strings need quotes around them.

    perldoc -f glob

You could use a List Slice to ensure that the glob returns only
one filename:

   rename( (glob 'ag*.txt')[0], 'agents.txt');


-- 
Tad McClellan
email: perl -le "print scalar reverse qq/moc.noitatibaher\100cmdat/"


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

Date: Fri, 15 May 2009 22:13:32 -0400
From: "Thrill5" <nospam@somewhere.com>
Subject: Re: My error log is growing dangerously large...
Message-Id: <gul7ge$erq$1@news.motzarella.org>


"Danish" <nigel@bouteyres.com> wrote in message 
news:554c063c-84db-4ae0-bafe-41b2565d3dd5@v17g2000vbb.googlegroups.com...
On May 15, 5:47 pm, Gunnar Hjalmarsson <nore...@gunnar.cc> wrote:
> Glenn Jackman wrote:
> > At 2009-05-15 09:13AM, "Nigel" wrote:
> >> 1. Do I understand from this that in Perl every variable should be
> >> initialised - not simply defined - before it is referenced? I use
> >> strict and all my varaibles are defined thus:
>
> >> my $foo;
>
> >> Should I be doing this instead:
>
> >> my $foo = "";
>
> > IMO you should either initialize your variables or at least check your
> > variables are defined() before referencing them.
> > print $foo if defined $foo;
>
> >> 2. Given that I've already written over seventy programs, many of
> >> which are many thousands of lines long, is there a safe way of
> >> stopping the error log filling up in this way...without going back and
> >> making major changes to all my programs?
>
> > If you don't want to fix your programs, turn off warnings.
>
> Or maybe just
>
> no warnings 'uninitialized';
>
> --
> Gunnar Hjalmarsson
> Email:http://www.gunnar.cc/cgi-bin/contact.pl- Hide quoted text -
>
> - Show quoted text -

)I think I know how to turn off warnings : remove the -w in the first
)line of each program, is that right?
)
)But where/how would I implement: no warnings 'uninitialised'?
)
)Thanks for all the help so far.
)
)Nigel

use warnings;
no warnings 'uninitialized';

Note that 'uninitialized' is the American English spelling using a 'z', not 
the Kings English with an 's'.





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

Date: Sat, 16 May 2009 04:42:28 GMT
From: merlyn@stonehenge.com (Randal Schwartz)
Subject: new CPAN modules on Sat May 16 2009
Message-Id: <KJpzqs.ty0@zorch.sf-bay.org>

The following modules have recently been added to or updated in the
Comprehensive Perl Archive Network (CPAN).  You can install them using the
instructions in the 'perlmodinstall' page included with your Perl
distribution.

Acme-Damn-0.04
http://search.cpan.org/~ibb/Acme-Damn-0.04/
'Unbless' Perl objects. 
----
Acme-ReturnValue-0.70.0
http://search.cpan.org/~domm/Acme-ReturnValue-0.70.0/
report interesting module return values 
----
Audio-Ecasound-Multitrack-0.997
http://search.cpan.org/~ganglion/Audio-Ecasound-Multitrack-0.997/
Perl extensions for multitrack audio processing 
----
Bot-WootOff-0.02
http://search.cpan.org/~mschilli/Bot-WootOff-0.02/
Poll woot.com during a woot-off and notify via IRC 
----
Cache-Ehcache-0.01
http://search.cpan.org/~yamamoto/Cache-Ehcache-0.01/
client library for Ehcache Server 
----
DBIx-Class-ResultSet-RecursiveUpdate-v0.006
http://search.cpan.org/~zby/DBIx-Class-ResultSet-RecursiveUpdate-v0.006/
like update_or_create - but recursive 
----
DBIx-Class-ResultSet-RecursiveUpdate-v0.007
http://search.cpan.org/~zby/DBIx-Class-ResultSet-RecursiveUpdate-v0.007/
like update_or_create - but recursive 
----
DBIx-Locker-0.091350
http://search.cpan.org/~rjbs/DBIx-Locker-0.091350/
locks for db resources that might not be totally insane 
----
Data-Pond-0.001
http://search.cpan.org/~zefram/Data-Pond-0.001/
Perl-based open notation for data 
----
DateTimeX-Easy-0.087
http://search.cpan.org/~rkrimen/DateTimeX-Easy-0.087/
Parse a date/time string using the best method available 
----
Diff-LibXDiff-0.02
http://search.cpan.org/~rkrimen/Diff-LibXDiff-0.02/
Calculate a diff with LibXDiff (via XS) 
----
Directory-Deploy-0.002
http://search.cpan.org/~rkrimen/Directory-Deploy-0.002/
Create files and directories on disk 
----
Elive-0.18
http://search.cpan.org/~warringd/Elive-0.18/
Elluminate Live (c) client library 
----
Getopt-Chain-0.011
http://search.cpan.org/~rkrimen/Getopt-Chain-0.011/
Command-line processing like svn and git 
----
Getopt-Chain-0.012
http://search.cpan.org/~rkrimen/Getopt-Chain-0.012/
Command-line processing like svn and git 
----
HTML-Shakan-0.02
http://search.cpan.org/~tokuhirom/HTML-Shakan-0.02/
form html generator/validator 
----
Jifty-Plugin-Authentication-CAS-0.9
http://search.cpan.org/~yvesago/Jifty-Plugin-Authentication-CAS-0.9/
JA-SIG CAS authentication plugin for Jifty 
----
Jifty-Plugin-Authentication-Ldap-0.9
http://search.cpan.org/~yvesago/Jifty-Plugin-Authentication-Ldap-0.9/
LDAP Authentication Plugin for Jifty 
----
Jifty-Plugin-AuthzLDAP-0.9
http://search.cpan.org/~yvesago/Jifty-Plugin-AuthzLDAP-0.9/
Jifty plugin to a add dynamic ldap authorization 
----
Jifty-Plugin-WikiToolbar-0.9
http://search.cpan.org/~yvesago/Jifty-Plugin-WikiToolbar-0.9/
Jifty plugin to add a wiki toolbar to your textarea box 
----
LW4-Reader-0.01
http://search.cpan.org/~tambascot/LW4-Reader-0.01/
Perl extension for reading Lightwright 4 files. 
----
Math-Primality-0.02
http://search.cpan.org/~leto/Math-Primality-0.02/
Advanced Primality Algorithms using GMP 
----
Math-Units-PhysicalValue-1.0007
http://search.cpan.org/~jettero/Math-Units-PhysicalValue-1.0007/
An OO interface for automatically calculating values with units. 
----
Module-Install-GithubMeta-0.08
http://search.cpan.org/~bingos/Module-Install-GithubMeta-0.08/
A Module::Install extension to include GitHub meta information in META.yml 
----
Module-Install-ProvidesClass-0.000001_99
http://search.cpan.org/~ash/Module-Install-ProvidesClass-0.000001_99/
provides detection in META.yml for 'class' keyword 
----
MoneyWorks-pm-0.01
http://search.cpan.org/~sprout/MoneyWorks-pm-0.01/
----
MooseX-Has-Sugar-0.0100
http://search.cpan.org/~kentnl/MooseX-Has-Sugar-0.0100/
Sugar Syntax for moose 'has' fields. 
----
MooseX-MethodAttributes-0.11
http://search.cpan.org/~flora/MooseX-MethodAttributes-0.11/
code attribute introspection 
----
Net-Twitter-OAuth-0.03
http://search.cpan.org/~miyagawa/Net-Twitter-OAuth-0.03/
Net::Twitter subclass that uses OAuth instead of Basic Auth 
----
Outline-Lua-0.01
http://search.cpan.org/~altreus/Outline-Lua-0.01/
Not Inline! 
----
Outline-Lua-0.02
http://search.cpan.org/~altreus/Outline-Lua-0.02/
Run Lua code from a string, rather than embedded. 
----
PDF-Burst-1.17
http://search.cpan.org/~leocharre/PDF-Burst-1.17/
create one pdf doc for each page in existing pdf document 
----
PDL-2.4.4_02
http://search.cpan.org/~chm/PDL-2.4.4_02/
the Perl Data Language 
----
POE-Component-SmokeBox-0.26
http://search.cpan.org/~bingos/POE-Component-SmokeBox-0.26/
POE enabled CPAN smoke testing with added value. 
----
Parse-Stallion-0.85
http://search.cpan.org/~arthur/Parse-Stallion-0.85/
EBNF based regexp backtracking parser and tree evaluator. 
----
Perl-Critic-Moose-0.999_002
http://search.cpan.org/~elliotjs/Perl-Critic-Moose-0.999_002/
Policies for Perl::Critic concerned with using Moose, the "post-modern" object system for Perl. 
----
RT-Extension-DateDiscordian-0.01
http://search.cpan.org/~falcone/RT-Extension-DateDiscordian-0.01/
Allows non-relative dates to be displayed as Discordian 
----
Rose-DBx-Object-Renderer-0.50
http://search.cpan.org/~danny/Rose-DBx-Object-Renderer-0.50/
Web UI Rendering for Rose::DB::Object 
----
SOAP-WSDL-2.00.10
http://search.cpan.org/~mkutter/SOAP-WSDL-2.00.10/
SOAP with WSDL support 
----
Schedule-Load-3.062
http://search.cpan.org/~wsnyder/Schedule-Load-3.062/
Load distribution and status across multiple host machines 
----
Statistics-Test-WilcoxonRankSum-0.0.4
http://search.cpan.org/~ingrif/Statistics-Test-WilcoxonRankSum-0.0.4/
perform the Wilcoxon (aka Mann-Whitney) rank sum test on two sets of numeric data. 
----
Sys-CPU-0.50
http://search.cpan.org/~mzsanford/Sys-CPU-0.50/
Perl extension for getting CPU information. Currently only number of CPU's supported. 
----
Task-Lingua-Any-Numbers-0.14
http://search.cpan.org/~burak/Task-Lingua-Any-Numbers-0.14/
Installs all number to word modules. 
----
Test-Apache2-0.04
http://search.cpan.org/~kzys/Test-Apache2-0.04/
Simple test harness of mod_perl handler 
----
Test-DistManifest-1.2.0
http://search.cpan.org/~frequency/Test-DistManifest-1.2.0/
Verify MANIFEST/MANIFEST.SKIP as an author test 
----
Test-DistManifest-1.2.1
http://search.cpan.org/~frequency/Test-DistManifest-1.2.1/
Verify MANIFEST/MANIFEST.SKIP as an author test 
----
Test-DistManifest-1.2.2
http://search.cpan.org/~frequency/Test-DistManifest-1.2.2/
Verify MANIFEST/MANIFEST.SKIP as an author test 
----
Test-File-1.26
http://search.cpan.org/~bdfoy/Test-File-1.26/
test file attributes 
----
Test-Output-0.16
http://search.cpan.org/~bdfoy/Test-Output-0.16/
Utilities to test STDOUT and STDERR messages. 
----
Text-CSV_XS-0.65
http://search.cpan.org/~hmbrand/Text-CSV_XS-0.65/
comma-separated values manipulation routines 
----
Text-RewriteRules-0.20
http://search.cpan.org/~ambs/Text-RewriteRules-0.20/
A system to rewrite text using regexp-based rules 
----
Variable-Magic-0.35
http://search.cpan.org/~vpit/Variable-Magic-0.35/
Associate user-defined magic to variables from Perl. 
----
WWW-Wikipedia-TemplateFiller-0.13
http://search.cpan.org/~diberri/WWW-Wikipedia-TemplateFiller-0.13/
Fill Wikipedia templates with your eyes closed 
----
Yahoo-Marketing-5.05
http://search.cpan.org/~shenj/Yahoo-Marketing-5.05/
an interface for Yahoo! Search Marketing's Web Services. 
----
local-lib-1.004000
http://search.cpan.org/~apeiron/local-lib-1.004000/
create and use a local lib/ for perl modules with PERL5LIB 


If you're an author of one of these modules, please submit a detailed
announcement to comp.lang.perl.announce, and we'll pass it along.

This message was generated by a Perl program described in my Linux
Magazine column, which can be found on-line (along with more than
200 other freely available past column articles) at
  http://www.stonehenge.com/merlyn/LinuxMag/col82.html

print "Just another Perl hacker," # the original

--
Randal L. Schwartz - Stonehenge Consulting Services, Inc. - +1 503 777 0095
<merlyn@stonehenge.com> <URL:http://www.stonehenge.com/merlyn/>
Smalltalk/Perl/Unix consulting, Technical writing, Comedy, etc. etc.
See http://methodsandmessages.vox.com/ for Smalltalk and Seaside discussion


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

Date: Fri, 15 May 2009 15:09:47 -0500
From: Tad J McClellan <tadmc@seesig.invalid>
Subject: Re: perl 5 grammar
Message-Id: <slrnh0rj0b.f5h.tadmc@tadmc30.sbcglobal.net>

Jürgen Exner <jurgenex@hotmail.com> wrote:
> Mike Samuel <mikesamuel@gmail.com> wrote:

>>I know perl has a complex grammar, but can someone point me at a
>>simple lexical grammar for perl 5 that will allow me to at least
>>identify comment, string, and regex boundaries?

> Comments are easy: anything following a # sign in the same line or
> anything enclosed as POD.


But not as easy as you describe:

   $str =~ m#no comment here#;

   print "no#comment#here#either\n";

   print q#not a comment#;

:-(


-- 
Tad McClellan
email: perl -le "print scalar reverse qq/moc.noitatibaher\100cmdat/"


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

Date: Fri, 15 May 2009 23:30:51 +0100
From: Ben Morrow <ben@morrow.me.uk>
Subject: Re: perl 5 grammar
Message-Id: <r171e6-9n1.ln1@osiris.mauzo.dyndns.org>


Quoth Mike Samuel <mikesamuel@gmail.com>:
> I maintain the syntax highlighter for code.google.com and perl support
> is rather lacking.
> 
> I know perl has a complex grammar, but can someone point me at a
> simple lexical grammar for perl 5 that will allow me to at least
> identify comment, string, and regex boundaries?

I find vim's syntax highlighting perfectly adequate, and it's not too
complex (unlike using PPI or the code from cperl-mode). It's possible to
confuse it, but most 'ordinary' code is highlighted correctly. 

Ben



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

Date: Fri, 15 May 2009 17:38:57 -0700
From: Jürgen Exner <jurgenex@hotmail.com>
Subject: Re: perl 5 grammar
Message-Id: <pm2s05d8rd71gjr1199ggp871ncohm6357@4ax.com>

Tad J McClellan <tadmc@seesig.invalid> wrote:
>Jürgen Exner <jurgenex@hotmail.com> wrote:
>> Comments are easy: anything following a # sign in the same line or
>> anything enclosed as POD.
>
>
>But not as easy as you describe:
>
>   $str =~ m#no comment here#;
>
>   print "no#comment#here#either\n";
>
>   print q#not a comment#;

Oh man, why do you always have to find those pesky special cases? 
Thanks for pointing this out, you are absolutely right, of course.

jue


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

Date: Fri, 15 May 2009 17:51:58 -0700
From: Nathan Keel <nat.k@gm.ml>
Subject: Re: perl 5 grammar
Message-Id: <P6oPl.32279$CN5.8282@newsfe23.iad>

Jürgen Exner wrote:

> Tad J McClellan <tadmc@seesig.invalid> wrote:
>>Jürgen Exner <jurgenex@hotmail.com> wrote:
>>> Comments are easy: anything following a # sign in the same line or
>>> anything enclosed as POD.
>>
>>
>>But not as easy as you describe:
>>
>>   $str =~ m#no comment here#;
>>
>>   print "no#comment#here#either\n";
>>
>>   print q#not a comment#;
> 
> Oh man, why do you always have to find those pesky special cases?
> Thanks for pointing this out, you are absolutely right, of course.
> 
> jue

I don't think a # character in a string is that special of a case, but
you surely knew all of what Tad posted anyway.


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

Date: Fri, 15 May 2009 18:28:28 -0700
From: merlyn@stonehenge.com (Randal L. Schwartz)
To: Mike Samuel <mikesamuel@gmail.com>
Subject: Re: perl 5 grammar
Message-Id: <86fxf525vn.fsf@blue.stonehenge.com>

>>>>> "Mike" == Mike Samuel <mikesamuel@gmail.com> writes:

Mike> I maintain the syntax highlighter for code.google.com and perl support
Mike> is rather lacking.

Mike> I know perl has a complex grammar, but can someone point me at a
Mike> simple lexical grammar for perl 5 that will allow me to at least
Mike> identify comment, string, and regex boundaries?

Can't be done at a static level.  Ever.

Proof is at http://www.perlmonks.org/index.pl?node_id=44722

The best you can do is say "this is likely 95% correct for 95% of the test
cases I've thought of".

And I'd be willing to bet you that if you show me a static lexer, I can find a
valid Perl program that will break it within a few minutes.  And probably
even likely in someone's production code. :)

print "Just another Perl hacker,"; # the original

-- 
Randal L. Schwartz - Stonehenge Consulting Services, Inc. - +1 503 777 0095
<merlyn@stonehenge.com> <URL:http://www.stonehenge.com/merlyn/>
Smalltalk/Perl/Unix consulting, Technical writing, Comedy, etc. etc.
See http://methodsandmessages.vox.com/ for Smalltalk and Seaside discussion


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

Date: Fri, 15 May 2009 19:25:02 -0700 (PDT)
From: Mike Samuel <mikesamuel@gmail.com>
Subject: Re: perl 5 grammar
Message-Id: <8cfd96ee-8dbb-45fc-b555-a7a870488b31@f28g2000pra.googlegroups.com>

On May 15, 6:28=A0pm, mer...@stonehenge.com (Randal L. Schwartz) wrote:
> >>>>> "Mike" =3D=3D Mike Samuel <mikesam...@gmail.com> writes:
>
> Mike> I maintain the syntax highlighter for code.google.com and perl supp=
ort
> Mike> is rather lacking.
>
> Mike> I know perl has a complex grammar, but can someone point me at a
> Mike> simple lexical grammar for perl 5 that will allow me to at least
> Mike> identify comment, string, and regex boundaries?
>
> Can't be done at a static level. =A0Ever.
>
> Proof is athttp://www.perlmonks.org/index.pl?node_id=3D44722
>
> The best you can do is say "this is likely 95% correct for 95% of the tes=
t
> cases I've thought of".

> And I'd be willing to bet you that if you show me a static lexer, I can f=
ind a
> valid Perl program that will break it within a few minutes. =A0And probab=
ly
> even likely in someone's production code. :)

Thanks for the explanation all.

Ecmascript has the same property where a regular lexical grammar is
impossible since the meaning of '/' depends on the production.
But in Ecmascript, there is a lexical grammar that is correct for all
programs a non-malicious coder is likely to write.  There are a few
places where this breaks down like (a++/b/i) vs (a =3D ++/b/i) but the
latter is useless.

But in perl, these syntactic irregularities show up frequently in
production code?

Is there a 95% solution that seems to work reasonably well?


> print "Just another Perl hacker,"; # the original
>
> --
> Randal L. Schwartz - Stonehenge Consulting Services, Inc. - +1 503 777 00=
95
> <mer...@stonehenge.com> <URL:http://www.stonehenge.com/merlyn/>
> Smalltalk/Perl/Unix consulting, Technical writing, Comedy, etc. etc.
> Seehttp://methodsandmessages.vox.com/for Smalltalk and Seaside discussion



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

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 V11 Issue 2421
***************************************


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