[17496] in Perl-Users-Digest
Perl-Users Digest, Issue: 4916 Volume: 9
daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Sat Nov 18 09:05:31 2000
Date: Sat, 18 Nov 2000 06:05:08 -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: <974556308-v9-i4916@ruby.oce.orst.edu>
Content-Type: text
Perl-Users Digest Sat, 18 Nov 2000 Volume: 9 Number: 4916
Today's topics:
Re: [newbie] how do i get activeperl in win98 to work p <johngros@Spam.bigpond.net.au>
[Perl] How to find the Perl FAQ <rootbeer&pfaq*finding*@redcat.com>
Re: Beginners blues. <johngros@Spam.bigpond.net.au>
Re: Beginners blues. <wyzelli@yahoo.com>
Re: hash printout <bart.lateur@skynet.be>
Re: How to transform a string to Hex and back to ascii <bart.lateur@skynet.be>
Re: Perl, unicode and internationalization/localization <godoy@conectiva.com>
Problems saving an uploaded file. <johan.ditmar@era.ericsson.se>
Problems saving an uploaded file. <johan.ditmar@era.ericsson.se>
Problems saving an uploaded file. <johan.ditmar@era.ericsson.se>
Problems saving an uploaded file. <johan.ditmar@era.ericsson.se>
Problems saving an uploaded file. <johan.ditmar@era.ericsson.se>
Problems saving an uploaded file. <johan.ditmar@era.ericsson.se>
Problems saving an uploaded file. <johan.ditmar@era.ericsson.se>
Problems saving an uploaded file. <johan.ditmar@era.ericsson.se>
Problems saving an uploaded file. <johan.ditmar@era.ericsson.se>
Problems saving an uploaded file. <johan.ditmar@era.ericsson.se>
Problems saving an uploaded file. <johan.ditmar@era.ericsson.se>
Problems saving an uploaded file. <johan.ditmar@era.ericsson.se>
Re: Problems saving an uploaded file. <bart.lateur@skynet.be>
sendmail with cgi.pm? xlr6drone@my-deja.com
Re: string checking problem fhinchey@my-deja.com
Digest Administrivia (Last modified: 16 Sep 99) (Perl-Users-Digest Admin)
----------------------------------------------------------------------
Date: Sat, 18 Nov 2000 12:22:31 GMT
From: "John Boy Walton" <johngros@Spam.bigpond.net.au>
Subject: Re: [newbie] how do i get activeperl in win98 to work properly?
Message-Id: <bwuR5.12249$tU2.102946@news-server.bigpond.net.au>
#!E:/Millenium Programs/perl/bin/Perl -w
Just change the path to where your perl is installed.
(That's my shebang line)
I don't know which server you are using.
I use Apache with Apache your scripts go in cgi-bin ( pretty standard) and
the html and pics goes in htdocs. But that is the default setup you can
configure it to go into directories named whatever you like.
------------------------------
Date: Sat, 18 Nov 2000 11:21:54 GMT
From: Tom Phoenix <rootbeer&pfaq*finding*@redcat.com>
Subject: [Perl] How to find the Perl FAQ
Message-Id: <pfaqmessage974546645.23681@news.teleport.com>
Archive-name: perl-faq/finding-perl-faq
Posting-Frequency: weekly
Last-modified: 29 Apr 2000
[ That "Last-modified:" date above refers to this document, not to the
Perl FAQ itself! The last _major_ update of the Perl FAQ was in Summer
of 1998; of course, ongoing updates are made as needed. ]
For most people, this URL should be all you need in order to find Perl's
Frequently Asked Questions (and answers).
http://www.cpan.org/doc/FAQs/
Please look over (but never overlook!) the FAQ and related docs before
posting anything to the comp.lang.perl.* family of newsgroups.
For an alternative way to get answers, check out the Perlfaq website.
http://www.perlfaq.com/
# # # # # # # # # # # # # # # # # # # # # # # # # # # # # #
Beginning with Perl version 5.004, the Perl distribution itself includes
the Perl FAQ. If everything is pro-Perl-y installed on your system, the
FAQ will be stored alongside the rest of Perl's documentation, and one
of these commands (or your local equivalents) should let you read the FAQ.
perldoc perlfaq
man perlfaq
If a recent version of Perl is not properly installed on your system,
you should ask your system administrator or local expert to help. If you
find that a recent Perl distribution is lacking the FAQ or other important
documentation, be sure to complain to that distribution's author.
If you have a web connection, the first and foremost source for all things
Perl, including the FAQ, is the Comprehensive Perl Archive Network (CPAN).
CPAN also includes the Perl source code, pre-compiled binaries for many
platforms, and a large collection of freely usable modules, among its
560_986_526 bytes (give or take a little) of super-cool (give or take
a little) Perl resources.
http://www.cpan.org/
http://www.perl.com/CPAN/
http://www.cpan.org/doc/FAQs/FAQ/html/
http://www.perl.com/CPAN/doc/FAQs/FAQ/html/
You may wish or need to access CPAN via anonymous FTP. (Within CPAN,
you will find the FAQ in the /doc/FAQs/FAQ directory. If none of these
selected FTP sites is especially good for you, a full list of CPAN sites
is in the SITES file within CPAN.)
California ftp://ftp.cdrom.com/pub/perl/CPAN/
Texas ftp://ftp.metronet.com/pub/perl/
South Africa ftp://ftp.is.co.za/programming/perl/CPAN/
Japan ftp://ftp.dti.ad.jp/pub/lang/CPAN/
Australia ftp://cpan.topend.com.au/pub/CPAN/
Netherlands ftp://ftp.cs.ruu.nl/pub/PERL/CPAN/
Switzerland ftp://sunsite.cnlab-switch.ch/mirror/CPAN/
Chile ftp://ftp.ing.puc.cl/pub/unix/perl/CPAN/
If you have no connection to the Internet at all (so sad!) you may wish
to purchase one of the commercial Perl distributions on CD-Rom or other
media. Your local bookstore should be able to help you to find one.
# # # # # # # # # # # # # # # # # # # # # # # # # # # # # #
Comments and suggestions on the contents of this document
are always welcome. Please send them to the author at
<pfaq&finding*comments*@redcat.com>. Of course, comments on
the docs and FAQs mentioned here should go to their respective
maintainers.
Have fun with Perl!
--
Tom Phoenix Perl Training and Hacking Esperanto
Randal Schwartz Case: http://www.rahul.net/jeffrey/ovs/
------------------------------
Date: Sat, 18 Nov 2000 12:05:02 GMT
From: "John Boy Walton" <johngros@Spam.bigpond.net.au>
Subject: Re: Beginners blues.
Message-Id: <OfuR5.12239$tU2.102601@news-server.bigpond.net.au>
Well I have a lot of people to thank already.
But it is still not quite right.
It does not open the file because the file does not exist.
open BOGUS,"+>>C:\\Progra~1"
open BOGUS,">>C:\\Progra~1"
open BOGUS,">C:\\Progra~1"
All do not create the file. My books once again tell me how open to read, to
write and append but nothing on file creation.
I hate being such a dope but I need some hints.
"Wyzelli" <wyzelli@yahoo.com> wrote in message
news:p3kR5.7$Bf1.3114@vic.nntp.telstra.net...
> "dionysus" <dionysus39@hotmail.com> wrote in message
> news:3a1538ed.163893847@nntp.unsw.edu.au...
> >
> > >
> > >No, for a couple of reasons, the main one being that spaces can't be
> > >passed to the command shell.
> > umm....no-one told me (or my copy of perl) that.....
> > I have never had any problems....but then I always use
> >
> > open(IN, "> c:\\some directory\\some file.txt") or die;
> >
> > for single quotes it would not work, yeah....
> >
>
> Hmmm, I keep getting 'invalid argument at line whatever'. It is probably
> something to do with the version of the Windoze command shell in use.
>
> I am on win2k pro Wkstn, and will test on a few different ones to see.
>
> Wyzelli
> --
> #Modified from the original by Jim Menard
> for(reverse(1..100)){$s=($_==1)? '':'s';print"$_ bottle$s of beer on the
> wall,\n";
> print"$_ bottle$s of beer,\nTake one down, pass it around,\n";
> $_--;$s=($_==1)?'':'s';print"$_ bottle$s of beer on the
> wall\n\n";}print'*burp*';
>
>
------------------------------
Date: Sat, 18 Nov 2000 22:47:42 +0930
From: "Wyzelli" <wyzelli@yahoo.com>
Subject: Re: Beginners blues.
Message-Id: <VjvR5.11$gk1.1142@vic.nntp.telstra.net>
"John Boy Walton" <johngros@Spam.bigpond.net.au> wrote in message
news:OfuR5.12239$tU2.102601@news-server.bigpond.net.au...
> Well I have a lot of people to thank already.
> But it is still not quite right.
> It does not open the file because the file does not exist.
> open BOGUS,"+>>C:\\Progra~1"
That tries to open a DIRECTORY in append/read mode... which it cannot do.
> open BOGUS,">>C:\\Progra~1"
That tries to open a DIRECTORY in append mode... ditto
> open BOGUS,">C:\\Progra~1"
That tries to open that same directory on write mode.... ditto
> All do not create the file. My books once again tell me how open to read,
to
> write and append but nothing on file creation.
open (HANDLE, '>c:/progra~1/test.txt') or die "Cannot open file $!";
print HANDLE 'This is data';
close HANDLE;
Copy and paste then run that and I'll be buggered if it doesn't work!
(assuming the user who is running the script has permission to create that
file in that directory, failing which the program should report "Cannot open
file Access denied" or similar).
Wyzelli
--
#Modified from the original by Jim Menard
for(reverse(1..100)){$s=($_==1)? '':'s';print"$_ bottle$s of beer on the
wall,\n";
print"$_ bottle$s of beer,\nTake one down, pass it around,\n";
$_--;$s=($_==1)?'':'s';print"$_ bottle$s of beer on the
wall\n\n";}print'*burp*';
------------------------------
Date: Sat, 18 Nov 2000 10:18:14 GMT
From: Bart Lateur <bart.lateur@skynet.be>
Subject: Re: hash printout
Message-Id: <solc1tkfi1sefgcrfn5p5fbfubnsl2b7t9@4ax.com>
paul simdars wrote:
> I have a hash like this :
>
>%hnums = (
>1, 20,
>2, 15,
>3, 40,
>4, 22 );
>
>I have looked thru lots of articles and examples but have not found what
>I am
>looking for. I want to sort them by the values and print the value and
>the
>key. I found a perfect example in a book but it didn't work.
foreach (sort { $hnums{$a} <=> $hnums{$b} } keys %hnums) {
print "$hnums{$_} belongs to $_\n";
}
-->
15 belongs to 2
20 belongs to 1
22 belongs to 4
40 belongs to 3
--
Bart.
------------------------------
Date: Sat, 18 Nov 2000 11:05:16 GMT
From: Bart Lateur <bart.lateur@skynet.be>
Subject: Re: How to transform a string to Hex and back to ascii
Message-Id: <h8oc1toiurmns89hclk8rp1sq65s7quhln@4ax.com>
dragnovich@my-deja.com wrote:
>$a = "68656c6c6f";
>$a =~ s/([a-fA-F0-9]{2})/pack("C",hex($1))/eg;
>print $a;
>
>This will print "hello" ok!
There's another, more direct pack/unpack template: "H"
$a = "68656c6c6f";
print pack 'H*', $a;
-->
hello
>but how can I do the inverse?? like:
$b = 'hello';
$c = join '', map { sprintf '%02X', $_ } unpack 'C*', $b;
print $c;
-->
68656C6C6F
or use '%02x' as the sprintf template if you like lowercase letters.
Using pack/unpack with the 'H' template works, too:
$d = unpack 'H*', 'hello';
print $d;
-->
68656c6c6f
--
Bart.
------------------------------
Date: 18 Nov 2000 08:15:43 -0200
From: Jorge Godoy <godoy@conectiva.com>
Subject: Re: Perl, unicode and internationalization/localization
Message-Id: <kpaeaxh9gw.fsf@dagon.conectiva>
On Fri, 17 Nov 2000, rcongiu@pacbell.net wrote:
> different character sets. But how can translate the Unicode to HTML
> ? How do I translate the unicode strings into a web page produced
> by a perl script ? I had a look at CPAN but couldn't find what
> should work for me. Can anyone help me ? Links , pointers, books,
> whatever about internationalization and perl are very very welcome,
> it's the first project of this kind for me.
Hi!
Take a look at:
- Unicode::Map
- Unicode::Map8
- Unicode::String
These are all modules available from CPAN.
WRT internationalization, there's the I18N::* modules and the
Locale::* modules too.
I'm yet to try something like you're doing --- using modules, not
badly written routines to handle I18N and localization --- for my
programas, as soon as I can rewrite the actual prototypes correctly.
See you,
--
Godoy. <godoy@conectiva.com>
Departamento de Publicações Conectiva S.A.
Publishing Department Conectiva Inc.
------------------------------
Date: Fri, 17 Nov 2000 15:58:08 +0100
From: "Johan Ditmar" <johan.ditmar@era.ericsson.se>
Subject: Problems saving an uploaded file.
Message-Id: <8v5d1t$5g9$1@newstoo.ericsson.se>
Hi all,
I am using Apache 1.3 together with ActiveState Perl 5.6.0.618 and I have
the following problem. I want to upload a file from a webpage and save it at
a server. I am using the following code to do that:
$bitfile = param("bitfile");
open (SAVE,">./bitfile.bit") || die $!;
binmode(SAVE);
while ( read($bitfile,$data,1024) ) {
print SAVE $data;
}
close SAVE;
What it does is that it takes the file handle and then saves the clients
file under 'bitfile.bit' on the server.
Sometimes this works, but many times it happens that the file is not saved
(it is created, but has size 0 or is only 1 byte long). I have enough space
on my disk and enough memory. Could this be a bug?
Johan
------------------------------
Date: Fri, 17 Nov 2000 15:58:08 +0100
From: "Johan Ditmar" <johan.ditmar@era.ericsson.se>
Subject: Problems saving an uploaded file.
Message-Id: <8v5eq5$8i4$1@newstoo.ericsson.se>
Hi all,
I am using Apache 1.3 together with ActiveState Perl 5.6.0.618 and I have
the following problem. I want to upload a file from a webpage and save it at
a server. I am using the following code to do that:
$bitfile = param("bitfile");
open (SAVE,">./bitfile.bit") || die $!;
binmode(SAVE);
while ( read($bitfile,$data,1024) ) {
print SAVE $data;
}
close SAVE;
What it does is that it takes the file handle and then saves the clients
file under 'bitfile.bit' on the server.
Sometimes this works, but many times it happens that the file is not saved
(it is created, but has size 0 or is only 1 byte long). I have enough space
on my disk and enough memory. Could this be a bug?
Johan
------------------------------
Date: Fri, 17 Nov 2000 15:58:08 +0100
From: "Johan Ditmar" <johan.ditmar@era.ericsson.se>
Subject: Problems saving an uploaded file.
Message-Id: <8v5gif$bs1$1@newstoo.ericsson.se>
Hi all,
I am using Apache 1.3 together with ActiveState Perl 5.6.0.618 and I have
the following problem. I want to upload a file from a webpage and save it at
a server. I am using the following code to do that:
$bitfile = param("bitfile");
open (SAVE,">./bitfile.bit") || die $!;
binmode(SAVE);
while ( read($bitfile,$data,1024) ) {
print SAVE $data;
}
close SAVE;
What it does is that it takes the file handle and then saves the clients
file under 'bitfile.bit' on the server.
Sometimes this works, but many times it happens that the file is not saved
(it is created, but has size 0 or is only 1 byte long). I have enough space
on my disk and enough memory. Could this be a bug?
Johan
------------------------------
Date: Fri, 17 Nov 2000 15:58:08 +0100
From: "Johan Ditmar" <johan.ditmar@era.ericsson.se>
Subject: Problems saving an uploaded file.
Message-Id: <8v5ian$esd$1@newstoo.ericsson.se>
Hi all,
I am using Apache 1.3 together with ActiveState Perl 5.6.0.618 and I have
the following problem. I want to upload a file from a webpage and save it at
a server. I am using the following code to do that:
$bitfile = param("bitfile");
open (SAVE,">./bitfile.bit") || die $!;
binmode(SAVE);
while ( read($bitfile,$data,1024) ) {
print SAVE $data;
}
close SAVE;
What it does is that it takes the file handle and then saves the clients
file under 'bitfile.bit' on the server.
Sometimes this works, but many times it happens that the file is not saved
(it is created, but has size 0 or is only 1 byte long). I have enough space
on my disk and enough memory. Could this be a bug?
Johan
------------------------------
Date: Fri, 17 Nov 2000 15:58:08 +0100
From: "Johan Ditmar" <johan.ditmar@era.ericsson.se>
Subject: Problems saving an uploaded file.
Message-Id: <8v5k2v$hvf$1@newstoo.ericsson.se>
Hi all,
I am using Apache 1.3 together with ActiveState Perl 5.6.0.618 and I have
the following problem. I want to upload a file from a webpage and save it at
a server. I am using the following code to do that:
$bitfile = param("bitfile");
open (SAVE,">./bitfile.bit") || die $!;
binmode(SAVE);
while ( read($bitfile,$data,1024) ) {
print SAVE $data;
}
close SAVE;
What it does is that it takes the file handle and then saves the clients
file under 'bitfile.bit' on the server.
Sometimes this works, but many times it happens that the file is not saved
(it is created, but has size 0 or is only 1 byte long). I have enough space
on my disk and enough memory. Could this be a bug?
Johan
------------------------------
Date: Fri, 17 Nov 2000 15:58:08 +0100
From: "Johan Ditmar" <johan.ditmar@era.ericsson.se>
Subject: Problems saving an uploaded file.
Message-Id: <8v5lr7$l22$1@newstoo.ericsson.se>
Hi all,
I am using Apache 1.3 together with ActiveState Perl 5.6.0.618 and I have
the following problem. I want to upload a file from a webpage and save it at
a server. I am using the following code to do that:
$bitfile = param("bitfile");
open (SAVE,">./bitfile.bit") || die $!;
binmode(SAVE);
while ( read($bitfile,$data,1024) ) {
print SAVE $data;
}
close SAVE;
What it does is that it takes the file handle and then saves the clients
file under 'bitfile.bit' on the server.
Sometimes this works, but many times it happens that the file is not saved
(it is created, but has size 0 or is only 1 byte long). I have enough space
on my disk and enough memory. Could this be a bug?
Johan
------------------------------
Date: Fri, 17 Nov 2000 15:58:08 +0100
From: "Johan Ditmar" <johan.ditmar@era.ericsson.se>
Subject: Problems saving an uploaded file.
Message-Id: <8v5njf$ns6$1@newstoo.ericsson.se>
Hi all,
I am using Apache 1.3 together with ActiveState Perl 5.6.0.618 and I have
the following problem. I want to upload a file from a webpage and save it at
a server. I am using the following code to do that:
$bitfile = param("bitfile");
open (SAVE,">./bitfile.bit") || die $!;
binmode(SAVE);
while ( read($bitfile,$data,1024) ) {
print SAVE $data;
}
close SAVE;
What it does is that it takes the file handle and then saves the clients
file under 'bitfile.bit' on the server.
Sometimes this works, but many times it happens that the file is not saved
(it is created, but has size 0 or is only 1 byte long). I have enough space
on my disk and enough memory. Could this be a bug?
Johan
------------------------------
Date: Fri, 17 Nov 2000 15:58:08 +0100
From: "Johan Ditmar" <johan.ditmar@era.ericsson.se>
Subject: Problems saving an uploaded file.
Message-Id: <8v5pbn$qlr$1@newstoo.ericsson.se>
Hi all,
I am using Apache 1.3 together with ActiveState Perl 5.6.0.618 and I have
the following problem. I want to upload a file from a webpage and save it at
a server. I am using the following code to do that:
$bitfile = param("bitfile");
open (SAVE,">./bitfile.bit") || die $!;
binmode(SAVE);
while ( read($bitfile,$data,1024) ) {
print SAVE $data;
}
close SAVE;
What it does is that it takes the file handle and then saves the clients
file under 'bitfile.bit' on the server.
Sometimes this works, but many times it happens that the file is not saved
(it is created, but has size 0 or is only 1 byte long). I have enough space
on my disk and enough memory. Could this be a bug?
Johan
------------------------------
Date: Fri, 17 Nov 2000 15:58:08 +0100
From: "Johan Ditmar" <johan.ditmar@era.ericsson.se>
Subject: Problems saving an uploaded file.
Message-Id: <8v5r41$c0$1@newstoo.ericsson.se>
Hi all,
I am using Apache 1.3 together with ActiveState Perl 5.6.0.618 and I have
the following problem. I want to upload a file from a webpage and save it at
a server. I am using the following code to do that:
$bitfile = param("bitfile");
open (SAVE,">./bitfile.bit") || die $!;
binmode(SAVE);
while ( read($bitfile,$data,1024) ) {
print SAVE $data;
}
close SAVE;
What it does is that it takes the file handle and then saves the clients
file under 'bitfile.bit' on the server.
Sometimes this works, but many times it happens that the file is not saved
(it is created, but has size 0 or is only 1 byte long). I have enough space
on my disk and enough memory. Could this be a bug?
Johan
------------------------------
Date: Fri, 17 Nov 2000 15:58:08 +0100
From: "Johan Ditmar" <johan.ditmar@era.ericsson.se>
Subject: Problems saving an uploaded file.
Message-Id: <8v5st1$2ol$1@newstoo.ericsson.se>
Hi all,
I am using Apache 1.3 together with ActiveState Perl 5.6.0.618 and I have
the following problem. I want to upload a file from a webpage and save it at
a server. I am using the following code to do that:
$bitfile = param("bitfile");
open (SAVE,">./bitfile.bit") || die $!;
binmode(SAVE);
while ( read($bitfile,$data,1024) ) {
print SAVE $data;
}
close SAVE;
What it does is that it takes the file handle and then saves the clients
file under 'bitfile.bit' on the server.
Sometimes this works, but many times it happens that the file is not saved
(it is created, but has size 0 or is only 1 byte long). I have enough space
on my disk and enough memory. Could this be a bug?
Johan
------------------------------
Date: Fri, 17 Nov 2000 15:58:08 +0100
From: "Johan Ditmar" <johan.ditmar@era.ericsson.se>
Subject: Problems saving an uploaded file.
Message-Id: <8v5ul9$5gv$1@newstoo.ericsson.se>
Hi all,
I am using Apache 1.3 together with ActiveState Perl 5.6.0.618 and I have
the following problem. I want to upload a file from a webpage and save it at
a server. I am using the following code to do that:
$bitfile = param("bitfile");
open (SAVE,">./bitfile.bit") || die $!;
binmode(SAVE);
while ( read($bitfile,$data,1024) ) {
print SAVE $data;
}
close SAVE;
What it does is that it takes the file handle and then saves the clients
file under 'bitfile.bit' on the server.
Sometimes this works, but many times it happens that the file is not saved
(it is created, but has size 0 or is only 1 byte long). I have enough space
on my disk and enough memory. Could this be a bug?
Johan
------------------------------
Date: Fri, 17 Nov 2000 15:58:08 +0100
From: "Johan Ditmar" <johan.ditmar@era.ericsson.se>
Subject: Problems saving an uploaded file.
Message-Id: <8v60dh$8td$1@newstoo.ericsson.se>
Hi all,
I am using Apache 1.3 together with ActiveState Perl 5.6.0.618 and I have
the following problem. I want to upload a file from a webpage and save it at
a server. I am using the following code to do that:
$bitfile = param("bitfile");
open (SAVE,">./bitfile.bit") || die $!;
binmode(SAVE);
while ( read($bitfile,$data,1024) ) {
print SAVE $data;
}
close SAVE;
What it does is that it takes the file handle and then saves the clients
file under 'bitfile.bit' on the server.
Sometimes this works, but many times it happens that the file is not saved
(it is created, but has size 0 or is only 1 byte long). I have enough space
on my disk and enough memory. Could this be a bug?
Johan
------------------------------
Date: Sat, 18 Nov 2000 10:57:03 GMT
From: Bart Lateur <bart.lateur@skynet.be>
Subject: Re: Problems saving an uploaded file.
Message-Id: <o1mc1tsbefabu8ecvipg66h658cvidqodn@4ax.com>
Johan Ditmar wrote:
No reason to post this 35 (!) times.
>I am using Apache 1.3 together with ActiveState Perl 5.6.0.618 and I have
>the following problem. I want to upload a file from a webpage and save it at
>a server.
>
> $bitfile = param("bitfile");
>
> open (SAVE,">./bitfile.bit") || die $!;
> binmode(SAVE);
>
> while ( read($bitfile,$data,1024) ) {
> print SAVE $data;
> }
> close SAVE;
>
>What it does is that it takes the file handle and then saves the clients
>file under 'bitfile.bit' on the server.
I'm not surprised this doesn't work. In fact, I would be surprised if it
ever worked at all. I really doubt that
$bitfile = param("bitfile");
would return an open filehandle. I could be wrong, but from what I
understand, files are uploaded through STDIN, in a multipart/form-data
MIME format.
Simplest would be to use CGI.pm for this, or at least check out how
CGI.pm does it. Look at the code, at lines 380-391, and 2838-2911
(roughly, depends on the version). For lighterweight alternative
modules, check out CGI::Lite, CGI::Minimal, and maybe some more.
--
Bart.
------------------------------
Date: Sat, 18 Nov 2000 09:19:14 GMT
From: xlr6drone@my-deja.com
Subject: sendmail with cgi.pm?
Message-Id: <8v5hih$738$1@nnrp1.deja.com>
I am using a guestbook script with cgi.pm but I am unable to get
the sendmail program to work. I want the users inputted data to
be sent to an email address. The sendmail function is at the
bottom of my code. It has worked with other scripts but obviously
cgi.pm works differently in this area. Would I have to use the
param() in order to use the variables in the sendmail program? If
so how would this be done? Any suggestions would be
appreciated.
best,
Tim
#!/usr/bin/perl
# guestbook.pl
use CGI qw/:standard :html3 :netscape/;
use POSIX;
@REQUIRED = qw/name e-mail/;
@OPTIONAL = qw/location comments/;
$TIMEOUT = 10; # allow up to 10 seconds for waiting on a locked
guestbook
$GUESTBOOKFILE = "guestbookfile.txt";
%ENTITIES = ('&'=>'&', '>'=>'>', '<'=>'<', '\"'=>'"' );
print header,
start_html('Guestbook'),
h1("Guestbook");
$_ = param('action');
CASE: {
/^sign/i and do { sign_guestbook(); last CASE; };
/^confirm/i and do { write_guestbook() and view_guestbook();
last CASE; };
/^view/i and do { view_guestbook(); last CASE; };
# default
generate_form();
}
####
#moved lock subr up
####
sub LOCK_SH { 1 }
sub LOCK_EX { 2 }
sub LOCK_UN { 8 }
sub lock {
my $path = shift;
my $for_writing = shift;
my ($lock_type,$path_name,$description);
if ($for_writing) {
$lock_type = LOCK_EX;
$path_name = ">>$path";
$description = 'writing';
} else {
$lock_type = LOCK_SH;
$path_name = $path;
$description = 'reading';
}
local($msg,$oldsig);
my $handler = sub { $msg='timed out'; $SIG{ALRM}=$oldsig; };
($oldsig,$SIG{ALRM}) = ($SIG{ALRM},$handler);
alarm($TIMEOUT);
open (FH,$path_name) or
warn("Couldn't open $path for $description: $!"), return undef;
# now try to lock it
unless (flock (FH,$lock_type)) {
warn("Couldn't get lock for $description (" . ($msg || "$!") . ")");
alarm(0);
close FH;
return undef;
}
alarm(0);
return FH;
}
sub unlock {
my $fh = shift;
flock($fh,LOCK_UN);
close $fh;
}
sub sign_guestbook {
my @missing = check_missing(param());
if (@missing) {
print_warning(@missing);
generate_form();
return undef;
}
my @rows;
foreach (@REQUIRED,@OPTIONAL) {
push(@rows,TR(th({-align=>
LEFT},$_),td(escapeHTML(param($_)))));
}
print "Here is your guestbook entry. Press ",
em('Confirm')," to save it, or ",em('Change'),
" to change it.",
hr,
table(@rows),
hr;
print start_form;
foreach (@REQUIRED,@OPTIONAL) {
print hidden(-name=>$_);
}
print submit(-name=>'action',
-value=>'Change Entry'),
submit(-name=>'action',
-value=>'Confirm Entry'),
end_form;
}
print end_html;
sub check_missing {
my (%p);
grep (param($_) ne '' && $p{$_}++,@_);
return grep(!$p{$_},@REQUIRED);
}
sub print_warning {
print font({-color=>'red'},
'Please fill in the following fields: ',
em(join(', ',@_)),
'.');
}
sub generate_form {
print start_form,
table(
TR({-align=>LEFT},
th('Your name'),
td(textfield(-name=>'name',-size=>50))
),
TR({-align=>LEFT},
th('Your e-mail address'),
td(textfield(-name=>'e-mail',-size=>50))
),
TR({-align=>LEFT},
th('Your city (optional)'),
td(textfield(-name=>'location',-size=>50))
),
TR({-align=>LEFT},
th('Your state (optional)'),
td(textfield(-name=>'state',-size=>50))
),
TR({-align=>LEFT},
th('Your subject (optional)'),
td(textfield(-name=>'subject',-size=>50))
),
TR({-align=>LEFT},
th('Comments (optional)'),
td(textarea(-name=>'comments',-rows=>4,
-columns=>50,
-wrap=>1))
)
),
br,
submit(-name=>'action',-value=>'View Guestbook'),
submit(-name=>'action',-value=>'Sign Guestbook'),
end_form;
}
sub write_guestbook {
my $fh = lock($GUESTBOOKFILE,1);
unless ($fh) {
print strong('Sorry, an error occurred: unable to open
guestbook file.'),p();
Delete('action');
print a({-href=>self_url},'Try again');
return undef;
}
my $date = strftime('%D',localtime);
print $fh join("\t",$date,map {CGI::escape(param($_))}
(@REQUIRED,@OPTIONAL)),"\n";
print $fh "\n";
print "Thank you, ",param('name'),", for signing the guestbook.\
n",
p(),
a({href=>"../source.html"},'Code Examples');
unlock($fh);
1;
}
sub view_guestbook {
print start_form,
submit(-name=>'Sign Guestbook'),
end_form
unless param('name');
my $fh = lock($GUESTBOOKFILE,0);
my @rows;
unless ($fh) {
print strong('Sorry, an error occurred: unable to open
guestbook file.'),br;
Delete('action');
print a({-href=>self_url},'Try again');
return undef;
}
while (<$fh>) {
chomp;
my @data = map {CGI::unescape($_)} split("\t");
foreach (@data) { $_ = escapeHTML($_); }
unshift(@rows,td(\@data));
}
unshift(@rows,th(['Date',@REQUIRED,@OPTIONAL]));
print table({-border=>''},
caption(strong('Previous Guests')),
TR(\@rows));
print p,a({href=>"../source.html"},'Code Examples');
1;
}
sub escapeHTML {
my $text = shift;
$text =~ s/([&\"><])/$ENTITIES{$1}/ge;
return $text;
}
####
#sendmail
####
open (MAIL, "|/usr/lib/sendmail -t") || &ErrorMessage("error
opening sendmail");
print MAIL "To: lex\@mindspring.com\n";
print MAIL "From: test\@mail.com\n";
print MAIL "Subject: $subject\n\n";
print MAIL "$location\n\n";
close (MAIL);
Sent via Deja.com http://www.deja.com/
Before you buy.
------------------------------
Date: Sat, 18 Nov 2000 07:55:45 GMT
From: fhinchey@my-deja.com
Subject: Re: string checking problem
Message-Id: <8v5cm0$364$1@nnrp1.deja.com>
sorry,
$logo refers to an image file being read from an images directory. it
has the format "example.gif". the sorted array consists of items read
from a text file "clients.txt" with the following code:
$file1 = 'clients.txt';
open(INFO, $file1) || die "can't open $file1: $!";
$entry=<INFO>
($contractor, $extra, $address1, $address2, $contact, $phone, $fax,
$class, $email, $webpage, $logo) = split(/\t/,$entry);
i then pull the logo filename into an array and sort them with this
code:
$dir = "../web/images/logos";
opendir(FOO, $dir) || die "Error: can't open directory $dir: $!";
while ($file = readdir(FOO)) {
push @list, $file;
}
@sorted = sort{uc($a) cmp uc($b)}@list;
Does this give you enough to go on? BTW, a weird thing is sometimes
this code actually works, then it stops working (on the same file
name). it's really frustrating!
-Frank
In article <x74s15g91v.fsf@home.sysarch.com>,
Uri Guttman <uri@sysarch.com> wrote:
> >>>>> "f" == fhinchey <fhinchey@my-deja.com> writes:
>
> f> I can't seem to get the following code to work properly..
>
> define 'properly'
>
> f> chomp $logo;
> f> foreach $item (@sorted) {
> f> chomp $item;
> f> if ($item eq $logo){
> f> print "<option selected>$item \n";
> f> }
> f> else{
> f> print "<option>$item \n";
> f> }
> f> }
>
> f> I want to be able to test weather $logo and $item names match.
If they
> f> do I want it to come up seleted. I've tried it with and without
the
> f> chomp and it doesn't work. Can anyone help?
>
> you should show some input data and what the html out looks like. the
> code looks ok just by looking at it. saying code doesn't work is not a
> useful thing. instead show the broken results and the expected
results.
>
> 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
>
Sent via Deja.com http://www.deja.com/
Before you buy.
------------------------------
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 4916
**************************************