[11099] in Perl-Users-Digest

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

Perl-Users Digest, Issue: 4699 Volume: 8

daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Wed Jan 20 13:05:45 1999

Date: Wed, 20 Jan 99 10:00:20 -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           Wed, 20 Jan 1999     Volume: 8 Number: 4699

Today's topics:
    Re: dbmopen vs. tie (Greg Ward)
    Re: Difficult issues not suitable for this newsgroup? <newsposter@cthulhu.demon.nl>
        ERROR: Parse Exception kate_stafford@my-dejanews.com
        Example of Perl Cookie Implementation please (Steve .)
        help with search and replace please pault2000@my-dejanews.com
    Re: help with search and replace please (Larry Rosler)
    Re: I have got a Perl problem <r25545@email.mot.nospam.com>
    Re: Is perl the right choise for the following job? <ed@pcr8.pcr.com>
    Re: Is there a way to create self contained perl execut (Clinton Pierce)
    Re: list of hashes <dgris@moiraine.dimensional.com>
    Re: list of hashes <alex@kawo2.rwth-aachen.de>
    Re: list of hashes <alex@kawo2.rwth-aachen.de>
    Re: location of the faq (was append to beginning) <newsposter@cthulhu.demon.nl>
        locking file for updating miko@idocs.com
    Re: Merging multiple files together........ <darrick@2unreal.com>
    Re: New to perl - trying to FTP (Greg Ward)
    Re: newbie - endless loop on simple program. (Greg Ward)
        Open File Detect <Robert.Davis@jhuapl.edu>
        perl script error kamez@my-dejanews.com
    Re: problem with: use module; (M.J.T. Guy)
    Re: problem with: use module; <Tony.Curtis+usenet@vcpc.univie.ac.at>
    Re: problem with: use module; <dgris@moiraine.dimensional.com>
        Running scripts with differing parameters. <no_spam@no_spam.com>
        Seeking a Book on (MS) SQL w/ perl <cmeilahn@nauiww.org>
        subroutine return values <rob.slattery@amaonline.com>
    Re: text indexes from lists sno@ais.org
    Re: Year 2038 problem (Curt Tilmes)
        Special: Digest Administrivia (Last modified: 12 Dec 98 (Perl-Users-Digest Admin)

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

Date: 20 Jan 1999 17:41:29 GMT
From: gward@thrak.cnri.reston.va.us (Greg Ward)
Subject: Re: dbmopen vs. tie
Message-Id: <7854g9$kdt$1@news0-alterdial.uu.net>

bluepuma@mailexcite.com <bluepuma@mailexcite.com> wrote:
> I just run into an error message using dbmopen :
> ndbm store returned -1, errno 28, key "204.174.244.4" at ./analyse line 143.
> 
> After browsing through newsgroups and altavista I believe it's because
> the value exceeds 1024 characters (bytes).

Quite possibly -- it says here (Camel Book p. 379, or 'perldoc
AnyDB_File') that dbm has 1024-byte blocksize limits, and ndbm has
4096-byte limits.  So your records are probably greater than 4k, not 1k,
but essentially you're right.

> If I would use the (not as easy to use) tie function, could I get
> rid of the 1024 byte limitation of the value ?

It depends what you tie to.  This isn't a limitation of Perl or the
old-fashioned dbmopen interface to DBM files; it's a limitation of the
underlying library.  dbm and ndbm (one or both of which are included
with most Unices) both suffer from the problem, as does sdbm (a
small-but-slow DBM that comes with Perl for use on systems that don't
already have it).

You have two options: GDBM or Berkeley DB.  DB is more powerful and
flexible, but GDBM is easier to build.  If all you need is a DBM with no
hard-coded blocksize limitations, GDBM is what you want.  Find it at
ftp://ftp.gnu.org/gnu/gdbm (or a mirror near you).  And yes, you'll have
to 'use GDBM_File' and then explicitly tie your file to a GDBM_File
instance.  dbmopen is convenient, but limited.

BTW, you should definitely read the AnyDB_File man page (or pp. 378-380
in the Camel Book) for a discussion of the various low-level database
formats available through Perl.

        Greg
-- 
Greg Ward - software developer                    gward@cnri.reston.va.us
Corporation for National Research Initiatives    
1895 Preston White Drive                      voice: +1-703-620-8990 x287
Reston, Virginia, USA  20191-5434               fax: +1-703-620-0913


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

Date: Wed, 20 Jan 1999 11:33:56 -0500
From: Erik van Roode <newsposter@cthulhu.demon.nl>
Subject: Re: Difficult issues not suitable for this newsgroup?
Message-Id: <36A60572.56658DC8@cthulhu.demon.nl>

James Richardson wrote:
> 
> <BAD MOOD>
> Why oh why is it that only simple questions seem to be asked / answered on
> this newgroup? Innumerable questions about CGI, about paths, about any
> number of things that are immediately knowable from the perl FAQ, or man
> perlfunc, but no interest at all about a reasonably valid question on XS,
> shame, I thought I might have contributed enough answers to this newsgroup
> over the last couple of years to warrant one difficult question.
> </BAD MOOD>
> 
> What do you think?

I'm almost always able to fix my problems. No need to ask them here.
That's probably true for most regular readers here.

Erik
-- 
Sure, doesn't everyone sign up for internet service so as to have
their mailbox stuffed with megabytes of postage-due rubbish every day?
Absolutely.  And everyone who owns a car intends that it be used as a
portable dumpster.  Any unwanted garbage in their vehicle they can
simply throw away, after all.


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

Date: Wed, 20 Jan 1999 16:24:46 GMT
From: kate_stafford@my-dejanews.com
Subject: ERROR: Parse Exception
Message-Id: <785000$epm$1@nnrp1.dejanews.com>

I'm pretty new to Perl, so bare with me if this is a stupid question.

I wrote a script with ActiveState build 509. It runs great when I run perl
script.pl, but when I compiled it with perl2exe, the program terminates with
ERROR: Parse Exception. I am able to successfully compile it on another system
running an identical installation of ActiveState.

I noticed in past posts people getting Parse Exception with the Win32-OBDC
module. I'm not using this in my script, but I updated it anyways with no
luck.

Any suggestions?

Thanks in advance,
Kate

*********************
 Kate Stafford, MCSE
 Network Engineer
*********************

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


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

Date: Wed, 20 Jan 1999 16:41:02 GMT
From: syarbrou@nospam.enteract.com (Steve .)
Subject: Example of Perl Cookie Implementation please
Message-Id: <36a60631.1769028@news.enteract.com>

I want to have a script on my unix box that when someone fills out a
form and submits it, the perl script will place a cookie on their
system to let me know next time they come in that they filled out the
form.

Next time they come in, I want to be able to check for that cookie,
and if it exists, redirect elsewhere.  I know how to do the redirect,
but was hoping to see some real examples of using cookies in a perl
script.  Thanks.

Steve


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

Date: Wed, 20 Jan 1999 15:55:29 GMT
From: pault2000@my-dejanews.com
Subject: help with search and replace please
Message-Id: <784u9b$d6q$1@nnrp1.dejanews.com>

Hi,

I have written a Perl script which is designed to perform a search and replace
on a file. The item to replace is taken from a file called pidate.log which is
then passed to the variable $oldate (or so I hoped). the item to replace it
comes from a simple form submission which is passed to $today.
(i.e. oldate is replaced by today)

Then (and this is where it goes wrong) $oldate should be replace by $today

I think there may be a problem with the way I am handling the $oldate file
(pidate.log).

Any help would be greatly appreciated as this is my most complex script yet!

Thanks in advance,

Paul

#!/usr/local/bin/perl -w
#
require "cgi-lib2.pl";
&ReadParse;
print "Content-type: text/html\n\n";

#################################################################
#            initialise date variable from form                 #
#################################################################
$today=$in{'today'};
#################################################################
#             open pidate.log and feed to variable              #
#################################################################

open (DATE, ">/datadisk/webvision/files/html/pidate.log") or die "can't open
date log: $!";

$olddate = <DATE>;

print DATE "$today" or die "can't print date log: $!";



#################################################################
#          open pi page and and search and replace date         #
#################################################################


$old="/datadisk/webvision/files/html/PI2.html";
$new="/datadisk/webvision/files/html/PI3.html";
$bak="/datadisk/webvision/files/html/PI2.bak";


open(OLD, "< $old") or die "can't open $old: $!";
open(NEW, "> $new") or die "can't open $new: $!";

#################################################################
#                       PROBLEM BELOW                           #
#################################################################

while (<OLD>) {
	s/$oldate/$today/g;
		(print NEW $_)	or die "can't write to $new: $!";
}

close(OLD)	or die "can't close $old: $!";
close(NEW)	or die "can't close $new: $!";
close(DATE)  or die "can't close date log: $!";;
rename($old, $bak)	or die "can't rename $old to $bak: $!";
rename($new, $old)	or die "can't rename $new to $old: $!";

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


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

Date: Wed, 20 Jan 1999 08:51:47 -0800
From: lr@hpl.hp.com (Larry Rosler)
Subject: Re: help with search and replace please
Message-Id: <MPG.110fa97764587efd9899aa@nntp.hpl.hp.com>

[Posted and a courtesy copy mailed.]

In article <784u9b$d6q$1@nnrp1.dejanews.com>, pault2000@my-dejanews.com 
<pault2000@my-dejanews.com> says...
 ...
> open (DATE, ">/datadisk/webvision/files/html/pidate.log") or die "can't open
> date log: $!";

Good diagnostic!  The file is created, or immediately truncated to zero 
length if it exists already.

> $olddate = <DATE>;

And now you read from it!  Hmmm...  I will read the code no further than 
this.

-- 
(Just Another Larry) Rosler
Hewlett-Packard Company
http://www.hpl.hp.com/personal/Larry_Rosler/
lr@hpl.hp.com


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

Date: Wed, 20 Jan 1999 16:52:23 +0100
From: Stephane Du Pasquier <r25545@email.mot.nospam.com>
Subject: Re: I have got a Perl problem
Message-Id: <36A5FBB7.702B@email.mot.nospam.com>

Ilya wrote:

> I get this error message with Perl 5.004, but not 5.003. The platform is
> HP-UX 10.20 and 9.*.
> 
> Value of <HANDLE> construct can be "0"; test with defined() at probe_components.pl line 65535.

this is a new warning in 5.004, when running in warning mode (-w);
most of the time, you can assume that any successfuly read line
evaluates to true, since it ends by a newline char (i.e., it
cannot be plain "0" or ""; and "0\n" or "\n" is true in perl).

in this case, it is safe to say:

  while($line=<FILE>) { ... }
or
  while(<>) { ... }

to read input files until the end. However, if the last line
of a (bugous) text file only contains a "0" (no newline), the
loop will miss it. Hence the warning. As suggested, the solution
is to check, not if the line is true, but rather if the read
completed, by checking if the returned value is defined. Above
examples can be rewritten this way:

  while(defined($line=<FILE>))
or
  while(defined($_=<>))

Alternatively, you can continue to use old scripts by removing
the -w at the top, provided you know you won't need the invaluable
warnings of this mode.

Didn't check yet, but before 5.005 was out, I think I read they
planned to remove this warning. Confirmation, anyone?

S.


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

Date: Wed, 20 Jan 1999 12:10:20 -0500
From: Ed Eddington <ed@pcr8.pcr.com>
Subject: Re: Is perl the right choise for the following job?
Message-Id: <36A60DFC.14A581C@pcr8.pcr.com>

Is LWP included with the standard Perl5 distribution?

Eugene Sotirescu wrote:
> 
> John Chambers wrote:
> 
> > Hmmm ... The CPAN archives seem to have HTML::Simple, but there
> > doesn't seem to be any LWP::Simple.  I grabbed the latest LWP and
> > installed it, and "man LWP::Simple" says "not found".
> >
> > Where do you get it?
> >
> > One problem is that the CPAN module list contains the word "simple"
> > about a zillion times, so it's not worth much as a search keyword.
> 
> It should have been installed with the lwp bundle.
> Try perldoc LWP::Simple
> 
> Look for in something like:
> 
> /usr/lib/perl5/site_perl/LWP
> 
> --
> 
> Eugene
> 
>  "I have an Apache Web Server that uses CGI forms written in COBOL."
>                                                         Post in clpm


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

Date: Wed, 20 Jan 1999 16:19:22 GMT
From: cpierce1@mail.ford.com (Clinton Pierce)
Subject: Re: Is there a way to create self contained perl executable?
Message-Id: <36a5f8a8.427830@news.ford.com>

On 20 Jan 1999 07:07:17 -0700, Tom Christiansen <tchrist@mox.perl.com>
wrote:

> [courtesy cc of this posting sent to cited author via email]
>
>In comp.lang.perl.misc, neilpaku@paradise.net.nz writes:
>:	I couldn't find in the faqs a solution to my problem. I would like to
>:create a script that also contained the perl interpreter so that I could
>:place this script on any machine and run it without having to install
>:perl. Is this possible? The intended platform is nt. If it is possible,
>
>Let's suppose that your script is 5k and the perl installation is
>two megatabytes.  If you give them both together, it costs 2.005
>megabyte.s  If you give them three such scripts,  it's now going to
>cost 6.015 megabytes.  Do you see where this is going?  It's a bad idea.
>Just give them the script.  If they want Perl, they know where to find it.
>If they don't know where to find it, then their professional systems
>admistrator will.  If they don't have one of those, then shame on them --
>computers are not toasters.  

For a development environment, or an environment where Perl is an
integral part of the operating environment (a webserver) I agree
wholeheartedly.   Install a Perl distribution.  Environments like that
should be professionally run, and to not be able to install a perl
distribution is a sign of ineptitude.  Agreed, Amen, and Hallelujeh.

However, for a VAST majority of Real Users, computers are toasters.
Turn it on.  Type letter to grandma.  Click on AOL.  Surf the Web.  I
only object to the (implied) overgeneralization that all computers (even
NT) that would want to make use of Perl programs are professionally run.

>But you could install Perl for them if and
>only if Perl is not already installed.   But this "bundle the interpreter
>with the script" on disk every time is just plain dumb.  Just say no.

It is a Necessary Evil to get work done, for some.  A perl2exe
distribution of a piece of software can easily be wrapped with Install
Shield, and point-and-drool installed by any POB who needs that perl
script to run.   4617089843.2   3145728

To do otherwise requires:

	1. Installing Activestate
	2. Rebooting
	3. Installing the correct support modules  (NOT an easy task.)
	4. Installing the script
	5. Resolving Path/AS installation issues.
	6. Running the script.

Even Prisoners of Bill should be able to reap the benefits of Perl.
(Without having to go through THAT.)  A "Professional", running a
system, should be able to deal with those steps.  I wouldn't expect an
end-user to.   Even 3MB of disk storage[1] is only about $.10 in 1999.
That may be an acceptable tradeoff.

>PS:  The cited perl2exe thingie ranges from remarkably stupid at its
>     best to a dangerous lie at its worst, depending on how it is
>     presented.  Forget it.

Such a blanket statement is developer bigotry and remarkably
shortsighted.  Software distribution is a Real Problem in the Real
World.  For development or professionally run environments, this
attitude may be appropriate.  For customers who are Windows Users who
just want to Get Things Done, and use a Perl application to do it,
perl2exe may be an adaquate bundling solution.


To the original poster: evaluate the pros and cons of using a bundler
like "perl2exe" based on the re-use value a real Perl distribution on
the disk, the competency of your administration staff, and whatever real
factors should be considered in your case.



[1] CompUSA, Seagate 4.3GB IDE (ST34321A) $149.95


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

Date: 20 Jan 1999 09:56:06 -0700
From: Daniel Grisinger <dgris@moiraine.dimensional.com>
Subject: Re: list of hashes
Message-Id: <m3iue1yjbt.fsf@moiraine.dimensional.com>

Alex Farber <alex@kawo2.rwth-aachen.de> writes:

> I have a question. Why doesn't it work to push() 
> a reference to a hash into a list, like this:
> 
>     push @loh, $href;

That works fine.

> Why do I have to do an extra anonymous hash:
> 
>     push @loh, {%$href};

I am simply guessing (all that I can do when not given any code
to look at), but I'd say that $href is probably a global variable
(or a lexical that hasn't gone out of scope) and that you are
pushing a reference to the same hash onto your array every time.
The second form you cited creates a copy of the original hash in
a new anonymous hash and then pushes that onto @loh, avoiding the
problem.

HTH.

dgris
-- 
Daniel Grisinger          dgris@moiraine.dimensional.com
perl -Mre=eval -e'$_=shift;;@[=split//;;$,=qq;\n;;;print 
m;(.{$-}(?{$-++}));,q;;while$-<=@[;;' 'Just Another Perl Hacker'


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

Date: Wed, 20 Jan 1999 18:13:14 +0000
From: Alex Farber <alex@kawo2.rwth-aachen.de>
To: Daniel Grisinger <dgris@moiraine.dimensional.com>
Subject: Re: list of hashes
Message-Id: <36A61CBA.E95076A7@kawo2.rwth-aachen.de>

[posted + mailed]

Hi Daniel,

> >     push @loh, $href;
> >     push @loh, {%$href};
> 
> I'd say that $href is probably a global variable
> (or a lexical that hasn't gone out of scope) and that you are
> pushing a reference to the same hash onto your array every time.
> The second form you cited creates a copy of the original hash in
> a new anonymous hash and then pushes that onto @loh, avoiding the
> problem.

could you please explain it little bit more? Because you seem
to be correct - it looked like I was always pushing the same 
(it printed HASH(0x80c5c9c) for all occurences) empty hash with 
my SybPerl-script:

   use strict;
   my $href;
 ...
   while($href = $dbh->ct_fetch(1, 1)) {
          push(@loh, $href);
       }
 ...
   for (@loh) {print;}      # debugging

Thanks!
/Alex 

--
http://www.simplex.ru/pref.html


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

Date: Wed, 20 Jan 1999 18:16:17 +0000
From: Alex Farber <alex@kawo2.rwth-aachen.de>
To: Daniel Grisinger <dgris@moiraine.dimensional.com>
Subject: Re: list of hashes
Message-Id: <36A61D71.269BFBDC@kawo2.rwth-aachen.de>

[posted + mailed again, sorry]

Oops, I have just reread the SybPerl man:


@data = $dbh->ct_fetch([$doAssoc [, $wantRef]])

     Retrieve one row of data. If $doAssoc is non-0, 
      a hash is returned with column name/value pairs. 
     If $wantRef is non-0, then a reference to an array 
     (or hash) is returned. This reference points to a
     static array (or hash), so to store the returned rows 
     in an array you must copy the array (or hash): 

       while($d = $dbh->ct_fetch(1, 1)) {
          push(@rows, {%$d});
       }


So I have to copy that static hash! Thanks for help!

/Alex

--
http://www.simplex.ru/pref.html


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

Date: Wed, 20 Jan 1999 11:24:12 -0500
From: Erik van Roode <newsposter@cthulhu.demon.nl>
Subject: Re: location of the faq (was append to beginning)
Message-Id: <36A6032B.C76F4D06@cthulhu.demon.nl>

"Ronnie D. Jewell" wrote:

> For future reference; where do I find a copy of the FAQ everyone
> mentioned?

Read the '[Perl] How to find the Perl FAQ' message that gets posted
regularly.

Erik


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

Date: Wed, 20 Jan 1999 15:59:37 GMT
From: miko@idocs.com
Subject: locking file for updating
Message-Id: <784uh1$dak$1@nnrp1.dejanews.com>

I seek advice on an issue which is a little more complicated than the
basic "how to lock a file" question.

What I'm trying to do can best be described with the "Public Bathroom"
metaphor.  (How proud I am that my programs can now be compared to
public bathrooms.  "Yes Mr. Interviewer", I can proudly say, "my
programs emulate toilets and urinals.")  Anyway, I'm writing a program
which accesses information in a tied hash file.  Like a public bathroom,
most of the time many instances of the program can share this resource,
because they will only be reading, not writing the information.  However,
every once in a while a second program, a sort of cyber-janitor, comes
along and needs to close the file down for cleaning... er... updating
the database.  At that point I'd like the janitor to put up a "closed
for updating" sign.  Then the janitor waits for any instances that
slipped in ahead of him to finish and leave.  Any instances that arrive
AFTER him have to wait until he's done.  The cyber-janitor does the
updates, takes down the sign, and any waiting instances can use the
resource again.  Now, to make things just a little more complicated,
there might be more than one program that needs to update the database.
This building has a lot of enthusiastic janitors, and they need to only
update the database one at a time.

So what I need is some sort of sometimes-lock mechanism.  Sharing is OK
most of the time, but sometimes the file is locked.  I read through the
FAQ and other documentation and haven't found any mention of this issue.
Is there a standard way of doing this?

- miko

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


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

Date: Wed, 20 Jan 1999 08:02:23 -0800
From: Dee <darrick@2unreal.com>
To: Tad McClellan <tadmc@metronet.com>
Subject: Re: Merging multiple files together........
Message-Id: <36A5FE0F.3E15087A@2unreal.com>

Sorry for not including more informaion with my previous post. The data
contained in the files look like this:
12-01-99 10:02:23 John Doe Portland Or 97211

The data is separated by just a single space. The fields do not have a
character limit. I would like to merge the information from multiple txt
files into just one txt file. I would like to sort the entries by date and
then time.

If there is any more information needed please drop me a message.

Thanks,
Dee

>



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

Date: 20 Jan 1999 17:26:47 GMT
From: gward@thrak.cnri.reston.va.us (Greg Ward)
Subject: Re: New to perl - trying to FTP
Message-Id: <7853kn$j8s$1@news0-alterdial.uu.net>

Richard Gordon <abc@abc.com> wrote:
> I am trying to use the ftp.pl package supplied with my perl distribution to
> get a list of files on an ftp server. Everything seems to work ok but I
> cannot work out how to get the list of files returned into an list(or even
> find out how the list of files get returned).

Gaaak!  That stuff is really, really, really old.  I doubt it's
supported anymore.  (I just looked at ftp.pl, and uh-oh! it uses
chat2.pl.  Bad sign...)

> I am using the ftp.pl package rather than the Net:FTP as I could not get the
> later to install.

Perhaps you should tell us what problems you had installing Net::FTP --
or more accurately, libnet.  Show us the commands you ran and the output
you got, and explain what's wrong (if it's not obvious).

I have a baaad feeling that you might be running Perl 4, though... in
which case, I have only one word for you: upgrade!  (Use "perl -v" to
find out what version of Perl you have.)

        Greg

-- 
Greg Ward - software developer                    gward@cnri.reston.va.us
Corporation for National Research Initiatives    
1895 Preston White Drive                      voice: +1-703-620-8990 x287
Reston, Virginia, USA  20191-5434               fax: +1-703-620-0913


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

Date: 20 Jan 1999 17:49:05 GMT
From: gward@thrak.cnri.reston.va.us (Greg Ward)
Subject: Re: newbie - endless loop on simple program.
Message-Id: <7854uh$kdt$2@news0-alterdial.uu.net>

Robert E. John <rjohn@raptor.com> wrote:

> # CODE FRAGMENT
> 
> $num=0;
> $increment=0.1;
> until ($num == 1.1) {
>   print("$num ");
>   $num = ($num + $increment); #Am I doing something bad here??
> 
> } #END OF CODE FRAGMENT
> 
> The program is simply supposed to output 0.1 0.2 0.3 0.4 0.5 0.6 0.7 0.8 0.9
> 1.0

In general, never assume that "x == y" will be true for floating point
numbers.  You just can't compare them for equality.  Use a relative
comparison, eg. recode your loop as

 until ($num > 1.0) {
   print "$num ";
   $num += $increment;
 }

Two aesthetic changes I made: remove the parens from the print
statement; they're unneeded, and would give you warning messages if you
ran with "-w" (which you should always, *always* do!).  And I changed
your increment to use Perl's increment-assignment operator, a very
convenient little beast borrowed from C.  Concision matters (but don't
take it too far!).

        Greg
-- 
Greg Ward - software developer                    gward@cnri.reston.va.us
Corporation for National Research Initiatives    
1895 Preston White Drive                      voice: +1-703-620-8990 x287
Reston, Virginia, USA  20191-5434               fax: +1-703-620-0913


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

Date: Wed, 20 Jan 1999 11:39:32 -0500
From: Bob Davis <Robert.Davis@jhuapl.edu>
Subject: Open File Detect
Message-Id: <36A606C4.FF106BE3@jhuapl.edu>

Is there anyway that I can detect that a file is currently opened by
another process?  Specifically, I need to be able to detect when an FTP
transfer completes so I can then move the file someplace else.
Thanks,
Bob



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

Date: Wed, 20 Jan 1999 15:38:09 GMT
From: kamez@my-dejanews.com
Subject: perl script error
Message-Id: <784t8v$c6g$1@nnrp1.dejanews.com>

thanks for helping me for the following touble i have ,
i'm not used with Perl ,
Thanks for any quick advise.
Khalid,

Here is the error message ( after running the script on Linux environment )

$ ./scriPerl.pl messages.1 ./scriPerl.pl: =256: command not found
 ./scriPerl.pl: =: command not found ./scriPerl.pl: =0: command not found
 ./scriPerl.pl: =0: command not found ./scriPerl.pl: =0: command not found
 ./scriPerl.pl: =0: command not found ./scriPerl.pl: =0: command not found
 ./scriPerl.pl: =0: command not found ./scriPerl.pl: =0: command not found
 ./scriPerl.pl: =0: command not found ./scriPerl.pl: =0: command not found
 ./scriPerl.pl: =0: command not found ./scriPerl.pl: =0: command not found
 ./scriPerl.pl: =0: command not found ./scriPerl.pl: =0: command not found
 ./scriPerl.pl: =0: command not found ./scriPerl.pl: =0: command not found
 ./scriPerl.pl: =0: command not found ./scriPerl.pl: =0: command not found
 ./scriPerl.pl: =0: command not found ./scriPerl.pl: =0: command not found
 ./scriPerl.pl: =0: command not found ./scriPerl.pl: syntax error near
unexpected token `open(IN,' ./scriPerl.pl: ./scriPerl.pl: line 28: `open(IN,
"<$name" ) || die  " can't open  file: $!";' $

And here is the part of the script it self  that causes the error :

$ more scriPerl.pl
$start;
$max_kbps=256;
$name = $ARGV[$1];
$ftotal=0;
$loops=0;
$total_pcn=0;
$total_kbps=0;
$total_nntp=0;
$total_smap=0;
$total_ftp=0;
$total_cis=0;
$total_tn=0;
$total_rap=0;
$total_other=0;
$t_http=0;
$t_pcn=0;
$t_nntp=0;
$t_smap=0;
$t_ftp=0;
$t_cis=0;
$t_tn=0;
$t_rap=0;
$t_other=0;

#
#---------------------------------- main--------------------------------------
#
open(IN, "<$name" ) || die  " can't open file: $!";
#
$_=<IN>;
$logdt= substr($_, 0, 6);  # Pull the date from first 6 char. of log file.

print  STDOUT << "EndOfHeader";





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


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

Date: 20 Jan 1999 16:32:53 GMT
From: mjtg@cus.cam.ac.uk (M.J.T. Guy)
Subject: Re: problem with: use module;
Message-Id: <7850fl$qr8$1@pegasus.csx.cam.ac.uk>

In article <783b9n$rdo$1@meowhost.meow.invalid>,
Fluffy <meowing@banet.net> wrote:
>Julien 'Jay' Tane <jtane@etu.info.unicaen.fr> wrote:
>> 
>> when I try :                 perl  mainfile.pl
>> 
>> it stops the compilation and prints:
>>             Module.pm did not return a true value at mainfile.pl
>
>You forgot to meow.  Add the following as the last line in Module.pm:
>
>	'meow';
>
>and all will be well.
>
>(Okay, any true statement will work, but meowing has so much more
>panache than a simple 1.  See the 'require' entry in perlfunc for an
>explanation of what the meowing accomplishes.  'use' is a form of
>'require', which is why the documentation may seem out of place.)

But 'meow' does have the minor disadvantage that if you check your
module with perl -wc, you'll get an error

Useless use of a constant in void context at ...


Mike Guy


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

Date: 20 Jan 1999 17:37:43 +0100
From: Tony Curtis <Tony.Curtis+usenet@vcpc.univie.ac.at>
Subject: Re: problem with: use module;
Message-Id: <83ogntrjc8.fsf@vcpc.univie.ac.at>

Re: problem with: use module;, M
<mjtg@cus.cam.ac.uk> said:

M> But 'meow' does have the minor disadvantage that
M> if you check your module with perl -wc, you'll
M> get an error

M> Useless use of a constant in void context at ...

<waste type=bandwidth>
Isn't that really a "useless use of cat" error? :-)
</waste>

-- 
Tony Curtis, Systems Manager, VCPC,    | Tel +43 1 310 93 96 - 12; Fax - 13
Liechtensteinstrasse 22, A-1090 Wien,  | <URI:http://www.vcpc.univie.ac.at/>
"You see? You see? Your stupid minds!  | private email:
    Stupid! Stupid!" ~ Eros, Plan9 fOS.| <URI:mailto:tony_curtis32@hotmail.com>


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

Date: 20 Jan 1999 09:37:35 -0700
From: Daniel Grisinger <dgris@moiraine.dimensional.com>
Subject: Re: problem with: use module;
Message-Id: <m3n23dyk6o.fsf@moiraine.dimensional.com>

bart.lateur@skynet.be (Bart Lateur) writes:

> Funny. Too bad you can't forget about the quoting, or you'd get
> warnings.

Nope, only if you have strict in effect.

$ cat meow.pm
package meow;
use strict;
sub new { return bless {}, shift }
no strict;
meow;
__END__

$ cat test.pl
use Devel::Peek;
use meow;
$purrrrr = new meow;
Dump $purrrrr;

$ perl test.pl
SV = RV(0x8121d2c) at 0x8118274
  REFCNT = 1
  FLAGS = (ROK)
  RV = 0x8111bc4
    SV = PVHV(0x81410d0) at 0x8111bc4
      REFCNT = 1
      FLAGS = (OBJECT,SHAREKEYS)
      NV = 0
      STASH = 0x813726c "meow"
      ARRAY = 0x0
      KEYS = 0
      FILL = 0
      MAX = 7
      RITER = -1
      EITER = 0x0


> You could also say
> 
> 	42
> 
> which would also add some mystery. And it's the answer to the question
> on life, the universe and everything.

Yup, I've actually used that in modules.  My coworkers got a kick
out of it. :-)

dgris
-- 
Daniel Grisinger          dgris@moiraine.dimensional.com
perl -Mre=eval -e'$_=shift;;@[=split//;;$,=qq;\n;;;print 
m;(.{$-}(?{$-++}));,q;;while$-<=@[;;' 'Just Another Perl Hacker'


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

Date: Wed, 20 Jan 1999 11:24:06 -0600
From: "Ban Spam Now" <no_spam@no_spam.com>
Subject: Running scripts with differing parameters.
Message-Id: <7853hq$10q@dfw-ixnews9.ix.netcom.com>

I am maintaining an existing Perl script for the first time.

I am thinking of writing a generalized function, within the script, which
executes the ksh script passed as a parameter to it. The reason for my
re-write is that there are a lot of functions, which basically do the same
thing but run different ksh scripts  its crying out for a general
function.

In an ideal world I would have all the kshs in separate files and have a
parameter file containing the ksh file names, the Perl script would loop
through the file names and execute them one at a time.

The problem I have is that some of the ksh files have parameters and some
dont.  The number of parameters vary and the parameters are always
variables which exist within the Perl script.

So, at run time, not only do I need to know the ksh script Im going to run
(the easy bit, I can read it from the file), but I also need to know which
parameters to pass it and somehow know which Perl variable they will be.

I hope Ive been clear!  Any ideas? Anyone done anything similar?

Thanks in anticipation.





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

Date: Wed, 20 Jan 1999 11:49:43 -0500
From: Carl Meilahn <cmeilahn@nauiww.org>
Subject: Seeking a Book on (MS) SQL w/ perl
Message-Id: <36A60926.C6B87A2F@nauiww.org>

Help!  I am looking for a book to help me learn to use SQL with
Perl 5.  I have a number of scripts using a flat-file system that
I'm going to be porting to an MS SQL server for better
reliability & speed.  Any suggestions for books and/or websites
would be great!  Please reply to my email address.

Thanks in advance.

--Carl M.




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

Date: Wed, 20 Jan 1999 10:44:41 -0600
From: "Rob S" <rob.slattery@amaonline.com>
Subject: subroutine return values
Message-Id: <nLnp2.1877$LL3.8257@newsfeed.slurp.net>

I have a subroutine which prints a line before it finishes
and control goes back to the main program. How can I use
the return value, 1 or 0 from a "successful subroutine print" back in
the main body of the program?

Thanks,
Rob Slattery


--
rob.slattery@amaonline.com
robert.slattery@noaa.gov
http://members.amaonline.com/chicago/
http://www.srh.noaa.gov/ama/




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

Date: Wed, 20 Jan 1999 17:12:32 GMT
From: sno@ais.org
Subject: Re: text indexes from lists
Message-Id: <7852pl$hat$1@nnrp1.dejanews.com>

In article <7835l9$tgj$1@nnrp1.dejanews.com>,
  sno@ais.org wrote:
> My desire is to have values in a regular array become a text key to
> positions in another array.
>
> For example:
>
> @list_of_keys ('id', 'name', 'address', 'home phone', 'work phone');
>
> @list_of_arrays = (
>         ['1', 'George', '333 Way Way', 'none', '555-5555'],
>         ['2', 'Pattie', '123 Orchard', '555-5555', '555-5555'],
>         ['3', 'Gary', '4444 Forest', '555-5555', '555-5555']
> );
>
> I would like to be able to acquire a column of data from all lists using
> the key name by position value.
>
> So that conceptually:
>
> $list_of_arrays[$num]['id'] would always reference the zero'th list position
> of all records. 'name' would reference list position '1', etc.
>
> Essentially, the desire is to reference a position with something like this:
>
> $list_of_arrays[$num]->[*keyname from alternate source*] without having to
> force a look-up compare loop for each call.
>
> I hope this is clear.  Anyway, I'm not a total moron when it comes to
> Perl.  The deeper concepts that might help me figure out a solution
> to this are not yet understood.
>
> Thanks for the helpful responses.
>
> --
> Stephen N. Opal

Well, I guess it was a lamer question.  After pondering this issue overnight
it seemed to me that if there isn't a perl utility (say 'enum') that would
give the result I wanted, I would either make my own sub or create a
look-up table with hashes.

With a pre-initialized table, it would be as cumbersome textually, and be
a bit faster at the expense of creating yet another hash list.

Unless someone offers some information that I haven't considered, I'll likely
go with the table solution.

Stephen Opal         sno@ais.org          http://www.ais.org/~sno

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


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

Date: 20 Jan 1999 16:09:48 GMT
From: curt@module (Curt Tilmes)
Subject: Re: Year 2038 problem
Message-Id: <784v4c$f61@post.gsfc.nasa.gov>

Matt Curtin (cmcurtin@interhack.net) wrote:
: $ uname -a
: IRIX gonzo 6.5 05190004 IP32

: $ perl -v
: This is perl, version 5.004_04 built for irix-n32

: $ perl -e 'print scalar localtime 2**30, "\n"'
: Sat Jan 10 08:37:04 2004

: $ perl -e 'print scalar localtime 2**31, "\n"'
: Fri Dec 13 15:45:52 1901

: $ perl -e 'print scalar localtime 2**55, "\n"'
: Wed Dec 31 19:00:00 1969

% uname -ms
Linux alpha
% perl -v

This is perl, version 5.005_02 built for alpha-linux

% perl -e 'print scalar localtime 2**30, "\n"'
Sat Jan 10 08:37:04 2004
% perl -e 'print scalar localtime 2**31, "\n"'
Mon Jan 18 22:14:08 2038
% perl -e 'print scalar localtime 2**55, "\n"'
Sun Jun 13 01:26:08 1141709097



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

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


Administrivia:

Well, after 6 months, here's the answer to the quiz: what do we do about
comp.lang.perl.moderated. Answer: nothing. 

]From: Russ Allbery <rra@stanford.edu>
]Date: 21 Sep 1998 19:53:43 -0700
]Subject: comp.lang.perl.moderated available via e-mail
]
]It is possible to subscribe to comp.lang.perl.moderated as a mailing list.
]To do so, send mail to majordomo@eyrie.org with "subscribe clpm" in the
]body.  Majordomo will then send you instructions on how to confirm your
]subscription.  This is provided as a general service for those people who
]cannot receive the newsgroup for whatever reason or who just prefer to
]receive messages via e-mail.

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

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