[23360] in Perl-Users-Digest

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

Perl-Users Digest, Issue: 5579 Volume: 10

daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Sun Sep 28 09:05:39 2003

Date: Sun, 28 Sep 2003 06:05: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           Sun, 28 Sep 2003     Volume: 10 Number: 5579

Today's topics:
    Re: authentication <bob_smith85@hotmail.com>
    Re: authentication <jwillmore@cyberia.com>
        basics <king21122@yahoo.com>
    Re: basics <krahnj@acm.org>
    Re: date in hash keys & sorting <king21122@yahoo.com>
    Re: date in hash keys & sorting <noreply@gunnar.cc>
        genkey function ??? <king21122@yahoo.com>
    Re: genkey function ??? <spam@thecouch.homeip.net>
    Re: hash reference as a hash key (Steve)
    Re: making hash of arrays (Andres Monroy-Hernandez)
    Re: making hash of arrays <krahnj@acm.org>
    Re: perl makefile.pl --help <king21122@yahoo.com>
    Re: perl makefile.pl --help (Jay Tilton)
    Re: Plugin Framework <pkent77tea@yahoo.com.tea>
    Re: POD docs and ANSI escapes <kalinaubears@iinet.net.au>
        sort problem <recoverer@lycos.de>
    Re: sort problem (Greg Bacon)
        Splitting subroutines out of a file <FirstName.LastNameWithUnderscoreForSpace@Pandora.Be.RemoveThis>
    Re: Splitting subroutines out of a file <nospam_for_jkeen@concentric.net>
        Uploading files using CGI.pm <notavailable@nospamplease.com>
        use strict with an undeclared variable <kuujinbo@hotmail.com>
    Re: use strict with an undeclared variable (Greg Bacon)
    Re: Using modules on server <bart.lateur@pandora.be>
    Re:  <bwalton@rochester.rr.com>
        Digest Administrivia (Last modified: 6 Apr 01) (Perl-Users-Digest Admin)

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

Date: Sun, 28 Sep 2003 08:58:49 +0300
From: Bob Smith <bob_smith85@hotmail.com>
Subject: Re: authentication
Message-Id: <3F767899.C6C026AE@hotmail.com>

James Willmore wrote:

> On Sat, 27 Sep 2003 15:24:17 +0300
> Bob Smith <bob_smith85@hotmail.com> wrote:
>
> > hiya all
> > could some kind sole give some guidance as how to implement user
> > authentication for a perl web app running mysql RDBMS.
> > some pointers in the correct direction would be *nighly*
> > appreciated.( did have a look at www::authenticate but don't know if
> > it is good or not. )
>
> Go to http://www.w3c.org/Security/Faq/www-security-faq.html and read
> it over.  This is a good "primer" on web security.
>
> Also look over persec to get a better idea of security in relation to
> Perl.
>
> Then look over the DBI module's documentation.
>
> If you have more specific questions after that, post them here.

thank's jim for the link and info. As the subject of network security is
large I prefer to make the approach in small steps, so for now I am only
interested in validating users properly.
so if anyone has information as to how to validate users visiting the
site I'd be grateful. thank's
/B

>
>
> HTH
>
> --
> Jim
>
> Copyright notice: all code written by the author in this post is
>  released under the GPL. http://www.gnu.org/licenses/gpl.txt
> for more information.
>
> a fortune quote ...
> If I had any humility I would be perfect.   -- Ted Turner



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

Date: Sun, 28 Sep 2003 08:00:21 GMT
From: James Willmore <jwillmore@cyberia.com>
Subject: Re: authentication
Message-Id: <20030928040019.03d8201f.jwillmore@cyberia.com>

On Sun, 28 Sep 2003 08:58:49 +0300
Bob Smith <bob_smith85@hotmail.com> wrote:
> James Willmore wrote:
> > On Sat, 27 Sep 2003 15:24:17 +0300
> > Bob Smith <bob_smith85@hotmail.com> wrote:
<snip>
> thank's jim for the link and info. As the subject of network
> security is large I prefer to make the approach in small steps, so
> for now I am only interested in validating users properly.
> so if anyone has information as to how to validate users visiting
> the site I'd be grateful. thank's
> /B

Again, read the DBI documentation.  Your question is answered there.

Most, if not all script I've written/seen validate one user on the
server side.  The forms that are presented are designed to guide the
user to update some/all fields in a database -or- allow users to
browse - all under one account.  To do user validation and database
access is no small affair.

The "quick and dirty" way to do it is use an Apache module designed to
maintain state between pages or htaccess.  Passed that, you may get a
better answer in a CGI authoring newsgroup.

-- 
Jim

Copyright notice: all code written by the author in this post is
 released under the GPL. http://www.gnu.org/licenses/gpl.txt 
for more information.

a fortune quote ...
The fortune program is supported, in part, by user contributions 
and by a major grant from the National Endowment for the
Inanities. 


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

Date: Sun, 28 Sep 2003 14:58:09 +1000
From: King <king21122@yahoo.com>
Subject: basics
Message-Id: <3F766A61.8070208@yahoo.com>

Hello
what is the different between
my %hash;
and
my %hash = ();
with examples

thanks



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

Date: Sun, 28 Sep 2003 08:01:38 GMT
From: "John W. Krahn" <krahnj@acm.org>
Subject: Re: basics
Message-Id: <3F76953B.2BD7D9C4@acm.org>

King wrote:
> 
> what is the different between
> my %hash;
> and
> my %hash = ();

Nothing, except one is longer.


John
-- 
use Perl;
program
fulfillment


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

Date: Sun, 28 Sep 2003 14:11:51 +1000
From: King <king21122@yahoo.com>
Subject: Re: date in hash keys & sorting
Message-Id: <3F765F87.5070308@yahoo.com>

Gunnar Hjalmarsson wrote:
> Sam wrote:
> 
>> one of the problems I am facing is converting the date, the result
>> are
>> 2002124 for 2002-Jan-24
>> 2002124 for 2002-Dec-4
>> that sorting will not work, any idea is appriciated
> 
> 
> Check out the sprintf() function. Example:
> 
>     @dates = ('2002-Jan-24', '2002-Dec-4');
> 
>     %months = ( Jan => 1, Feb => 2, Mar => 3, Apr => 4,
>                 Maj => 5, Jun => 6, Jul => 7, Aug => 8,
>                 Sep => 9, Oct => 10, Nov => 11, Dec => 12 );
> 
>     @sortabledates = map { sprintf '%d%02d%02d',
>         map { /[a-z]{3}/i ? $months{$_} : $_ } split /-/
>     } @dates;
> 

Gunnar.
your code is a bit challenging for me. what do ? and : do in the inside 
map block? I am trying to understand you code.

thanks




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

Date: Sun, 28 Sep 2003 09:27:19 +0200
From: Gunnar Hjalmarsson <noreply@gunnar.cc>
Subject: Re: date in hash keys & sorting
Message-Id: <bl62p2$8aaa4$1@ID-184292.news.uni-berlin.de>

King wrote:
> Gunnar Hjalmarsson wrote:
>> Sam wrote:
>>> one of the problems I am facing is converting the date, the
>>> result are
>>> 2002124 for 2002-Jan-24
>>> 2002124 for 2002-Dec-4
>>> that sorting will not work, any idea is appriciated
>>
>> Check out the sprintf() function. Example:
>>
>>     @dates = ('2002-Jan-24', '2002-Dec-4');
>>
>>     %months = ( Jan => 1, Feb => 2, Mar => 3, Apr => 4,
>>                 Maj => 5, Jun => 6, Jul => 7, Aug => 8,
>>                 Sep => 9, Oct => 10, Nov => 11, Dec => 12 );
>>
>>     @sortabledates = map { sprintf '%d%02d%02d',
>>         map { /[a-z]{3}/i ? $months{$_} : $_ } split /-/
>>     } @dates;
> 
> Gunnar.
> your code is a bit challenging for me. what do ? and : do in the
> inside map block?

http://www.perldoc.com/perl5.8.0/pod/perlop.html#Conditional-Operator

> I am trying to understand you code.

Okay.. For some reason, I assumed an array with a number of dates that 
you wanted to convert. This code, that gives the same result, may be 
easier to follow:

     @dates = ('2002-Jan-24', '2002-Dec-4');

     foreach $date (@dates) {
         push @sortabledates, dateconvert($date);
     }

     sub dateconvert {
         my $date = shift;
         my %months = (
             Jan => 1, Feb => 2, Mar => 3, Apr => 4,
             May => 5, Jun => 6, Jul => 7, Aug => 8,
             Sep => 9, Oct => 10, Nov => 11, Dec => 12
         );
         my ($year, $month, $day) = split /-/, $date;
         $month = $months{$month};
         return sprintf '%d%02d%02d', $year, $month, $day;
     }

-- 
Gunnar Hjalmarsson
Email: http://www.gunnar.cc/cgi-bin/contact.pl



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

Date: Sun, 28 Sep 2003 14:40:08 +1000
From: King <king21122@yahoo.com>
Subject: genkey function ???
Message-Id: <3F766628.3060003@yahoo.com>

what is this function about and why isn't there any mention to it in the 
Kamel book?



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

Date: Sun, 28 Sep 2003 01:40:19 -0400
From: Mina Naguib <spam@thecouch.homeip.net>
Subject: Re: genkey function ???
Message-Id: <2vudb.44628$So6.1236313@weber.videotron.net>

-----BEGIN xxx SIGNED MESSAGE-----
Hash: SHA1

King wrote:
> what is this function about and why isn't there any mention to it in the 
> Kamel book?
> 

I've never heard of the Kamel book.

Also genkey is not a built-in perl function.

Could you be possibly looking at Perl source code that calls genkey() ? Have you considered the 
possibility that this function might be defined somewhere else in the file, in an included file, or 
in a module used by your program ?

A quick googling of "perl genkey" hints that this might be part of the OpenCA::OpenSSL package.


-----BEGIN xxx SIGNATURE-----
Version: GnuPG v1.2.1 (GNU/Linux)
Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org

iD8DBQE/dnRFeS99pGMif6wRAkyaAKD6gkefrnnk6qlSezwVvim1ob77gACcCIK/
B8xXtqFuvoA79pI7m3ZNvl4=
=wJdc
-----END PGP SIGNATURE-----



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

Date: 28 Sep 2003 03:49:29 -0700
From: ineverlookatthis@yahoo.com (Steve)
Subject: Re: hash reference as a hash key
Message-Id: <f0d57f86.0309280249.641330f3@posting.google.com>

Steve Grazzini <grazz@pobox.com> wrote in message news:<axldb.9078$yU5.7723@nwrdny01.gnilink.net>...
> Steve <ineverlookatthis@yahoo.com> wrote:
> > >refs as keys are a fine thing as long as the ref itself is also in the
> > >value part (either the value itself or inside someother structure which
> > >is the value).
> > 
> > Do you mean I could add a value such as 
> > $eachDNA->{uniqueaddress} = $eachDNA; 
> > and then use that as a hash key ?
> 
> That's a circular reference, so it's not the ideal solution.
> 

oops I meant to say $eachDNA->{uniqueaddress} = "$eachDNA";

> > I can see how that is better than what I am presently doing, but not
> > fundamentally different. I can of course ensure that the hashref will
> > remain in existence, but does that mean that it won't change its value
> > when stringified ?
> 
> Yes.  Unless you bless() the reference, the stringified form will
> stay the same until the object is destroyed.

OK, I will relax,

Thanks

Steve


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

Date: 27 Sep 2003 21:53:54 -0700
From: andres@monroy.com (Andres Monroy-Hernandez)
Subject: Re: making hash of arrays
Message-Id: <3591b31a.0309272053.6860e620@posting.google.com>

Hi Harpreet,

Hash values must be scalars. What I think you should do is a hash of
array references. Try doing this:

%dir_struct = ( "directory01" => \("user01", "group01", "755"),
                 "directory02" => \("user02", "group02", "777"),
                 );

Hope it helps.

Cheers,
-Andres


Harpreet Dhillon <jattspirit@yahoo.com> wrote in message news:<BLndb.152$8v4.25125030@newssvr13.news.prodigy.com>...
> Hello All,
>    I am newbie to perl. I need to make a hash of arrays. Can someone please
> explaing how I can do that ? I tried to do the following but it didn't
> worked.
> 
> %dir_struct = ( "directory01" => ("user01", "group01", "755"),
>                 "directory02" => ("user02", "group02", "777"),
>                 );
> 
> As you can see above, I am trying to create a directory structure and need
> to store the information in some kind of array which will include user
> name, group name, permissions and may be other information. If you know any
> better way to do the same without making use of any database, please let me
> know.
> 
> Appreciate your help,
> Harpreet


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

Date: Sun, 28 Sep 2003 08:00:11 GMT
From: "John W. Krahn" <krahnj@acm.org>
Subject: Re: making hash of arrays
Message-Id: <3F7694E3.64830AF9@acm.org>

Andres Monroy-Hernandez wrote:
> 
> Hi Harpreet,
> 
> Hash values must be scalars. What I think you should do is a hash of
> array references. Try doing this:
> 
> %dir_struct = ( "directory01" => \("user01", "group01", "755"),
>                  "directory02" => \("user02", "group02", "777"),
>                  );
> 
> Hope it helps.

It might if that were actually a hash of array references.  What you
have is list of eight elements, six of which are references to scalars,
which looks like this:

%dir_struct = ( "directory01", \"user01", \"group01", \"755",
                "directory02", \"user02", \"group02", \"777",
                 );


John
-- 
use Perl;
program
fulfillment


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

Date: Sun, 28 Sep 2003 15:04:41 +1000
From: King <king21122@yahoo.com>
Subject: Re: perl makefile.pl --help
Message-Id: <3F766BE9.7030207@yahoo.com>

Tony Curtis wrote:
>>>On Sun, 28 Sep 2003 09:09:20 +1000,
>>>King <king21122@yahoo.com> said:
>>
> 
>>what is perl makefile.pl does and why the switch --help
>>is putting out $perl makefile.pl --help
>>Can't open perl script "makefile.pl": No such file or directory
> 
> 
> Isn't it self-explanatory?  There's no such file.
> 
> hth
> t

maybe I should explain.
I am trying to follow the instruction at 
http://tiny-tools.sourceforge.net/README.html#quick_install_personal to 
install TinyTools for emacs.
the instruction says at point 1.6

       % cd bin/
       % perl makefile.pl --help
       % perl makefile.pl --binary emacs --verbose 2  dos2unix all
                          |                           +======= ===
         All command line options must                |
         come BEFORE build options                    |
                                                      |
                                 Two build options here

since it gives me the results as indicated in my first post. does that 
impley that I have to copy the file makefile.pl to the bin/?

thanks



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

Date: Sun, 28 Sep 2003 09:13:35 GMT
From: tiltonj@erols.com (Jay Tilton)
Subject: Re: perl makefile.pl --help
Message-Id: <3f769fb3.258528287@news.erols.com>

King <king21122@yahoo.com> wrote:
: Tony Curtis wrote:
: >>>On Sun, 28 Sep 2003 09:09:20 +1000,
: >>>King <king21122@yahoo.com> said:
: > 
: >>Can't open perl script "makefile.pl": No such file or directory
: > 
: > Isn't it self-explanatory?  There's no such file.
: > 
: I am trying to follow the instruction at 
: http://tiny-tools.sourceforge.net/README.html#quick_install_personal to 
: install TinyTools for emacs.
: the instruction says at point 1.6
: 
:        % cd bin/

Surely that means to cd into the bin/ directory created during the
unpacking phase.

: does that 
: impley that I have to copy the file makefile.pl to the bin/?

No, you're just in the wrong bin.

This is not really a Perl issue.  It's an issue with the application and
its instructions; Perl is only incidentally involved.



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

Date: Sun, 28 Sep 2003 11:30:07 +0100
From: pkent <pkent77tea@yahoo.com.tea>
Subject: Re: Plugin Framework
Message-Id: <pkent77tea-526A8B.11300728092003@pth-usenet-02.plus.net>

In article <Pine.SOL.4.56.0309271955050.5161@pollux.cse.Buffalo.EDU>,
 Vikas <vvikas@cse.buffalo.edu> wrote:

> I have been programming in Perl for long and at number of places I come
> across modules which say they follow a plugin framework and anyone can
> plug their plugins (codes) into their software.
> 
> Can anyone give me pointers as to how to develop such a software which
> supports plugin framework . I mean can I read articles or tutorials about
> it somewhere?

I don't know of any good tutorials etc on the subject but here's what 
general info I've learnt about such plugin architectures from building 
and using them:

* plugins are loaded on demand
* plugins are generally best modelled as classes, so you load the plugin 
class and instantiate a plugin object of that class
* plugins conform to a specified API. Some methods may be mandatory, 
some may be optional, and so on, but there must be some standard to work 
with
* the API can be as simple or as complex as you need. One class of 
plugins I wrote has one constructor method (returns a new object), and 
one object method (returns 1 or 0) :-)
* Inheritance can be very useful. E.g. an X::Y factory class produces 
X::Y::Foo and X::Y::Bar (etc..) objects, and those objects inherit some 
methods from X::Y, maybe things such as debugging routines, file I/O, 
and so on.
 
If you've got any more details about the kind of plugins and application 
you want to write there's probably some more specific pointers.

P

-- 
pkent 77 at yahoo dot, er... what's the last bit, oh yes, com
Remove the tea to reply


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

Date: Sun, 28 Sep 2003 14:36:13 +1000
From: Sisyphus <kalinaubears@iinet.net.au>
Subject: Re: POD docs and ANSI escapes
Message-Id: <3f7665f1$0$23608$5a62ac22@freenews.iinet.net.au>

Steve Grazzini wrote:
> James Willmore <jwillmore@cyberia.com> wrote:
> 
>>On Sat, 27 Sep 2003 22:29:36 +1000
>>Sisyphus <kalinaubears@iinet.net.au> wrote:
>>
>>>Hi,
>>>On my linux box 'perldoc' (but not 'man') is failing to interpret
>>>the ANSI escapes. How do I remedy this ?
>>>

>>
>>The "quick fix" is to run perldoc with the '-t' option.
> 
> 
> You can also set the LESS environment variable to "-r".
> 

Thanks guys.

Cheers,
Rob


-- 
To reply by email u have to take out the u in kalinaubears.



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

Date: Sun, 28 Sep 2003 13:02:34 +0200
From: hugo leitmeier <recoverer@lycos.de>
Subject: sort problem
Message-Id: <3f76bfcc@olaf.komtel.net>

Hi,

Problem:

Date		Name	Average	Number
----		----	-------	------
21.09.2003	Caesar	17.75	3748
15.08.2003	Anton	10.34	276
10.08.2003	Berta	15.38	138
27.08.2003	Anton	12.00	2765
29.08.2003	Anton	11.25	2766
10.08.2003	Caesar	10.00	374
12.08.2003	Caesar	15.75	3748



I like that. But, how can i accomplish that?

Date		Name	Average	Number
----		----	-------	------
15.08.2003	Anton	10.34	276
27.08.2003	Anton	12.00	2765
29.08.2003	Anton	11.25	2766
10.08.2003	Berta	15.38	138
10.08.2003	Caesar	10.00	374
12.08.2003	Caesar	15.75	3748
21.09.2003	Caesar	17.75	3748
----------	------	-----	----
3rd (asc)	1st(asc)	2nd(asc)

best regards

hugo



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

Date: Sun, 28 Sep 2003 11:42:22 -0000
From: gbacon@hiwaay.net (Greg Bacon)
Subject: Re: sort problem
Message-Id: <vndi8ubo1fjg05@corp.supernews.com>

In article <3f76bfcc@olaf.komtel.net>,
    hugo leitmeier  <recoverer@lycos.de> wrote:

: [...]
: I like that. But, how can i accomplish that?
: 
: Date		Name	Average	Number
: ----		----	-------	------
: 15.08.2003	Anton	10.34	276
: 27.08.2003	Anton	12.00	2765
: 29.08.2003	Anton	11.25	2766
: 10.08.2003	Berta	15.38	138
: 10.08.2003	Caesar	10.00	374
: 12.08.2003	Caesar	15.75	3748
: 21.09.2003	Caesar	17.75	3748
: ----------	------	-----	----
: 3rd (asc)	1st(asc)	2nd(asc)

    % cat try
    #! /usr/local/bin/perl

    use warnings;
    use strict;

    my @header;
    my @rows;

    while (<DATA>) {
        if (1 .. /^----/) {
            push @header => $_;
        }
        else {
            push @rows => $_;
        }
    }

    print @header,
          map $_->[0],
          sort {
              $a->[2] cmp $b->[2] ||
              $a->[3] <=> $b->[3] ||
              $a->[1] cmp $b->[1]
          }
          map [$_, (split)[0,1,3]],
          @rows;

    __DATA__
    Date            Name    Average Number
    ----            ----    ------- ------
    21.09.2003      Caesar  17.75   3748
    15.08.2003      Anton   10.34   276
    10.08.2003      Berta   15.38   138
    27.08.2003      Anton   12.00   2765
    29.08.2003      Anton   11.25   2766
    10.08.2003      Caesar  10.00   374
    12.08.2003      Caesar  15.75   3748
    % ./try
    Date            Name    Average Number
    ----            ----    ------- ------
    15.08.2003      Anton   10.34   276
    27.08.2003      Anton   12.00   2765
    29.08.2003      Anton   11.25   2766
    10.08.2003      Berta   15.38   138
    10.08.2003      Caesar  10.00   374
    12.08.2003      Caesar  15.75   3748
    21.09.2003      Caesar  17.75   3748

Hope this helps,
Greg
-- 
Government, even in its best state, is but a necessary evil; in its worst
state, an intolerable one.  Government, like dress, is the badge of lost
innocence; the palaces of kings are built upon the ruins of the bowers of
paradise.          -- Thomas Paine, "Common Sense"


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

Date: Sun, 28 Sep 2003 11:33:02 GMT
From: Jos De Laender <FirstName.LastNameWithUnderscoreForSpace@Pandora.Be.RemoveThis>
Subject: Splitting subroutines out of a file
Message-Id: <OFzdb.45397$rD4.2093151@phobos.telenet-ops.be>


Dear group ,

I'm in a hurry to split out a number of subroutines in a bunch of pl files.
(getting them in separate files)

I realize it is not rocket science , but getting everything right taking 
into account curly braces that may appear in the subroutine may lead me to 
a mini parsing routine.

Somebody knows about available routines or modules doing this ?

The autosplit comes near , but it works only on more or less correctly 
formed modules , which is not my case (ordinary perl files)

Thanks for any suggestions or help.

-- 
Jos De Laender


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

Date: 28 Sep 2003 12:43:20 GMT
From: "James E Keenan" <nospam_for_jkeen@concentric.net>
Subject: Re: Splitting subroutines out of a file
Message-Id: <bl6l18$7vi@dispatch.concentric.net>


"Jos De Laender"
<FirstName.LastNameWithUnderscoreForSpace@Pandora.Be.RemoveThis> wrote in
message news:OFzdb.45397$rD4.2093151@phobos.telenet-ops.be...
>
> I'm in a hurry to split out a number of subroutines in a bunch of pl
files.
> (getting them in separate files)
>
> I realize it is not rocket science , but getting everything right taking
> into account curly braces that may appear in the subroutine may lead me to
> a mini parsing routine.
>
Why?  Either these subroutines are currently operating correctly in your
main package (I hope that you are using both warnings and strict) -- in
which case they should work properly when imported -- or they are not.

> Somebody knows about available routines or modules doing this ?
>
> The autosplit comes near , but it works only on more or less correctly
> formed modules , which is not my case (ordinary perl files)
>
In Perl 5 (i.e., for the past 9 years), the standard, recommended way to
import subroutines into a main package has been to place them in a module
ending in a ".pm" extension and to use Exporter to designate which
subroutines are always inported into main, which are imported on request,
etc.  See 'perldoc perlmod'.  What is your rationale for planning to use a
deprecated procedure?




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

Date: Sun, 28 Sep 2003 12:55:22 +0100
From: "D Borland" <notavailable@nospamplease.com>
Subject: Uploading files using CGI.pm
Message-Id: <L_zdb.184$Rw3.69@newsfep1-gui.server.ntli.net>

Hi folks,

Can anyone see why this is not working, when i use the script on my web
hosting service, it returns success but no image has been uploaded when i
look in the uploads dir, just can't see why it's not working...

__CODE__

#!/usr/bin/perl

use CGI;
use CGI::Carp 'fatalsToBrowser';
use File::Basename;

my $query = new CGI;

my $uploadDir = 'uploads';
my $uploadFile = $query->upload('image1');
my $filename = basename $query->param('image1');

open (NEWFILE), ">$uploadDir/$filename"
  or die "Cannot open $uploadDir/$filename : $!\n";

binmode (NEWFILE);

while (<$uploadFile> ) {
    print NEWFILE;
}

close (NEWFILE);

print $query->header,
         $query->start_html('File Uploaded'),
         $query->p('Succesful upload'),
         $query->end_html;

__END__

Thanks for your time

Dagmar




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

Date: Sun, 28 Sep 2003 20:23:04 +0900
From: ko <kuujinbo@hotmail.com>
Subject: use strict with an undeclared variable
Message-Id: <bl6ge0$bra$1@pin3.tky.plala.or.jp>

I was looking for an efficient way to find the largest key (assuming all 
numeric keys) in a *large* hash and found an excellent solution here 
(sorry for the long link):

http://groups.google.com/groups?hl=en&lr=&ie=UTF-8&frame=right&th=f36fea95a112ca1f&seekm=01bd66cb%24a9542460%241ff8aecc%40direct.ca.direct.ca#link5

the relevant code:

foreach ($max = each %hash;
          defined ($a = each %hash);
          $max = $a if $a > $max) {}

Took me a while to figure it out - most of the time you see 'foreach' 
being shortened to 'for' instead of the other way around.

Anyway, there are two things I can't figure out.

1. If you're including the strict and warnings pragmas, why is it that 
you can get away with not declaring $a? I thought defined() might have 
something to do with it, but the docs only say that when used on a hash 
element it tells you whether the value is defined.

2. Is defined() necessary in the condition? The assignment of each key 
to $a returns true. I think there was a reference in the thread to why 
defined is used, but I didn't understand the explanation, so I'm not sure.

For anyone who might suggest sort() or iterating with keys() to 
accomplish the task, please follow the link above for explanations to 
why this method is more efficient.

Thanks in advance - keith



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

Date: Sun, 28 Sep 2003 11:50:26 -0000
From: gbacon@hiwaay.net (Greg Bacon)
Subject: Re: use strict with an undeclared variable
Message-Id: <vndio2ff4lpq75@corp.supernews.com>

In article <bl6ge0$bra$1@pin3.tky.plala.or.jp>,
    ko  <kuujinbo@hotmail.com> wrote:

: [...]
:
: 1. If you're including the strict and warnings pragmas, why is it that 
: you can get away with not declaring $a? [...]

The strict pragma's manpage says

    Because of their special use by sort(), the variables
    $a and $b are exempted from this check.

: 2. Is defined() necessary in the condition? The assignment of each key 
: to $a returns true. [...]

What if the hash contains a 0 key?

: [...]

Hope this helps,
Greg
-- 
The democracy will cease to exist when you take away from those who are
willing to work and give to those who would not.
    -- Thomas Jefferson


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

Date: Sun, 28 Sep 2003 06:58:41 GMT
From: Bart Lateur <bart.lateur@pandora.be>
Subject: Re: Using modules on server
Message-Id: <li1dnv05r0l8lf60sji88slgs0gjvco8gh@4ax.com>

D Borland wrote:

>I'm trying to use File::basename in a script rather than re-invent the wheel
>as such as i keep getting told.  But the hosting company i'm with don't have
>it on and aren't likely to install it for me. 

AFAIK File::Basename is, and has been for a long time, a core module,
meaning it comes with Perl. It looks like your ISP has been deleting
stuff.

-- 
	Bart.


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

Date: Sat, 19 Jul 2003 01:59:56 GMT
From: Bob Walton <bwalton@rochester.rr.com>
Subject: Re: 
Message-Id: <3F18A600.3040306@rochester.rr.com>

Ron wrote:

> Tried this code get a server 500 error.
> 
> Anyone know what's wrong with it?
> 
> if $DayName eq "Select a Day" or $RouteName eq "Select A Route") {

(---^


>     dienice("Please use the back button on your browser to fill out the Day
> & Route fields.");
> }
 ...
> Ron

 ...
-- 
Bob Walton



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

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.  

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 V10 Issue 5579
***************************************


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