[8425] in Perl-Users-Digest

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

Perl-Users Digest, Issue: 2042 Volume: 8

daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Fri Mar 6 15:27:39 1998

Date: Fri, 6 Mar 98 12:01:02 -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           Fri, 6 Mar 1998     Volume: 8 Number: 2042

Today's topics:
        [Q] Connecting Win32 Perl and a DLL? <foygel@shrug.isdn.uiuc.edu>
        [Q] Example using Net::UDP server? (Mark W. Schumann)
    Re: [QUES} Perl Win95 <uri@sysarch.com>
    Re: About the foreach statement (hymie!)
    Re: CGI.pm and taint checking schwern@starmedia.net
    Re: commify <quentin@jihad.amd.com>
    Re: DB failures on DEC Alpha if DB created elsewhere (Mike Heins)
        file-upload.cgi program <naps@napsys.com>
    Re: Finding absolute pathname (Earl Hood)
    Re: Formatting telephone numbers - How to? (Mark Daku)
    Re: Good Perl book <edwardj@webpromote.com>
        help NetBSD perl 5.004 make test <patmac@cityscape.co.uk>
        Help on sockets <djpaul@fnet.gr>
    Re: How to use Perl Hashes? (I R A Aggie)
        Http - URL Regexp to remove only last part if (John R. Long)
    Re: Length of an array? <merlyn@stonehenge.com>
    Re: local/global and my <tchrist@mox.perl.com>
        Need help using hash to read file/array skulk@wam.umd.edu
    Re: Need help using hash to read file/array <jdf@pobox.com>
        Newbie needs help with utime <kmphillip@RemoveThisPart.Hotmail.com>
    Re: Newbie needs help with utime <quentin@jihad.amd.com>
    Re: Newbie's question about package <jdf@pobox.com>
        Newbies question for Win32 <cybergiggy@home.com>
    Re: Perl (CGI)/database schwern@starmedia.net
    Re: Perl and/or C parsing code, in Perl? (David A Thomas)
        Problem with a CGI counter script... <fxp4258@rit.edu>
    Re: Problem with a CGI counter script... (Boris Pelakh)
    Re: Using pod2html.pl on Win32 <Harald.Joerg@mch.sni.de>
    Re: Using pod2html.pl on Win32 <jdf@pobox.com>
    Re: utime not working (Clinton Pierce)
    Re: What is PERL? Learn JAVA instead? <jdporter@min.net>
    Re: What is PERL? Learn JAVA instead? <keithmur@mindspring.com>
        Digest Administrivia (Last modified: 8 Mar 97) (Perl-Users-Digest Admin)

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

Date: 6 Mar 1998 18:39:14 GMT
From: Fnord Prefect <foygel@shrug.isdn.uiuc.edu>
Subject: [Q] Connecting Win32 Perl and a DLL?
Message-Id: <6dpfsi$ge0$1@vixen.cso.uiuc.edu>

I've been entirely stumped by something that seems like it 
would be easy to do - how do I connect a Win32 Perl script
to a generic DLL?  Dynaloader stuff is Perl-specific,
whereas I need something that will link to a DLL compiled
from C code.

Any help will earn my eternal gratitude.

-Dan



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

Date: 6 Mar 1998 11:35:37 -0500
From: catfood@apk.net (Mark W. Schumann)
Subject: [Q] Example using Net::UDP server?
Message-Id: <6dp8kp$bot@junior.apk.net>

I'm having a great deal of trouble making a UDP-based server with
Net::UDP.  I know how to deal with sockets already, but there is
something about the class implementation in Net::{Gen,Inet,UDP} that
I don't understand well enough to proceed.  Here's an example of what
I am trying to do.  I believe that all I really need is a similar
example that works.

#!/usr/local/bin/perl -w
use Net::UDP;
use strict;

print STDERR "initializing\n";
my $upd = new Net::UDP ('myhost.here.world', 1025, debug => 2);
print STDERR "binding\n";
$upd->bind (1001) || die "can't bind: $!";
0;

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

Here I get a boatload of output from the 'debug' and finally:

Your vendor has not defined Net::Inet macro bind, used at ... line 7

My problem seems to be that I don't understand the error message at
all.  I've read the source to Net::Gen, Net::Inet, and Net::UDP,
searched the FAQs, and DejaNews'd it to death.  And I *can* write sockets
code with the old-fashioned socket() and bind() calls.

Any ideas or working examples would be appreciated.  Thanks to all.


-- 
Mark W. Schumann | catfood@apk.net
Why should I change or hide my return address to deter spammers?
I just loop the garbage right back at 'em.


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

Date: 06 Mar 1998 13:38:43 -0500
From: Uri Guttman <uri@sysarch.com>
To: "Adam Carden" <adam@pacific-artists.demon.co.uk>
Subject: Re: [QUES} Perl Win95
Message-Id: <x790qnwtos.fsf@sysarch.com>


what kind of moron are you posting a jpeg to c.l.p.m? mail it only to the
requester. we don't need 1600 lines of crap! thank god i have a high
speed connection to the net. think of all the others you have
effectively spammed.

uri

-- 
Uri Guttman                     SYStems ARCHitecture and Software Engineering
uri@sysarch.com                                          Have Perl, Will Hack
http://www.sysarch.com                (781) 643-7504 x*2  FAX: (781) 643-2710
Try the Best Search Engine on the Net -------->  http://www.northernlight.com


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

Date: 6 Mar 1998 16:23:38 GMT
From: hymie@lactose.smart.net (hymie!)
Subject: Re: About the foreach statement
Message-Id: <6dp7ua$78f$1@news.smart.net>

Odie Deth wrote:
> 
> Given a statement such as:
> 
> foreach (@variable ) {
>   print $_;
> }
> 
> Is there a way to find out what $variable it's at?

How about

foreach $i (0..$#variable)
{
  print "$i\t$variable[$i]\n";
}

 ..hymie!
http://www.smart.net/~hymowitz * agis customers: e-mail and web service refused
hymie@lactose.smart.net ********** pgp public key: e-mail pgp@lactose.smart.net
===== Unsolicited commercial e-mail spam will be forwarded to postmasters =====


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

Date: Fri, 06 Mar 1998 11:46:10 -0600
From: schwern@starmedia.net
To: johnc@interactive.ibm.com
Subject: Re: CGI.pm and taint checking
Message-Id: <6dpcnp$1q6$1@nnrp1.dejanews.com>

You scared me there for a second!  I had this horrible vision of all our CGIs
suddenly having security holes blown through them one-by-one...  then I
re-read perlsec:

           open(FOO, "< $arg");        # OK - read-only file
           open(FOO, "> $arg");        # Not OK - trying to write

           open(FOO,"echo $arg|");     # Not OK, but...
           open(FOO,"-|")
               or exec 'echo', $arg;   # OK

Reading a file w/a tainted variable is fine.  WRITING is a whole 'nother ball
of rendered animal fat.


In article <34FE9232.E220EB21@interactive.ibm.com>,
  johnc@interactive.ibm.com wrote:
>
> I am using CGI.pm for the first time in a major project. I am have taint
> checking turned on (-T). The problem is that I am not being forced to
> untaint my variables. I am using 3 user inputs in an open command and it
> works just fine.
>
> Is CGI.pm causing these variables to be untainted? If so, why? That
> seems stupid. Or am I doing something wrong? Is there another way to
> turn on taint checking that is better than the -T command?
> --
>
> John Call
>
>


-----== Posted via Deja News, The Leader in Internet Discussion ==-----
http://www.dejanews.com/   Now offering spam-free web-based newsreading


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

Date: 06 Mar 1998 10:10:42 -0600
From: Quentin  Fennessy <quentin@jihad.amd.com>
Subject: Re: commify
Message-Id: <ximwwe7er5p.fsf@jihad.amd.com>

cstewart@flash.net (Chuck Stewart) writes:

>     $total = 1234345
>     $total=~ s/^(-?\d+)(\d{3})/$1,$2/;
> 
> This will results in 1234,345
> How can I print 1,234,345

Check out:

	perldoc perlfaq5

And look for:

	"How can I output my numbers with commas added?"

-- 
Quentin Fennessy			AMD, Austin Texas


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

Date: 6 Mar 98 17:27:28 GMT
From: mikeh@minivend.com (Mike Heins)
Subject: Re: DB failures on DEC Alpha if DB created elsewhere
Message-Id: <35003200.0@news.one.net>

HMahaffey <hmahaffey@aol.com> wrote:
> We wrote a multi-platform Build Management tool in Perl.  We store information
> about the builds in a DB (nothing fancy, just the one that comes bundled with
> Perl... what is that, SDBM?)  No problems reading and writing on HP, Solaris
> 2.6, Irix 5, and Irix 6.  Then we come to DEC OSF 4b, where we can't read
> anything written by the other platforms.  If the DEC CREATES the database, it
> can read and write fine, but it can't do so if some other platform originally
> created the database.

> Is this some 64-bit issue?  An option on the installation of Perl I can tweak? 
> Has anyone else seen anything like this?  Please don't say that multiple
> platform types can't update the same database.....

It is a byte-ordering issue. You will need to use Berkeley DB (Perl's
module is DB_File) to get transportable databases. It is byte-order
independent. None of the others supported by Perl are.

Regards,
Mike Heins                          http://www.minivend.com/  ___ 
                                    Internet Robotics        |_ _|____
Just because something is           131 Willow Lane, Floor 2  | ||  _ \
obviously happening doesn't         Oxford, OH  45056         | || |_) |
mean something obvious is           <mikeh@minivend.com>     |___|  _ <
happening. --Larry Wall             513.523.7621 FAX 7501        |_| \_\


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

Date: 6 Mar 1998 18:21:01 GMT
From: NAPS <naps@napsys.com>
Subject: file-upload.cgi program
Message-Id: <35003BEC.41C202E6@napsys.com>

Hi Anyone,

I'm really interested in getting your (Jeff C's) Perl file-upload script
to run on my NT Server and I'm hoping that you can help.

Configuration:
I'm running NT Server 4.0 servPk 3 with Netscape Enterprise Server
v3.0i. I have installed Perl 5.001 successfully and have been able to
run my other Perl scripts from the command prompt and from a Web
browser. The server has a ShellCGI directory called 'perl-pl'. The file
extension for Perl on this server is .pl not .cgi; (not sure if this
isn't a problem as well).

Installation:
I put your three scripts into the cgi-pl directory. I renamed them
install.pl, file-upload.pl and I left the library named as is, CGI.pm. I
then ran the install script. Everything worked fine until I pressed "y"
as my response to the Windows question; at which time I received an
error: "error getpwuid function is unimplemented at install.pl line 122,
<STDIN> line 5". I then attempted to edit the file-upload.pl file
manually. The variables are currently defined as:

    #don't know what this should be for NT
    $userid = 2301;
    #don't know what this should be for NT
    $groupid = 1000;
    $path = "D:\perlDropFolder";
    $url = "http://europa/perlDropFolder";
    $overwrite = 1;
    $success_url = "";
    $Windows = 1;
    $exclusive_lock = 2;      # --> DO NOT CHANGE THIS VALUE - It should

                              # --> be set to '2'
    $unlock_lock = 8;         # --> DO NOT CHANGE THIS VALUE - It should

                              # --> be set to '8'
I'm sure that part of the problem is my lack of knowledge of how $userid
and &groupid translates from UNIX to NT.

HTML Page that calls script:
I knew at this point that the script would not be working but I went
ahead and created a test html file anyway. It looks like this:
<HTML>
<HEAD>
</HEAD>
<BODY BGCOLOR="FFFFFF">
  <FORM ACTION="/cgi-pl/file-upload.pl" METHOD="post"
ENCTYPE="x-www-form-encoded">

    <TABLE border=2 cellspacing=1 cellpadding=4>
      <TR><TD COLSPAN="2" ALIGN="right">
        File To Capture: <INPUT TYPE="file" NAME="txtFilePath" SIZE=30">

      </TD></TR>

      <TR><TD colspan=2 align=right>
        <INPUT TYPE="submit" VALUE="Upload File">
      </TD></TR>
    </TABLE >

  </FORM>
</BODY>
</HTML>

I ran the script and selected a file from my local disk. The server then
returned the following error:
[05/Mar/1998:10:48:58] failure: for host 14.103.41.26 trying to POST
/cgi-pl/file-upload.pl, cgi-parse-output reports: the CGI program
D:\Perl\perl5\perl.exe did not produce a valid header (program
terminated without a valid CGI header (check for core dump or other
abnormal termination)

I hope that I've given you enough info to point me in the right
direction. I'm a bit new to Perl and have been using Java and JavaScript
to perform the file upload functionality but that requires a signed
applet and trusting users because of the security restrictions placed on
Java running in Web browsers; hence my interest in a server-side script.

Thanks,
Gary Barna
naps@napsys.com
North Atlantic Publishing Systems, Inc.



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

Date: 6 Mar 1998 18:35:48 GMT
From: ehood@medusa.acs.uci.edu (Earl Hood)
Subject: Re: Finding absolute pathname
Message-Id: <6dpfm4$5d5@news.service.uci.edu>

	[mail & posted]
In article <r6zg1kvg82m.fsf@peridot.southwind.net>,
John Goerzen  <jgoerzen@southwind.net> wrote:

>When given a filename, say in $0, what is a good way to get the
>absolute path to the filename?  For instance, $0 might contain
>"./test.pl" and I want to get /home/jgoerzen/test.pl out of it.
>
>There is a realpath(3) call in C that accomplishes this but I see no
>equivolent in Perl.  Ideas?

Use the Cwd module.  Get your current working directory and save it.
Chdir to the directory specified $0 (strip off program name portion).
Get the current working directory (which will be the absolute pathname
of the directory containing the program).  Chdir back to original
directory (if you need).

BTW, this should handle the cases where symbolic links are in use.

	--ewh
-- 
             Earl Hood              | University of California: Irvine
      ehood@medusa.acs.uci.edu      |      Electronic Loiterer
http://www.oac.uci.edu/indiv/ehood/ | Dabbler of SGML/WWW/Perl/MIME


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

Date: 06 Mar 1998 11:44:37 -0500
From: daku@nortel.ca (Mark Daku)
Subject: Re: Formatting telephone numbers - How to?
Message-Id: <esqyaynvkei.fsf@nortel.ca>

"Joanne James" <jjames@netguild.com> writes:

> Hi. I'm helping out on a project using Perl and am learning as I go.  I've
> been trying to show telephone numbers (numbers only are stored on database
> -no
> dashes) on an html page with dashes inserted.  The database contains both 
> US and international phone numbers.  I want to put in dashes as in the
> following: 
> 999-999-9999 in all cases.  I just need an example.  Assume you are getting
> a field from an Oracle database and want to put it into an array (I
> presume), then insert the dashes.  How would you do it?  I have been trying
> for hours to get this to work!  I would appreciate some feedback. Thanks
> for the
> help!

Personally I wouldn't bother trying to accomplish this until you have a
little more information about those numbers.  Simply ask for the local 
number of the person.  The ask for what part of the globe does it belong,
etc.  From this information you can matach this up with the dial plans for
those regions.   This will then allow you to state a number in an appropriate
fashion.

This appropriate fashion is ONLY valid for a specific region.  Not all parts
of the globe use the same methods to get to other international exchanges.
This results in a different way of dialing the number.
Phone numbers for the most part are only valid from the calling point.
What we use to dial a number in London England is not the same number that
is used to dial London England from say Berlin.

The simpliest way to sum this up is that at my office I have to dial 6
before a long distance number and 9 for a local number.  I can bet
that your office is different.  Now your office is one country and
mine is another.  Now you can see that the numbers we dial are
different for the same endpoint.

Welcome to the wonderfully world of digit translation as we call it in
the phone biz.

So what's the solution.  Well there is none.  Because the moment you
figure it out it's obsolete.  For example North America is moving to
the 10 digit dial plan.  For the ease of use of the end customer the
telcos most often let the first 3 digits be assumed.  You then have to
prepend a 1 in order to dial long distance.  Does this sound different
that usual.  If you were to buy your own telephone switch and some how
manage to get it on the network in N.A. if you installed it and did
very little to configure it you would HAVE to dial all 10 digits just
to call next door.

So I say again the solution is don't do it.  You could spend years on this
for very little gain.

OK I'll give you a N.A. cheat.  If the number is 10 digits and the
first 3 digits match area code in N.A. then you can do the N.A. -
padding.  This is a educated geuss.  Why because this 10 digit number
may be the exact same number as some dial from HongKong to BangKok.
But for the most part it will be correct.

Phones are not IP addresses they are NOT unique.

Mark Daku


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

Date: Fri, 06 Mar 1998 18:44:08 GMT
From: Ed Jamison <edwardj@webpromote.com>
To: Tom O'Neil <oneilt@ucla.edu>
Subject: Re: Good Perl book
Message-Id: <350043CC.67911296@webpromote.com>

Again, I cannot reccommend a better book than Programming Perl, From
O'Reilly.  If you are after CGI more than Perl, I'd recommend CGI
Programming for the WWW, also from O'Reilly.  This is an excellent book
for learning all aspects of CGI and implementing them in your web
site....  Go here: http://www.ora.com/catalog/cgi/

HTH,
Edward Jamison

Tom O'Neil wrote:

> I've had  a fair amount of experience with Perl, but it was a couple
> of years ago so I'm a little rusty.  I was wondering what a good Perl
> (including CGI) book(s) might be for a good reference and reminder?
>
> Tom O'Neil
> oneilt@ucla.edu





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

Date: Fri, 06 Mar 1998 18:41:55 +0000
From: patmac <patmac@cityscape.co.uk>
Subject: help NetBSD perl 5.004 make test
Message-Id: <35004373.4C46@cityscape.co.uk>

Hello,

make test on my NetBSD 1.3 (perl5.004_04) and perl5.004 both 
fail to find IO/File.pm 

I believe its a lack of shared library failure, but /lib doesnt
exist on my FreeBSD 2.2.2 system and perl's running fine on that on
that one.


please mail pgm@demon.net

thanks patmac


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

Date: Thu, 05 Mar 1998 10:23:46 -0800
From: DjPaul <djpaul@fnet.gr>
Subject: Help on sockets
Message-Id: <34FEEDB1.B2824E93@fnet.gr>

I'm writing an application where a socket accepts connections and forks
child process to handle the connection.Father process must be warned
when the connection drops from the client so it can logs disconnection
time etc.
What is the way to do this?

Thank you,
Paul Delia



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

Date: Fri, 06 Mar 1998 11:04:29 -0500
From: fl_aggie@thepentagon.com (I R A Aggie)
Subject: Re: How to use Perl Hashes?
Message-Id: <fl_aggie-0603981104300001@aggie.coaps.fsu.edu>

In article <6dmmpb$2ct$1@nnrp1.dejanews.com>, sspiegle@crcg.edu wrote:

+ I couldn't open a link to a PERLFAQ7 link on the web that I located
+ via a search. Can someone point me to a good link for that?

If you have perl installed locally, it's on your machine:

   perldoc perlfaq7

James

-- 
Consulting Minister for Consultants, DNRC
The Bill of Rights is paid in Responsibilities - Jean McGuire
To cure your perl CGI problems, please look at:
<url:http://www.perl.com/CPAN-local/doc/FAQs/cgi/idiots-guide.html>


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

Date: Fri, 06 Mar 1998 17:32:21 GMT
From: johnr@pacificnet.net (John R. Long)
Subject: Http - URL Regexp to remove only last part if
Message-Id: <35002d91.264444837@dnews.pacificnet.net>

I need to retain all of a url if it does not contain a file ref, If file/cgi.. then chop it off but don't chop
off any dirs. Problem is if a dir does not have a trailing slash then it gets chopped too.. I have been trying
to do this in regexps and am hoping that there is a standard set of code to do this. It always fails on my
test data in some way. 
The following is some of my many attempts to get this. Do I need to do an
 if ($url =~ {htm.|cgi|pl|\?} { filter differently.......}  # the cgi/pl  may not be at the end of the last
segment.
Or is there a regexp that will handle this.  The purpose is to filter off dup entries at the same url/dir
level. 

foreach $line (@lines) {
    if ($line =~ /\<li\>\<a href\=\"([^\"]+)\" target=new>([^<]+)<\/a>/) {
		$url = $1;

#	local($type,$host,$port,$path,$url) = @_;
    	$url =~ m|^(\w*):*//(.*)|;
		$type = $1;
		if ($type eq "") { $type = "http"; }
		$host = $2;
#		$port = &defport($type);
		$request = "/";		# default
		($host =~ s|^([^/]+)(/.*)$|$1|) && ($request = $2);
		$req = $2;
		($host =~ s/:(\d+)$//) && ($port = $1);
		($path = $request) =~ s|[^/]*$||;

#($type,$host,$port,$path,$request);

#		$line =~ m{href="((?:[^"/]*/)*)([^"]*)"}i;
#		$url =~ m{($:[^"/]*/)*[^"]*"}i;
#		$line =~ m{http://((([^"/]*/)*)[^/]*)([^"]*)"}i; # if $2 then compare $2 else $1
#		$line =~ m{http://(([^"]*)/?([^"]*)"}i;
		print "$url\n$host$port$path\n$req\n$request\n\n";
		}
	}
#==========================================================
#	$line = '<li><a href="http://www.svr.com/dir/default.htm" >Spamm1';
#	$line =~ m{
#	   href="                 # bounded by this literal on the left
#	   ((?:[^"/]*/)*)         # a bunch of directory segments, captured to $1
#	   ([^"]*)                # the document name, captured to $2
#	   "                      # bounded rightside by the closing quote
#	 }xi;
#=======================================
#$line = '<li><a href="http://www.svr.com" >Spamm1';
#$line =~ m{
#   href="                 # bounded by this literal on the left
#   ([^"]*)/               # a bunch of directory segments, captured to $1
#   ([^"]*)                # the document name, captured to $2
#   "                      # bounded rightside by the closing quote
# }xi;
#print "$1\n$2\n";
#_____________________________________________________

Thanks much

ps - Many thanks to Mr Feinberg for his patient help :-)

John R. Long



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

Date: 06 Mar 1998 10:26:56 -0700
From: Randal Schwartz <merlyn@stonehenge.com>
To: dkw0@cdc.gov (David Wall)
Subject: Re: Length of an array?
Message-Id: <8clnunybkv.fsf@gadget.cscaper.com>

>>>>> "David" == David Wall <dkw0@cdc.gov> writes:

David> perl -e "$a=split(/ /,'$a is 3'); print $a"

David> perl -e "$a=scalar ('$a','is','3'); print $a"

David> And if I'm getting the swing of things correctly, these two
David> one-liners are just about equivalent, except for the split.  In
David> both cases, I'm forcing a list into a scalar context.

No.  You aren't.

And you would have noticed had you done:

	$n = scalar ('$a', 'is', '5');

Because now $n is 5. :-)

In a list context, comma is a "list builder".  In a scalar context,
comma is the "comma operator", which means to evaluate the left
expression, then the right expression, and return the right expression.

In this case, it's the value "5", the last element of the list.

Repeating what I screamed about last week (again :-)...

	There's no way to force a list to a scalar context.
	It can't exist.  It just can't.

print "Just another Perl hacker," # but not what the media calls "hacker!" :-)
## legal fund: $20,990.69 collected, $186,159.85 spent; just 178 more days
## before I go to *prison* for 90 days; email fund@stonehenge.com for details

-- 
Name: Randal L. Schwartz / Stonehenge Consulting Services (503)777-0095
Keywords: Perl training, UNIX[tm] consulting, video production, skiing, flying
Email: <merlyn@stonehenge.com> Snail: (Call) PGP-Key: (finger merlyn@teleport.com)
Web: <A HREF="http://www.stonehenge.com/merlyn/">My Home Page!</A>
Quote: "I'm telling you, if I could have five lines in my .sig, I would!" -- me


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

Date: 6 Mar 1998 16:24:03 GMT
From: Tom Christiansen <tchrist@mox.perl.com>
Subject: Re: local/global and my
Message-Id: <6dp7v3$ct4$1@csnews.cs.colorado.edu>

 [courtesy cc of this posting sent to cited author via email]

In comp.lang.perl.misc, 
    mwang@alhena.ibk.ml.com (Michael Wang) writes:
:I myself find my, and local very confusing. 

When you read "local", think:

    "Mr Interpreter: please save away the old value of this global
    variable at run-time, restoring the saved value at block exit".

When you read "my", think:

    "Mr Compiler: please declare this private variable at compile-time
    visible only in its enclosing scope and any scopes nested within
    that one."

Neither of these has a C-programming name, and you know what?  Neither
concept is present in C, at least, not when you add in the automatic
storage management issues related to refcounting.

--tom
-- 
	Tom Christiansen	tchrist@jhereg.perl.com

You have to admit that it's difficult to misplace the Perl sources.  :-)
		--Larry Wall in <1992Aug26.184221.29627@netlabs.com>


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

Date: Fri, 06 Mar 1998 11:21:42 -0600
From: skulk@wam.umd.edu
Subject: Need help using hash to read file/array
Message-Id: <6dpb9p$28$1@nnrp1.dejanews.com>

My problem is that I am trying to read a file that is basically an error log
for a web page. Anytime someone accessed a page and the location failed it was
sent into this log. Now I have to use this error log and search through and
find all the files with a certain extension, say http://one.two.three/AAA
there will be several files and directories from this extension, say
http://one.two.three/AAA/BB/c.html  i need to go through and find these files.
There are a few thousand and of course some will repeat. I want only the first
occurence of these. Help would be much appreciated as I tried to use using
arrays and failed miserably.

-----== Posted via Deja News, The Leader in Internet Discussion ==-----
http://www.dejanews.com/   Now offering spam-free web-based newsreading


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

Date: 06 Mar 1998 13:42:57 -0500
From: Jonathan Feinberg <jdf@pobox.com>
Subject: Re: Need help using hash to read file/array
Message-Id: <90qnzmmm.fsf@news.concentric.net>

skulk@wam.umd.edu writes:

> There are a few thousand and of course some will repeat. I want only the first
> occurence of these. Help would be much appreciated as I tried to use using
> arrays and failed miserably.

You are right in that hashes are better suited for this task.  I'll
assume that you've already extracted the URL from the line, and put it
into the variable $url.

   $urls_seen{$url}++;

That line creates the hash key $urls_seen{$url} if it didn't already
exist, and increments it each time that $url appears.  Then, when
you've gone through the file, you can

   foreach $url (keys %urls_seen) {
      # do something with the $url
   }

Hope this helps.

-- 
Jonathan Feinberg   jdf@pobox.com   Sunny Brooklyn, NY


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

Date: Fri, 6 Mar 1998 11:41:47 -0500
From: "Kat" <kmphillip@RemoveThisPart.Hotmail.com>
Subject: Newbie needs help with utime
Message-Id: <6dp904$7vs$1@proxye1.nycap.rr.com>

Hi!
I'm having trouble getting the utime function to work on NT.  The
following is a sample of my code.
$filename = "file";
$mtime = time;
$atime = time;
utime = ($mtime, $atime, $filename);

I have verified that the file has read/write permissions.  Also, utime
is returning a zero which indicates to me that perl is recognizing the
function.  Also, time is returning the current date and time.

PLEASE HELP OR TELL ME A BETTER WAY TO CHANGE THE FILE MODIFICATION
DATE!

Kathy,
Note: you will need to change the E-mail address. This to prevent SPAM.
kmphillip@RemoveThisPart.hotmail.com





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

Date: 06 Mar 1998 12:34:24 -0600
From: Quentin  Fennessy <quentin@jihad.amd.com>
Subject: Re: Newbie needs help with utime
Message-Id: <ximpvjzeki7.fsf@jihad.amd.com>


"Kat" <kmphillip@Hotmail.com> writes:

> utime = ($mtime, $atime, $filename);
> 

You are assigning to utime() -- not calling it with the appropriate
arguments.  Check out:

	perldoc -f utime

-- 
Quentin Fennessy			AMD, Austin Texas


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

Date: 06 Mar 1998 12:10:33 -0500
From: Jonathan Feinberg <jdf@pobox.com>
Subject: Re: Newbie's question about package
Message-Id: <n2f368za.fsf@news.concentric.net>

? the platypus {aka David Formosa} <dformosa@st.nepean.uws.edu.au> writes:

> qw is more convent.

I think of it as more abbey.  Abbey... gail.

-- 
Jonathan Feinberg   jdf@pobox.com   Sunny Brooklyn, NY


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

Date: Fri, 6 Mar 1998 12:37:16 -0500
From: "cyber giggy" <cybergiggy@home.com>
Subject: Newbies question for Win32
Message-Id: <6dpc9u$fve$1@camel29.mindspring.com>

Hi
I have just downloaded Perl for Win32. and successfully installing it.
I beginning practicing writing in Perl in Notepad. afterward when I try to
save it with a ".pl" .  Notepad then save this as a ".txt" file.  Example:
hello.pl.txt
Question #1. How can I save a file in Notepad with the .pl extension
I have try going in to my folder option in "My Computer\View\Option\Files
types\New type." and add a new type of file.
Question #2. Is what do I fill in the "Content type{MIME}" , "Actions:" & "
Default extension for content type" field.
=====Add New Files Type=====
Description of type: Perl files
Associated extension: .pl
Content type {MIME}: ?????
Default extension for content type:?????
Actions:??????

Thank Q.
Ricky37@mindspring.com




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

Date: Fri, 06 Mar 1998 11:49:07 -0600
From: schwern@starmedia.net
To: GholamReza.Azimi@iu.hioslo.no
Subject: Re: Perl (CGI)/database
Message-Id: <6dpct0$22g$1@nnrp1.dejanews.com>

DBI and DBD::Sybase
http://www.hermetica.com/technologia/perl/DBI/index.html

Gives you full SQL access to Sybase (or any other database via swapping DBD::*
modules)

In article <01bd4854$1173dae0$5c4a2780@0060979f885b.iu.hioslo.no>,
  "Gholam Reza Azimi" <GholamReza.Azimi@iu.hioslo.no> wrote:
>
> Hello everyone
>
> I've developed a database in Sybase. What I would like to know is how to
> process this file through my Perl-scripts for processing and data storage!
> SQL is one way to query data from this file. But what about storage?
>
> can anyone help me with that!
>
> Reza
>


-----== Posted via Deja News, The Leader in Internet Discussion ==-----
http://www.dejanews.com/   Now offering spam-free web-based newsreading


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

Date: 6 Mar 1998 15:59:33 GMT
From: nobody@mudshark.micro.ti.com (David A Thomas)
Subject: Re: Perl and/or C parsing code, in Perl?
Message-Id: <6dp6h5$4ec$1@spock.asic.sc.ti.com>

Rich Morin (rdm@cfcl.com) wrote:
> I'm interested in being able to find the beginnings and endings of blocks,
> as wall as definitions of (and references to) subroutines.  
 ...
> I played around a little with some Perl code to do this and found it a bit
> tricky to get right (!).  I then looked around a bit in the CPAN, but didn't
> find anything that seemed particualrly relevant.  So, I'm asking for pointers.

The Text::Balanced module might be what you're looking for.

--
David Thomas                       (david-at-micro-dot-ti-dot-com)
Texas Instruments, Houston                          (281)-274-2347


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

Date: Fri, 06 Mar 1998 10:21:00 -0500
From: Frank Pape <fxp4258@rit.edu>
Subject: Problem with a CGI counter script...
Message-Id: <3500145C.4976F11A@rit.edu>

I have a very simple CGI script that counts users to a web page (loaded
in an img tag):

---------------
  #!/usr/local/bin/perl

  print "Content-type: image/gif\n\n";

  open(IMG, "<transparent.gif");
  @image = <IMG>;
  close (IMG);
  print @image;

  open(FILE, "count");
  $count = <FILE>;
  close (FILE);
  $count++;
  open(FILE, ">count");
  print FILE "$count";
  close (FILE);
---------------

Most of the time, this works fine, but here's my problem:  Once in a
great great while, something goes screwy and it knocks of a large amount
of hits before rewriting the count file.  This only seems to happen on
my busiest web page (~5000 hits/day), so the only possible cause I can
guess at is that the file is somehow being read by one instance of the
counter while it is being written to by another...

I might be able to fix that if I used a seperate lock file to tell me
when the count file is being written to... But since I don't really know
what's causing the problem (and when it will pop up next), I have no way
to test whether or not it is fixed.

Has anybody else had a similar problem?  Or any ideas?

Thanks in advance,
Frank Pape
fxp4258@rit.edu - please send replies to me via email as well- I'm not
sure how often I can check the newsgroup.


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

Date: 6 Mar 1998 18:06:39 GMT
From: pelakh@rsn.hp.com (Boris Pelakh)
Subject: Re: Problem with a CGI counter script...
Message-Id: <6dpdvf$n55$1@news.rsn.hp.com>

In article <3500145C.4976F11A@rit.edu>, Frank Pape  <fxp4258@rit.edu> wrote:
>Most of the time, this works fine, but here's my problem:  Once in a
>great great while, something goes screwy and it knocks of a large amount
>of hits before rewriting the count file.  This only seems to happen on
>my busiest web page (~5000 hits/day), so the only possible cause I can
>guess at is that the file is somehow being read by one instance of the
>counter while it is being written to by another...

This probably is the problem. Grab CounterFie.pm from CPAN and spare re-
inventing the wheel. It works great for me.

-- 
Boris Pelakh             SPP DevSW / HP CXDL              pelakh@rsn.hp.com
Natural selection saw to it that professional heroes who at a crucial moment 
tended to ask themselves questions like "What is my purpose in life?" very 
quickly lacked both.                 -- (Terry Pratchett, Interesting Times)


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

Date: Fri, 06 Mar 1998 17:45:05 +0100
From: Harald Joerg <Harald.Joerg@mch.sni.de>
To: rthorne@netscape.com
Subject: Re: Using pod2html.pl on Win32
Message-Id: <35002811.B8F9C34D@mch.sni.de>

[mailed and posted]

Rob Thorne wrote:
> 
> I have written some Perl modules, in which I've included POD
> documentation.  The modules now work, but I'm having trouble getting
> HTML out of the .PM files.
> 
> I've gone through the Perlpod page, and I've also read the stuff inside
> pod2html.pl.  It looks like I should be able to do something like this,
> and get out HTML:
> 
> perl pod2html.pl < MyModule.pm > MyModule.html

Usually I say
   pod2html --infile=MyModule.hm --outfile=MyModule.html
to my computer, which works on many operating systems and on Win32.
You can find out more about the various switches by typing
   pod2html --help
or, still more, with
   perldoc pod2html
With 5.004 for Win32, start exercising with:
   pod2html --infile=pod2html.bat --outfile=pod2html.html
(Gurusamy Sarathy's binary distribution for Win32 has 
 pod2html.bat, but no pod2html.pl)
--
Oook,
--haj--


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

Date: 06 Mar 1998 12:08:04 -0500
From: Jonathan Feinberg <jdf@pobox.com>
Subject: Re: Using pod2html.pl on Win32
Message-Id: <ogzj693f.fsf@news.concentric.net>

Rob Thorne <rthorne@netscape.com> writes:

> perl pod2html.pl < MyModule.pm > MyModule.html

   perl pod2html.pl --infile=MyModule.pm --outfile=MyModule.html

Also, are you sure that your pod is well-formed?

-- 
Jonathan Feinberg   jdf@pobox.com   Sunny Brooklyn, NY


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

Date: 6 Mar 1998 17:41:46 GMT
From: cpierce1@cp500.fsic.ford.com (Clinton Pierce)
Subject: Re: utime not working
Message-Id: <6dpcgq$hc74@eccws1.dearborn.ford.com>

In article <6dp3ol$sgi@netaxs.com>,
	joel@wmi0.wmi.com (Joel Coltoff) writes:
>In article <6dnqmr$pfo@dfw-ixnews11.ix.netcom.com>,
>Kat <kmphillip@spamsuck.hotmail.com> wrote:
>
>snip
>
>>PLEASE HELP OR TELL ME A BETTER WAY TO CHANGE THE FILE MOD DATE!
>
>One way would be to use the function as is intended and not the
>way you want it to work. Looking in any book on perl or on-line
>docs is a good place to start. I've been known to use it this
>way but never, never on a first date.
>
>    utime $atime, $mtime, $filename;
>

System calls fail, sometimes:

   utime $atime, $mtime, $filename or die "Couldn't utime $filename: $!\n";

On a first date, you gotta be careful.  
use Protection or die;



*************************************************************************
************************** FREE RANDAL **********************************
*************************************************************************

-- 
+------------------------------------------------------------------------+
|  Clinton A. Pierce    |   "If you rush a Miracle Man,   | http://www.  |
|  cpierce1@ford.com    |     you get rotten miracles"    | dcicorp.com/ |
| fubar@ameritech.net   |--Miracle Max, The Princess Bride| ~clintp      |
+------------------------------------------------------------------------+
GCSd-s+:+a-C++UALIS++++P+++L++E---t++X+b+++DI++++G++e+>++h----r+++y+++>y*



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

Date: Fri, 06 Mar 1998 10:57:38 -0500
From: John Porter <jdporter@min.net>
Subject: Re: What is PERL? Learn JAVA instead?
Message-Id: <35001CF2.6F67@min.net>

Evan Kirshenbaum wrote:
> 
> John Porter <jdporter@min.net> writes:
> >
> > Ha. Perl has no need of "reflection" (java's hacked API which
> > enables dynamic introspection) as a distinct capability,
> > because perl is a dynamic language from the ground up;
> > perl supports introspection (call it dynamic if you want)
> > intrinsically.
> 
> Perl is very good at "try it and cope if it's undefined", which is one
> of the uses for reflection.  It is less good at enumerating *what*
> methods are defined for an object. 

> I'm pretty sure that it can be
> done by going through the symbol tables for the package, but I'd count
> this as "less convenient".  Another reflection question I have is
> whether, without resorting to symbolic references, one can get a
> reference to a sub such that when invoked on an object, the
> appropriate overridden instance is called.

That is, call a (possibly undef) method and catch, vs. don't even try
to call a method if it's undef.

On the first hand, perl has a (arguably barely adequate) try/catch
mechanism, as well as the AUTOLOAD method for handling undefined
calls.  These are all I've ever needed, and I don't consider them
inconvenient.

On the second hand, examining the symbol table is one way (only
rarely have I felt the need to do this).  If you find it too
inconvenient, perhaps you'd find the Devel::Symdump module more
friendly.  Then there's UNIVERSAL::can().  

> > > exception handling,
> >
> There are a couple of differences between [perl's] and (what
> I'd consider) true exception handling.
>
> The first is that your
> exceptions can only be strings, rather than things that contain data.
> Granted, the string can be used as the key into some table somewhere,
> but then you have to remember to take the object out of the table or
> it won't get reclaimed.

That's a pretty good point.
One case when it might not be as troublesome, is if the thing you
want to throw is in a symbol table; then the string can be used as
a symbolic reference.

> Second, and more important, in Perl, I have to catch at every level
> and rethrow if the exception isn't of the correct class, while in Java
> or C++, the language itself guarantees that only the handler at the
> correct level is executed.

I quote tchrist: "...why from function B, he can't call function C 
if C has an exception in its signature that B isn't explicitly 
dealing with, even though he called B from A, and A does handle 
C's exceptions?" (http://language.perl.com/versus/java.html)

If this is Java's notion of correctness, I think it's more
inconvenient, not less.


> Third, code within an eval cannot do a return.

That is, not the kind of return you think you want.
IMHO, this is an idiomatic difference, which has nothing to do with
whether perl has "real" exception handling. IMHO.


> Finally, in Java there is the notion of the "finally" clause that
> ensures that cleanup is handled correctly on the path from the throw
> to the catch or, alternatively, by the normal return.

I'm not sure if I wish C++ had this feature.  I'm getting pretty
frustrated with C++ programs that unceremoiously exit, from god
knows where, because of an uncaught exception.
I'm glad that in perl, an uncaught exception is blithely ignored.
(That is, a die within an eval, whose resulting value of $@ is
not one of the ones tested for.)


> > > switch statements,
> >
> > I -- and I think most perl programmers would agree -- find
> > no inconvenience whatsoever is perl's multi-way braching
> > capability.
> 
> Perhaps I'm an exception.  I've run into bugs several times saying
> 
>   SWITCH:
>    {
>      if ($a eq "foo") { $x = 1; last SWITCH; }
>      if ($a eq "bar") { $y = 25; last SWITCH; }
>      if ($a eq "baz") { $z = "nope"; last SWITCH; }
>      die "None matched";
>    }
> 
> Generally I run into problems when the name of the variable being
> switched over changes and the change isn't reflected in all the cases.

If you have this kind of problem in this context, you're probably
going to have it elsewhere, even if there were a switch statement.


> I will admit that this has gotten considerably better (in terms of
> clarity and maintainability) now that we can say things like
> 
>     sub switch
>     {
>         &{$_[1]->{$_[0]} || $_[2]};
>     }
> 
>     $a = "a";
> 
>     switch($a,
>            {"a" => sub { print "It's an a\n"; },
>             "b" => sub { print "It's a b\n"; }},
>            sub { print "Nothing\n"; });
> 
> but this imposes new restrictions (can't return from the external
> context within a branch), and probably can't be optimized.

Good thing there's more than one way to do it.

"Although the Perl Slogan is There's More Than One Way to Do It, 
I hesitate to make 10 ways to do something.  :-)"
             -- Larry Wall in <9695@jpl-devvax.JPL.NASA.GOV>

John Porter


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

Date: Fri, 06 Mar 1998 11:25:16 -0600
From: "Keith G. Murphy" <keithmur@mindspring.com>
Subject: Re: What is PERL? Learn JAVA instead?
Message-Id: <3500317C.7F71A537@mindspring.com>

Bart Lateur wrote:
> 
> Evan Kirshenbaum <evan@garrett.hpl.hp.com> wrote:
> 
> >On second thought, it appears that I may be being to charitable.  A
> >reading of perlobj points out that yes, there is true garbage
> >collection going on, but it happens *only* at interpreter shutdown (by
> >running a mark/sweep).  A test confirms that this appears to be what
> >happens.  This does guarantee that destructors are (eventually)
> >called, but it also means that a program that needs to repeatedly
> >build large temporary graphs is still going to find itself rapidly
> >growing and/or running out of memory due to uncollected garbage.
> 
> It seems like letting the programmer manually invoking the (full)
> garbage collector, just like happens at interpeter shutdown, might be a
> worthwile addition to the Perl kernel.
> 
> In the meantime, a workaround might be manually breaking the circular
> chain, once you know you're through.

IIRC there's an example of that in HTML::Element.


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

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

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