[22851] in Perl-Users-Digest

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

Perl-Users Digest, Issue: 5072 Volume: 10

daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Wed Jun 4 06:05:42 2003

Date: Wed, 4 Jun 2003 03:05:07 -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, 4 Jun 2003     Volume: 10 Number: 5072

Today's topics:
        Advanced Perl Course - UK <jaszmania@tiscali.co.uk>
    Re: capturing output of executed system command (Tad McClellan)
    Re: capturing output of executed system command (Tad McClellan)
    Re: capturing output of executed system command (Tad McClellan)
        format STDERR from childprocess <michael.korte@materna.de>
        formatted STDERR of an child process <michael.korte@materna.de>
    Re: formatting my output (Tad McClellan)
    Re: getting the date for "last Wednesday" <usenet@dwall.fastmail.fm>
    Re: getting the date for "last Wednesday" <krahnj@acm.org>
    Re: getting the date for "last Wednesday" (Anno Siegel)
        Hy guys,I need some help(opening directories) (Zoran)
    Re: Hy guys,I need some help(opening directories) <g4rry_short@zw4llet.com>
    Re: Hy guys,I need some help(opening directories) (Anno Siegel)
    Re: Is it possible to do it ? <sgt19@tid.es>
    Re: LWP and HTTP protocol (Chacrint Charinthorn)
    Re: Module to decode MS Word documents? <bigj@kamelfreund.de>
        notes for book "writing appache modules with perl and c <knb@gfz-potsdam.de>
    Re: perl script for level 0 and incremental backups <sgt19@tid.es>
        regular expression problem (KT)
    Re: selecting more than 1 record from database with win (Philip Lees)
    Re: selecting more than 1 record from database with win (Tad McClellan)
        strange perl behaviour with cgi <rinaul@hotmail.com>
    Re: strange perl behaviour with cgi <mbudash@sonic.net>
    Re: strange perl behaviour with cgi (Tad McClellan)
        vars from htaccess to cgi <tunmaster@hotmail.com>
        Digest Administrivia (Last modified: 6 Apr 01) (Perl-Users-Digest Admin)

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

Date: Mon, 2 Jun 2003 15:25:47 +0100
From: "Jaszmania" <jaszmania@tiscali.co.uk>
Subject: Advanced Perl Course - UK
Message-Id: <bbfmpj$rgn$1@yarrow.open.ac.uk>

I thought folks might be interested in a couse being run by QA Training -
30th June , 5 days in london (Holborn). The course is usually only run at
customer sites so this is a special one off public running . i wouldn't
normally advertise on behalf of companies but given this is a one off - I
thought it might be useful to know about.

If your interested see their website www.qa.com or contact
lucy.sketchley@qa.com

The course id is :NEPERLAV-2 and covers:

Language Environment

Editor; Tags; Online Documentation; Profiling for speed; Code coverage;
Warning and diagnostics; Debugger

Subroutines

Named and default Parameters; Call by Reference; Prototypes; Subroutine
References; Closures

Modules

Module review and loading: %INC, @INC , use lib; Namespaces; Symbol
import/export Scopes; Multiple packages per module

Object Oriented Programming I

Review of references; Constructors; Destructors; Data types; Inheritance;
Reference counting and loops

Object Oriented Programming II

The 'fields' and 'base' modules; Operator overloading; Named constructors;
Virtual constructors

Advanced Regular Expressions

Overview of options; Side effect variables Back-referencing; Greedy and
minimal matches Multi-line matching; Global matches; Extended Regular
xpressions;

Handling Errors and Exceptions

Error detection; Returning errors or throwing exceptions; Error-throwing
functions; undef and eval; Using %SIG; Errors in Sub-programs

Database Interfacing Using DBI

The tie interface; DBI and DBD; Connect and disconnect; Life cycle of a
statement; Reading information & meta-data; Repeated statement execution;
Other database handle methods; Calling a stored procedure

Web Programming I

CGI background; The CGI header and MIME types; Simple form handling;
Multiple forms on one page; Multiple submit buttons in one form; Graphical
submit buttons; Another language: JavaScript

Web Programming II

Multiple-run scripts; State preserving forms; HTML & forms with CGI module;
Sessions & transactions

Web Programming III

Object Oriented Interface to CGI.pm; Generating images; Using headers &
cookies; File upload; mod_perl vs FastCGI; Security

Network Programming

Review of TCP/IP; Using sockets: sockets and IO::Socket::*; Simple client
and server; Local domain sockets; Datagram; Networking using odules: ftp,
http, mail

Multi-Threaded Programming

Review of threads, pthreads, Win32 threads; Using threads in perl;
Synchronisation; Race condition; Deadlock and Livelock; Caveats and bugs;
Design patterns






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

Date: Tue, 3 Jun 2003 22:26:17 -0500
From: tadmc@augustmail.com (Tad McClellan)
Subject: Re: capturing output of executed system command
Message-Id: <slrnbdqpmp.ltm.tadmc@magna.augustmail.com>

Andy Baxter <news2@earthsong.null.free-online.co.uk> wrote:
> benson limketkai wrote:
> 
>> suppose i have:
>> 
>> system 'ps'
>> 
>> how can i redirect the output into an array?

> $ps=`ps`; # capture output of 'ps'

> @ps=split /\n/,$ps; # split into an array


> Also the 'split 
> /\n/,$ps' which means split the string $ps into an array with one element 
> for each line of the string


If you use backticks in list context, instead of scalar context,
you get the desired list directly, no need for split().


   my @ps = qx/ ps /;  # ( I don't use actual `backtick chars` in My Code )


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


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

Date: Tue, 3 Jun 2003 22:27:25 -0500
From: tadmc@augustmail.com (Tad McClellan)
Subject: Re: capturing output of executed system command
Message-Id: <slrnbdqpot.ltm.tadmc@magna.augustmail.com>

benson limketkai <bensonl@stanford.edu> wrote:

> system 'ps'
> 
> how can i redirect the output into an array?


Folks that do not read the documentation for the function that
they are using deserve any pain they get.

Try to avoid pain.


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


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

Date: Wed, 4 Jun 2003 01:53:39 -0500
From: tadmc@augustmail.com (Tad McClellan)
Subject: Re: capturing output of executed system command
Message-Id: <slrnbdr5rj.m4u.tadmc@magna.augustmail.com>


[ Please do not top-post ]


Andy Baxter <news2@earthsong.null.free-online.co.uk> wrote:
> Steve Grazzini wrote:
>> Andy Baxter <news2@earthsong.null.free-online.co.uk> wrote:


>>> $ps=`ps`; # capture output of 'ps'

>>> @ps=split /\n/,$ps; # split into an array
>> 
>> You're making this harder than it needs to be:
>>  
>>   my @ps = `ps`;
>> 
> thanks. didn't know you could do this.


Folks that do not read the documentation for the function that
they are using deserve any pain they get.

Try to avoid pain.

The description of backticks in perlop.pod describes both
scalar context and list context behaviors. 

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


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

Date: Wed, 4 Jun 2003 11:41:33 +0200
From: "Michael Korte" <michael.korte@materna.de>
Subject: format STDERR from childprocess
Message-Id: <bbkese$nlb$1@pentheus.materna.de>

Hello NG .-)




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

Date: Wed, 4 Jun 2003 11:51:25 +0200
From: "Michael Korte" <michael.korte@materna.de>
Subject: formatted STDERR of an child process
Message-Id: <bbkfeu$om4$1@pentheus.materna.de>

Hello NG :-)

I´ve a tricky question :

My perlscript is starting a process (In my case : ldapdelete / ldapmodify)
and it switches the STDERR into my Logfile
like this :

open(LOGG,">>logfile.log") or die "could not open logfile.log";
open(STDERR, ">&LOGG") || die "STDERR: $!\n";

This works fine, but all STDERRoutput, of course, is being written directly
into the file. All Entries I´m creating from the actual script
are formatted like :

[03.06.2003] [ERROR] "Some Error String "

Does somebody know a possibility to format the STDERR from the childprocess
before writing into the file ?
My first suggestion was to write it into a tmpfile, for later formatting
these entries, but in this case I would not get the
real time when the Error occureds...

Maybe I can first send the STDERR into a  function ?
Thx for any suggestion.

 regards Michael




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

Date: Tue, 3 Jun 2003 22:30:40 -0500
From: tadmc@augustmail.com (Tad McClellan)
Subject: Re: formatting my output
Message-Id: <slrnbdqpv0.ltm.tadmc@magna.augustmail.com>

slash <satishi@gwu.edu> wrote:

>         printf "@stack\n";


I classify mixing interpolation with a printf format string as an abuse.


> how can i format it better so the file is a little more readable.


By using printf() correctly.


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


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

Date: Wed, 04 Jun 2003 04:10:15 -0000
From: "David K. Wall" <usenet@dwall.fastmail.fm>
Subject: Re: getting the date for "last Wednesday"
Message-Id: <Xns93901BB25852dkwwashere@216.168.3.30>

cp <cpryce@pryce.nospam.net> wrote:

> In article <Xns938FDBFCA519Edkwwashere@216.168.3.30>, David K. Wall
><usenet@dwall.fastmail.fm> wrote:
> 
>> I need a function that will return the calendar date for Wednesday
>> of last week.  If the current day of the week is Wednesday, I want
>> last week's date.  All I need is year, month, and day.
> 
> IFIRC Date::Manip will do some of those calculations for you. If
> speed is not an issue, it might be worth investigating. 

Yup, I suppose I should have posted my alternate solution using 
Date::Manip:

use Date::Manip qw/ParseDate Date_Init/;
sub get_last_wed_mod {
    Date_Init('TZ=EST5EDT'); # stupid Windows "OS"needs this
    my $last_wed =  ParseDate "last Wednesday";
    return substr($last_wed, 0, 4), # year
           substr($last_wed, 4, 2), # month
           substr($last_wed, 6, 2); # day
}

I'm not sure if it's prettier, and I know it's slower, but it's 
certainly shorter.  :-)



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

Date: Wed, 04 Jun 2003 09:03:18 GMT
From: "John W. Krahn" <krahnj@acm.org>
Subject: Re: getting the date for "last Wednesday"
Message-Id: <3EDDB5CF.7E7C5D46@acm.org>

"David K. Wall" wrote:
> 
> I need a function that will return the calendar date for Wednesday of
> last week.  If the current day of the week is Wednesday, I want last
> week's date.  All I need is year, month, and day.
> 
> Here's the function I wrote:
> 
>     sub get_last_wed {
>         my $usetime = time();
>         my $weekday = 0;  # as long as it's not 3 (Wed)
>         my @date;
>         while ($weekday != 3) { # 3=Wed (0=Sun)
>             $usetime -= 24*60*60;
>             ($weekday, @date) = (localtime $usetime)[6,5,4,3];
>         }
>         return $date[0]+1900, $date[1]+1, $date[2]; # Year,Month,Day
>     }
> 
> It returns just what I want, but in my opinion it's a bit ugly.  Should
> I try to make it "prettier", or just go ahead and use it?  It doesn't
> really *matter*, but I or whoever has to maintain this years down the
> road might appreciate it.
> 
> By the way, execution speed is not an issue.  I wouldn't want it to take
> more than, say, 0.1 sec, but other than that I don't care.  It's far
> faster than that already.

sub get_last_wed {
    my @date = localtime time() - ( 86400 * ( (localtime)[6] + 4 ) );
    return $date[5] + 1900, $date[4] + 1, $date[3];
    }


John
-- 
use Perl;
program
fulfillment


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

Date: 4 Jun 2003 09:10:04 GMT
From: anno4000@lublin.zrz.tu-berlin.de (Anno Siegel)
Subject: Re: getting the date for "last Wednesday"
Message-Id: <bbkd1c$4ii$1@mamenchi.zrz.TU-Berlin.DE>

David K. Wall <usenet@dwall.fastmail.fm> wrote in comp.lang.perl.misc:
> cp <cpryce@pryce.nospam.net> wrote:
> 
> > In article <Xns938FDBFCA519Edkwwashere@216.168.3.30>, David K. Wall
> ><usenet@dwall.fastmail.fm> wrote:
> > 
> >> I need a function that will return the calendar date for Wednesday
> >> of last week.  If the current day of the week is Wednesday, I want
> >> last week's date.  All I need is year, month, and day.
> > 
> > IFIRC Date::Manip will do some of those calculations for you. If
> > speed is not an issue, it might be worth investigating. 
> 
> Yup, I suppose I should have posted my alternate solution using 
> Date::Manip:
> 
> use Date::Manip qw/ParseDate Date_Init/;
> sub get_last_wed_mod {
>     Date_Init('TZ=EST5EDT'); # stupid Windows "OS"needs this
>     my $last_wed =  ParseDate "last Wednesday";
>     return substr($last_wed, 0, 4), # year
>            substr($last_wed, 4, 2), # month
>            substr($last_wed, 6, 2); # day
> }
> 
> I'm not sure if it's prettier, and I know it's slower, but it's 
> certainly shorter.  :-)

It may also be more correct.

In the presence of DST, there are days that are shorter than 24 hours
(in local time).  In your original solution you are stepping back by 24
hour intervals, so you may skip the day you are looking for if you
are unlucky.  You would then get the Wednesday a week earlier.

Anno


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

Date: 4 Jun 2003 01:29:20 -0700
From: zoran_m@t-online.de (Zoran)
Subject: Hy guys,I need some help(opening directories)
Message-Id: <e9a805db.0306040029.2a9830ea@posting.google.com>

if (!opendir VH,$directory)
{
$erg_text->delete("1.0",'end');
$erg_text->insert('end',"Directory $directory not found\n");return;}

foreach $file (readdir VH){
if ($file eq $opname)
{
open DAT,"< $opname";
undef $/; 
$rawdata=<DAT>;
$flaggy=1;
}}

All right,thats my code.I am running my program from C:\perl\appz
If I open files in this directory I get no problems.But If I am going to 
directory C:\perl I cannot open any file.I am getting this error message:

"readline()on closed filehandle DAT at test.pl line 309"

line 309:$rawdata=<DAT>;

Can someone explain me what's wrong with my code?
Please help.

Thank you very much

Zoran


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

Date: Wed, 04 Jun 2003 10:13:09 +0000
From: Garry Short <g4rry_short@zw4llet.com>
Subject: Re: Hy guys,I need some help(opening directories)
Message-Id: <bbkdav$hpj$1$830fa79d@news.demon.co.uk>

Zoran wrote:

> if (!opendir VH,$directory)
> {
> $erg_text->delete("1.0",'end');
> $erg_text->insert('end',"Directory $directory not found\n");return;}
> 
> foreach $file (readdir VH){
> if ($file eq $opname)
> {
> open DAT,"< $opname";
> undef $/;
> $rawdata=<DAT>;
> $flaggy=1;
> }}
> 
> All right,thats my code.I am running my program from C:\perl\appz
> If I open files in this directory I get no problems.But If I am going to
> directory C:\perl I cannot open any file.I am getting this error message:
> 
> "readline()on closed filehandle DAT at test.pl line 309"
> 
> line 309:$rawdata=<DAT>;
> 
> Can someone explain me what's wrong with my code?
> Please help.
> 
> Thank you very much
> 
> Zoran

Yes. You're not doing any checking.

Line 308: open DAT, "$opname" or die "Can't open $opname: $!\n";
The $! will return the system error, probably telling you that the file
doesn't exist (I'm guessing from your comments that you're in the wrong
directory). You're also only reading a file, so the preceeding < is
unnecessary.

Try preceeding the "open" statement with something like:
$opname = "$directory\/$opname";
to build a full path statement (assuming your directory contains the full
path, and not just the folder name).

The alternative is to use chdir to ensure that your current directory is as
expected.

Personally, I'd put all the error checks and close statements in, and try it
again:

opendir VH, $directory or {    # Not sure if this'll actually work, never 
# tried it; stick it in a subroutine if it doesn't
  $erg_text->delete("1.0",'end');
  $erg_text->insert('end',"Directory $directory not found\n");
  die "Directory $directory not found\n";
}

foreach $file (readdir VH){
  if ($file eq $opname)
  {
    open DAT,"$opname" or die "Can't open file $opname: $!\n";
    undef $/;
    $rawdata=<DAT>;
    $flaggy=1;
    close DAT;
  }
}
closedir VH;


This isn't tested; you'll have to do that yourself.

HTH,

Garry




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

Date: 4 Jun 2003 09:30:36 GMT
From: anno4000@lublin.zrz.tu-berlin.de (Anno Siegel)
Subject: Re: Hy guys,I need some help(opening directories)
Message-Id: <bbke7s$7gd$1@mamenchi.zrz.TU-Berlin.DE>

Zoran <zoran_m@t-online.de> wrote in comp.lang.perl.misc:
> if (!opendir VH,$directory)
> {
> $erg_text->delete("1.0",'end');
> $erg_text->insert('end',"Directory $directory not found\n");return;}
> 
> foreach $file (readdir VH){
> if ($file eq $opname)
> {
> open DAT,"< $opname";

You should always check the return value of open().  As you have seen,
things *can* go wrong.  You could just skip files you can't open:

    open DAT, "< $opname" or do {
        warn "Can't open $opname in $directory: $!";
        next;
    };

> undef $/; 
> $rawdata=<DAT>;
> $flaggy=1;
> }}
> 
> All right,thats my code.I am running my program from C:\perl\appz
> If I open files in this directory I get no problems.But If I am going to 
> directory C:\perl I cannot open any file.I am getting this error message:
> 
> "readline()on closed filehandle DAT at test.pl line 309"
> 
> line 309:$rawdata=<DAT>;

Old story, but apparently not a FAQ yet.

readdir() returns only the file name, not the whole path to the file.
Unless the directory you're reading is your current directory (that
was the case when your code seemed to work), you must prepend the
directory name to the file name:

    open DAT, "$directory/$file" or ...

On the other hand, I don't see why you need readdir() at all.  You
are looking through the directory to find a file named $opname.
You'd get the same effect, with less hassle, if you just did

    if ( -f "$directory/$opname" ) {
        open DAT, "$directory/$opname" or ...
        # etc
    }

Anno


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

Date: Wed, 04 Jun 2003 10:45:57 +0200
From: Stephane Titard <sgt19@tid.es>
Subject: Re: Is it possible to do it ?
Message-Id: <3EDDB1C5.5A5B4393@tid.es>

Hi Jean-Luc,
Just don't give up!
stick to something simple, Perl has got lots of powerful constructs
that sometimes bite at even the most advanced user.

stephan




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

Date: 3 Jun 2003 23:57:02 -0700
From: chacrint@hotmail.com (Chacrint Charinthorn)
Subject: Re: LWP and HTTP protocol
Message-Id: <bfe227db.0306032257.7e44ff41@posting.google.com>

Thanks for those who answered my questions.

> Why do you care? What seems to be your problem if you don't try
> anything specific and just let the module do what it thinks is best? I
> believe it'll do whichever the remote server supports.

My problem was that I had the 500 Internal Server Error when I do:
------------------
POST /Services/script.php HTTP/1.1
 ....

The server responded as:
-------------------------
HTTP/1.0 200 OK
Date: Sun, 01 Jun 2003 12:53:29 GMT
Server: Apache/1.3.27 (Unix) PHP/4.2.3 mod_ssl/2.8.12 OpenSSL/0.9.6b
X-Powered-By: PHP/4.2.3
Content-Type: text/html
X-Cache: MISS from host.domain.net
X-Cache-Lookup: MISS from host.domain.net:8080
Connection: close
 
 ...


> 
> Martien


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

Date: Wed, 04 Jun 2003 10:17:00 +0200
From: "Janek Schleicher" <bigj@kamelfreund.de>
Subject: Re: Module to decode MS Word documents?
Message-Id: <pan.2003.06.04.08.16.58.122338@kamelfreund.de>

Stuart Moore wrote at Tue, 27 May 2003 18:11:53 +0100:

> Are there any modules that'd help me grab text from a word document? Doesn't
> matter if it looses all formatting etc but it'll need to get text from
> inside tables, preferably leaving some mark where the table boundaries are
> but not essential. A quick browse of CPAN revealied nothing.
> 
> If not, any suggestions for other languages (preferably ones that are easily
> used for cgi)

Well, I often use a tool called
antiword  (www.antiword.org)
to solve such problems.

It's not Perlish, but it's a solution :-)


Best Wishes,
Janek


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

Date: Wed, 4 Jun 2003 10:37:50 +0200
From: Knut Behrends <knb@gfz-potsdam.de>
Subject: notes for book "writing appache modules with perl and c"
Message-Id: <MPG.1947ce4c6945abde989681@news.cis.dfn.de>

Does anyone know an URL which points to a document of class notes (or 
something like that)  for the book "writing appache modules with perl 
and c" (the eagle book). 

This is my preffered mode of learning (writing my comments to the class 
notes)
Someone might have put a chapter-wise summary online already. Can't find 
it with google.
--
Knut Behrends
GFZ Potsdam, Germany


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

Date: Wed, 04 Jun 2003 10:37:23 +0200
From: Stephane Titard <sgt19@tid.es>
Subject: Re: perl script for level 0 and incremental backups
Message-Id: <3EDDAFC3.F33C4308@tid.es>

Hi,
why not using some mirroring tool: comes to mind rsync, wget
there is some client module for rsync form CPAN but i would just use
perl as a wrapper here -

o you write it yourself:
get the list of files
for each one get MD5 checksum
if differ copy
no ?


HTH
steph




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

Date: 4 Jun 2003 01:17:57 -0700
From: kennedyel_5000@yahoo.com (KT)
Subject: regular expression problem
Message-Id: <6495f466.0306040017.57b7ba7d@posting.google.com>

Hi all
Perl Problem
if i have a variable that is as followed, how do i assign a new
variable equal http:// and end with .hk   , but as the web page is
vary every times, so i think it should stop be4 HTTP/1.0.


GET http://www.orientaldaily.com.hk/ HTTP/1.0
Accept: */*
Accept-Language: en-au
Proxy-Connection: Keep-Alive
If-Modified-Since: Sat, 24 May 2003 07:18:51 GMT; length=4848
User-Agent: Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.0;
Q312461; .NET CLR 1.0.3705)
Host: www.orientaldaily.com.hk
Proxy-Authorization: Basic cHBwOmFhYWFhYQ==


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

Date: Wed, 04 Jun 2003 06:13:39 GMT
From: pjlees@ics.forthcomingevents.gr (Philip Lees)
Subject: Re: selecting more than 1 record from database with win32::0dbc
Message-Id: <3edd8de8.62158968@news.grnet.gr>

On Tue, 03 Jun 2003 11:24:15 GMT, <w@wp.pl> wrote:

>Anyone knows how to read more than one row of data from database using
>win32::odbc.
>I am trying to select all records containing specific value with " SELECT *
>FROM table WHERE columnvalue = 'value'" and then use fetchrow() to see
>selected records but it is not working. Is there any other way to do this.
>Thanks for any help

Show us your code and explain what you mean by 'not working' and
somebody may be able to help you.

Phil

-- 
Ignore coming events if you wish to send me e-mail


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

Date: Wed, 4 Jun 2003 02:08:57 -0500
From: tadmc@augustmail.com (Tad McClellan)
Subject: Re: selecting more than 1 record from database with win32::0dbc
Message-Id: <slrnbdr6o9.m4u.tadmc@magna.augustmail.com>

w@wp.pl <w@wp.pl> wrote:

> it is not working.


There is an error on line 17.


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


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

Date: Wed, 04 Jun 2003 06:20:05 GMT
From: Jes Naulen <rinaul@hotmail.com>
Subject: strange perl behaviour with cgi
Message-Id: <hb3rdv0sl283b02gkgrc89ii9cef33u33c@4ax.com>


I am very puzzled by some Perl/CGI behaviour. I created a perl cgi
script that's called from a browser. The perl variables are getting
messed up. It seems the perl session is 'remembering' the values for
the browsers perl session. I worked for hours trying to find out
what's wrong, but in the end I ended with the bajsic script:

  #!/usr/bin/perl
  print "Content-type: text/html\n\n";
  print $test;

and it starts counting {1,2,3...). When I open another browser and
call the script, that brouwser starts counting from 1 again. Here too,
obviously the variable $test is being remembered between browser
sessions.

What is wrong (with perl, with apache?) and what can I do about it?

Regards,
Jess


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

Date: Wed, 04 Jun 2003 06:51:31 GMT
From: Michael Budash <mbudash@sonic.net>
Subject: Re: strange perl behaviour with cgi
Message-Id: <mbudash-14F0F3.23513203062003@typhoon.sonic.net>

In article <hb3rdv0sl283b02gkgrc89ii9cef33u33c@4ax.com>,
 Jes Naulen <rinaul@hotmail.com> wrote:

> I am very puzzled by some Perl/CGI behaviour. I created a perl cgi
> script that's called from a browser. The perl variables are getting
> messed up. It seems the perl session is 'remembering' the values for
> the browsers perl session. I worked for hours trying to find out
> what's wrong, but in the end I ended with the bajsic script:
> 
>   #!/usr/bin/perl
>   print "Content-type: text/html\n\n";
>   print $test;
> 
> and it starts counting {1,2,3...). When I open another browser and
> call the script, that brouwser starts counting from 1 again. Here too,
> obviously the variable $test is being remembered between browser
> sessions.
> 
> What is wrong (with perl, with apache?) and what can I do about it?
> 
> Regards,
> Jess

i'm gonna go out on a limb and guess that you're script is being run 
under mod_perl. if so, you need to read this:

http://perl.apache.org/docs/1.0/guide/porting.html

hth-

-- 
Michael Budash


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

Date: Wed, 4 Jun 2003 02:08:00 -0500
From: tadmc@augustmail.com (Tad McClellan)
Subject: Re: strange perl behaviour with cgi
Message-Id: <slrnbdr6mg.m4u.tadmc@magna.augustmail.com>

Jes Naulen <rinaul@hotmail.com> wrote:
> 
> I am very puzzled by some Perl/CGI behaviour. I created a perl cgi
> script that's called from a browser. 


That is impossible.

CGI programs, regardless of what programming language they are
written in, are never called from a browser.

CGI programs are always called by a web _server_.


> The perl variables are getting
> messed up. 


No they're not.


> It seems the perl session is 'remembering' the values for
> the browsers perl session. 
      ^^^^^^^^^^^^^
      ^^^^^^^^^^^^^

But now we know that there is no such thing. Right?

The browser is merely an "output device", the "computing" (CGI program)
is running on the server.


> I worked for hours trying to find out
> what's wrong, 


What's wrong is your understanding of the technology involved.

Fixing the details is hopelessly difficult if you don't understand
the fundamentals.

Have you seen the CGI FAQs?

Understand the flow of info from a form in a browser, to web server,
to CGI program, back to server, and finally on to the browser again?


> but in the end I ended with the bajsic script:
> 
>   #!/usr/bin/perl


You should ask for all the help you can get, as suggested in 
the Posting Guidelines:

   #!/usr/bin/perl
   use warnings;
   use strict;


>   print "Content-type: text/html\n\n";
>   print $test;
> 
> and it starts counting {1,2,3...). 


That program does not do any counting.

Is it the wrong program?

Did you leave some of the code out?

Show a complete program if you want help fixing the program.

Have you seen the Posting Guidelines that are posted
here frequently?


> When I open another browser and
> call the script, that brouwser starts counting from 1 again. 


There is no counting going on that we can see, so we cannot help
you with this counting thing.

Troubleshooting code is hard enough when you can see the code,
it is most often impossible for invisible code...


> Here too,
> obviously the variable $test is being remembered between browser
> sessions.


That cannot happen.

Tell us how we can reproduce the problem that you are seeing,
and then we will be able to help you fix the problem.


> What is wrong (with perl, with apache?) 


Nothing. They are doing exactly what they are supposed to do
(as far as we can tell, with "missing counting" and all).


> and what can I do about it?


First, understand the basics of interaction for CGI and web stuff.

Second, tell us what it is that you wanted it to do instead of
what it is doing (as suggested in the Posting Guidelines).


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


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

Date: Wed, 04 Jun 2003 09:56:08 GMT
From: "joe" <tunmaster@hotmail.com>
Subject: vars from htaccess to cgi
Message-Id: <YmjDa.364316$me2.41617284@amsnews02.chello.com>

LS,

Through a .htaccess-file I redirect visitors to another page in case of an
error (401, 403, 404, 500). This other page is a cgi script which prints out
an error message and logs what went wrong. The value of the environmental
variable QUERY_STRING of the error-page, will be equal to the environmental
variable REDIRECT_QUERY_STRING of the error handling script.

This way I can read the variables sent using the GET method. But what about
variables using the POST method? I tried reading their values using the
param-functing and by "read (STDIN, my $buffer, $ENV{'CONTENT_LENGTH'});"

Are these variables lost in the process or can anyone tell me how to get in
touch with them

Thanks a lot in advance,

Joe




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

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 5072
***************************************


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