[18123] in Perl-Users-Digest
Perl-Users Digest, Issue: 283 Volume: 10
daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Tue Feb 13 18:06:06 2001
Date: Tue, 13 Feb 2001 15:05:16 -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: <982105516-v10-i283@ruby.oce.orst.edu>
Content-Type: text
Perl-Users Digest           Tue, 13 Feb 2001     Volume: 10 Number: 283
Today's topics:
    Re: "Any" with Arrays egwong@netcom.com
    Re: "Any" with Arrays <kstep@pepsdesign.com>
    Re: cgi visitors check nobull@mail.com
    Re: directory structure <orycteropus@ntlworld.com>
    Re: FAQ 4.24:   How do I reformat a paragraph? <mischief@velma.motion.net>
    Re: FAQ 4.24:   How do I reformat a paragraph? <flavell@mail.cern.ch>
    Re: flock() strategy for Win95? - eval() etc <russ_jones@rac.ray.com>
        ftp permission denied, but perl works fine jk1138
    Re: Hashes of Arrays <ren.maddox@tivoli.com>
    Re: Hashes of Arrays <jdf@pobox.com>
    Re: Help Running  Perl Scripts from a web-page <tlav1@mediaone.net>
    Re: How do I translate a Cobol WORKING-STORAGE SECTION  <russ_jones@rac.ray.com>
        How to redirect output within Perl script? <rvl2@MailAndNews.com>
    Re: How to redirect output within Perl script? <jdf@pobox.com>
    Re: Locking files in a CGI script egwong@netcom.com
    Re: Locking files in a CGI script <kstep@pepsdesign.com>
        RE: Need help with an array <jgs2283@MailAndNews.com>
        Newbie Perl / CGI Question <bovvy@cableinet.co.uk>
        no headers using CGI.pm <jeff_fletcher@pacbell.net>
        Parsing file question <jdb@ga.prestige.net>
    Re: Parsing file question <jdb@ga.prestige.net>
        Digest Administrivia (Last modified: 16 Sep 99) (Perl-Users-Digest Admin)
----------------------------------------------------------------------
Date: Tue, 13 Feb 2001 19:08:10 GMT
From: egwong@netcom.com
Subject: Re: "Any" with Arrays
Message-Id: <uCfi6.58$Sx5.13157@news.flash.net>
PaAnWa <paul_wasilkoff@ucg.org> wrote:
[cut]
> Is there a way to do the
> following:
>
> if ($in{'Country'} eq ANY @Country) {action 1;}
Use Quantum::Superpositions 
  http://search.cpan.org/search?dist=Quantum-Superpositions
and your code will look almost exactly as you've written it.
A less elegant (but more common) solution is to use grep
  if ( grep { $in{Country} eq $_ } @Country ) { action 1; }
see the perlfunc manpage.
By the way, if you're not using CGI.pm, you ought to be.
Regards,
ERic
------------------------------
Date: Tue, 13 Feb 2001 14:28:23 -0500
From: "Kurt Stephens" <kstep@pepsdesign.com>
Subject: Re: "Any" with Arrays
Message-Id: <96c1ra$573$1@slb7.atl.mindspring.net>
"PaAnWa" <paul_wasilkoff@ucg.org> wrote in message
news:t8j0fqk1cqp39f@corp.supernews.com...
> I am working on a form-processing script.  In particular I am looking at a
> way of more efficiently evaluating the country field value.  For example,
if
> the country field equals Fiji or New Zealand or Tonga an email is sent to
> address1.  If the country field equals Canada an email is sent to address
2.
> If the country field is equal to Austria or Belgium or Denmark or
> Switzerland or France an email is sent to address3.  But if the country
> field is equal to USA or all other countries then a datafile is appended.
>
> How do I simplify the arguments to a)detect if an email should be sent and
> then b)to what address should the mail be sent.  Is there a way to do the
> following:
I would use a hash to associate the email address with the country.  If an
address exists, send the mail.  If not, update the file.  Since there are
more countries than email addresses in your case, perform a two-level lookup
where country codes are associated with regions and regions are associated
with addresses.
my %regions = (
    fj     => 'pacific',
    nz   => 'pacific',
    to    => 'pacific',
    ca   => 'canada',
    at    => 'europe',
    be    => 'europe',
    dk    => 'europe',
    us    => 'usa'
);
my %addresses = (
    pacific => 'pacific@somedomain.nz',
    canada => 'canada@somedomain.ca',
    europe => 'europe@somedomain.be'
);
my $cc = $cgi->param('country');
my $address = $addresses{$regions{$cc}};
if (defined $address) {
    # Send the email to $address
}
else {
    # Update the file
}
HTH,
Kurt Stephens
------------------------------
Date: 13 Feb 2001 19:02:48 +0000
From: nobull@mail.com
Subject: Re: cgi visitors check
Message-Id: <u9ofw6h0dj.fsf@wcl-l.bham.ac.uk>
Faycal Saffih <fsaffih@venus.uwaterloo.ca> writes:
> Cn anyone tell me how can I get my website visitors servers or emails?
To get information about the user there are a few approaches:
1) Make a form where they can type the the answer.  You probably need
   to offer them some reward for providing the information.
2) Write a program will execute on their computer and grab the
   information.  To get at private information you will either need to
   exploit a security flaw in their web client or somehow trick them
   into downloading and running your program.
2a) As two but tell them upfront that the purpose of your program is
   to disclose their private data to people you think diserve it.
3) Enroll your site in some sort of "web passport" program.  This is
   really a varient of (1) or (2a).
This has nothing whatever to do with Perl.
Note: option 2 is a criminal offence in many countries. 
-- 
     \\   ( )
  .  _\\__[oo
 .__/  \\ /\@
 .  l___\\
  # ll  l\\
 ###LL  LL\\
------------------------------
Date: Tue, 13 Feb 2001 20:36:06 -0000
From: "Ory" <orycteropus@ntlworld.com>
Subject: Re: directory structure
Message-Id: <zSgi6.18170$zz4.498463@news2-win.server.ntlworld.com>
Abigail writted:
> Walter Hafner asked:
> // I need to access a squid-like directory structure in round-robin.
> // If I have directories "/aa/" to /zz/, can anyone give me a convenient
> // way to access them? aa, ab, ... zz, aa, ab, ...
> //
> // I know how to do it with substrings etc. I just wanted a more elegant
> // solution. :-)
>
>     my @foo = ('aa' .. 'zz');
>     my $i   =   0;
>     while (1) {print "/$foo[($i+=1)%=@foo]/\n"}
Or, if you feel index variables aren't a Good Thing;
  my $foo = 'z';
  while (1) {($foo=++$foo)=~s/.(..)/$1/; print "/$foo/\n"}
Or even:
  my @foo = ('aa'..'zz');
  while (1) {push@foo,shift@foo; print "/$foo[-1]/\n"}
(Which also start in the right place. ;)
BTW, this is my first ever post to CLPM, even though I've been following it
on and off over a year. I've never had anything much worth saying (even this
post is contrived for the sake of it, really) and if you only snuffle about
in the archives and read the docs, 99.9% of questions already have answers
in any case.
But I did want to say a big Thank You to all those here who've shown me so
much stuff in that time. And it's been a lot of fun as well as teaching me
plenty.
And to those who think this group is a waste of time; if that's the way you
view it, then it probably is.
Ta,
    da 'Vark
--
print "No JAPH yet," ;
------------------------------
Date: Tue, 13 Feb 2001 21:57:21 -0000
From: Chris Stith <mischief@velma.motion.net>
Subject: Re: FAQ 4.24:   How do I reformat a paragraph?
Message-Id: <t8jbe1hqkfgrbe@corp.supernews.com>
Peter J. Acklam <jacklam@math.uio.no> wrote:
> PerlFAQ Server <faq@denver.pm.org> writes:
>> +
>>   How do I reformat a paragraph?
>> 
>>     Use Text::Wrap (part of the standard Perl distribution):
>> 
>>         use Text::Wrap;
>>         print wrap("\t", '  ', @paragraphs);
>> 
>>     The paragraphs you give to Text::Wrap should not contain embedded
>>     newlines. Text::Wrap doesn't justify the lines (flush-right).
>                                    ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
> Isn't there a difference between justified text and flush-right
> text?  I thought justified text was adjusted (i.e., stretched) so
> the text was aligned on both sides, whereas flush-right text is
> only aligned along the right side (with no stretching).
There's left justified, right justified, center justified (although
centering doesn't necessarily mean center justified), and then there's
what you're thinking of, which is fully justified. Full justification
is used when a document is meant to be pretty as well as informative. ;-)
> At least, this is how it is implemented in HTML/CSS.
You also have the options of left, right, and center without the
name "justify" attached to them. I've always, in the past, assumed
that "justify" unqualified meant left-justification. I guess I'll
have to change my thinking.
Chris
-- 
Christopher E. Stith
The purpose of a language is not to help you learn the
language, but to help you learn other things by using the
language. --Larry Wall, The Culture of Perl, August 1997
------------------------------
Date: Tue, 13 Feb 2001 23:37:18 +0100
From: "Alan J. Flavell" <flavell@mail.cern.ch>
Subject: Re: FAQ 4.24:   How do I reformat a paragraph?
Message-Id: <Pine.LNX.4.30.0102132328280.32545-100000@lxplus003.cern.ch>
On Tue, 13 Feb 2001, Chris Stith wrote:
> > Isn't there a difference between justified text and flush-right
> > text?  I thought justified text was adjusted (i.e., stretched) so
> > the text was aligned on both sides, whereas flush-right text is
> > only aligned along the right side (with no stretching).
>
> There's left justified, right justified, center justified (although
> centering doesn't necessarily mean center justified),
Well, it's often confusingly called that, but that's silly, because
the action of "justifying" a line is the incorporation of additional
space to make it a fixed length overall.
So left-aligned and right-aligned and centered lines are _not_
"justified", and it's confusing to term them so.  Whereas "justified"
lines are so-called because of the operation of justifying them, and
that's normally done for the purpose of getting them aligned on both
sides.
> and then there's
> what you're thinking of, which is fully justified.
That's "justified".
Take a look for example at the relevant terms in
http://www.smartbiz.com/sbs/arts/eyn3.htm or
http://www.gbltd.com/glossary.html
all the best
------------------------------
Date: Tue, 13 Feb 2001 13:51:53 -0600
From: Russ Jones <russ_jones@rac.ray.com>
Subject: Re: flock() strategy for Win95? - eval() etc
Message-Id: <3A899059.4F52D70D@rac.ray.com>
Matt Kruse wrote:
> 
> Godzilla! <godzilla@stomp.stomp.tokyo> wrote:
Dear Matt:
You know better than this. You're trying to teach a pig to sing.
-- 
Russ Jones - HP OpenView IT/Operatons support
Raytheon Aircraft Company, Wichita KS
russ_jones@rac.ray.com 316-676-0747
Te audire non possum. Musa sapientum fixa est in aure. - Plautus
------------------------------
Date: 13 Feb 2001 18:52:43 GMT
From: jk1138
Subject: ftp permission denied, but perl works fine
Message-Id: <96bvpr01iqq@news2.newsguy.com>
Here's the situation:
I wrote a Perl script that dynamically creates directories and files. I often need to personally modify these files or upload manually-created files, and I want to do this through an FTP client. Once I run the script below, however, I get a "553 Permission Denied" error whenever I try to access (delete, overwrite, rename, chmod, etc.) the dynamically-generated directories and files through FTP.
The relevant code is as follows:
	if (-d $makethis) {
		#Directory exists. Do Nothing
	} else {
		mkdir $makethis, "755" || die $!;
	}
	open(OUTFILE, "> $filename") || die $!;
	print OUTFILE "$outText"; 
	close(OUTFILE);
The code generates both the directories and files as expected (and chmods files and directories to 666 and 755, respectively). I have no problems modifying these files and directories through perl, but I need to be able to do that through FTP, as well.
I do not have Telnet access to my remotely-hosted server and I must use a login name and password to access FTP.
The question is: How do I change my code so that it allows my FTP account to make modifications to the files and directories that Perl dynamically generates?
==================================
Posted via http://nodevice.com
Linux Programmer's Site
------------------------------
Date: 13 Feb 2001 14:51:04 -0600
From: Ren Maddox <ren.maddox@tivoli.com>
Subject: Re: Hashes of Arrays
Message-Id: <m3n1bqs3wn.fsf@dhcp11-177.support.tivoli.com>
Todd Shoenfelt <tshoenfe@cisco.com> writes:
> use strict;
> 
> It will save you a lot of trouble with scoping issues like this.
While it is certainly good advice, and may even help find some other
problems, it does not help with this particular situation.
> > while (@row = $sth->fetchrow_array()){
> >     $user{$row[0]}{@job} = $row[1];
> > }
> 
> # Try:
> while ( my @row = $sth->fetchrow_array()) {
>     ...
> }
There are certainly times when failing to properly scope @row could
lead to all sorts of confusion, but this isn't one of them.  The value
is being replaced every time, but nothing is holding a reference to
the array, only copies, so this is not a problem.
-- 
Ren Maddox
ren@tivoli.com
------------------------------
Date: 13 Feb 2001 16:38:26 -0500
From: Jonathan Feinberg <jdf@pobox.com>
Subject: Re: Hashes of Arrays
Message-Id: <elx2b6wd.fsf@pobox.com>
rfoskett@my-deja.com writes:
> > while (@row = $sth->fetchrow_array()){
> >     $user{$row[0]}{@job} = $row[1];
> > }
> 
> it's using the last job id as you are specifying '@job' as a hashkey
> - which will convert to the last element in the @job array.
This is wrong. @job in a scalar context evaluates to the number of
elements in job.
-- 
Jonathan Feinberg   jdf@pobox.com   Sunny Brooklyn, NY
http://pobox.com/~jdf
------------------------------
Date: Tue, 13 Feb 2001 21:33:34 GMT
From: ted <tlav1@mediaone.net>
Subject: Re: Help Running  Perl Scripts from a web-page
Message-Id: <3A89D2E9.23601380@mediaone.net>
I don't know if it's free, but I'm pretty sure you can get at least a shareware
version of WS_FTP from http://www.tucows.com.  After you upload your perl script
to the server, highlight it on the server side of WS_FTP, right click, and select
"UNIX chmod" from the menu.  It will then ask you what permissions you'd like to
give the file.  Select all three for owner, read & execute for group, and read &
execute for world.  HOWEVER, depending on how the server is configured, this
sometimes doesn't work.  If it doesn't, the only other things I can suggest is to
telnet to your server and chmod it from the command line.  I don't use AOL so I
don't know if this is possible.  If that doesn't work, you may have to call AOL
and have them set the permissions for you.  Again, I don't know if AOL does this
kind of thing.
Also, another respondent pointed out a problem with wrong-facing slashes in your
shebang line.  I completely missed that!
Hope you get it working.  Please let me know what happens.
ted
Falc2199 wrote:
> >1) Did you upload your perl program as ASCII text?
> >2) Did you change permissions ( chmod ) on your perl program to 755 after you
> >uploaded it?
> >3) Make sure perl is where the shebang line says it is
> >4) You're missing the basic minimum HTML tags to create an HTML
>
> I am sure I got 1,3, and 4 covered. The only problem is changing the
> permissions.
> I am writing my scripts on a Windows platform, so I don't have to worry about
> it then.Only when my web-host runs my script on a UNIX server do they come into
> play.
>
>  I am not sure how you change permissions with my FTP service, if that is even
> where you change it.
>
> Can you point me in the direction of a free FTP app where you know how to
> change permissions, so you can tell me how it is done.
>
> Thanks,
> Jehan
------------------------------
Date: Tue, 13 Feb 2001 14:18:23 -0600
From: Russ Jones <russ_jones@rac.ray.com>
Subject: Re: How do I translate a Cobol WORKING-STORAGE SECTION into the format I  wanted?
Message-Id: <3A89968F.4CDB62A0@rac.ray.com>
jck1 wrote:
> 
> Sorry. I have poor English.  So, I can't explain what I want clearly. But I
> will try to do it.
much snipped
> As the story goes, we can generate the output data. It may look like the
> below statement.
> ==============================================================
> 01 IABC-R.
>                 03 IABC-F13                     PIC 9(07).
>                 03 IABC-F14 OCCURS 3 TIMES.
>                         05 IABC-AKLFJDKAS       PIC X(01).
>                         05 IABC-ZZZZZZZZ OCCURS 2 TIMES.
>                                 07 IABC-KKK     PIC 9(08).
>                                 07 IABC-ZZZ     PIC 9(01).
>                                 07 IABC-KKK     PIC 9(08).
>                                 07 IABC-ZZZ     PIC 9(01).
>                         05 IABC-AKLFJDKAS       PIC X(01).
>                         05 IABC-ZZZZZZZZ OCCURS 2 TIMES.
>                                 07 IABC-KKK     PIC 9(08).
>                                 07 IABC-ZZZ     PIC 9(01).
>                                 07 IABC-KKK     PIC 9(08).
>                                 07 IABC-ZZZ     PIC 9(01).
>                         05 IABC-AKLFJDKAS       PIC X(01).
>                         05 IABC-ZZZZZZZZ OCCURS 4 TIMES.
>                                 07 IABC-KKK     PIC 9(08).
>                                 07 IABC-ZZZ     PIC 9(01).
>                                 07 IABC-KKK     PIC 9(08).
>                                 07 IABC-ZZZ     PIC 9(01).
>                 03 FILLER                       PIC X(10).
> ==============================================================
> That's all. I will work hard to find some solution. And any suggestion and
> answer is welcome. :)
Do you want your resulting output to still be COBOL? Because what
you've shown here won't compile. You have a number of variables
defined multiple times, and you still have your OCCURS clauses, which
the compiler will still try to allocate storage for.  You'll have to
either use FILLER or come up with some kind of naming convention. Do
you need to code for OCCURS DEPENDING ON? How about OCCURS ZERO TO
THREE TIMES DEPENDING ON? How about REDEFINES?
I'm curious what end result you're looking for. If it's compilable
COBOL code, that's one problem, but if you're building a memory map or
something like that, some COBOL compilers have options that will map
working storage to memory locations. I know the IBM MVS one will,
although it's been too many years for me to remember the specific
options.
Being a dinosaur, to me this looks like an interesting problem. And
it's one that I've dealt with before, although not with Perl. Post
more info!
As a suggestion, if you want it to compile, maybe your output for the
example you gave might look like this: (typed from memory, not cut and
pasted, not compiled, but I'm pretty sure that it's valid code)
      * asterisk in column 7 for a comment? I can't remember.
       01  IABC-R.
         03  IABC-F13				PIC 9(07).
      *  03  IABC-F14 OCCURS 3 TIMES.
         03  IABC-F14-1.
           05  IABC-AKLFJDKAS			PIC X(01).
      *    05  IABC-ZZZZZZZZ OCCURS 2 TIMES.
           05  IABC-ZZZZZZZZ-1.
             07  IABC-KKK			PIC 9(08).
             07  IABC-ZZZ                       PIC 9(01).
           05  IABC-ZZZZZZZZ-2.
             07  IABC-KKK			PIC 9(08).
             07  IABC-ZZZ                       PIC 9(01).
         03  IABC-F14-2.
           05  IABC-AKLFJDKAS			PIC X(01).
      *    05  IABC-ZZZZZZZZ OCCURS 2 TIMES.
           05  IABC-ZZZZZZZZ-1.
             07  IABC-KKK			PIC 9(08).
             07  IABC-ZZZ                       PIC 9(01).
           05  IABC-ZZZZZZZZ-2.
             07  IABC-KKK			PIC 9(08).
             07  IABC-ZZZ                       PIC 9(01).
         03  IABC-F14-3.
           05  IABC-AKLFJDKAS			PIC X(01).
      *    05  IABC-ZZZZZZZZ OCCURS 2 TIMES.
           05  IABC-ZZZZZZZZ-1.
             07  IABC-KKK			PIC 9(08).
             07  IABC-ZZZ                       PIC 9(01).
           05  IABC-ZZZZZZZZ-2.
             07  IABC-KKK			PIC 9(08).
             07  IABC-ZZZ                       PIC 9(01).
         03  FILLER				PIC X(10).
ps: Your English looked good enough to me.
-- 
Russ Jones - HP OpenView IT/Operatons support
Raytheon Aircraft Company, Wichita KS
russ_jones@rac.ray.com 316-676-0747
Te audire non possum. Musa sapientum fixa est in aure. - Plautus
------------------------------
Date: Tue, 13 Feb 2001 14:22:29 -0500
From: rvl <rvl2@MailAndNews.com>
Subject: How to redirect output within Perl script?
Message-Id: <3A8D25D9@MailAndNews.com>
I'm converting from old system to Sun Unix and have to convert scripts.
I need to be able redirect output to a file from a Perl script, but I
can't do it by calling from the outside shell (i.e. $ script > log_file)
as this script is being run from shell and from other executable
programs actively and in background.
In other words I need to be able to redirect from inside this shell.
Here's a sample of the script, I need to redirect _everything_
to a file so nothing is printed on screen. Please help.
I would appreciate if you could email me the reply at
slyudmir@jefco.com as my company blocks access to usenet.
Thank you.
----------------------------------------------------------------
#!/usr/bin/perl
    package pricefeed_updt;
    require 'check_object_cpl.pl';
    $main'SEVERITY = 'exit(1)';
    $pricefile = &main'CHECK_OBJECT('=');
# calc yields for option=2 (IDC priced flg='I')
    open(DATA, "| /runs/prcyldcalc") || eval($main'SEVERITY);
    print(DATA "\n");
    print(DATA "2\n");
    print(DATA "N\n");
    close(DATA);
    exit(0);
----------------------------------------------------------------
------------------------------
Date: 13 Feb 2001 17:18:40 -0500
From: Jonathan Feinberg <jdf@pobox.com>
Subject: Re: How to redirect output within Perl script?
Message-Id: <ae7qb51b.fsf@pobox.com>
rvl <rvl2@MailAndNews.com> writes:
> In other words I need to be able to redirect from inside this shell.
See perlopen in the section entitled "Obscure Open Tricks".
-- 
Jonathan Feinberg   jdf@pobox.com   Sunny Brooklyn, NY
http://pobox.com/~jdf
------------------------------
Date: Tue, 13 Feb 2001 19:15:35 GMT
From: egwong@netcom.com
Subject: Re: Locking files in a CGI script
Message-Id: <rJfi6.66$Sx5.13157@news.flash.net>
Hariga Ben <lurvas@excite.com> wrote:
> I'm pretty sure this is covered by some FAQ or something similar but I can't 
> find it. So, if someone knows where I can find some hints on how to do this I 
> would be grateful for a pointer.
[cut]
> Adding information is no problem, then I can 'flock'. But I don't really know 
> how to proceed when it comes to changing some info. I mean I can't use 
> 'flock' since I can't be sure that there will be a second call that submits 
> the changes and releases the lock ... (I'm probably looking for a lock that 
> times out after 15 minutes or so).
[cut]
A file lock will only last as long as your CGI script is running.
So, unless you're running under mod_perl (Apache::Registry), you have
nothing to worry about.  (Of course I mean when you're using flock(),
not a sentinel file.  A sentinel *can* be used to lock a file across
CGI invocations.)
Anyhow, see the "File Locking" section in the perlopentut manpage.
ERic
------------------------------
Date: Tue, 13 Feb 2001 15:26:18 -0500
From: "Kurt Stephens" <kstep@pepsdesign.com>
Subject: Re: Locking files in a CGI script
Message-Id: <96c591$l9r$1@nntp9.atl.mindspring.net>
"Hariga Ben" <lurvas@excite.com> wrote in message
news:01HW.B6AF3662000394C904CE5CE0@news.communique.se...
> I'm pretty sure this is covered by some FAQ or something similar but I
can't
> find it. So, if someone knows where I can find some hints on how to do
this I
> would be grateful for a pointer.
>
> I'm writing a few simple CGI scripts which will allow two people to change
> some information. Since the updates will be few (probably in the order of
> once or twice a week) there will probably be no problem with concurrent
> changes etc  ... but I would like to learn a few new thing I thought I
would
> take the opportunity to play a bit 8-)
>
> Adding information is no problem, then I can 'flock'. But I don't really
know
> how to proceed when it comes to changing some info. I mean I can't use
> 'flock' since I can't be sure that there will be a second call that
submits
> the changes and releases the lock ... (I'm probably looking for a lock
that
> times out after 15 minutes or so).
This has nothing to do with Perl, but my typing fingers could use some
exercise.
Any action that changes data on the server should be atomic - a single call
locks the resource, updates it and frees the lock.  The problem is
maintaining the state of the application between the time that the user
starts the action and when the data is ready to be written.
In many cases, all of the data persists in the form itself.  The CGI
application sends a blank form to the user, and the user fills in and
submits the data back to the server.  The application validates the data and
either performs the update or sends the invalid data back to the user for
corrections.  Multi-page applications may save their intermediate data in
hidden fields before the final submission.  In both of these cases, the
browser maintains the application state between requests.
In more complex multi-page forms this technique may not be appropriate - The
application may need to perform a sequence of operations and the number of
hidden fields becomes unwieldy.  This calls for a session strategy where the
server stores the intermediate data in either a temporary file or a database
table.  A hidden field, query string parameter or a cookie associates the
session data with the current request .  When the user completes the final
stage of the process, the application performs the update and deletes the
temporary resources.  In this case it is necessary to delete the resources
created by abandoned sessions.  This can be done using a scheduled process
(cron or at) or when deleting the resources for a completed session.
In any case, there is no reason to lock server resources during the time
that the user spends entering data.  Locking, updating and freeing the
resource should be performed as a single, atomic action.
Kurt Stephens
------------------------------
Date: Tue, 13 Feb 2001 15:04:33 -0500
From: Janet Schlueb <jgs2283@MailAndNews.com>
Subject: RE: Need help with an array
Message-Id: <3A8DC9F2@MailAndNews.com>
If I have
$webhost = 'www.whatever.net';
$webpage[0] = 
'/servlet/ApparelKeySearch?xaction=%2Fservlet%2FApparelKeySearch&iqformat=xm
l&
iqdtdtype=0&site=spreexml&keywords=' .$key. 
'&logic=0&Submit=Submit+Query&maxpersite=1&maxtotal=100&pagesize=9999';
$webpage[1] = 
'/servlet/AuctionKeySearch?xaction=%2Fservlet%2FAuctionKeySearch&iqformat=xm
l&
iqdtdtype=0&site=spreexml&keywords=' .$key. 
'&logic=0&Submit=Submit+Query&maxpersite=1&maxtotal=100&pagesize=9999';
$webpage[2] = 
'/servlet/AutoKeySearch?xaction=%2Fservlet%2FAutoKeySearch&iqformat=xml&iqdt
dt
ype=0&site=spreexml&keywords=' .$key. 
'&logic=0&Submit=Submit+Query&maxpersite=1&maxtotal=100&pagesize=9999';
#and so on up to $webpage[21], would the following 2 statements be correct?
$PageUrl  = 'http://' . $webhost . @webpage[0..21];
$rqst = HTTP::Request->new('GET', $PageUrl);
I really appreciate your help!  Thanks, Janet
>===== Original Message From mjd@plover.com =====
>[mailed and posted]
>In article <3A8A58E4@MailAndNews.com>,
>Janet Schlueb  <jgs2283@MailAndNews.com> wrote:
>>Hello, I know that this isn't too difficult of a question, but I was
>>wondering
>>if anyone could tell me how to do this in one statement rather than 22:
>>
>>$rqst = HTTP::Request->new('GET', $PageUrl);
>>$rqst = HTTP::Request->new('GET', $PageUrl2);
>>$rqst = HTTP::Request->new('GET', $PageUrl3);
>
>The right approach is to have the page urls in a snigle array variable
>instead of in 23 similarly-named but unrelated scalar variables.
>
>If the URLs are in an array, say @PageUrl, then you use
>        for $url (@PageURL) {
>          $request = HTTP::Request->new('GET', $url);
>        }
>
>
>Any time you have variables named $PageUrl1, $PageURL2, and so on, it
>means you made a mistake, and you should have been using an array all
>along.  With the array, you can still refer to the individual urls as
>$PageUrl[0], $PageUrl[1], ... $PageUrl[22], but you may also refer to
>the URLs as a group using the @PageUrl notation I showed above.
>
>See
>        http://www.perl.com/pub/2000/04/raceinfo.html
>for more discussion of this point.
>--
>@P=split//,".URRUU\c8R";@d=split//,"\nrekcah xinU / lreP rehtona tsuJ";sub p{
>@p{"r$p","u$p"}=(P,P);pipe"r$p","u$p";++$p;($q*=2)+=$f=!fork;map{$P=$P[$f^ord
>($p{$_})&6];$p{$_}=/ ^$P/ix?$P:close$_}keys%p}p;p;p;p;p;map{$p{$_}=~/^[P.]/&&
>close$_}%p;wait until$?;map{/^r/&&<$_>}%p;$_=$d[$q];sleep rand(2)if/\S/;print
------------------------------
Date: Tue, 13 Feb 2001 19:37:40 GMT
From: Matt York <bovvy@cableinet.co.uk>
Subject: Newbie Perl / CGI Question
Message-Id: <1103_982092992@mattspc>
Hi Group,
I'm currently trying to write a CGI script that will allow me to specify 
my own parameters as well as those generated by a form.
e.g.
I am trying to get the parameter myparam passed into the next page not just the form items.
print "<p>username and password</p>";
print param('myparam','myval'');
print textfield(-name=>'username');
print "<BR><p>Password</p>";
print password_field(-name=>'password');			
print "<BR><p>Press submit below when done</p>";
print submit('Login');
print end_form;
can anyone see what i'm doing wrong ?
------------------------------
Date: Tue, 13 Feb 2001 12:18:08 -0600
From: "Jeff Fletcher" <jeff_fletcher@pacbell.net>
Subject: no headers using CGI.pm
Message-Id: <3Cgi6.89603$Wq1.37874039@nnrp5-w.sbc.net>
My server uses MS IIS, so I've been told I need to prevent my scripts from
sending a header. I've tried to use...
use CGI qw(:standard -nph);
and a few other suggested syntaxes I got here
(http://stein.cshl.org/WWW/software/CGI/cgi_docs.html#nph) that supposedly
do the same thing. Nothing seems to work.
Does anyone have the answer to this?
Thanks.
--------
Jeff Fletcher, Editor
sfbaygolf.com: The online guide to Bay Area golf
jeff@sfbaygolf.com
http://www.sfbaygolf.com
------------------------------
Date: Tue, 13 Feb 2001 18:15:45 GMT
From: "Jeremia d." <jdb@ga.prestige.net>
Subject: Parsing file question
Message-Id: <3A88DE01.3E08AFFD@ga.prestige.net>
--------------A53E42D2FE612DB404692344
Content-Type: text/plain; charset=us-ascii
Content-Transfer-Encoding: 7bit
Ok I am doing a script that will find all the SUID files on the system, then writing them to a file.
How can i parse the log file and grab each line and then test the file with some file test operators?
So say the format of the log was;
/usr/blah/bleg
/foo/bar/telnet
etc... How could i break this down and test each file idividually. Thanks ahead--
A little experience often upsets a lot of theory.
--------------A53E42D2FE612DB404692344
Content-Type: text/html; charset=us-ascii
Content-Transfer-Encoding: 7bit
<!doctype html public "-//w3c//dtd html 4.0 transitional//en">
<html>
<pre>Ok I am doing a script that will find all the SUID files on the system, then writing them to a file.</pre>
<pre>How can i parse the log file and grab each line and then test the file with some file test operators?</pre>
<pre>So say the format of the log was;</pre>
<pre>/usr/blah/bleg</pre>
<pre>/foo/bar/telnet</pre>
<pre>etc... How could i break this down and test each file idividually. Thanks ahead-- 
A little experience often upsets a lot of theory.</pre>
 </html>
--------------A53E42D2FE612DB404692344--
------------------------------
Date: Tue, 13 Feb 2001 19:29:47 GMT
From: "Jeremia d." <jdb@ga.prestige.net>
Subject: Re: Parsing file question
Message-Id: <3A88EF5A.CC2E856@ga.prestige.net>
--------------5CEB8EDA17BF2F773322093E
Content-Type: text/plain; charset=us-ascii
Content-Transfer-Encoding: 7bit
This is what im working with
open(SLOG, "suid.log") or die "Can't open Suid.log: $!\n";
while ($file = <SLOG>) {
   ($file) = split(" ", $file);
}
ftest();
ftest {
print "$file is Readable\n" if -r $file;
print "$file is Writeable\n" if -w $file;
print "$file is Executable\n" if -x $file;
print "$file is Setuid\n" if -u $file;
print "$file is Setgid\n" if -g $file;
print "$file is Sticky\n" if -k $file;
print "$file is Text\n" if -T $file;
}
#foreach $file (print $file) {
 #  ftest()
 #}
"Jeremia d." wrote:
> I know how to do the file test operators i just need to know how to
> aprse each line of the file and store in a variable or maybe an array?
> To test each one, that it finds.
> "Jeremia d." wrote:
>
>>
>>
>> Ok I am doing a script that will find all the SUID files on the system, then writing them to a file.
>>
>> How can i parse the log file and grab each line and then test the file with some file test operators?
>>
>> So say the format of the log was;
>>
>> /usr/blah/bleg
>>
>> /foo/bar/telnet
>>
>> etc... How could i break this down and test each file idividually. Thanks ahead--
>> A little experience often upsets a lot of theory.
>>
>>
>
> --
> A little experience often upsets a lot of theory.
>
>
--
A little experience often upsets a lot of theory.
--------------5CEB8EDA17BF2F773322093E
Content-Type: text/html; charset=us-ascii
Content-Transfer-Encoding: 7bit
<!doctype html public "-//w3c//dtd html 4.0 transitional//en">
<html>
This is what im working with
<br>open(SLOG, "suid.log") or die "Can't open Suid.log: $!\n";
<br>while ($file = <SLOG>) {
<br>   ($file) = split(" ", $file);
<br>}
<br> 
<br>ftest();
<br> 
<br>ftest {
<br>print "$file is Readable\n" if -r $file;
<br>print "$file is Writeable\n" if -w $file;
<br>print "$file is Executable\n" if -x $file;
<br>print "$file is Setuid\n" if -u $file;
<br>print "$file is Setgid\n" if -g $file;
<br>print "$file is Sticky\n" if -k $file;
<br>print "$file is Text\n" if -T $file;
<br>}
<br> 
<br>#foreach $file (print $file) {
<br> #  ftest()
<br> #}
<br> 
<br> 
<p>"Jeremia d." wrote:
<blockquote TYPE=CITE>I know how to do the file test operators i just need
to know how to aprse each line of the file and store in a variable or maybe
an array? To test each one, that it finds.
<br>"Jeremia d." wrote:
<blockquote TYPE=CITE> 
<pre>Ok I am doing a script that will find all the SUID files on the system, then writing them to a file.</pre>
<pre>How can i parse the log file and grab each line and then test the file with some file test operators?</pre>
<pre>So say the format of the log was;</pre>
<pre>/usr/blah/bleg</pre>
<pre>/foo/bar/telnet</pre>
<pre>etc... How could i break this down and test each file idividually. Thanks ahead-- 
A little experience often upsets a lot of theory.</pre>
 </blockquote>
<pre>-- 
A little experience often upsets a lot of theory.</pre>
 </blockquote>
<pre>-- 
A little experience often upsets a lot of theory.</pre>
 </html>
--------------5CEB8EDA17BF2F773322093E--
------------------------------
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 V10 Issue 283
**************************************