[7578] in Perl-Users-Digest

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

Perl-Users Digest, Issue: 1204 Volume: 8

daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Tue Oct 21 10:27:23 1997

Date: Tue, 21 Oct 97 07:00:50 -0700
From: Perl-Users Digest <Perl-Users-Request@ruby.OCE.ORST.EDU>
To: Perl-Users@ruby.OCE.ORST.EDU (Perl-Users Digest)

Perl-Users Digest           Tue, 21 Oct 1997     Volume: 8 Number: 1204

Today's topics:
     Re: ARGV question (Keith Willis)
     Can perl be maken to Compiler instead of interpreter? <www@ultra2.src.ncu.edu.tw>
     Re: Can perl be maken to Compiler instead of interprete <seay@absyss.fr>
     Date calculations in Perl (Yue H K Ken)
     E-Mail by perl... <dassri@willinet.net>
     Re: E-Mail by perl... (Mike Stok)
     Example code for a News Reader (Chizl)
     Re: Example code for a News Reader (Mike Stok)
     Re: Fastest Compare On Array Elements <friedman@uci.edu>
     Re: fill out web form ? <Carry.Megens@nym.sc.philips.com>
     Re: Help: redirected STDOUT lost (buffer overflow?) (Nem W Schlecht)
     IP to hostname doesn't work after Dial up update (Win95 <jbokma@caiw.nl>
     Method ``print'' invocation syntax --- only one form po <tobez@plab.ku.dk>
     Re: non-greedy regexps <eike.grote@theo.phy.uni-bayreuth.de>
     Re: non-greedy regexps <ajohnson@gpu.srv.ualberta.ca>
     Re: Perl Bug Report <Greg.Allen@csfp.co.uk>
     perl debugger doesn't show "my" vars. <beg@mrl.sps.mot.com>
     Re: perl on vax (Mike Stok)
     Preprocessor for perl. (was: Re: Perl equivalent to #if (Janne Leppdnen)
     Re: Preprocessor for perl. (was: Re: Perl equivalent to <seay@absyss.fr>
     Re: Q: How to setup a default argument in a function? <seay@absyss.fr>
     Re: Save As... Name on MS Word downloads <tneohcb@pc.jaring.my>
     Segmentation Fault in sort! <phiroze@eecs.umich.edu>
     Re: setuid not changing uid (Nem W Schlecht)
     Re: text wrap (Nem W Schlecht)
     The problem is about "cookie". <alexis@email.gcn.net.tw>
     Re: What's wrong with my script ???? <eike.grote@theo.phy.uni-bayreuth.de>
     Digest Administrivia (Last modified: 8 Mar 97) (Perl-Users-Digest Admin)

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

Date: Tue, 21 Oct 1997 12:40:48 GMT
From: keith_willis.junk@non-hp-unitedkingdom-om1.om.hp.com (Keith Willis)
Subject: Re: ARGV question
Message-Id: <34559f71.960119979@news>

On 17 Oct 1997 02:59:25 -0500, nem@abattoir.cc.ndsu.nodak.edu (Nem W
Schlecht) wrote:

>[courtesy copy e-mailed to author(s)]
>
>In comp.lang.perl.misc, Alan  <ahecker@interport.net> wrote:
>>
>>So, if I do:
>>
>>$count = 1;
>>$len = @ARGV;
>>until ($count == $len) {
>>      open (IN, $ARGV[$count]);
>>      #do some operations here
>>      close (IN);
>>      $count++;
>>}

or:

#!/usr/bin/perl -w
use strict;
while (<>) {
   print "File $ARGV\n";
   close ARGV;
}

----------------------------------------------------------------------
The above message reflects my own views, not those of Hewlett Packard.
When emailing me, please note that there is no '.junk' in my address.


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

Date: Tue, 21 Oct 1997 19:38:19 +0800
From: www <www@ultra2.src.ncu.edu.tw>
Subject: Can perl be maken to Compiler instead of interpreter?
Message-Id: <344C942B.53849CE2@ultra2.src.ncu.edu.tw>

hi all,

       I have perl interpreter. I want a perl compiler to compile my
*.pl program

to *.ext in NT. IS there any perl compiler been maken or source code I
can make

them to compiler?  Would any body tell me?

Thanks
lai @src.ncu.edu.tw




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

Date: Tue, 21 Oct 1997 14:16:50 +0200
From: Doug Seay <seay@absyss.fr>
To: www@ultra2.src.ncu.edu.tw
Subject: Re: Can perl be maken to Compiler instead of interpreter?
Message-Id: <344C9D32.5D62969D@absyss.fr>

[posted and mailed]

www wrote:
> 
> hi all,
> 
>        I have perl interpreter. I want a perl compiler to compile my
> *.pl program
> 
> to *.ext in NT. IS there any perl compiler been maken or source code I
> can make
> 
> them to compiler?  Would any body tell me?

"perldoc perlfaq3" for the question

	How can I compile my Perl program into byte code or C?

Also there might be something special for NT not unlike dump/undump for
Unix.  Dunno, but it wouldn't be portable.

Also, I note that ask for something with a .pl suffix.  .pl is, for the
most part, ancient history.  .pl was for perl library files which have
been replaced by perl module (.pm) files.  Are you using perl4 perhaps? 
Use "perl -v" to find out what version you use.

- doug


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

Date: Tue, 21 Oct 1997 09:00:12 GMT
From: kyue@ouhk.edu.hk (Yue H K Ken)
Subject: Date calculations in Perl
Message-Id: <62hqf7$ecq@du04.oli.hk>

Hi,

Is there any shareware module that can do date calculations for Perl ?
(except the common DateCalc3.2 written in C, since our host machine 
hasn't got an ansi C compiler).

Best Regards,
Ken


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

Date: Sun, 19 Oct 1997 19:36:07 -0500
From: "Sribatsa Das" <dassri@willinet.net>
Subject: E-Mail by perl...
Message-Id: <62e97f$dap$1@news.willinet.net>

Folks,

I am in the process of writing a perl program to send mails through my SMPT.
I'm able to send the message with subject and attachment with subject.  I
refered to RFC 2183.  I'm not able to send a message with a subject, body
and attachment.

Have any of you attempted this?  If you have any hints, I would appreciate
to have that.

Thanks.

---Sri




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

Date: 21 Oct 1997 13:42:56 GMT
From: mike@stok.co.uk (Mike Stok)
Subject: Re: E-Mail by perl...
Message-Id: <62ibh0$pqt@news-central.tiac.net>

In article <62e97f$dap$1@news.willinet.net>,
Sribatsa Das <dassri@willinet.net> wrote:

>I am in the process of writing a perl program to send mails through my SMPT.
>I'm able to send the message with subject and attachment with subject.  I
>refered to RFC 2183.  I'm not able to send a message with a subject, body
>and attachment.
>
>Have any of you attempted this?  If you have any hints, I would appreciate
>to have that.

The README for the MIME Tools module contains this:

NAME
    MIME-tools - modules for parsing (and creating!) MIME entities

SYNOPSIS
    Here's some pretty basic code for parsing a MIME message, and outputting
    its decoded components to a given directory:

        use MIME::Parser;

        # Create parser, and set the output directory:
        my $parser = new MIME::Parser;
        $parser->output_dir("$ENV{HOME}/mimemail");

        # Parse input:
        $entity = $parser->read(\*STDIN) or die "couldn't parse MIME stream";

        # Take a look at the top-level entity (and any parts it has):
        $entity->dump_skeleton; 


    Here's some code which composes and sends a MIME message containing
    three parts: a text file, an attached GIF, and some more text:

        use MIME::Entity;

        # Create the top-level, and set up the mail headers:
        $top = build MIME::Entity Type   =>"multipart/mixed",
                                  -From    => "me\@myhost.com",
                                  -To      => "you\@yourhost.com",
                                  -Subject => "Hello, nurse!";

        # Attachment #1: a simple text document: 
        attach $top  Path=>"./testin/short.txt";

        # Attachment #2: a GIF file:
        attach $top  Path        => "./docs/mime-sm.gif",
                     Type        => "image/gif",
                     Encoding    => "base64";

        # Attachment #3: some literal text:
        attach $top  Data=>$message;

        # Send it:
        open MAIL, "| /usr/lib/sendmail -t -i" or die "open: $!";
        $top->print(\*MAIL);
        close MAIL;

so if you're using an up to date perl you can get the module and install
it.  The README was at
ftp://ftp.funet.fi/pub/languages/perl/CPAN/modules/by-category/15_World_Wide_Web_HTML_HTTP_CGI/MIME/MIME-tools-3.204.readme
and ypu'll find the module distribuiton in the same directory.  Aslo on
CPAN (the comprehensive perl archive network) there is a set of modules
known as libnet which allow you to deal with a SMTP server directly rather
than calling sendmail (or using something like blat on NT.)

CPAN also contains the perl list of frequently asked questions and their
answers in the doc directory under CPAN.  If you prefer using a web
browser then http://www.perl.com/ contains links to CPAN.

Hope this helps,

Mike

-- 
mike@stok.co.uk                    |           The "`Stok' disclaimers" apply.
http://www.stok.co.uk/~mike/       |   PGP fingerprint FE 56 4D 7D 42 1A 4A 9C
http://www.tiac.net/users/stok/    |                   65 F3 3F 1D 27 22 B7 41
stok@psa.pencom.com                |      Pencom Systems Administration (work)


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

Date: Tue, 21 Oct 1997 06:33:32 GMT
From: chizl@SPAMkarland.com (Chizl)
Subject: Example code for a News Reader
Message-Id: <344c4c6a.16019950@news.unicomp.net>

Anyone have any example code for a news reader?

L8r,
Chizl - CEO
Karland International
www.karland.com


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

Date: 21 Oct 1997 13:32:23 GMT
From: mike@stok.co.uk (Mike Stok)
Subject: Re: Example code for a News Reader
Message-Id: <62iat7$opj@news-central.tiac.net>

In article <344c4c6a.16019950@news.unicomp.net>,
Chizl <chizl@SPAMkarland.com> wrote:
>Anyone have any example code for a news reader?

No, but the libnet modules for perl 5.xxx avaialble on any comprehensive
perl archive network (CPAN) site contains Net::NNTP.  The docvumentation
for this module starts like this:

NAME
       Net::NNTP - NNTP Client class

SYNOPSIS
           use Net::NNTP;

           $nntp = Net::NNTP->new("some.host.name");
           $nntp->quit;


DESCRIPTION
       Net::NNTP is a class implementing a simple NNTP client in
       Perl as described in RFC977. Net::NNTP inherits its
       communication methods from Net::Cmd

So you may be able to build on that.  CPAN can be reached at its master
site at ftp.funet.fi under /pub/languages/perl/CPAN/ or by browsing the
links on the main page at http://www.perl.com/

Hope this helps,

Mike

-- 
mike@stok.co.uk                    |           The "`Stok' disclaimers" apply.
http://www.stok.co.uk/~mike/       |   PGP fingerprint FE 56 4D 7D 42 1A 4A 9C
http://www.tiac.net/users/stok/    |                   65 F3 3F 1D 27 22 B7 41
stok@psa.pencom.com                |      Pencom Systems Administration (work)


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

Date: 21 Oct 1997 13:30:33 GMT
From: "Eric D. Friedman" <friedman@uci.edu>
Subject: Re: Fastest Compare On Array Elements
Message-Id: <62iapp$se6@news.service.uci.edu>

[mailed, posted]

In article <344AE40B.635F2555@bell-labs.com>,
Stephan Vladimir Bugaj  <bugaj@bell-labs.com> wrote:

<What is the fastest way (computation time, not programmer time) to use
<all of the elements in an array for && and || comparison?
<
<foreach $foo (@bar)
<{
<      if(! $fnord=~/ $foo/) { $flag = 1; }
<}

Can you possibly check these without the regex?  eq is much faster.
On a large array, you'll want to use a for loop and exit as soon
as you can (your flag idea, but with a `last' thrown in):

foreach my $elem (@list)
{
  if ($elem eq $searchfor) { $flag++; last; }
}

If you don't mind checking all of the elements of the array, you
should use grep in a scalar context, which perldoc -f grep 
tells us gives the number of matches for that array. thus:

#!/dcs/bin/perl5 -w

my $lookfor = 'a';

my @search = qw (d e f g a r s t);
my @fail = qw (d e f g b r s t);

my $flag = grep /$lookfor/o, @search; 
if ($flag) { print "got it\n" }

$flag = grep /$lookfor/o, @fail; 
if ($flag) { print "got it\n" }
else { print "nope\n" }

Output:
got it
nope

P.S.  Note the use of /o in the regexes I greped with.  A big win if
you can do it, but eq is still better.
HTH,
Eric

<if(!$flag)
<{
<    #do the thing...
<}
<
<#Logical Or
<#if($fnord=~/$bar[0]/ || ... $fnord=~$bar[n])
<#
<$fnord, $flag=0;
<foreach $foo (@bar)
<{
<    if($fnord=~/$foo/)
<    {
<        $flag = 1;
<        last;
<    }
<}
<if($flag)
<{
<    #do the thing
<}
<
<...but there must be something faster...
<
<Thanks.
<
<LL+P,
<Stephan
<
<
<--
<                        "Do computers think?"
<------------------------------------------------------------------------
<Stephan Vladimir Bugaj                               bugaj@bell-labs.com
<Member of Technical Staff                                 (908) 949-3875
<Multimedia Communication Research Dept.              Rm. 4F-601, Holmdel
<Bell Labs of Lucent Technologies            www.multimedia.bell-labs.com
<PGP Key available from www.pgp.net/wwwkeys.html or your local keyserver.
<Non-Lucent personal website located at www.cthulhu-dynamics.com/stephan.
<------------------------------------------------------------------------
< STANDARD DISCLAIMER:  My opinions are NOT necessarily those of LUCENT.
<------------------------------------------------------------------------
<                "Do submarines swim?" - E.W. Dijkstra
<
<
<


-- 
Eric D. Friedman
friedman@uci.edu


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

Date: Tue, 21 Oct 1997 07:35:32 GMT
From: Carry Megens <Carry.Megens@nym.sc.philips.com>
Subject: Re: fill out web form ?
Message-Id: <344C5B44.4E11@nym.sc.philips.com>

steven wrote:
> 
> hi,
> 
> i would like to write a routine that goes to specific web page and fills
> out a web form. do you how i could do this? if the "method" of that form
> is "post" (i.e., it includes all the information submitted in the URL of
> the web it returns), then this is fairly trivial to do, you can include
> the information in the the URL you open. but the problem is that most of
> the pages i want to do this for use method=get (i.e., the pages they
> return have just standard whatever.cgi or whatever.pl filenames, not
> whatever.cgi?name=steven like the post method does).  do you know how i
> could do this, or somewhere to point me to? i looked in the perl faq,
> but i couldn't find anything of this sort.  thanks.
> 
> steven
Steven, first of all, you mix up things: the GET method uses the
?name=value way of passing name,value pairs to the CGI program,
the POST method uses stdin to send this information.
By the way: a well written CGI program handles both methods...

I suggest you to use javascript to access fields on a web form
and change the values and submit the form.
See for yourself at http://www.javagoodies.com and other 
javascript locations.

hope this helps,

-- 
Carry Megens           Designflow Services  M 2.039        !!!
Philips Semiconductors Consumer IC                        (0o0)
Gerstweg 2             6534 AE Nijmegen                    \U/
Nijmegen               the Netherlands
talkto: +31-24-353 4587
faxto : +31-24-353 3509
seri  : nymegens@nyhp03
mailto:Carry.Megens@nym.sc.philips.com
http://cicc06.nym.sc.philips.com:8080/~nymegens (intrAnet)


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

Date: 21 Oct 1997 01:50:30 -0500
From: nem@abattoir.cc.ndsu.nodak.edu (Nem W Schlecht)
Subject: Re: Help: redirected STDOUT lost (buffer overflow?)
Message-Id: <62hjbm$aco@abattoir.cc.ndsu.nodak.edu>

[courtesy copy e-mailed to author(s)]

In comp.lang.perl.misc, Chris Romano  <romchr@ibm.net> wrote:
>Hi...
>
>I'm trying to redirect the output from a "tar -cvf" command to a file:
>
>I'm trying this on an AIX v3.2.5 and v4.1.4 system:
>
>  open(STDOUT,">/filename");
>  select(STDOUT);$|=1;    # turn off bufferring (i think :-))
>  system ("tar -cvf ./home ./usr ./apps");
>  close(STDOUT);
>
>...unfortunately, I only get the last half of the tar output in my file.
>
>It seems as though a buffer fills up and gets overwritten, and the first
>half
>of the output disappears.

First off, your tar command is wrong.  What file are you trying to create?
How about:

system ("tar -cvf file.tar ./home ./usr ./apps");

Hmm.. why aren't you just doing this:

system ("tar -cvf file.tar ./home ./usr ./apps >/filename");

If you're adding stuff to filename before or after this statement, then
just change the ">" to ">>".

Also, odd things happen when you user system().  The following is what I
would consider a simpler, more careful way of doing it:

open(TAR_OUT, ">filename") || die "Couldn't open <filename>";
open(TAR_COM, "tar -cvf file.tar ./home ./usr ./apps |") || die "No tar";
print TAR_OUT while (<TAR_COM>);
close(TAR_COM);
close(TAR_OUT);

Although, I must note, all of my examples, as well as your original worked
fine on my machine (IRIX 6.2) and on one of our nodes (AIX 4.2.1) in our
SP2.

PS - comp.lang.perl is a dead group.  Please do not cross-post to it.

-- 
Nem W Schlecht                  nem@plains.nodak.edu
NDUS UNIX SysAdmin         http://www.nodak.edu/~nem
"Perl did the magic.  I just waved the wand."


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

Date: 21 Oct 1997 08:17:47 GMT
From: "John Bokma" <jbokma@caiw.nl>
Subject: IP to hostname doesn't work after Dial up update (Win95, Perl 5.003 build 306)
Message-Id: <01bcddf9$c2f71860$02521e0a@tschai>

The following piece of Perl doesn't work anymore after I installed de
Dial Up
Update (Windows'95).

$peer_host = gethostbyaddr(inet_aton($ip), AF_INET);

It just returns a dotted decimal IP address. (on each attempt, even
with
known numbers).

I use Perl 5.003 build 306 (Activeware). I know it is an older
version, but
is it a bug of this version?

Regards,

John


-- 
----------------------------------------------------------------------
------
C A S T L E  A M B E R      Freelance Software Development
(Java/Perl/C/CGI)
http://www.caiw.nl/~jbokma/ [Java demo's, Perl scripts, resume and
more...]
mail:jbokma@caiw.nl         phone: +31 10 4291827



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

Date: Tue, 21 Oct 1997 14:28:59 +0200
From: "tobez@plab.ku.dk" <tobez@plab.ku.dk>
Subject: Method ``print'' invocation syntax --- only one form possible?
Message-Id: <344CA00B.6DA6@plab.ku.dk>

Hi,

Is there any way to use method invocation syntax
  method $ObjRef LIST;
while method name is ``print'' and object underlying
structure is a hash?

For example:
-------------------
package Hashy;

sub new
{
   return bless {}, shift;
}

sub print
{
   shift;
   print @_
}

sub prt
{
   shift;
   print @_
}

package main;

$h = new Hashy;
prt $h "Hi!\n";
$h->print("Hi!\n");
print $h "Hi!\n";
------------

Here prt $h LIST invocation works perfectly fine, $h->print(args) works
as well, but print $h LIST does not --- built-in ``print'' is activated
instead,
which of course fails, for it expects GLOB reference and finds a blessed
HASH
reference.

Is there any workaround?  You know, the syntax is very nice, and
I really MUST have a hash --- my class uses some instance variables.
Another difficulty is that I cannot ``use FileHandle;'' for the output
does not go to any kind of file at all.


Thank you in advance,
Anton.

P.S.  Please, also E-mail your replies --- the traffic in this group is
HUGE.


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

Date: Tue, 21 Oct 1997 08:57:17 +0200
From: Eike Grote <eike.grote@theo.phy.uni-bayreuth.de>
Subject: Re: non-greedy regexps
Message-Id: <344C524D.167E@theo.phy.uni-bayreuth.de>

Hi,

Ashraf Ahmed wrote:
> 
> A perl regexp question ...
> 
> Let's say I have a string like this,
> 
>         "meeabmooabmuuabheheabyum"
>             --   --   --    --
> 
> and let's say that I want to find the (first) *shortest* sub-string
> which starts with "ab" and ends with "ab". In this case, the returned
> string should be
> 
>         "abmooab"

> The FAQ suggests using the perl5 non-greedy constructs, but I seem to
> remember reading somewhere that one should be careful when using
> these. What should I be careful about when using the non-greedy
> constructs?

Maybe the advice you saw was from the early days of Perl 5, because
non-greedy regular expressions don't exist in earlier versions
of Perl and you might have run into compatibility problems, but
today everyone should have upgraded to Perl 5.

> And is there some solution that works without using the
> non-greedy constructs (which would also work in a language that
> doesn't support these constructs)?

The only way I can think of in the moment is to construct a loop
and search for the desired substring "by hand".


Bye, Eike
-- 
=======================================================================
>>--->>    Eike Grote  <eike.grote@theo.phy.uni-bayreuth.de>    <<---<<
-----------------------------------------------------------------------
 Home Page, Address, PGP,...:  http://www.phy.uni-bayreuth.de/~btpa25/
-----------------------------------------------------------------------
 PGP fingerprint:      1F F4 AB CF 1B 5F 4B 1D 75 A1 F9 C5 7B 3F 37 06
=======================================================================


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

Date: Tue, 21 Oct 1997 03:26:14 -0600
From: Andrew Johnson <ajohnson@gpu.srv.ualberta.ca>
Subject: Re: non-greedy regexps
Message-Id: <344C7536.988FBA7@gpu.srv.ualberta.ca>

Iain Chalmers wrote:
!

!  Ashraf Ahmed <ashraf@apollo3.com> wrote:
! 
! > A perl regexp question ...
! >
! >
! > Let's say I have a string like this,
! >
! >         "meeabmooabmuuabheheabyum"
! >             --   --   --    --
! >
! > and let's say that I want to find the (first) *shortest* sub-string
! > which starts with "ab" and ends with "ab". In this case, the returned
! > string should be
! >
! >         "abmooab"
! >
! >
! > I can't use /ab.*ab/, since that will match
! >
! >         "abmooabmuuabheheab"
! >

[snip]

! try /ab.*?ab/

[snip]
 
! > The FAQ suggests using the perl5 non-greedy constructs, but I seem to
! > remember reading somewhere that one should be careful when using
! > these. What should I be careful about when using the non-greedy
! > constructs? And is there some solution that works without using the
! > non-greedy constructs (which would also work in a language that
! > doesn't support these constructs)?

Maybe you could try to find that advice again and see what exactly
the cautionary statements were referring to with regards to non-greedy
quantifiers...
in the meantime, if you are dead-set against using the non-greedy
methods like Iain and the FAQ suggested, then you might look into
negative look-ahead:

$_="meeabmooabmuuabheheabyum";
/(ab(?:.(?!ab))*.ab)/;
print "$1\n";

or perhaps substr(),index(),and length():

$_="meeabmooabmuuabheheabyum";
print substr($_,
         index($_,"ab"),
         index($_,"ab",
         index($_,"ab")+1)-
         index($_,"ab")+
         length("ab")
      );
#:-)

of course, 'other' languages might not support these
constructs either sooo... maybe you'll want to just
use .*? after all :-)

regards
andrew


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

Date: Tue, 21 Oct 1997 11:39:43 +0100
From: Greg Allen <Greg.Allen@csfp.co.uk>
Subject: Re: Perl Bug Report
Message-Id: <344C866F.2E7D@csfp.co.uk>

Charles Margolin wrote:
> Not a bug.  Your statement
>   my $z = $y->{'1'} if defined $y;
> would do two things if it had been executed:  declare the lexical
> $z and set its value.  Here it did neither, so $z is a package
> "global" variable. It was set to "a" on the first call, so it
> is still defined in the second call.

Shouldn't -w be able to detect this and warn, hence "predicated
declarations" would be actively discouraged, on the assumption that
you'd probably never want to use them. A preferable coding style might
be:
	my $z = defined $y && $y->{1};
or in this particular case:
	my $z = defined $y ? $y->{1} : $x;

Note I have perl 5.002, which doesn't warn, perhaps 5.004 does?
test case that should warn under "-w":

	#! /usr/local/bin/perl5 -w
	use strict;
	my $fred = "hello" if exists $ENV{dontOptimiseMe};

where exists $ENV{} is just a non-constant expression that can't be
optimised away.

anyone know better?
_____________________________________________________
Greg Allen             
OTC Settlement Systems     
Credit Suisse Financial Products
_____________________________________________________


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

Date: 21 Oct 1997 02:33:18 -0700
From: Evgenij Beresin <beg@mrl.sps.mot.com>
Subject: perl debugger doesn't show "my" vars.
Message-Id: <6yb3n5uld.fsf@mrl.sps.mot.com>

Hi all,

Recently I started to use perl debugger (-d option),
and discovered that it doesn't show vars declared as "my".
Global and "local" vars are displayed OK.
What is wrong?

(email reply will be appreciated)

Evgenij Beresin


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

Date: 21 Oct 1997 13:27:38 GMT
From: mike@stok.co.uk (Mike Stok)
Subject: Re: perl on vax
Message-Id: <62iaka$odd@news-central.tiac.net>

In article <344C2F6B.920CC1FA@alumni.nctu.edu.tw>,
Wuulong Sheu  <wuulong@alumni.nctu.edu.tw> wrote:
>can I use perl on vax?

There is a README.vms in the distribution which says:

Last Revised 11-September-1997 by Dan Sugalski <sugalsd@lbcc.cc.or.us>
Originally by Charles Bailey <bailey@newman.upenn.edu>

* Intro

The VMS port of Perl is as functionally complete as any other Perl port
(and as complete as the ports on some Unix systems). The Perl binaries
provide all the Perl system calls that are either available under VMS or
reasonably emulated. There are some incompatibilites in process handling
(e.g the fork/exec model for creating subprocesses doesn't do what you
might expect under Unix), mainly because VMS and Unix handle processes and
sub-processes very differently.

There are still some unimplemented system functions, and of coursse we
could use modules implementing useful VMS system services, so if you'd
like
to lend a hand we'd love to have you. Join the Perl Porting Team Now!

The current sources and build procedures have been tested on a VAX using
VaxC and Dec C, and on an AXP using Dec C. If you run into problems with
other compilers, please let us know.

[...]

so if you're using VMS on your vax then you are probably OK.

Hope this helps,

Mike

-- 
mike@stok.co.uk                    |           The "`Stok' disclaimers" apply.
http://www.stok.co.uk/~mike/       |   PGP fingerprint FE 56 4D 7D 42 1A 4A 9C
http://www.tiac.net/users/stok/    |                   65 F3 3F 1D 27 22 B7 41
stok@psa.pencom.com                |      Pencom Systems Administration (work)


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

Date: 21 Oct 1997 06:16:36 GMT
From: Janne.Leppanen@metla.fi (Janne Leppdnen)
Subject: Preprocessor for perl. (was: Re: Perl equivalent to #ifdef in C?)
Message-Id: <62hhc4$pf3$1@bambu.metla.fi>

>There is an option to use cpp to preprocess commands, but many of us
>don't like it.  Personally, I don't like using cpp for several reasons
>
>        - this is Perl, not C (why not use m4?)

I also think that most cpp programs suck... gcc's version is usable.
Don't know about m4.

>        - compilation would take even longer

Preprocessing is usually VERY fast. 
(besides the actual code will run faster and will be smaller)

>        - it adds no new functionality
>        - # is now for comments and cpp commands
>
>I'd rather see stuff like
>
>BEGIN   {
>        if ( $config_option )
>                { eval { sub foo() { "yes"; } } };
>        else
>                { eval { sub foo() { "no"; } } };
>        die "error with foo: @_\n";
>        }
>
>or for this particular (trivial) case
>
>        use constant FOO => ($config_option ? "yes" : "no" );
>
>For more complicated options, how about
>
>BEGIN   {
>        if ( $config_option )
>                { require 'unix.stuff.pm'; }
>        else
>                { require 'non-unix.stuff.pm'; }
>        }
>
>Actually the BEGIN would be optinal here, but I'd rather get the errors
>from require early and not start "real" processing with invalid
>syntax.   Of course, YMMV and you can use that ugly cpp all you like.

I'd rather see.

	**if 	defined(config_option)
		require 'unix.stuff.pm';
	**else	
		require 'non-unix.stuff.pm';
        **fi

	or 


	**{}= defined(debug);

	sub foo
	{
	  **{ die if ($i < 10); }**	# done if debug defined
	}

	or

	**{ require 'unix.stuff.pm'; 		}**if defined(config_option)
	**{ require 'non-unix.stuff.pm'; 	}**else

	or something more throughly thinked.

And all this would be done while developing the app.. and the
preprocessed file should be installed so it is run by user. 

Perl currenly looses to c++ atleast in speed and typechecking... so
I must use c++ for tasks that require those (+overloading). Perl however 
seems to be more vivid language so hopefully it'll change to be more serious 
language for programmers like me.



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

Date: Tue, 21 Oct 1997 14:44:44 +0200
From: Doug Seay <seay@absyss.fr>
To: Janne Leppdnen <Janne.Leppanen@metla.fi>
Subject: Re: Preprocessor for perl. (was: Re: Perl equivalent to #ifdef in C?)
Message-Id: <344CA3BC.5FD757DE@absyss.fr>

[posted and mailed]

it looks like this was originally posted and CC'd to me, but I never saw
the posting.  This is based of the copy I got via email.  Perhaps the
UCE has struck again?

Janne Leppdnen wrote:
> 
> >There is an option to use cpp to preprocess commands, but many of us
> >don't like it.  Personally, I don't like using cpp for several reasons
> >
> >        - this is Perl, not C (why not use m4?)
> 
> I also think that most cpp programs suck... gcc's version is usable.
> Don't know about m4.

My bone with cpp isn't that it sucks (which it well may), but that it
was made for _C_.  C is an excellent language for many problems, but it
isn't Perl.  I don't think the two should be intermixed anymore than I
think APL and VisualBasic should be combined.  Sure, Perl's XS stuff
understands C, but that doesn't mean the two languages are
interchangable.  And I just mentioned m4 because it is "generic".  I
think it sucks much more than any cpp I've used.

> >        - compilation would take even longer
> 
> Preprocessing is usually VERY fast.
> (besides the actual code will run faster and will be smaller)

But it is still an extra step.  It will add a non-zero amount of time to
the compilation step.  As for smaller, why do you say that?  Perl uses
"constant folding" which is a technique to remove useless if/else
branches/loops/whatever that are not used.  Think about

	use constant DEBUG => 0;

	if ( DEBUG )
		{ print "lots of debugging information\n"; }
	else
		{ print LOG "log event\n"; }

this will be reduced by perl to the simpler

	print LOG "log event\n";

At the byte code level, the two should be identical.  The "if" and the
unused branch were "constant folded" away.  At runtime, they simply
don't exist.  What does cpp give you that this doesn't?  I don't want to
be offensive, but you are programming Perl, but thinking C.  Most of us
did that at first.  Try to look for a Perl solution to your problems and
work with the language, not against it.

	<snipped examples using BEGIN>

> I'd rather see.
> 
>         **if    defined(config_option)
>                 require 'unix.stuff.pm';
>         **else
>                 require 'non-unix.stuff.pm';
>         **fi
> 
>         or
> 
>         **{}= defined(debug);
> 
>         sub foo
>         {
>           **{ die if ($i < 10); }**     # done if debug defined
>         }
> 
>         or
> 
>         **{ require 'unix.stuff.pm';            }**if defined(config_option)
>         **{ require 'non-unix.stuff.pm';        }**else
> 
>         or something more throughly thinked.

I take it that you want ** to be a prefix for conditional compilation
keywords.  Sure, it works, but what does it do that BEGIN doesn't?  Not
that I'm a big fan of BEGIN, mind you.  I'm just stating that this
functionality already exists in the language.  You want to add syntax
without adding capability.  That is work for no gain, which violates the
"if it ain't broke, don't fix it" priciple.


> And all this would be done while developing the app.. and the
> preprocessed file should be installed so it is run by user.

The the files aren't "run" as anyone.  The "require" directive imports
the file into the current process (not unlike cpp's #include, but it
compiles and runs this file too).  Everything stays in the same process,
the euid/ruid aren't changed either.


> Perl currenly looses to c++ atleast in speed and typechecking... so
> I must use c++ for tasks that require those (+overloading). Perl however
> seems to be more vivid language so hopefully it'll change to be more serious
> language for programmers like me.

I trust that you are not implying that Perl is a non-serious language
(sorry for the double negative).  Although the Perl base is kinda small
by C/C++ standards, it is never-the-less a serious language.  If you
want a "toy" language, go look at tcl :-)

Speed is in the eyes of the beholder.  I can develop a simple TCP/IP
server more quickly in Perl than I can in C++, so for my development
time, Perl is faster.  True that for raw execution speed C is faster,
but is that the only concern?  And I think that the heavy type checking
of C++ went overboard.  IIRC there is no way to return a NULL pointer
for an object reference (object &obj).  You have to create an error
instance of this object and supply that instead.  This is a typechecking
overkill, don't you think?  While you could pass a pointer instead of a
reference (object *obj), this seems to be less common.  But I seem to be
moving away from the idea of #ifdef and into Perl<->C++ advocacy, so I'm
gonna stop here.

- doug


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

Date: Tue, 21 Oct 1997 10:38:11 +0200
From: Doug Seay <seay@absyss.fr>
To: Eric Heft <eheft@dnaco.net>
Subject: Re: Q: How to setup a default argument in a function?
Message-Id: <344C69F3.51CB1323@absyss.fr>

[posted and mailed]

Eric Heft wrote:
> 
> Hi,
> 
>    What I want to do is have a function that takes a variable number of
> arguments.
> If an argument is not passed, I'll like to set a specific value to it.
> For example
> the following function rnd might be called as:
> 
> rnd(1,6);
> rnd(2,10);
> rnd(1,10,6);

	sub	rnd ($$;$)
	{
	my ($numDie,$die,$cnt) = @_;
	$cnt ||= 0;

This says that if $cnt has a false value (such as undefined), then use
0.  In general, if false values are acceptable and you can only use the
default value if the variable is undefined, that would be

	$cnt = 0 unless ( defined $cnt );

- doug


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

Date: Tue, 21 Oct 1997 20:36:17 +0800
From: Simon Tneoh Chee-Boon <tneohcb@pc.jaring.my>
To: Martien Verbruggen <mgjv@comdyn.com.au>
Subject: Re: Save As... Name on MS Word downloads
Message-Id: <344CA1C1.5165@pc.jaring.my>

Martien Verbruggen wrote:
[snip]
> An answer to your question:
> invoke the cgi with a url like:
> http://some_server/cgi-path/script_name/save_as_this.doc
> Martien
Another solution which works in netscape, is using the following
headers:
Content-Type: file/type
Content-Disposition: filename="filename"

You can take a look at the example at
http://www.tneoh.zoneit.com/cgi/upload/
Hope this helps.

--
Simon Tneoh Chee-Boon
Application Developer	Hitechniaga Sdn. Bhd.
tneohcb@pc.jaring.my	60-3-9660966
http://www.tneoh.zoneit.com/simon/


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

Date: Tue, 21 Oct 1997 09:24:35 -0400
From: Phiroze Parakh <phiroze@eecs.umich.edu>
Subject: Segmentation Fault in sort!
Message-Id: <344CAD13.ED218E8F@eecs.umich.edu>

perl's sort keeps giving me this error: Segmentation Fault
I know what a SEGV is, however, what bothers me is that is occours in
sort!

here is my code:
@pidx = @pidx [ sort bySideNameIndexDir 0..$#pidx  ];

sub bySideNameIndexDir {

  my ($ra, $pa, $ta, $sa, $ia) = ($pidx[$a]{rname}, $pidx[$a]{port}, 
				  $pidx[$a]{type},  $pidx[$a]{side}, 
				  $pidx[$a]{idx});
  my ($rb, $pb, $tb, $sb, $ib) = ($pidx[$b]{rname}, $pidx[$b]{port}, 
				  $pidx[$b]{type},  $pidx[$b]{side}, 
				  $pidx[$b]{idx});

  if ($NN{$sa} == $NN{$sb}) {
    if ($ia == $ib) {
      return $pa cmp $pb;
    } else {
      if ((exists $order{$pa}) && ($order{$pa}{dir} eq "up")) {
	return $ia <=> $ib;
      } elsif ((exists $order{$pa}) && ($order{$pa}{dir} eq "down")) {
	return $ib <=> $ia;
      } else {
	$order{$pa}{dir} = 'down';
	return $ia <=> $ib;
      }
    }
  } else {
    return $NN{$sa} <=> $NN{$sb};
  }
}

##############

Now what seems to be happening, is that after 200+ calls to
bySideNameIndexDir, $a becomes corrupted!
the routine gets entered with $a == "".  Soon $b becomes "" and I get my
Segmentation Fault.

I run the code with -wT and use strict
No problems there.  the -w tells me when the sort routine starts to get
$a == "" because $pidx[$a]{...} 
will be an unitialised value. I also checked for $a and $b in my code
and found none! The size of pidx = 360.
PS: If sort calls C's qsort, then I do know that on some qsorts, an out
of bound memory read ma be performed
 . This was detected when I purified some C code.

Help.

-- Phiroze
-- 

    ...../\/\/\.../\....../\./\/\/\...      phiroze@engin.umich.edu
   ...../\..../\./\/\..../\./\..../\.       phiroze@eecs.umich.edu
  ...../\/\/\/\./\../\../\./\/\/\/\.        UNIVERSITY OF MICHIGAN
 ...../\......./\..../\/\./\.......  Electrical Engineering & Computer
Science
 ...../\......./\....../\./\.......       Advanced Computer Architecture
Lab


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

Date: 21 Oct 1997 01:23:26 -0500
From: nem@abattoir.cc.ndsu.nodak.edu (Nem W Schlecht)
Subject: Re: setuid not changing uid
Message-Id: <62hhou$a2n@abattoir.cc.ndsu.nodak.edu>

[courtesy copy e-mailed to author(s)]

In comp.lang.perl.misc, Scott Smith <scottsmi@blue.seas.upenn.edu> wrote:
>When I try running a setuid perl script, it runs as the user invoking
>the script.  This happened both with a real script that was denied
>permission to do what it should have been trying to do as root and with
>this test script
>	#!/usr/bin/perl
>	use English; print "$EUID\n";

It may be that your system does not allow this.
Look at the 'suidscript.pl' program, description and code are in the
"Programming Perl" book, *FIRST* edition (the one with the purple-pink
binder) on page 305.  I'm sure you can also get it from an O'Reilly FTP
site.  It will compile a C wrapper that you can set the set-uid stuff on.

-- 
Nem W Schlecht                  nem@plains.nodak.edu
NDUS UNIX SysAdmin         http://www.nodak.edu/~nem
"Perl did the magic.  I just waved the wand."


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

Date: 21 Oct 1997 01:30:14 -0500
From: nem@abattoir.cc.ndsu.nodak.edu (Nem W Schlecht)
Subject: Re: text wrap
Message-Id: <62hi5m$a5p@abattoir.cc.ndsu.nodak.edu>

[courtesy copy e-mailed to author(s)]

In comp.lang.perl.misc, Mike Rambour <name@server.com> wrote:
>  I am trying to make the text::wrap module work, but I dont have
>privs on the server to put the module anywhere but my own cgi
>directory.  I dont know how to do this, I assume I copy the wrap.pm
>into my cgi and in my script somehow tell it to use that module in my
>directory. 
>
>  So how do I do that please ? I think I need to modify the @INC but I
>am not sure, and I am not even sure if thats right.

Add this to the top of your script, before the 'use Text::Wrap' line:

use lib '/full/path/to/directory/where/module/is/;

Note: this should point to the directory where the "Text" directory is.  In
that "Text" directory should be the file "Wrap.pm".

Modifying @INC would only be effective if you put it in the BEGIN routine:

BEGIN {
  push(@INC, '/full/path/to/directory/where/module/is/');
}


-- 
Nem W Schlecht                  nem@plains.nodak.edu
NDUS UNIX SysAdmin         http://www.nodak.edu/~nem
"Perl did the magic.  I just waved the wand."


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

Date: Tue, 21 Oct 1997 14:42:08 +0800
From: alexis <alexis@email.gcn.net.tw>
Subject: The problem is about "cookie".
Message-Id: <344C4EC0.36B1@email.gcn.net.tw>

Hi everybody:

As a Internet programmer, I always deal with a lot of problem for CGI
and Web servers. Recently, I have encountered a serious problem about
using Perl on NT IIS. 
The problem is about "cookie". I used "Set-Cookie:" command in UNIX web
server and it just worked fine, but once I moved the same scource code
to NT than everything went wrong. Netcsape browser can no longer detect
the cookie I have set. Is the ENV "HTTP_COOKIE" wrong?

If any friend know the problem above, please give me a hit.

Thanks a million!!


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

Date: Tue, 21 Oct 1997 08:52:06 +0200
From: Eike Grote <eike.grote@theo.phy.uni-bayreuth.de>
Subject: Re: What's wrong with my script ????
Message-Id: <344C5116.41C6@theo.phy.uni-bayreuth.de>

Hi,

B.S.LEE wrote:
> 
> I have written a perl cgi script and I try to test it on my server but
> it can't run. I really can't figure out what's wrong with my script. I
> keep getting the error message as below:-
> 
> Can't modify subtraction in scalar assignment at
> C:\WebShare\wwwroot\cgi-bin\test1.pl line 13, near "$value;"Execution
> of C:\WebShare\wwwroot\cgi-bin\test1.pl aborted due to compilation
> errors..
> 

    [...]
>                 $regis-data{$name1}=$value;
    [...]               ^
                     variable names must not not contain '-' !
                     (better use an underscore '_' instead)


Bye, Eike
-- 
=======================================================================
>>--->>    Eike Grote  <eike.grote@theo.phy.uni-bayreuth.de>    <<---<<
-----------------------------------------------------------------------
 Home Page, Address, PGP,...:  http://www.phy.uni-bayreuth.de/~btpa25/
-----------------------------------------------------------------------
 PGP fingerprint:      1F F4 AB CF 1B 5F 4B 1D 75 A1 F9 C5 7B 3F 37 06
=======================================================================


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

Date: 8 Mar 97 21:33:47 GMT (Last modified)
From: Perl-Request@ruby.oce.orst.edu (Perl-Users-Digest Admin) 
Subject: Digest Administrivia (Last modified: 8 Mar 97)
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.  

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

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