[17559] in Perl-Users-Digest

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

Perl-Users Digest, Issue: 4979 Volume: 9

daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Tue Nov 28 14:10:43 2000

Date: Tue, 28 Nov 2000 11:10:26 -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: <975438626-v9-i4979@ruby.oce.orst.edu>
Content-Type: text

Perl-Users Digest           Tue, 28 Nov 2000     Volume: 9 Number: 4979

Today's topics:
    Re: How to find what is between n'th and the next tab? (Anno Siegel)
    Re: How to rsh from cgi? <nickco3@yahoo.co.uk>
        how to test if cgi-script was shift-reloaded by browser <gbrinkmann@dimedis.de>
    Re: how to test if cgi-script was shift-reloaded by bro <gbrinkmann@dimedis.de>
    Re: how to test if cgi-script was shift-reloaded by bro <gbrinkmann@dimedis.de>
    Re: how to test if cgi-script was shift-reloaded by bro (Rafael Garcia-Suarez)
    Re: Loading of modules? <dan@tuatha.sidhe.org>
    Re: making varialbles private to a module <bart.lateur@skynet.be>
        mathematical backgrounds with Perl <vincentg@datashaping.com>
    Re: mathematical backgrounds with Perl <revjack@radix.net>
        Multiple Modules <noone@dontbother.com>
    Re: Multiple Modules (Chris Fedde)
    Re: Multiple Modules <noone@dontbother.com>
    Re: Newbie question concerning columns nobull@mail.com
        Perl 5 & Perl 6 core files dumps + possible typo in x2p (Sebastien Blondeel)
    Re: Perl not executing from Cron job (Flint Slacker)
    Re: Posting Guidelines? gls33@byu.edu
    Re: Reading a csv file <jeff@vpservices.com>
    Re: Reading a csv file (David Wall)
        running Perl program on NT and accessing a UNIX machine <l.hagen@HumanInference.com>
        Session tracking! <berube@odyssee.net>
    Re: Session tracking! <dsimonis@fiderus.com>
    Re: Session tracking! (Abigail)
    Re: Session tracking! nobull@mail.com
    Re: Session tracking! (Flint Slacker)
        Digest Administrivia (Last modified: 16 Sep 99) (Perl-Users-Digest Admin)

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

Date: 28 Nov 2000 15:27:43 -0000
From: anno4000@lublin.zrz.tu-berlin.de (Anno Siegel)
Subject: Re: How to find what is between n'th and the next tab?
Message-Id: <900itg$hot$1@lublin.zrz.tu-berlin.de>

Bart Lateur  <bart.lateur@skynet.be> wrote in comp.lang.perl.misc:
>Anno Siegel wrote:
>
>>Another approach uses a regex: qr/(?:[^\t]*\t){$col}([^\t]*)(?:\t|$)/;
>>deposits the $col'th column in $1.  This requires compilation of a
>>regex for each column.
>
>I think 'd try that with the /o option.

 ...as long as $col doesn't vary from call to call.  Since it was
a variable in the original code I don't think we can assume that.

It may pay to pre-compile the requisite set of regexes:

my @get_col map qr/^(?:[^\t]*\t){$_}([^\t\n]*)/, 0 .. $n_fields - 1;

[snip regex cleanup]

>If you need more than one column, I might use a closure (custom sub).
>From 5.6 on, /o works properly inside a closure.
>
>	sub get_column {
>	    my $col = shift;
>	    return sub {
>	        shift =~ /^(?:[^\t]*\t){$col}([^\t\n]*)/o;
>	        $1;
>	    };
>	}
>
>	my $sub = get_column(5);
>	$_ = join "\t", 'A' .. 'Z';
>	print $sub->($_);
>-->
>	F

That is an interesting property of closures.  It is hard to see,
however, how this can be realized without repeated compilation
of the regex.

Anno


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

Date: Tue, 28 Nov 2000 17:31:45 +0000
From: Nick Condon <nickco3@yahoo.co.uk>
Subject: Re: How to rsh from cgi?
Message-Id: <3A23EC01.4139AE86@yahoo.co.uk>

bdesany@my-deja.com wrote:

> I have a weak web server and a powerful "application" server. I would
> like to process requests via CGI on the web server and then issue a
> resulting command to the application server. Then the user would click
> on a link that would show the contents of the file produced by the
> command that the application server just ran.
>
> The CGI script is running under httpd username (I don't know how to
> change it, and don't know if I'd want to).
>
> I have been trying to do this in the following way:
>
> my $COMMAND = "rsh";
> local *PIPE;
> my $pid = open PIPE, "-|";
> croak "Couldn't fork $!" unless defined $pid;
> unless ($pid) {
>   exec $COMMAND, "appserver", "-l", "my_own_username", "command" or
> croak "Cannot open pipe to rsh!\n";
> }
> etc...
>
> Now, this doesn't work (permission denied) if I put an entry in
> my .rhosts file on the app server for the webserver and user httpd. And
> I don't know the ramifications for this security-wise if I did get it
> to work.
>
> Does anyone have any ideas on how to accomplish what I am trying to do
> here in a secure way, whether it is refinements of the way I've tried
> or something completely different? Thanks,

Use 'ssh', and set it up to use RSA authentication. Your two servers can
then reliably and securely identify each other, and they can run processes
on each other remotely without using a password. It is *much* more secure
than rhosts authentication (which is inherently insecure and should be
disabled if you're on an open network).

http://www.openssh.com
--
Nick



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

Date: Tue, 28 Nov 2000 15:06:12 +0100
From: Gert Brinkmann <gbrinkmann@dimedis.de>
Subject: how to test if cgi-script was shift-reloaded by browser?
Message-Id: <3A23BBD4.99B9C802@dimedis.de>


Hello,

i need to know if a CGI-script was 

a) loaded normally called by clicking an link or typing it manually,
b) reloaded by using the right-mouse-menu-reload-item or the
toolbar-reload-button,
c) <SHIFT>-reloaded by one of these.

I have found many descriptions that said that shift-reload c) results in
an env-entry

  $ENV{HTTP_PRAGMA} = 'no-cache'.

This is true, but there is no difference to an reload of type b) without
the shift key. With an call a) this no-cache-entry correctly is not
there, so i can distinguish between (a) and (b,c).

But how to differentiate between b) and c)?

Thanks in advance if anybody has a hint,

Gert


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

Date: Tue, 28 Nov 2000 15:56:41 +0100
From: Gert Brinkmann <gbrinkmann@dimedis.de>
Subject: Re: how to test if cgi-script was shift-reloaded by browser?
Message-Id: <3A23C7A9.99925DE7@dimedis.de>


Hello Gert,

i had the same problem ;) but now i found that there is no difference
between b) and c) on server-side. The only difference seems to be on
client-side where netscape does not use the cached images when holding
shift but really loads them again.

Ciao,

Gert


Gert Brinkmann wrote:
> a) loaded normally called by clicking an link or typing it manually,
> b) reloaded by using the right-mouse-menu-reload-item or the
> toolbar-reload-button,
> c) <SHIFT>-reloaded by one of these.
> But how to differentiate between b) and c)?


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

Date: Tue, 28 Nov 2000 15:57:38 +0100
From: Gert Brinkmann <gbrinkmann@dimedis.de>
Subject: Re: how to test if cgi-script was shift-reloaded by browser?
Message-Id: <3A23C7E2.934AAF40@dimedis.de>


Hi Gert,

Thank you very much for your fast answer...

:)

Gert Brinkmann wrote:
> i had the same problem ;) but now i found that there is no difference
> between b) and c) on server-side.


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

Date: Tue, 28 Nov 2000 15:10:46 GMT
From: rgarciasuarez@free.fr (Rafael Garcia-Suarez)
Subject: Re: how to test if cgi-script was shift-reloaded by browser?
Message-Id: <slrn927ip2.kmk.rgarciasuarez@rafael.kazibao.net>

Gert Brinkmann wrote in comp.lang.perl.misc:
> 
> Hello,
> 
> i need to know if a CGI-script was 
> 
> a) loaded normally called by clicking an link or typing it manually,
> b) reloaded by using the right-mouse-menu-reload-item or the
> toolbar-reload-button,
> c) <SHIFT>-reloaded by one of these.

other options:
d) accessed by a robot
e) accessed by someone with a telnet on port 80 on your web server
f) one of a,b,c,d,e), but behind a personal or corporate HTTP proxy that
will mess up the referer and/or no-cache headers

etc...

The answer to your question is : you can't. You can examine carefully
the behavior of a specific version of a browser on a specific version of
an OS and try to deduce heuristics from there. But you will not get
reliable data.

-- 
# Rafael Garcia-Suarez / http://rgarciasuarez.free.fr/


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

Date: Tue, 28 Nov 2000 16:43:45 GMT
From: Dan Sugalski <dan@tuatha.sidhe.org>
Subject: Re: Loading of modules?
Message-Id: <5hRU5.75892$P82.8262174@news1.rdc1.ct.home.com>

Jason Timmins <jason@webfoundry.co.uk> wrote:
> Hi There,

> Can anyone tell me where in the source for Perl 5.6.0 the interpreter loads
> modules from the file system?

> I've found stuff called Perl_load_module but I was looking for a nice fread
> command.

You're not going to find anything nearly that simple, alas. If nothing else,
the code in a .pm file needs to run through the parser and any executable
code needs to be loaded by the OS' shared library loading system.

You can check out the require opcode function for a start, and go from there.
It's got the code to handle loading in perl files from disk. The code to
handle loading in shared libraries is in ext/DynaLoader, probably in the
dl_dlopen.xs file. (There are a bunch of dl_*.xs files--which one gets
used depends on what platform you build perl on, since loading up shared
libraries is different on different OSes)

I'll warn you, though--it's rather... interesting code.

					Dan


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

Date: Tue, 28 Nov 2000 14:17:38 GMT
From: Bart Lateur <bart.lateur@skynet.be>
Subject: Re: making varialbles private to a module
Message-Id: <d1f72t09dos81uqfm9lh7hrj6ps3nu4j0v@4ax.com>

Marc Logghe wrote:

>I tried the following example with Perl version 5.005_03 built for
>i386-linux and v5.6.0 built for MSWin32-x86-multi-thread:
>package Alpha;
>my $aa = 10;
>   $x = "azure";
>
>package Beta;
>my $bb = 20;
>   $x = "blue";
>
>package main;
>print "$aa, $bb, $x, $Alpha::x, $Beta::x\n";
>
>
>In the first case I got the answer given in the book:
>10, 20, , azure, blue
>In the latter I got, unexpectedly:
> , , , azure, blue
>Does this mean you now have in v5.6.0 invisible block boundaries so that $aa
>and $bb go out of scope?

No... I tried this script, on IndigoPerl 5.6 for Win32, and on
ActivePerl for Win32, 5.6, and I got the proper answer on both:

	10, 20, , azure, blue

Scope boundaries are file boundaries, and blocks.

	{
		my $x;
		...
		#scope ends here
	}
	my $x = 123;

-- 
	Bart.


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

Date: Tue, 28 Nov 2000 10:37:06 -0600
From: Vincent Granville <vincentg@datashaping.com>
Subject: mathematical backgrounds with Perl
Message-Id: <3A23DF32.3C1229C7@datashaping.com>

Interesting mathematical creations. They are not fractals.
It's produced with pretty simple functions, and does not
require recursive computations. Actually, some of these
objects are very similar to fractals - but again do not
involve recursive formulas. Some other images are clearly
not fractals, but instead exhibit original textures (like wool
cloth or carpet).

http://www.datashaping.com/artwork.shtml




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

Date: 28 Nov 2000 18:59:36 GMT
From: revjack <revjack@radix.net>
Subject: Re: mathematical backgrounds with Perl
Message-Id: <900vao$4i1$2@news1.Radix.Net>
Keywords: Hexapodia as the key insight

Vincent Granville explains it all:

:Interesting mathematical creations. They are not fractals.

$90.00 

bwahahahaa

Go jump in the lake.

f'ups set

-- 
revjack@radix.net
stochasticgnosisthroughablativedissonance


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

Date: Tue, 28 Nov 2000 07:54:00 -0800
From: "Robert Lund" <noone@dontbother.com>
Subject: Multiple Modules
Message-Id: <t27l2u1ad7je7d@corp.supernews.com>

This might be another RTFM question, but I'd like to hear the experts'
answers:

I have a HUGE CGI script that handles different API calls, and I've broken
up the 45 APIs into their own perl modules.  Lets call the main CGI
main.cgi, and all of the modules a through z.pm.   A through Z.pm all use
LWP and CGI modules, and I've 'use'd those modules in each module (a-z).
Here's what the code looks like:

main.cgi:

use CGI ':standard';
use LWP::Simple 'get';
use a.pm;
use b.pm
use c.pm
# all the way to z.pm


a.pm

use CGI ':standard';
use LWP::Simple 'get';


My questions are:

1) Is the above the best way to break up my functions into independant
modules?  Would a 'require' be better?

2) Do I need to 'use' LWP and CGI again and again in each submodule?  Does
this cause inefficiency when main.cgi 'use's each of the modules (a-z)?

Thanks for all of your help... I'm trying to make this as efficient as
possible, and I don't want to have needless redundancies...

--Robert






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

Date: Tue, 28 Nov 2000 18:00:47 GMT
From: cfedde@fedde.littleton.co.us (Chris Fedde)
Subject: Re: Multiple Modules
Message-Id: <jpSU5.144$QX6.171057152@news.frii.net>

In article <t27l2u1ad7je7d@corp.supernews.com>,
Robert Lund <noone@dontbother.com> wrote:
>This might be another RTFM question, but I'd like to hear the experts'
>answers:
>
>I have a HUGE CGI script that handles different API calls, and I've broken
>up the 45 APIs into their own perl modules.  Lets call the main CGI
>main.cgi, and all of the modules a through z.pm.   A through Z.pm all use
>LWP and CGI modules, and I've 'use'd those modules in each module (a-z).
>Here's what the code looks like:
>

My first question is what motivated this choice for factoring your
application.  Generally modules group a conceptual area.  What you've
done does not have any performance advantages.  And assuming that
the module names are as ambiguous as you describe them there are
no readability advantages that I can see.  If you want to break
your subroutines up to avoid start time loading overhead then read
the AutoSplit manual page.

Specificly to your questions.  You only need to "use" a module once.
But it does not hurt to "use" them multiple times.
-- 
    This space intentionally left blank


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

Date: Tue, 28 Nov 2000 10:29:01 -0800
From: "Robert Lund" <noone@dontbother.com>
Subject: Re: Multiple Modules
Message-Id: <t27u5ikuph084d@corp.supernews.com>

The names of the modules I use are not actually a-z.pm, I'm just using them
as examples.   Again, the reason I've split them up if for the sakes of
readibility and maintainability.   Each one is an individual perl module
that exports sundry subroutines.  Putting it all into one file would be
thousands of lines of code.   If I don't 'use' CGI and LWP in each of the
smaller modules, the functions like get and param aren't available.   I was
hoping someone might have some insight as to the best way to arrange these
files...


"Chris Fedde" <cfedde@fedde.littleton.co.us> wrote in message
news:jpSU5.144$QX6.171057152@news.frii.net...
> In article <t27l2u1ad7je7d@corp.supernews.com>,
> Robert Lund <noone@dontbother.com> wrote:
> >This might be another RTFM question, but I'd like to hear the experts'
> >answers:
> >
> >I have a HUGE CGI script that handles different API calls, and I've
broken
> >up the 45 APIs into their own perl modules.  Lets call the main CGI
> >main.cgi, and all of the modules a through z.pm.   A through Z.pm all use
> >LWP and CGI modules, and I've 'use'd those modules in each module (a-z).
> >Here's what the code looks like:
> >
>
> My first question is what motivated this choice for factoring your
> application.  Generally modules group a conceptual area.  What you've
> done does not have any performance advantages.  And assuming that
> the module names are as ambiguous as you describe them there are
> no readability advantages that I can see.  If you want to break
> your subroutines up to avoid start time loading overhead then read
> the AutoSplit manual page.
>
> Specificly to your questions.  You only need to "use" a module once.
> But it does not hurt to "use" them multiple times.
> --
>     This space intentionally left blank




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

Date: 28 Nov 2000 18:14:03 +0000
From: nobull@mail.com
Subject: Re: Newbie question concerning columns
Message-Id: <u9hf4sotg4.fsf@wcl-l.bham.ac.uk>

darkon@one.net (David Wall) writes:

> nobull@mail.com wrote in <u9vgt9paq0.fsf@wcl-l.bham.ac.uk>:
> >until ( eof FILE ) {
> >  push @$_ => scalar(<FILE>) for @rows;
> >}

> I suppose I might like a bit more whitespace:

> until ( eof FILE ) {
>     for (@rows) {
>         push @$_, scalar(<FILE>);
>     }
> }

I'd like less...

push @$_ => scalar(<FILE>) for @rows until eof FILE;

 ...but Perl only allows a single statement modifier.  If you have any
comments on this please do _not follow-up here, join the "Why only a
single statement modifier?" thread in clp.moderated.

-- 
     \\   ( )
  .  _\\__[oo
 .__/  \\ /\@
 .  l___\\
  # ll  l\\
 ###LL  LL\\


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

Date: 28 Nov 2000 16:42:48 GMT
From: blondeel@nef.ens.fr (Sebastien Blondeel)
Subject: Perl 5 & Perl 6 core files dumps + possible typo in x2p/a2py.c
Message-Id: <900na8$lhi$1@nef.ens.fr>

Recently I had the surprise to have Perl5 (and Perl6 compiled to test
with this new version) dump cores.

my system: GNU/Linux. Happened both on Red Hat 6.1 and Debian 2.2

Unfortunately:
 . the problem is so heavily dependent on the machine configuration
  I cannot reproduce it at will (and right now it seems I cannot)
  Therefore it looks difficult for someone else to be able to reproduce
  it...
 . the problem stopped to occur when either version of Perl was compiled
  with the -g option

However I kept both core files (Red Hat version) and can perlform on
them whatever operation you would advice me to. For the moment I include
the result of the "where" command for both.

Maybe it is a GCC problem, or a problem specific to my distribution.
Should there be a more appropriate place to post this information,
please tell me.

====

Unrelatedly, I noticed the word "locatime" in x2p/a2py.c
Should that not be "localtime" instead?

The problem still appears in the perl7 source archive I downloaded and
in the file with RCS revision:

/* $RCSfile: a2py.c,v $$Revision: 4.1 $$Date: 92/08/07 18:29:14 $

(same revision as in the perl-5.6.0 source archive)

===
Perl5 "where" for the core

Core was generated by `/usr/bin/perl T.pl [...]'
Program terminated with signal 11, Segmentation fault.
Reading symbols from /lib/libnsl.so.1...done.
Reading symbols from /lib/libdl.so.2...done.
Reading symbols from /lib/libm.so.6...done.
Reading symbols from /lib/libc.so.6...done.
Reading symbols from /lib/libcrypt.so.1...done.
Reading symbols from /lib/ld-linux.so.2...done.
#0  0x400a7e96 in chunk_free (ar_ptr=0x4013c040, p=0x81ee75b) at malloc.c:3033
3033    malloc.c: No such file or directory.
(gdb) where
#0  0x400a7e96 in chunk_free (ar_ptr=0x4013c040, p=0x81ee75b) at malloc.c:3033
#1  0x400a7d75 in __libc_free (mem=0x81ee764) at malloc.c:2959
#2  0x807a50c in Perl_safefree ()
#3  0x809b069 in Perl_rxres_restore ()
#4  0x809ad76 in Perl_pp_substcont ()
#5  0x80b155d in Perl_runops_standard ()
#6  0x8059308 in perl_run ()
#7  0x805787f in main ()
#8  0x400671eb in __libc_start_main (main=0x8057810 <main>, argc=3, 
    argv=0xbffff894, init=0x8056b2c <_init>, fini=0x80b15cc <_fini>, 
    rtld_fini=0x4000a610 <_dl_fini>, stack_end=0xbffff88c)
    at ../sysdeps/generic/libc-start.c:90

Perl6 "where" for the core

Core was generated by `/home/guest/bin/perl6 T.pl [...]'
Program terminated with signal 11, Segmentation fault.
Reading symbols from /lib/libnsl.so.1...done.
Reading symbols from /lib/libdb.so.3...done.
Reading symbols from /usr/lib/libgdbm.so.2...done.
Reading symbols from /lib/libdl.so.2...done.
Reading symbols from /lib/libm.so.6...done.
Reading symbols from /lib/libc.so.6...done.
Reading symbols from /lib/libcrypt.so.1...done.
Reading symbols from /lib/ld-linux.so.2...done.
#0  __libc_free (mem=0x49222020) at malloc.c:2941
2941    malloc.c: No such file or directory.
(gdb) where
#0  __libc_free (mem=0x49222020) at malloc.c:2941
#1  0x8086854 in Perl_safefree ()
#2  0x80ad813 in Perl_rxres_restore ()
#3  0x80ad4fa in Perl_pp_substcont ()
#4  0x809140d in Perl_runops_standard ()
#5  0x805bc40 in S_run_body ()
#6  0x805b9eb in perl_run ()
#7  0x8059911 in main ()
#8  0x400a71eb in __libc_start_main (main=0x80598b0 <main>, argc=3, 
    argv=0xbffff884, init=0x8058b14 <_init>, fini=0x80d17fc <_fini>, 
    rtld_fini=0x4000a610 <_dl_fini>, stack_end=0xbffff87c)
    at ../sysdeps/generic/libc-start.c:90



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

Date: Tue, 28 Nov 2000 15:31:29 GMT
From: flint@flintslacker.com (Flint Slacker)
Subject: Re: Perl not executing from Cron job
Message-Id: <3a24cdcc.67895358@news.tcn.net>


This is from redhat 6.1.....

This using crontab -e

* * * * * /tmp/env.pl

#!/usr/bin/perl

open(OUT, "> /tmp/ENV.txt.old.1");
foreach $key (keys %ENV) {
        print OUT "$key = $ENV{$key}\n";
}

HOSTTYPE = i386
LOGNAME = root
OSTYPE = Linux
TERM = dumb
SHELL = /bin/sh
HOME = /root
SHLVL = 1
PATH = /usr/bin:/bin

This runs........ now the same program, still crontab -e

* * * * * root /tmp/env.pl

This fails, but the same line in /etc/crontab run perfectly.....

Maybe your crontab entry is incorrect, just a thought.

Flint



On Mon, 27 Nov 2000 11:03:32 +1000, "Paul Mulloni"
<paul@NOSPAM.multibase.com.au> wrote:

>Hello all,
>System:
>    Red hat 6.1
>    Perl 5.005_03
>
>The perl script will execute from the command line but when the perl scripts
>is run from a cron job it does not work.  It looks like it wants to run the
>script file using the /usr/sh shell instead of the perl shell even though
>the "#!/usr/bin/perl" line is set. I have found that a SHELL environment
>variable can be set within the cron job so setting it  to "/usr/bin/perl"
>has the perl script working to a certain extent.  When this is set then the
>perl script is executed as if the -c option is set so it does not actually
>execute the script only compiles it!!!
>
>Not sure why this is happening??
>
>Paul.
>
>



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

Date: 28 Nov 2000 09:33:27 -0700
From: gls33@byu.edu
Subject: Re: Posting Guidelines?
Message-Id: <ubsv05a5k.fsf@SNOW.i-did-not-set--mail-host-address--so-shoot-me>

tadmc@metronet.com (Tad McClellan) writes:


> I'll take a stab at some posting guidelines.

A while back I posted some basic guidelines, a couple of other people
chimed in with some improvements, looking at that discussion may be a
good place to start (you have my full permission to use anything that
I wrote).  The Deja.com url for the post is:
http://x64.deja.com/[ST_rn=ps]/threadmsg_ct.xp?AN=538903079.1&mhitnum=31&CONTEXT=975428579.1692729350

or do your own search using snow@statsci.com as the author and "Ignore
the idiots" as the thread title.

hope this helps,

--
---------------------------------------------------------------------
 Dr. Gregory L. Snow         |  Inertia makes the world go round,
     (Greg)                  |   Love makes the trip worth taking.
   gls@byu.edu               |
---------------------------------------------------------------------


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

Date: Tue, 28 Nov 2000 08:54:50 -0800
From: Jeff Zucker <jeff@vpservices.com>
Subject: Re: Reading a csv file
Message-Id: <3A23E35A.AD526D23@vpservices.com>

Bart Lateur wrote:
> 
> David Wall wrote:
> 
> >He'd probably be better off using Text:CSV_XS to parse the CSV file, unless
> >he knows ahead of time that this code will work.
> 
> Oh yeah?
> 
> If Text::CSV_XS rejects your input, there's nothing you can do about it.
> It happens.
> 
> At least, with your own parsing code in Perl, you can *make it work*.
> 
> (Only half joking)

Joking or not, you are incorrect that there is "nothing you can do about
it" -- at a minimum, you can wrap the call to Text::CSV_XS->parse() in
an eval and handle lines it barfs on any way you want.  How is that any
different from any parser (HTML::Parser, XML::Parser, etc.)? -- they all
die when they encounter data that doesn't fit their definition of well
formed and that's what they should do.

Given that the separator, escape, and end of line patterns are all user
definable; that you can choose to allow embedded newlines or not; etc,
it is difficult for me to see what kind of data could conceivably be
called well-formed CSV that it would not handle that a regex would.  Do
you have an example?

-- 
Jeff


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

Date: 28 Nov 2000 13:04:04 -0500
From: darkon@one.net (David Wall)
Subject: Re: Reading a csv file
Message-Id: <8FFA85C31darkononenet@206.112.192.118>

bart.lateur@skynet.be (Bart Lateur) wrote in
<6r572tcm3ip7kr079lqifuncb1oq7mmutu@4ax.com>: 

>David Wall wrote:
>
>>He'd probably be better off using Text:CSV_XS to parse the CSV file,
>>unless he knows ahead of time that this code will work.
>
>Oh yeah?
>
>If Text::CSV_XS rejects your input, there's nothing you can do about it.
>It happens.
>
>At least, with your own parsing code in Perl, you can *make it work*.
>
>(Only half joking)

A good point.  Ok, how about using Text::ParseWords?  :-)  I deliberately 
used some data below that Text::CSV_XS doesn't like, but this code 
processes it fine....  (I only used Text::ParseWords because I didn't want 
to fiddle around with all the stuff myself)


#!/usr/bin/perl -w
use strict;
use Text::ParseWords;
use CGI qw/header Td Tr start_html start_table/;

print header, 
    start_html(-title=>"Doc title"), 
    start_table({width=>"100%", border=>"0"}), "\n";
print Tr(Td( [qw/Date Match Name1 Name2 Name3/] )), "\n";
while (<DATA>) {
    chomp;
    # keep delims inside fields for nicknames
    my @field = &quotewords(',\s*', 1, $_); 
    foreach (@field) {
        s/^"//;
        s/"$//;
    }
    print Tr(Td(\@field));
    print "\n";
}
print end_table, end_html;

__DATA__
7-Nov-2000,Yes,"Smith, John","Doe, John","Doe, Jane"
7-Nov-2000, Yes, "Smith, John", "Doe, John", "Doe, Jane"
12-Dec-2000, "No", "Smith, John", "Doofus, James "Billy"", "Doe, Jane"
12-Dec-2000, "No", "Smith, John", "Doofus, James 'Billy'", "Doe, Jane"

-- 
David Wall
darkon@one.net


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

Date: Tue, 28 Nov 2000 15:39:00 +0100
From: Lex Hagen <l.hagen@HumanInference.com>
Subject: running Perl program on NT and accessing a UNIX machine
Message-Id: <04932F2B7E20D211856C00A0C9A060952B0F9E@mail.humaninference.com>

Subj.: running Perl program on NT and accessing a UNIX machine

Hi,

Is it possible to run a Perl program on a Windows NT machine, that logs
on 
to a remote UNIX machine? On that machine the Perl program should
execute some
commands and when this is finished, it should disconnect from the UNIX 
machine and execute some commannds on the Win NT machine (from where it 
is running). After that the Perl program can be terminated.

Anybody knows whether this is possible and how?

All tips are welcome, please send a copy of your respons to
L.Hagen@HumanInference.nl

Thanks in advance,

Lex



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

Date: Tue, 28 Nov 2000 11:57:06 -0500
From: "Neb" <berube@odyssee.net>
Subject: Session tracking!
Message-Id: <qrRU5.266$s8.20852@news.globetrotter.net>

Hi,

I'm wondering, is there a way to create a unique session ID for people
visiting my web site using some of the ENV variables ?  I do not want to
store the ID on the client using a cookie.  I want that everytime the client
access a WEB page, I can find the ID using the information of the client,
like something like the IP address, the browser name and version, etc.

Is there a combo of many ENV variables that will create a unique session ?

Thank you,

neb






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

Date: Tue, 28 Nov 2000 12:18:52 -0500
From: Drew Simonis <dsimonis@fiderus.com>
Subject: Re: Session tracking!
Message-Id: <3A23E8FC.4D96FE4A@fiderus.com>

Neb wrote:
> 
> Hi,
> 
> I'm wondering, is there a way to create a unique session ID for people
> visiting my web site using some of the ENV variables ?  I do not want to
> store the ID on the client using a cookie.  I want that everytime the client
> access a WEB page, I can find the ID using the information of the client,
> like something like the IP address, the browser name and version, etc.
> 
> Is there a combo of many ENV variables that will create a unique session ?
> 

Likely not.  Don't ever count on environment vars coming to you for 
something like a session id.  It is too easily forged, and may not
even be present.  You'll find alot of good discussion on maintaining 
state with Perl over in comp.infosystems.www.authoring.cgi, but this
question is not on topic here.


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

Date: 28 Nov 2000 18:06:28 GMT
From: abigail@foad.org (Abigail)
Subject: Re: Session tracking!
Message-Id: <slrn927t14.mnq.abigail@tsathoggua.rlyeh.net>

On Tue, 28 Nov 2000 11:57:06 -0500, Neb (berube@odyssee.net) wrote in comp.lang.perl.misc <URL: news:<qrRU5.266$s8.20852@news.globetrotter.net>>:
++ Hi,
++ 
++ I'm wondering, is there a way to create a unique session ID for people
++ visiting my web site using some of the ENV variables ?  I do not want to
++ store the ID on the client using a cookie.  I want that everytime the client
++ access a WEB page, I can find the ID using the information of the client,
++ like something like the IP address, the browser name and version, etc.


No. But what an earth does this have to do with Perl?



Abigail


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

Date: 28 Nov 2000 18:11:17 +0000
From: nobull@mail.com
Subject: Re: Session tracking!
Message-Id: <u9k89ootkq.fsf@wcl-l.bham.ac.uk>

"Neb" <berube@odyssee.net> writes off-topic:

> I do not want to store the ID on the client using a cookie.  I want
> that everytime the client access a WEB page, I can find the ID using
> the information of the client, like something like the IP address,
> the browser name and version, etc.

> Is there a combo of many ENV variables that will create a unique session ?

No. This has nothing to do with Perl.

-- 
     \\   ( )
  .  _\\__[oo
 .__/  \\ /\@
 .  l___\\
  # ll  l\\
 ###LL  LL\\


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

Date: Tue, 28 Nov 2000 18:35:06 GMT
From: flint@flintslacker.com (Flint Slacker)
Subject: Re: Session tracking!
Message-Id: <3a23f923.2293648@news.tcn.net>


If you can get the person into .htaccess protected directory you can
track them using $ENV{'REMOTE_USER'}.  Using mod_auth_mysql,
mod_rewrite and some good scripting, you can log people in without
having to prompt them for a username and password, but be warned,
people bookmark inside the protected area are your enemy.

:)

Flint

On Tue, 28 Nov 2000 12:18:52 -0500, Drew Simonis
<dsimonis@fiderus.com> wrote:

>Neb wrote:
>> 
>> Hi,
>> 
>> I'm wondering, is there a way to create a unique session ID for people
>> visiting my web site using some of the ENV variables ?  I do not want to
>> store the ID on the client using a cookie.  I want that everytime the client
>> access a WEB page, I can find the ID using the information of the client,
>> like something like the IP address, the browser name and version, etc.
>> 
>> Is there a combo of many ENV variables that will create a unique session ?
>> 
>
>Likely not.  Don't ever count on environment vars coming to you for 
>something like a session id.  It is too easily forged, and may not
>even be present.  You'll find alot of good discussion on maintaining 
>state with Perl over in comp.infosystems.www.authoring.cgi, but this
>question is not on topic here.



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

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 V9 Issue 4979
**************************************


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