[26233] in Perl-Users-Digest

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

Perl-Users Digest, Issue: 8418 Volume: 10

daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Wed Sep 14 14:05:21 2005

Date: Wed, 14 Sep 2005 11:05:06 -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, 14 Sep 2005     Volume: 10 Number: 8418

Today's topics:
    Re: FAQ 9.16 How do I decode a CGI form? <segraves_f13@mindspring.com>
    Re: FAQ 9.16 How do I decode a CGI form? <sherm@dot-app.org>
    Re: FAQ 9.16 How do I decode a CGI form? xhoster@gmail.com
    Re: FAQ 9.16 How do I decode a CGI form? <babacio@free.fr>
    Re: FAQ 9.16 How do I decode a CGI form? <sherm@dot-app.org>
    Re: FAQ 9.16 How do I decode a CGI form? <segraves_f13@mindspring.com>
    Re: FAQ 9.16 How do I decode a CGI form? xhoster@gmail.com
    Re: File Modification Date <vma_nntp@vmacs.us>
    Re: Open variable txt file <1usa@llenroc.ude.invalid>
    Re: Open variable txt file <no@email.com>
    Re: Open variable txt file <flavell@ph.gla.ac.uk>
    Re: Open variable txt file <1usa@llenroc.ude.invalid>
        Opening many txt files <tony@heagren.com>
    Re: Opening many txt files <1usa@llenroc.ude.invalid>
    Re: Opening many txt files <tony@heagren.com>
    Re: Opening many txt files <sherm@dot-app.org>
        Digest Administrivia (Last modified: 6 Apr 01) (Perl-Users-Digest Admin)

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

Date: Wed, 14 Sep 2005 15:14:45 GMT
From: "Bill Segraves" <segraves_f13@mindspring.com>
Subject: Re: FAQ 9.16 How do I decode a CGI form?
Message-Id: <F7XVe.11560$9i4.3348@newsread2.news.atl.earthlink.net>

"PerlFAQ Server" <comdog@panix.com> wrote in message
news:dg87dk$fu5$1@reader1.panix.com...
<snip>>
>             my $total = param( "price" ) + param( "shipping" );
>
>             my @items = param( "item ); # multiple values, same field name

should be

               my @items = param( "item"); # multiple values, same field
name

--
Bill Segraves




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

Date: Wed, 14 Sep 2005 11:51:34 -0400
From: Sherm Pendley <sherm@dot-app.org>
Subject: Re: FAQ 9.16 How do I decode a CGI form?
Message-Id: <m28xxzve9l.fsf@Sherm-Pendleys-Computer.local>

"Bill Segraves" <segraves_f13@mindspring.com> writes:

> "PerlFAQ Server" <comdog@panix.com> wrote in message
> news:dg87dk$fu5$1@reader1.panix.com...
> <snip>>
>>             my $total = param( "price" ) + param( "shipping" );
>>
>>             my @items = param( "item ); # multiple values, same field name
>
> should be
>
>                my @items = param( "item"); # multiple values, same field
> name

Well, actually it should be:

    my @items = param('item'); #multiple values, same field

It's not difficult to see why newbies persist in (ab)using double quotes every-
where, when even the FAQ does it. :-(

sherm--

-- 
Cocoa programming in Perl: http://camelbones.sourceforge.net
Hire me! My resume: http://www.dot-app.org


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

Date: 14 Sep 2005 15:58:07 GMT
From: xhoster@gmail.com
Subject: Re: FAQ 9.16 How do I decode a CGI form?
Message-Id: <20050914115807.082$CQ@newsreader.com>

Sherm Pendley <sherm@dot-app.org> wrote:
> "Bill Segraves" <segraves_f13@mindspring.com> writes:
>
> > "PerlFAQ Server" <comdog@panix.com> wrote in message
> > news:dg87dk$fu5$1@reader1.panix.com...
> > <snip>>
> >>             my $total = param( "price" ) + param( "shipping" );
> >>
> >>             my @items = param( "item ); # multiple values, same field
> >>             name
> >
> > should be
> >
> >                my @items = param( "item"); # multiple values, same
> > field name
>
> Well, actually it should be:
>
>     my @items = param('item'); #multiple values, same field
>
> It's not difficult to see why newbies persist in (ab)using double quotes
> every- where, when even the FAQ does it. :-(

Why is it abusive to use double quotes in that manner?

Xho

-- 
-------------------- http://NewsReader.Com/ --------------------
Usenet Newsgroup Service                        $9.95/Month 30GB


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

Date: Wed, 14 Sep 2005 18:02:22 +0200
From: Babacio <babacio@free.fr>
Subject: Re: FAQ 9.16 How do I decode a CGI form?
Message-Id: <m2wtljeiy9.fsf@baba.ba>

xhoster@gmail.com.

>> Well, actually it should be:
>>
>>     my @items = param('item'); #multiple values, same field
>>
>> It's not difficult to see why newbies persist in (ab)using double quotes
>> every- where, when even the FAQ does it. :-(
>
> Why is it abusive to use double quotes in that manner?

Because you should use double quotes only if you want variable
replacement? 
-- 
Bé erre hue ixe eu elle, Bruxelles.


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

Date: Wed, 14 Sep 2005 12:28:24 -0400
From: Sherm Pendley <sherm@dot-app.org>
Subject: Re: FAQ 9.16 How do I decode a CGI form?
Message-Id: <m2slw7txzr.fsf@Sherm-Pendleys-Computer.local>

xhoster@gmail.com writes:

> Sherm Pendley <sherm@dot-app.org> wrote:
>> "Bill Segraves" <segraves_f13@mindspring.com> writes:
>>
>> > "PerlFAQ Server" <comdog@panix.com> wrote in message
>> > news:dg87dk$fu5$1@reader1.panix.com...
>> >>
>> >>             my @items = param( "item ); # multiple values, same field
>> >>             name
>> >
>> > should be
>> >
>> >                my @items = param( "item"); # multiple values, same
>> > field name
>>
>> Well, actually it should be:
>>
>>     my @items = param('item'); #multiple values, same field
>>
>> It's not difficult to see why newbies persist in (ab)using double quotes
>> every- where, when even the FAQ does it. :-(
>
> Why is it abusive to use double quotes in that manner?

To me, it's a minor nit; there are far, far worse abuses of Perl. ;-) Some
folks make a huge deal of it though.

Regardless of how severe an issue you think it is, the idea is the same:
Double quotes are a mental "flag" that tell the reader that something is
being interpolated. Using them for a constant non-interpolated string can
be misleading.

sherm--

-- 
Cocoa programming in Perl: http://camelbones.sourceforge.net
Hire me! My resume: http://www.dot-app.org


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

Date: Wed, 14 Sep 2005 17:30:57 GMT
From: "Bill Segraves" <segraves_f13@mindspring.com>
Subject: Re: FAQ 9.16 How do I decode a CGI form?
Message-Id: <l7ZVe.12248$FW1.382@newsread3.news.atl.earthlink.net>

"Sherm Pendley" <sherm@dot-app.org> wrote in message
news:m28xxzve9l.fsf@Sherm-Pendleys-Computer.local...
> "Bill Segraves" <segraves_f13@mindspring.com> writes:
>
> > "PerlFAQ Server" <comdog@panix.com> wrote in message
> > news:dg87dk$fu5$1@reader1.panix.com...
> > <snip>>
> >>             my $total = param( "price" ) + param( "shipping" );
> >>
> >>             my @items = param( "item ); # multiple values, same field
name
> >
> > should be
> >
> >                my @items = param( "item"); # multiple values, same field
> > name
>
> Well, actually it should be:
>
>     my @items = param('item'); #multiple values, same field
>
> It's not difficult to see why newbies persist in (ab)using double quotes
every-
> where, when even the FAQ does it. :-(

IMO, the issue Sherm raises is a different, but valid, issue.

I was merely pointing out a syntax error, i.e., a missing string terminator.
The type of string terminator, i.e., double or single quote, is irrelevant
to this (syntax) problem as long as the types match.

As you can plainly see the compiler produces similar error messages for both
unterminated double and single quotes, e.g.,

Double - Can't find string terminator '"' anywhere before EOF at faq916.pl
line 5.

Single - Can't find string terminator "'" anywhere before EOF at faq916.pl
line 5.

In addition, the compiler is smart enough to use unambiquous quoting in its
own diagnostic messages. ;-)

Cheers.
--
Bill Segraves




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

Date: 14 Sep 2005 17:41:39 GMT
From: xhoster@gmail.com
Subject: Re: FAQ 9.16 How do I decode a CGI form?
Message-Id: <20050914134139.263$a6@newsreader.com>

Babacio <babacio@free.fr> wrote:
> xhoster@gmail.com.
>
> >> Well, actually it should be:
> >>
> >>     my @items = param('item'); #multiple values, same field
> >>
> >> It's not difficult to see why newbies persist in (ab)using double
> >> quotes every- where, when even the FAQ does it. :-(
> >
> > Why is it abusive to use double quotes in that manner?
>
> Because you should use double quotes only if you want variable
> replacement?

What if you don't want variable replacement, but rather want \n
replacement, \t replacement, or if you want literal single quotes to be
left alone?  Sure, the number of \n, \t, and q{'} in this string does
happen to be zero; but that happenstance is a poor reason to change my
double quotes to single quotes.

Maybe I do want, in general, variable interpolation.  But, in this
particular case, the number of variables I want replaced happens to be
equal to zero. Why should I have to change my quoting style whenever I
change the number of variable interpolations from zero to non-zero (or
back)?

Obviously, the same argument works the other way, "why should I avoid
single quotes just because the number of $ that need to be taken literally
happens to be equal to zero?".  That is why I wouldn't label either singles
or doubles in this context as an abuse.  Which would be better to use
depends on what types of changes are likely to occur to the code in the
future.

Xho

-- 
-------------------- http://NewsReader.Com/ --------------------
Usenet Newsgroup Service                        $9.95/Month 30GB


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

Date: Wed, 14 Sep 2005 11:42:15 -0600
From: "Vance M. Allen" <vma_nntp@vmacs.us>
Subject: Re: File Modification Date
Message-Id: <biZVe.12$4V2.1990@news.uswest.net>

Sorry for the confusion; for this project, I needed the modification date, 
but if anyone knows how to get the creation date too, that's great.  I'm 
using the standard ext3 filesystem.

I was successful through the help provided here to get the modification 
date/time.  Thanks for everyone's input.

Vance


"Tad McClellan" <tadmc@augustmail.com> wrote in message 
news:slrndig6ml.30j.tadmc@magna.augustmail.com...
Vance M. Allen <vma_nntp@vmacs.us> wrote:

> Subject: File Modification Date
                ^^^^^^^^^^^^

> date and/or time that a file was
> created
  ^^^^^^^

> the file modified timestamp.
           ^^^^^^^^


Modified: 2
Created: 1

Which is it?

Many filesystems do not keep track of when a file is created.


> If anyone can help me with the libraries


You don't need _any_ libraries to get the modified time stamp:

   perldoc -f stat

see also:

   perldoc -f -X

and maybe:

   perldoc -f localtime


-- 
    Tad McClellan                          SGML consulting
    tadmc@augustmail.com                   Perl programming
    Fort Worth, Texas 




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

Date: Wed, 14 Sep 2005 15:33:58 +0000 (UTC)
From: "A. Sinan Unur" <1usa@llenroc.ude.invalid>
Subject: Re: Open variable txt file
Message-Id: <Xns96D175A91C991asu1cornelledu@132.236.56.8>

Tony Heagren <tony@big-giant-head.com> wrote in
news:2005091416045216807%tony@biggiantheadcom: 

> Is there a way to tell perl to open a txt file from a variable passed
> (in this case) from Flash.

We do not know anything about Flash here (and those of us who do, pretend 
not to :)

> ie instead of using this:
> open(FILE,">../www/folder/exact_filename.txt") or print
> "response=trouble"; 
> 
> could I use something like this:
> open(FILE,">$a_txt_file_name_passed_from_flash_as_a_variable") or
> print "response=trouble";


What happened when you tried it?

Why do you think it is a good idea to keep on going when the file open 
failed?

The variable name you are using is just too long for comfort.

open my $output, '>', $outfilename
  or die "Cannot open $outfilename: $!";

> All and any help much appreciated

Please read the posting guidelines for this group to learn how you can help 
yourself, and help others help you.

Sinan


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

Date: Wed, 14 Sep 2005 17:00:39 +0100
From: Brian Wakem <no@email.com>
Subject: Re: Open variable txt file
Message-Id: <3oqvp7F7a9s6U1@individual.net>

Tony Heagren wrote:

> Hi All,
> 
> new to this so forgive if this is a very obvious question.
> 
> Is there a way to tell perl to open a txt file from a variable passed
> (in this case) from Flash.
> 
> ie instead of using this:
> open(FILE,">../www/folder/exact_filename.txt") or print
> "response=trouble";
> 
> could I use something like this:
> open(FILE,">$a_txt_file_name_passed_from_flash_as_a_variable") or print
> "response=trouble";


You could, but don't.

What if someone passes in /etc/passwd ?

Pass in a number by all means, and have a hash that links it to a filename.

my %file = (
        1 => '/somefile',
        2 => '/someother-file',
);

if (!defined $file{$number_passed_in}) {
        print "FOAD!\n";
}
else {
        open (FILE, "> $file{$number_passed_in}") or die "Can't open
$file{$number_passed_in} - $!";
}


-- 
Brian Wakem
Email: http://homepage.ntlworld.com/b.wakem/myemail.png


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

Date: Wed, 14 Sep 2005 17:30:30 +0100
From: "Alan J. Flavell" <flavell@ph.gla.ac.uk>
Subject: Re: Open variable txt file
Message-Id: <Pine.LNX.4.62.0509141720060.838@ppepc56.ph.gla.ac.uk>

On Wed, 14 Sep 2005, A. Sinan Unur wrote:

> > could I use something like this:
> > open(FILE,">$a_txt_file_name_passed_from_flash_as_a_variable") or
> > print "response=trouble";
> 
> What happened when you tried it?

But this detail should be the least of his worries...

> Why do you think it is a good idea to keep on going when the file open 
> failed?

Fair comment.

> The variable name you are using is just too long for comfort.

But surely the variable name was just meant as a didactic example?

But it's *tainted*, and, as such, looks like a security hazard waiting 
to bite.

I'd start by emphasising the -T option and the reason for its 
existence.  *Even* if the argument is currently under the control
of the hon. Usenaut, my gut feeling is to treat it as unsafe until
proved otherwise.  The consequences of an accident could be severe.

> open my $output, '>', $outfilename
>   or die "Cannot open $outfilename: $!";

Something like that would be fine, but only after sanity-checking the 
argument, IMHO.

all the best


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

Date: Wed, 14 Sep 2005 17:14:43 +0000 (UTC)
From: "A. Sinan Unur" <1usa@llenroc.ude.invalid>
Subject: Re: Open variable txt file
Message-Id: <Xns96D186BD2A725asu1cornelledu@132.236.56.8>

"Alan J. Flavell" <flavell@ph.gla.ac.uk> wrote in 
news:Pine.LNX.4.62.0509141720060.838@ppepc56.ph.gla.ac.uk:

> On Wed, 14 Sep 2005, A. Sinan Unur wrote:
> 
>> > could I use something like this:
>> > open(FILE,">$a_txt_file_name_passed_from_flash_as_a_variable") or
>> > print "response=trouble";
>> 
>> What happened when you tried it?
> 
> But this detail should be the least of his worries...
> 
>> Why do you think it is a good idea to keep on going when the file open 
>> failed?
> 
> Fair comment.
> 
>> The variable name you are using is just too long for comfort.
> 
> But surely the variable name was just meant as a didactic example?
> 
> But it's *tainted*, and, as such, looks like a security hazard waiting 
> to bite.
> 
> I'd start by emphasising the -T option and the reason for its 
> existence.  *Even* if the argument is currently under the control
> of the hon. Usenaut, my gut feeling is to treat it as unsafe until
> proved otherwise.  The consequences of an accident could be severe.
> 
>> open my $output, '>', $outfilename
>>   or die "Cannot open $outfilename: $!";
> 
> Something like that would be fine, but only after sanity-checking the 
> argument, IMHO.

Agreed. I did not mean to disregard the security implications, but only 
answered the direct question.

Apologies for failing to point the OP to

perldoc perlsec

Basically, anything that deals with the big bad web needs to run in under 
taint mode (that is a necessary, not sufficient condition for security). 
In that case, you will find that you'll need to ensure that input passed 
to your program from the outside world has to be verified by your program 
before you can do certain things (such as open a file whose name has been 
passed to your script from the outside).

This is a good thing.

Thanks, Alan, for catching that.

Sinan



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

Date: Wed, 14 Sep 2005 15:33:58 GMT
From: Tony Heagren <tony@heagren.com>
Subject: Opening many txt files
Message-Id: <2005091416335875249%tony@heagrencom>

Hi all,

is there a way to tell perl to open a file whose name is passed
as a variable ?

i.e. instead of using this:


//open(FILE,">../www/folder/filename.txt") or print "sorted=trouble";


is there a way to use something like this :

//open(FILE,">../www/folder/$my_variable_passed_from_flash") or print 
"sorted=trouble";

where $my_variable_passed_from_flash is a precise file name.

The reason is that I have about 200 txt files each of which needs to be opened
and written to periodically and I don't want to have to create a 
seperate perl script
to handle each one - or to have to write all that code in flash.



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

Date: Wed, 14 Sep 2005 15:34:50 +0000 (UTC)
From: "A. Sinan Unur" <1usa@llenroc.ude.invalid>
Subject: Re: Opening many txt files
Message-Id: <Xns96D175CE96F89asu1cornelledu@132.236.56.8>

Tony Heagren <tony@heagren.com> wrote in
news:2005091416335875249%tony@heagrencom: 

> Hi all,
> 
> is there a way to tell perl to open a file whose name is passed
> as a variable ?

This is not a chat room. Post your question, and wait for responses.

Sinan

PS: By the way: *PLONK*


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

Date: Wed, 14 Sep 2005 15:43:19 GMT
From: Tony Heagren <tony@heagren.com>
Subject: Re: Opening many txt files
Message-Id: <2005091416432016807%tony@heagrencom>

Maybe it's the newsreader when I checked back
for responses my post had vanished.
So I posted it again from a different source.
Got a problem with that ?

This is not a chat room - neither is it your place to give lessons in 
etiquette.



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

Date: Wed, 14 Sep 2005 11:52:29 -0400
From: Sherm Pendley <sherm@dot-app.org>
Subject: Re: Opening many txt files
Message-Id: <m24q8nve82.fsf@Sherm-Pendleys-Computer.local>

Tony Heagren <tony@heagren.com> writes:

> is there a way to tell perl to open a file whose name is passed
> as a variable ?

We heard you the first time. Have you read the posting guidelines for this
group?

sherm--

-- 
Cocoa programming in Perl: http://camelbones.sourceforge.net
Hire me! My resume: http://www.dot-app.org


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

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


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