[17073] in Perl-Users-Digest

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

Perl-Users Digest, Issue: 4485 Volume: 9

daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Mon Oct 2 00:11:07 2000

Date: Sun, 1 Oct 2000 21:05:12 -0700 (PDT)
From: Perl-Users Digest <Perl-Users-Request@ruby.OCE.ORST.EDU>
To: Perl-Users@ruby.OCE.ORST.EDU (Perl-Users Digest)
Message-Id: <970459512-v9-i4485@ruby.oce.orst.edu>
Content-Type: text

Perl-Users Digest           Sun, 1 Oct 2000     Volume: 9 Number: 4485

Today's topics:
    Re: benefits of arrays over hashes(associative arrays)  <joehecht@code4sale.com>
    Re: benefits of arrays over hashes(associative arrays)  <godzilla@stomp.stomp.tokyo>
    Re: benefits of arrays over hashes(associative arrays)  <harrisr@bignet.net>
    Re: benefits of arrays over hashes(associative arrays)  (Logan Shaw)
    Re: benefits of arrays over hashes(associative arrays)  <godzilla@stomp.stomp.tokyo>
    Re: benefits of arrays over hashes(associative arrays)  <bmb@ginger.libs.uga.edu>
    Re: Comparing mod times with stat(); <flavell@mail.cern.ch>
    Re: die() ignores tied STDERR? <bmb@ginger.libs.uga.edu>
        Expect.pm May Do The Trick <jwestover@sprintmail.com>
        Extracting Specific information from a file <jbengard@chaincast.com>
    Re: Extracting Specific information from a file ebohlman@omsdev.com
    Re: Extracting Specific information from a file <godzilla@stomp.stomp.tokyo>
    Re: Extracting Specific information from a file <jbengard@chaincast.com>
    Re: File upload testing if it's there yorktown5425@my-deja.com
    Re: Files and things (Martien Verbruggen)
    Re: Files and things (Martien Verbruggen)
    Re: flocking while using the diamond operator? (Martien Verbruggen)
    Re: flocking while using the diamond operator? (Gwyn Judd)
        help with a d/l script for pdf files. <scottl@sympac.com.au>
    Re: help with a d/l script for pdf files. <tony_curtis32@yahoo.com>
    Re: How to detect modules currently in use? (Daniel Chetlin)
    Re: How to detect modules currently in use? (Martien Verbruggen)
    Re: Inserting HTML into CGI script as if it was beingin <bwalton@rochester.rr.com>
        Digest Administrivia (Last modified: 16 Sep 99) (Perl-Users-Digest Admin)

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

Date: Sun, 01 Oct 2000 22:26:02 GMT
From: "Joe C. Hecht" <joehecht@code4sale.com>
Subject: Re: benefits of arrays over hashes(associative arrays) and vice versa
Message-Id: <ZROB5.860$G15.205660@paloalto-snr1.gtei.net>

> Who should I believe? -- Larry Wall, Tom Christiansen and Jon Orwant or
> Godzilla!...

Godzilla! is more fun to read :)

ummm.... Godzilla! ummm....

Joe





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

Date: Sun, 01 Oct 2000 16:09:00 -0700
From: "Godzilla!" <godzilla@stomp.stomp.tokyo>
Subject: Re: benefits of arrays over hashes(associative arrays) and vice versa
Message-Id: <39D7C40C.B00A794E@stomp.stomp.tokyo>

Randy Harris wrote:

> Godzilla! wrote:
 
> > ¹  _Learning Perl_
> >    Schwartz, Randall L. and Christiansen, Tom
> >    O'Reilly & Associates
> >    July 1997 Second Edition
> >    ISBN: 1-56592-284-0
> >    page 66
 
> Mr. Schwartz spells his given name Randal (as do I).

 
It's an inside joke between Randall and myself.
Thank you playing newsgroup spell checker. Every
newsgroup needs someone to monitor spelling.


Godzilla!


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

Date: Sun, 1 Oct 2000 19:57:27 -0400
From: "Randy Harris" <harrisr@bignet.net>
Subject: Re: benefits of arrays over hashes(associative arrays) and vice versa
Message-Id: <stfjq2rqf8k958@corp.supernews.com>


Godzilla! <godzilla@stomp.stomp.tokyo> wrote in message
news:39D7C40C.B00A794E@stomp.stomp.tokyo...
> Randy Harris wrote:
>
> > Godzilla! wrote:
>
> > > ¹  _Learning Perl_
> > >    Schwartz, Randall L. and Christiansen, Tom
> > >    O'Reilly & Associates
> > >    July 1997 Second Edition
> > >    ISBN: 1-56592-284-0
> > >    page 66
>
> > Mr. Schwartz spells his given name Randal (as do I).
>
>
> It's an inside joke between Randall and myself.
> Thank you playing newsgroup spell checker. Every
> newsgroup needs someone to monitor spelling.
>
>
> Godzilla!

I don't monitor spelling.  I thought it a matter of courtesy, rather
than spelling.  If you prefer to incorrectly identify Randal, that is of
course, between you and he.

Randal (Randy) Harris





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

Date: 1 Oct 2000 19:08:36 -0500
From: logan@cs.utexas.edu (Logan Shaw)
Subject: Re: benefits of arrays over hashes(associative arrays) and vice versa
Message-Id: <8r8jm4$b37$1@provolone.cs.utexas.edu>

In article <39D7C40C.B00A794E@stomp.stomp.tokyo>,
Godzilla! <godzilla@stomp.stomp.tokyo> wrote:
>Randy Harris wrote:
>> Godzilla! wrote:
>> >    Schwartz, Randall L. and Christiansen, Tom
> 
>> Mr. Schwartz spells his given name Randal (as do I).
> 
>It's an inside joke between Randall and myself.

Randall?\?

  - Logan


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

Date: Sun, 01 Oct 2000 17:18:47 -0700
From: "Godzilla!" <godzilla@stomp.stomp.tokyo>
Subject: Re: benefits of arrays over hashes(associative arrays) and vice versa
Message-Id: <39D7D467.1BC3EB8C@stomp.stomp.tokyo>

Randy Harris wrote:
 
> Godzilla! wrote:
> > Randy Harris wrote:
> > > Godzilla! wrote:

> > > > ¹  _Learning Perl_
> > > >    Schwartz, Randall L. and Christiansen, Tom
> > > >    O'Reilly & Associates
> > > >    July 1997 Second Edition
> > > >    ISBN: 1-56592-284-0
> > > >    page 66

> > > Mr. Schwartz spells his given name Randal (as do I).

> > It's an inside joke between Randall and myself.
> > Thank you playing newsgroup spell checker. Every
> > newsgroup needs someone to monitor spelling.

> I don't monitor spelling.

Then how did you catch my spelling error?

> I thought it a matter of courtesy, rather
> than spelling.

Courtesy is very important. I have noted
everyone in all newsgroups are very polite
and well mannered. It is good to be courteous.

* wonders if the are-is battle will erupt again *


> If you prefer to incorrectly identify Randal,

Two things, very clear I have Randall correctly
identified. Don't know of any other with his
name writing books on Perl. Why is my misspelling
incorrect when I intentionally misspelled his
name? I correctly misspelled his name.

> that is of course, between you and he.

Isn't it though. Right about now he is smiling
despite my mildly annoying him. Naturally he,
nor others, will ever admit to my causing some
smiles and laughter around here. Techno-Geeksters
are not suppose to smile nor laugh. This is all
very serious business. I mean, like how could
they play snippet golf with all this noise and
rabble-rousement I am causing within this onlooking
crowd of snippet golf affec.. affection.. hmm..
affectionádos I guess. How do you spell that word?

Demagogue Godzilla!


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

Date: Sun, 1 Oct 2000 22:49:48 -0400
From: Brad Baxter <bmb@ginger.libs.uga.edu>
Subject: Re: benefits of arrays over hashes(associative arrays) and vice versa
Message-Id: <Pine.A41.4.21.0010012235370.16950-100000@ginger.libs.uga.edu>

On Mon, 2 Oct 2000, Cameron Elliott wrote:

> Can someone tell me which is better to use?
> I cant see the point of a hash except to store something by reference to a
> name which is possible to do through creative uses of arrays anyway.
> 
> Can someone please correct me if I am wrong (which is probable) and inform
> me of the advantages/disadvantages of each.
> 
> Thankyou
> 
> ps.  An array is faster to access isn't it?

Cameron,

You've gotten numerous answers by now.  I'd just like to add that for me,
two of the features of Perl that make it better than sliced bread are:

1. hashes
2. regular expressions

You appear to be in a position to soon discover this for yourself.

Happy coding,

Brad

ps: references are pretty damn wonderful, too.  That's because they open
the door to wondrous creations like arrays of hashes of arrays of hashes
of arrays.  This is magic, pure and simple.



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

Date: Mon, 2 Oct 2000 00:23:39 +0200
From: "Alan J. Flavell" <flavell@mail.cern.ch>
Subject: Re: Comparing mod times with stat();
Message-Id: <Pine.GHP.4.21.0010020007420.25515-100000@hpplus03.cern.ch>

On Sun, 1 Oct 2000, Dave A. wrote:

> : Nobody cares about your HTML/CGI problems in clpm.  So don't bring
> : them up.
 
> I'm sorry, When i leave this information out, someone complains
> that I didn't include it, When I post it, someone tells me it's
> not relavent.

Your problem in this regard is that as a beginner, you still haven't
worked out how the pieces fit together, and consequently you haven't
worked out what could be a vital piece of information, and what is so
far removed from your actual problem as to be irrelevant. That's
understandable for a beginner, but it's something you need to work on.

See, the regulars here are accustomed to people getting to know in
general terms how to approach programming problems and how to write
some simple code, long before they think of writing extensions to
their web server (which, in a sense, is what CGI is about).  So they
tend to lose patience with people who jumped into the deep end before
they'd learned to paddle in the shallow end first.  Cope with it, lurk
for a bit: you should find the pieces start falling into place.

You might be better off making the acquaintance of the
comp.infosystems.www.authoring.cgi group, and watching which kinds of
questions work out over there and which ones come off better here.

Let's take this case for example, it might help to illustrate a point.  
You were really just trying to compare a file stat with the current
time, and that's something that is meaningful in _any_ program, not
only in a CGI script.  So, prune your problem down to its essentials
(i.e in this case, something that you could run from a command line)
and solve _that_ problem - if you'd asked that as a question in its
own right, the hon. Usenaut wouldn't have bawled you out for confusing
the issue with HTML and CGI.  Once you've got the answer to that piece
of the jigsaw, then you're ready to fit it back into a bigger picture.

That's really just a habit of problem solving that it would be good to
get accustomed to.

Remember (because if you don't, the regulars are sure going to beat
you with a clue stick until you do) that Perl doesn't necessarily mean
CGI - and CGI doesn't necessarily mean Perl.

> I knew I was not doing this correctly, but nothing clicked
> (amateur i know, but still learning)

Everyone has to start somewhere.  Don't feel bad about that. As long
as you're keen to learn, there are people here keen to help, at all
levels of ability.

good luck



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

Date: Sun, 1 Oct 2000 22:55:31 -0400
From: Brad Baxter <bmb@ginger.libs.uga.edu>
Subject: Re: die() ignores tied STDERR?
Message-Id: <Pine.A41.4.21.0010012252570.16950-100000@ginger.libs.uga.edu>

On Sun, 1 Oct 2000, David Coppit wrote:

> I tied STDERR to a module in order to detect when something goes wrong
> in a CGI script. Unfortunately, die() doesn't seem to do "print
> STDERR". Below is a test script. Any suggestions, besides checking $?
> in addition to checking for output to STDERR?

David,

Without actually answering your question, have to looked into using the
following:

use CGI qw/:standard/;
use CGI::Carp 'fatalsToBrowser';

Brad



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

Date: Mon, 02 Oct 2000 01:32:35 GMT
From: "KDW" <jwestover@sprintmail.com>
Subject: Expect.pm May Do The Trick
Message-Id: <TARB5.3240$YY2.142832@newsread2.prod.itd.earthlink.net>

Thanks for your response.  I found expect.pm while doing some research on
the web. This seems to be a viable approach to dealing with Unix system
commands (passwd) that expect an interactive response from the terminal.

I suppose in my original message I should have said that I wanted to tackle
this issue using Perl instead of some other language......Which is why I
chose to post my question on this forum.........




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

Date: Sun, 1 Oct 2000 15:54:19 -0700
From: "James Bengard" <jbengard@chaincast.com>
Subject: Extracting Specific information from a file
Message-Id: <cfPB5.57$we4.108112@news.pacbell.net>

Im not sure if there is a simple response to this
but..

      Here is my situation

      I am pulling down an XML page to a text file, I need to be able to get
certain information from this text file.  I dont know if my brain has quit
working but I am stuck.

      The XML file comes down as one huge long line, no new lines no
nothing.

      This is a part of this large line:

      <?xml version="1.0"  encoding="ISO-8859-1"?><!DOCTYPE masterController
SYSTEM "/masterController.dtd"><masterController hostName="ccm-vns1"
numLocals="1"><localController hostName="ccm-vns1" numChains="16"><chain
chainID="19-2" broadcasting="yes" streamwidth="3645"><TRANSMITTER
NumChildren="10" NumPending="0" MaxChildren="26" NumFailures="0"
NodeId="123.654.987.177:80"><PLAYER NumChildren="0" NumPending="0"
MaxChildren="52" NumFailures="1" NodeId="123.456.789.65-172.16.5.72:8026
(behind firewall)"></PLAYER><REPEATER NumChildren="0" NumPending="0"
MaxChildren="54" NumFailures="0" NodeId="256.194.240.119:8005"></REPEATER>


      Basically this is the same informaiton along the entire document. with
new information everytime around...

      Now I am relativly new with perl, and I have pulled in files and got
information out if it when it was well lets say organized.
      So what I would like to pull from this information is either a file
that lists the following:


      19-2            #Represents ChainID
      TRANSMITTER 123.654.987.177:80  #IP Address of TRANSMITTER
      REPEATER 256.194.240.119:8005 #IP Address of REPEATER
      ANY help on this will be greatly appreciated.

      Thank you in advace










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

Date: 1 Oct 2000 23:23:27 GMT
From: ebohlman@omsdev.com
Subject: Re: Extracting Specific information from a file
Message-Id: <8r8h1f$18ce$2@news.enteract.com>

James Bengard <jbengard@chaincast.com> wrote:
> Im not sure if there is a simple response to this
                            ^^^^^^
> but..

There may well be.

>       Here is my situation

>       I am pulling down an XML page to a text file, I need to be able to get
> certain information from this text file.  I dont know if my brain has quit
> working but I am stuck.

>       The XML file comes down as one huge long line, no new lines no
> nothing.

>       This is a part of this large line:

>       <?xml version="1.0"  encoding="ISO-8859-1"?><!DOCTYPE masterController
> SYSTEM "/masterController.dtd"><masterController hostName="ccm-vns1"
> numLocals="1"><localController hostName="ccm-vns1" numChains="16"><chain
> chainID="19-2" broadcasting="yes" streamwidth="3645"><TRANSMITTER
> NumChildren="10" NumPending="0" MaxChildren="26" NumFailures="0"
> NodeId="123.654.987.177:80"><PLAYER NumChildren="0" NumPending="0"
> MaxChildren="52" NumFailures="1" NodeId="123.456.789.65-172.16.5.72:8026
> (behind firewall)"></PLAYER><REPEATER NumChildren="0" NumPending="0"
> MaxChildren="54" NumFailures="0" NodeId="256.194.240.119:8005"></REPEATER>


>       Basically this is the same informaiton along the entire document. with
> new information everytime around...

>       Now I am relativly new with perl, and I have pulled in files and got
> information out if it when it was well lets say organized.
>       So what I would like to pull from this information is either a file
> that lists the following:


>       19-2            #Represents ChainID
>       TRANSMITTER 123.654.987.177:80  #IP Address of TRANSMITTER
>       REPEATER 256.194.240.119:8005 #IP Address of REPEATER
>       ANY help on this will be greatly appreciated.

You'll definitely want to use an XML parser to read this information
rather than trying to hack it with regexes.  I'd suggest trying Grant
McLean's XML::Simple, which should be able to convert the whole thing into
an easily-accessible hash of hashes (when playing around with it, you'll
probably want to use Data::Dumper to print out the returned data structure
for inspection).



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

Date: Sun, 01 Oct 2000 16:38:02 -0700
From: "Godzilla!" <godzilla@stomp.stomp.tokyo>
Subject: Re: Extracting Specific information from a file
Message-Id: <39D7CADA.98BFDB7E@stomp.stomp.tokyo>

James Bengard wrote:

(snipped)
 
> The XML file comes down as one huge long line, no new lines no
> nothing.
 
> This is a part of this large line:

 
Accomplishing your goal is a piece of cake. Small handful
of code, it's done. However, there is a problem. Your 
data example is fake. Spaces are missing at the end of
lines causing critical words to run together. You have
at least one case of a word repeated twice and ran together
where it should be one word. You are missing /TRANSMITTER
in your data. 

I stopped looking at your data after noting so many errors.
Your data, as shown, is FUBAR. You cannot be extracting 
reliable data from this data example. Your data set example
is corrupt.


Godzilla!
-- 
Dr. Kiralynne Schilitubi ¦ Cooling Fan Specialist
UofD: University of Duh! ¦ ENIAC Hard Wiring Pro
BumScrew, South of Egypt ¦ HTML Programming Class


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

Date: Sun, 1 Oct 2000 19:51:00 -0700
From: "James Bengard" <jbengard@chaincast.com>
Subject: Re: Extracting Specific information from a file
Message-Id: <5JSB5.73$we4.168589@news.pacbell.net>

Im sorry that it came out that way on the screen, it actually does not come
out that way, as I explaind it was read in as one long line, that is just
the way it cut and pasted into the message.

Anyways, I was able to get it to break and be a more structured listing with
new lines so I can extract the data I need from it now.

@document = split (">", $document);

  # Save into local file
    open(LOCALFILE,">$localfile") || die "Cannot open the local file for
write\n";
    flock(LOCALFILE,2);
    foreach $line (@document)
    {
    print LOCALFILE "$line>\n" ;
     }

Since I am very new at this, I was happy to get it working.  I would like to
know if there is a better way to do what I just did without chomping the >
and then readding it.

Also, I would like to know some good ways of extracting the data I was
originally searching for

 <chain chainID="19-2" broadcasting="yes" streamwidth="3645">
<TRANSMITTER NumChildren="11" NumPending="0" MaxChildren="26"
NumFailures="0" NodeId="140.128.78.177:80">
<REPEATER NumChildren="0" NumPending="0" MaxChildren="54" NumFailures="0"
NodeId="123.154.230.124:8002">
</REPEATER>

This is how the whole file is now, but I want to get the chainID, the
Transmitter NodeID and the Repeater NodeID

Thank you.


"Godzilla!" <godzilla@stomp.stomp.tokyo> wrote in message
news:39D7CADA.98BFDB7E@stomp.stomp.tokyo...
> James Bengard wrote:
>
> (snipped)
>
> > The XML file comes down as one huge long line, no new lines no
> > nothing.
>
> > This is a part of this large line:
>
>
> Accomplishing your goal is a piece of cake. Small handful
> of code, it's done. However, there is a problem. Your
> data example is fake. Spaces are missing at the end of
> lines causing critical words to run together. You have
> at least one case of a word repeated twice and ran together
> where it should be one word. You are missing /TRANSMITTER
> in your data.
>
> I stopped looking at your data after noting so many errors.
> Your data, as shown, is FUBAR. You cannot be extracting
> reliable data from this data example. Your data set example
> is corrupt.
>
>
> Godzilla!
> --
> Dr. Kiralynne Schilitubi ¦ Cooling Fan Specialist
> UofD: University of Duh! ¦ ENIAC Hard Wiring Pro
> BumScrew, South of Egypt ¦ HTML Programming Class
>




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

Date: Mon, 02 Oct 2000 02:51:06 GMT
From: yorktown5425@my-deja.com
Subject: Re: File upload testing if it's there
Message-Id: <8r8t6o$n6e$1@nnrp1.deja.com>


> Nope. Fake email addresses are used to conceal.
> See my email address? Real as can be.

AFAIK - the email addresses I used are real.  I check them everyday, am
on several mailing lists with them.

> However, I routinely post my real email address
> and post links to my sites. People know who I am
> and where to reach me, as a real person. This is
> factual. Some people here mail bomb my address
> every so often or send threatening email from
> fake email addresses.

Given your attitude, I'm not surprised.  However; it certianly isn't
correct behavoir to mail bomb anyone.

> You are hiding just like all others who use
> fake email addresses. This is suspect.

again - the email address used is valid, & working. The problem you have
with it is your own, not mine.

> You are certainly not scoring any points with me.

Didn't realize I had to score points with you, will be careful of that
in the future.

> There existed no problem until you elected to

really?  Your first reply to me wasn't intended to belittle me or be
condescending? hmm will have to reread it I guess.

> flat out lie to me, claiming there is no fatal flaw
> in your code and, your code works. This is a lie.
> Additionally you claimed to have pasted those snippets
> directly from your script and, in subsequent articles,
> claimed to have made a typo during typing those snippets.

I did paste it, but there was a lot of code between the { & } which I
thought I would cull since they were not needed for the discussion, and
just added bloat to the message.  So I deleted the lines, and in doing
so accidently deleted the 'else'.  This is done in other newsgroup to
reduce the message size, and to remove distracting code from the post.
I mistyped it - oops
Your response was abosultly useless and rather venomous.  This was my
first post to this newsgroup, which I think was pretty clear. So a typo
might be expected, and certianly looking at the code a resonable person
would have figure it to be a typo (at least that's my experience in
other news groups).  Besides the typo had nothing to do with the
question I was asking.  But you simply decided to focus on that.  The
question was on the 'if' clause, which is valid - but I guess that
doesn't matter

> If you haven't realized this yet, I spotted you for
> a fake after a quick glance at your first article.
> You have not and will not pull wool over my eyes.
> Others yes, but not me. I am woman, not some ignorant
> knuckle dragging hairy backed slope browed flat toothed
> pea brained Neandertal sexist man, so commonly found
> in this newsgroup, just as you are found.

You can certianly believe you are a great and powerful person or woman.
But you've only proved to me that you are suffering from a serious
inferority complex and must try to make up for it by trying to
'virtually' abuse people in a news group. Such is the lot some people
play in life.

O well - I think both of us have spent enough time on this rather
dreadful thread.  I guess we will have to both walk away believing the
other to be a jackass.  In other words, we'll have to agree to disagree.

Have fun abusing your next victim.



Sent via Deja.com http://www.deja.com/
Before you buy.


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

Date: Mon, 2 Oct 2000 11:33:04 +1100
From: mgjv@tradingpost.com.au (Martien Verbruggen)
Subject: Re: Files and things
Message-Id: <slrn8tflu0.jr6.mgjv@martien.heliotrope.home>

On Sun, 01 Oct 2000 13:14:31 GMT,
	jon_uk@my-deja.com <jon_uk@my-deja.com> wrote:
> Hi,
> 
> I have 2 small problems.  I need to -
> 
> - Find out what size (in bytes) a folder is.  Basicly, I need to know
> the total size of /home/myname/cgi-bin (with the all the files etc).

I suppose you mean recursively
# perldoc File::Find
# perldoc -f stat

And you'll need quite some knowledge of file systems to get 'reliable'
numbers. And you'll have to think about why you want to know this: Do
you want to know the numbers of bytes contained in files and/or
directories, or do you want to know how much disk space is being used by
all this stuff? No, they are not necessarily the same. Then there's the
question of links and symlinks. You're looking at quite some
interesting code, to do it correctly.

> - How do I copy everything in a folder, to another area.  This is for
> backing up everything.  So I need to copy everything in /home/ to
> something like /home2/.

# perldoc -f opendir
# perldoc -f readdir
# perldoc -f closedir

In case you again meant recursively:
# perldoc File::Find

And to copy files:
# perldoc File::Copy

\begin{offtopic}

> Can anyone help?  I am on a Unix server if that helps.  Thanks,

Then why don't you use the standard tools that come with the OS? Perl
isn't the answer to everything, you know? Some answers have already been
given a long time ago:

$ man du

and for recursive copy:

$ man cp
(look for -r option)

And for backups, one of:

$ man tar
$ man dump
$ man cpio

or some others.

You have the right to write in directories other than your own, and you
didn't even know about these tools? You have rights like these, and you
call directories folders? Are you sure you don't want to hire a
sysadmin?

\end{offtopic}

Martien
-- 
Martien Verbruggen              | 
Interactive Media Division      | Think of the average person. Half of
Commercial Dynamics Pty. Ltd.   | the people out there are dumber.
NSW, Australia                  | 


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

Date: Mon, 2 Oct 2000 11:36:04 +1100
From: mgjv@tradingpost.com.au (Martien Verbruggen)
Subject: Re: Files and things
Message-Id: <slrn8tfm3k.jr6.mgjv@martien.heliotrope.home>

On Sun, 1 Oct 2000 19:56:00 +0100,
	CJ Llewellyn <darryl@work-thicker.co.uk> wrote:
> <jon_uk@my-deja.com> wrote in message news:8r7dbl$ke6$1@nnrp1.deja.com...
> > Hi,
> >
> > I have 2 small problems.  I need to -
> >
> > - Find out what size (in bytes) a folder is.  Basicly, I need to know
> > the total size of /home/myname/cgi-bin (with the all the files etc).
> 
> If your running an ftp server on your machine sitesize.sourceforge.net will
> help.

Sorry, but that is a silly answer. 

$ man du

No need for an FTP server. There would only be a need if you couldn't
actually execute anything on tha machine. And in that case, the question
would be meaningless.

Martien
-- 
Martien Verbruggen              | 
Interactive Media Division      | +++ Out of Cheese Error +++
Commercial Dynamics Pty. Ltd.   | Reinstall Universe and Reboot +++
NSW, Australia                  | 


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

Date: Mon, 2 Oct 2000 11:50:14 +1100
From: mgjv@tradingpost.com.au (Martien Verbruggen)
Subject: Re: flocking while using the diamond operator?
Message-Id: <slrn8tfmu6.jr6.mgjv@martien.heliotrope.home>

On Sun, 01 Oct 2000 16:37:52 GMT,
	Garry Williams <garry@ifr.zvolve.net> wrote:
> On Sun, 01 Oct 2000 15:37:59 GMT, tmdryden@my-deja.com
> <tmdryden@my-deja.com> wrote:
> 
> >My problem is not with flock'ing- locking a file opened with "open"
> >works great.  The problem is when I use the <> diamond operator to open
> >the file- I do not know how to lock the file in that situation.  No one
> >addresses this situation anywhere in the perl newsgroups, either.
> 
> You can't.  Process the @ARGV and open the file(s) explicitly.  

Well, that's not entirely true. You can lock the file that is currently
open (use the ARGV handle), and you can even keep track of whether
that's another one than the one you had a lock on already ($ARGV).
However, it is impossible to do it correctly and at the right time :).

Even if, with some trickery, you could find a way to get it done, it
wouldn't be worth it.  You'd end up with more and more complex code than
explicit opening and locking.

Martien
-- 
Martien Verbruggen              | 
Interactive Media Division      | That's funny, that plane's dustin'
Commercial Dynamics Pty. Ltd.   | crops where there ain't no crops.
NSW, Australia                  | 


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

Date: Mon, 02 Oct 2000 03:52:35 GMT
From: tjla@guvfybir.qlaqaf.bet (Gwyn Judd)
Subject: Re: flocking while using the diamond operator?
Message-Id: <slrn8tg1jv.7l0.tjla@thislove.dyndns.org>

I was shocked! How could Garry Williams <garry@ifr.zvolve.net>
say such a terrible thing:

>Did you try this?  

Whoops no :)

-- 
Gwyn Judd (print `echo 'tjla@guvfybir.qlaqaf.bet' | rot13`)
I want to so HAPPY, the VEINS in my neck STAND OUT!!


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

Date: Mon, 02 Oct 2000 14:01:49 -0700
From: Scott Laughton <scottl@sympac.com.au>
Subject: help with a d/l script for pdf files.
Message-Id: <39D8F7BD.F0C57818@sympac.com.au>

Hi there,

I am wanting to write a script that will hand a pdf (Adobe Acrobat
Reader) file to the browser to download.  When you click a normal link
to a pdf file on a computer that has Acrobat Reader installed it spawns
the Acrobat Reader and loads that into the browser and then loads the
pdf file into the Reader.

What I want to do is force the file to download and have the user save
the file where he wants instead of spawning the Acrobat Reader and
loading the file in there.

Is there some header I can send with the link to the file that I would
normally print to the location bar?

Thankyou for your time.

Scott Laughton.



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

Date: 01 Oct 2000 22:07:06 -0500
From: Tony Curtis <tony_curtis32@yahoo.com>
Subject: Re: help with a d/l script for pdf files.
Message-Id: <87lmw8rlet.fsf@limey.hpcc.uh.edu>

>> On Mon, 02 Oct 2000 14:01:49 -0700,
>> Scott Laughton <scottl@sympac.com.au> said:

> Is there some header I can send with the link to the
> file that I would normally print to the location bar?

Ooooh, this one again.

The answer is: no.

You cannot force the client software to do something like
this from the server-side.

hth
t
-- 
Namaste!
And an "oogabooga" to you too!
                                         -- Homer Simpson


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

Date: 1 Oct 2000 23:30:38 GMT
From: daniel@chetlin.com (Daniel Chetlin)
Subject: Re: How to detect modules currently in use?
Message-Id: <8r8heu0chf@news1.newsguy.com>

On Sun, 1 Oct 2000 14:49:08 -0300, Netcom <aphowe@netcom.ca> wrote:
>Is there any way to detect which are modules are currently in use at the
>moment? The idea is to do the following:
>
># a module which the used has asked for (parsed out of a template)
>$module = "CGI";
>
># get a list of modules which have already been imported via "use
>ModuleName;"
>@modulesCurrentlyInUse = ???
>
># import the module if it hasn't been already
>use $module unless (grep { $_ eq $module } @modulesCurrentlyInUse);

This is a good question. Problem well-phrased, making it clear what is
wanted. And it's also an example of something which is rather difficult
to find in the docs.

>From perlvar:

  =item %INC

  The hash %INC contains entries for each filename included via the
  C<do>, C<require>, or C<use> operators.  The key is the filename
  you specified (with module names converted to pathnames), and the
  value is the location of the file found.  The C<require>
  operator uses this hash to determine whether a particular file has
  already been included.

So for your use, first you'd want to translate the module into a
filename:

  ($filename = $module) =~ s[::][/]g;
  $filename .= '.pm';

And then confirm whether or not it's been loaded:

  require $filename unless exists $INC{$filename};

Also note that one cannot call C<use> in a conditional like you have
above. C<use> is equivalent to C<require> in a BEGIN block, followed by
calling the import function on the required module. If memory serves,
Ilya once submitted a patch to be able to use `use' conditionally like
that, but it never went through. As far as I'm concerned, it's better to
be clear about what you want to do. If you want the module loaded at
compile time and its import method called, as if it were used, do that:

  BEGIN {
      # Code to translate $module to $filename as above
      unless (exists $INC{$filename}) {
          require $filename;
          $module->import;
      }
  }

Otherwise simply call require.

-dlc


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

Date: Mon, 2 Oct 2000 12:01:02 +1100
From: mgjv@tradingpost.com.au (Martien Verbruggen)
Subject: Re: How to detect modules currently in use?
Message-Id: <slrn8tfnie.jr6.mgjv@martien.heliotrope.home>

On 1 Oct 2000 23:30:38 GMT,
	Daniel Chetlin <daniel@chetlin.com> wrote:
> On Sun, 1 Oct 2000 14:49:08 -0300, Netcom <aphowe@netcom.ca> wrote:
> >Is there any way to detect which are modules are currently in use at the
> >moment? The idea is to do the following:
[snip]
> ># import the module if it hasn't been already
> >use $module unless (grep { $_ eq $module } @modulesCurrentlyInUse);

[snip]

>   require $filename unless exists $INC{$filename};

I suspect you already know this, but just to make it clear to anyone
else reading this thread: require already does this checking for you.
There is no need to check whether a module is already loaded before
loading it. 

# perldoc -f require
[snip]
                   sub require {
                       my($filename) = @_;
                       return 1 if $INC{$filename};
[snip]

> Also note that one cannot call C<use> in a conditional like you have
> above. C<use> is equivalent to C<require> in a BEGIN block, followed by
> calling the import function on the required module.

Indeed. So use will never load a module twice either :)

> Otherwise simply call require.

That's what I'd do. Simply use or require the module wherever you need
it, and let perl worry about whether or not it has already been loaded.

Martien
-- 
Martien Verbruggen              | 
Interactive Media Division      | Little girls, like butterflies, need
Commercial Dynamics Pty. Ltd.   | no excuse - Lazarus Long
NSW, Australia                  | 


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

Date: Sun, 01 Oct 2000 22:07:08 GMT
From: Bob Walton <bwalton@rochester.rr.com>
Subject: Re: Inserting HTML into CGI script as if it was beinging #NCLUDEd via  SSI
Message-Id: <39D7B595.B05D85F1@rochester.rr.com>

Mick Beeby wrote:
> 
> I have a standard HTML file setup for my copyright notices and links
> footer that is inserted into all my HTML and ASP pages using a Server
> Side Include.
> 
> How can I open this file from within a CGI script and read the
> contents and write them to the browser screen as if the file had been
> #INCLUDEd using SSI.
> 
> I can simply use SSI within ASP pages but cannot do this from within a
> .cgi or .pl module.
> 
> I'd appreciate any replies cross-mailed to me at
> mick.beeby@mjb-is.co.uk
 ...
> Mick

Well, you can implement it any way you choose. All you have to do is
cram the appropriate text out to STDOUT.  One suggestion would be
something like (assuming you use CGI::Carp 'fatalsToBrowser';):

     $filename='whatever.html';
     open IN,$filename or die "Oops, $filename: $!\n";
     print <IN>;
     close IN;

-- 
Bob Walton


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

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

| NOTE: The mail to news gateway, and thus the ability to submit articles
| through this service to the newsgroup, has been removed. I do not have
| time to individually vet each article to make sure that someone isn't
| abusing the service, and I no longer have any desire to waste my time
| dealing with the campus admins when some fool complains to them about an
| article that has come through the gateway instead of complaining
| to the source.

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.

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 V9 Issue 4485
**************************************


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