[15718] in Perl-Users-Digest

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

Perl-Users Digest, Issue: 3131 Volume: 9

daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Tue May 23 06:05:34 2000

Date: Tue, 23 May 2000 03:05:09 -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: <959076308-v9-i3131@ruby.oce.orst.edu>
Content-Type: text

Perl-Users Digest           Tue, 23 May 2000     Volume: 9 Number: 3131

Today's topics:
    Re: ??? help! referrer url should be ...... <gellyfish@gellyfish.com>
    Re: A definition of true? <lr@hpl.hp.com>
    Re: Basic scripting question <gellyfish@gellyfish.com>
    Re: Basic scripting question (Bart Lateur)
    Re: Building a hash array <rhomberg@ife.ee.ethz.ch>
        clpmisc is a *discussion* forum (was Re: regexes *sigh* <gellyfish@gellyfish.com>
    Re: cut off text after a <br> <f.lalane@no-spam.pra.org.uk>
    Re: cut off text after a <br> <bill.kemp@wire2.com>
    Re: cut off text after a <br> <dave@dave.org.uk>
    Re: Form Script <gellyfish@gellyfish.com>
    Re: HELP MEEEEEE <gellyfish@gellyfish.com>
    Re: Help with 500 Internal Server Error <bill.kemp@wire2.com>
    Re: How to COPY a website <user0201@vjeran.com>
    Re: Including variables defined outside the script <dave@dave.org.uk>
    Re: Including variables defined outside the script (Bart Lateur)
    Re: join " ", do {$x++}, do {$x++}, do {$x++}; <Tbone@pimpdaddy.com>
    Re: join " ", do {$x++}, do {$x++}, do {$x++}; (Villy Kruse)
    Re: join " ", do {$x++}, do {$x++}, do {$x++}; (Bart Lateur)
    Re: Looking for a good editor... <gellyfish@gellyfish.com>
    Re: LWP Module and error 500 <f.lalane@no-spam.pra.org.uk>
    Re: PERL and COM port <gellyfish@gellyfish.com>
        Runtime error <Kai.Wipplinger@de.bosch.com>
    Re: SQL newbie question <gellyfish@gellyfish.com>
    Re: Suggest an approach for HTML Form submission <gellyfish@gellyfish.com>
    Re: updated : Re: regexes *sigh* damn I hate these thin (Bart Lateur)
        Digest Administrivia (Last modified: 16 Sep 99) (Perl-Users-Digest Admin)

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

Date: 23 May 2000 07:11:50 +0100
From: Jonathan Stowe <gellyfish@gellyfish.com>
Subject: Re: ??? help! referrer url should be ......
Message-Id: <8gd7f6$8ei$1@orpheus.gellyfish.com>

On Sun, 21 May 2000 15:31:26 -0700 John Springer wrote:
> in article 8g9bin$krk$1@nnrp1.deja.com, swapnil909@my-deja.com at
> swapnil909@my-deja.com wrote on 5/21/00 11:57 AM:
> 
>> BUT I WANT THAT THE REFERRER THAT VALUECLIK.COM RECIEVES IS MYSITE.COM
>> AND NOT MYCLIENTS.COM
>> 
>> could somebody please help what should i do????
>> all programs are done in perl.
>> i have tried quite a few redirection scripts, but none seems to work.
>> 
> The HTTP_REFERER comes from the browser, so there is little you can do about
> it directly.  The only thing I can see is if the ad on the page is pointing
> to say http://valueckick.com/gobble/gobble, you could instead point it to a
> script on your own site.  Then the script goes to valueclick, gets the
> graphic, and delivers it to the client, along with the right click-through
> URLs.  You would have to look like a browser going to valueclick to get the
> client, which you could do with the NET:: libraries and probably some other
> stuff that emulates a browser.  It's not too hard if you just open a telnet
> connection on port 80 and send all the headers a browser would send.
> 

I dont see any reason to go to the effort of reinventing an HTTP client when
the LWP::UserAgent would make this so much easier :


#!/usr/bin/perl -w

use strict;

use LWP::UserAgent;

my $agent = new LWP::UserAgent;


$agent->agent("Gelzilla/666"); 

my $request = new HTTP::Request 'GET' => 'http://localhost';

$request->header('Accept' => 'text/html',
                  Referer => 'http://any.referer.org.uk');


my $result = $agent->request($request);



if ($result->is_success) 
  {
   print $result->as_string;
  } 
else 
 {
   print "Error: " . $result->status_line . "\n";
 }


/J\
-- 
You'll have to speak up, I'm wearing a towel.
-- 
fortune oscar homer


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

Date: Tue, 23 May 2000 00:10:28 -0700
From: Larry Rosler <lr@hpl.hp.com>
Subject: Re: A definition of true?
Message-Id: <MPG.1393ceb863a8b02c98aab8@nntp.hpl.hp.com>

[I wrapped your insanely long first line by hand.  Check your 
newsreader's settings.]

In article <8gcv6i0qbj@enews3.newsguy.com>, vsauder@hekimian.com says...
> Is there a Perl-recommended way to assign TRUE or FALSE to a variable?
> I thought I saw a comment from Larry on not re-assigning the values
> TRUE and FALSE.
> 
> Script:
>   use strict;
>   my $var = true;
> 
> Error:
> Bareword "true" not allowed while "strict subs" in use at C:\temp\t.pl line 2.
> 
> My solution:
>   my $true = 1;
>   my $false = 0;
> 
> Any other solutions?

    my $TRUE  = 1;
    my $FALSE = 0;

(because using all caps for a variable name has a conventional 
connotation of constancy).

Better, because they cannot be changed inadvertantly:

    use constant TRUE  => 1;
    use constant FALSE => 0;

Or, equivalently but less clearly:

    sub TRUE  () { 1 };
    sub FALSE () { 0 };

Or, for any of the above, define FALSE as 0, then TRUE as !FALSE.  Or 
vice versa.

-- 
(Just Another Larry) Rosler
Hewlett-Packard Laboratories
http://www.hpl.hp.com/personal/Larry_Rosler/
lr@hpl.hp.com


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

Date: 23 May 2000 07:18:46 +0100
From: Jonathan Stowe <gellyfish@gellyfish.com>
Subject: Re: Basic scripting question
Message-Id: <8gd7s6$9pc$1@orpheus.gellyfish.com>

On Mon, 22 May 2000 12:58:29 -0400 e adams wrote:
> Hi,
> I'm  new Perl user and would like to know if there is a way to write
> script that, for example, deletes every 3rd line in a file. I am able to
> substitute every 3rd line with a blank line but I can not delete the
> line unless I go into an editor and do it manually.
> Thank you for any advice
> 
perlfaq4:

       How do I change one line in a file/delete a line in a
       file/insert a line in the middle of a file/append to the
       beginning of a file?

/J\
-- 
Black, marbelized with a liquid center. The Stealth Bowler. The pins
don't know what hit 'em.
-- 
fortune oscar homer


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

Date: Tue, 23 May 2000 09:42:35 GMT
From: bart.lateur@skynet.be (Bart Lateur)
Subject: Re: Basic scripting question
Message-Id: <392c4841.2167395@news.skynet.be>

Godzilla! wrote:

>$line_counter = 1;
>
>open (NEW, ">test.txt");
>
>foreach $new_line (@Test)
> {
>  if ($line_counter < 3)
>   { 
>    print NEW $new_line; 
>    $line_counter++;
>   }
>  elsif ($line_counter = 3)

In theory, this ought to have been

   elsif($line_counter == 3)

but, since you don't get here unless $line_counter already is 3 or
higher, and you reset it once you get here, well, you don't even need
this test. That's why you din't notice the error. A simple

	else

will do very nice thank you.

>   { 
>    $line_counter = 1;
>    next; 
>   }
> }

The "next" is superfluous, since it's the last thing you do in the loop.

>Look Ma! No strict, no -w, no nothing
>and it kicks butt all over Perl 5!

I don't care much for "strict", apart from "strict refs" (which warns
against barewords). But "-w" would have told you about the assignment in
the "if" test.

	Found = in conditional, should be == at ...

-- 
	Bart.


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

Date: Tue, 23 May 2000 11:33:19 +0200
From: Alex Rhomberg <rhomberg@ife.ee.ethz.ch>
Subject: Re: Building a hash array
Message-Id: <392A505F.8E2FC62D@ife.ee.ethz.ch>

jimmy_mcnamara@my-deja.com wrote:
> 
> Hi Folks,
> 
> I'm reading arguments from the command line using a perl script. One
> of the arguments say $ARGV[5] will be of the form jim~jack~jill. This is
> probably a very trivial question but can I make a hash array of that
> data so I can access it using something similar to the following
> construct:

Use a hash for lookups:

%AccountAliasList = map {$_ => 1} split /~/, $ARGV[5];

#check whether $AccountAlias is listed in $AccountAliasList
if(exists($AccountAliasList{$AccountAlias}) {

You should be able to use hash lookups instead of looping through the
list
for comparison, as in your code.

- Alex


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

Date: 22 May 2000 21:23:48 +0100
From: Jonathan Stowe <gellyfish@gellyfish.com>
Subject: clpmisc is a *discussion* forum (was Re: regexes *sigh* damn I hate these things )
Message-Id: <8gc50k$vlf$1@orpheus.gellyfish.com>

On 22 May 2000 01:26:57 GMT The WebDragon wrote:
> 
> Start a new thread if you're gonna digress from my questions in the future, 
> thanks. (this goes for anyone, not just you in particular, Godzilla)
> 

Whilst I might concur with you about the ravings of sundry trolls and the
followups they engender - I think you will find that most of the regular posters
here would consider this to be a place for discussion rather than simply answering
questions, after all, apart from the truly altruistic, there would be little
here for a lot of people.  Topic spread is bound to happen in a group like this
and that, in my opinion, is where the really interesting stuff happens (with the
exception of the posts referred to above, which do I admit to being in 
abundance at the moment. )

/J\
-- 
Lisa, stop that racket! I'm trying to fix your mother's camera. Easy,
easy....I think I'll need a bigger drill.
-- 
fortune oscar homer


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

Date: Tue, 23 May 2000 09:32:02 +0100
From: "Franck Lalane" <f.lalane@no-spam.pra.org.uk>
Subject: Re: cut off text after a <br>
Message-Id: <959070717.5683.0.nnrp-08.9e9872de@news.demon.co.uk>


Lance Boyle <lancelotboyle@hotmail.com> wrote in message
news:8gd106$hvb$1@plutonium.btinternet.com...
> Somebody provided a hack below within a perl script to cut off text after
> certain amount of characters
>
> if( length( $newstext ) > 256 ) {
> $tmpnewshtml = substr( $newstext, 0, 128 );
> $tmpnewshtml =~ s/(.*)\s.*/$1/;
> $newshtml .= $tmpnewshtml . qq~
>
> However is it possible to modify this to cut off text after a line break
> <br> instead ?
>
> I have tried a few combinations though not very successfully.
>
> I hope this is on topic as I don't want to be spanked again (well not in
> public anyhow).
>

try
($tmpnewshtml) = $newstext =~ m/(.*)?<br>/;
It should put all the characters before the first <br> in your temp string.

Franck




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

Date: Tue, 23 May 2000 10:27:46 +0100
From: "W Kemp" <bill.kemp@wire2.com>
Subject: Re: cut off text after a <br>
Message-Id: <959074158.19482.1.nnrp-02.c3ad6973@news.demon.co.uk>


>> However is it possible to modify this to cut off text after a line break
>> <br> instead ?


>try
>($tmpnewshtml) = $newstext =~ m/(.*)?<br>/;
>It should put all the characters before the first <br> in your temp string.


Just wondering- does this take into account 'greed'
 ie taking as much as possible into the (.*)? bit
 so if there are more than one <br>,  it will include these too?

SORRY just checked - thats what the ()? is for isn't it? This is quite
subtle stuff]

Oh well, here's an alternative I thought of to do a direct chop, that relies
on .* being able to match with extra <br>'s

$newstext =~ s/<br>.*$//;

Perhaps it would be useful to do it case insensitive too?




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

Date: Tue, 23 May 2000 10:46:27 +0100
From: Dave Cross <dave@dave.org.uk>
Subject: Re: cut off text after a <br>
Message-Id: <2pkkis813shntf2jaghrncng91ojbvpbfv@4ax.com>

On Tue, 23 May 2000 10:27:46 +0100, "W Kemp" <bill.kemp@wire2.com>
wrote:

>
>>> However is it possible to modify this to cut off text after a line break
>>> <br> instead ?
>
>
>>try
>>($tmpnewshtml) = $newstext =~ m/(.*)?<br>/;
>>It should put all the characters before the first <br> in your temp string.
>
>
>Just wondering- does this take into account 'greed'
> ie taking as much as possible into the (.*)? bit
> so if there are more than one <br>,  it will include these too?
>
>SORRY just checked - thats what the ()? is for isn't it? This is quite
>subtle stuff]
>
>Oh well, here's an alternative I thought of to do a direct chop, that relies
>on .* being able to match with extra <br>'s
>
>$newstext =~ s/<br>.*$//;
>
>Perhaps it would be useful to do it case insensitive too?

And perhaps you should take into account the possibility that the
string we're working on contains newline characters.

$newstext =~ s/<br>.*\Z//is;


hth,

Dave...

-- 
<http://www.dave.org.uk>  SMS: sms@dave.org.uk
yapc::Europe - London, 22 - 24 Sep <http://www.yapc.org/Europe/>

"There ain't half been some clever bastards" - Ian Dury [RIP]


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

Date: 23 May 2000 07:37:55 +0100
From: Jonathan Stowe <gellyfish@gellyfish.com>
Subject: Re: Form Script
Message-Id: <8gd903$dep$1@orpheus.gellyfish.com>

On Sun, 21 May 2000 12:40:17 -0700 Marcus Ouimet wrote:
> I am trying to find a perl script that will send the info for a form not
> using sendmail. For some reason the script I am using gives no errors but
> does the following:
> 
> Sends to:
> 
> something@something.com
> something.something.com
> something@something.ca
> something@something.com.au
> 
> Will not send to:
> 
> something@sk.sympatico.ca
> something@websurfer.co.za
> 
>     Does anyone wither know what the problem might be? I am pretty sure it
> is a send mail problem, that is why I am looking for a script that I can
> edit that doesn't use send mail..... Any suggestions/solutions?

Are you sure that it sends the last of four you say it does send ?  I would
suggest that it is some ignorant e-mail address 'validation' on the part of
your script and not a problem with sendmail at all.

/J\
-- 
Mmmm, purple.
-- 
fortune oscar homer


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

Date: Tue, 23 May 2000 09:54:16 GMT
From: Jonathan Stowe <gellyfish@gellyfish.com>
Subject: Re: HELP MEEEEEE
Message-Id: <czsW4.669$6T1.110992@news.dircon.co.uk>

On Mon, 22 May 2000 17:54:26 +0200, Marco Natoni Wrote:
> Jonathan,
> 
> Jonathan Stowe wrote:
>> Obsolete ? Care to explain that comment which seems to be at 
>> variance with the perlstyle document for 5.6.0 :
> 
>   Your PERL itself should explain that
> 
> <cite>
>         Use of bare << to mean <<"" is deprecated at ... line ....
> </cite>
> 

Ah.  Sorry.  I thought you meant heredocs in general.

/J\


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

Date: Tue, 23 May 2000 10:15:46 +0100
From: "W Kemp" <bill.kemp@wire2.com>
Subject: Re: Help with 500 Internal Server Error
Message-Id: <959074157.19482.0.nnrp-02.c3ad6973@news.demon.co.uk>

>your doing it the hard way, trial-and-error. There are easier methods.


I still learn like a child -different people need different learning styles
(did I say I'm an ex-teacher?)
I do find documentation hard to read sometimes (ie do they really want a
square bracket in that, or is it to tell me its optional etc.)
I nearly always try out regular expressions locally first too.

If I have some strange problem it is sometimes useful to run the script with
an 'exit' before it does anything [a method rather like looking for car keys
by retracing your steps from last time you used them]. If it complains about
something on the command line I know I've done something silly.

>If I had taken the approach of creating a local development environment
>to match the target I'd still be working on that instead of getting

>coding done and out the door.


But the perl snippet test box I had in mind could be virtually anything. An
end of life windows PC?





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

Date: Tue, 23 May 2000 10:12:30 +0200
From: "Vjeran" <user0201@vjeran.com>
Subject: Re: How to COPY a website
Message-Id: <8gdepe$f83$1@as102.tel.hr>

Mark-Jason Dominus <mjd@plover.com> wrote in message
news:39298c79.5fee$12a@news.op.net...

> >Which is blocked on my website because it has been shown not to
> >respect robots.txt.  Evil Product.  Do not buy.  Do not promote.

> Yeah, it's a real stinker.  It appears that whoever wrote it couldn't
> figure out how to tell it not to fetch the same document twice, and so
> it has a propensity to get stuck in loops, fetching the same files
> over and over and over.

Actually it (TeleportPRO) can identify itself as any program there is or
even name you can think of.
It can simulate ordinary browser witking with only 1 connection to server,
so I really dont know how can you block it when it looks definitely like a
web browser (can work even with pause)?

but that other thing - You are right man.
Program is made by programmers who didnt have idiot users in mind so if
teleport pro is not configured properly it can update same files on local
computer over and over.


:-P



v.






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

Date: Tue, 23 May 2000 08:12:25 +0100
From: Dave Cross <dave@dave.org.uk>
Subject: Re: Including variables defined outside the script
Message-Id: <gjbkisgikg4h9idhekvgnfuco5utnvg11b@4ax.com>

On Mon, 22 May 2000 16:56:35 -0900, "Joshua J. Kugler"
<isd@mail.as.uaf.edu> wrote:

>[Sorry if this is a repost, but my news software, or server is being tweaky.
>
>In in the file MyModule.pm, there are a few lines like this:
>
>my $var="data';
>my $var2="moredata";
>
>In my script, I have these lines:
>
>use lib "path/to/my/modules/dir";
>use strict;
>use MyModule;
>
>It finds MyModule (no errors reported), but when I try to use those variables, it says
>they must have explicit package names.  I know this means the variables aren't getting
>defined, but why?  The module does not have any "package" statements in it.  Why aren't
>the variables being defined in $main:: ?
>
>I read the pertinant parts  in the Camel book, and searched deja, but it hasn't clicked in my
>head. Any hints?

Read the definition of 'my' on page 189 of the Camel again. The first
sentance says:

"This operator declares one or more private variables to exist only
within the innermost enclosing block, subroutine, eval or file."

That last word is the important one. By using 'my' you're saying that
the variables only exist in MyModule.pm and therfore the calling
script can't see them.

hth,

Dave...

-- 
<http://www.dave.org.uk>  SMS: sms@dave.org.uk
yapc::Europe - London, 22 - 24 Sep <http://www.yapc.org/Europe/>

"There ain't half been some clever bastards" - Ian Dury [RIP]


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

Date: Tue, 23 May 2000 09:42:38 GMT
From: bart.lateur@skynet.be (Bart Lateur)
Subject: Re: Including variables defined outside the script
Message-Id: <392d4e76.3756595@news.skynet.be>

Joshua J. Kugler wrote:

>In in the file MyModule.pm, there are a few lines like this:
>
>my $var="data';
>my $var2="moredata";
>
>In my script, I have these lines:
>
>use lib "path/to/my/modules/dir";
>use strict;
>use MyModule;
>
>It finds MyModule (no errors reported), but when I try to use those
>variables, it says they must have explicit package names.  I know this
>means the variables aren't getting defined, but why?  The module does
>not have any "package" statements in it.  Why aren't the variables
>being defined in $main:: ?

Because you defined them as lexical variables. That's what my() does for
you.

You want to define them in %main::, no matter what package they're
originally in? Then use them as 

	$::var = 'data';

which even makes 'strict' happy.

-- 
	Bart.


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

Date: 23 May 2000 07:36:43 GMT
From: Intergalactic Denizen of Mystery <Tbone@pimpdaddy.com>
Subject: Re: join " ", do {$x++}, do {$x++}, do {$x++};
Message-Id: <8gdceb$72d$1@news.enteract.com>

lr@hpl.hp.com writes:
>In article <8gcstu$2hiq$1@news.enteract.com>, Tbone@pimpdaddy.com says...
>> I seem to have lost the ability to RTFM... could someone point me
>> to where it says that the above (see subject line) will guarantedly
>> produce "1 2 3"?
>
>Nowhere.  What makes you think it has too?

It was just an optimistic post, in the hope that it was guaranteed,
by analogy with the "comma operator". Experimenting does give you
expected results. However, I also know that it would be out of
character for perl (or its docs) to have anything resembling it.
Well, my dreams are shattered of course. But at least I will have
more reliable code... 



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

Date: 23 May 2000 07:45:35 GMT
From: vek@pharmnl.ohout.pharmapartners.nl (Villy Kruse)
Subject: Re: join " ", do {$x++}, do {$x++}, do {$x++};
Message-Id: <slrn8ikdou.ead.vek@pharmnl.ohout.pharmapartners.nl>

On Mon, 22 May 2000 23:59:12 -0700, Larry Rosler <lr@hpl.hp.com> wrote:

>
>A firm semantics for Perl would require introducing and elaborating the 
>'sequence point' concept of ANSI/ISO C.
>

C does have the same problem/feature.  What would the following program
prduce? and would it produce the same on every system?

#include <stdio.h>
#include <stdlib.h>
int main ()
{
	int i = 0;
	printf ("%d %d %d %d\n", i++, i++, i++, i++);
	return 0;
}


-- 
Villy


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

Date: Tue, 23 May 2000 09:42:40 GMT
From: bart.lateur@skynet.be (Bart Lateur)
Subject: Re: join " ", do {$x++}, do {$x++}, do {$x++};
Message-Id: <392e4fdc.4114486@news.skynet.be>

Intergalactic Denizen of Mystery wrote:

>It was just an optimistic post, in the hope that it was guaranteed,
>by analogy with the "comma operator".

I think it IS garanteed by the comma operator. See perlop. Only, the
result '1 2 3' will only be achieved if $x is 1 before running this
code.

  Comma Operator

    Binary "," is the comma operator. In scalar context it evaluates
    its left argument, throws that value away, then evaluates its
    right argument and returns that value. This is just like C's
    comma operator.

    In list context, it's just the list argument separator, and
    inserts both its arguments into the list.


Hmmm... that isn't very explicit, isn't it? In scalar context, it is
garanteed to be executed from left to right, but in list context, it's
not said in so many words.

Just a gap in the docs?

-- 
	Bart.


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

Date: 23 May 2000 07:03:02 +0100
From: Jonathan Stowe <gellyfish@gellyfish.com>
Subject: Re: Looking for a good editor...
Message-Id: <8gd6um$6nr$1@orpheus.gellyfish.com>

On Sun, 21 May 2000 22:25:12 +0900 Padawan wrote:
> Good day,
> I'm a Perl Padawan (beginner) and have tried a few of Perl editing and
> testing programs (Perl Builder, Perl Studio, DZ Perl Editor), but I want to
> put the money down on a highly recommended editor.  What do the Jedi Masters
> of Perl and Perl/CGI use?

That'll be a trick question as none of the aforementioned editors will run on 
the operating systems that I work with.  Of course a real Jedi Master wouldnt
need to use an editor but would deploy the force to write the bits directly
to the disk.

Please see <http://www.perl.com/reference/query.cgi?editors> and do a search on
Deja News <http://www.deja.com/> on this topic as it has been discussed to death
in the past.

/J\
-- 
Ah, beer, my one weakness. My achille's heel, if you will.
-- 
fortune oscar homer


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

Date: Tue, 23 May 2000 09:26:45 +0100
From: "Franck Lalane" <f.lalane@no-spam.pra.org.uk>
Subject: Re: LWP Module and error 500
Message-Id: <959070400.5470.0.nnrp-08.9e9872de@news.demon.co.uk>

Here are some more details:

This is part of a CGI script for a search engine.

I have index files where I have the files location for the search result.

What I do, is opening the files to get the title, and then display links to
those files.

For the moment, I do it with all the files running on the script server, and
all the references to the remote files don't have any title.

I only need to open a remote file to get the what's between the <title>
tags.

I tried the head() function, but it return the file do not exist.

All the files I try to reach are just plain text HTML files (not generated
dynamically)

I have a correct output (I display all the local files results and some
other things from the search engine), but when I write:

$doc = getprint 'http://www.mysite.com/myfile.htm';

it print "500", which I guess is the error code (according to the
documentation)

I don't really want a redirect() method because I don't want to display the
file.

Thanks

Franck




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

Date: 23 May 2000 07:07:06 +0100
From: Jonathan Stowe <gellyfish@gellyfish.com>
Subject: Re: PERL and COM port
Message-Id: <8gd76a$7hd$1@orpheus.gellyfish.com>

On Sun, 21 May 2000 21:18:00 GMT py1ll@my-deja.com wrote:
> Which script could I use to access (read and write) a COM port using
> PERL? 

This is discussed in perlfaq8 :

       How do I read and write the serial port?

However this doesnt mention the modules Device::SerialPort or Win32::SerialPort
which are available from CPAN <http://www.cpan.org>

/J\
-- 
I can't believe it! Reading and writing actually paid off!
-- 
fortune oscar homer


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

Date: Tue, 23 May 2000 11:05:06 +0200
From: Kai Wipplinger <Kai.Wipplinger@de.bosch.com>
Subject: Runtime error
Message-Id: <392A49C2.24BA49E3@de.bosch.com>

Hello together,

i posted this problem earlier but maybe without enough Information,
because it seems only to appear on my machine. I get an Runtime Error
when running the script below. I used a debugger on the perl.exe and get
the Message that a Stack overflow occures. Here are the Informations I
can give (I hope the German output is not a Problem it doesn't mean
anything specific):

----------------------------------------
Debug Messages (the lines are to long but i won't change the output):

"C:\Programme\ASPerl\bin\perl.exe" wurde geladen. Es wurden keine
entsprechenden Symbolinformationen gefunden.
"C:\WINNT\System32\ntdll.dll" wurde geladen. Es wurden keine
entsprechenden Symbolinformationen gefunden.
"C:\WINNT\system32\KERNEL32.DLL" wurde geladen. Es wurden keine
entsprechenden Symbolinformationen gefunden.
"C:\WINNT\system32\ADVAPI32.DLL" wurde geladen. Es wurden keine
entsprechenden Symbolinformationen gefunden.
"C:\WINNT\system32\USER32.DLL" wurde geladen. Es wurden keine
entsprechenden Symbolinformationen gefunden.
"C:\WINNT\system32\GDI32.DLL" wurde geladen. Es wurden keine
entsprechenden Symbolinformationen gefunden.
"C:\WINNT\system32\RPCRT4.DLL" wurde geladen. Es wurden keine
entsprechenden Symbolinformationen gefunden.
"C:\WINNT\system32\WSOCK32.DLL" wurde geladen. Es wurden keine
entsprechenden Symbolinformationen gefunden.
"C:\WINNT\system32\WS2_32.DLL" wurde geladen. Es wurden keine
entsprechenden Symbolinformationen gefunden.
"C:\WINNT\system32\msvcrt.dll" wurde geladen. Es wurden keine
entsprechenden Symbolinformationen gefunden.
"C:\WINNT\system32\WS2HELP.DLL" wurde geladen. Es wurden keine
entsprechenden Symbolinformationen gefunden.
LDR: Automatic DLL Relocation in perl.exe
LDR: Dll PerlCRT.dll base 78000000 relocated due to collision with
C:\WINNT\system32\MSVCRT.dll
"C:\WINNT\system32\PerlCRT.dll" wurde geladen. Es wurden keine
entsprechenden Symbolinformationen gefunden.
"C:\Programme\ASPerl\bin\perlcore.dll" wurde geladen. Es wurden keine
entsprechenden Symbolinformationen gefunden.
Nicht abgefangene Ausnahme in perl.exe (PERLCORE.DLL): 0xC00000FD: Stack
Overflow.
Thread 0xC5 wurde mit Code -1 (0xFFFFFFFF) beendet.
Das Programm "C:\Programme\ASPerl\bin\perl.exe" wurde mit  Code -1
(0xFFFFFFFF) beendet.

----------------------------------------
Perl version:

This is perl, version 5.005_03 built for MSWin32-x86-object
(with 1 registered patch, see perl -V for more detail)

Copyright 1987-1999, Larry Wall

Binary build 521 provided by ActiveState Tool Corp.
http://www.ActiveState.com
Built 12:26:50 Oct 16 1999


Perl may be copied only under the terms of either the Artistic License
or the
GNU General Public License, which may be found in the Perl 5.0 source
kit.

Complete documentation for Perl, including FAQ lists, should be found on
this system using `man perl' or `perldoc perl'.  If you have access to
the
Internet, point your browser at http://www.perl.com/, the Perl Home
Page.

------------------
Operating System:

Microsoft Windows NT
4.00.1381

-------------------
Perlscript with problem:
#! perl -w
use strict;

use Text::ParseWords;

my $good = 5624;
my $bad  = 5625;


open (FTEST,">tstpali.txt") or die "can't create Testfile";

print FTEST "B";
my $x;
for ($x=0; $x<$good; $x++)
{
  print FTEST "A";
}

print FTEST "B";

close FTEST;

open (FTEST,"<tstpali.txt") or die "can't open Testfile";

my $TestTxt = <FTEST>;

print "tstpali: parse the good one\n";
my @list = &parse_line("B",0, $TestTxt);
print "tstpali: the good one is ok\n";

close FTEST;

# print "tstpali: @list\n";  

open (FTEST,">tstpali.txt") or die "can't create Testfile";

print FTEST "B";
for ($x=0; $x<$bad; $x++)
{
  print FTEST "A";
}

print FTEST "B";

close FTEST;

open (FTEST,"<tstpali.txt") or die "can't open Testfile";

$TestTxt = <FTEST>;

print "tstpali: parse the bad one\n";
@list = &parse_line("B",0, $TestTxt);
print "tstpali: the bad one is ok (shit happens)\n";

close FTEST;

#print @list;

---------------------
I have put some Output to ParseWords.pm. The additional Lines in
parse_line:

sub parse_line {
	# We will be testing undef strings
	local($^W) = 0;

    my($delimiter, $keep, $line) = @_;
    my($quote, $quoted, $unquoted, $delim, $word, @pieces);

    print "parse_line: start while\n";
    while (length($line)) {
#        printf "parse_line: While %d\nLine :%s\n",length($line),$line;
	($quote, $quoted, undef, $unquoted, $delim, undef) =
	    $line =~ m/^(["'])                 # a $quote
                        ((?:\\.|(?!\1)[^\\])*)    # and $quoted text
                        \1 		       # followed by the same quote
                        ([\000-\377]*)	       # and the rest
		       |                       # --OR--
                       ^((?:\\.|[^\\"'])*?)    # an $unquoted text
		      (\Z(?!\n)|(?-x:$delimiter)|(?!^)(?=["']))  
                                               # plus EOL, delimiter, or
quote
                      ([\000-\377]*)	       # the rest
		      /x;		       # extended layout
        printf "parse_line: regex finished\n";
	return() unless( $quote || length($unquoted) || length($delim));

	$line = $+;
        printf "parse_line: nextLine\n";

        if ($keep) {
	    $quoted = "$quote$quoted$quote";
	}
        else {
	    $unquoted =~ s/\\(.)/$1/g;
	    if (defined $quote) {
		$quoted =~ s/\\(.)/$1/g if ($quote eq '"');
		$quoted =~ s/\\([\\'])/$1/g if ( $PERL_SINGLE_QUOTE && $quote eq "'");
            }
	}
        $word .= defined $quote ? $quoted : $unquoted;
 
        if (length($delim)) {
            push(@pieces, $word);
            push(@pieces, $delim) if ($keep eq 'delimiters');
            undef $word;
        }
        if (!length($line)) {
            push(@pieces, $word);
	}
    }
    return(@pieces);
}


---------------------------
Output of the script and Parse line:

tstpali: parse the good one
parse_line: start while
parse_line: regex finished
parse_line: nextLine
parse_line: regex finished
parse_line: nextLine
tstpali: the good one is ok
tstpali: parse the bad one
parse_line: start while
parse_line: regex finished
parse_line: nextLine
Error: Runtime exception


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

Date: 22 May 2000 20:55:57 +0100
From: Jonathan Stowe <gellyfish@gellyfish.com>
Subject: Re: SQL newbie question
Message-Id: <8gc3cd$qai$1@orpheus.gellyfish.com>

On Mon, 22 May 2000 14:52:32 +0100 Bagsy wrote:
>     Hi,
>     I'm trying to write an SQL query which will compare the elements of an
> array to every column in a table and return any matches. Would this work?
> 
> SELECT * FROM exampletable
> WHERE * = $foo[1] AND $foo[2] etc..?
> 
>     I imagine it wouldn't. If I want to return the rows where all the
> elements of @foo match at least one column what would be the correct way to
> structure the query? Thanks in advance.

Of course it wont work.  You will probably want to ask in some comp.databases.*
newsgroup if you are uncertain of the correct SQL syntax - however the way that
I might approach this is by constructing the query on the fly :

#!/usr/bin/perl -w

use strict;

my @columns = qw( name
                  address
                  phone_number );

my @array = qw( gellyfish foodleboodle armpit);

my @query_terms;

foreach my $column ( @columns )
{
  foreach my $value ( @array )
  {
    push @query_terms, "$column = '$value'";
  }
}

my $query = "SELECT * FROM exampletable\nWHERE " . join " OR\n", @query_terms;

print $query;


You could use the facilities of DBI or your Database to obtain the list of
columns in your table.

/J\
-- 
Education is an admirable thing. But it is well to remember that nothing
that is worth knowing can be taught.
-- 
fortune oscar homer


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

Date: 23 May 2000 07:43:14 +0100
From: Jonathan Stowe <gellyfish@gellyfish.com>
Subject: Re: Suggest an approach for HTML Form submission
Message-Id: <8gd9a2$efm$1@orpheus.gellyfish.com>

On 22 May 2000 06:55:23 GMT The WebDragon wrote:
> In article <392842DE.FA5478FB@home.com>, ecostello@home.com wrote:
> 
>  | Greetings,
>  | 
>  | I need to create a Macintosh Perl program that mimics an HTML form 
>  | submission to a web server and parses the resulting page.  I have MacPerl 
>  | installed, but I'm not sure I have all the appropriate modules, libraries, 
>  | packages, etc...
>  | 
>  | Could someone point me in the right direction or suggest an approach?
>  | 
> 
> you need CGI.pm (version 2.66 runs perfectly under MacPerl)
> 

While this is good advice for CGI programming in general it doesnt help the OP
in mimicking an HTML form submission.  To do this one would want to use
LWP::UserAgent - I have no idea whether it is available for MacPerl though.

/J\
-- 
Heh Heh Heh! Lisa! Vampires are make believe, just like elves and gremlins
and eskimos!
-- 
fortune oscar homer


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

Date: Tue, 23 May 2000 08:41:51 GMT
From: bart.lateur@skynet.be (Bart Lateur)
Subject: Re: updated : Re: regexes *sigh* damn I hate these things
Message-Id: <392a437f.950257@news.skynet.be>

The WebDragon wrote:

> | This gives:
> | 
> | 	Name = utdm/dm-cyberwar.zip, rating = 7.5
> | 	Name = utdm/dm-nitro.zip, rating = 9
> 
>well, this is close.. but you missed the part above where I mentioned 
>that I needed to *extract* the gametype from the name. 
>
>Ultimately I'll have as output.. 
>
>Gametype = utdm, filename = dm-cyberwar(*1), rating = 7.5
>Gametype = utdm, filename = dm-nitro, rating = 9

I thought that was rather trivial. For example, instead of using

	$name = $1 if defined $1;

you can do:

	if defined($1) {
	    ($gametype, $name) = split /\//, $1;
	    $name =~ s/\.[^.]*$//;
	}

-- 
	Bart.


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

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


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