[29306] in Perl-Users-Digest

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

Perl-Users Digest, Issue: 550 Volume: 11

daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Thu Jun 21 16:10:07 2007

Date: Thu, 21 Jun 2007 13:09:13 -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           Thu, 21 Jun 2007     Volume: 11 Number: 550

Today's topics:
    Re: FAQ 1.6 What is perl6? <purlgurl@purlgurl.net>
    Re: FAQ 1.6 What is perl6? (Randal L. Schwartz)
        File::Find losing one file? <seven.reeds@gmail.com>
    Re: File::Find losing one file? <seven.reeds@gmail.com>
    Re: File::Find losing one file? <brian.helterline@hp.com>
    Re: File::Find losing one file? <asuter@cisco.com>
    Re: File::Find losing one file? <purlgurl@purlgurl.net>
    Re: How can I use the string variable expansion for OO  <ilias@lazaridis.com>
    Re: looking to prototype a grammar need suggestions. <bpatton@ti.com>
        MASON getting arguments. <bpatton@ti.com>
    Re: Need help reading two-dimentional array from a file <jgibson@mail.arc.nasa.gov>
    Re: Need help reading two-dimentional array from a file <uri@stemsystems.com>
    Re: The Modernization of Emacs <martin@see.sig.for.address>
    Re: The Modernization of Emacs: terminology buffer and  <garrickp@gmail.com>
    Re: Trying to make sense of perl for web development.  trudge@gmail.com
    Re: Which Perl 5 OO extension can be seen as "standard" <ilias@lazaridis.com>
        Digest Administrivia (Last modified: 6 Apr 01) (Perl-Users-Digest Admin)

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

Date: Thu, 21 Jun 2007 12:19:46 -0700
From: Purl Gurl <purlgurl@purlgurl.net>
Subject: Re: FAQ 1.6 What is perl6?
Message-Id: <feqdnYzkhsjIUufbnZ2dnUVZ_rKvnZ2d@giganews.com>

PerlFAQ Server wrote:

> 1.6: What is perl6?

Bloatware Vaporware.


>     "We're really serious about reinventing everything that needs
>     reinventing." --Larry Wall


Now hold on there just a minute! A few days back some of the childish
False Gods of Perl around here were screaming their heads off about,
"not reinventing the wheel."

I'll be damn, there is Larry Wall confessing to "reinventing the wheel."

Sic 'em boys! Chase Wall down, bark at him, yell at him about how he
is not to "reinvent the wheel."

Ha! You boys are such ignorant hypocrites.

BARK! BARK! BARK!


-- 
Purl Gurl
--
"Then again what can you expect from a fat-assed, champagne swilling,
  half-breed just off the Rez?"
   - Joe Kline


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

Date: Thu, 21 Jun 2007 12:53:23 -0700
From: merlyn@stonehenge.com (Randal L. Schwartz)
Subject: Re: FAQ 1.6 What is perl6?
Message-Id: <86tzt1dqz0.fsf@blue.stonehenge.com>

>>>>> "Purl" == Purl Gurl <purlgurl@purlgurl.net> writes:

>> "We're really serious about reinventing everything that needs
>> reinventing." --Larry Wall


Purl> Now hold on there just a minute! A few days back some of the childish
Purl> False Gods of Perl around here were screaming their heads off about,
Purl> "not reinventing the wheel."

Purl> I'll be damn, there is Larry Wall confessing to "reinventing the wheel."

I've never told people not to reinvent the wheel, if I was absolutely sure
they were completely familiar with the wheel they were reinventing.

In this case, I'm pretty sure that Larry is familiar with the wheel
he is reinventing.  Heck, he invented most of it in the first place.

Put your "wand of unjustified comparisons" back in its sheath.

-- 
Randal L. Schwartz - Stonehenge Consulting Services, Inc. - +1 503 777 0095
<merlyn@stonehenge.com> <URL:http://www.stonehenge.com/merlyn/>
Perl/Unix/security consulting, Technical writing, Comedy, etc. etc.
See PerlTraining.Stonehenge.com for onsite and open-enrollment Perl training!

-- 
Posted via a free Usenet account from http://www.teranews.com



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

Date: Thu, 21 Jun 2007 11:23:02 -0700
From:  "seven.reeds" <seven.reeds@gmail.com>
Subject: File::Find losing one file?
Message-Id: <1182450182.548617.152000@c77g2000hse.googlegroups.com>

Hi,

I have a directory hierarcy that is holding some "news" articles [a
local term for some loosely related files].  The hierarchy is based on
the date of creation: ./YYYY/MM/DD/<article_number>.news

I am using File::Find to crawl through the dirs to find the ".news"
files.  As it finds a news file it appends the full pathname to an
array.  I know that there are X news files in the tree but  (X-1) are
ever returned from File::Find.

Ideas are welcome, please

I am doing:

use File::Find;
my @articles = ();
find({wanted     => \&findArticle,  no_chdir   => 1}, ".");
warn "#### $#articles\n";
 ...

sub findArticle()
{
    if (-f && /\d+.news/)
    {
        push(@articles, $_);
    }
}



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

Date: Thu, 21 Jun 2007 11:58:32 -0700
From:  "seven.reeds" <seven.reeds@gmail.com>
Subject: Re: File::Find losing one file?
Message-Id: <1182452312.442328.35570@k79g2000hse.googlegroups.com>

nevermind.  It is my fault.  There is not a problem

cheers



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

Date: Thu, 21 Jun 2007 12:02:00 -0700
From: Brian Helterline <brian.helterline@hp.com>
Subject: Re: File::Find losing one file?
Message-Id: <f5ehvb$np8$1@usenet01.boi.hp.com>

seven.reeds wrote:
> Hi,
> 
> I have a directory hierarcy that is holding some "news" articles [a
> local term for some loosely related files].  The hierarchy is based on
> the date of creation: ./YYYY/MM/DD/<article_number>.news
> 
> I am using File::Find to crawl through the dirs to find the ".news"
> files.  As it finds a news file it appends the full pathname to an
> array.  I know that there are X news files in the tree but  (X-1) are
> ever returned from File::Find.
> 
> Ideas are welcome, please
> 
> I am doing:
> 
> use File::Find;
> my @articles = ();
> find({wanted     => \&findArticle,  no_chdir   => 1}, ".");
> warn "#### $#articles\n";

$#articles returns the last index of @articles which is X-1 elements
in the array since arrays start with index 0.

If you want the number of elements in @articles, evaluate the array in 
scalar context;

my $nelements = @articles;
or
my $nelemenets = $#articles + 1;


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

Date: Thu, 21 Jun 2007 12:02:20 -0700
From: "Asim Suter" <asuter@cisco.com>
Subject: Re: File::Find losing one file?
Message-Id: <1182452542.638151@sj-nntpcache-2.cisco.com>


"seven.reeds" <seven.reeds@gmail.com> wrote in message 
news:1182450182.548617.152000@c77g2000hse.googlegroups.com...
> Hi,
>
> I have a directory hierarcy that is holding some "news" articles [a
> local term for some loosely related files].  The hierarchy is based on
> the date of creation: ./YYYY/MM/DD/<article_number>.news
>
> I am using File::Find to crawl through the dirs to find the ".news"
> files.  As it finds a news file it appends the full pathname to an
> array.  I know that there are X news files in the tree but  (X-1) are
> ever returned from File::Find.
>
> Ideas are welcome, please
>
> I am doing:
>
> use File::Find;
> my @articles = ();
> find({wanted     => \&findArticle,  no_chdir   => 1}, ".");
> warn "#### $#articles\n";
> ...
>
> sub findArticle()
> {
>    if (-f && /\d+.news/)
>    {
>        push(@articles, $_);
>    }
> }
>

Because array index starts at zero ? ;-)

Regards.
Asim Suter 




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

Date: Thu, 21 Jun 2007 12:02:40 -0700
From: Purl Gurl <purlgurl@purlgurl.net>
Subject: Re: File::Find losing one file?
Message-Id: <VNqdnaw35tPPVufbnZ2dnUVZ_sCinZ2d@giganews.com>

seven.reeds wrote:

(snipped)

> I am using File::Find to crawl through the dirs to find the ".news"
> files.  As it finds a news file it appends the full pathname to an
> array.  I know that there are X news files in the tree but  (X-1) are
> ever returned from File::Find.

> warn "#### $#articles\n";

warn scalar (@articles), "\n";

$#articles will be one less than the actual number
of elements in your array. This is the index number
of the last element, which begins with zero for the
first element.

Use of scalar() will return the actual number of elements.


#!perl

@Array = qw (one two three);

warn "$#Array\n";

warn scalar (@Array), "\n";


PRINTED RESULTS:

2
3


-- 
Purl Gurl
--
"Then again what can you expect from a fat-assed, champagne swilling,
  half-breed just off the Rez?"
   - Joe Kline


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

Date: Thu, 21 Jun 2007 12:32:17 -0700
From:  Ilias Lazaridis <ilias@lazaridis.com>
Subject: Re: How can I use the string variable expansion for OO "$self->attribute"
Message-Id: <1182454337.265345.60090@p77g2000hsh.googlegroups.com>


            Dr.Ruud       :
> Ilias Lazaridis schreef:
>
> > So, it seems if I want to have somethin other like
> >
> > return sprintf "%s: %s", $self->label, $self->val($attrib);
> >
> > that I have to code myself something like e.g.:
> >
> > return sip "$self->label: $self->val($attrib)";
>
> See also `perldoc overload`.

http://www.tu-chemnitz.de/docs/perldoc-html/overload.html

looks very interesting.

btw: can I actually overload the "@" and "%", too - thus my custom
Array/Hash class is used?

 .

--
http://dev.lazaridis.com/lang/ticket/13



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

Date: Thu, 21 Jun 2007 11:42:54 -0700
From:  bpatton <bpatton@ti.com>
Subject: Re: looking to prototype a grammar need suggestions.
Message-Id: <1182451374.583618.285070@p77g2000hsh.googlegroups.com>

On Jun 21, 3:19 am, Grehom <gre...@ntlworld.com> wrote:
> On 20 Jun, 14:44, bpatton <bpat...@ti.com> wrote:
>
>
>
> > I do regression testing for rule sets of IC layout verification.
> > The current rule sets are written in a doc file in complete free form
> > and useless to try and parse.  Different people say the same thing in
> > different words.
> > I'm looking to create a prototype grammar for describing the rules.
> > The majority will be very simple, others will be quite complex and
> > contain many pseudo layers.  Here's a couple of examples and some
> > explanation
>
> > CONT size = 100 x 100
> > MET1 overlap CONT = 50
> > BOGUS = CONT common to MET1  <-- psuedo layer  created from the "and"
> > of 2 other layers that may or may not be pseudo layers
>
> > I've already done some data generation on by simply calling a routine
> > sub common(layer1,layer2,width,height) {
> > draw something
>
> > }
>
> > This is simple and too limited.  At the very bottom this routine will
> > have to exist, it's the calling of this routine. making the decisions
> > on which routines to call and in what order.  I've considered CLIPS
> > but the problem still exists, no matter what language or platform.
> > How to describe a rule in a strict grammer so that a computer language
> > can break it apart and act upon the grammar according to the order and
> > specific words.
>
> > I'm thinking that I need to have a list of
> > Noun    -> layer and pseudo layer names  (CONT,MET1,BOGUS)
> > verb        -> denotes an action   ( overlap, extends into,
> > touching ,...)
> > adjective  -> to modify a noun or pronoun
> > pronoun   -> substitutes for a noun or noun phrase with or without a
> > determiner, such as you and they
>
> > The idea is to supply a set of values for each of the 4 grammar
> > categories and use only these to describe the rules.
> > The nouns are the only section that is eligible to grow by the rule
> > coder.
>
> > >From this controlled grammar, I would then generate layout data to the
>
> > specifications of the grammer
>
> In my opinion you could do a lot worse than by taking a look at Damian
> Conway's 'Parse::RecDescent'.  I'm certainly no rocket scientist, but
> I find this grammar very useful where I want to do a bit more than I
> can comfortably manage using regexps.

Just got through reading the pod.  I do believe this is where I'll
start.  I'll know more after I get into it more.  But it looks like
what I want.  If nothing else it will relieve the possible hundreds of
if/the/else this I would likely have.

Now to get me some test data and start prototyping.



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

Date: Thu, 21 Jun 2007 13:05:36 -0700
From:  bpatton <bpatton@ti.com>
Subject: MASON getting arguments.
Message-Id: <1182456336.122173.168990@k79g2000hse.googlegroups.com>

I know that all the values passed into a module are in @_
assume @_ looks like [ c , 3 , d , 4 ]
But between
<%args>
$a => 1;
$b => 2;
</%args>

How do I get the variables $a and $b and their values when they may
not have been passed in?



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

Date: Thu, 21 Jun 2007 11:10:23 -0700
From: Jim Gibson <jgibson@mail.arc.nasa.gov>
Subject: Re: Need help reading two-dimentional array from a file
Message-Id: <210620071110237829%jgibson@mail.arc.nasa.gov>

In article <x7bqfaug4r.fsf@mail.sysarch.com>, Uri Guttman
<uri@stemsystems.com> wrote:

> >>>>> "AS" == Asim Suter <asuter@cisco.com> writes:
> 
>   AS> Which is slurping the whole file in one shot. Gone will be the days of 
> { 
>   AS> local $/; <DATA >} idiom.
> 
> that idiom is gone now. use File::Slurp.

I must respectfully disagree. That idiom is far from dead. Pulling in a
744-line module to replace one, easily-comprehensible line of code
doesn't make sense to me.

-- 
Jim Gibson

 Posted Via Usenet.com Premium Usenet Newsgroup Services
----------------------------------------------------------
    ** SPEED ** RETENTION ** COMPLETION ** ANONYMITY **
----------------------------------------------------------        
                http://www.usenet.com


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

Date: Thu, 21 Jun 2007 19:02:55 GMT
From: Uri Guttman <uri@stemsystems.com>
Subject: Re: Need help reading two-dimentional array from a file
Message-Id: <x7lkedruzk.fsf@mail.sysarch.com>

>>>>> "JG" == Jim Gibson <jgibson@mail.arc.nasa.gov> writes:

  JG> In article <x7bqfaug4r.fsf@mail.sysarch.com>, Uri Guttman
  JG> <uri@stemsystems.com> wrote:

  >> >>>>> "AS" == Asim Suter <asuter@cisco.com> writes:
  >> 
  AS> Which is slurping the whole file in one shot. Gone will be the days of 
  >> { 
  AS> local $/; <DATA >} idiom.
  >> 
  >> that idiom is gone now. use File::Slurp.

  JG> I must respectfully disagree. That idiom is far from dead. Pulling in a
  JG> 744-line module to replace one, easily-comprehensible line of code
  JG> doesn't make sense to me.

you consider this:

open my $fh, $filename or die "can't open $filename ;
my $text = do { local $/; <$fh> }
close $fh ;

clearer and a better idiom than:

use File::Slurp ;
my $text = read_file( $filename ) ;


i find that hard to believe. most newbies will not know how to set $/ or
do it right. you need more in the idiom to handle opening files (local
@ARGV is another wacky trick for that).

also file::slurp is faster in most cases, has more flexibilty in how it
returns the data and also has other functions such as write_file and
append_file. if i can get work done at the yapc hackathon it will have
prepend_file, edit_file and edit_file_line added as well as a speedup
for slurping smaller files.

and many CPAN modules already use File::Slurp as well as many private
programs. they must like it for a reason.

your choice.

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: Thu, 21 Jun 2007 19:26:00 +0100
From: Martin Gregorie <martin@see.sig.for.address>
Subject: Re: The Modernization of Emacs
Message-Id: <vesqk4-5v5.ln1@zoogz.gregorie.org>

Bjorn Borud wrote:
> [Martin Gregorie <martin@see.sig.for.address>]
> | 
> | As for documentation, lets look at vi. Not a great editor, but every
> | *nix variation has it installed and any fool can learn to use it in
> | about 2 hours flat and it does at least have good pattern matching.
> 
> there's also the "info" system in Emacs, which not only covers Emacs
> itself, but usually also a lot of documentation available for Emacs
> extensions and other programs.  again, this predates a lot of things
> that people are used to today, so just because it seems (and sometimes
> is) a bit more fiddly, it must necessarily be inferior.
>
I thought it might be in "info", like most GNUish things but I couldn't 
check because I don't have it installed.

> for instance, Linux has come a long way in addressing the needs of
> desktop users, yet some people refuse to use Linux because it doesn't
> behave *exactly* like Windows (as if that was a worthwhile goal) and
> they are too lazy or don't think they can manage, to learn a new
> system.
> 
Yep, and the same people think a command line is to be avoided at all 
costs. "I mean, its so /last century/ and you can't do anything useful 
with it anyway".

Obligatory OT comment: right now I have two xterm sessions open with 
which I've been writing a Swing/JDBC app using nowt but a bash shell, 
cvs, microEmacs and (of course) J2SE. I don't need no steenking IDE.


-- 
martin@   | Martin Gregorie
gregorie. | Essex, UK
org       |


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

Date: Thu, 21 Jun 2007 12:16:15 -0700
From:  Falcolas <garrickp@gmail.com>
Subject: Re: The Modernization of Emacs: terminology buffer and keybinding
Message-Id: <1182453375.531950.141460@m36g2000hse.googlegroups.com>

On Jun 21, 10:09 am, Robert Uhl <eadmun...@NOSPAMgmail.com> wrote:
> You're quite right.  Windows/Mac user interfaces are so clunky that they
> massively hamper productivity.  Emacs, OTOH, enables it.  For example,
> C-s is search forward; C-r is search backward ('reverse'); C-M-s is
> search forward for a regular expression; C-M-r is search backward for a
> regular expression.  A Windows or Mac editor would have C-s for save,
> and that's it.  It might have C-f for find, but it'd pop up a dialogue
> instead of offering an interactive search, causing a mental context
> switch.  Searching would interrupt one's flow of thought rather than
> being part of it.

Being a primarily windows user, I have to question your assertion that
using ctrl-f for find causes a "mental context switch". For me, in 90%
of the windows applications, finding something is as simple as ctrl-f,
the phrase, hit enter. Not terribly different from your set of
commands. The biggest difference is that if I need to use a Find
feature I might not often use, I have a visual interface to all the
related search functions. On the other hand, a terminal program would
necessitate a memory search at best, or a trip to the help pages at
worst.

The best part of my windows knowledge is that it's transferable to
most (all?) of the applications I work with. Find is usually ctrl-f.
Undo is ctrl-z. Save is ctrl-s, yadda yadda. Such knowledge is rarely
transferable from terminal programs in my experience -- what may be
true for one program (emacs) is wildly different in another program
(vi), and useless in yet another (pico).

On the other hand, I can move from notepad to Word to Open Office to
Notepad++, based on the availability at the terminal I'm on, with
little difficulty.

For the record, I use VIM when in terminals. Emacs isn't available on
our *nix boxes.



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

Date: Thu, 21 Jun 2007 11:40:21 -0700
From:  trudge@gmail.com
Subject: Re: Trying to make sense of perl for web development.
Message-Id: <1182451221.420731.239460@e9g2000prf.googlegroups.com>

On Jun 21, 12:27 am, cendrizzi <cendri...@gmail.com> wrote:
> Ok, I'm trying to learn perl for a potential position.
>
> I would consider myself a very experienced php programmer with a
> little exposure to perl.
>
> As far as syntax goes, perl seems pretty easy (some things I even like
> a lot).  I have an ubuntu feistry server that I've setup with
> mod_perl.  It works great for parsing simple stuff but now I'm ready
> to extend the functionality a bit and want to connect to postgresql,
> etc.
>
> Admittedly this is more a systems things than a programming thing but
> I need to get things in place so I can program and learn.  First of
> all, how does mod perl work with the cpan packages?  When I install
> something using cpan should I be able to use that module (ie "use
> module::module") immediately after?  So far that has not been my
> experience.  Furthermore, can I use the cgi stuff in cpan when I'm
> using mod_perl, like cgi::ajax??  I've just never had to deal with all
> this with php so it's feeling very overwhelming in how it all works
> together (I'm trying to read books and have been googling for hours to
> make sense of it).
>
> Finally, and most frustrating is getting error or warning feedback.
> Where do I go?  I currently am trying to connect to my db with:
>  $dbh = DBI->connect("dbi:Pg:dbname=ecommerce;host=127.0.0.1",
> "cendrizzi", "************", {AutoCommit => 0});
>
> I then try to do stuff with $dbh and nothing happens but I don't get
> errors either.  I have no idea what is going on or if I can even
> successfully connect to the db?!  In PHP you can turn on errors and
> warnings to display them in the page, I'm sure Perl is just
> different.  How can I troubleshoot this stuff?
>
> Thanks for any help you can provide me with.

The first thing you should do is get in the habit of adding the
following lines to the top of all your Perl scripts:
use strict;
use warnings;

You will see this advice given to newcomers constantly, and you are
wise to heed it, if you are not already doing so.

One little trick I do to help me in the development stages is to
redirect the error messages to a file in the same directory as the
script, instead of the Apache log files.

Near the beginning of each script I add:
BEGIN
{
	open (STDERR,">>$0-err.txt");
	print STDERR "\n",scalar localtime,"\n";
}

This block of code creates a file in the same directory the script is
in, thus making it very easy to find. Also, '$0' is the name of the
current script, so if your script is called 'login.pl', this error
file is called 'login.pl-err.txt', making it even easier to find. This
has the added advantage that if you change the name of the script, you
don't have to edit this block of code. Once your script is working
with no errors, comment out the block of code.

Since I don't know what your situation is, I can't say whether you
should be using mod_perl or not, but if you are just starting out with
Perl, I would say leave it for now - learn to walk first. I have not
yet found a situation where I needed to run mod_perl (which of course
may not be saying much, but it may be that you can get a lot done
without it as well).

A few good books on my shelf: "Perl Cookbook"; "Programming Perl";
"Perl Black Book"; "MySQL and Perl for the Web".



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

Date: Thu, 21 Jun 2007 12:42:47 -0700
From:  Ilias Lazaridis <ilias@lazaridis.com>
Subject: Re: Which Perl 5 OO extension can be seen as "standard" (defacto, quasi)?
Message-Id: <1182454967.717867.77770@p77g2000hsh.googlegroups.com>

            Ch Lamprecht       :
> Ilias Lazaridis wrote:
>
> > I dislike the verbosity:
> >
> >   has 'x' => (is => 'rw', isa => 'Int');
> >   has 'y' => (is => 'rw', isa => 'Int');
> You don't need the type constraint here:
>    has 'x' => (is=>'rw');
>    has 'y' => (is=>'rw');
> If that's still too verbose for you you could wrap &has and make (is=>'rw') default.

ok, like this:

hasInt 'x';
has_int 'x';

but most possibly there's a even more elegant way to provide the
default value.

thank's for the clarification.

 .

--
http://dev.lazaridis.com/lang/ticket/2



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

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


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