[19071] in Perl-Users-Digest

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

Perl-Users Digest, Issue: 1266 Volume: 10

daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Sun Jul 8 14:07:16 2001

Date: Sun, 8 Jul 2001 11: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)
Message-Id: <994615507-v10-i1266@ruby.oce.orst.edu>
Content-Type: text

Perl-Users Digest           Sun, 8 Jul 2001     Volume: 10 Number: 1266

Today's topics:
    Re: automatic form submission <creafin1998@yahoo.com>
    Re: Calculating business hours between 2 dates (Tad McClellan)
        dynamicaly creating names for hashes and arrays (Christian Fandel)
    Re: dynamicaly creating names for hashes and arrays (Clinton A. Pierce)
    Re: environment variable in cgi (David Efflandt)
        FAQ: When shouldn't I program in Perl? <faq@denver.pm.org>
    Re: Filtering mail based on size (Clinton A. Pierce)
    Re: grouping characters in variables in Regexps... <jnurick@zdnetonebox.com>
    Re: grouping characters in variables in Regexps... (Tad McClellan)
        How do I use html name anchor tag when html generated b <perl@wizdom.org.uk>
    Re: Is there a more efficient way to code a hash pass?? <bwalton@rochester.rr.com>
    Re: Merging two scripts <David.Hiskiyahu@alcatel.be>
    Re: Modem::Vgetty problems, please help! (David Efflandt)
        MS proxy server <talon@anytimenow.com>
        Multine REGEX <jc_va@spamisnotcool.hotmail.com>
        Parsing PGM files [was: Regex problem] <iltzu@sci.invalid>
    Re: Problem with QUERY_STRING <mail@nexo.de>
    Re: Problem with QUERY_STRING <wyzelli@yahoo.com>
    Re: Problem with QUERY_STRING <dbe@wgn.net>
    Re: Problem with QUERY_STRING <mail@nexo.de>
    Re: Problem with QUERY_STRING <mail@nexo.de>
    Re: Problem with QUERY_STRING <David.Hiskiyahu@alcatel.be>
        problems using perlcc (Michael Amann)
        Program or Script (perlfaq1) [OT?] (5-i's)
    Re: Term::ANSIColor in Windows 2000's CMD <pen411@home.com>
    Re: Term::ANSIColor in Windows 2000's CMD <wyzelli@yahoo.com>
    Re: timeout for perl / win32 ?? <carlo_73@hotmail.com>
        Digest Administrivia (Last modified: 6 Apr 01) (Perl-Users-Digest Admin)

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

Date: Sun, 8 Jul 2001 12:31:31 -0500
From: "John Smith" <creafin1998@yahoo.com>
Subject: Re: automatic form submission
Message-Id: <tkh5q5jm1dd33b@corp.supernews.com>

I don't think that will work, but I'll try anything.

I cannot use a <body onload...>

I think I just need to understand the myForm.submit();
What is wrong (if anything) with the following?  My problem could be with
the perl scripts I'm passing the values to as params.  I'm looking at it
now.  The automatic submit seems to execute as I've seen from my cgi error
log that the script.pl is executing when errors occur inside script.pl.
I'll cross-post this message to the main javascript group in hopes for help
there too.

<FORM NAME ="myForm" METHOD="POST" ACTION="script.pl">
<input type="hidden" name="config" value="cfgvarval">
<input type="hidden" name="myvar" value="myvarval">
</FORM>

<SCRIPT LANGUAGE="JavaScript1.1">
<!-- Begin
myForm.submit();
//  End -->
</script>

Thank you.  Anyone, please provide further help here.


"Smiley" <gurm@intrasof.com> wrote in message
news:3b47fd6f.16654147@news1.on.sympatico.ca...
> John,
>
> I'm not sure I understand what you're getting at here - but if you
> want to send form data to a script without actually getting the data
> from the user, it's pretty easy to do.  You'd just refer to the script
> something like this :
>
>
http://www.yourserver.com/cgi-bin/yourscript.cgi?item1="Hello"&item2="There"
>
> Your form data are item1 and item2, and their values respectively are
> Hello and There.  Doing this you don't have to submit the data from a
> form when you call the script.
>
> Is that what you wanted to know?  If not, could you be a little more
> specific?
>
> On Sat, 7 Jul 2001 22:05:35 -0500, "John Smith"
> <creafin1998@yahoo.com> wrote:
>
> >Does anyone know how to submit a form automatically (cannot require
buttons
> >or user interaction) within a perl script?  I've tried the following with
a
> >few variations:
> >
> >print "
> ><FORM NAME =\"Somescript\" METHOD=\"POST\" ACTION=\"script.pl\"> <input
> >type=\"hidden\" name=\"config\" value=\"$configvar\">   <input
> >type=\"hidden\" name=\"myvar\" value=\"$myvar\"
> >onChange=\"Somescript.submit()\"> </FORM>";
> >
> >Please help.
> >
> >Thanks in advance.
>




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

Date: Sun, 8 Jul 2001 11:42:17 -0400
From: tadmc@augustmail.com (Tad McClellan)
Subject: Re: Calculating business hours between 2 dates
Message-Id: <slrn9kgvqp.137.tadmc@tadmc26.august.net>

Bart Lateur <bart.lateur@skynet.be> wrote:
>Alan J. Flavell wrote:
>
>>With respect, the FAQ is only the easy part of the hon.
>>Usenaut's actual question.  (And we don't seem to have heard
>>what we're supposed to do about public holidays yet...).
>
>Public holidays aren't business hours.


Yes and that, I think, was exactly what Alan was saying!  :-)

The FAQ answer does not handle holidays, and so does not
handle "business days", which Alan suggests was the
"hard part".


>One possibility is to use the Date::Calc module. If you look at the last
>example in the docs as per CPAN, you'll see code to calculate the 
>difference between dates excluding saturdays and sundays. That's a
>start. And IIRC, Steffen Beyer is working on a check to see if a day is
>a holiday, though the online docs don't mention it.


I use the Date::Business module for business _days_, but I never
needed business hours.


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


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

Date: 8 Jul 2001 07:27:58 -0700
From: christian_fandel@web.de (Christian Fandel)
Subject: dynamicaly creating names for hashes and arrays
Message-Id: <1bff553d.0107080627.7c7730e3@posting.google.com>

My Problem is as following:

I have different groups. The name of each group represents one array.
The name of the groups is retrieved from a flat ASCII File and should
be used do create an array. To each group exists an oddity of values
used as references to hashes. the name of these hashes should be
created by the referencing one of the values of the specified group.
In this special hash is at last one value that should be used as a
reference to n hashes with names created so that the name of the
reference value, the group, and an incremantal of n are used.

Whats the way to do it ? Is it possible at all ?

Thanks


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

Date: Sun, 08 Jul 2001 15:12:19 GMT
From: clintp@geeksalad.org (Clinton A. Pierce)
Subject: Re: dynamicaly creating names for hashes and arrays
Message-Id: <nL_17.177456$DG1.29666236@news1.rdc1.mi.home.com>

[Posted and mailed]

In article <1bff553d.0107080627.7c7730e3@posting.google.com>,
	christian_fandel@web.de (Christian Fandel) writes:
> I have different groups. The name of each group represents one array.
> The name of the groups is retrieved from a flat ASCII File and should
> be used do create an array. To each group exists an oddity of values
> used as references to hashes. the name of these hashes should be
> created by the referencing one of the values of the specified group.
> In this special hash is at last one value that should be used as a
> reference to n hashes with names created so that the name of the
> reference value, the group, and an incremantal of n are used.
> 
> Whats the way to do it ? Is it possible at all ?

Of course it's possible.  You're trying to create a hash of hashes
of arrays.  (I think, you're explanation got confusing there at the end.)

Look in the perldsc (data structures cookbook) for some examples of how
to create complex structures using hashes, arrays and references.

-- 
    Clinton A. Pierce            Teach Yourself Perl in 24 Hours  *and*
  clintp@geeksalad.org                Perl Developer's Dictionary
"If you rush a Miracle Man,     for details, see http://geeksalad.org     
	you get rotten Miracles." --Miracle Max, The Princess Bride


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

Date: Sun, 8 Jul 2001 17:09:28 +0000 (UTC)
From: see-sig@from.invalid (David Efflandt)
Subject: Re: environment variable in cgi
Message-Id: <slrn9kh4u8.lh7.see-sig@typhoon.xnet.com>

On 6 Jul 2001 12:07:22 -0700, hao tran <hao7@yahoo.com> wrote:
> Hi all,
> I try to get the simple enviroment variable by $HOME = $ENV{HOME}; 
> but the problem is it is not displayed on the browser like netscape. 
> (using print "Content-type:text/html\n\n")

That variable likely does not exist in CGI unless you set it.  See the
docs for your webserver.  Following is a quick and dirty little env.cgi I
use to list the %ENV hash, but note that some variables you see may be
optional or browser specific:

#!/usr/bin/perl -w
print "Content-type: text/plain\n\n";
foreach (sort keys %ENV) { print "$_: $ENV{$_}\n"; }
# following optional to tell what user is running your CGI on Unix:
print "\nScript is running as ",`whoami`,"\n";

-- 
David Efflandt  (Reply-To is valid)  http://www.de-srv.com/
http://www.autox.chicago.il.us/  http://www.berniesfloral.net/
http://cgi-help.virtualave.net/  http://hammer.prohosting.com/~cgi-wiz/


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

Date: Sun, 08 Jul 2001 12:17:01 GMT
From: PerlFAQ Server <faq@denver.pm.org>
Subject: FAQ: When shouldn't I program in Perl?
Message-Id: <1bY17.57$T3.170736128@news.frii.net>

This message is one of several periodic postings to comp.lang.perl.misc
intended to make it easier for perl programmers to find answers to
common questions. The core of this message represents an excerpt
from the documentation provided with every Standard Distribution of
Perl.

+
  When shouldn't I program in Perl?

    When your manager forbids it--but do consider replacing them :-).

    Actually, one good reason is when you already have an existing
    application written in another language that's all done (and done well),
    or you have an application language specifically designed for a certain
    task (e.g. prolog, make).

    For various reasons, Perl is probably not well-suited for real-time
    embedded systems, low-level operating systems development work like
    device drivers or context-switching code, complex multi-threaded
    shared-memory applications, or extremely large applications. You'll
    notice that perl is not itself written in Perl.

    The new, native-code compiler for Perl may eventually reduce the
    limitations given in the previous statement to some degree, but
    understand that Perl remains fundamentally a dynamically typed language,
    not a statically typed one. You certainly won't be chastised if you
    don't trust nuclear-plant or brain-surgery monitoring code to it. And
    Larry will sleep easier, too--Wall Street programs not withstanding. :-)

- 

Documents such as this have been called "Answers to Frequently
Asked Questions" or FAQ for short.  They represent an important
part of the Usenet tradition.  They serve to reduce the volume of
redundant traffic on a news group by providing quality answers to
questions that keep coming up.

If you are some how irritated by seeing these postings you are free
to ignore them or add the sender to your killfile.  If you find
errors or other problems with these postings please send corrections
or comments to the posting email address or to the maintainers as
directed in the perlfaq manual page.

Answers to questions about LOTS of stuff, mostly not related to
Perl, can be found by pointing your news client to

    news:news.answers

or to the many thousands of other useful Usenet news groups.

Note that the FAQ text posted by this server may have been modified
from that distributed in the stable Perl release.  It may have been
edited to reflect the additions, changes and corrections provided
by respondents, reviewers, and critics to previous postings of
these FAQ. Complete text of these FAQ are available on request.

The perlfaq manual page contains the following copyright notice.

  AUTHOR AND COPYRIGHT

    Copyright (c) 1997-1999 Tom Christiansen and Nathan
    Torkington.  All rights reserved.

This posting is provided in the hope that it will be useful but
does not represent a commitment or contract of any kind on the part
of the contributers, authors or their agents.

                                                           01.10
-- 
    This space intentionally left blank


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

Date: Sun, 08 Jul 2001 15:22:39 GMT
From: clintp@geeksalad.org (Clinton A. Pierce)
Subject: Re: Filtering mail based on size
Message-Id: <3V_17.177554$DG1.29672020@news1.rdc1.mi.home.com>

[no mail, hopeless paranoid address munger]

In article <jb4rsorq4x.fsf@analog.net>,
	mike hardy <no_sp@m.for_me.org> writes:
> I can use Mail::Audit to do everything besides the most important part -
> determining the size of the message.  

The manpage for mail audit says that once you have a Mail::Audit object, you
can call the body method which will return:

	Returns a reference to an array of lines in the body
           of the email.

Let's say you've got:

	$b=$mess->body();

So now you can say:

	if (@$b > 1000) {   # More than 1k lines
		$mess->reject("Blah blah blah");
	}

	for(@$b) { $l+=length }
	if ($l > 10000) {  # More than 10k bytes
		$mess->reject(Blah blah blah");
	}


-- 
    Clinton A. Pierce            Teach Yourself Perl in 24 Hours  *and*
  clintp@geeksalad.org                Perl Developer's Dictionary
"If you rush a Miracle Man,     for details, see http://geeksalad.org     
	you get rotten Miracles." --Miracle Max, The Princess Bride


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

Date: Sun, 08 Jul 2001 16:41:22 +0100
From: John Nurick <jnurick@zdnetonebox.com>
Subject: Re: grouping characters in variables in Regexps...
Message-Id: <s81gkt8qjarv5qj35h0dn9n74q1l17ssth@4ax.com>

On Sun, 8 Jul 2001 01:58:01 -0400, "Richard Morey"
<NOSPAMricharddmorey@yahoo.com> wrote:

>
>Here are two similar chunks of code:
>
>#This, with braces....
>$test = "My name is {print this}";
>$openp = "{";
>$closep = "}";
>
>$test=~/$openp(.*?)$closep/i;
>print "$test\n";
>print $1;
>
>#This, with parentheses....
>$test = "My name is (print this)";
>$openp = "(";
>$closep = ")";
>
>$test=~/$openp(.*?)$closep/i;
>print "$test\n";
>print $1;
>
>The first works as expected - it prints:
>
>My name is {print this}
>print this
>
>The second, however, doesn't. It outputs:
>
>My name is {print this}

No, it prints "My name is (print this)". It's safer to copy and paste
than to re-type!

>What is wrong? Why can't I use the parentheses?

At last! a question I think I can answer!

Parentheses are special in regular expressions. Try this:

use strict;

my $test = "My name is (print this);
my $openp = quotemeta "(";
my $closep = quotemeta ")";

$test =~ /$openp(.*?)$closep/i;

print "$test\n$1\n";


--
With best wishes
John

Please reply to the newsgroup and not by e-mail.


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

Date: Sun, 8 Jul 2001 12:03:42 -0400
From: tadmc@augustmail.com (Tad McClellan)
Subject: Re: grouping characters in variables in Regexps...
Message-Id: <slrn9kh12u.137.tadmc@tadmc26.august.net>

John W. Krahn <krahnj@acm.org> wrote:
>Richard Morey wrote:
>> 
>> Here are two similar chunks of code:
>> 
>> #This, with braces....
>> $test = "My name is {print this}";
>> $openp = "{";
>> $closep = "}";
>> 
>> $test=~/$openp(.*?)$closep/i;
>> print "$test\n";
>> print $1;
>> 

[ snip one with () instead of {} ]

>> The first works as expected - it prints:
>> 
>> My name is {print this}
>> print this


And this one really does print that.


>The characters {, }, (, and ) are special in regular expressions and
>have to be escaped to match the literal characters. 


But {} are only special "sometimes". They are not special in the
OP's first case, which likely added to the confusion.

It appears that perl can, in this case at least, DWIM whether {} is 
a quantifier or not.


>you should test whether the match succeeded so that
>$1 will contain valid data.


That is the Single Most Important Rule of using the 
dollar-digit variables, so I cannot snip it even though
I don't have anything to add to it.


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


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

Date: Sun, 8 Jul 2001 16:38:12 +0100
From: Mark Worsdall <perl@wizdom.org.uk>
Subject: How do I use html name anchor tag when html generated by perl?
Message-Id: <CecJxvEk5HS7EwVU@worsdall.demon.co.uk>

Hi all,

I have perl generating some big web pages, so to make life easier for 
the user I wanted to use the html name tag so the user ends up where 
they were last.

I tried sticking #55 on the end of a POST method (program.pl#55) but the 
html did not display at position 55 where the name 55 was.

I have no idea how I would do this with get method but at the moment 
neither method is working.

Has anyone achieved this?

Mark.
-- 
News:


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

Date: Sun, 08 Jul 2001 16:11:55 GMT
From: Bob Walton <bwalton@rochester.rr.com>
Subject: Re: Is there a more efficient way to code a hash pass??
Message-Id: <3B488673.5489CE3F@rochester.rr.com>

"Carlos C. Gonzalez" wrote:
 ...
> I was wondering if there was a more efficient (perhaps better) way to
> write the following function.
> 
> sub open_file
> {
>   my ($h, $file) = @_;
>   tie %$h, "DB_File", $file, O_RDONLY|O_CREAT, 0666, $DB_HASH
>     or die "Cannot open $file: $!\n";
>   return;
> }
> 
> I call it by:
> 
> open_file(\%h, "D:/www/somefile.db");
> 
> The above seems to work just fine but I am wondering if there is a
> clearer way to write the open_file function regarding the hash
> references.  Such that I don't have to use "%$" to do it.

No, I think you've got it.  My only suggestion regarding clarity would
be to call the hash reference $href or $hash_reference rather than $h.
> 
> Also is it good practice to put an empty return statement at the end of
> functions? I have read some allusions to this in some of the books I
> have.

The only advantage that would have would be that it would always return
either undef or an empty list (depending on context), rather than
whatever the last expression in the sub evaluated to (adjusted to
context).  But unless you are actually making use of the returned value,
the return function at the end of a sub is not needed.  And even if you
are making use of the return value, just stating $value; is equivalent
to return($value);. So the return function is not needed at all unless
you want to return from somewhere other than the end of the function. 
It may be clearer code, though, to include the return statement -- but
in that case, it is also clearer to include the return value, in my
opinion.  But that's all just a matter of style.
 ...
> Carlos
 ...
-- 
Bob Walton


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

Date: Sun, 08 Jul 2001 19:55:28 +0200
From: David HISKIYAHU <David.Hiskiyahu@alcatel.be>
Subject: Re: Merging two scripts
Message-Id: <3B489E90.C3E08846@alcatel.be>


cd wrote:
> 
> I have a script which emails out two messages using information from a
> form. The emails go out in HTML format to two different email
> addresses and it works really well...
> 
> I have another script which works well creating and maintaining a flat
> database. I would like to have the information entered in the form go
> to the email script and to be entered into the database as well....
> 
> Is there any way to do this? Do I merge the scripts? Call one from the
> other? Forget this idea all together?

One could find here tricks with exec'ing one script from the other,
but the best way is the simplest: mix the code of the two scripts into 
one - make a third script to keep the other two working as they are.

Even if you are a novice in programming, do not give up, you can make
it.

Break the task into small exercises, for example:

- In the email-sending script, modify the code so that the job of
  sending the message is done by a subroutine - unless the script is 
  already working like that.

- In the DB-handling script, find the right place in code where you
  can call the email-sending subrouting with the email adress(es) and
  the content of the message.

- Copy the email-sending subroutine into the DB-handling script and 
  'glue' the two by making a procedure call.

Good luck!

--------

Still lost? 

- Send the scripts over, might help to give you a better tip.
- Learn programming, try to get a good book on Perl.

 
> Any help would be appreciated...
> 
> Thanks....

-- 
Quote of the day:
              
Don't tell your friend what you do not want your enemy to know.
- a Jewish proverb


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

Date: Sun, 8 Jul 2001 17:49:39 +0000 (UTC)
From: see-sig@from.invalid (David Efflandt)
Subject: Re: Modem::Vgetty problems, please help!
Message-Id: <slrn9kh79i.lh7.see-sig@typhoon.xnet.com>

On 7 Jul 2001 17:43:24 -0700, Laron <law_40@hotmail.com> wrote:
> Hello, I found you address in a news group.  I hope that you don't
> mind my contacting you....
> 
> I'm trying to use the Modem::Vgetty package to simple call a phone
> number through my modem..  I'm using active perl on windows 2000.
> Everytime I try to run a script, I get an error similar to
> 
> Can't call method "dial" on an undefined value at te.pl line 4.
> 
> here's some example code..
> 
> use Modem::Vgetty;
> my $v = new Modem::Vgetty;
> $number="5555555";
> $v->dial($number);
> $v->waitfor('READY');
> $v->shutdown;

I am not familiar with Modem::Vgetty, but that sounds like a Unix thing
where various gettys are used for incoming connections from serial ports
(modems) and terminals.

You may want to check out Win32::SerialPort (which has also been ported to
Device::SerialPort for Unix).  I have not tried the Win32 variant, but I
was able to communicate and dial out with a modem in Linux using the 
Device one.

-- 
David Efflandt  (Reply-To is valid)  http://www.de-srv.com/
http://www.autox.chicago.il.us/  http://www.berniesfloral.net/
http://cgi-help.virtualave.net/  http://hammer.prohosting.com/~cgi-wiz/


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

Date: Sun, 08 Jul 2001 16:57:06 GMT
From: Lee Bennett <talon@anytimenow.com>
Subject: MS proxy server
Message-Id: <1104_994611426@sabre>

Hi

Does anyone know how to authenicate a user via a NT PDC or BDC to that a perl script can access the web via a Mircosoft proxy server.

Thanks



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

Date: Sun, 08 Jul 2001 15:38:15 GMT
From: "Buck Turgidson" <jc_va@spamisnotcool.hotmail.com>
Subject: Multine REGEX
Message-Id: <H7%17.91896$Md.24958457@typhoon.southeast.rr.com>

I have read Perlvar, and did a search on Google, and I still haven't
come up with the answer.  I am trying to parse a large SQL statement
that is creating thousands of database tables, and pull out the value
for TABLESPACE.  A SQL statement can span multiple lines, and is
invariably terminated with "/" character, to which I've set $/.
However, I cannot get it to print the orphan tablespace in my test
input file.  Any ideas as to what I am doing wrong?



<-------code-------------->

#!/usr/bin/perl -w
$infile="c:\\uf\\temp\\temp.sql";
$oracle_ddl_terminator = "/";   # also tried to escape it e.g. "\/"
$/ = $oracle_ddl_terminator;

open(IN,$infile) or
    die("Cannot open $infile $!");

while(<IN>) {
   if ( /TABLESPACE\s(\w+)/ ) {
      print "$1\n";
   }
}


</-------code-------------->


<-------input-------------->

   ABSENCE_CLASS) TABLESPACE TSINDEX STORAGE (INITIAL 4096 NEXT 4096
   /
   ABSENCE_CLASS) TABLESPACE
   TSORPHAN STORAGE (INITIAL 4096 NEXT 4096
   /
   ABSENCE_CODE) TABLESPACE TSOTHER STORAGE (INITIAL 4096 NEXT 4096
   /
   ABSENCE_TYPE) TABLESPACE TSTHIS STORAGE (INITIAL 4096 NEXT 4096
   /
   ABSENCE_TYPE) TABLESPACE TSTHAT STORAGE (INITIAL 4096 NEXT 4096
   /

</-------input-------------->



<-------output-------------->


C:\uf\temp>perl -w C:\uf\perl\tablspac.pl
TSINDEX
TSOTHER
TSTHIS
TSTHAT


</-------output-------------->









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

Date: 8 Jul 2001 15:59:38 GMT
From: Ilmari Karonen <iltzu@sci.invalid>
Subject: Parsing PGM files [was: Regex problem]
Message-Id: <994606363.19128@itz.pp.sci.fi>

[Crossposted to comp.graphics.misc, where someone might actually know
something about all this stuff..]

In article <m3wv5mkqrb.fsf@dhcp9-173.support.tivoli.com>, Ren Maddox wrote:
>On Fri, 6 Jul 2001, andrew@mvt.ie wrote:
>> 
>> I'm trying to read in binary pgm files, and I've run into a bit of a
>> problem.  The files typically have a header that looks like this;
>
>/^(P5\s+#.*\n)(\d+\s+)(\d+\s+)(\d+\s+)((?s).*)$/

You might as well implement the full binary PGM spec, as described for
example in http://www.daubnet.com/formats/PBM.html

  s/^P5(?:#.*\n|\s)+(\d+)(?:#.*\n|\s)+(\d+)(?:#.*\n|\s)+(\d+)\s//

This should capture the numbers in $1, $2 and $3 -- if it succeeds, the
remaining portion of the string will be the pixel data, and should be
exactly $1*$2 bytes long if I understand the spec correctly.

(Actually, the PGM spec seems to allow for CR-terminated comments.  The
change needed to handle that is trivial, but would make the regexp even
less readable than it already is.)

-- 
Ilmari Karonen -- http://www.sci.fi/~iltzu/
"Get real!  This is a discussion group, not a helpdesk.  You post something,
we discuss its implications.  If the discussion happens to answer a question
you've asked, that's incidental."           -- nobull in comp.lang.perl.misc



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

Date: Sun, 8 Jul 2001 09:41:15 +0200
From: "Emil Horowitz" <mail@nexo.de>
Subject: Re: Problem with QUERY_STRING
Message-Id: <9i92rc$hjks3$1@ID-78897.news.dfncis.de>

$Bill Luebkert <dbe@wgn.net> schrieb in im Newsbeitrag:
3B47A26E.F9554211@wgn.net...
> Emil Horowitz wrote:
> >
> > Hello,
> >
> > out of certain reasons, I need the environment string
$ENV{'CONTENT_LENGTH'}
> > twice:
> >
> > 1.: in "use CGI qw(:standard)"
> > 2.: the normal way over $ENV{'CONTENT_LENGTH'}
> >
> > It looks to me as if the string can only be read once in a script. If
> > "$query = new CGI" comes first, $ENV{'CONTENT_LENGTH'}is empty. If I put
> > $ENV{'CONTENT_LENGTH'}fist, "$query->" does not deliver any values.
> >
> > I could solve the problem if the CGI module would provide a possibility
to
> > get the original QUERY_STRING. I could not find this in the
documentation
> > (maybe missed it). Could anyobody help out?
>
> Your question is a bit confusing.
>
> CGI.pm doesn't alter the %ENV.  Try posting a *brief* complete example
that shows
> your problem.

This is not always correct. If you choose the POST method, the script reads
a data stream (not a vairable) from STDIN, which deletes it. So it would be
helpful if CGI.pm had a function to hand through the original reguest
string.








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

Date: Sun, 8 Jul 2001 19:33:56 +0930
From: "Wyzelli" <wyzelli@yahoo.com>
Subject: Re: Problem with QUERY_STRING
Message-Id: <X%V17.2$Rz3.648@vic.nntp.telstra.net>

"Emil Horowitz" <mail@nexo.de> wrote in message
news:9i7s0v$h0uvg$1@ID-78897.news.dfncis.de...
> Hello,
>
> out of certain reasons, I need the environment string
$ENV{'CONTENT_LENGTH'}
> twice:
>
> 1.: in "use CGI qw(:standard)"
> 2.: the normal way over $ENV{'CONTENT_LENGTH'}
>
> It looks to me as if the string can only be read once in a script. If
> "$query = new CGI" comes first, $ENV{'CONTENT_LENGTH'}is empty. If I put
> $ENV{'CONTENT_LENGTH'}fist, "$query->" does not deliver any values.
>
> I could solve the problem if the CGI module would provide a possibility to
> get the original QUERY_STRING. I could not find this in the documentation
> (maybe missed it). Could anyobody help out?
>

Yes.

Read the envirnoment string into a scalar variable (say $input), then call

my $query = CGI->new($input);

This way the query is available to any CGI object you care to create.

my $query2 = CGI->new($input); # second CGI object with same query string.

Wyzelli
--
#Modified from the original by Jim Menard
for(reverse(1..100)){$s=($_==1)? '':'s';print"$_ bottle$s of beer on the
wall,\n";
print"$_ bottle$s of beer,\nTake one down, pass it around,\n";
$_--;$s=($_==1)?'':'s';print"$_ bottle$s of beer on the
wall\n\n";}print'*burp*';





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

Date: Sun, 08 Jul 2001 04:30:54 -0700
From: "$Bill Luebkert" <dbe@wgn.net>
Subject: Re: Problem with QUERY_STRING
Message-Id: <3B48446E.255CA761@wgn.net>

Emil Horowitz wrote:
> 
> $Bill Luebkert <dbe@wgn.net> schrieb in im Newsbeitrag:
> 3B47A26E.F9554211@wgn.net...
> > Emil Horowitz wrote:
> > >
> > > Hello,
> > >
> > > out of certain reasons, I need the environment string
> $ENV{'CONTENT_LENGTH'}
> > > twice:
> > >
> > > 1.: in "use CGI qw(:standard)"
> > > 2.: the normal way over $ENV{'CONTENT_LENGTH'}
> > >
> > > It looks to me as if the string can only be read once in a script. If
> > > "$query = new CGI" comes first, $ENV{'CONTENT_LENGTH'}is empty. If I put
> > > $ENV{'CONTENT_LENGTH'}fist, "$query->" does not deliver any values.
> > >
> > > I could solve the problem if the CGI module would provide a possibility
> to
> > > get the original QUERY_STRING. I could not find this in the
> documentation
> > > (maybe missed it). Could anyobody help out?
> >
> > Your question is a bit confusing.
> >
> > CGI.pm doesn't alter the %ENV.  Try posting a *brief* complete example
> that shows
> > your problem.
> 
> This is not always correct. If you choose the POST method, the script reads
> a data stream (not a vairable) from STDIN, which deletes it. So it would be
> helpful if CGI.pm had a function to hand through the original reguest
> string.

I said %ENV is not modified by CGI.pm  I said nothing about STDIN.

Rereading the confusing post, it appears he may indeed have been 
talking about STDIN when he mistakenly stated QUERY_STRING since 
he refers to CONTENT_LENGTH (which only applies to STDIN/POST).

-- 
  ,-/-  __      _  _         $Bill Luebkert   ICQ=14439852
 (_/   /  )    // //       DBE Collectibles   Mailto:dbe@todbe.com 
  / ) /--<  o // //      http://dbecoll.webjump.com/ (Free Perl site)
-/-' /___/_<_</_</_     Castle of Medieval Myth & Magic http://www.todbe.com/


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

Date: Sun, 8 Jul 2001 19:19:03 +0200
From: "Emil Horowitz" <mail@nexo.de>
Subject: Re: Problem with QUERY_STRING
Message-Id: <9ia4md$hkgjh$1@ID-78897.news.dfncis.de>

Wyzelli <wyzelli@yahoo.com> schrieb in im Newsbeitrag:
X%V17.2$Rz3.648@vic.nntp.telstra.net...
> "Emil Horowitz" <mail@nexo.de> wrote in message
> news:9i7s0v$h0uvg$1@ID-78897.news.dfncis.de...
> Read the envirnoment string into a scalar variable (say $input), then call
>
> my $query = CGI->new($input);
>
> This way the query is available to any CGI object you care to create.
>
> my $query2 = CGI->new($input); # second CGI object with same query string.
>
> Wyzelli
> --








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

Date: Sun, 8 Jul 2001 19:22:56 +0200
From: "Emil Horowitz" <mail@nexo.de>
Subject: Re: Problem with QUERY_STRING
Message-Id: <9ia4tm$hs0it$1@ID-78897.news.dfncis.de>

Sorry, the post before this one went off by mistake

Emil Horowitz <mail@nexo.de> schrieb in im Newsbeitrag:
9ia4md$hkgjh$1@ID-78897.news.dfncis.de...
> Wyzelli <wyzelli@yahoo.com> schrieb in im Newsbeitrag:
> X%V17.2$Rz3.648@vic.nntp.telstra.net...
> > "Emil Horowitz" <mail@nexo.de> wrote in message
> > news:9i7s0v$h0uvg$1@ID-78897.news.dfncis.de...
> > Read the envirnoment string into a scalar variable (say $input), then
call
> >
> > my $query = CGI->new($input);
> >
> > This way the query is available to any CGI object you care to create.
> >
> > my $query2 = CGI->new($input); # second CGI object with same query
string.
> >
> > Wyzelli
> > --

Thank you, this is a good way to achive the wanted result. If you need the
query string to deal with it outside CGI.pm, you also can hand it through
with this:

$qs = $query->query_string();

Hope this helps.
Emil








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

Date: Sun, 08 Jul 2001 20:01:23 +0200
From: David HISKIYAHU <David.Hiskiyahu@alcatel.be>
To: Emil Horowitz <mail@nexo.de>
Subject: Re: Problem with QUERY_STRING
Message-Id: <3B489FF3.4409A672@alcatel.be>


Why not just do it the old way?

Modules are OK as long as you do things simple
and straightforward, but ones it gets complex
you simply do not have a clue what this module
does inside.

So why not just avoid using the module - after
all the old way (before the module was invented)
only costs you copying a commonly known procedure
of a couple of lines ... then using a hash of 
parameters rather than a qw object - big deal!



Emil Horowitz wrote:
> 
> Hello,
> 
> out of certain reasons, I need the environment string $ENV{'CONTENT_LENGTH'}
> twice:
> 
> 1.: in "use CGI qw(:standard)"
> 2.: the normal way over $ENV{'CONTENT_LENGTH'}
> 
> It looks to me as if the string can only be read once in a script. If
> "$query = new CGI" comes first, $ENV{'CONTENT_LENGTH'}is empty. If I put
> $ENV{'CONTENT_LENGTH'}fist, "$query->" does not deliver any values.
> 
> I could solve the problem if the CGI module would provide a possibility to
> get the original QUERY_STRING. I could not find this in the documentation
> (maybe missed it). Could anyobody help out?
> 
> Emil

-- 
Quote of the day:
              
Don't tell your friend what you do not want your enemy to know.
- a Jewish proverb


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

Date: 8 Jul 2001 06:23:28 -0700
From: michael.amann@surfeu.de (Michael Amann)
Subject: problems using perlcc
Message-Id: <11099217.0107080523.305a9fae@posting.google.com>

Hi all,

I want to use perlcc (perl v5.6.0) and when I issue the following
commdand: perlcc preprocess.pm then I got the following error 
output:
"Can't locate object method "savecv" via package "B::SPECIAL" at 
/usr/lib/perl5/5.6.0/i586-linux/B.pm line 191.
CHECK failed--call queue aborted"

Does anyone knows what I'm doing wrong? If you want I can provide
you with the module (preprocess.pm).

Regards,

Michael


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

Date: Sun, 08 Jul 2001 13:26:53 GMT
From: fiveyes@iiiii.com (5-i's)
Subject: Program or Script (perlfaq1) [OT?]
Message-Id: <3b4f59cc.292396282@news.msy.bellsouth.net>

Reading perlfaq1, under the heading "Is it a Perl program or a Perl
script?", the entry ends with:
"Now that ``script'' and ``scripting'' are terms that have been seized
by unscrupulous or unknowing marketeers for their own nefarious
purposes, they have begun to take on strange and often pejorative
meanings, like ``non serious'' or ``not real programming''.
Consequently, some perl programmers prefer to avoid them altogether."

Can anyone point me to any examples of, or allusions to any of these
"unscrupulous or unknowing marketeers"?  Or at least clarify what the
author meant in a bit more detail?

Numerous search strategies have come up with nothing for me, either on
the web or newsgroups, though I'm certain others have written more
along these lines.  The reason I'm asking is that I'm preparing a
webmaster resource that will have a section devoted to scams and such
and I feel this is something that might be developed further within
that context.  Possibly along the lines of what to be wary of when
dealing with scripts and their installers.

My apologies if this is off topic in the extreme, but my curiosity
does override my better judgement at times.



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

Date: Sun, 08 Jul 2001 07:53:51 GMT
From: "Mark Dudley" <pen411@home.com>
Subject: Re: Term::ANSIColor in Windows 2000's CMD
Message-Id: <jkU17.16764$B5.3593022@news1.rdc1.tn.home.com>

> Has anyone successfully used the Term::ANSIColor module in Windows 2000's
> CMD using ActivePerl?  I've tried using code straight from the module's
> documentation, but still see the standard colors.  If I run the same
script
> on a Linux console, everything works as expected.  Is this a limitation of
> CMD or is there a special option to allow for ANSI colors in it?  Thanks
for
> your help.

I have not seen this module, but..
"Back in the old days", in order to get color from a prompt, you needed to
run the ANSI.SYS driver (or better, NANSI.SYS) unless you were writing in a
application that had a CRT interface or was written in assembly.







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

Date: Sun, 8 Jul 2001 20:58:10 +0930
From: "Wyzelli" <wyzelli@yahoo.com>
Subject: Re: Term::ANSIColor in Windows 2000's CMD
Message-Id: <UeX17.3$Rz3.883@vic.nntp.telstra.net>

"noms" <dont@mail.me> wrote in message news:9i6fa8$qsk$1@bob.news.rcn.net...
> Has anyone successfully used the Term::ANSIColor module in Windows 2000's
> CMD using ActivePerl?  I've tried using code straight from the module's
> documentation, but still see the standard colors.  If I run the same
script
> on a Linux console, everything works as expected.  Is this a limitation of
> CMD or is there a special option to allow for ANSI colors in it?  Thanks
for
> your help.

As far as I know, to get ansi type colors in W2k, you need to be running
ansi.sy, and command.com in compatibilioty mode.  I recall reading something
on ntfaq.com that talked about it.  I think the big hangup was that you
needed to get a fairly old command.com (like DOS 5 or so).

Wyzelli
--
#Modified from the original by Jim Menard
for(reverse(1..100)){$s=($_==1)? '':'s';print"$_ bottle$s of beer on the
wall,\n";
print"$_ bottle$s of beer,\nTake one down, pass it around,\n";
$_--;$s=($_==1)?'':'s';print"$_ bottle$s of beer on the
wall\n\n";}print'*burp*';





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

Date: Sun, 8 Jul 2001 07:57:04 -0400
From: "Carlo B." <carlo_73@hotmail.com>
Subject: Re: timeout for perl / win32 ??
Message-Id: <9i9hkh$hl03m$1@ID-95818.news.dfncis.de>

"Stefan Geißler" <stefan.geissler@temis-group.com> escribió en el mensaje
news:9i4e6t$mvt1@news-1.bank.dresdner.net...
> Hi all,
>
> does anyone know how to set a timeout for perl on win32 systems?
>
> Say you need to do a system call and if this doesn't return within a
> specified time, you
> The alarm() call that is mentioned in perl example for Unix does not exist
> and I haven't been able to find another solution.
>
> Any help greatly appreciated.
> Best,
> Stefan Geißler
>
>
>
>
Im stuck in this problem too, with perl for win32 the alarm function is not
implemented, so is supposed that the only way to add a timeout is using the
select(2) system call.
From perlfunc:
----
select RBITS,WBITS,EBITS,TIMEOUT

This calls the select(2) system call with the bit masks specified, which can
be constructed using fileno and vec, along these lines:
    $rin = $win = $ein = '';
    vec($rin,fileno(STDIN),1) = 1;
    vec($win,fileno(STDOUT),1) = 1;
    $ein = $rin | $win;
If you want to select on many filehandles you might wish to write a
subroutine:

    sub fhbits {
        my(@fhlist) = split(' ',$_[0]);
        my($bits);
        for (@fhlist) {
            vec($bits,fileno($_),1) = 1;
        }
        $bits;
    }
    $rin = fhbits('STDIN TTY SOCK');
The usual idiom is:

    ($nfound,$timeleft) =
      select($rout=$rin, $wout=$win, $eout=$ein, $timeout);
or to block until something becomes ready just do this

    $nfound = select($rout=$rin, $wout=$win, $eout=$ein, undef);
Most systems do not bother to return anything useful in $timeleft, so
calling select() in scalar context just returns $nfound.

Any of the bit masks can also be undef. The timeout, if specified, is in
seconds, which may be fractional. Note: not all implementations are capable
of returning the$timeleft. If not, they always return $timeleft equal to the
supplied $timeout.

You can effect a sleep of 250 milliseconds this way:

    select(undef, undef, undef, 0.25);
WARNING: One should not attempt to mix buffered I/O (like read or <FH>) with
select, except as permitted by POSIX, and even then only on POSIX systems.
You have to use sysread instead.

----


Now i've triyed for weeks to find the way to make this work but since now
seems all to complicate and i cannot find a good example about how to add a
timeout for a socket connect call. Let me know if it works for you.





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

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


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