[27112] in Perl-Users-Digest

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

Perl-Users Digest, Issue: 8986 Volume: 10

daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Thu Feb 23 06:05:49 2006

Date: Thu, 23 Feb 2006 03:05:04 -0800 (PST)
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, 23 Feb 2006     Volume: 10 Number: 8986

Today's topics:
    Re: error-prone coding styles <january.weiner@gmail.com>
    Re: Implementing a "pull" (?) interface in perl xhoster@gmail.com
    Re: Reading Mac / Unix / DOS text files <tadmc@augustmail.com>
    Re: Reading Mac / Unix / DOS text files <january.weiner@gmail.com>
        Digest Administrivia (Last modified: 6 Apr 01) (Perl-Users-Digest Admin)

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

Date: Thu, 23 Feb 2006 08:59:30 +0100 (CET)
From: January Weiner <january.weiner@gmail.com>
Subject: Re: error-prone coding styles
Message-Id: <dtjq12$u24$2@sagnix.uni-muenster.de>

Samwyse <samwyse@gmail.com> wrote:
> One of the very first programs (non-Perl) that I had to maintain (as 
> opposed to create) was written by a joker who decided to use O as a 
> variable name.  Distinguishing between
>    X = 0;
> and
>    X = O;
> was a source of much merriment for the rest of the staff.  Fortunately 
> for his nose, he was quick at ducking whenever clenched fists were in 
> his vicinity.

Yeah.  Lack of reasonable editors or skills at using them (how do you do
"s/\(\W\)O\(\W\)/\1BloodyStupidVariableName\2/g in Notepad?) is always
a problem.

j.

-- 


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

Date: 23 Feb 2006 02:12:14 GMT
From: xhoster@gmail.com
Subject: Re: Implementing a "pull" (?) interface in perl
Message-Id: <20060222211446.267$9Y@newsreader.com>

Arvin Portlock <nomail@sorry.com> wrote:
> xhoster@gmail.com wrote:
>
> > The easiest way is to have the application block until a new record is
> > ready. That is just what readline aka <> does:
> >
> > $parser->init($foo);
> > while (defined (my $i=$parser->get_one()) {
> >   process($i);
> > };
>
> I don't understand. You are describing exactly how I want the
> interface to act but not saying how you are doing it, i.e.,
> how exactly get_one() works. But yes, that's what I'm aiming for.

OK, now I don't understand.  If you give an example of how get_all() would
work, we could discuss how to make it work like get_one() (assuming I can).
But without seeing what you are currently doing, I don't know to help you
change it!

Xho

-- 
-------------------- http://NewsReader.Com/ --------------------
Usenet Newsgroup Service                        $9.95/Month 30GB


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

Date: Wed, 22 Feb 2006 22:31:33 -0600
From: Tad McClellan <tadmc@augustmail.com>
Subject: Re: Reading Mac / Unix / DOS text files
Message-Id: <slrndvqel5.bc2.tadmc@magna.augustmail.com>

January Weiner <january.weiner@gmail.com> wrote:
> A. Sinan Unur <1usa@llenroc.ude.invalid> wrote:
> 
>> You should use the codes for those characters rather than the escapes.
> 
> Hmmm, OK, and why?


So you will *know* what character you will get.

   print "\n";

outputs different characters when perl is run on different systems.

If you use the codes, everybody on every system sees what you
want them to see.


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


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

Date: Thu, 23 Feb 2006 08:54:07 +0100 (CET)
From: January Weiner <january.weiner@gmail.com>
Subject: Re: Reading Mac / Unix / DOS text files
Message-Id: <dtjpmv$u24$1@sagnix.uni-muenster.de>

Rick Scott <rick@shadowspar.dyndns.org> wrote:
> > Why an error? (yeah, it can lead to errors, agree, but then, of
> > course, a collegue of mine says the same about using Perl)

> Why cause a greater propensity to introduce errors than one has to?

Yeah, I guess I _could_ switch to Python, which is verrry orrrdentlich,
syntax imposes coding style, etc., etc... sorry.  I use Python when
teaching.  I use Perl when doing my bloody job. Seriously: Perl is
notorious for shorthands, quick dirty code snippets etc. I would not have
been programming in Perl if I was ana^W careful.

> > just some basic common sense is sufficient to say when using
> > shorthand is OK and when it is a bad idea. I do use the <IF>
> > construct in few-liners that do not read more than one file. I do
> > think it is important to define variables if you are writing a
> > larger piece of code. I do not understand the whole stir about
> > this issue.

> Since there's a way to do things that lets you do everything you can 
> do with a bareword filehandle without incurring the disadvantages,
> why not make a habit of using it?  As of Perl 5.6, you can do this:

>     open my $FILE, '<', $filename or die "Can't open file: $!";

> Then the filehandle is stored in the lexical variable $FILE (where it
> can't be stomped on by someone else's code) instead of in the package 
> variable *FILE (where it can).

Thanks for these explanation, but read what I have written above. Yeah, I
know that, I use it in larger projects.  I don't care about that in the
five liners.  Frankly, do you use "use strict ; use warnings ;" with
one-liners run with "perl -e"?  Will you try to convince me that omitting
these is a serious danger and causes a greater propensity to introduce
errors? ...with "perl -e"?  Well -- I agree.  Of course it does - so what?

> > > Pick up a copy of Damian Conway's "Perl Best Practices" -- he
> > > explains why this and about a thousand other `harmless style
> > > preferences' aren't harmless, aren't stylish, and definitely
> > > aren't preferable.
> >
> > So what is the problem with whitespace? Why is while(<STDIN>) more
> > harmful than while ( <STDIN> ) ?

> Actually, I'd go with the first of these two.  About whitespace in 
> general -- there's not necessarily too many hard and fast rules;
> you just want to make best use of it to increase the readability of
> your code.  To take an extreme example,

(snip example)

Yes, I do agree with general formatting, but I was critisized for this
particular thing -- not putting space in while(<BLAH>). By the way,

> LINE: 
> foreach my $line (@lines) {
>     my ($registry, $cc, $type, $start, $length, $date, $status) =
>         split qr{\|}, $line;

>     next LINE unless $status;
>     next LINE unless ($type eq 'ipv4');
>     print $start;
> }

 ...I would most probably write as

  my @info ;
  for(@lines) {
    ($stat, $type, $start) = split /\|/ ; # info has now: registry, cc, 
                        # type, start, length, date, status
    next unless ($info[-1] && $info[2] eq 'ipv4') ;
    print $info[3] ;
  }

which probably is for you

> some other godawful thing.

j.

-- 


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

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


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