[13966] in Perl-Users-Digest

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

Perl-Users Digest, Issue: 1376 Volume: 9

daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Sun Nov 14 18:05:48 1999

Date: Sun, 14 Nov 1999 15:05:15 -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: <942620714-v9-i1376@ruby.oce.orst.edu>
Content-Type: text

Perl-Users Digest           Sun, 14 Nov 1999     Volume: 9 Number: 1376

Today's topics:
        Header types for HTML plus GIF mmclaug@my-deja.com
    Re: Header types for HTML plus GIF <lr@hpl.hp.com>
    Re: Header types for HTML plus GIF (David Efflandt)
    Re: Header types for HTML plus GIF (Brett W. McCoy)
        Hebrew HTML Clever Converter olkina@my-deja.com
        Help with file writing <expoinfo@globalexpos.co.nz>
    Re: Help with file writing <seshadri9@worldnet.att.net>
    Re: Help with Stoopid Nutscrape (Netscape) <expoinfo@globalexpos.co.nz>
    Re: how can i ask outlook express to download the email <jeff@vpservices.com>
    Re: how can i ask outlook express to download the email <nima.m@lyckseleNOSPAM.net>
    Re: how can i ask outlook express to download the email (David Efflandt)
    Re: how to create a random id? (Peter Scott)
        Mail::Mailer smtp module not working? <Mark.Johnson@InfoHarvest.ab.ca>
    Re: more bad header <chris@chrismail.connectfree.co.uk>
    Re: more bad header (David Efflandt)
        Output from exec "file"; rach55@my-deja.com
    Re: parsing (David Efflandt)
    Re: Perl and commonsense part 2 <uri@sysarch.com>
    Re: perl as first language? <ritchie@fnal.gov>
    Re: Perl forgot 3 lines of the script (Brett W. McCoy)
    Re: Perl forgot 3 lines of the script <andrewperrin@netscape.net>
    Re: Perl forgot 3 lines of the script (Brett W. McCoy)
    Re: Perl forgot 3 lines of the script <lr@hpl.hp.com>
        PERL-Terminal <matthschulzantispam@gmx.net>
        Rand Number without the decimals!! <expoinfo@globalexpos.co.nz>
    Re: Rand Number without the decimals!! <lr@hpl.hp.com>
    Re: Rand Number without the decimals!! (Martien Verbruggen)
    Re: Rand Number without the decimals!! (David Efflandt)
    Re: RE : DBD::Pg table attributes. reference to array o <rick.delaney@home.com>
        Digest Administrivia (Last modified: 16 Sep 99) (Perl-Users-Digest Admin)

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

Date: Sun, 14 Nov 1999 19:14:17 GMT
From: mmclaug@my-deja.com
Subject: Header types for HTML plus GIF
Message-Id: <80n1m7$k72$1@nnrp1.deja.com>

I know that if I want to print out a standard HTML page using a perl CGI
script, I need to use:

Content-type: text/html

for the header.
But what if I have a GIF image somewhere in the HTML? How can I display
the image *and* the HTML?
In other words, why doesn't this sample code display the image?

================
#! /usr/bin/perl -w

print "Content-type: text/html\n\n";
print <<TheEnd;
<html>
<body>
<p>
This is a test file showing text and an image<br>
<img src="test.GIF"></img>
</p>
</body>
</html>
TheEnd
===============

It doesn't display the GIF image successfully.
I know the MIME type for GIF is Content-type: image/gif  ... how can I
introduce it into my script?

Thanks for your help.
Michael


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


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

Date: Sun, 14 Nov 1999 13:47:14 -0800
From: Larry Rosler <lr@hpl.hp.com>
Subject: Re: Header types for HTML plus GIF
Message-Id: <MPG.1298cdbd2e120ef198a1ff@nntp.hpl.hp.com>

In article <80n1m7$k72$1@nnrp1.deja.com> on Sun, 14 Nov 1999 19:14:17 
GMT, mmclaug@my-deja.com <mmclaug@my-deja.com> says...
+ I know that if I want to print out a standard HTML page using a perl
+ CGI script, I need to use:
+ 
+ Content-type: text/html
+ 
+ for the header.
+ But what if I have a GIF image somewhere in the HTML? How can I
+ display the image *and* the HTML?
+ In other words, why doesn't this sample code display the image?
+ 
+ ================
+ #! /usr/bin/perl -w
+ 
+ print "Content-type: text/html\n\n";
+ print <<TheEnd;
+ <html>
+ <body>
+ <p>
+ This is a test file showing text and an image<br>
+ <img src="test.GIF"></img>
+ </p>
+ </body>
+ </html>
+ TheEnd
+ ===============
+ 
+ It doesn't display the GIF image successfully.
+ I know the MIME type for GIF is Content-type: image/gif  ... how can I
+ introduce it into my script?

The same way as if you were using any programming language beside Perl 
to generate the HTML dynamically via CGI, or using a static HTML file:  
you can't.  That has nothing to do with this newsgroup.

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


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

Date: 14 Nov 1999 21:58:24 GMT
From: efflandt@xnet.com (David Efflandt)
Subject: Re: Header types for HTML plus GIF
Message-Id: <slrn82uc3v.ll.efflandt@efflandt.xnet.com>

On Sun, 14 Nov 1999 19:14:17 GMT, mmclaug@my-deja.com
<mmclaug@my-deja.com> wrote:
>I know that if I want to print out a standard HTML page using a perl CGI
>script, I need to use:
>
>Content-type: text/html
>
>for the header.
>But what if I have a GIF image somewhere in the HTML? How can I display
>the image *and* the HTML?
>In other words, why doesn't this sample code display the image?
>
>================
>#! /usr/bin/perl -w
>
>print "Content-type: text/html\n\n";
>print <<TheEnd;
><html>
><body>
><p>
>This is a test file showing text and an image<br>
><img src="test.GIF"></img>
></p>
></body>
></html>
>TheEnd
>===============
>
>It doesn't display the GIF image successfully.
>I know the MIME type for GIF is Content-type: image/gif  ... how can I
>introduce it into my script?

Wrong newsgroup (should be cgi newsgroup).  It should work, except I never
heard of '</img>' tag (remove it).  Is it really 'test.GIF' or is it
'test.gif' (the OS may be case sensitive)?  Does the same URL ending with
text.GIF instead of the script name work?  If not, you need to figure that
out first.  For example if it is a cgi-bin, the server may be trying to
execute the GIF.

-- 
David Efflandt  efflandt@xnet.com  http://www.xnet.com/~efflandt/
http://www.de-srv.com/  http://cgi-help.virtualave.net/
http://thunder.prohosting.com/~cv-elgin/


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

Date: Sun, 14 Nov 1999 22:55:33 GMT
From: bmccoy@news.lan2wan.com (Brett W. McCoy)
Subject: Re: Header types for HTML plus GIF
Message-Id: <slrn82uftu.m51.bmccoy@dragosani.lan2wan.com>

Also sprach mmclaug@my-deja.com <mmclaug@my-deja.com>:

>================
>#! /usr/bin/perl -w
>
>print "Content-type: text/html\n\n";
>print <<TheEnd;
><html>
><body>
><p>
>This is a test file showing text and an image<br>
><img src="test.GIF"></img>
></p>
></body>
></html>
>TheEnd
>===============

First of all, you should be using 'use strict'.  Second of all, you'll
find life much easier if you use Lincoln Stein's CGI.pm -- no need for
heredocs and trying to keep brackets and tags matched up.  It let's you
focus on the logic of your program rather than the syntax of HTML.

-- 
Brett W. McCoy           
                                        http://www.lan2wan.com/~bmccoy/
-----------------------------------------------------------------------
Silence is the element in which great things fashion themselves.
		-- Thomas Carlyle


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

Date: Sun, 14 Nov 1999 17:10:29 GMT
From: olkina@my-deja.com
Subject: Hebrew HTML Clever Converter
Message-Id: <80mqe4$fi5$1@nnrp1.deja.com>

Looking for clever Perl or Java engine that can convert Hebrew texts
into HTML-logical files.


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


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

Date: Mon, 15 Nov 1999 10:43:24 +1300
From: Andrew Broadley <expoinfo@globalexpos.co.nz>
Subject: Help with file writing
Message-Id: <382F2CFC.40841ECB@globalexpos.co.nz>

Hi,

My script makes the file...

but on my local machine it works.. and writes fine into the file

but when its on a remote server (unix) it creates the file.. but does
not write to it!!

any ideas ?

--
<x-rich>Thanks,


Andrew Broadley

Information Technology

GLOBAL EXPOS (NZ) LIMITED


http://www.globalexpos.co.nz

<italic>"Better business using the power of the Internet

and the face-to-face advantage of exhibitions"

</italic>

E-mail me on my cellphone:

0212956648@messagetracker.co.nz

           (max <bold>146</bold> characters)


</x-rich>




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

Date: Sun, 14 Nov 1999 17:23:40 -0800
From: Seshadri Sriperumbudur <seshadri9@worldnet.att.net>
Subject: Re: Help with file writing
Message-Id: <382F609C.6B9051B5@worldnet.att.net>



Andrew Broadley wrote:

> Hi,
>
> My script makes the file...
>
> but on my local machine it works.. and writes fine into the file

> but when its on a remote server (unix) it creates the file.. but does
> not write to it!!
>

What's this? Is this a CGI question? Or a perl question... what IS it?

>
> any ideas ?
>
> E-mail me on my cellphone:
>
> 0212956648@messagetracker.co.nz
>
>

Oh yeah, sure!



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

Date: Mon, 15 Nov 1999 09:41:35 +1300
From: Andrew Broadley <expoinfo@globalexpos.co.nz>
Subject: Re: Help with Stoopid Nutscrape (Netscape)
Message-Id: <382F1E7F.8DAB1C30@globalexpos.co.nz>

Too true bout netscape, it does tighten up my lazy coding :o) best HTML
debugger I ever met :o)

Bart Lateur wrote:

> Andrew Broadley wrote:
>
> >HTML is fine, ive been doing html longer than perl, but I believe its a
> >fault with the perl script I've done. I still dont understand why you need
> >to put Context type: text/standard in (even though it is in there)
>
> >> > When i print out on my perl script... IE is fine.. but Netscape only
> >> > prints the HTML code... why is that ?
>
> Actually, it's the reverse: NEtscape is fine, but IE ignores the
> content-type header, and examines the content. Even if you did
>
>         print "Content-type: text/plain\n\n";
>
> and then output your HTML, IE would still show it as a web page, not as
> plain text as requested.
>
> Sorry for the non-Perl related content, but I hate it when people
> unrightfully say that "IE is fine, but Netscape screws up." We don't
> want to encourage Microsoft to go further down this horrendous road.
>
> --
>         Bart.

--
<x-rich>Thanks,


Andrew Broadley

Information Technology

GLOBAL EXPOS (NZ) LIMITED


http://www.globalexpos.co.nz

<italic>"Better business using the power of the Internet

and the face-to-face advantage of exhibitions"

</italic>

E-mail me on my cellphone:

0212956648@messagetracker.co.nz

           (max <bold>146</bold> characters)


</x-rich>




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

Date: 14 Nov 1999 18:29:59 GMT
From: Jeff Zucker <jeff@vpservices.com>
Subject: Re: how can i ask outlook express to download the email?
Message-Id: <382EFF5F.5AF338E9@vpservices.com>

geofox wrote:
 
> how can i ask outlook express to download the email?

Since you asked this in a Perl newsgroup, I will give you a Perl answer:

$you->get_on_knees();
$you->voice_mode('humble');
$you->ask_outlook(q/
    Pretty, pretty please with sugar on top,
    download my email.
/);

Also, I find it helps not to ask outlook express too many questions
before noon, it tends to sleep late.

-- 
Jeff


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

Date: Sun, 14 Nov 1999 22:30:25 +0100
From: "Nima Mortazavi" <nima.m@lyckseleNOSPAM.net>
Subject: Re: how can i ask outlook express to download the email?
Message-Id: <80n9m0$iu$1@zingo.tninet.se>

That was god :-)


Jeff Zucker <jeff@vpservices.com> wrote in message
news:382EFF5F.5AF338E9@vpservices.com...
> geofox wrote:
>
> > how can i ask outlook express to download the email?
>
> Since you asked this in a Perl newsgroup, I will give you a Perl answer:
>
> $you->get_on_knees();
> $you->voice_mode('humble');
> $you->ask_outlook(q/
>     Pretty, pretty please with sugar on top,
>     download my email.
> /);
>
> Also, I find it helps not to ask outlook express too many questions
> before noon, it tends to sleep late.
>
> --
> Jeff




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

Date: 14 Nov 1999 22:10:44 GMT
From: efflandt@xnet.com (David Efflandt)
Subject: Re: how can i ask outlook express to download the email?
Message-Id: <slrn82ucr2.ll.efflandt@efflandt.xnet.com>

On Sun, 14 Nov 1999 05:43:04 +0800, geofox <geofox@softhome.net> wrote:
>Hi,
>I have moved the email in /var/spool/mail
>to $HOME/mailbox by procmail but
>i can't download the email from RedHat 6 now????
>
>How can I ask outlook express to download the email
>in $HOME/mailbox?
>Other setting i need to setup in .procmailrc?!

What does that have to do with Perl?  Two choices:
1. Reconfigure &| recompile SMTP and POP3 servers to use the new location.
2. Put the mail back where you got it from.

-- 
David Efflandt  efflandt@xnet.com  http://www.xnet.com/~efflandt/
http://www.de-srv.com/  http://cgi-help.virtualave.net/
http://thunder.prohosting.com/~cv-elgin/


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

Date: 14 Nov 1999 21:52:28 GMT
From: psl@euclid.jpl.nasa.gov (Peter Scott)
Subject: Re: how to create a random id?
Message-Id: <80naus$3em@netline.jpl.nasa.gov>

In article <slrn82o6sl.lmh.abigail@alexandra.delanet.com>, abigail@delanet.com (Abigail) writes:
> '' I want to generate in perl a random id like e3479b76955is5349
> '' How can I make it? 
>  
> Use quantum effects.
> 
>     # Y2K compliant!
>     use Physics::Mechanics::Quantum;
> 
>     $id = '=' x 17;

Did Hawking ever fix the bug in that module that was causing
mini black holes to be created because they got the number of
rolled-up dimensions wrong?  (Who can blame them, I mean one
week it's 7 another it's 11, some days it's 22...)

-- 
This is news.  This is your      |  Peter Scott
brain on news.  Any questions?   |  (psl@euclid.jpl.nasa.gov)

Disclaimer:  These comments are the personal opinions of the author, and 
have not been adopted, authorized, ratified, or approved by JPL.


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

Date: Sun, 14 Nov 1999 12:02:27 -0700
From: Mark Johnson <Mark.Johnson@InfoHarvest.ab.ca>
Subject: Mail::Mailer smtp module not working?
Message-Id: <382F0743.CE203842@InfoHarvest.ab.ca>

I'm using Mail::Mailer to prepare and send messages.  Since this
application will likely run on a Windows NT machine, I thought it
best to use SMTP as a mailer.  Unfortunately, the messages are
not sent, and sendmail reports an unexpected close:

Nov 13 19:20:53 www sendmail[3267]: TAA03267: collect: unexpected close
on conne
ction from hart.infoharvest.ab.ca,
sender=<infoharv@hart.infoharvest.ab.ca>: Err
or 0

Here's the code I'm testing:

#!/usr/bin/perl

use Mail::Mailer;

$mailer = new Mail::Mailer 'smtp', Server => 'www.infoharvest.ca';

%header = ( From     => 'Mark.Johnson@InfoHarvest.ca',
            To       => 'mark@www.infoharvest.ab.ca',
            Subject  => 'Testing the emailer' );

$mailer->open(\%header) or die $!;
print $mailer <<EndofMail;
This mail was sent from Perl.

EndofMail
$mailer->close;

-- 
mailto:Mark.Johnson@InfoHarvest.ca
InfoHarvest Inc., Edmonton              http://www.infoharvest.ca/


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

Date: Sun, 14 Nov 1999 17:40:49 -0000
From: "Chris" <chris@chrismail.connectfree.co.uk>
Subject: Re: more bad header
Message-Id: <382f0227.0@news2.cluster1.telinco.net>

It hasn't worked!

--
Chris
chris@chrismail.connectfree.co.uk
www.bl-soft.com/chrissite




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

Date: 14 Nov 1999 22:21:54 GMT
From: efflandt@xnet.com (David Efflandt)
Subject: Re: more bad header
Message-Id: <slrn82udg1.ll.efflandt@efflandt.xnet.com>

On Sun, 14 Nov 1999 10:12:44 GMT, Michel Dalle <michel.dalle@usa.net> wrote:
>In article <382e88ff.0@news2.cluster1.telinco.net>, "Chris" <chris@chrismail.connectfree.co.uk> wrote:
>>I'm still getting told bad header = :
>>http://blsoftpart.hypermart.net/sign_up.pl/forward.pl (depending on which
>>file I open and I've checked with hypermart and the #!usr/local/bin/perl is
>>the right path)
>[snip]
>
>Have you tried adding
>        use CGI::Carp qw(fatalsToBrowser);
>in your script ?

Even that won't work if Chris forgot to ftp upload in ASCII mode.
Apparently Chris did not read my earlier post in one of the multiple 
newgroups posted to about this earlier.

>Your script is probably dying somewhere...

Righto, looking for 'perl^M'.

>Of course, your forward.pl script doesn't seem to generate HTTP headers at
>all, so that may be a problem too. Why don't you try them out locally before
>posting them to your remote website ?
>
>And you don't need to flock EVERY file you open - only the ones that you
>want to update.

Actually it is better to be safe than sorry.  I have had scripts go into
endless loops when more than one instance fight over the file pointer just
reading a file (solaris).

-- 
David Efflandt  efflandt@xnet.com  http://www.xnet.com/~efflandt/
http://www.de-srv.com/  http://cgi-help.virtualave.net/
http://thunder.prohosting.com/~cv-elgin/


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

Date: Sun, 14 Nov 1999 20:51:48 GMT
From: rach55@my-deja.com
Subject: Output from exec "file";
Message-Id: <80n7d4$o56$1@nnrp1.deja.com>

I have a specific, but basic, problem.

I have a parent program that is called via web and that, depending on
inputs, runs an 'exec' on another file.  But, everything that I output
with a 'print "info"' does not come out on the browser, even though it
does come out when I access it via command prompt.  So, I'm guessing
that when I call a subprogram, it doesn't know where to output the
'print' statements.

One way out of this would be to output to a file, and then print the
file in the parent program after a 'system' call, but I'd rather not do
that.

Any solutions?

Thanks a bunch.

Novice Perl Programmer


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


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

Date: 14 Nov 1999 22:28:54 GMT
From: efflandt@xnet.com (David Efflandt)
Subject: Re: parsing
Message-Id: <slrn82udt6.ll.efflandt@efflandt.xnet.com>

On Sun, 14 Nov 1999 10:24:51 -0000, marcus armand <marcus@a-net.co.uk> wrote:
>have a script that queries a database on a remote server.
>The results are returned as text names and addresses (a long and useless
>list) followed by a list of hyperlinks. These are currently displayed on the
>screen in a very unuserfriendly manner.
>
>I need build my own hmtl document from this automaticaaly on-line.
>I need to attach the first name and address to the first URL etc.
>
>Also how do I make the initail request. At the moment it is just a URL
>attached to a form action?
>
>Does the form action need to go to another script use OPEN and then the URL
>to the search script?

You likely need a CGI script.  Take a look at the LWP module or if you do
not have access to that, IO::Socket (see 'perldoc perlipc').  Or on a most
basic level you can use Socket (perldoc Socket).  Then you need to parse
the data you receive.  CGI.pm can be handy for generating html (perldoc CGI).

-- 
David Efflandt  efflandt@xnet.com  http://www.xnet.com/~efflandt/
http://www.de-srv.com/  http://cgi-help.virtualave.net/
http://thunder.prohosting.com/~cv-elgin/


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

Date: 14 Nov 1999 12:43:47 -0500
From: Uri Guttman <uri@sysarch.com>
Subject: Re: Perl and commonsense part 2
Message-Id: <x7g0y9x92k.fsf@home.sysarch.com>

>>>>> "BL" == Bart Lateur <bart.lateur@skynet.be> writes:

  BL> Uri Guttman wrote:
  >> if all you will do is test for existance of the key then this is even
  >> simpler:
  >> 
  >> @hash{ @array } = () ;

  BL> Which is very fast compared to any other method. However, *who* in is
  BL> right mind would test only for existence of a key, if you're free to
  BL> choose whatever hash value you like?

because sometimes just a test for membership in a set is all you actually
need. there are many cases like that so i will not list any. just use
your imagination a little.

  BL> 	@hash{@array} = (1) x @array;
  BL> 	@hash{@array} = 1 .. @array;

those are covered in my hash slice tutorial.

  BL> 	$hash{$_}++ foreach @array;

that one looks kinda slow compared to the first one (assuming an empty
hash and all you want are 1's as values). if you are counting keys seen
then that is the right way to do it.

uri

-- 
Uri Guttman  ---------  uri@sysarch.com  ----------  http://www.sysarch.com
SYStems ARCHitecture, Software Engineering, Perl, Internet, UNIX Consulting
The Perl Books Page  -----------  http://www.sysarch.com/cgi-bin/perl_books
The Best Search Engine on the Net  ----------  http://www.northernlight.com


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

Date: Sat, 13 Nov 1999 14:16:46 +0000
From: "David J. Ritchie" <ritchie@fnal.gov>
Subject: Re: perl as first language?
Message-Id: <382D72CE.85D90963@fnal.gov>

>  All the songs were G&S.  That one
> was "I am the very model of a modern anti-Bayesian".  It
> even scanned better than yours.

I'd love to see that song--there are a few anti-B's that would benefit
from it.

Could you post it?

--David

ritchie@fnal.gov
http://fncduh.fnal.gov/~ritchie



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

Date: Sun, 14 Nov 1999 17:19:48 GMT
From: bmccoy@news.lan2wan.com (Brett W. McCoy)
Subject: Re: Perl forgot 3 lines of the script
Message-Id: <slrn82ts84.l5i.bmccoy@dragosani.lan2wan.com>

On Mon, 08 Nov 1999 22:48:21 +0100, Utilisateur Red Hat Linux
<b.herzog@netcourrier.com> wrote:

>I need to write to a filehandle in a CGI script.
>So, i inserted, at the begining of the script:
>
>open(FILE,">file");
>print FILE "Hello !";
>close(FILE);
>
>All permissions and directories are correctly set (i did check that),
>and those 3 lines perfectly work as an entire script (if i paste them in
>a differetn file.pl and run it, i get Hello written to file).
>
>But in the CGI script, that doesn't work. As if Perl forgot to read the
>3 lines ...

Are you using -w, use strict, use diagnostics and Carp with fatals to
browser? The permissions of CGI typically are very minimal (user nobody,
for instance), and what may work for a non-CGI script won't necessarily
work for CGI.  Also, try running the CGI script from the command (using,
of course, the -w, use strict, etc.) and see what happens there as well.

-- 
Brett W. McCoy           
                                        http://www.lan2wan.com/~bmccoy/
-----------------------------------------------------------------------
Tomorrow, you can be anywhere.


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

Date: Sun, 14 Nov 1999 10:04:19 -0800
From: Andrew J Perrin <andrewperrin@netscape.net>
Subject: Re: Perl forgot 3 lines of the script
Message-Id: <382EF9A3.45B68E08@netscape.net>

"Brett W. McCoy" wrote:
> 
> On Mon, 08 Nov 1999 22:48:21 +0100, Utilisateur Red Hat Linux
> <b.herzog@netcourrier.com> wrote:
 ...
> >open(FILE,">file");
> >print FILE "Hello !";
> >close(FILE);
 ...
> >But in the CGI script, that doesn't work. As if Perl forgot to read the
> >3 lines ...
> 
> Are you using -w, use strict, use diagnostics and Carp with fatals to
> browser? The permissions of CGI typically are very minimal (user nobody,
> for instance), and what may work for a non-CGI script won't necessarily
> work for CGI.  Also, try running the CGI script from the command (using,
> of course, the -w, use strict, etc.) and see what happens there as well.

Try, also, testing the result of the open() call, which will very likely
tell you the problem:

open(FILE,">file") || die "Can't write to file: $!\n";

or...

open(FILE,">file") || print "Can't write to file: $!\n";

the former version will (probably) put the error message in your
server's error log, the latter will (probably) put it in the browser
from which you call the script, provided the rest of your script works
passably.

-- 
--------------------------------------------------------------
Andrew J. Perrin    -     UC Berkeley, Sociology & Demography
Consulting: Solaris-Linux-NT-Samba-Perl-MS Access-Postgres
andrewperrin@netscape.net - http://demog.berkeley.edu/~aperrin
--------------------------------------------------------------


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

Date: Sun, 14 Nov 1999 18:41:53 GMT
From: bmccoy@news.lan2wan.com (Brett W. McCoy)
Subject: Re: Perl forgot 3 lines of the script
Message-Id: <slrn82u124.l5i.bmccoy@dragosani.lan2wan.com>

On Sun, 14 Nov 1999 10:04:19 -0800, Andrew J Perrin
<andrewperrin@netscape.net> wrote:

>> >But in the CGI script, that doesn't work. As if Perl forgot to read the
>> >3 lines ...
>> 
>> Are you using -w, use strict, use diagnostics and Carp with fatals to
>> browser? The permissions of CGI typically are very minimal (user nobody,
>> for instance), and what may work for a non-CGI script won't necessarily
>> work for CGI.  Also, try running the CGI script from the command (using,
>> of course, the -w, use strict, etc.) and see what happens there as well.
>
>Try, also, testing the result of the open() call, which will very likely
>tell you the problem:
>
>open(FILE,">file") || die "Can't write to file: $!\n";
>
>or...
>
>open(FILE,">file") || print "Can't write to file: $!\n";
>
>the former version will (probably) put the error message in your
>server's error log, the latter will (probably) put it in the browser
>from which you call the script, provided the rest of your script works
>passably.

Using Carp qw(Fatals to browser) can ensure something gets printed to the
borwser window.  But, yes, the best solution is to test for success on the
calls to open.

-- 
Brett W. McCoy           
                                        http://www.lan2wan.com/~bmccoy/
-----------------------------------------------------------------------
Knowledge is power.
		-- Francis Bacon


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

Date: Sun, 14 Nov 1999 11:52:24 -0800
From: Larry Rosler <lr@hpl.hp.com>
Subject: Re: Perl forgot 3 lines of the script
Message-Id: <MPG.1298b2d21f47eae198a1fc@nntp.hpl.hp.com>

In article <slrn82u124.l5i.bmccoy@dragosani.lan2wan.com> on Sun, 14 Nov 
1999 18:41:53 GMT, Brett W. McCoy <bmccoy@news.lan2wan.com> says...

 ...

> Using Carp qw(Fatals to browser) can ensure something gets printed to the
> borwser window.

    use CGI::Carp qw(fatalsToBrowser);

How I abhor those 'studly caps'.

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


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

Date: Sun, 14 Nov 1999 17:23:32 -0500
From: Matth Schulz <matthschulzantispam@gmx.net>
Subject: PERL-Terminal
Message-Id: <942618291.479477183@netnews.worldnet.att.net>

Hi, all

I'm trying to do a terminal-like application in perl5.

There is a serial-coupled box, which i try to handle.
I used minicom, works fine, but i have to set some filters and controls for in-
and output. So i tried following:

#!/usr/bin/perl -w
use English;
my ($kidpid, $lines, $liner, $port, $oldh);

unless (@ARGV == 1) { die "usage: $0 ttySx" }
($port) = @ARGV;

open(BOX, "+>/dev/$port") or die "can't connect to >/dev/$port $!";
$OUTPUT_AUTOFLUSH = 1;
# split the program into two processes, identical twins
die "can't fork: $!" unless defined($kidpid = fork());

# the if{} block runs only in the parent process
if ($kidpid) {
#        print STDERR "[pa Child#: $kidpid   Parent#: $$]\n";    #debug only
 # copy standard input to the BOX
 while (defined ($lines = <STDIN>)) {
         print "**s** $lines";   #deb: line sent
         print BOX $lines;
         if ($lines eq "exit\n") {
                 kill("TERM",$kidpid); # send SIGTERM to child
                 close(BOX);
                 exit 0;
         }
 }
}
# the else{} block runs only in the child process
else {
#        print STDERR "[ch Child#: $kidpid   Parent#: $$]\n";    #debug only
 # copy BOX to standard output
 while (1){
         $liner = <BOX>;
         print STDOUT "**r** $liner";    # deb: line received
 }
}


There seems to be some confusion between input- and outputbuffer.
I get 


ati0
**s** ati0
**r** ati0
**r**
**r**
**r** Xircom CreditCard Modem CM-56T (Revision 2.08)
**r**
**r**
**r**
**r** OK
**r**
**r** ati0
**r**
**r**
**r** Xircom CreditCard Modem CM-56T (Revision 2.08)
**r**
**r**
**r**
**r** OK
**r**         
 ..

Does somebody know, what i'm doing wrong?



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

Date: Mon, 15 Nov 1999 09:48:06 +1300
From: Andrew Broadley <expoinfo@globalexpos.co.nz>
Subject: Rand Number without the decimals!!
Message-Id: <382F2006.37EBC424@globalexpos.co.nz>

Hi y'all,

Two problems,

I cant seem to get $ENV{'REMOTE_HOST'}; on my script anymore.. in Unix
or Win32 ?!?! any ideas why ? i need it for a temp file... but if i cant
figure out.. ill use the random number in the temp files instead..

and...

I was just wondering how to make a random number in perl without the
Decimals ?!?!?


Thanks,
Andrew Broadley
Information Technology
______________________________

GLOBAL EXPOS (NZ) LIMITED
http://www.globalexpos.co.nz
"Better business using the power of the Internet
and the face-to-face advantage of exhibitions"

E-mail me on my cellphone:
0212956648@messagetracker.co.nz
(max 146 characters)



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

Date: Sun, 14 Nov 1999 13:49:48 -0800
From: Larry Rosler <lr@hpl.hp.com>
Subject: Re: Rand Number without the decimals!!
Message-Id: <MPG.1298ce4efcd61d0898a200@nntp.hpl.hp.com>

In article <382F2006.37EBC424@globalexpos.co.nz> on Mon, 15 Nov 1999 
09:48:06 +1300, Andrew Broadley <expoinfo@globalexpos.co.nz> says...

 ...

> I cant seem to get $ENV{'REMOTE_HOST'}; on my script anymore.. in Unix
> or Win32 ?!?! any ideas why ? i need it for a temp file... but if i cant
> figure out.. ill use the random number in the temp files instead..

That is because the server isn't setting it, which is not a Perl issue.

> I was just wondering how to make a random number in perl without the

perldoc -f int

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


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

Date: Sun, 14 Nov 1999 22:34:09 GMT
From: mgjv@comdyn.com.au (Martien Verbruggen)
Subject: Re: Rand Number without the decimals!!
Message-Id: <BNGX3.81$zg7.2135@nsw.nnrp.telstra.net>

On Mon, 15 Nov 1999 09:48:06 +1300,
	Andrew Broadley <expoinfo@globalexpos.co.nz> wrote:
> Hi y'all,
> 
> Two problems,
> 
> I cant seem to get $ENV{'REMOTE_HOST'}; on my script anymore.. in Unix
> or Win32 ?!?! any ideas why ? i need it for a temp file... but if i cant
> figure out.. ill use the random number in the temp files instead..

That must be because it's not in the environment. But Perl has nothing
to do with that. This is CGI, right? The server is responsible for
setting that. If it doesn't, reconfigure the server.

Are you using this for 'unique' file names? Do you know that when
people are behind a proxy, that variable will be the same for all of
them? Maybe you should ask in a group that talks about CGI how to do
this correctly. A random number would be a possible start.

> and...
> 
> I was just wondering how to make a random number in perl without the
> Decimals ?!?!?

perldoc -f int

Martien
-- 
Martien Verbruggen              | 
Interactive Media Division      | We are born naked, wet and hungry.
Commercial Dynamics Pty. Ltd.   | Then things get worse.
NSW, Australia                  | 


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

Date: 14 Nov 1999 22:40:36 GMT
From: efflandt@xnet.com (David Efflandt)
Subject: Re: Rand Number without the decimals!!
Message-Id: <slrn82uej3.ll.efflandt@efflandt.xnet.com>

On Mon, 15 Nov 1999 09:48:06 +1300, Andrew Broadley
<expoinfo@globalexpos.co.nz> wrote:
>
>Two problems,
>
>I cant seem to get $ENV{'REMOTE_HOST'}; on my script anymore.. in Unix
>or Win32 ?!?! any ideas why ? i need it for a temp file... but if i cant
>figure out.. ill use the random number in the temp files instead..

Most servers skip DNS lookup (faster) unless they have to.  I don't know
if this works in Windows, but for Unix you can typically use the process
ID for a unique temporary file extension (at least until the computer
reboots), like filename.$$

>I was just wondering how to make a random number in perl without the
>Decimals ?!?!?

Add 1 to the range you want and turn the result into an integer.  But note
that (random ne unique).  It may be rare for the same number to come up
twice in a row, but it can happen.  It's a crap shoot.

-- 
David Efflandt  efflandt@xnet.com  http://www.xnet.com/~efflandt/
http://www.de-srv.com/  http://cgi-help.virtualave.net/
http://thunder.prohosting.com/~cv-elgin/


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

Date: Sun, 14 Nov 1999 17:10:15 GMT
From: Rick Delaney <rick.delaney@home.com>
Subject: Re: RE : DBD::Pg table attributes. reference to array of hashes!
Message-Id: <382EED10.E8AEDADA@home.com>

[posted & mailed]

Dan Hennessey wrote:
> 
> I've scoured the net and all the documentation I can find and I cant
> work out how to retrieve the field names ( whoops, sorry attribute
> names ) from a Postgres database using DBD::Pg.

There's an example in the DBI manpages, under the heading, "Simple
Examples".

> Please help me Obi Wan, you're my only hope.

That's DBI::Wan.

-- 
Rick Delaney
rick.delaney@home.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 1376
**************************************


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