[25091] in Perl-Users-Digest

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

Perl-Users Digest, Issue: 7341 Volume: 10

daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Fri Oct 29 18:05:43 2004

Date: Fri, 29 Oct 2004 15:05:06 -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           Fri, 29 Oct 2004     Volume: 10 Number: 7341

Today's topics:
    Re: computing the checksum <troc@pobox.com>
    Re: computing the checksum <cNaOlSePbA@MvPeLtEsAtSaEr.com>
    Re: Convert String Containing Hex Values <uguttman@athenahealth.com>
    Re: Convert String Containing Hex Values <cmail@cherryplankton.com>
    Re: Convert String Containing Hex Values <cmail@cherryplankton.com>
    Re: Convert String Containing Hex Values <uguttman@athenahealth.com>
    Re: Convert String Containing Hex Values <abigail@abigail.nl>
        converting list to an array <nospam@nospam.com>
    Re: converting list to an array <usa1@llenroc.ude.invalid>
    Re: converting list to an array <nospam@nospam.com>
    Re: converting list to an array <nospam@nospam.com>
        FAQ 4.23: How do I find matching/nesting anything? <comdog@panix.com>
    Re: How to handle large variable <do-not-use@invalid.net>
    Re: How to handle large variable <uguttman@athenahealth.com>
    Re: How to handle large variable <tadmc@augustmail.com>
    Re: IDEs <NOdj.athensSPAM@surfeu.fi>
    Re: IDEs <mjcarman@mchsi.com>
    Re: IDEs <mjcarman@mchsi.com>
    Re: modifying hash key (dispatch table) <tadmc@augustmail.com>
    Re: system return value makes for strange logic <abigail@abigail.nl>
        Digest Administrivia (Last modified: 6 Apr 01) (Perl-Users-Digest Admin)

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

Date: Fri, 29 Oct 2004 19:31:07 GMT
From: Rocco Caputo <troc@pobox.com>
Subject: Re: computing the checksum
Message-Id: <slrnco56og.hdf.troc@eyrie.homenet>

On Fri, 29 Oct 2004 10:40:04 -0600, Spin wrote:
> I need to compute the checksum on a hex message sent to a lab machine 
> via Device::SerialPort.
>
> This is the C code snippet and instructions in their manual:
> Assume the message is held in buf. "buf" is an array of unsigned char.
>
> unsigned char *buf
> short int message_size;
> unsigned char trailer[2];
> trailer[0] = 0;
> for (int i = 0; i < message_size; i++)
> 	trailer[0] += buf[i];
> trailer[0] |= 0x80; // Turning on high bite ensures this cannot be an 
> ETX byte
> trailer[1] = 0x03; // End of message ETX
>
> Here's what I have in my perl script (note I'm just printing to screen 
> at this point, not to the device):
> #!/usr/bin/perl -w
> use strict;
> use Term::ANSIColor;
> my $status = chr(02);	# Start of message (STX)
> $status .= chr(hex(30));
> $status .= chr(hex(33));
> $status .= chr(hex(80));
> $status .= chr(hex(86));
> $status .= chr(hex(53));
> $status .= chr(hex(50));
> $status .= chr(hex(20));
> $status .= chr(hex(20));
> $status .= chr(hex(20));
> $status .= chr(hex(73));
> my $check_sum = 0;
> my @reroute = unpack("H2"x length($status),$status);
> for my $i (0 .. 10) {
> 	$check_sum += hex($reroute[$i]);
> 	print $reroute[$i];
> 	$i++;
> }
> $check_sum |= hex(0x80);
> $status .= hex($check_sum);
> $status .= chr(03);
> print color("red"), $check_sum, color("reset");
> print unpack("H*",$status),"\n";

How about:

  my $buffer = "\x02\x30\x33\x80\x86\x53\x50\x20\x20\x20\x73";
  my $check_sum = unpack("%8C*", $buffer) | 0x80;
  printf "check sum = %x\n", $check_sum;
  $buffer .= chr($check_sum) . chr(3);

> I know from their example that the checksum byte should be:
> $status .= chr(hex(89));

A direct translation of the C version disagrees.  It says the checksum
should be 0xE1.

  my $buffer = (
    chr(2) . chr(0x30) . chr(0x33) . chr(0x80) . chr(0x86) . chr(0x53) .
    chr(0x50) . chr(0x20) . chr(0x20) . chr(0x20) . chr(0x73)
  );

  my $check_sum = 0;
  for (0..length $buffer) {
    $check_sum += ord(substr($buffer, $_, 1));
  }

  $check_sum &= 0xFF; # remove all but least significant byte
  $check_sum |= 0x80; # turn on high bit to avoid ETX

  printf "check sum = %x\n", $check_sum;

  $buffer .= chr($check_sum) . chr(3);

The shorter example also calculates 0xE1 as your checksum.

-- 
Rocco Caputo - http://poe.perl.org/


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

Date: Fri, 29 Oct 2004 13:58:58 -0600
From: Spin <cNaOlSePbA@MvPeLtEsAtSaEr.com>
Subject: Re: computing the checksum
Message-Id: <10o5881143qd76f@corp.supernews.com>

Rocco Caputo wrote:
>   my $check_sum = 0;
>   for (0..length $buffer) {
>     $check_sum += ord(substr($buffer, $_, 1));
>   }
> 
>   $check_sum &= 0xFF; # remove all but least significant byte
>   $check_sum |= 0x80; # turn on high bit to avoid ETX
> 
>   printf "check sum = %x\n", $check_sum;
> 
>   $buffer .= chr($check_sum) . chr(3);
> 
</ Begin unrestrained gratitude>
Thank you soooooooooooooo much! It works!
</ End above>

They never said in the manual where to begin the checksum, but I had a 
hunch that it began at byte 5, not at the start. I was right, and your 
code calculated the checksum to be 89, same as theirs.

This hex stuff is a little dizzying sometimes...

Thanks again,
Caleb


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

Date: Fri, 29 Oct 2004 14:19:23 -0400
From: Uri Guttman <uguttman@athenahealth.com>
Subject: Re: Convert String Containing Hex Values
Message-Id: <m33bzxwfo4.fsf@linux.local>

>>>>> "c" == cp  <cmail@cherryplankton.com> writes:

  c> s/(.*)\_[[:xdigit:]]+\_(.*)/$1 $2/;

overkill. you don't need to grab and put back the leading and trailing
strings. like gunnar did, just delete the stuff you want to delete.

and _ doesn't need escaping there (or anywhere as it is just a word
char).

so your regex should be:

	s/_[[:xdigit:]]+_//;

a lot cleaner and easier to read.

uri



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

Date: Fri, 29 Oct 2004 15:22:13 -0400
From: cp <cmail@cherryplankton.com>
Subject: Re: Convert String Containing Hex Values
Message-Id: <10o569b6j73a9c2@news.supernews.com>

Uri Guttman wrote:

>>>>>> "c" == cp  <cmail@cherryplankton.com> writes:
> 
>   c> s/(.*)\_[[:xdigit:]]+\_(.*)/$1 $2/;
> 
> overkill. you don't need to grab and put back the leading and trailing
> strings. like gunnar did, just delete the stuff you want to delete.
> 
> and _ doesn't need escaping there (or anywhere as it is just a word
> char).
> 
> so your regex should be:
> 
> s/_[[:xdigit:]]+_//;
> 
> a lot cleaner and easier to read.
> 
> uri

Thanks for the tip.  I mistakenly remembered from my quick reading of
'Programming Perl' that all non alpha characters were metacharacters, but I
was wrong.  I am looking at the list right now (p. 141 3rd ed.) which is :

\ | ( ) [ { ^ $ * + ? .

and then you have / which only needs a backslash in front to match literally
if it is also used as a delimiter.

I probably shouldn't be trying to help out around here yet, but I couldn't
resist trying to help a fellow cp!

-- 
www.cherryplankton.com


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

Date: Fri, 29 Oct 2004 16:02:34 -0400
From: cp <cmail@cherryplankton.com>
Subject: Re: Convert String Containing Hex Values
Message-Id: <10o58kv1oigbrc3@news.supernews.com>

Uri Guttman wrote:

>>>>>> "c" == cp  <cmail@cherryplankton.com> writes:
> 
>   c> s/(.*)\_[[:xdigit:]]+\_(.*)/$1 $2/;
> 
> overkill. you don't need to grab and put back the leading and trailing
> strings. like gunnar did, just delete the stuff you want to delete.
> 
> and _ doesn't need escaping there (or anywhere as it is just a word
> char).
> 
> so your regex should be:
> 
> s/_[[:xdigit:]]+_//;
> 
> a lot cleaner and easier to read.
> 
> uri

This could be a stretch in trying to justify backslashing characters
unnecessarily, but what about the possibility of reserved metacharacters? 
What if Larry Wall decides to make use of _ and the other
non-metacharacter, non-alpha characters and old scripts that did not
backslash them will be broken?  I know it's a stretch and I did read that
even if Perl6 breaks old scripts, there will be a tool to upgrade scripts
from Perl5 to Perl6 so maybe it's not even an issue.

-- 
www.cherryplankton.com


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

Date: Fri, 29 Oct 2004 16:25:09 -0400
From: Uri Guttman <uguttman@athenahealth.com>
Subject: Re: Convert String Containing Hex Values
Message-Id: <m3lldpuva2.fsf@linux.local>

>>>>> "c" == cp  <cmail@cherryplankton.com> writes:

  >> so your regex should be:
  >> 
  >> s/_[[:xdigit:]]+_//;
  >> 
  >> a lot cleaner and easier to read.

  c> This could be a stretch in trying to justify backslashing
  c> characters unnecessarily, but what about the possibility of
  c> reserved metacharacters?  What if Larry Wall decides to make use of
  c> _ and the other non-metacharacter, non-alpha characters and old
  c> scripts that did not backslash them will be broken?  I know it's a
  c> stretch and I did read that even if Perl6 breaks old scripts, there
  c> will be a tool to upgrade scripts from Perl5 to Perl6 so maybe it's
  c> not even an issue.

_ is in \w and will always be a word char and needs no more escaping
than does k or 3. perl5 regexes ain't gonna change metachar meanings or
it will break too much code. perl6 not only will have a perl5 regex
compiler it will have a much easier regex (actually called rules and
grammars) extension mechanism that it won't need to change its metachars
in the future.

uri




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

Date: 29 Oct 2004 21:22:23 GMT
From: Abigail <abigail@abigail.nl>
Subject: Re: Convert String Containing Hex Values
Message-Id: <slrnco5d4f.g9f.abigail@alexandra.abigail.nl>

cp (cpryce@nospam.pryce.net) wrote on MMMMLXXVII September MCMXCIII in
<URL:news:291020041130026861%cpryce@nospam.pryce.net>:
``  If I have a string that looks like this: 
``  
``  Job_x0020_Number
``  
``  How do I turn that into: 
``  
``  Job Number 


    s/_x([[:xdigit:]]+)_/chr hex $1/eg;



Abigail
-- 
perl -le 's[$,][join$,,(split$,,($!=85))[(q[0006143730380126152532042307].
          q[41342211132019313505])=~m[..]g]]e and y[yIbp][HJkP] and print'


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

Date: Fri, 29 Oct 2004 14:10:49 -0400
From: "daniel kaplan" <nospam@nospam.com>
Subject: converting list to an array
Message-Id: <1099073485.24976@nntp.acecape.com>

hi all,

at the very bottom is my code for reading an email account....now i do know
it works because the code does return the refernce to an array and i pick
out the emails....

but to be efficient i would like to return early with no reference if there
are no "new" msgs.  so Net::POP3 offers:

"ping ( USER )
Returns a list of two elements. These are the number of new messages and the
total number of messages for USER. "

so with two UNREAD msgs in my email box) i have tried the following,

@all_msgs = $pop->ping($user);
$all_msgs = @all_msgs;
#$all_msgs ends up equaling -1
#any attempts at reading $all_msgs[0] shows nothing

and i have tried

($list1, $list2)  = $pop->ping($user);
#$list1 & 2 remain empty

the line xxxxxxxxxx in my code is where i have insterted the top two
attempts

to the best of my knowledge (which i conceed is still new) this is what i am
supposed to do, referencing FAQ, and 2 books....i have confirmed that $user
hasn't changed as well.

can anyone point me in the right direction?

thanks ahead

--original code--
$pop = Net::POP3->new($host);
$conn = $pop->login($user, $pass);
$list = $pop->list();

xxxxxxxxxxxxxxxxx

foreach my $msgnum (keys %$list)
{
      my $size = $pop->list($msgnum);
      my $array_temp = $pop->get($msgnum);
      push @array, $array_temp;
       $pop->delete($msgnum) if ($deletemail);
}
$pop->quit();
return \@array;




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

Date: 29 Oct 2004 20:15:27 GMT
From: "A. Sinan Unur" <usa1@llenroc.ude.invalid>
Subject: Re: converting list to an array
Message-Id: <Xns9591A56198348asu1cornelledu@132.236.56.8>

"daniel kaplan" <nospam@nospam.com> wrote in
news:1099073485.24976@nntp.acecape.com: 

> hi all,
> 
> at the very bottom is my code for reading an email account....now i do
> know it works because the code does return the refernce to an array
> and i pick out the emails....
> 
> but to be efficient i would like to return early with no reference if
> there are no "new" msgs.  so Net::POP3 offers:

 ...
 
> so with two UNREAD msgs in my email box) i have tried the following,
> 
> @all_msgs = $pop->ping($user);
> $all_msgs = @all_msgs;
> #$all_msgs ends up equaling -1

Then you should check if $pop->ping($user); actually succeeded. If it did 
not succeed, then you should investiage why not.

Also, do you have:

use strict;
use warnings;

at the top of your script?

And, have you read the posting guidelines yet. If you had, you would have 
known to post a small but complete script exhibiting the problem you were 
experiencing. The script you posted did not have a $pop->ping call.

If you are still refusing to read the guidelines, I can only refer you to:

http://perl.plover.com/Questions4.html

> --original code--

use strict;
use warnings;

> $pop = Net::POP3->new($host);

my $pop = Net::POP3->new($host)
    	or die "Cannot setup connection";

etc.

Sinan.


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

Date: Fri, 29 Oct 2004 16:27:40 -0400
From: "daniel kaplan" <nospam@nospam.com>
Subject: Re: converting list to an array
Message-Id: <1099081697.768249@nntp.acecape.com>

"A. Sinan Unur" <usa1@llenroc.ude.invalid> wrote in message
news:Xns9591A56198348asu1cornelledu@132.236.56.8...
> And, have you read the posting guidelines yet. If you had, you would have
> known to post a small but complete script exhibiting the problem you were
> experiencing. The script you posted did not have a $pop->ping call.
>

i have read, and trust me, the missing line was just an oversight on the cut
and paste....




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

Date: Fri, 29 Oct 2004 16:58:05 -0400
From: "daniel kaplan" <nospam@nospam.com>
Subject: Re: converting list to an array
Message-Id: <1099083523.348356@nntp.acecape.com>

"A. Sinan Unur" <usa1@llenroc.ude.invalid> wrote in message
news:Xns9591A56198348asu1cornelledu@132.236.56.8...

> Then you should check if $pop->ping($user); actually succeeded. If it did
> not succeed, then you should investiage why not.

ding ding ding, a cupie doll for you!  am so UNUSED to open
source, I didn't think that I could debug INTO the Net::Pop3
code.  Which on your recommendation I did, and I do
believe that it is returning me a NULL!  Now am still new enough that
I have enough headaches debugging my own code much less someone
else's.  and mind you not saying there is a bug there, but according to
the Net::Pop3 docs I should be getting back a list of two elements when
there are items in my mailbox (which there are).

I will look at this in depth later, in the meantime found another way
around my problem, but in the end I do need to use the "ping" object so
I will make sure I look into it further.

thanks for you help




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

Date: Fri, 29 Oct 2004 22:03:03 +0000 (UTC)
From: PerlFAQ Server <comdog@panix.com>
Subject: FAQ 4.23: How do I find matching/nesting anything?
Message-Id: <cluemn$ium$1@reader1.panix.com>

This message is one of several periodic postings to comp.lang.perl.misc
intended to make it easier for perl programmers to find answers to
common questions. The core of this message represents an excerpt
from the documentation provided with Perl.

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

4.23: How do I find matching/nesting anything?

    This isn't something that can be done in one regular expression, no
    matter how complicated. To find something between two single characters,
    a pattern like "/x([^x]*)x/" will get the intervening bits in $1. For
    multiple ones, then something more like "/alpha(.*?)omega/" would be
    needed. But none of these deals with nested patterns. For balanced
    expressions using "(", "{", "[" or "<" as delimiters, use the CPAN
    module Regexp::Common, or see "(??{ code })" in perlre. For other cases,
    you'll have to write a parser.

    If you are serious about writing a parser, there are a number of modules
    or oddities that will make your life a lot easier. There are the CPAN
    modules Parse::RecDescent, Parse::Yapp, and Text::Balanced; and the
    byacc program. Starting from perl 5.8 the Text::Balanced is part of the
    standard distribution.

    One simple destructive, inside-out approach that you might try is to
    pull out the smallest nesting parts one at a time:

        while (s/BEGIN((?:(?!BEGIN)(?!END).)*)END//gs) {
            # do something with $1
        }

    A more complicated and sneaky approach is to make Perl's regular
    expression engine do it for you. This is courtesy Dean Inada, and rather
    has the nature of an Obfuscated Perl Contest entry, but it really does
    work:

        # $_ contains the string to parse
        # BEGIN and END are the opening and closing markers for the
        # nested text.

        @( = ('(','');
        @) = (')','');
        ($re=$_)=~s/((BEGIN)|(END)|.)/$)[!$3]\Q$1\E$([!$2]/gs;
        @$ = (eval{/$re/},$@!~/unmatched/i);
        print join("\n",@$[0..$#$]) if( $$[-1] );



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

Documents such as this have been called "Answers to Frequently
Asked Questions" or FAQ for short.  They represent an important
part of the Usenet tradition.  They serve to reduce the volume of
redundant traffic on a news group by providing quality answers to
questions that keep coming up.

If you are some how irritated by seeing these postings you are free
to ignore them or add the sender to your killfile.  If you find
errors or other problems with these postings please send corrections
or comments to the posting email address or to the maintainers as
directed in the perlfaq manual page.

Note that the FAQ text posted by this server may have been modified
from that distributed in the stable Perl release.  It may have been
edited to reflect the additions, changes and corrections provided
by respondents, reviewers, and critics to previous postings of
these FAQ. Complete text of these FAQ are available on request.

The perlfaq manual page contains the following copyright notice.

  AUTHOR AND COPYRIGHT

    Copyright (c) 1997-2002 Tom Christiansen and Nathan
    Torkington, and other contributors as noted. All rights 
    reserved.

This posting is provided in the hope that it will be useful but
does not represent a commitment or contract of any kind on the part
of the contributers, authors or their agents.


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

Date: 29 Oct 2004 20:11:07 +0200
From: Arndt Jonasson <do-not-use@invalid.net>
Subject: Re: How to handle large variable
Message-Id: <yzd3bzx1jk4.fsf@invalid.net>


Uri Guttman <uguttman@athenahealth.com> writes:
> >>>>> "AJ" == Arndt Jonasson <do-not-use@invalid.net> writes:
> 
>   AJ> Uri Guttman <uri@stemsystems.com> writes:
> 
>   >> and the empty string in $/ has another specific meaning of paragraph
>   >> mode. so using the term 'nothing' around $/ is not a good idea. computer
>   >> stuff likes specificity and not vagueness.
> 
>   AJ> Is there a need to rub it in? We agree. I'm the kind of person who'd
>   AJ> like to see a formal definition for Perl.
> 
> i never stated we need a formal definition for perl. how did you get
> that from my post?

No, you didn't state that, and I didn't get that from your post at
all. Did I state that you did? I made it clear (or I tried to) that I
too consider it important to let things be well defined. How do you
get from "would like to see" to "thinks we need"?

Does this lead anywhere? It hasn't been about Perl for a while now; not
even about programming practice.

>   AJ> Yes, yes, I wasn't advocating sloppy style (like permitting all of
>   AJ> the above statements about $x), but I do want to know where the
>   AJ> line is drawn. Are all of them unpermissible?
> 
> like anything else in software and the world, it takes experience. some
> get it faster than other like coding in general. writing unambiguous
> english (or any natural lang) is a skill unto itself. and if it is too
> unambiguous it becomes stilted and boring and useless too. read damian
> conway's or peter scott's books to see how to write interesting and
> accurate technical english.

I really do want to know which ones are OK (they've disappeared in the
quoted text now, I see). It's a simple, very specific, question. Maybe
there isn't a simple answer, though.

I'll look up the names you mention - apart from that I don't see how your
answer relates to my question, even if I agree (if I'm permitted to do so)
with what you write.


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

Date: Fri, 29 Oct 2004 14:24:48 -0400
From: Uri Guttman <uguttman@athenahealth.com>
Subject: Re: How to handle large variable
Message-Id: <m3u0sdv0un.fsf@linux.local>

>>>>> "AJ" == Arndt Jonasson <do-not-use@invalid.net> writes:

  >> 
  >> i never stated we need a formal definition for perl. how did you get
  >> that from my post?

  AJ> No, you didn't state that, and I didn't get that from your post at
  AJ> all. Did I state that you did? I made it clear (or I tried to) that I
  AJ> too consider it important to let things be well defined. How do you
  AJ> get from "would like to see" to "thinks we need"?

  AJ> Is there a need to rub it in? We agree. I'm the kind of person who'd
  AJ> like to see a formal definition for Perl.

in that paragraph you said you agree and then commented on a formal
definition. that reads to me like i said that too and you agree. see,
ambiguous english! to what did you agree? that is dangling (at least in
my eyes :).

  AJ> I'll look up the names you mention - apart from that I don't see
  AJ> how your answer relates to my question, even if I agree (if I'm
  AJ> permitted to do so) with what you write.

well, those are two very good writers and excellent perl writers in
particular. so their books will improve your perl and show you ways to
write high quality technical english.

uri


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

Date: Fri, 29 Oct 2004 15:15:48 -0500
From: Tad McClellan <tadmc@augustmail.com>
Subject: Re: How to handle large variable
Message-Id: <slrnco597k.1m0.tadmc@magna.augustmail.com>

Arndt Jonasson <do-not-use@invalid.net> wrote:


> Exactly how vague is one allowed to be without misleading, when saying
> things about 'undef', I wonder. 


As vague as you like *without introducing an ambiguity*.


> "$x has no value", 


That one is just plain incorrect.

It _does_ have a value, the "special" value named "undef".


> "$x is undefined",
> "$x has the value 'undef'", "$x has the undefined value", 


Those all seem fine to me.


> "$x is set
> to nothing". 


There are 3 kinds of "nothing" with regards to a Perl scalar.

It might be zero, or it might be the empty string, or it might
be undef (which can act like either a zero or an empty string
depending on how you use it).

With regards to $/, you get "slurp mode" with undef and "para mode"
with the empty string, so it really does make a difference here.


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


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

Date: Fri, 29 Oct 2004 22:13:09 +0300
From: "Jussi Mononen" <NOdj.athensSPAM@surfeu.fi>
Subject: Re: IDEs
Message-Id: <clu4n7$l0n$1@nyytiset.pp.htv.fi>


"Michael Carman" <mjcarman@mchsi.com> kirjoitti 
viestissä:clthdk$9422@onews.rockwellcollins.com...
> There are almost as many opinions as there are programmers, but I'll
> toss in a recommendation anyway: UltraEdit. I tend to program in a few
> different languages at any given time, so I'm not a fan of IDEs that
> specialize in a particular language. I prefer a good text editor that's
> customizable and extensible.

Ultraedit has a pretty lousy indentation engine IMO, otherwise it is quite a 
good editor at least for Windows. Emacs is my choice though from different 
flavours of *NIX to Windows. The configurability and customization is 
excellent and the amount of available add-on's is huge :-)

> UltraEdit isn't free, but it's very inexpensive. It takes a little
> tweaking, but it can be made into a very good environment. (tweak the
> syntax highlighting, add in ctags, add some custom commands for checking
> syntax, running, debugging, checking in/out of source control, etc.)

None of this is needed with Emacs (ok, maybe something, but it is rather 
good editor out-of-the-box) and did I mention that Emacs is free ;-)

/jUSSi 




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

Date: Fri, 29 Oct 2004 14:17:12 -0500
From: Michael Carman <mjcarman@mchsi.com>
Subject: Re: IDEs
Message-Id: <clu4vr$9463@onews.rockwellcollins.com>

daniel kaplan wrote:
> 
> no grep (is there a dos equiv?)

See http://sourceforge.net/projects/ppt/

    Perl Power Tools (aka the Unix Reconstruction Project) is an
    attempt to provide implementations of all core UNIX programs
    in perl. This allows greater portability between UNIXes, as
    well as non UNIX platforms.

For grep, I took the tcgrep program, created a DOS batch wrapper using
pl2bat, renamed it "grep.bat" and put it in my PATH. Oh, I also inserted
one line to make globbing work better:

    if (@ARGV) {
+++     @ARGV = map {glob} @ARGV; # added for use in DOS
        $Mult = 1 if ($opt{r} || (@ARGV > 1) || -d $ARGV[0])
                      && !$opt{h};
   }

Presto! grep for DOS!

-mjc


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

Date: Fri, 29 Oct 2004 14:47:20 -0500
From: Michael Carman <mjcarman@mchsi.com>
Subject: Re: IDEs
Message-Id: <clu6ob$94d3@onews.rockwellcollins.com>

Jussi Mononen wrote:
> "Michael Carman" <mjcarman@mchsi.com> kirjoitti 
> viestissä:clthdk$9422@onews.rockwellcollins.com...
> 
>> There are almost as many opinions as there are programmers, but 
>> I'll toss in a recommendation anyway: UltraEdit.
> 
> Ultraedit has a pretty lousy indentation engine IMO

True, it's not very sophisticated, but that feature is unimportant to
me. I really don't *want* my editor to do that. I do occasionally use
PerlTidy to clean up someone else's code, though. :)

> Emacs is my choice though from different flavours of *NIX to Windows.

I've tried it several times -- mostly because I wanted something that
was available across multiple platforms (UE is Win* only) -- but the
learning curve is too steep. My productivity would drop to zero while I
tried to figure out how to do things. Part of the problem is that its a
very different paradigm. I'm sure it's great if that's what you're used
to, but it's hard to do that.

> The configurability and customization is excellent and the amount of 
> available add-on's is huge :-)

Too huge. I don't want or need three syntax highlighting modes for Perl.
I only want one, but I want to be able to tweak it.

> did I mention that Emacs is free ;-)

Free is good, but I don't mind paying for quality software. At $35, UE
is a bargain. (Great support, too.)

-mjc


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

Date: Fri, 29 Oct 2004 15:17:22 -0500
From: Tad McClellan <tadmc@augustmail.com>
Subject: Re: modifying hash key (dispatch table)
Message-Id: <slrnco59ai.1m0.tadmc@magna.augustmail.com>

Arndt Jonasson <do-not-use@invalid.net> wrote:
> 
> Tad McClellan <tadmc@augustmail.com> writes:
>> My personal style is to never use ampersands on sub calls, whether
>> called direct or via a coderef, I always use parens on sub calls 
>> instead (even when they take no args).
> 
> I was going to ask whether that was true even for 'eof', since the
> calls "eof" and "eof()" behave differently, 


I should have said "on user-defined sub calls" because ...


> but I suppose 'eof' is not
> a subroutine, but a built-in function.

 ... I rarely use parens on the built-ins.


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


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

Date: 29 Oct 2004 21:37:03 GMT
From: Abigail <abigail@abigail.nl>
Subject: Re: system return value makes for strange logic
Message-Id: <slrnco5dvv.g9f.abigail@alexandra.abigail.nl>

Eric Bohlman (ebohlman@omsdev.com) wrote on MMMMLXXVII September MCMXCIII
in <URL:news:Xns9591729577743ebohlmanomsdevcom@130.133.1.4>:
%%  wana <ioneabu@yahoo.com> wrote in
%%  news:10o4odkcq2dgm01@news.supernews.com: 
%%  
%% > and even though it doesn't look right at first glance, it makes sense
%% > because system apparently returns 0 with success and numbers > 0 for
%% > failure.  I read about it in 'Programming Perl' and saw the
%% > explanation that the return value gives information about the nature
%% > of the failure. Isn't this strange?  Don't we normally look to $! for
%% > errors and consider 0 to mean failure?  I can accept it, but 'do and
%% > die' sounds funny compared to the usual 'do or die'.
%%  
%%  The reason is that system() returns the exit status of the program it runs. 
%%  What that status is is under the program's control, not perl's.  The 
%%  convention (which again has nothing to do with Perl) is that a program 
%%  exits with 0 on success and any number of non-zero values upon failure.  
%%  Why?  Because there's only one way a program can succeed, but quite a few 
%%  ways it can fail (the number of such ways varying from program to program) 
%%  and it's helpful if it can signal *why* it failed.


Hindsight is 20/20 of course, but it there would have been some other 
options. First, there's not really a reason the return value of system
should indicate the reason why - open doesn't use its return value to
indicate the reason for failure either. Instead, $! is set. And a system
that fails sets $? already, which gives the same information. I cannot
recall I ever used the return value of system other than for its boolean
value - if I want to know the reason, I always use $?. system could also
have returned a magical value, that in boolean context returned false on
a failure, and true on success, but in numerical context, it just acts
as $? now.



Abigail
-- 
perl -swleprint -- -_='Just another Perl Hacker'


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

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


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