[29003] in Perl-Users-Digest

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

Perl-Users Digest, Issue: 247 Volume: 11

daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Wed Mar 21 11:10:09 2007

Date: Wed, 21 Mar 2007 08:09:09 -0700 (PDT)
From: Perl-Users Digest <Perl-Users-Request@ruby.OCE.ORST.EDU>
To: Perl-Users@ruby.OCE.ORST.EDU (Perl-Users Digest)

Perl-Users Digest           Wed, 21 Mar 2007     Volume: 11 Number: 247

Today's topics:
    Re: crontab -e doesnt seem to work <glennj@ncf.ca>
        how to new Table in a loop? <robertchen117@gmail.com>
    Re: how to new Table in a loop? <robertchen117@gmail.com>
    Re: how to new Table in a loop? <zen13097@zen.co.uk>
    Re: How to print on the special table cell column? <bik.mido@tiscalinet.it>
        I do not manage to read all the parameters since my cgi <john.swilting@wanadoo.fr>
    Re: I dotn understand this error <hackeras@gmail.com>
    Re: I dotn understand this error <bik.mido@tiscalinet.it>
    Re: Need help understanding how a file input block work <tester.paul@gmail.com>
        Net DNS Update problem <milneyboy@googlemail.com>
    Re: Net::Telnet Error handling/trapping <nospam@example.com>
    Re: Net::Telnet Error handling/trapping <uri@stemsystems.com>
    Re: On Java's Interface (the meaning of interface in co <lew@nospam.lewscanon.com>
    Re: On Java's Interface (the meaning of interface in co <web@pobox.com>
    Re: Perl/CGI file upload <gratemyl@gmail.com>
    Re: perl: adding lines and replacing stings <mritty@gmail.com>
        rss2twitter 0.1 <fabrizio@pivari.com>
        upload method not returning undef? <sukesh@zoom.co.uk>
        Digest Administrivia (Last modified: 6 Apr 01) (Perl-Users-Digest Admin)

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

Date: 21 Mar 2007 13:08:08 GMT
From: Glenn Jackman <glennj@ncf.ca>
Subject: Re: crontab -e doesnt seem to work
Message-Id: <slrnf02bho.s5p.glennj@smeagol.ncf.ca>

At 2007-03-21 12:40AM, "mihirshirali@gmail.com" wrote:
>  However now crontab -e wont let me do any editing.. I see the
>  following when I issue it:
>  crontab -e
>  65
>  
>  ?
>  
>  ?
> <snips>
>  Any help will be appreciated


    export EDITOR=vi
    crontab -e


-- 
Glenn Jackman
"You can only be young once. But you can always be immature." -- Dave Barry


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

Date: 21 Mar 2007 00:09:28 -0700
From: "robertchen117@gmail.com" <robertchen117@gmail.com>
Subject: how to new Table in a loop?
Message-Id: <1174460968.641307.33280@e1g2000hsg.googlegroups.com>

I want to new different table for different months in my hash, but the
new HTML::Table need to return a variable, I could not use $($table .
$month), what should I do?

foreach $month (sort keys %months_days) {
        @days = @{$months_days{$month}};
        if($#days > 0){
        #$mystring = "table" . $month;
        $table1 = new HTML::Table(-align=>'left',
           #-head=> ['Sunday', 'Monday', 'Tuesday', 'Wednesday',
'Thursday', 'Friday', 'Saturday'],
           -width=>'60%',
           #-align=>'center',
           -border=>0,
        );

        $table1->setCellAlign('center');
 ...
}



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

Date: 21 Mar 2007 00:11:15 -0700
From: "robertchen117@gmail.com" <robertchen117@gmail.com>
Subject: Re: how to new Table in a loop?
Message-Id: <1174461075.089156.9800@e65g2000hsc.googlegroups.com>

On 3=D4=C221=C8=D5, =CF=C2=CE=E73=CA=B109=B7=D6, "robertchen...@gmail.com" =
<robertchen...@gmail.com>
wrote:
> I want to new different table for different months in my hash, but the
> new HTML::Table need to return a variable, I could not use $($table .
> $month), what should I do?
>
> foreach $month (sort keys %months_days) {
>         @days =3D @{$months_days{$month}};
>         if($#days > 0){
>         #$mystring =3D "table" . $month;
>         $table1 =3D new HTML::Table(-align=3D>'left',
>            #-head=3D> ['Sunday', 'Monday', 'Tuesday', 'Wednesday',
> 'Thursday', 'Friday', 'Saturday'],
>            -width=3D>'60%',
>            #-align=3D>'center',
>            -border=3D>0,
>         );
>
>         $table1->setCellAlign('center');
> ...
>
>
>
> }- =D2=FE=B2=D8=B1=BB=D2=FD=D3=C3=CE=C4=D7=D6 -
>
> - =CF=D4=CA=BE=D2=FD=D3=C3=B5=C4=CE=C4=D7=D6 -

I mean tables, not just one table.



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

Date: 21 Mar 2007 11:20:12 GMT
From: Dave Weaver <zen13097@zen.co.uk>
Subject: Re: how to new Table in a loop?
Message-Id: <460114ec$0$27103$db0fefd9@news.zen.co.uk>

robertchen117@gmail.com <robertchen117@gmail.com> wrote:
>  I want to new different table for different months in my hash, but the
>  new HTML::Table need to return a variable, I could not use $($table .
>  $month), what should I do?

Use a hash.

    my %table;

>  foreach $month (sort keys %months_days) {
>          @days = @{$months_days{$month}};
>          if($#days > 0){
>          #$mystring = "table" . $month;
>          $table1 = new HTML::Table(-align=>'left',

           $table{ $month } = new HTML::Table(-align=>'left',

>             #-head=> ['Sunday', 'Monday', 'Tuesday', 'Wednesday',
>  'Thursday', 'Friday', 'Saturday'],
>             -width=>'60%',
>             #-align=>'center',
>             -border=>0,
>          );
> 
>          $table1->setCellAlign('center');

           $table{ $month }->setCellAlign('center');




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

Date: Wed, 21 Mar 2007 10:57:36 +0100
From: Michele Dondi <bik.mido@tiscalinet.it>
Subject: Re: How to print on the special table cell column?
Message-Id: <330203p0rsppqk60lait0k9cpnbjigrit1@4ax.com>

On 20 Mar 2007 20:33:09 -0700, "robertchen117@gmail.com"
<robertchen117@gmail.com> wrote:

> print $cgi->start_table({-border=>0});
>	print "<tr align=\"left\">";

Two things:

(1) why are you mixing literal HTML and CGI.pm's methods. I see cases
in which this would be convenient, just not this one, in which it's
plainly inelegant.

(2) You can use alternate deliters to improve readability anyway:

	print qq{<tr align="left">};

(In this particular case you may and probably *should* use single
quotes altogether, since you don't need interpolating nor special
escapes.)

>	print $cgi->th('Sunday');
>	print $cgi->th('Monday');
>	print $cgi->th('Tuesday');
>	print $cgi->th('Wensday');
>	print $cgi->th('Thursday');
>	print $cgi->th('Friday');
>	print $cgi->th('Saturday');

You can use CGI.pm's *distributive* properties for a cleaner syntax:

  print $c->th([qw/Sunday Monday Tuesday Wensday Thursday Friday
Saturday/]);


Michele
-- 
{$_=pack'B8'x25,unpack'A8'x32,$a^=sub{pop^pop}->(map substr
(($a||=join'',map--$|x$_,(unpack'w',unpack'u','G^<R<Y]*YB='
 .'KYU;*EVH[.FHF2W+#"\Z*5TI/ER<Z`S(G.DZZ9OX0Z')=~/./g)x2,$_,
256),7,249);s/[^\w,]/ /g;$ \=/^J/?$/:"\r";print,redo}#JAPH,


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

Date: Wed, 21 Mar 2007 08:41:49 +0100
From: "john.swilting" <john.swilting@wanadoo.fr>
Subject: I do not manage to read all the parameters since my cgi
Message-Id: <4600e1be$0$27375$ba4acef3@news.orange.fr>

the parameters which come from the gallery photographs to order and the
number of the image are well read by the cgi

but when I filled the form. I read only the field addresses
my site is almost finished .help me please

my code
#!/usr/bin/perl -w
use diagnostics;
use strict;
use CGI qw(:standard escapeHTML);
use CGI::Carp qw(fatalsToBrowser);

my %params;
my $cgi;
my $key;
my $image;
my $action;
my $length_tableau;
my @key;
my @action;
$cgi = new CGI;
%params = $cgi->Vars;
for $key(sort keys %params){
##    $action = $key;
##    $image = $params{$key};
    push(@key , $key);
    push(@action , $params{$key});
    }
      
print header,
      start_html('Commande'),
      h1('Bon de Commande'),
      start_form,
          pre ( p ("Nom:              ",textfield("nom")),
                p ("Adresse:          ",textfield("adresse")),
                p ("Ville:            ",textfield("ville")),
                p ("Code Postal:      ",textfield("code_postal")),
                p ("Pays:             ",textfield("pays")),
                p ("Telephone:        ",textfield("teléphone")),
                p ("E-mail :          ",textfield("mail")),
                p(""),
               p("vous
desirer",tt(escapeHTML($key[0])),"l'image",tt(escapeHTML($action[0]))),
               p("debug",tt(escapeHTML(@key)),tt(escapeHTML(@action)))),
      submit,
      end_form,
      end_html;




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

Date: 21 Mar 2007 02:42:01 -0700
From: "=?utf-8?B?zp3Or866zr/Pgg==?=" <hackeras@gmail.com>
Subject: Re: I dotn understand this error
Message-Id: <1174470121.643807.15540@l77g2000hsb.googlegroups.com>

Peter J. Holzer wrote:

I invoke it through firefox liek http://10.0.0.2

here is the whole code if you can see the error that would be good, i
cant and although its syntactically correct my web server wont even
ruin it.



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

Date: Wed, 21 Mar 2007 13:44:43 +0100
From: Michele Dondi <bik.mido@tiscalinet.it>
Subject: Re: I dotn understand this error
Message-Id: <11a2031b12pn54pq1lboq0kn4q9rl51f3s@4ax.com>

On 21 Mar 2007 02:42:01 -0700, "?????" <hackeras@gmail.com> wrote:

>Peter J. Holzer wrote:
>
>I invoke it through firefox liek http://10.0.0.2

No, that's not what PJH wrote. Please do not strip quoting so
drastically.

>here is the whole code if you can see the error that would be good, i

Where is it?

>cant and although its syntactically correct my web server wont even
>ruin it.

Huh?!?


Michele
-- 
{$_=pack'B8'x25,unpack'A8'x32,$a^=sub{pop^pop}->(map substr
(($a||=join'',map--$|x$_,(unpack'w',unpack'u','G^<R<Y]*YB='
 .'KYU;*EVH[.FHF2W+#"\Z*5TI/ER<Z`S(G.DZZ9OX0Z')=~/./g)x2,$_,
256),7,249);s/[^\w,]/ /g;$ \=/^J/?$/:"\r";print,redo}#JAPH,


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

Date: 21 Mar 2007 07:48:43 -0700
From: "Paul" <tester.paul@gmail.com>
Subject: Re: Need help understanding how a file input block works
Message-Id: <1174488523.396156.259070@o5g2000hsb.googlegroups.com>

Wow!  Thank you so much for taking the time to respond to my post with
such a detailed response.  That was great and *very* helpful.

On Mar 20, 7:44 pm, Ben Morrow wrote:
> > 11:                        $overview++;
> > 12:                        $bin = \@overview;
>
> This line I don't understand the purpose of. Is $bin assigned a ref to
> some...
>

After reading your reply about reference/dereference expressions, I
now understand what the script is trying to do.

In my original post, I included a sample of what the input file looks
like.  Basically, it's a normal text file with a bunch of sections
that have headings in ALL CAPS followed by a dash line separator.  The
sample code that I posted only had the first 'if' block in it, but the
actual script contains about 5 of these 'if' blocks.  (They all look
about the same, just the variables change.)

So, when the $line matches a particular section heading, the $bin
variable is referenced to the desired array variable (e.g. line 12).
Then when it gets to the end, it pushes the $line into the correct
array variable (line 17).  That line 12 reference assignment changes
in each section, so basically the script is trying to be efficient in
the way it's dumping each line into the correct, desired array
variable.

Essentially, it parses each section from the input file into a
different array variable.  I get it now.  Maybe not some of the fiddly
bits still, but enough to know what I'm doing now.

Thank you all for your terrific responses.  I'm glad that I decided to
post to this news group.

All the best!  Cheers.  Paul. =)



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

Date: 21 Mar 2007 06:58:18 -0700
From: "milney_boy" <milneyboy@googlemail.com>
Subject: Net DNS Update problem
Message-Id: <1174485497.997991.78490@l75g2000hse.googlegroups.com>

Hello,

I'm trying to write a script to update records on my BIND server.  To
start with I am writing a simple script to add and delete A records.

I want to be able to have multiple A records with the same hostname/
alias but with different IP addresses.  When it comes to deleting
them, I want to use the yxrrset to make sure the exact record exists
first (so that i know if for some reason it does not exist).

The problem is that whilst the value-dependant yxrrset seems to work
correctly when there is only a single A record with the same hostname/
alias, it always reports nxrrset when there is more than one.

I have cut my code right down to try and get to the bottom of it, but
it is still not working:

----------------------------------------------
#!/usr/bin/perl -w
user Net::DNS;

my $update = Net::DNS::Update->new("mydomain.com");

$update->push("pre", yxrrset("two.mydomain.com A 212.212.31.212"));

my $res = Net::DNS::Resolver->new;
$res->nameserver("ns1.mydnshost.com");

my $reply = $res->send($update);
print $reply->header->string . "\n";
----------------------------------------------

When nslookup shows:
Name: two.mydomain.com
Address: 212.212.31.212
Output is:
;; id = 45744
;; qr = 1   opcode = UPDATE    rcode = NOERROR
;; zocount = 0  prcount = 0  upcount = 0   adcount = 0

When nslookup shows:
Name: two.mydomain.com
Address: 212.212.31.212
Name: two.mydomain.com
Address: 212.212.31.213
Output is:
;; id = 28698
;; qr = 1   opcode = UPDATE    rcode = NXRRSET
;; zocount = 0  prcount = 0  upcount = 0   adcount = 0

Any ideas on why this might be?  It seems that the second you add
multiple records the value-dependany yxrrset does not match any of the
records.

I've tried adding the TTL into the yxrrset statement but still no luck.



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

Date: Wed, 21 Mar 2007 07:48:47 -0700
From: "Chris G." <nospam@example.com>
Subject: Re: Net::Telnet Error handling/trapping
Message-Id: <460145d5$0$97216$892e7fe2@authen.yellow.readfreenews.net>

I am sorry that the group is so intolerant of top-posting, but how I
post it my choice, just others have a choice to respond or not.  This is
not a flame, just a statement of fact.  In the interest of not further
polluting the ng with non-perl postings, this is the last I will comment
on it.  Let's just agree to disagree and move on.

Regards,

Chris


Uri Guttman wrote:
>>>>>> "CG" == Chris G <nospam@example.com> writes:
> 
>   CG> I appreciate your concern over my posting habits, but I prefer
>   CG> top-posting and that's my client's default setting.  That setting
>   CG> controls both email and newsgroup replies, so changing it isn't really
>   CG> an option.  Sorry.
> 
> and you will lose many of the regulars here who will killfile you. and
> there is NO default setting called top posting. it is just where the
> editor leaves the cursor after you quote a post. is it so hard for you
> to move the cursor down? do you have RSI? are you brain dead? do you
> care about what others think? or the extra work you make others do? or
> breaking longstanding guidelines in the group? did you learn anything in
> kindergarten? 
> 
> uri
> 


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

Date: Wed, 21 Mar 2007 10:07:23 -0500
From: Uri Guttman <uri@stemsystems.com>
Subject: Re: Net::Telnet Error handling/trapping
Message-Id: <x7lkhqfxec.fsf@mail.sysarch.com>

>>>>> "CG" == Chris G <nospam@example.com> writes:

  CG> I am sorry that the group is so intolerant of top-posting, but how I
  CG> post it my choice, just others have a choice to respond or not.  This is
  CG> not a flame, just a statement of fact.  In the interest of not further
  CG> polluting the ng with non-perl postings, this is the last I will comment
  CG> on it.  Let's just agree to disagree and move on.

it is not intolerant. it has been know for decades that interpersed
edited quotes are much better for technical discussion as they are
commonly q&a. do you want answers before the questions? not all posts
are received in the same order so it is better to read top down as
english is normally written. this group has kept these basic usenet
rules and encourages them. individuals will decide to killfile those who
deliberately top post as you want to do. it is your choice to step on
the toes here and not anyone else's. it is not a case of agreeing to
disagree but your choosing to not adhere to the groups guidelines. it is
all on you. enjoy the fact that you will just get less and worse help
than if you didn't top post. is that something you want to tradeoff? it
is like choosing a class with a stupid but lenient teacher vs one with a
much smarter but stricter one. you want a useless teacher or kingsfield
from the paper chase?

uri

-- 
Uri Guttman  ------  uri@stemsystems.com  -------- http://www.stemsystems.com
--Perl Consulting, Stem Development, Systems Architecture, Design and Coding-
Search or Offer Perl Jobs  ----------------------------  http://jobs.perl.org


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

Date: Wed, 21 Mar 2007 08:53:05 -0400
From: Lew <lew@nospam.lewscanon.com>
Subject: Re: On Java's Interface (the meaning of interface in computer programing)
Message-Id: <BMmdneR6mfcvt5zbnZ2dnUVZ_rCsnZ2d@comcast.com>

Xah Lee wrote:
> In a functional language, a function can be specified by its name and

Are you sure you know what a "functional language" is?

> parameter specs. For example:
> f(3)
> f(3, [9,2])
> f("some string")

This is not really "typical" syntax for a functional language. LISP, for 
example, has the "function name" as an element of a list. (Some might argue 
that LISP isn't exactly a functional language.)

Also, since you are commenting on Java, you should use "Java-like" syntax 
rather than "[9,2]". What is "[9,2]" intended to represent? The range of 
integers decreasing from 9 to 2, inclusive?

> For another example, usually a program needs to talk to another
> software such as a database software. 

Interesting use of the word "software".

> In essence, making the database useful to other software.

This is not a sentence.

> Such a list of function spec is often called API, which stands for Application
> Programing Interface.

"an API"

> The API terminology is abused by the marketing-loving Sun Microsystems
> by calling the Java language's documentation as “The Java API”, even
> though Java the language and its paraphernalia of libraries and
> hardware-emulation system (all together jargonized as “the Java
> Platform”) isn't a Application nor Interface. (a [sic] API implies that
> there are two disparate entities involved, which are allowed to
> communicate thru [sic] it. In the case of “The Java API”, it's one entity
> talking to itself.).

This is incorrect in every factual detail. And what's with the editorial 
comment in the middle of the exposition ("marketing-loving", "jargonized")? 
How does that help explain the concepts, even if it were supportable by the 
evidence?

Sun calls the API documentation "the Java API documentation", not "the Java 
API", and not the language documentation, and the API is indeed an interface. 
An API need not be, and quite often is not, an application - being an 
application is in no wise part of being an API. And why in the world did you 
capitalize "Application" and "Interface"?

It's "an API", not "a API". It's "through", not "thru".

The statement about an "API" having to do with "two disparate entities" makes 
no sense. There is certainly nothing in the API that one can characterize as 
"one entity talking to itself". What "entities" do you imagine are involved?

> In general, the interface concept in programing is a sort of
> specification that allows different entities to call and make use of
> the other [sic], with the implication that the caller need not know what's
> behind the facade.

There is no antecedent for "the other", and you haven't defined "entities", 
and the word "interface" has a number of meanings "in general ... in 
programming". You should focus on the Java meaning (and your grammar).

> In the Object Oriented Programing Paradigm [sic], a new concept arose, that
> is the “interface” aspect of a class.

Historical citation needed. And an interface is not an "aspect of a class".

> As we've seen, a function has parameter spec [sic] that is all there it [sic] is a
> user needs to know for using it. In Java, this is the method's
> “signature”. Now, as the methodology of the OOP experience multiplies,
> it became apparent that the interface concept can be applied to
> Classes as well. Specifically: the interface of a class is the class's
> methods.

OK, I've had enough. I'd say you need a good editor to clean up the grammar, 
but then all you'd have is a better-written incorrect explanation.

-- Lew


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

Date: 21 Mar 2007 06:34:37 -0700
From: "Dr. Who" <web@pobox.com>
Subject: Re: On Java's Interface (the meaning of interface in computer programing)
Message-Id: <1174484076.994815.89820@y66g2000hsf.googlegroups.com>

Don't Feed The Trolls :-)



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

Date: 21 Mar 2007 02:52:24 -0700
From: "Jerome" <gratemyl@gmail.com>
Subject: Re: Perl/CGI file upload
Message-Id: <1174470744.141746.234670@o5g2000hsb.googlegroups.com>

On Mar 20, 10:50 pm, Keith Keller <kkeller-use...@wombat.san-
francisco.ca.us> wrote:
> On 2007-03-20, Jerome <grate...@gmail.com> wrote:
>
>
>
> > I have looked at the upload function, but as far as I see it requires
> > me to specify a field name - I need to do this for all fields of
> > "type" file.
>
> Okay...so now look for "FETCHING THE NAMES OF ALL THE PARAMETERS
> PASSED TO YOUR SCRIPT:".  And please try to do at least some of your own
> work yourself; that's all the pointers you're getting from me, at least,
> until you show some of your own effort.
>
> Have you read the Posting Guidelines that are posted here frequently?
>
> --keith
>
> --
> kkeller-use...@wombat.san-francisco.ca.us
> (try just my userid to email me)
> AOLSFAQ=http://www.therockgarden.ca/aolsfaq.txt
> see X- headers for PGP signature information

That pointer was brilliant, thanks a lot! I think I figured it out now!



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

Date: 21 Mar 2007 07:17:14 -0700
From: "Paul Lalli" <mritty@gmail.com>
Subject: Re: perl: adding lines and replacing stings
Message-Id: <1174486634.556736.326800@l77g2000hsb.googlegroups.com>

On Mar 20, 7:38 pm, Tad McClellan <t...@augustmail.com> wrote:
> Ben Morrow <b...@morrow.me.uk> wrote:
> > Yes, of course... and there I thought I was being so clever :(.
> > Ach well.
>
> But at least you took the heat that I would have gotten, as I was
> going to suggest the same thing.  :-)

I did the same thing too - I just tested it before I posted. :-P

Paul Lalli



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

Date: 21 Mar 2007 07:12:02 -0700
From: "Fabrizio Pivari" <fabrizio@pivari.com>
Subject: rss2twitter 0.1
Message-Id: <1174486322.196616.311810@l77g2000hsb.googlegroups.com>

What is rss2twitter?
http://www.pivari.com/rss2twitter.html
rss2twitter is a freeware perl tool (we distribute also a Windows
excutable) to send to Twitter (batch) the links and the posts of a
RSS. I decide to develop it because I've a lot of blogs with Blogger
and I like the wordpress Twitter pluging of Alex King.

If you like the tool we like your donations ;)
http://www.pivari.com/rss2twitter.html#donate

Configure and run rss2twitter
At the moment rss2twitter is a command line and works in the same way
on every OS supported by perl
rss2twitter [-options] (or perl rss2twitter.pl [-options]
where options include:
-help to print the line help
-verbose to print verbose messages
-version to print version
-debug to help to debug
-configure file to use a specific configuration file (the default is
rss2twitter.cfg in the same directory of the executable)


rss2twitter uses the file rss2twitter.cfg as its configuration file.
This file must reside in the same directory as the rss2twitter file,
since it searches for this file at runtime. You can create your own
rss2twitter.cfg file and use it with -configure option.
Inside this file, you can change the values for the user, password,
feed
To change any of these values, you just need to edit rss2twitter.cfg.
You can also create a new .cfg file and tell rss2twitter to read it at
runtime, using the -configure yourfile.cfg option.
With user and password you have to set your Twitter user and password.
With feed you can set the RSS feed to download.
rss2twitter will make a file named xxxxxxxx.r2t where xxxxxxxx is the
user you have set in rss2twitter.cfg. rss2twitter will use this file
to send to twitter only the new posts. DON'T DELETE IT.
Pay attention: send posts to Twitter is very slow so run rss2twitter
with -verbose to verify it is working.



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

Date: 21 Mar 2007 02:37:18 -0700
From: "Suk" <sukesh@zoom.co.uk>
Subject: upload method not returning undef?
Message-Id: <1174469838.851886.18260@d57g2000hsg.googlegroups.com>

Hi

I'm tinkering with a simple file upload script

I want to be sure that if a user enters an invalid filename (i.e one
that doesnt exist) in a webform an error is returned. In the CGI
documentation it says the upload( ) method should return undef for an
invalid filehandle, but I cant seem to get this to work:

Here is the script im using:-

#!/usr/local/bin/perl
use strict;
use warnings;
use CGI qw(:standard);

our $upload_dir = "/tmp";
our $filename;
our $upload_filehandle;
our $message="Thank you";

$filename = param("file");
$filename =~ s/.*[\/\\](.*)/$1/;

$upload_filehandle = upload("file");

die "Invalid filehandle" if (!defined($upload_filehandle));

open UPLOADFILE, ">$upload_dir/$filename";

binmode UPLOADFILE;

while ( <$upload_filehandle> )
{
  print UPLOADFILE;
}

close UPLOADFILE;

print header;
print <<END_HTML;
<HTML>
<HEAD>
<TITLE>Thank you for your upload</TITLE>
<script type="text/javascript">
        alert("$message");
</script>
</HEAD>
<BODY>
</BODY>
</HTML>
END_HTML

The "die" seems to be ignored, and I get an empty file in /tmp if I
enter a non-existent file in the webform?



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

Date: 6 Apr 2001 21:33:47 GMT (Last modified)
From: Perl-Users-Request@ruby.oce.orst.edu (Perl-Users-Digest Admin) 
Subject: Digest Administrivia (Last modified: 6 Apr 01)
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: due to the current flood of worm email banging on ruby, the smtp
server on ruby has been shut off until further notice. 

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 V11 Issue 247
**************************************


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