[17468] in Perl-Users-Digest

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

Perl-Users Digest, Issue: 4888 Volume: 9

daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Tue Nov 14 18:06:29 2000

Date: Tue, 14 Nov 2000 15:05:16 -0800 (PST)
From: Perl-Users Digest <Perl-Users-Request@ruby.OCE.ORST.EDU>
To: Perl-Users@ruby.OCE.ORST.EDU (Perl-Users Digest)
Message-Id: <974243116-v9-i4888@ruby.oce.orst.edu>
Content-Type: text

Perl-Users Digest           Tue, 14 Nov 2000     Volume: 9 Number: 4888

Today's topics:
    Re: algorith help: combining similar lines (Adam Spragg)
    Re: Alternate solution to (split)[2..-1] problem <ken@forum.swarthmore.edu>
        beginner question regarding extracting email body with  (Debian User)
        Converting Troff to Jpeg <jeffahill@_ANTISPAM_.lucent.com>
        CPAN Modules <mesarch@ee.net>
    Re: CPAN Modules <elaine@chaos.wustl.edu>
    Re: CPAN Modules <jeff@vpservices.com>
    Re: Directory Size <adamf@box43.gnet.pl>
    Re: display shell alias in perl? <quantum_mechanic@my-deja.com>
        Document management question! <gary@dkstat.com>
    Re: Document management question! (Garry Williams)
    Re: Document management question! <greg2@surfaid.org>
    Re: Handling Postcode Ranges <lincmad001@telecom-digest.zzn.com>
        Hash referencing Problem (Misinterpreted Character) <seppy@chartermi.net>
    Re: Hash referencing Problem (Misinterpreted Character) <ren.maddox@tivoli.com>
    Re: Hash referencing Problem (Misinterpreted Character) (Garry Williams)
    Re: Hash referencing Problem (Misinterpreted Character) <newsposter@cthulhu.demon.nl>
        How to detect open port ?? <alex@-nospam-degekste.com>
    Re: How to detect open port ?? (Garry Williams)
    Re: HTML download form - CGI/Perl <jfeuerst@eecs.tufts.edu>
    Re: HTML download form - CGI/Perl <jboes@eomonitor.com>
    Re: Installing Perl mods from Perl CGI <jboes@eomonitor.com>
        Digest Administrivia (Last modified: 16 Sep 99) (Perl-Users-Digest Admin)

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

Date: 14 Nov 2000 20:45:50 GMT
From: atspragg@garbanzo.engr.ucdavis.edu (Adam Spragg)
Subject: Re: algorith help: combining similar lines
Message-Id: <8us89u$3s4$1@mark.ucdavis.edu>

Martien Verbruggen (mgjv@tradingpost.com.au) wrote:
: In other words, you should probably define what 'grouping' means.

: If all fields count (which your example seems to suggest), this is a

Right... I should have said that all fields counted.

: [1] See the entry for $; in perlvar for a description of
: multidimensional array emulation. Of course, you're free to do an
: explicit join or concatenation to generate the key for the hash.

Interesting!  Thanks for your help!

Adam


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

Date: Tue, 14 Nov 2000 15:57:53 -0600
From: Ken Williams <ken@forum.swarthmore.edu>
Subject: Re: Alternate solution to (split)[2..-1] problem
Message-Id: <141120001557536075%ken@forum.swarthmore.edu>

Ren Maddox <ren.maddox@tivoli.com> wrote:
>A few weeks ago there there was a thread regarding using the
>.. operator within an array index to allow it to DWIM when what I mean
>is to mix both positive and negative lookups.
>
>I'm not going to go into all of the problems mentioned in that thread,
>but one of the final results was that for arrays you could simply say
>@array[2..$#array].  The problem, of course, is that this only works
>for arrays and not for non-array lists such as the one in the subject.
>
>It occurred to me that a perhaps simple solution would be to provide
>some way to index the last element of a list.  The obvious solution
>presented itself: a bare "#".  It would only work within an index and
>would also refer to the list being indexed.  So the expression desired
>in the subject becomes:
>
>print (split)[2..#]

I like the goal, but I'm not crazy about the #.  I think it would be
nice to simply leave off the last subscript:

         print (split)[2..]

This would make slices with positive indexes analogous to regular
expression quantifiers:

    {n}    Match exactly n times
    {n,}   Match at least n times
    {n,m}  Match at least n but not more than m times

This doesn't address the problem of slices like @array[2..-3], but I
think it nicely handles the most common case.

I'm having a hard time imagining that this hasn't been proposed before
though, so perhaps some people (insightful people?) don't like it.

 -Ken


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

Date: Tue, 14 Nov 2000 20:40:48 +0000 (UTC)
From: damajah@kzahq.ath.cx (Debian User)
Subject: beginner question regarding extracting email body with regexp
Message-Id: <slrn9138qg.dmj.damajah@kzahq.ath.cx>

Hi, I am trying to learn perl by starting with a simple email client,
I can extract the From and Subject ok like this:

#!/usr/bin/perl

while (<STDIN>) {
	($from) = /^From: (.+)$/;
	($subject) = /^Subject: (.+)$/;

Then I try and get the body, which I can't do.  Now this program reads
standard mailbox format files, a single message at a time
from stdin, so I want to read from the first line following a line
where \n is the first character up till eof.

Heres what I tried but it doesn't work:
	
	($body) = split(/^\n/s, $_, 1);

I also tried this:

	($body) =~ m/^\n (.+)/s;

Please don't laugh, I am only learning :)

Thanks

Kurt



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

Date: Tue, 14 Nov 2000 15:52:41 -0600
From: Jeff H <jeffahill@_ANTISPAM_.lucent.com>
Subject: Converting Troff to Jpeg
Message-Id: <3A11B429.53EB2736@_ANTISPAM_.lucent.com>

Does anyone out there know of a Perl utility that would convert a Troff file
into a Jpeg image for web display?  The Jpeg part is not especially important,
it could be Gif or Png for all I care, as long as I can put it on a webpage.  

Jeff


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

Date: Tue, 14 Nov 2000 16:49:38 -0500
From: "Mike Mesarch" <mesarch@ee.net>
Subject: CPAN Modules
Message-Id: <8usc49$9r9$1@sshuraaa-i-1.production.compuserve.com>

If I have a given module name, say Mail::Sender for example.  How can I find
out what package this is in on CPAN?  If I do a seach on CPAN for mail I
only get the following:
Thanks!
-Mike

PPM> search mail
Packages available from
soap://www.activestate.com/cgibin/SOAP/ppmserver.plex?class=PPM::SOAPServer:
Mail-POP3Client [2.6 ] Perl 5 module to talk to a POP3 (RFC1081) server
MailTools       [1.15] Parse mail addresses




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

Date: Tue, 14 Nov 2000 21:58:30 GMT
From: "Elaine Ashton" <elaine@chaos.wustl.edu>
Subject: Re: CPAN Modules
Message-Id: <aAiQ5.14357$AM5.270468@news1.nokia.com>

"Mike Mesarch" <mesarch@ee.net> wrote in message
news:8usc49$9r9$1@sshuraaa-i-1.production.compuserve.com...
> If I have a given module name, say Mail::Sender for example.  How can I
find
> out what package this is in on CPAN?  If I do a seach on CPAN for mail I
> only get the following:
> PPM> search mail
> Packages available from
>
soap://www.activestate.com/cgibin/SOAP/ppmserver.plex?class=PPM::SOAPServe
r:

PPM is not CPAN, rather a repository of precompiled modules organised by
AS themselves. If you wish to search CPAN itself, you can try
http://search.cpan.org/ or http://kobesearch.cpan.org/ or use CPAN.pm.

http://search.cpan.org/search?dist=Mail-Sender

e.




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

Date: Tue, 14 Nov 2000 14:00:47 -0800
From: Jeff Zucker <jeff@vpservices.com>
Subject: Re: CPAN Modules
Message-Id: <3A11B60F.BD898889@vpservices.com>

Mike Mesarch wrote:
> 
> If I have a given module name, say Mail::Sender for example.  How can I find
> out what package this is in on CPAN?  If I do a seach on CPAN for mail I
> only get the following:
> 
> PPM> search mail

ppm searches ActiveState *NOT* CPAN.

That module is apparently not available on activeState.  To do the
equivalent search for it on CPAN, type this into your web browser:

   http://search.cpan.org/search?mode=module&query=Mail

To learn the difference between ppm accessible modules and CPAN modules
and the different ways of installing them, consult the ActiveState
documentation.

-- 
Jeff


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

Date: Tue, 14 Nov 2000 20:07:12 +0100
From: Adam <adamf@box43.gnet.pl>
Subject: Re: Directory Size
Message-Id: <3A118D60.6ED@box43.gnet.pl>

The Know Hunter wrote:
> 
> In article <29170-3A117A13-11@storefull-242.iap.bryant.webtv.net>,
> matt_daemon@webtv.net  wrote:
> 
> > How do I check the size of a directory before writing to it? Before I
> > write the new file(s) to a directory, I want to make sure that the new
> > [additional] file(s), won't make the directory exceed 5 Megs, and if
> > they do, I want the script to print a message, such as "directory is too
> > full to use."
> >
> > Thank You
> > -matt
> >
> 
> $dirname='/home/xpto/';
> while (<$dirname*>) {
>         $totsize+=-f $_;
                     ^
                     ^ i would use -s here ;)                     

> }
> if ($totsize > 5*2**20) {
>         print "directory full\n";
> } else {
>         #do anything!
> }

--
Adam.


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

Date: Tue, 14 Nov 2000 20:14:57 GMT
From: Quantum Mechanic <quantum_mechanic@my-deja.com>
Subject: Re: display shell alias in perl?
Message-Id: <8us6fo$jht$1@nnrp1.deja.com>

In article <8uqd9g$4mv$1@nnrp1.deja.com>,
  Quantum Mechanic <quantum_mechanic@my-deja.com> wrote:
> In article <V9XP5.388$xb1.21276@eagle.america.net>,
>   garry@zvolve.com wrote:
> > On 13 Nov 2000 18:21:05 +0000, nobull@mail.com <nobull@mail.com>
> wrote:
> > >"Philip Tsai" <tsailipu@home.com> writes:
> > >
> > >> This looks to be a simple operation yet I spent hours reading
> documentation
> > >> and searching using different combinations of keywords on
> www.perl.com,
> > >> google and other search engines to no avail:  how can one assign
> the value
> > >> of a shell "alias [some alias name]" inside a Perl program?
> > >
> > >You can't.
> > >
> > >This is covered by the FAQ: ...
> > >
> > >The aliases are part of the shell environment (although they are
not
> > >actually environment variables[1] so are not inherited by
subshells).
> >
> > Some shells allow you to "inherit" aliases by defining a variable
that
> > names a file that is sourced by each new-generation shell.  If you
> > place your alias commands and any other environment variable
settings
> > you require in this file, they will be set when the shell is
started.
> > In ksh it's ENV and in bash it's BASH_ENV.  Of course, this doesn't
> > help the original poster because perl invokes /bin/sh (on most Unix
> > systems) to implement qx//.
> >
> > The answer "You can't" is correct, of course.
> >
> > --
> > Garry Williams
> >
>
> Not being at my *nix box right now, I can't try this, but...
>
> In csh, can you pipe some alias settings to source to "activate" them?
>
> For instance,
>
>   my_alias_generating_perl_script | source
>
> Or does this not DWIW because source is now a subshell?
>
> Incidentally, I don't think it was all that clear whether the original
> poster was trying to *read* aliases already set, or *set* aliases to
be
> effective out in the parent shell once a script terminated. (We're all
> sure that they can't be *set* this way.)
>
> -QM
>
> --
> Quantum Mechanics: The dreams stuff is made of.
>
> Sent via Deja.com http://www.deja.com/
> Before you buy.
>

This works in csh:

  eval `perl -e 'print "alias xyz banner perl"'`

This works in ksh:

  eval `perl -e 'print "alias xyz=banner perl"'`

except I can't figure out the quote-quoting...;(

-QM
--
Quantum Mechanics: The dreams stuff is made of.


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


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

Date: Tue, 14 Nov 2000 12:25:10 -0800
From: Gary <gary@dkstat.com>
Subject: Document management question!
Message-Id: <3A119FA6.436DD432@dkstat.com>

Hello,

I work for a company that runs the following environment:

OS:                 Freebsd for Intel machines
Database:        Mysql
Languages:      Perl, C

We have a need to create a document management warehouse where
we can do the following:

1. take MS/word docs and save them to a database.
2. be able to search those docs for words/phases and display a list of
which documents
    contain the words/phrases.
3. Be able to view the word documents that contain the phrases/words
with a www/browser.
4. Be able to print the documents back out in MS/Word format.

An additional item is:

1. To be able to scan document into the Database (mysql).

I am basically looking for suggestions, maybe from someone who has done
something similar,
on what they found to be the best combination of tools/software to do
this.
We are open, with a limited budget, to paying for a bundled product that
would fit nicely into our
above mentioned environment.

Thanks for any ideas, thoughts on this question!

Gary Artim
Drogin, Kakigi and Associates
mailto:gary@dkstat.com



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

Date: Tue, 14 Nov 2000 20:46:15 GMT
From: garry@ifr.zvolve.net (Garry Williams)
Subject: Re: Document management question!
Message-Id: <rwhQ5.486$xb1.28908@eagle.america.net>

On Tue, 14 Nov 2000 12:25:10 -0800, Gary <gary@dkstat.com> wrote:
>...
>We have a need to create a document management warehouse where we can
>do the following:
>
>1. take MS/word docs and save them to a database.
>
>2. be able to search those docs for words/phases and display a list
>of which documents contain the words/phrases.
>
>3. Be able to view the word documents that contain the phrases/words
>with a www/browser.
>
>4. Be able to print the documents back out in MS/Word format.
>
>An additional item is:
>
>1. To be able to scan document into the Database (mysql).
>
>I am basically looking for suggestions, maybe from someone who has
>done something similar, on what they found to be the best combination
>of tools/software to do this.  We are open, with a limited budget, to
>paying for a bundled product that would fit nicely into our above
>mentioned environment.

>Thanks for any ideas, thoughts on this question!

I don't know what this has to do with Perl.  

You might want to take your problem to Xerox and look at their
DocuShare product.  It does all of the above and more "out of the
box".  

-- 
Garry Williams


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

Date: Tue, 14 Nov 2000 21:14:05 +0000
From: Greg Griffiths <greg2@surfaid.org>
Subject: Re: Document management question!
Message-Id: <3A11AB1D.4ED278A9@surfaid.org>

you could take a look at

OpenText Livelink http://www.opentext.com
Cardiff Software http://www.cardiff.com

although you could always do you own.

Gary wrote:

> Hello,
>
> I work for a company that runs the following environment:
>
> OS:                 Freebsd for Intel machines
> Database:        Mysql
> Languages:      Perl, C
>
> We have a need to create a document management warehouse where
> we can do the following:
>
> 1. take MS/word docs and save them to a database.
> 2. be able to search those docs for words/phases and display a list of
> which documents
>     contain the words/phrases.
> 3. Be able to view the word documents that contain the phrases/words
> with a www/browser.
> 4. Be able to print the documents back out in MS/Word format.
>
> An additional item is:
>
> 1. To be able to scan document into the Database (mysql).
>
> I am basically looking for suggestions, maybe from someone who has done
> something similar,
> on what they found to be the best combination of tools/software to do
> this.
> We are open, with a limited budget, to paying for a bundled product that
> would fit nicely into our
> above mentioned environment.
>
> Thanks for any ideas, thoughts on this question!
>
> Gary Artim
> Drogin, Kakigi and Associates
> mailto:gary@dkstat.com



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

Date: Fri, 10 Nov 2000 15:21:48 -0800
From: Linc Madison <lincmad001@telecom-digest.zzn.com>
Subject: Re: Handling Postcode Ranges
Message-Id: <101120001521483027%lincmad001@telecom-digest.zzn.com>

In article <3A0B7D08.E4F4FC4C@earthlink.net>, Andrew Lee
<andrew_lee@earthlink.net> wrote:

> Have you tried a DBM file tied to a hash?
> 
> Peter Sundstrom wrote:
> 
> > I'm looking for an efficient way of handling postcode ranges in reasonably
> > large files (20Mb).  I need to return a number of the postcode range
> > sequence.  For example:
> >
> > 0000-1000    return 1
> > 1001-2000    return 2
> > 2001-2500    return 3
> > ...
> >
> > The postcode ranges will vary depending on the file being processed, so I
> > need to initialise the postcode ranges from a configuration file.
> >
> > The postcodes will range from 0 to 9999.  I was thinking about initialising
> > a hash for the entire range, but it seems overkill to initialise 10,000
> > values.
> >
> > Suggestions on how to handle it will be greatfully accepted.

It also depends greatly on how complicated the mapping is. If you only
have maybe a dozen ranges, then your performance hit isn't going to be
too bad even if you do it as a sequence of if/elsif statements.

There are other things you can do, too. For instance, if the postcodes
are all (or nearly all) blocked by hundreds, you could do an array
indexed by (int ($code/100)), possibly with a few up-front special
cases (e.g., handle 3217 differently from other 32xx).

In any case, if you do a brute-force assignment, an array is a better
bet than a hash, since your keys are a filled sequence of integers.


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

Date: Tue, 14 Nov 2000 16:18:45 -0500
From: "Brian E. Seppanen" <seppy@chartermi.net>
Subject: Hash referencing Problem (Misinterpreted Character)
Message-Id: <3A11AC35.EBA34AC1@chartermi.net>

I'm very new to using perl, but I'm trying to construct a hash.  
Here's what I want.  I want my key to be an IP address, and the value
will be octets.
Here's what I have

@ip=`cat routerips`;
foreach (@ip) {
   chomp;
   $ip=$_;
   $octets=`snmpget $ip $community $oid | cut -f2 -d =`;
   $ip=%snmptable;
   $snmptable{$ip}=$octets;
   }


When I go to print out the data:

foreach $ip (keys(%snmptable)) {
   print "at $ip we have $snmptable{$ip}\n";
   }

Here's what I get:

at 0 we have  4080025071
at 1/8 we have  3287830498.

My understanding is that a hash can have any scalar value. So I'm
leaning thinking that the foreach statement is somehow converting the
data from scalar to numberic?  Is this correct?

Well any assistance appreciated.  Thanks.


 
Brian Seppanen
Regional Data Center
Charter Communications
Marquette, Michigan


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

Date: 14 Nov 2000 15:26:55 -0600
From: Ren Maddox <ren.maddox@tivoli.com>
Subject: Re: Hash referencing Problem (Misinterpreted Character)
Message-Id: <m3n1f2fdnk.fsf@dhcp11-177.support.tivoli.com>

"Brian E. Seppanen" <seppy@chartermi.net> writes:

> I'm very new to using perl, but I'm trying to construct a hash.  
> Here's what I want.  I want my key to be an IP address, and the value
> will be octets.
> Here's what I have
> 
> @ip=`cat routerips`;

If you change this to:

  chomp(@ip=`cat routertips`);

then you don't need that chomp below.  It doesn't really matter, just
telling you that you can do it this way.  In my mind it is cleaner
because chomp is really an IO type of thing, so putting it together
with the actual IO is just better.

> foreach (@ip) {
>    chomp;
>    $ip=$_;

If you want to use a named variable, then do so on the foreach line:

  foreach my $ip (@ip) {

Or, skip the named variable and just use $_ wherever you've used $ip.

>    $octets=`snmpget $ip $community $oid | cut -f2 -d =`;

Acknowledging that using the right tool for the right job is great,
as is code reuse, there is almost never a need to call the "cut"
program from within a Perl script.  Just use "split":

     my $octets = (split /=/, `snmpget $_ $community $oid`)[1];

Unless, that is, I am misinterpreting a step here.  Is snmpget
returning one line of output or multiple?  If just a single line, then
my advice applies.  If multiple lines, you can still certainly do it
within Perl, but you might not feel that it is worth it:

     my $octets = join "", map { (split /=/)[1] }
                               `snmpget $_ $community $oid`;

>    $ip=%snmptable;

HERE IS YOUR PROBLEM.

What is it you are trying to do with that line of code?  I think you
could simply delete the above line, and you would get the behavior you
want.  You are assigning to $ip the scalar value of %snmptable.  The
scalar value of a hash is a ratio of how many buckets are used versus
how many buckets exist (with the answer being 0 for empty hashes).
That explains the output below.

>    $snmptable{$ip}=$octets;

You could skip the $octets variable entirely and simply assign the
snmpget results directly to $snmptable{$_}.

[rest of code omitted as it looks basically fine]

> at 0 we have  4080025071
> at 1/8 we have  3287830498.
> 
> My understanding is that a hash can have any scalar value. So I'm
> leaning thinking that the foreach statement is somehow converting the
> data from scalar to numberic?  Is this correct?

I'm not sure what the octets are supposed to look like, so I'm not
sure if those are correct or not.  If they are correct, then the
deleting the spurious assignment of the hash to $ip above will take
care of it.  If the octets are not printing correctly, then I'm not
sure what the problem is.  I would need to see what either the input
or the expected output is.

-- 
Ren Maddox
ren@tivoli.com


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

Date: Tue, 14 Nov 2000 21:41:52 GMT
From: garry@ifr.zvolve.net (Garry Williams)
Subject: Re: Hash referencing Problem (Misinterpreted Character)
Message-Id: <AkiQ5.493$xb1.29054@eagle.america.net>

On Tue, 14 Nov 2000 16:18:45 -0500, Brian E. Seppanen
<seppy@chartermi.net> wrote:
>I'm very new to using perl, but I'm trying to construct a hash.
>Here's what I want.  I want my key to be an IP address, and the value
>will be octets.  Here's what I have

I'm going to assume that you really have started your script with: 

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

>@ip=`cat routerips`;
>foreach (@ip) {
>   chomp;
>   $ip=$_;

Why not say 

  foreach $ip ( @ip ) {

in the first place.  Then you don't have to copy the contents of $_ to
$ip.  

>   $octets=`snmpget $ip $community $oid | cut -f2 -d =`;

I guess I have to assume that you have code to set the value of
$community and $oid before you get here

>   $ip=%snmptable;

Here's your problem.  Why are you destroying the value in $ip when you
want to use it for your key in the very next statement?  Delete this
line.  

-- 
Garry Williams


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

Date: 14 Nov 2000 21:53:12 GMT
From: Erik van Roode <newsposter@cthulhu.demon.nl>
Subject: Re: Hash referencing Problem (Misinterpreted Character)
Message-Id: <8usc88$8ii$2@internal-news.uu.net>

Brian E. Seppanen <seppy@chartermi.net> wrote:

> @ip=`cat routerips`;
> foreach (@ip) {
>    chomp;
>    $ip=$_;
>    $octets=`snmpget $ip $community $oid | cut -f2 -d =`;
>    $ip=%snmptable;

  What is the preceding line supposed to do?

  From the perldata manual page:
    If you evaluate a hash in a scalar context, it returns a
    value that is true if and only if the hash contains any
    key/value pairs.  (If there are any key/value pairs, the
    value returned is a string consisting of the number of used
    buckets and the number of allocated buckets, separated by a
    slash.  This is pretty much useful only to find out whether
    Perl's (compiled in) hashing algorithm is performing poorly
    on your data set.

Don't you just want to use the value that was assigned to $ip a
few lines earlier?

>    $snmptable{$ip}=$octets;
>    }

Erik



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

Date: Tue, 14 Nov 2000 19:30:27 GMT
From: "Alex" <alex@-nospam-degekste.com>
Subject: How to detect open port ??
Message-Id: <npgQ5.55734$fO2.350271@dbsch1.home.nl>

Hi,

I want to check if a certain port on a remote machine is open. ie if the
lp daemon is running on a system (unix/nt). How do I do that using perl
without nmap or rsh's ??

Thanks





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

Date: Tue, 14 Nov 2000 20:20:40 GMT
From: garry@ifr.zvolve.net (Garry Williams)
Subject: Re: How to detect open port ??
Message-Id: <s8hQ5.485$xb1.28804@eagle.america.net>

On Tue, 14 Nov 2000 19:30:27 GMT, Alex <alex@-nospam-degekste.com> wrote:
>Hi,
>
>I want to check if a certain port on a remote machine is open. ie if the
>lp daemon is running on a system (unix/nt). How do I do that using perl
>without nmap or rsh's ??

Maybe the answer to that would be clear, if you pondered how to do it
using C or Java or ...

You could connect to the service and declare it "alive", if that was
successful.  

See the perlipc manual page ("Sockets: Client/Server Communication")
and the in.lpd manual page.  

-- 
Garry Williams


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

Date: Tue, 14 Nov 2000 19:35:23 GMT
From: Jozxyqk <jfeuerst@eecs.tufts.edu>
Subject: Re: HTML download form - CGI/Perl
Message-Id: <%tgQ5.7215$M51.1504067@typhoon.ne.mediaone.net>

> use CGI qw/:all/;
> print "Content-type: application/x-zip-compressed\n\n";
> open (IN, "c:\\setups\\server stuff\\tinyweb web server.zip") or print
> "can't open music file\n";

binmode(IN);

> while (sysread IN, $store, 512) {
> 	print $store;
> 	}
> close IN;



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

Date: Tue, 14 Nov 2000 15:04:04 -0500
From: Jeff Boes <jboes@eomonitor.com>
Subject: Re: HTML download form - CGI/Perl
Message-Id: <3a119c19$0$30003$44a10c7e@news.net-link.net>

dionysus wrote:
> 
> Problem 1 (major). - if I use this, the client is prompted to download
> a file. Great. But, when they do go to download the file, they recieve
> around 200bytes of data. Opening the destination file in Notepad
> reveals that they received the same few bytes that are displayed on
> the screen if you attempt type "more tinywe~1.zip" at the dos prompt,
> where "tiny web server.zip" was the 72Kb file I was using for the
> test. I assume that is because sysread() is reading the file in the
> same (text-oriented?) way that more reads files...(as more will read
> the entirity of any text file I parse it, but only the first few lines
> of any binary file)....

I think this will go away if you look back at the posted example, and
use binmode() on both the output AND the input file handles. 

perldoc -f binmode

will tell you that "... binmode() is not only important for readline()
and print() operations, but also when using read(),              
seek(), sysread(), syswrite() and tell() (see the perlport manpage for
more details)."

> Problem 2 (minor). - when the user is prompted to download the file,
> the default filename is not "tiny web server.zip" or "tinywe~1.zip",
> but "ftest.zip" - where ftest.pl is the name of the perl/cgi
> script....

Hmm... I'm pretty sure this is browser-dependent, not a function of your
script. Perhaps you need to check a CGI group, and ask specific
questions regarding the brand of browser you are using?

> use strict;
> use warnings;
> use CGI qw/:all/;
> open(IN, "< c:\\setups\\server stuff\\tinyweb web server.zip")
>         or die "Can't open infile: $!";

  binmode IN;

> my @info = stat(IN);
> my $length = $info[7];
> my $blksize = $info[11] || 16384;

  binmode STDOUT;

> print "Content-type: application/x-zip-compressed\n\n";
> my $buffer;
> while (!eof(IN)) {
>     read(IN, $buffer, $blksize);
>     print $buffer;
> }
> close IN;
> exit 0;

-- 
Jeff Boes <jboes@eoexchange.com>          Tel:  (616) 381-9889 x.18
Sr. Software Engineer, EoExchange, Inc.   http://www.eoexchange.com/
Search, Monitor, Notify.                  http://www.eomonitor.com/


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

Date: Tue, 14 Nov 2000 15:08:31 -0500
From: Jeff Boes <jboes@eomonitor.com>
Subject: Re: Installing Perl mods from Perl CGI
Message-Id: <3a119c1a$0$30003$44a10c7e@news.net-link.net>

zfer@my-deja.com wrote:

> I suppose that I can install my favourite Perl modules in my directory
> and in someway require them from future CGI.

perldoc -q 'my own' library

perldoc -f use

perldoc -q install CPAN


-- 
Jeff Boes <jboes@eoexchange.com>          Tel:  (616) 381-9889 x.18
Sr. Software Engineer, EoExchange, Inc.   http://www.eoexchange.com/
Search, Monitor, Notify.                  http://www.eomonitor.com/


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

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


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