[23669] in Perl-Users-Digest

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

Perl-Users Digest, Issue: 5876 Volume: 10

daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Sun Nov 30 21:05:46 2003

Date: Sun, 30 Nov 2003 18:05:07 -0800 (PST)
From: Perl-Users Digest <Perl-Users-Request@ruby.OCE.ORST.EDU>
To: Perl-Users@ruby.OCE.ORST.EDU (Perl-Users Digest)

Perl-Users Digest           Sun, 30 Nov 2003     Volume: 10 Number: 5876

Today's topics:
    Re: binding ICMP to a specific IP address (David Efflandt)
    Re: binding ICMP to a specific IP address <vladimir@NoSpamPLZ.net>
    Re: character encodings <usenet@morrow.me.uk>
    Re: character encodings <flavell@ph.gla.ac.uk>
    Re: Deleting tmp-files of CGI.pm upload() (David Efflandt)
    Re: Deleting tmp-files of CGI.pm upload() <johanoberm@gmx.de>
    Re: Deleting tmp-files of CGI.pm upload() <usenet@morrow.me.uk>
    Re: hash key evaluation creates an entry ! <eddGallary2@hotmail.com>
    Re: hash key evaluation creates an entry ! <REMOVEsdnCAPS@comcast.net>
        How to find what is in my current @INC? <Temp@NoSuchDomain.Info>
    Re: How to find what is in my current @INC? <nospam_for_jkeen@concentric.net>
    Re: How to find what is in my current @INC? <tore@aursand.no>
    Re: Memory Allocation Error when to fetching BLOB field (William Herrera)
    Re: number formatting.. <david@simplymaya.com>
    Re: perl 5.6 multi byte <nmihai_year_2000@yahoo.com>
    Re: Problem installing through PPM <invalid-email@rochester.rr.com>
    Re: Syntax checking of user input <invalid-email@rochester.rr.com>
    Re: traping a request termination from a browser <johnm@aiamail.com>
    Re: trouble with DBI/CGI <Juha.Laiho@iki.fi>
    Re: trouble with DBI/CGI <jwillmore@remove.adelphia.net>
        Digest Administrivia (Last modified: 6 Apr 01) (Perl-Users-Digest Admin)

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

Date: Sun, 30 Nov 2003 19:55:14 +0000 (UTC)
From: efflandt@xnet.com (David Efflandt)
Subject: Re: binding ICMP to a specific IP address
Message-Id: <slrnbskip2.73u.efflandt@typhoon.xnet.com>

On 30 Nov 2003 10:09:58 -0800, Stuart Kendrick <skendric@fhcrc.org> wrote:
> hi,
> 
> i'd like to run a number of ICMP intensive scripts from a single box.  
> in my experience, this is problematic ... ICMP doesn't support ports 
> the way TCP and UDP do, so the IP stack doesn't know to which process 
> to return the ICMP Echo Reply ... so process A can receive a response 
> to a ping which process B emitted ... neither process enjoys this ... 
> nor does the operator.

You ping a specific host or IP, so unless 2 processes are pinging the 
same host, this should be a non-issue whether true or not.  I used Linux 
ping to ping 2 hosts simultaniously from 2 xterms, and both responded 
properly.

> ok, so i can rewrite fping in Perl ... the Net::Ping module ships with
> example code.  and Net::Ping supports a 'bind' parameter, which allows 
> lets me specify the source IP address for the ICMP packet.  but then, 
> i have to run my scripts as root or at least as setuid root ... neither 
> of which thrills me.
> 
> Net::Ping::External doesn't require root access to run, as it uses the 
> OS's ping binary.  But ... it doesn't yet support binding to different 
> IP addresses (presumably, the "-I" parameter varies enough between OSes 
> that this is hard to support).
> 
> i think i'm stuck.  i think i need more hardware -- one box per
> ping-intensive app.

The normal purpose of a bind parameter is if routing is ambiguous.  Did
you ever stop to think that you could simply edit the module to suit your
desires?  Just curious why you need to run that ping-intensive app.  That
could be considered abuse unless you own the IPs being pinged.

-- 
David Efflandt - All spam ignored  http://www.de-srv.com/


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

Date: Mon, 01 Dec 2003 00:44:33 GMT
From: lostriver <vladimir@NoSpamPLZ.net>
Subject: Re: binding ICMP to a specific IP address
Message-Id: <R9wyb.24994$Ac1.505354@weber.videotron.net>

On 30 Nov 2003 10:09:58 -0800, Stuart Kendrick wrote:
> hi,
> 
> i'd like to run a number of ICMP intensive scripts from a single box.  
> in my experience, this is problematic ... ICMP doesn't support ports 
> the way TCP and UDP do, so the IP stack doesn't know to which process 
> to return the ICMP Echo Reply ... so process A can receive a response 
> to a ping which process B emitted ... neither process enjoys this ... 
> nor does the operator.

That should not be a problem, ICMP Pings (Echo/Echo Reply  -  Type 8/0, Code 0) 
do have ID field and Sequence # .....

RFC 792, page 15:

    The data received in the echo request message must be returned in the 
echo reply message.

    The identifier and sequence number may be used by the echo sender to 
aid in matching the replies with the echo requests. For example, the identifier 
might be used like a port in TCP or UDP to identify a session, and the sequence 
number might be incremented on each echo request sent. The echoer returns these 
same values in the echo reply.


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

Date: Sun, 30 Nov 2003 21:16:10 +0000 (UTC)
From: Ben Morrow <usenet@morrow.me.uk>
Subject: Re: character encodings
Message-Id: <bqdmmq$a9h$1@wisteria.csv.warwick.ac.uk>


Jaap Karssenberg <j.g.karssenberg@student.utwente.nl> wrote:
> I have a script that should read files utf8 compliant, so I used
> binmode(FILE, ':utf8'). But now it appears some users have latin2
> encoded files, causing some regexes to throw warnings about malformed
> utf8 chars. Is there a way to detect the character encoding and DWIM ? I
> would hate to have to tell my users they should convert everything to
> utf8 first.

You can't, in general. One thing you could try is

1. open the file in :raw mode.
2. read a largeish chunk into a $scalar.
3. turn the utf8 flag on with Encode::_utf8_on($scalar);.
4. check if the data is valid with Encode::is_utf8($scalar, 1);.
5. If it is, reopen the file with :utf8. If it ain't, assume latin2
   and reopen with :encoding(latin2).

It seems there is no way to check if a sequence of bytes forms valid
utf8 without first setting the utf8 flag on... but never mind
that. Note that it is perfectly possible for data that was in fact
saved in latin2 to pass this test, just rather unlikely; and that if
next week you find some users are using latin1 you're completely
screwed, as there's no way to tell latin1 from latin2. :)

Ben

-- 
Like all men in Babylon I have been a proconsul; like all, a slave ... During
one lunar year, I have been declared invisible; I shrieked and was not heard,
I stole my bread and was not decapitated.
~ ben@morrow.me.uk ~                   Jorge Luis Borges, 'The Babylon Lottery'


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

Date: Sun, 30 Nov 2003 21:41:10 +0000
From: "Alan J. Flavell" <flavell@ph.gla.ac.uk>
Subject: Re: character encodings
Message-Id: <Pine.LNX.4.53.0311302133390.16904@ppepc56.ph.gla.ac.uk>

On Sun, 30 Nov 2003, Jaap Karssenberg wrote:

> On Sun, 30 Nov 2003 16:52:46 GMT Jürgen Exner wrote:
> : You don't tell us what kind fo files those are.
> : For e.g. HTML or XML the meta charset header resp. the encoding
> : attribute should tell you what encoding to expect.
> : Just scan for it and evaluate the rest of the file accordingly.
>
> Can be all kinds of files, the script is there to determine what they
> are.

It can't be done, in general.  There is no way to reliably distinguish
between the commonly-used 8-bit codes (iso-8859-whatever, etc.), for
example.  It would be sheer guesswork, without some kind of additional
knowledge, language analysis or something.

As others have said, utf-8 can be verified for consistency, and the
hypothesis rejected if it proves to be false.  But passing the
consistency test doesn't incontrovertibly prove that it's utf-8: it
might just be a co-incidence that a particular 8-bit-coded text passed
the utf-8 consistency check.

So we really _do_ need to know more about your situation if we are to
offer any kind of realistic help.

> In general the files have neither meta data attached to them or
> headers with meta data.

Then you're stuck with trying heuristic methods, IMHO.


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

Date: Sun, 30 Nov 2003 20:01:04 +0000 (UTC)
From: efflandt@xnet.com (David Efflandt)
Subject: Re: Deleting tmp-files of CGI.pm upload()
Message-Id: <slrnbskj40.73u.efflandt@typhoon.xnet.com>

On Sun, 30 Nov 2003, Ben Morrow <usenet@morrow.me.uk> wrote:
> 
> yf110@vtn1.victoria.tc.ca (Malcolm Dew-Jones) wrote:
>> : 4) unlink(*{$fh}) or die "Can't remove uploaded temp file: $!";
>> 
>> I would always include the file name in the error message, so here I might 
>> try
>> 
>> 	die "Can't remove uploaded temp file: $!, ",*{$fh};
> 
> Unless I am very much mistaken, that is not a filename at all but a
> filehandle. This will be why you can't unlink it: perl will be
> attempting to unlink the stringification of the filehandle, which is
> unlikely to be terribly successful.

Whatever it is, it is a read-once filehandle.  So it can be read once and 
saved, but that is it.  It is removed automatically, so there is no need 
to attempt that.

-- 
David Efflandt - All spam ignored  http://www.de-srv.com/


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

Date: Mon, 01 Dec 2003 00:13:28 +0100
From: Jo Oberman <johanoberm@gmx.de>
Subject: Re: Deleting tmp-files of CGI.pm upload()
Message-Id: <35uksvg5v5jbo3vpemh7h45jluuootc7ea@4ax.com>

> .... saved, but that is it.  It is removed automatically, so there is no need 
>to attempt that.

Unfortunately, not. 
Using my configuration (Windows XP, Apache 1.3.27, Perl 5.6.1, CGI.pm V2.93),
the CGItemp-files are left in my directoy c:\temp.
So I have to help myself.

Any idea's how to delete them?

Thanks
Jo


On Sun, 30 Nov 2003 20:01:04 +0000 (UTC), efflandt@xnet.com (David Efflandt) wrote:

>On Sun, 30 Nov 2003, Ben Morrow <usenet@morrow.me.uk> wrote:
>> 
>> yf110@vtn1.victoria.tc.ca (Malcolm Dew-Jones) wrote:
>>> : 4) unlink(*{$fh}) or die "Can't remove uploaded temp file: $!";
>>> 
>>> I would always include the file name in the error message, so here I might 
>>> try
>>> 
>>> 	die "Can't remove uploaded temp file: $!, ",*{$fh};
>> 
>> Unless I am very much mistaken, that is not a filename at all but a
>> filehandle. This will be why you can't unlink it: perl will be
>> attempting to unlink the stringification of the filehandle, which is
>> unlikely to be terribly successful.
>
>Whatever it is, it is a read-once filehandle.  So it can be read once and 
>saved, but that is it.  It is removed automatically, so there is no need 
>to attempt that.



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

Date: Mon, 1 Dec 2003 00:44:46 +0000 (UTC)
From: Ben Morrow <usenet@morrow.me.uk>
Subject: Re: Deleting tmp-files of CGI.pm upload()
Message-Id: <bqe2tu$k7s$1@wisteria.csv.warwick.ac.uk>


Jo Oberman <johanoberm@gmx.de> wrote:
> > .... saved, but that is it.  It is removed automatically, so there
> >is no need to attempt that.
> 
> Unfortunately, not. 
> Using my configuration (Windows XP, Apache 1.3.27, Perl 5.6.1, CGI.pm V2.93),
> the CGItemp-files are left in my directoy c:\temp.
> So I have to help myself.
> 
> Any idea's how to delete them?

my $TMPFH       = $Query->upload(...);
my $tmpfilename = $Query->tmpFileName($TMPFH);

For some reason this is undocumented... it doesn't seem to be
'internal', or anything...

Ben

[don't include a full quote of the article you're replying to]

-- 
It will be seen that the Erwhonians are a meek and long-suffering people,
easily led by the nose, and quick to offer up common sense at the shrine of
logic, when a philosopher convinces them that their institutions are not based 
on the strictest morality.  [Samuel Butler, paraphrased]       ben@morrow.me.uk


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

Date: Mon, 01 Dec 2003 06:13:40 +1100
From: Edo <eddGallary2@hotmail.com>
Subject: Re: hash key evaluation creates an entry !
Message-Id: <3FCA4164.1000502@hotmail.com>


> To find the size of the array, using $# or @
> 
> 	use strict;
> 
> 	my %set;
> 	$set{1} = [1,2,3,4,5,6,7];
> 
> 	print "\n syntax for array \n";
> 
> 	print @{$set{1}};
> 
> 	print "\n same syntax, but get index instead of values \n";
> 
> 	print $#{$set{1}} ;
> 
> 	print "\n or get number of elements \n";
> 
> 	print scalar @{$set{1}} ;



after 2 1/2 hr of playing around with the debugger and the code I 
finally got it.
I know some of you could have done this in 2 1/2 minuts. but I am learning.
the show sub below, is there a module to print out any of this kind of 
data structure sorted already with out having to write a 100 times 
foreach loops?   thanks

         if (( $tmp > $max )||($tmp == 1)) {
             my %slic;
             foreach my $ky ( @kdslic ){
                 $slic{$sym}{$ky} = $$dbits{$ky};
             }
             push @{$set{$tmp}},\%slic;
         }


     if ( exists $set{1}) {
         if ($#{$set{1}}> $enf) {
             splice @{$set{1}}, $enf;
             show;
             exit;
         }
     }

and to print out the sorted HoAoH

sub show {
             foreach my $k (sort keys %set) { #HoA
                 print $k, "\n";
                 for my $j ( 0 .. $#{$set{$k}} ){ #AoH
                     foreach my $i ( sort keys %{@{$set{$k}}[$j]} ){ #HoH
                         print "    ", $i, "\n";
                         foreach my $h ( sort keys 
%{%{@{$set{$k}}[$j]}->{$i}} ) { #final hash
                             print "           ", $h, "  ", 
$set{$k}[$j]->{$i}{$h}, "\n";
                         }
                         print "\n\n";
                     }
                 }
             }
         }





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

Date: Sun, 30 Nov 2003 16:41:13 -0600
From: "Eric J. Roode" <REMOVEsdnCAPS@comcast.net>
Subject: Re: hash key evaluation creates an entry !
Message-Id: <Xns9443B42F5FE8Fsdn.comcast@216.196.97.136>

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

Edo <eddGallary2@hotmail.com> wrote in
news:3FCA4164.1000502@hotmail.com: 

> after 2 1/2 hr of playing around with the debugger and the code I 
> finally got it.
> I know some of you could have done this in 2 1/2 minuts. but I am
> learning. the show sub below, is there a module to print out any of
> this kind of data structure sorted already with out having to write a
> 100 times foreach loops?   thanks

Yes, look at the Dumper module.

- -- 
Eric
$_ = reverse sort $ /. r , qw p ekca lre uJ reh
ts p , map $ _. $ " , qw e p h tona e and print

-----BEGIN xxx SIGNATURE-----
Version: PGPfreeware 7.0.3 for non-commercial use <http://www.pgp.com>

iQA/AwUBP8pyZGPeouIeTNHoEQLgMACcDSp8tfS1ljUYM7l+uJFaGmVZUjoAn0aQ
hV/T+lC5Sn43mchWtOBRY8yH
=wYLf
-----END PGP SIGNATURE-----


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

Date: Sun, 30 Nov 2003 22:49:36 GMT
From: "Picker Leon" <Temp@NoSuchDomain.Info>
Subject: How to find what is in my current @INC?
Message-Id: <4uuyb.364341$0v4.19268335@bgtnsc04-news.ops.worldnet.att.net>

Do I do a
where perl
perl-???

I need to tie:file to a standred perl 5.6.1.




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

Date: 01 Dec 2003 00:00:16 GMT
From: "James E Keenan" <nospam_for_jkeen@concentric.net>
Subject: Re: How to find what is in my current @INC?
Message-Id: <bqe0ag$isr@dispatch.concentric.net>


"Picker Leon" <Temp@NoSuchDomain.Info> wrote in message
news:4uuyb.364341$0v4.19268335@bgtnsc04-news.ops.worldnet.att.net...
> Do I do a
> where perl
> perl-???
>
> I need to tie:file to a standred perl 5.6.1.
>
>

Tie::File is not standard to Perl 5.6.1; it is standard to 5.8.  Get it on
CPAN:
http://search.cpan.org/~mjd/Tie-File-0.96/lib/Tie/File.pm




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

Date: Mon, 01 Dec 2003 01:09:51 +0100
From: Tore Aursand <tore@aursand.no>
Subject: Re: How to find what is in my current @INC?
Message-Id: <pan.2003.12.01.00.06.09.615812@aursand.no>

On Sun, 30 Nov 2003 22:49:36 +0000, Picker Leon wrote:
> Do I do a
> where perl
> perl-???

What do you _really_ want to find out?  To find out what is in the @INC
variable, just print it;

  perl -e 'print join("\n", @INC)'

If you want to find out what modules you have installed, refer to the FAQ
(as it's already been answered);

  perldoc -q installed

> I need to tie:file to a standred perl 5.6.1.

If you want to install/upgrade modules from CPAN, you should use the CPAN
modules for that.  Login as root;

  perl -MCPAN -e shell


-- 
Tore Aursand <tore@aursand.no>
"To cease smoking is the easiset thing I ever did. I ought to know,
 I've done it a thousand times." -- Mark Twain


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

Date: Sun, 30 Nov 2003 19:50:16 GMT
From: posting.account@lynxview.com (William Herrera)
Subject: Re: Memory Allocation Error when to fetching BLOB field from MS-SQL server Table
Message-Id: <3fca497b.61725776@news2.news.adelphia.net>

On Sun, 30 Nov 2003 11:24:15 -0500, "Bazil" <Admin@goMonitor.com> wrote:

>- There are no trouble fetching non blob fields, (Text ,numeric etc.)
>-Inserted a 3 character text into Blob Field, OK
>- Fetch a 3 Characte Blob text "ABC" failed as well
>
>It looks like trying to allocate -1 byte to image field and it failes!!!
>

You need to look at the way the image fields are defined originally. Do you
have the SQL code that created the database anywhere? What happens if you fetch
a row of the table using DBI without selecting just the field in question?



---
Use the domain skylightview (dot) com for the reply address instead.


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

Date: Mon, 01 Dec 2003 01:28:57 +0000
From: David <david@simplymaya.com>
Subject: Re: number formatting..
Message-Id: <v56lsvosophf5dag1nf180uufvh7har5qh@4ax.com>

On Thu, 27 Nov 2003 15:11:25 +0200, "Jaan Kronberg"
<jaan.kronberg@mail.ee> wrote:

>Hello there,
>
>
>my $somenumber    = 1000000;
>
>I'd like to format this $somenumber to look like 1.000.000,00
>Can it be done with sprintf? Other ways?
>
>Thx,
>jk
>

If you want a quick way.

use Number::Format;
my $nu = new Number::Format(
    -thousands_sep   => ',',
    -decimal_point   => '.'
);

$nu->format_number($somenumber);




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

Date: Sun, 30 Nov 2003 20:53:16 GMT
From: "Mihai N." <nmihai_year_2000@yahoo.com>
Subject: Re: perl 5.6 multi byte
Message-Id: <Xns94438327A54C4MihaiN@216.148.227.77>


> Hey guys, I need to do some parsing on a file that includes Japanese
> Shift JIS and Chinese GB1312 and was wondering if someone could help
> me with some errors im getting.
Nobody answered her, so I will give it a try :)

> I am not entirely sure what pragmas i need to use, or really
> how to open a wide character file properly (is GB1312 and Japanese
> Shift JIS wide chars?  Is that different from utf8?)  
Nothing special with Perl 5.6.
GB1312 is in fact GB2312 and is used for Simplified Chinese.
Both GB2312 and ShiftJIS are double byte character sets (DBCS).
It does not mean they are wide char.
Some characters have on byte, some have two bytes.
This is why in many cases is a problem to do search, search-replace, etc
for bytes that can be half a characters.
For instance back-slash can be the second byte for several Japanese 
characters. Same for other characters (second byte can be anything above 
0x40)
And yes, they are very different from utf8.
DBCS can have 1 or 2 bytes, utf8 can have up to 5.
DBCS cover one character set only (Simplified Chinese or Japanese, in this 
case), utf8 covers the whole Unicode.
For DBCS it is not possible to tell what bytes can be lead or trayling bytes,
without help from the OS or without hard-coded tables. And the tables are
different from DBCS charset to another. UTF8 is clear, no need of tables.

> I have been
> trying to do research on multilingual support for perl 5.6, but it is
> highly confusing and I am positive I am missing something.  
Main question: why 5.6? 5.8 is out for a long time already, and it is way 
better in handling this kind of problems.
It does supports utf8, regular expressions on utf8, etc.

> My program
> is exiting early without having read the entire file (at least, it is
> only getting through about 10K of a 20K line file).
There is no reason to stop reading, does not matter the encoding.
I suspect something else.
Tell us more about OS, data file (is there a risk to have control 
characters?)
It allways stops in the same place? Did you try to delete some lines from the 
beginning of the files to see where it stops after this? Maybe there is 
a certain line that stops it.

> I've included a
> code snippet and stripped out any attempts at multi-byte compatibility
> I've attempted in the hopes that someone will spot what is obviously
> wrong with it.
Nothing obviously wrong.
Except no ; after "open IN, ..."
And no $g_hLang not defined, but used.

And you increment $i for each line you read, then compare it
against $g_nMaxFiles (again undefined) and exit.
It this what you want? To exit after $g_nMaxFiles lines?
Maybe this is the problem. And has nothing to do with the encoding.

-- 
Mihai
-------------------------
Replace _year_ with _ to get the real email


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

Date: Sun, 30 Nov 2003 22:46:46 GMT
From: Bob Walton <invalid-email@rochester.rr.com>
Subject: Re: Problem installing through PPM
Message-Id: <3FCA7155.3040305@rochester.rr.com>

Nilendu wrote:

> Hello,
> 
> I have to use DateTime::Format::Epoch moudle to convert any given time
> to its corresponding Epoch value. But when i search for the module
> using ppm from active perl 5.6.1 it shows no match for
> Date:Time::Epoch

------^


>  what could be the possible reasons


I recommend you look at http://datetime.perl.org/ -- this set of modules 
is under development, and probably isn't ported to Windoze yet.  In the 
meantime, there are other modules that can do this, like Date::Manip and 
Date::Calc -- which should have come with your distribution.
 ...


> Nilendu

-- 
Bob Walton
Email: http://bwalton.com/cgi-bin/emailbob.pl



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

Date: Sun, 30 Nov 2003 22:18:17 GMT
From: Bob Walton <invalid-email@rochester.rr.com>
Subject: Re: Syntax checking of user input
Message-Id: <3FCA6AAB.30407@rochester.rr.com>

mike wrote:

 ...
> i need to get user input and filter the input like this :
> pass(func1) (OR|AND) pass(anyinput) (OR|AND) pass(func) 
> 
> the conditions to be met are
> 1) check for any number of the word "pass"
> 2) only OR and AND can be used. Therefore the following are valid:
>    - pass(anywords) AND pass(anywords2) OR pass(anyany) 
>    - pass(anywords) AND pass(anywords3)
>    - pass(anywords)
> 3) any number of words and digits can be inside the parenthesis
>    eg pass(abcd) or pass(1d2ad) etc
> 4) cannot have a "runaway" OR or AND, like this
>    - pass(asdfa) OR
>  
> an initial attempt is 
> 
> my $input = <STDIN>;
> chomp($input);
> if ( $input =~ /(OR|AND)$/  )
> {   failed() ; }
> elsif ( $input =~ /^pass\((.*)\)$/ )
> { dosomething(); }
> 
> 
> 
> but i am stuck with this input condition whereby user keys in many
> "pass" ,
> something like this: 
> pass(args1) OR pass(args2) AND pass(args3) OR pass(args4) AND
> pass(args5) OR pass(1234) AND pass(args6) OR pass(aafs)
> 
> in a situation like this, how can i perform input validation using
> regular expressions in perl?


A situation like exactly what?  Is that intended to be a single input 
line which was wrapped somewhere between your posting and my viewing, or 
is it supposed to represent a way of continuing an expression from one 
line to another?  If the former, then a regex like:

   /^pass\([^)]*?\)(?:\s+(?:AND|OR)\s+pass\([^)]*?\))*$/

should work to tell you if you have a valid expression according to your 
stated rules or not.  That's assuming stuff with parens can't be inside 
the pass() calls, etc.

Here is a complete example:

use strict;
use warnings;
while(<DATA>){
	chomp;
	print "input: $_\n";
	if(/^pass\([^)]*?\)(?:\s+(?:AND|OR)\s+pass\([^)]*?\))*$/){
		print "valid\n";
	}
	else{
		print "invalid\n";
	}
}
__END__
pass(anywords) AND pass(anywords2) OR pass(anyany)
pass(anywords) AND pass(anywords3)
pass(anywords)
[next line wrapped when posted]
pass(args1) OR pass(args2) AND pass(args3) OR pass(args4) AND 
pass(args5) OR pass(1234) AND pass(args6) OR pass(aafs)
pass(sdflkj) AND pass(sdflkj) OR

 ...


-- 
Bob Walton
Email: http://bwalton.com/cgi-bin/emailbob.pl



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

Date: Sun, 30 Nov 2003 19:57:05 -0600
From: "John Michael" <johnm@aiamail.com>
Subject: Re: traping a request termination from a browser
Message-Id: <vsl7viio9tom42@corp.supernews.com>

Alright Greg
This is what I have figured out.  I found this in the modules section of the
advanced perl book, but it seems to work in regular scripts as well.

Basically add an END subroutine to the bottom of your script and put what
you want to do in their.  The END subroutine will be called when ever the
script terminates.  I tried it by hitting the stop button while downloading
a large file and it was called.  In fact it is called no matter how the
script is ended even if you do an exit;
One thing you have to be aware of though.  The section can use variables
from the script, but they may not have been used in the script yet so they
may not have a value and could cause some strange output.  It depends on
where the script terminated before the END routine is called.
This worked for me when I tested it.

sub END {
    local(*FH);
    open (FH, ">>temp.info");
        print FH "$temp_var bytes were sent before END BLOCK was called at
$VAR{'fmtd_date'} for PID $$\n";
    close(FH);
    die ;        # this is probably really not needed.
}

You must create the temp.info file first to test it or make the directory
writable.
$temp_var comes from somewhere else in my program where I was sending
output.

Let me know if you find anything else.

cya
John Michael



"Gregory Toomey" <nospam@bigpond.com> wrote in message
news:3368890.zbijW4l4sA@gregs-web-hosting-and-pickle-farming...
> It was a dark and stormy night, and John Michael managed to scribble:
>
> > Say I were to write a script that would server a large file through a
web
> > interface and record somewhere the file size.
> >
> > Is it possible for me to know if the user downloading the file
terminated
> > the connection early so that I could record the correct size?
> >
> > How would I trap this situation so that I could do some sort of roll
back
> > or clean up if this were to happen?
> >
> >
> > Thanks
> > JM
>
> I have a similar problem - I download large files via the web (eg
http://www.ipo-australia.com/download/20031128.txt via Perl/Apache/rewrite
rules/cgi) and want to stop when the user hits stop on the browser. I have
posted questions to various groups in the past month with no success.
>
> I do know
> 1. it is possible - I was using an ISP at one stage that stopped the cgi
when the user hit stop
> 2. Apache knows the user has hit stop, as I see that no bytes are being
sent on the ethernet port
> 3. I have tried trapping SIGPIPE within Perl with no success
>
> So if anybody can provide code that works (rather than describing what
should work) I would be very interested.
>
> gtoomey




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

Date: Sun, 30 Nov 2003 19:27:00 GMT
From: Juha Laiho <Juha.Laiho@iki.fi>
Subject: Re: trouble with DBI/CGI
Message-Id: <bqdg67$2ep$1@ichaos.ichaos-int>

altalingua@hotmail.com (David Morel) said:
>I am having trouble combining DBI and CGI.
>
>Consider the following program:
>
>#!/usr/local/bin/perl -w
>use strict;
>use DBI;
>use CGI ':standard';
>
>print "Content-type: text/plain\n\n";

Btw, as you already have "use CGI ':standard';" there you might
as well use it to your advantage by replacing the
print "Content-type: text/plain\n\n";
with
print header('text/plain');
-- 
Wolf  a.k.a.  Juha Laiho     Espoo, Finland
(GC 3.0) GIT d- s+: a C++ ULSH++++$ P++@ L+++ E- W+$@ N++ !K w !O !M V
         PS(+) PE Y+ PGP(+) t- 5 !X R !tv b+ !DI D G e+ h---- r+++ y++++
"...cancel my subscription to the resurrection!" (Jim Morrison)


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

Date: Sun, 30 Nov 2003 22:54:10 GMT
From: James Willmore <jwillmore@remove.adelphia.net>
Subject: Re: trouble with DBI/CGI
Message-Id: <20031130175409.7c3f2cc7.jwillmore@remove.adelphia.net>

On 30 Nov 2003 07:06:53 -0800
genericax@hotmail.com (Sara) wrote:
> altalingua@hotmail.com (David Morel) wrote in message
> news:<60c4a7b1.0311292116.670c439f@posting.google.com>...
<snip>
> I've found with DBI, many errors DON'T get to the browser, but the
> SQL fails. In those cases, the log file always captures them. This
> is particularly true for incorrect SQL statements.

Because of improper use of the module :-)  You *need* to code so that
errors from DBI calls *are* reported.  For example:

my $dbh = DBI->connect('dbi:ODBC:mydb', 'user', 'pass')
    or die "Connection failed: ", $DBI::errstr,"\n";

The error *will* show in the web server's error log (at least Apache
will do such trival things - not sure about IIS).  And, it *will* show
in the browser, just like other errors, if you use CGI::Carp
(importing 'fatalsToBrowser').

HTH

-- 
Jim

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

a fortune quote ...
Disco is to music what Etch-A-Sketch is to art. 



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

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


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