[7297] in Perl-Users-Digest

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

Perl-Users Digest, Issue: 922 Volume: 8

daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Tue Aug 26 04:17:18 1997

Date: Tue, 26 Aug 97 01:00:38 -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, 26 Aug 1997     Volume: 8 Number: 922

Today's topics:
     $#name ???? denis@mathi.uni-heidelberg.de
     Re: $#name ???? <dshoyt@worldnet.att.net>
     ANNOUNCEMENT: Python Conference Program <guido@eric.cnri.reston.va.us>
     Re: Calculating Days between two dates!! <rootbeer@teleport.com>
     Re: cardinality of an array given a reference <rootbeer@teleport.com>
     Re: cardinality of an array given a reference <rael@zx81.dnai.com>
     Does anyone know how to call a perl script with 2 argum <dongmien@cs.washington.edu>
     Domain User Management with Perl32 <jamie_gaines@unc.edu>
     Re: Extensions <dshoyt@worldnet.att.net>
     FOUND: Info for Perl on Windows NT (Viper)
     Getting started with ODBC.pm on MSsql6.5 (Danny Aldham)
     Help!! mail from cgi/perl-script under win-nt/windmail ol@pp-ulm.de
     How do I break up a line (Mike Rambour)
     How do I pass data to a sort function? (Scott Grosch)
     Re: How do I pass data to a sort function? (Josh Purinton)
     Re: last line of a @list... (Andrew M. Langmead)
     list contents of directory... <thomasdj@wam.umd.edu>
     Re: PERL 5.001 on WIN NT 4.0 with IIS 3.0 (Viper)
     Re: perl cgi and mastercard <cs@zip.com.au>
     Problem with sub and my <jhitt@engin.umich.edu>
     Problems with backticks <ralph_janke@writeme.com>
     protect a perl-script (Benjamin Butz)
     Re: ReadParse <rootbeer@teleport.com>
     RegExp Win95/NT4.0 ? <Marc_Filthaut@HP.com>
     Re: Send question for Perl Gurus (Josh Purinton)
     This server does not work on IRIX 5.3 <manu@ipbs.fr>
     Re: When to use "use strict" <nospam@domain.com>
     Re: When to use "use strict" (Mike Heins)
     Re: When to use "use strict" (Josh Purinton)
     Digest Administrivia (Last modified: 8 Mar 97) (Perl-Users-Digest Admin)

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

Date: Tue, 26 Aug 1997 09:18:30 +0200
From: denis@mathi.uni-heidelberg.de
Subject: $#name ????
Message-Id: <34028346.41C6@mathi.uni-heidelberg.de>

hi,

i just tried to read the "far more than everything you've ever wanted
to know about sorting" www page.
there i read something like $list[$#list]. i didn't find it in the 
camel book :-( what does $#list mean?
thanks

	denis


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

Date: Mon, 25 Aug 1997 22:00:34 -1000
From: "Dave Hoyt" <dshoyt@worldnet.att.net>
Subject: Re: $#name ????
Message-Id: <5tu102$lsu@mtinsc03.worldnet.att.net>


 denis@mathi.uni-heidelberg.de wrote in article <34028346.41C6@mathi.uni-hei
delberg.de>...
>there i read something like $list[$#list]. i didn't find it in the
>camel book :-( what does $#list mean?

Denis,
The $# in front of an array variable will output the number of items in the
array ( minus one because the array starts at zero).
- Dave




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

Date: 25 Aug 1997 15:55:51 -0400
From: Guido van Rossum <guido@eric.cnri.reston.va.us>
Subject: ANNOUNCEMENT: Python Conference Program
Message-Id: <5l67sunik8.fsf@eric.cnri.reston.va.us>


[Even though this is a Python conference, we believe it is of interest
to other language communities.  Note for instance the Java papers in
the program.  My apologies if you disagree.]

We have now selected the papers to be presented at the Python
conference.  The program is shown below; you can also view it at

http://www.python.org/workshops/1997-10/techprogram.html

Take good notice of the following items!  The first deadline is less
than three weeks away:

- The REGISTRATION DEADLINE for the early bird discount ($50) is
  September 12.  Your payment must have been received by this date to
  qualify for the discount.
  http://www.python.org/workshops/1997-10/registration.html

- The RESERVATION DEADLINE for the conference hotel, the Sainte Claire
  Hyatt in downtown San Jose, is September 15.  After this date you
  will not be able to book a room at the special conference discount
  price.
  http://www.python.org/workshops/1997-10/accomodations.html

- The deadline for SHORT TALK SUBMISSIONS is September 19.  This is
  your chance to talk about your project!
  http://www.python.org/workshops/1997-10/shorties.html

- We're still solliciting subjects for the DEVELOPERS' DAY.  There's
  no deadline, but the program is filling up!
  http://www.python.org/workshops/1997-10/devday.html

As always, the conference home page is
http://www.python.org/workshops/1997-10/

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

Here is the program of the technical papers sessions:

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

Wednesday, October 15

 8.30 am  breakfast
 9.00 am  Session: Welcome and Java
	  Welcome
	  User-Centered Evolutionary Software Development Using Python
	  and Java,
	  Douglas Cunningham, Carnegie Mellon University
	  Python and Java - The Best of Both Worlds,
	  Jim Hugunin, Corporation for National Research Initiatives
 10.30 am coffee break
 11.00 am Session: Scientific Computing
	  Feeding a Large-scale Physics Application to Python,
	  David M. Beazley and Peter S. Lomdahl, Dept. of Computer
	  Science, University of Utah / Los Alamos National Laboratory
	  The Molecular Modelling Toolkit: a case study of a large
	  scientific application in Python,
	  Konrad Hinsen, Laboratoire de Dynamique Moliculaire,
	  Institut de Biologie Structurale
	  Experiences with Extension Programming and Scripting in
	  Python,
	  Charles Anderson, IEOR Department, UC Berkeley
 12.30 pm lunch
 2.00 pm  Session: The Real World
	  Case Study: Python in a Commercial Environment,
	  Greg Stein, Microsoft
	  Persistent Storage of Python Objects in Relational
	  Databases,
	  Joel Shprentz, BDM Federal
	  Jim Ahlstrom, Using Python With a Legacy System (invited
	  talk)
 3.30 pm  tea break
 4.00 pm  Session: Short Talks
	  See separate call
 5.30 pm  adjourn
 7.00 pm  Conference Banquet (time subject to change)

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

Thursday, October 16

 8.30 am  breakfast
 9.00 am  Session: Programming Patterns
	  Design patterns in Python,
	  Vespe Savikko, Software Systems Laboratory, Tampere
	  University of Technology
	  Implementing a Selective Undo Framework in Python,
	  Monty Zukowski, Zero to One Software Design
	  Concurrent Object-Oriented Programming in Python with ATOM,
	  Michael Papathomas and Anders Andersen, Computing
	  Department, Lancaster University / NORUT IT
 10.30 am coffee break
 11.00 am Session: Invited Talks
	  Mark Hammond, Python and COM,
	  Guido van Rossum, What's new in Python 1.5,
 12.30 pm lunch
 2.00 pm  Session: Potpourri,
	  A Distributed Infrastructure for Mobile Computing,
	  A. Rakotonirainy and M. Chilvers, DSTC, University of
	  Queensland
	  Internationalizing Python,
	  Martin von Lvwis, Institut f|r Informatik,
	  Humboldt-Universitdt zu Berlin
	  A graphical MSC editor,
	  Marco Dierschke, Dept. of Computer Science,
	  Humboldt-Universitdt zu Berlin
 3.30 pm  tea break
 4.00 pm  Panel: Commercial Opportunities for Python
 5.30 pm  adjourn

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

And here, as a reminder, is the Tutorial Program:

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

Tuesday, October 14


  Track 1: Introduction and COM

* Morning session: Introduction to Python (abstract)
  Tutor: Paul Dubois, LLNL

* Afternoon session: Python and COM (Microsoft's Component Object Model)
  Tutor: Greg Stein, Microsoft; and Mark Hammond, Australia

  Track 2: Numeric and Scientific Computing using Python

* Morning session: Numeric Python (abstract)
  Tutor: David Ascher, Brown University

* Afternoon session: Scientific Computing with Python (abstract)
  Tutor: Konrad Hinsen, Institute for Structural Biology (CEA/CNRS),
  France

  Track 3: Extending and Embedding Python

* Morning session: Python/C Integration (abstract)
  Tutor: Mark Lutz, Coral Systems

* Afternoon session: Python-C/C++ Integration with SWIG (abstract)
  Tutor: David Beazley, University of Utah

  Track 4: Web server programming in Python

* Morning session: Introduction to CGI programming in Python (abstract)
  Tutor: Aaron Watters, Lucent Technologies

* Afternoon session: Other server-side solutions, including Bobo
  Tutor: Jim Fulton, Digital Creations

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

-- 
--Guido van Rossum (home page: http://www.python.org/~guido/)


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

Date: Mon, 25 Aug 1997 16:59:06 -0700
From: Tom Phoenix <rootbeer@teleport.com>
To: Stephen P Lee <splee@sfu.ca>
Subject: Re: Calculating Days between two dates!!
Message-Id: <Pine.GSO.3.96.970825165817.24449E-100000@julie.teleport.com>

On 25 Aug 1997, Stephen P Lee wrote:

> Is there a script or module that can convert between Julian and Lunar
> (Chinese or Asian) dates? 

If there's a module which does what you want, it should be listed in
the module list on CPAN. If you don't find one to your liking, you're
welcome and encouraged to submit one! :-)  Hope this helps!

    http://www.perl.com/CPAN/

-- 
Tom Phoenix           http://www.teleport.com/~rootbeer/
rootbeer@teleport.com  PGP   Skribu al mi per Esperanto!
Randal Schwartz Case:  http://www.rahul.net/jeffrey/ovs/



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

Date: Mon, 25 Aug 1997 17:58:40 -0700
From: Tom Phoenix <rootbeer@teleport.com>
To: Tad McClellan <tadmc@flash.net>
Subject: Re: cardinality of an array given a reference
Message-Id: <Pine.GSO.3.96.970825175658.24449L-100000@julie.teleport.com>

On Sun, 24 Aug 1997, Tad McClellan wrote:

>    print "cardinality is ",$#{@$arref},"\n"; 

Unless one of us has a different definition of cardinality from the other,
I think you meant this.

    print "cardinality is ", scalar(@$arref), "\n";

But I don't think the mistake was (strictly speaking) yours. :-)

-- 
Tom Phoenix           http://www.teleport.com/~rootbeer/
rootbeer@teleport.com  PGP   Skribu al mi per Esperanto!
Randal Schwartz Case:  http://www.rahul.net/jeffrey/ovs/




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

Date: 25 Aug 1997 19:04:08 -0700
From: Rael Dornfest <rael@zx81.dnai.com>
Subject: Re: cardinality of an array given a reference
Message-Id: <874t8dr97r.fsf@zx81.dnai.com>


> : $arref=["one","two"];
> : @ar=@$arref;
> : print "cardinality is ",$#ar,"\n";

>    print "cardinality is ",$#{@$arref},"\n"; 

> : Is there a way to do this without first creating @ar?  I can't seem to
> : work it out syntactically.  Perl chokes on $#@$arref, and $#(@$arref)
> : doesn't work either. 

How about...

$arref = ["one", "two"];
print "cardinality is ", scalar @$arref, "\n";

Rael

---------------------------------------------------------------------------
/Rael Dornfest/                    <title>Vice President & Webmaven</title>
                              %company = (DNAI => 'Direct Network Access');
print <<ADDRESS;
2039 Shattuck Avenue, Suite 206                           To: rael@dnai.com
Berkeley, CA 94704                                 atdt 888 321 3624 (DNAI)
ADDRESS                           <a href="http://www.dnai.com">Website</a>





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

Date: Tue, 26 Aug 1997 05:38:51 GMT
From: "Roxy" <dongmien@cs.washington.edu>
Subject: Does anyone know how to call a perl script with 2 arguments in an html file?
Message-Id: <01bcb100$1dc11240$f6085f80@big>

I got a perl script, and I would like to execute the perl script with 2
arguments from an
html file as I did in a unix shell.
Something likes 
perl filename.pl input.txt output.txt
Could anyone help me?
TIA,
-- 
--------------------------------------------------
Roxy
Get PR-Tracker -- Tracks problem reports (bugs, defects)
INFORMATION http://www.prtracker.com/info.html
DOWNLOAD http://www.prtracker.com/download.html
TECH SUPPORT http://www.prtracker.com/TechSupport.html
                                                            



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

Date: Mon, 25 Aug 1997 20:12:59 -0400
From: Jamie Gaines <jamie_gaines@unc.edu>
Subject: Domain User Management with Perl32
Message-Id: <34021F8B.3BE1@unc.edu>

I am trying to use the Win32::NetAdmin module to add users to my domain,
but have thus far been unsuccessful.  I can create a local user on my
local machine, but am looking for a way to automate user creation on the
domain level.  The UserCreate() function does not seem to offer a
parameter for creating Domain users.  Am I just missing somehting
obvious, or is this just not possible?  Any help would be appreciated. 
Thanks.


Jamie Gaines
jamie_gaines@unc.edu


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

Date: Mon, 25 Aug 1997 22:16:45 -1000
From: "Dave Hoyt" <dshoyt@worldnet.att.net>
Subject: Re: Extensions
Message-Id: <5tu1ue$lsu@mtinsc03.worldnet.att.net>


 John Grimm wrote in article <340203B4.71D8@wireedm.com>...
>How can I see if a file has a .tec extension?
>
John,
I'm sure that something like this will help you:

print ".tec extension" if $filename =~ /\.tec$/;

-Dave 




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

Date: Tue, 26 Aug 1997 00:52:40 GMT
From: lord_viper@mailrunner.net (Viper)
Subject: FOUND: Info for Perl on Windows NT
Message-Id: <340428c6.175868348@news.accesscom.net>

Tips, tricks, samples, examples, cgi, perl, ISAPI, SSI, etc.
All for use on Windows NT Server 4.0

http://www.4images.com/ntperl

There's even 2 cool "Powered By Perl" logos there.


----------------------------------------------------------------------
Note: Remove underscores from email addresses when replying via email.



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

Date: 25 Aug 1997 20:05:34 -0700
From: danny@lennon.postino.com (Danny Aldham)
Subject: Getting started with ODBC.pm on MSsql6.5
Message-Id: <5tth5u$mqf$1@lennon.postino.com>

I have installed activewares perl and the ODBC.pm module onto a NT4
machine running SQL6.5 . I seem to be able to connect to the database
using the test.pl program; it passes the tests and finds the tables.
But that is a far as I get. I cannot figure out the syntac to do my
own sql queries.  Simple things like create a table, alter a table, or
insert data into the table. Then maybe do a Query on a column. If someone
has some simple sample code, it would be very much appreciated.

--
Danny Aldham           SCO Ace , MCSE , JAPH , DAD
I don't need to hide my e-mail address, I broke my sendmail.


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

Date: Tue, 26 Aug 1997 01:21:22 -0600
From: ol@pp-ulm.de
Subject: Help!! mail from cgi/perl-script under win-nt/windmail
Message-Id: <872518850.24270@dejanews.com>

I want to send mails from a cgi-perl script.
I use windmail as mail-client under Windows NT and the Enterprise Server
2.0 from Netscape.
There's a funny thing. When I'm starting the perl-script directly from the
www-server (in the dos-box), then the script send the mail, as the script
has to do. But when I start the cgi-perl-script from a html-site like
"<form method=post action="http://xxx.xxx.de/cgi/script.pl"> or indirect
from a browser, then the browser get the message "Server error".
Is this a problem by the server, by the script or what...
Please for some help and sorry for my english
christian

-------------------==== Posted via Deja News ====-----------------------
      http://www.dejanews.com/     Search, Read, Post to Usenet


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

Date: Tue, 26 Aug 1997 06:53:09 GMT
From: name@server.com (Mike Rambour)
Subject: How do I break up a line
Message-Id: <34027d52.1185231@news.west.net>

from a textarea in a html form.  I have a form with a textarea in it
and  I writing the output to a file, that I later read into a HTML
page that unfortunately has a PRE in it.  The end result is that my
output is all messed up, if a user presses the return key it all works
but it they just type in the textarea it ends up as one long line.

What I am trying to do is split the line into multiple lines at 70
chars or less, but I also need to break up words.  I have it working
at <70 but it splits words.

	mike
	mikey at inline-tech dot com  
(replace at with @ and replace dot with . to reply)

And for you automated email spammers out there, here's the email addresses 
of the current board of the Federal Communications Commission:
Chairman Reed Hundt: rhundt@fcc.gov 
Commissioner James Quello: jquello@fcc.gov 
Commissioner Susan Ness: sness@fcc.gov 
Commissioner Rachelle Chong: rchong@fcc.gov

And let's help you send some spam to the USPS, too:
customer@email.usps.gov


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

Date: 26 Aug 1997 01:39:50 GMT
From: grosch@ichips.intel.com (Scott Grosch)
Subject: How do I pass data to a sort function?
Message-Id: <5ttc56$la0$1@news.or.intel.com>


If I do this:

----------------------------------------------------------------------
sub bysomething {
	my $recordA = $href->{records}->{$a}->{someElement};
	my $recordB = $href->{records}->{$b}->{someElement};

	$recordA cmp $recordB;
}

$href = new someClass @args;
 ...
@blah = sort bysomething keys %{$href->{records}};
----------------------------------------------------------------------
	
I'll be ok, since bysomething can see the $href variable.  But what if I
have something like this:

----------------------------------------------------------------------
sub bysomething {
	my $recordA = $href->{records}->{$a}->{someElement};
	my $recordB = $href->{records}->{$b}->{someElement};

	$recordA cmp $recordB;
}
 
sub someRoutine {
	my $href = new someClass @args;
	
	@blah = sort bysomething keys %{$href->{records}};
}
----------------------------------------------------------------------

Then I'm screwed, since bysomething doesn't have access to $href.   How do
I make that second case work?  I pretty much need to be able to pass something
into the sort routine, be it $href or $href->{records}

I don't want to just do:

sort {
        my $recordA = $href->{records}->{$a}->{someElement};
        my $recordB = $href->{records}->{$b}->{someElement};
 
        $recordA cmp $recordB;
} keys %{$href->{records}};

since I will be calling this sort a number of times from different places in
the code...


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

Date: 25 Aug 1997 23:16:01 -0700
From: joshp@silmaril.com (Josh Purinton)
Subject: Re: How do I pass data to a sort function?
Message-Id: <5ttsb1$ue$1@shell3.ba.best.com>

[ posted and mailed ]

The one and only Scott Grosch <grosch@ichips.intel.com> writes:
> [If] I have something like this:
>
> sub bysomething {
> 	my $recordA = $href->{records}->{$a}->{someElement};
>	my $recordB = $href->{records}->{$b}->{someElement};
>	$recordA cmp $recordB;
> }
> sub someRoutine {
>	my $href = new someClass @args;
>	@blah = sort bysomething keys %{$href->{records}};
> }
>
> Then I'm screwed, since bysomething doesn't have access to $href. 
> How do I make that second case work? I pretty much need to be able
> to pass something into the sort routine, be it $href or
> $href->{records}

Pass the hash reference to bysomething() like this:

sub bysomething {
	my($hash) = @_;
	$hash->{$a}->{someElement} cmp $hash->{$b}->{someElement};
}

@sorted = sort { bysomething($href->{records}) } keys %{$href->{records}};

--Josh



-- 
Josh Purinton <joshp@silmaril.com>
	
Any sufficiently advanced technology will be indistinguishable
from magic.  -- Arthur C. Clarke


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

Date: Mon, 25 Aug 1997 17:32:34 GMT
From: aml@world.std.com (Andrew M. Langmead)
Subject: Re: last line of a @list...
Message-Id: <EFHCqA.w3@world.std.com>

bert@arsnova.xs4all.nl (Bert ten Cate) writes:

>I need to get the last line of @list into $lastline. Does anybody know how to
>do this? Any help is appriciated...

$lastline = $list[-1];
or
$lastline = $list[$#list];

will both work. I'm assuming you want a copy to stay in @list as
well. If you want to move the last line from @list into $lastline,
then look at the pop() function.

If you had problems understanding the sections on arrays in the
perldata man page, then maybe it would be a good idea to start off
with a tutorial book on the perl programming language. One
recommendation would be "Learning Perl" by Randal Schwartz.

-- 
Andrew Langmead


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

Date: Tue, 26 Aug 1997 03:19:00 -0400
From: "David J. Thomas" <thomasdj@wam.umd.edu>
Subject: list contents of directory...
Message-Id: <34028363.5E99@wam.umd.edu>

Does anyone know a way to look into a specific directory (the path would
be <STDIN> and print a html file that is nicer than the regular html
output of a directory... ie say the path is ../info/  The script would
take this argument

cd $argument

and then do a 

foreach $name(*) {
print "$name\n";
}

this way I could print it out with a background and in tables... however
I wish.  I just can't get past this part.. that's all

thanks for the help..


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

Date: Tue, 26 Aug 1997 00:48:22 GMT
From: lord_viper@mailrunner.net (Viper)
Subject: Re: PERL 5.001 on WIN NT 4.0 with IIS 3.0
Message-Id: <340227a2.175576605@news.accesscom.net>

On Mon, 25 Aug 1997 00:15:07 +0300, Petri Backstrom
<petri.backstrom@icl.fi> scribbled these simple words:

|
|
|While you're at it, see also tlist.exe.


While you're really at it, go to: http://www.4images.com/ntperl

This is THE place for help with Perl and Windows NT.

'nuff said.



----------------------------------------------------------------------
Note: Remove underscores from email addresses when replying via email.



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

Date: 26 Aug 1997 00:28:49 GMT
From: Cameron Simpson <cs@zip.com.au>
To: swinning@direct.ca (S. M. (Steve) Winning)
Subject: Re: perl cgi and mastercard
Message-Id: <19970826105241-cameron-1-19045@sid.research.canon.com.au>

swinning@direct.ca (S. M. (Steve) Winning) writes:
| Would you know where I could obtain a pre-written Perl CGI script for 
| handling www order forms with Visa and Mastercrd fields. I don't need to 
| process the transactions over the net, but I need to have order forms 
| sent back to my email address. I hope you can help.

I did one of these once. While I don't have a neat little package to
hand, I append creditcard.pl, which has the check digit algorithm for
credit cards. I used the CGI module to do the forms.

BTW, I trust you're going to encrypt this stuff before emailing. Credit
card details should _not_ travel in the clear, nor be stored in the clear.
We used PGP, encrypted all the data, then decrypted at transaction
processing time.
	- Cameron Simpson, cs@zip.com.au, DoD#743
	  http://www.zip.com.au/~cs/
--
"What the hell are we supposed to use, man -- harsh language?"
"Flame units only."	- _Aliens_

#!/bin/sh
#

sed 's/^X//' >creditcard.pl <<'EOF-/home/sid/cameron/scripts/cs/creditcard.pl'
X#!/usr/local/bin/perl
X#
X
Xsub CheckDigit	# cardnumber -> ok
X	{ local($_)=@_;
X
X	  s/[-\s]+//g;
X
X	  /\D/ && ((warn "non-digit in card number \"$_\""),
X		   return undef
X		  );
X
X	  if (/^496/)	{ $_=$'; }	# special case - old scheme?
X
X	  /\d$/;
X	  my($check)=$&;		# extract check digit
X	  $_=$`;
X
X	  my(@digits)=split(//);
X
X	  my($mult);
X
X	  $mult=1+(@digits%2);		# allow for stripping "496"
X	  for $d (@digits)
X		{ $d*=$mult;
X		  $mult=3-$mult;	# oscillate between 2 and 1
X		}
X
X	  my($d);
X
X	  for $d (@digits)
X		{ if ($d >= 10)
X			{ my(@d2)=split(//,$d);
X			  $d=$d2[0]+$d2[1];
X			}
X		}
X
X	  my($total);
X
X	  $total=0;
X	  for $d (@digits)
X		{ $total+=$d;
X		}
X
X	  $total%=10;
X	  if ($total > 0)	{ $total=10-$total; }
X
X	  $check == $total;
X	}
X
X1;
EOF-/home/sid/cameron/scripts/cs/creditcard.pl

exit 0


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

Date: Mon, 25 Aug 1997 21:29:27 -0400
From: "Jeffrey A. F. Hittinger" <jhitt@engin.umich.edu>
Subject: Problem with sub and my
Message-Id: <34023177.351A@engin.umich.edu>

Hello,

Please forgive me if these are stupid questions.  I have been searching
through the man pages and the FAQ, and I have not yet been able to find
an answer to my questions.

I am having problems with the syntax of calling subroutines and the 
"my" function.  Consider the simple example:

#!/usr/um/bin/perl -w
use_diagnostics;
use_strict;
$name = "Jeff";
say_hello($name);

sub say_hello {
    my ($myname) = @_;
    print "Hello, $myname!\n";
}

>From my understanding of the man pages and "Learning Perl", this should
work.  However, I get the following compilation errors:

syntax error in file hello at line 6, next 2 tokens "say_hello("
"my" may clash with future reserved word at hello line 9.
syntax error in file hello at line 9, next 2 tokens "my ("
Execution of hello aborted due to compilation errors.

The diagnostics man page has not helped me figure this out.  I can make
the code work if I do the following:

#!/usr/um/bin/perl -w
use_diagnostics;
use_strict;
$name = "Jeff";
&say_hello($name);

sub say_hello {
    $myname = $_[0];
    print "Hello, $myname!\n";
}

but it is my understanding that I should not need to use the '&', just
the parenthesis.  I am baffled why Perl does not seem to understand its
own function "my".

I am probably missing something very simple here, but I have yet been
able to locate any explanation for this behavior.  FYI, I am rusing 
Perl 5.004 on an HP-UX 10.20 machine.  

Thanks for the help,

Jeff
-----------------------------------------------------------------------------
Jeffrey A. F. Hittinger             Office:  (313) 764-7573
W.M. Keck Foundation CFD Laboratory CFD Lab: (313) 936-0107 
Department of Aerospace Engineering Fax:     (313) 763-0578
The University of Michigan          URL:
http://www-personal.umich.edu/~jhitt

"One World. One Web. One Program."   - Microsoft promotional
advertisement
"Ein Volk, ein Reich, ein Fuehrer!"  - Adolph Hitler


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

Date: Mon, 25 Aug 1997 20:01:39 -0500
From: Ralph Janke <ralph_janke@writeme.com>
Subject: Problems with backticks
Message-Id: <34022AF2.C36567E1@writeme.com>

I use perl 5.003_22 and have randomly problems with backticks.
When I assign the output of a command in backticks to a variable,
sometimes the variable contains the right value after the assignment,
sometimes it is empty.

A " | cat" within the backticks at the end seems to currently stablelize
it. However, I would like to know if this is a bug, or if anybody else
has the same problem.

Ralph Janke



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

Date: 25 Aug 1997 19:15:17 GMT
From: bbutz@student.uni-kl.de (Benjamin Butz)
Subject: protect a perl-script
Message-Id: <5tslk5$mkb$2@sun.rhrk.uni-kl.de>


Hello,

how can I protect a perl-script? Everybody 
can execute the script, but nobody can read
the source code (it is not a CGI access problem)

bye
Benjamin

 


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

Date: Mon, 25 Aug 1997 17:41:01 -0700
From: Tom Phoenix <rootbeer@teleport.com>
To: John Grimm <nick@wireedm.com>
Subject: Re: ReadParse
Message-Id: <Pine.GSO.3.96.970825173913.24449J-100000@julie.teleport.com>

On Mon, 25 Aug 1997, John Grimm wrote:

> How can I have CGI-LIB ReadParse put the info in another associative
> array? 

Use CGI.pm instead of cgi-lib, and call the 'associative array' a 'hash',
so you can stop living in the early 1990s. :-)

-- 
Tom Phoenix           http://www.teleport.com/~rootbeer/
rootbeer@teleport.com  PGP   Skribu al mi per Esperanto!
Randal Schwartz Case:  http://www.rahul.net/jeffrey/ovs/



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

Date: Tue, 26 Aug 1997 08:36:19 +0200
From: Marc Filthaut <Marc_Filthaut@HP.com>
Subject: RegExp Win95/NT4.0 ?
Message-Id: <34027963.4E14@HP.com>

Hi,

I have a simple question to all the Windows Perl programmers.

I programm perl under unix and have the hole regexp, but when i use the
same regexp under windows they didn't work. Is there a different between
perl for windows and for unix ??

Marc


-- 
___________________________________________________________________
Marc Filthaut                      Hewlett-Packard GmbH
SW Delivery Support Engineering    Berliner Str. 111       _/
                                   40880 Ratingen         _/
Phone  : +49-2102-90-6505          Germany               _/_/_/ _/_/_/
Telnet : 705-6505                                       _/  _/ _/  _/
Fax    : +49-2102-90-6885                              _/  _/ _/_/_/
                                                            _/
eMail  : Marc_Filthaut@HP.com                              _/
_____________________________________________________________________


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

Date: 25 Aug 1997 23:37:32 -0700
From: joshp@silmaril.com (Josh Purinton)
Subject: Re: Send question for Perl Gurus
Message-Id: <5tttjc$aht$1@shell3.ba.best.com>

[ posted and mailed ]

The one and only Michael Q. Le <lem@ece.ucdavis.edu> writes:
> I have a perl socket question for any of you gurus out there.
> What is the perl equivalent for the following C code:
>
>    #define QW_REQUEST_PREFIX '\377', '\377', '\377', '\377'
>    struct {
>        char prefix[4];
>        char command[16];
>    } serverstatus = { REQUEST_PREFIX, 's', 't', 'a', 't', 'u', 's', '\n',
>            0, 0, 0, 0, 0, 0, 0};
>
>    send( server, (const char *)&serverstatus, sizeof(qwserverstatus), 0);
>

pack("a20", ...) creates a 20 byte string, padded with trailing
nulls:

my $REQUEST_PREFIX = "\377" x 4;
my $serverstatus = pack "a20", $REQUEST_PREFIX . "status\n";
send($server, $serverstatus, 0);


--Josh

-- 
Josh Purinton <joshp@silmaril.com>
	
The difference between theory and practice is usually larger in
practice than in theory.  -- Peter Salus


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

Date: Tue, 26 Aug 1997 08:48:01 +0200
From: Emmanuel Courcelle <manu@ipbs.fr>
Subject: This server does not work on IRIX 5.3
Message-Id: <34027C21.167E@ipbs.fr>

Here is a little server and client: when I try to send "big" files
(>=100K), and when the server runs an a Silicon graphics (5.3 only, it
works with an O2 running 6.3) it hangs with a core dump when closing the
socket. Is there a solution ???
I use perl 5.004_01.
Thanks in advance...

THE SERVER:

=============================================================
#!/usr/local/bin/perl
#
#

use IO::Socket;
use Net::hostent;               # for OO version of gethostbyaddr

$PORT = 9000;                   # pick something not in use
$server = IO::Socket::INET->new(Proto     => 'tcp',
                                LocalPort => $PORT,
                                Listen    => SOMAXCONN,
                                Reuse     => 1);
die "$::msg_err can't setup server" unless $server;
print "[Server $0 on $::host accepting clients]\n";
main_loop();
exit;

sub main_loop {
    while ($client = $server->accept()) {
        $client->autoflush(1);
        $FILE=<$client>;     # the client sends the filename in the
first line
        chop $FILE;
        $FILE .= ".server";  # we modify the name to be sure who did
create it
        open (F,">$FILE");
        print $client "OK\n"; # we send an ack to the client
        while (<$client>) {
            print F;         # receive and create the file
        };
        close(F);
        close($client) if ($client != 0);
        print "client closed, still accepting connections\n";
    };
};

====================================================================

THE CLIENT:

====================================================================

#!/usr/local/bin/perl
#

use IO::Socket;

#
# Address & name of server
#

if (defined($ARGV[0])) {
    $Remname = $ARGV[0];
} else {
    $Remname = "localhost";
};

$remote = IO::Socket::INET->new(Proto    => "tcp",
                                PeerAddr => $Remname,
                                PeerPort => "9000")
    || die "cannot connect to $Remname, port 9000";
$remote->autoflush(1);
print $remote "MYFILE\n";       # send the file name
open (F,"MYFILE");              # open the file
$_ = <$remote>;                 # wait for the server's answer
chop;
print "Error\n" if ($_ ne "OK"); # continue if server is OK
while (<F>) {                   # read the file
    print $remote $_;           # and send it
};
close (F);
close ($remote);

-- 
--------------------------------------------------------------
Emmanuel COURCELLE		
Institut de Pharmacologie et de Biologie Structurale - I.P.B.S.
Groupe de cristallographie biologique.

CNRS/CEMES/IPBS				Tel (33 ou 0) 5-62-25-79-62
29 rue Jeanne Marvig 			Fax (33 ou 0) 5-62-25-79-60  
31055 TOULOUSE cedex - FRANCE		e-mail   manu@ipbs.fr
--------------------------------------------------------------


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

Date: Mon, 25 Aug 1997 20:56:19 -0400
From: John Nolan <nospam@domain.com>
To: David Ransier <david_ransier@intercept.com>
Subject: Re: When to use "use strict"
Message-Id: <340229B3.671C@domain.com>

David Ransier wrote:
> This weeks question is about "use strict".  I'm trying to add "some polish"
> to my programs and "use strict" seems like a good cleanup mechanism.
> 
> My problem is, when "use strict refs" is enabled, I need to fully qualify
> my variable names with Package identifiers. I've never seen any programs
> that others have written using fully qualified variables.

I've used them.  I thought it would make the code easier to maintain. 
Looks neater.  Harder to write, but easier to read. 
(Not that I'm a guru or anything...)  

> I'd like to hear some opinions from others. For programs I intend to send
> to customers, should I use "use strict"? Should I use Package identifiers
> and fully qualify variable names? Other than "-w", are there other
> important switches I should be using to add polish to my Perl programming
> style?


For CGI programs, you might want to use the -T switch, to turn taint
checks on. 
This will help you avoid using user-input strings without checking them
first. 

--
## John Nolan  
## jpn acm org


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

Date: 26 Aug 1997 02:33:12 GMT
From: mheins@prairienet.org (Mike Heins)
Subject: Re: When to use "use strict"
Message-Id: <5ttf98$1o8$1@vixen.cso.uiuc.edu>

David Ransier (david_ransier@intercept.com) wrote:
: I've been writing some pretty large Perl programs and I'm definitely still
: learning about Perl.
: 
: This weeks question is about "use strict".  I'm trying to add "some polish"
: to my programs and "use strict" seems like a good cleanup mechanism.
: 
: My problem is, when "use strict refs" is enabled, I need to fully qualify
: my variable names with Package identifiers. I've never seen any programs
: that others have written using fully qualified variables. 
: 
: I'd like to hear some opinions from others. For programs I intend to send
: to customers, should I use "use strict"? Should I use Package identifiers
: and fully qualify variable names? Other than "-w", are there other
: important switches I should be using to add polish to my Perl programming
: style?
: 

I use strict all of the time for any program I plan on writing to disk.
Most times I break that rule, I later wish I didn't.

The advantage to "use strict", from my viewpoint, is that when the
program passes a syntax check it really *means* something.  It doesn't
always mean the program will work -- but it seems to work first time
quite often. And I won't often be pursuing typos or unitialized
variable warnings.

It also prevents users who don't know what they are doing from
changing the program.  They try, it won't compile, and they
call for help.

By using package-scoped lexicals ( my $Whatever; ), 'use vars
qw($Whatever)', and a few naming conventions I find I don't often need to
fully-qualify a variable name. And when I do reach into another package
for a variable value, it gives me pause to think about it. Many times
I can then avoid the interaction caused by dependence on another
module.

-- 
Regards,
Mike Heins

This post reflects the
opinion of my employer.


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

Date: 25 Aug 1997 22:55:04 -0700
From: joshp@silmaril.com (Josh Purinton)
Subject: Re: When to use "use strict"
Message-Id: <5ttr3o$kd2$1@shell3.ba.best.com>

[ posted and mailed ]

The one and only Michael Schuerig <uzs90z@uni-bonn.de> writes:
>Josh Purinton <joshp@silmaril.com> wrote:
>> Declare variables global to a package with 'use vars', e.g.
>> 
>>   package MyPackage;
>>   use vars qw/$foo @bar %baz/;
>
>Is there a difference or advantage to writing it as
>
>    pacackge MyPackage;
>    my $foo;
>    my @bar;
>    my %baz;

If you 'use vars', you can use a package qualifier to access $foo,
@bar, and %baz from other files, i.e. $MyPackage::foo.  'my'
variables, on the other hand, are only accessible in the lexical
scope they are declared in -- in this case, the file.

--Josh



-- 
Josh Purinton <joshp@silmaril.com>
	
The difference between theory and practice is usually larger in
practice than in theory.  -- Peter Salus


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

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

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