[10526] in Perl-Users-Digest

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

Perl-Users Digest, Issue: 4118 Volume: 8

daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Sat Oct 31 10:07:15 1998

Date: Sat, 31 Oct 98 07:00:23 -0800
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, 31 Oct 1998     Volume: 8 Number: 4118

Today's topics:
    Re: 0 - 1 toggling question (Matthew Bafford)
    Re: help a poor student (brian d foy)
        HELP! alarm doesn't work during gethostbyaddr() eric4242@my-dejanews.com
    Re: Not to start a language war but.. <arcege@shore.net>
    Re: Not to start a language war but.. <arcege@shore.net>
    Re: Perl & Y2K - booby trap code lvirden@cas.org
    Re: Perl for the mainframe? <jhi@alpha.hut.fi>
        Special: Digest Administrivia (Last modified: 12 Mar 98 (Perl-Users-Digest Admin)

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

Date: Sat, 31 Oct 1998 08:16:51 -0500
From: dragons@scescape.net (Matthew Bafford)
Subject: Re: 0 - 1 toggling question
Message-Id: <MPG.10a4d6f3268137769896f6@news.scescape.net>

In article <<3640ddfd.4281129@news.ping.be>>, bart.mediamind@ping.be 
(Bart Lateur) pounded the following:
=> Matthew Bafford wrote:
=> >    $var = !$var+0;
=> 
=> I think I prefer
=> 
=> 	$var = !$var || 0 ;
=> 
=> I don't understand why your version doesn't give any warnings when run
=> under -w. It looks like !(expr) acts like a warning disabler.
=> 
=> 
=> 	$var = undef() + 0;
=> Use of uninitialized value at test.pl line 7.
=> 
=> 	$var = '' + 0;
=> Argument "" isn't numeric in add at test.pl line 8.

Hmm...

% perl -w-
#!/usr/bin/perl -w
$var = 1;

for ( 1 .. 5 ) {
    $var = !$var+0;
    print "$var\n";
}

$var = 1;
$var = ''+0;
print "\n$var\n";
__END__
Argument "" isn't numeric in add at toggle line 12.
0
1
0
1
0

0
% perl -v
This is perl, version 5.005_02.
 ...

What does yours do?

=> 	Bart.

--Matthew


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

Date: Sat, 31 Oct 1998 08:57:48 -0500
From: comdog@computerdog.com (brian d foy)
Subject: Re: help a poor student
Message-Id: <comdog-ya02408000R3110980857480001@news.panix.com>

In article <71eo9l$jrn$1@merki.connect.com.au>, "James Greenhalgh" <mghalgh@goulburn.net.au> posted:

> We have to design a stupid text adventure in a language of our choice for
> school. I know bugger all about perl but I want to learn. It probably seems
> simple to anyone except a retard like me but what gives with this script?
> msg me at mghalgh@goulburn.net.au . And could the smart arse programmers who
> do it for a living please give the insults a miss.

you seem to have the insults adequately covered.

-- 
brian d foy                                  <comdog@computerdog.com>
CGI Meta FAQ <URL:http://computerdog.com/CGI_MetaFAQ.html>


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

Date: Sat, 31 Oct 1998 12:35:13 GMT
From: eric4242@my-dejanews.com
Subject: HELP! alarm doesn't work during gethostbyaddr()
Message-Id: <71f061$s14$1@nnrp1.dejanews.com>

Hi,

I'm using the following simple code to try to set a timer for
the gethostbyaddr() function.  Unfortunately, the arrival of
the ALRM signal does NOT seem to interrupt the running gethostbyaddr()
function.  Any suggestions?  gethostbyaddr() doesn't take any
sort of argument for a maximum number of seconds to wait for
a reply, and the only other thing I can think of is to compile
into the Perl interpreter support for C's setjmp() and longjmp()
functionality (which I'd rather not do!)

sub TrapTimeout
{
        $TIMED_OUT = 1;
}


$SIG{'ALRM'} = 'TrapTimeout';

alarm(3);
$TIMED_OUT = 0;

# $_addr is the appropriately 'packed' x.x.x.x address
($_name, $_aliases, $_type, $_len, @_addrs) = gethostbyaddr($_addr, 2);
alarm 0;

if ( $TIMED_OUT )
{
      $_name = "???";
}


Note again that my code works fine unless gethostbyaddr() isn't able
to resolve the IP label, in which case it can take a long time for it
to finally return.  I'd like to set a 3-second timeout (which I am
trying to do above with alarm, but to no avail...)

Thanks,
Eric

-----------== Posted via Deja News, The Discussion Network ==----------
http://www.dejanews.com/       Search, Read, Discuss, or Start Your Own    


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

Date: Sat, 31 Oct 1998 14:17:36 GMT
From: "Michael P. Reilly" <arcege@shore.net>
Subject: Re: Not to start a language war but..
Message-Id: <4_E_1.389$%C5.52195@news.shore.net>

In comp.lang.python Russ Allbery <rra@stanford.edu> wrote:
: In comp.lang.perl.misc, Jason Orendorff <jorendorff@ixl.com> writes:

:> The corresponding Python for this admittedly inane little routine would
:> be something like:

[Code snippet snipped]

:> Arguably, there's less to screw up here; you don't check return codes at
:> all.  But under the hood, the system does it anyway, and automatically
:> throws exceptions on errors.

: There's a problem with this argument.  How much information are you losing
: by relying on the exception?  I would, when coding the above in Perl (and
: likely in Python as well) specifically say *what* I was doing that failed
: in each case, not just say something generic like "open failed".  I want
: the file name, the operating system error code, and (this is the hard
: part) the conceptual piece of work the program was attempting to do at the
: same time.

No language, to my knowledge, has an intrinsic "conceptual" view of the
execution.  Conceptual views are a human construct and part of the art
of computer science.  But Python returns three pieces of information on
an exception:
* the exception
* argument(s) to the exception; can be any type, including list, dict,
  instance, function, etc. (in the case of an OS error, this is a tuple
  of the errno value and perror string)
* traceback, which includes the stack, function, code file, line number,
  etc.

I won't go into how Python's exception handling is more advanced tho.

: If I can't get all that automagically from exceptions, I have to throw my
: own exceptions that include the information that I want.  Which takes us
: back to what Perl does.

If you want to throw an exception with conceptual information, then you'll
have to do it yourself, in any language: Perl, Python, Tcl, C.

Perl still has the confusion that $!/$OS_ERRNO is a string AND a number
with a different value, which contradicts how scalars are documented to
work (in general).  This is Perl contradiction number what?

  $ perl -e 'chdir("/foo"); print $!+0, "\t", $!, "\n";'
  2       No such file or directory

As for exceptions in Perl, it wasn't until Perl 5 that you could use a
block in an eval.  Which means that the trapped code fragment is
compiled at runtime in releases before Perl 5.  And there is supposedly
a documented one-time overhead to using eval (it's been a long time
since I've seen that reference, so that might have changed).

  -Arcege

FYI: I was a Perl scripter for more than four years.  Then Perl 5 came
out; I laughed in dismay and started looking for something better.
Another person lost to the Perl community because of the corrupted
syntax (and before anyone tries to flame.. that is my opinion, based on
fact of syntax/design changes in Perl).


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

Date: Sat, 31 Oct 1998 14:45:13 GMT
From: "Michael P. Reilly" <arcege@shore.net>
Subject: Re: Not to start a language war but..
Message-Id: <ZnF_1.391$%C5.52195@news.shore.net>

In comp.lang.python LIN Li <li-za.li@ubs.com> wrote:
: Just curious, can someone show me how to create all these routines for a
: class using another routine in Python? (Do you need these things for a
: Python class at all?) Code similar to these should never happen in a
: highlevel __Elegant__ language like Python. The result may persue me to
: use python (JPython) for my next big project.

I'm making some assumptions of what the missing Java code is, but:

from StringIO import StringIO # standard library module
class StringBuffer(StringIO):
  def append(self, value):
    self.write(str(value)) # append to buffer
    return self.getvalue() # return the whole thing (should this be?)

or to write your own:

class StringBuffer:
  from string import join
  def __init__(self):
    self.string = []
  def __str__(self):  # for use in print and format strings
    return self.join(self.string, '')
  def append(self, value):
    self.string.append(str(value))
    return str(self)  # don't know why the string is returned
  def prepend(self, value):
    self.string.insert(0, str(value))
    return str(self)

  -Arcege

: Walter Tice USG wrote:
:> 
:  In article <718rsc$ctn$1@client3.news.psi.net> abigail@fnx.com writes:
:  >Zenin (zenin@bawdycaste.org) wrote on MDCCCLXXXV September MCMXCIII in
:  ><URL:news:909623452.948196@thrush.omix.com>:
:  >++ Dave Kirby <dkirby@bigfoot.com> wrote:
:  >++
:  >++     From my current (blagh) Java project:
:  >++
:  >++     public StringBuffer append (boolean bool)   {
: extractStringBuffer().append (bool); type = STRING; return string; }
:  >++     public StringBuffer append (char     ch)    {
: _extractStringBuffer().append (ch);   type = STRING; return string; }
:  >++     public StringBuffer append (int     num)    {
: _extractStringBuffer().append (num);  type = STRING; return string; }
:  >++     public StringBuffer append (long    num)    {
: _extractStringBuffer().append (num);  type = STRING; return string; }
:  >++     public StringBuffer append (float   num)    {
: _extractStringBuffer().append (num);  type = STRING; return string; }
:  >++     public StringBuffer append (double  num)    {
: _extractStringBuffer().append (num);  type = STRING; return string; }
:  >++     public StringBuffer append (Object  obj)    {
: _extractStringBuffer().append (obj);  type = STRING; return string; }
:  >++     public StringBuffer append (String  str)    {
: _extractStringBuffer().append (str);  type = STRING; return string; }
:  >++     public StringBuffer append (char[]  data)   {
: _extractStringBuffer().append (data); type = STRING; return string; }


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

Date: 31 Oct 1998 14:51:56 GMT
From: lvirden@cas.org
Subject: Re: Perl & Y2K - booby trap code
Message-Id: <71f86c$21g$1@srv38s4u.cas.org>


According to Matthew Bafford <dragons@scescape.net>, quoting the perl faq:
:The year returned by these functions when used in an array context is 
:the year minus 1900.
:
:For years between 1910 and 1999 this happens to be a 2-digit decimal 
:number.

For the more literal minded, or people using English as a secondary language,
the question might arise "what about the year returned by these functions
when NOT used in an array context - what value is returned then"...
-- 
<URL:mailto:lvirden@cas.org> Quote: Saving the world before 
<*> O- <URL:http://www.purl.org/NET/lvirden/> |     bedtime.
Unless explicitly stated to the contrary, nothing in this posting
should be construed as representing my employer's opinions.


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

Date: 31 Oct 1998 15:10:18 +0200
From: Jarkko Hietaniemi <jhi@alpha.hut.fi>
Subject: Re: Perl for the mainframe?
Message-Id: <oeeogqsj2rp.fsf@alpha.hut.fi>


Ken Munro <ken.munro@ns.sympatico.ca> writes:

> This may seem like an absurd question, but is there a port of the Perl

Why absurd?

> interpreter for the OS390 MVS IBM mainframe?

Yes.

You should be able to compile the version 5.005_02 straight from the source.
Grab the latest stable source from

	http://www.perl.org/CPAN/src/stable.tar.gz


Or, if you can live with an older binary release

	http://www.perl.org/CPAN/ports/index.html

and follow the OS390 link.

> I've written a Perl script to process mainframe JCL. Can I run it on the
> mainframe itself, rather than having to do some intermediary file
> transfering?

I would say yes, you can, but then again I am far from a mainframe
expert.  You probably want to join the mailing list perl-mvs@perl.org
and ask there.  Take a look at

	http://www.perl.org/maillist.html

There are other Perl-related mailing lists too you might want to join.

> Thanks.

You are welcome.

-- 
$jhi++; # http://www.iki.fi/~jhi/
        # There is this special biologist word we use for 'stable'.
        # It is 'dead'. -- Jack Cohen


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

Date: 12 Jul 98 21:33:47 GMT (Last modified)
From: Perl-Request@ruby.oce.orst.edu (Perl-Users-Digest Admin) 
Subject: Special: Digest Administrivia (Last modified: 12 Mar 98)
Message-Id: <null>


Administrivia:

Special notice: in a few days, the new group comp.lang.perl.moderated
should be formed. I would rather not support two different groups, and I
know of no other plans to create a digested moderated group. This leaves
me with two options: 1) keep on with this group 2) change to the
moderated one.

If you have opinions on this, send them to
perl-users-request@ruby.oce.orst.edu. 


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.  

To submit articles to comp.lang.perl.misc (and this Digest), send your
article to perl-users@ruby.oce.orst.edu.

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.

The Meta-FAQ, an article containing information about the FAQ, is
available by requesting "send perl-users meta-faq". The real FAQ, as it
appeared last in the newsgroup, can be retrieved with the request "send
perl-users FAQ". Due to their sizes, neither the Meta-FAQ nor the FAQ
are included in the digest.

The "mini-FAQ", which is an updated version of the Meta-FAQ, is
available by requesting "send perl-users mini-faq". It appears twice
weekly in the group, but is not distributed in the digest.

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 V8 Issue 4118
**************************************

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