[16534] in Perl-Users-Digest
Perl-Users Digest, Issue: 3946 Volume: 9
daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Tue Aug 8 06:05:54 2000
Date: Tue, 8 Aug 2000 03:05:14 -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: <965729113-v9-i3946@ruby.oce.orst.edu>
Content-Type: text
Perl-Users Digest Tue, 8 Aug 2000 Volume: 9 Number: 3946
Today's topics:
Re: 5.00 > 5.6 <gellyfish@gellyfish.com>
about "syntax error" of perl program najura@my-deja.com
about "syntax error" of perl program najura@my-deja.com
Re: Array Length ? <post2menow@hotmail.com>
Client-side PerlScript object model <Marcel.van.der.Laan@ict.nl>
Re: Converting from US dates/numbers to European dates/ <thunderbear@bigfoot.com>
Re: Dreaded 500 message <gellyfish@gellyfish.com>
Re: dropping space from begginning & end of a string <gellyfish@gellyfish.com>
function like grep <unplug@poboxes.com>
Re: function like grep (Andreas Kahari)
Re: How to open web page from Perl script <gellyfish@gellyfish.com>
Re: launch a browser and get a URL <gellyfish@gellyfish.com>
Re: Learning Perl, 2nd Ed. Exercises. How can I do them <tabs_paradise@yahoo.com>
Need help!! <rashid1218@hotmail.com>
Re: Need help!! <foo@bar.va>
Re: one liner? (Anno Siegel)
Perl and opening tcp socket rhlinuxguru@my-deja.com
Perl error <peter_gadsbyNOpeSPAM@hfcbank.co.uk.invalid>
Re: PerlDAP 1.4 and Perl 5.6 compile problems <gellyfish@gellyfish.com>
printing backspace in WinNT <eng80956@nus.edu.sg>
Re: Problem With AT Command, DBI ODBC on NT4 <gellyfish@gellyfish.com>
Problems creating a file in IIS <abel@inlander.es>
Re: question (Rafael Garcia-Suarez)
Re: question <unplug@poboxes.com>
Re: question (Rafael Garcia-Suarez)
Re: reg expressions - protect html <thunderbear@bigfoot.com>
running a perl script from dos prompt <rashid1218@hotmail.com>
Re: Simple reg expression question <bart.lateur@skynet.be>
Re: Simple regular Expression Question <debjit@oyeindia.com>
Re: totally newbie to perl, I ... <gellyfish@gellyfish.com>
Re: uploading file <gellyfish@gellyfish.com>
re: using perl to fetch finger .plan information <nospam@nospam.com>
what does foreach (0...10) do ??? <steve_button@my-deja.com>
Re: what does foreach (0...10) do ??? (Rafael Garcia-Suarez)
Re: what does foreach (0...10) do ??? <gellyfish@gellyfish.com>
Digest Administrivia (Last modified: 16 Sep 99) (Perl-Users-Digest Admin)
----------------------------------------------------------------------
Date: 7 Aug 2000 21:54:35 +0100
From: Jonathan Stowe <gellyfish@gellyfish.com>
Subject: Re: 5.00 > 5.6
Message-Id: <8mn7mb$153$1@orpheus.gellyfish.com>
On 7 Aug 2000 12:12:54 -0500 Greymaus wrote:
> *** post for free via your newsreader at post.newsfeeds.com ***
I'm sorry it appears the content of your message seems to have got lost
amid all the crap that your news provider has inserted around it.
/J\
--
yapc::Europe in assocation with the Institute Of Contemporary Arts
<http://www.yapc.org/Europe/> <http://www.ica.org.uk>
------------------------------
Date: Tue, 08 Aug 2000 09:04:45 GMT
From: najura@my-deja.com
Subject: about "syntax error" of perl program
Message-Id: <8moifa$k80$1@nnrp1.deja.com>
Hi:
Excuse me ,who can help me solve the problem
of perl program !I wrote the perl program to get
the information from the FORM and put the data
send the client by E-Mail.But the system
said "syntax error at d:\test.pl line 46,
near "if" ,Execution of d:\test.pl aborted due to
compilation errors. " ,when I testing the
program. It's the first time I write the perl
program,so I don't know what I can do.if you know
something about it or you can solve the
problem ,please send me quickly!my E-mail
is:najura@citiz.net
Thank you
very much !!!
following is the code for test.pl:
--------------------------------------------------
---
#!/usr/local/bin/perl
%postInputs=readpostInput();
$dateCommand="date";
$time='$dateCommand';
open(MAIL,"/usr/sbin/sendmail -t") || return 0;
select (MAIL);
print <<"EOF";
To:najura\@citiz.net
From:$postInputs{'email'}
Subject:ÐÅÏ¢µÇ¼±í
#Subject:$postInputs{'email'} Information
Requested
$time
×ÓÅ®ÐÕÃû:$postInputs{'childname'}
ÐÔ±ð:$postInputs{'childsex'}
³öÉúÄêÔÂ:$postInputs{'childyear'}.$postInputs
{'childmonth'}.$postInputs{'childday'}
Ëù¶ÁÖÐѧ:$postInputs{'childschool'}
Ëù±¨×¨Òµ1(ѧԺ/ϵ):$postInputs{'d1'}.$postInputs
{'z1'}
Ëù±¨×¨Òµ2(ѧԺ/ϵ):$postInputs{'d2'}.$postInputs
{'z2'}
Ëù±¨×¨Òµ3(ѧԺ/ϵ):$postInputs{'d3'}.$postInputs
{'z3'}
Ëù±¨×¨Òµ4(ѧԺ/ϵ):$postInputs{'d4'}.$postInputs
{'z4'}
ÁªÏµµØÖ·:$postInputs{'address'}
ÓÊÕþ±àÂë:$postInputs{'zip'}
ÁªÏµµç»°:$postInputs{'telephone'}
E-Mail:$postInputs{'email'}
УÓÑÐÕÃû:$postInputs{'xyname'}
ÐÔ±ð:$postInputs{'xysex'}
³öÉúÄêÔÂ:$postInputs{'xyyear'}.$postInputs
{'xymonth'}.$postInputs{'xyday'}
¾Í¶Áʱ¼ä:$postInputs{'learnyear1'}.$postInputs
{'learnmonth1'}.$postInputs{'learnday1'}µ½³öÉúÄê
ÔÂ:$postInputs{'learnyear2'}.$postInputs
{'learnmonth2'}.$postInputs{'learnday3'}
¾Í¶ÁÔº/ϵ/רҵ:$postInputs{'xyd'}.$postInputs
{'xyx'}.$postInputs{'xyz'}
Ŀǰµ¥Î»:$postInputs{'factory'}
Ö°Îñ:$postInputs{'zw'}
EOF
close(MAIL);
select(STDOUT);
printThankyou();
Sub readpostInput()
{My(%searchField,$buffer,$pair,@pairs);
if($ENV{'REQUEST_METHOD'} eq 'POST')
{
read(STDIN,$buffer,$ENV
{'CONTENT_LENGTH'});
@pairs=split(/&/,$buffer);
foreach $pair(@pairs)
{($name,$value)=split
(/=/,$pair);
$value=~tr/+/ /;
$value=~$/%([a-fA-F0-9]
[a-fA-F0-9]/pack("c",hex($1)))/eg;
$name=~tr/+/ /;
$name=~$/%([a-fA-F0-9]
[a-fA-F0-9]/pack("c",hex($1)))/eg;
$searchField($name)
=$value;
}
}
return (%searchField);
Sub printThankyou()
{print<<"EOF";
Content-type:text/html
<html>
<head>
<title>ллÄãÌîдÁË2000ÄêУÓÑ×ÓÅ®±¨¿¼Ä¸Ð£
ÐÅÏ¢µÇ¼±í!</title>
</head>
</html>
EOF
}
--------------------------------------------------
---------------------------------
Sent via Deja.com http://www.deja.com/
Before you buy.
------------------------------
Date: Tue, 08 Aug 2000 09:04:46 GMT
From: najura@my-deja.com
Subject: about "syntax error" of perl program
Message-Id: <8moifb$k82$1@nnrp1.deja.com>
Hi:
Excuse me ,who can help me solve the problem
of perl program !I wrote the perl program to get
the information from the FORM and put the data
send the client by E-Mail.But the system
said "syntax error at d:\test.pl line 46,
near "if" ,Execution of d:\test.pl aborted due to
compilation errors. " ,when I testing the
program. It's the first time I write the perl
program,so I don't know what I can do.if you know
something about it or you can solve the
problem ,please send me quickly!my E-mail
is:najura@citiz.net
Thank you
very much !!!
following is the code for test.pl:
--------------------------------------------------
---
#!/usr/local/bin/perl
%postInputs=readpostInput();
$dateCommand="date";
$time='$dateCommand';
open(MAIL,"/usr/sbin/sendmail -t") || return 0;
select (MAIL);
print <<"EOF";
To:najura\@citiz.net
From:$postInputs{'email'}
Subject:ÐÅÏ¢µÇ¼±í
#Subject:$postInputs{'email'} Information
Requested
$time
×ÓÅ®ÐÕÃû:$postInputs{'childname'}
ÐÔ±ð:$postInputs{'childsex'}
³öÉúÄêÔÂ:$postInputs{'childyear'}.$postInputs
{'childmonth'}.$postInputs{'childday'}
Ëù¶ÁÖÐѧ:$postInputs{'childschool'}
Ëù±¨×¨Òµ1(ѧԺ/ϵ):$postInputs{'d1'}.$postInputs
{'z1'}
Ëù±¨×¨Òµ2(ѧԺ/ϵ):$postInputs{'d2'}.$postInputs
{'z2'}
Ëù±¨×¨Òµ3(ѧԺ/ϵ):$postInputs{'d3'}.$postInputs
{'z3'}
Ëù±¨×¨Òµ4(ѧԺ/ϵ):$postInputs{'d4'}.$postInputs
{'z4'}
ÁªÏµµØÖ·:$postInputs{'address'}
ÓÊÕþ±àÂë:$postInputs{'zip'}
ÁªÏµµç»°:$postInputs{'telephone'}
E-Mail:$postInputs{'email'}
УÓÑÐÕÃû:$postInputs{'xyname'}
ÐÔ±ð:$postInputs{'xysex'}
³öÉúÄêÔÂ:$postInputs{'xyyear'}.$postInputs
{'xymonth'}.$postInputs{'xyday'}
¾Í¶Áʱ¼ä:$postInputs{'learnyear1'}.$postInputs
{'learnmonth1'}.$postInputs{'learnday1'}µ½³öÉúÄê
ÔÂ:$postInputs{'learnyear2'}.$postInputs
{'learnmonth2'}.$postInputs{'learnday3'}
¾Í¶ÁÔº/ϵ/רҵ:$postInputs{'xyd'}.$postInputs
{'xyx'}.$postInputs{'xyz'}
Ŀǰµ¥Î»:$postInputs{'factory'}
Ö°Îñ:$postInputs{'zw'}
EOF
close(MAIL);
select(STDOUT);
printThankyou();
Sub readpostInput()
{My(%searchField,$buffer,$pair,@pairs);
if($ENV{'REQUEST_METHOD'} eq 'POST')
{
read(STDIN,$buffer,$ENV
{'CONTENT_LENGTH'});
@pairs=split(/&/,$buffer);
foreach $pair(@pairs)
{($name,$value)=split
(/=/,$pair);
$value=~tr/+/ /;
$value=~$/%([a-fA-F0-9]
[a-fA-F0-9]/pack("c",hex($1)))/eg;
$name=~tr/+/ /;
$name=~$/%([a-fA-F0-9]
[a-fA-F0-9]/pack("c",hex($1)))/eg;
$searchField($name)
=$value;
}
}
return (%searchField);
Sub printThankyou()
{print<<"EOF";
Content-type:text/html
<html>
<head>
<title>ллÄãÌîдÁË2000ÄêУÓÑ×ÓÅ®±¨¿¼Ä¸Ð£
ÐÅÏ¢µÇ¼±í!</title>
</head>
</html>
EOF
}
--------------------------------------------------
---------------------------------
Sent via Deja.com http://www.deja.com/
Before you buy.
------------------------------
Date: Tue, 8 Aug 2000 11:58:33 +0200
From: "Ed Bras" <post2menow@hotmail.com>
Subject: Re: Array Length ?
Message-Id: <8molj6$ctc$1@enterprise.cistron.net>
"Jeff Yoak" <jeff@yoak.com> wrote in message
news:8mmn1l01399@news1.newsguy.com...
>
> [posted and emailed]
>
> In article <8mmjck$mak$1@enterprise.cistron.net>, "Ed Bras"
> <post2menow@hotmail.com> wrote:
>
> > but then it prints the reference of the array. Neither does print
> > scalar(@$ArrayinHash{Array}) work, which didn't suprise me.
>
> Try scalar @{$ArrayinHash{Array}}
>
> > But what does work, is assiging it to a temporally array:
> > @ArrayTemp = $ArrayinHash{Array}
> > print scalar(@ArrayTemp)
>
> No it didn't. Unless you happened to expect a return value of '1' The
> thing on the right is a reference. You'll have to dereference it to get
> the array.
>
> Cheers, Jeff
>
Thanks guys,
The @{} operator works perfect to translate it from a array reference to a
array context.
Ed Bras
------------------------------
Date: Tue, 8 Aug 2000 10:12:49 +0200
From: "Marcel van der Laan" <Marcel.van.der.Laan@ict.nl>
Subject: Client-side PerlScript object model
Message-Id: <8mojs6$k30$1@tasmania.dev.ict.nl>
Hi there,
I'm trying out some client-side PerlScript-ing, but a bit confused... I've
looked at the ie3examples from ActiveState but these don't take me very far.
I'd like to know more about how to access the browser object model from
Perl. For example, I'm looking for information on changing the contents of a
page or form using the inner/outer HTML/Text values. Concrete example:
adding/changing the <OPTIONS> in a <SELECT> item from a script. Do I change
the value and somehow refresh the page, or what?
I just can't seem to find any info on Client-side scripting. It seems there
is quite a bit on Server-side/ASP stuff, but this won't do for me (trust me,
I have my reasons...). I'v looked at the hash keys available for elements,
but changing them doesn't always produce the right results...
Does anyone have any links/info about Client-side PerlScripting?
Thanks,
Marcel
### Example code: testpage.pl
sub testScript
{
my $form = $window->document->testform;
my $txt = $window->document->p1;
$form->testSelect->innerHTML->{'Value'} =
"<OPTION selected>TestItem</OPTION>";
$txt->innerText->{'Value'} = "<I>Text</I>";
}
1;
<!-- Example testpage.html -->
<HTML>
<HEAD>
<SCRIPT LANGUAGE="PerlScript" SRC="testpage.pl"></SCRIPT>
</HEAD>
<BODY>
<FORM action="" name="testform">
<SELECT name="testSelect"> </SELECT>
</FORM>
<P name="p1">This is test</P>
<SCRIPT LANGUAGE="PerlScript">&testScript</SCRIPT>
</BODY>
</HTML>
------------------------------
Date: Tue, 08 Aug 2000 10:59:33 +0200
From: =?iso-8859-1?Q?Thorbj=F8rn?= Ravn Andersen <thunderbear@bigfoot.com>
Subject: Re: Converting from US dates/numbers to European dates/numbers
Message-Id: <398FCBF5.3C558941@bigfoot.com>
"Godzilla!" wrote:
> I am curious now. Are there machines programmed to
> deal with a comma as a decimal point? This is sincere.
Commas are used in Europe in the same way that decimal points are used
in the USA.
This is just a minor annoyance compared to sorting.
--
Thorbjørn Ravn Andersen "...plus...Tubular Bells!"
http://bigfoot.com/~thunderbear
------------------------------
Date: 7 Aug 2000 21:40:12 +0100
From: Jonathan Stowe <gellyfish@gellyfish.com>
Subject: Re: Dreaded 500 message
Message-Id: <8mn6rc$14e$1@orpheus.gellyfish.com>
On Mon, 07 Aug 2000 14:41:00 -0400 David Somner wrote:
> Okay, that is much more reasonable than any of the other posts that I
> got here. BTW, this is the ONLY language newsgroup that doesnt seem to
> care about the language's implementation throughout the platforms.
Yes but its not a matter of the implementation of the language - it is a
problem with a completely different and unrelated piece of software, I am
sure you would have the same problem with Python or TCL.
> I've
> seen this before with other languages. This one will probably follow
> those into obscurity unless something else happens.
>
Huh ?
> Anyway, I'll see what they say over in the that other newsgroup about
> the PWS for Win95/Win98. Happy programming!
>
You should ask in comp.infosystems.www.servers.ms-windows .
Oh yeah
*plonk*
/J\
--
yapc::Europe in assocation with the Institute Of Contemporary Arts
<http://www.yapc.org/Europe/> <http://www.ica.org.uk>
------------------------------
Date: 8 Aug 2000 07:19:17 +0100
From: Jonathan Stowe <gellyfish@gellyfish.com>
Subject: Re: dropping space from begginning & end of a string
Message-Id: <8mo8p5$o7$1@orpheus.gellyfish.com>
On Mon, 07 Aug 2000 13:21:57 GMT Chest Rockwell wrote:
> On Mon, 7 Aug 2000 13:18:14 +0100, Mark Worsdall
> <linux@worsdall.demon.co.uk> wrote:
>
>>Hi,
>>
>>I have this string:-
>>
>>my $string = ' hello todays world ';
>>
>>How could I drop the space from the beginning and the end?
>
> Use the trim function
>
In Visual Basic or Informix 4GL perhaps but not in Perl I'm afraid.
/J\
--
yapc::Europe in assocation with the Institute Of Contemporary Arts
<http://www.yapc.org/Europe/> <http://www.ica.org.uk>
------------------------------
Date: Tue, 08 Aug 2000 17:29:23 +0800
From: unplug <unplug@poboxes.com>
Subject: function like grep
Message-Id: <398FD2F3.FAC921B1@poboxes.com>
Does perl has any function like grep??
Rgds
unplug
------------------------------
Date: 8 Aug 2000 12:03:02 +0100
From: andkaha@hello.to.REMOVE (Andreas Kahari)
Subject: Re: function like grep
Message-Id: <398fdad6@merganser.its.uu.se>
In article <398FD2F3.FAC921B1@poboxes.com>, unplug <unplug@poboxes.com> wrote:
>Does perl has any function like grep??
>
>Rgds
>unplug
Yes, it's called "grep".
See the perlfunc manual, or "perldoc -f grep".
/A
--
# Andreas Kähäri, <URL:http://hello.to/andkaha/>.
# ...brought to you from Uppsala, Sweden.
# All junk e-mail is reported to the appropriate authorities.
# Criticism, cynicism and irony available free of charge.
------------------------------
Date: 8 Aug 2000 08:05:14 +0100
From: Jonathan Stowe <gellyfish@gellyfish.com>
Subject: Re: How to open web page from Perl script
Message-Id: <8mobfa$ou$1@orpheus.gellyfish.com>
On Mon, 07 Aug 2000 18:02:14 GMT hla_sa@my-deja.com wrote:
> In article <87hf8xyo89.fsf@limey.hpcc.uh.edu>,
> Tony Curtis <tony_curtis32@yahoo.com> wrote:
>> >> On Mon, 07 Aug 2000 17:09:59 GMT,
>> >> hla_sa@my-deja.com said:
>>
>> There's a number of questions in there, all related but
>> somewhat different.
>>
>> > I'm new to Perl and need to know how to open an existing
>> > web page from within a Perl script.
>>
>> with the LWP modules:
>>
>> perldoc lwpcook
>>
>> [ I think open() is a bit of a misnomer, "fetch" might be
>> better, or maybe it's just me... ]
>>
> Thanks. It would be running a stand alone script on the server.
> Shouldn't use lwp::simple;
> print get "http:// ... .html";
> work ? It's not for me.
>
Well of course it should be 'use LWP::Simple' case does matter. But that
notwithstanding yes it should work - however you will have need to print
at the very least the appropriate 'Content-Type:' header before that: if
you are using CGI.pm this is simplified by the provision of the header()
method.
/J\
--
yapc::Europe in assocation with the Institute Of Contemporary Arts
<http://www.yapc.org/Europe/> <http://www.ica.org.uk>
------------------------------
Date: 8 Aug 2000 07:41:27 +0100
From: Jonathan Stowe <gellyfish@gellyfish.com>
Subject: Re: launch a browser and get a URL
Message-Id: <8moa2n$pu$1@orpheus.gellyfish.com>
On Fri, 04 Aug 2000 00:18:44 GMT arthur wrote:
> in article 87snslvqmj.fsf@limey.hpcc.uh.edu, Tony Curtis at
> tony_curtis32@yahoo.com wrote on 8/3/00 4:04 PM:
>>> ignorance. I want to open a browser off my Desktop and
>>> be at a specific URL.
>>
>> And your perl issue is...?
>>
>> t
>
>
> I use Macperl 5 Is that what you mean by issue?
>
Well it certainly makes a difference - I wont be recommending you to use
WIn32::OLE for this :) I believe MacPerl has a module that interfaces with
AppleScript - you might be able to use that though I have never used MacPerl.
/J\
--
yapc::Europe in assocation with the Institute Of Contemporary Arts
<http://www.yapc.org/Europe/> <http://www.ica.org.uk>
------------------------------
Date: Sat, 5 Aug 2000 20:29:54 +0100
From: "Gonçalo" <tabs_paradise@yahoo.com>
Subject: Re: Learning Perl, 2nd Ed. Exercises. How can I do them on win98?
Message-Id: <398c6b70@212.18.160.197>
Thanks.
All I needed was the line perl -w file.pl
Now everything is working fine. (altough the hashes are a bit compicated for
me now, but I'll get the hand with it)
Thanks.
--
Gonçalo - The Metallica Source
http://www.themetsource.com
webmaster@themetsource.com
bean <bean@agentkhaki.com> wrote in message
news:MPG.13f6091916fdc18f989690@news.concentric.net...
> > exercises. Well, how can I do them with win98? I did a file called
> > exercise.pl and run it on apache trough a string like this
>
> Go to http://www.perl.com and click the link on the left side that says
> "Is there a Windows version of Perl?" And then to "...our Downloads
> section" and... ah screw it. Go here:
>
> http://www.activestate.com/ActivePerl/
>
> It's pretty self explanatory. Once you've got that downloaded and
> installed, you can run perl scripts from the DOS prompt by typing
>
> perl -w yourscripthere.pl
> ^
> The w gives you warnings if you do dumb things.
>
> > http://localhost/cgi-bin/exercise.pl but I got the 500 error.
>
> Yeah, Apache was a pain to configure for Win32. I use Omnihttpd for
> testing CGI if that's what you're doing. Get it at
> http://www.omnicron.ab.ca
>
> bean
------------------------------
Date: Tue, 08 Aug 2000 07:42:17 GMT
From: Rashid Saharudin <rashid1218@hotmail.com>
Subject: Need help!!
Message-Id: <8modkp$h1d$1@nnrp1.deja.com>
I got a perl script where I would like to remove blank lines/ comments
in an asp file.
I got all the scripts inside, but is it possible to run the perl script
without the file being specified in the perl file rather be specified
like : c:\scripts\perl arrays.pl "c:\documents\text.asp"
Could anyone help me please.
--
RASHID SAHARUDIN
Sent via Deja.com http://www.deja.com/
Before you buy.
------------------------------
Date: Tue, 08 Aug 2000 10:00:28 +0200
From: Marco Natoni <foo@bar.va>
Subject: Re: Need help!!
Message-Id: <398FBE1C.A8EFC68C@bar.va>
Rashid,
Rashid Saharudin wrote:
> I got a perl script where I would like to remove blank lines/
> comments in an asp file. I got all the scripts inside, but is
> it possible to run the perl script without the file being specified
> in the perl file rather be specified like :
> c:\scripts\perl arrays.pl "c:\documents\text.asp"
Yes, it is possible: The diamond operator (<>) reads from each of the
files specified in the command line of the script or from the standard
input if the command line is empty. Note that in this way it is very
hard to save the content of your program performance in the same file
where the input has been read. Otherwise, you can use the @ARGV list,
containing all the tokens in the command line.
Best regards,
Marco
------------------------------
Date: 8 Aug 2000 09:24:33 -0000
From: anno4000@lublin.zrz.tu-berlin.de (Anno Siegel)
Subject: Re: one liner?
Message-Id: <8mojkh$q6$1@lublin.zrz.tu-berlin.de>
Uri Guttman <uri@sysarch.com> wrote in comp.lang.perl.misc:
>>>>>> "RLS" == Randal L Schwartz <merlyn@stonehenge.com> writes:
>
>>>>>> "Chris" == Chris W <crasssh@my-deja.com> writes:
> Chris> I have lines of (variable length) data containing space-separated
> Chris> integers. I want to change all but the first five integers in each line
> Chris> to 0. I can do this by splitting it into an array, as below, but I am
> Chris> sure there must be some 'neater'/'shorter' way. Any suggestions?
>
> RLS> One line if you futz:
>
> RLS> { my $cnt = 0; s/(\d+)/++$cnt > 5 ? 0 : $1/ge; }
>
>another way:
>
> s{((?:\d+\s+){5})(.*)}{my $s = $2; $s =~ s/\d+/0/g ; "$1$s"}e ;
Still another (though not in a single statement):
m/(?:\d+\s+){5}/g; substr( $_, pos) =~ s/\d+/0/g;
Anno
------------------------------
Date: Tue, 08 Aug 2000 07:54:58 GMT
From: rhlinuxguru@my-deja.com
Subject: Perl and opening tcp socket
Message-Id: <8moech$hdq$1@nnrp1.deja.com>
I am very very new to perl, but it seems like it would be ideal for
what I am trying to do...
I've messed with the tcp commands, and am baffled...
I want a perl script that will open a tcp connection on a specified
port to an ip for like 30 seconds, and then close it....
I dont need to capture data or send any data, i just need to open the
socket, and keep it open for a specified amount of time...
Is there an easy way to do this?
Thanks,
Mike
Sent via Deja.com http://www.deja.com/
Before you buy.
------------------------------
Date: Tue, 08 Aug 2000 02:50:38 -0700
From: Peter_Gadsby <peter_gadsbyNOpeSPAM@hfcbank.co.uk.invalid>
Subject: Perl error
Message-Id: <042a80e8.d8c4385d@usw-ex0102-014.remarq.com>
Hi everybody, I am quite new to Perl.....
I'm using Perl on an IBM AIX machine, and running a script to
access an Oracle database, but intermittendly the script fails
with a Sigtrap core dump ( Caught a SIGILL
at /usr/local/lib/perl5/5.00503/Exporter.pm line 0
IOT/Abort trap(coredump) )
The problem only occurs about 1 in 4 executions, the Perl
version is 5.005_03 built for aix
HELP !!!!!! Thanks Peter_Gadsby@hfcbank.co.uk
The script looks like this .........
$Oraperl::safe=1;
use Oraperl;
#
# Initialising environment variables.
#
my($dbuser)='xxxx/xxxx';
my($dbname)='xxxx';
my($dblink);
my($PID);
my(
@ora_result
);
#
# Format standard output parameters.
#
$^ = 'DATA_TOP';
$~ = 'DATA_BODY';
$= = 10000000;
$PID = $ARGV[0];
$dblink = $ARGV[1];
#
# Oracle connection login.
#
my($lda) = &ora_login($dbname, $dbuser, '')
|| &page_support("ora_login: $ora_errno:
$ora_errstr\n");
#
# Extract datafiles from Oracle.
#
my $proc_sql = "
SELECT
sql_text
FROM
v\$session\@$dblink,
v\$sqltext\@$dblink
WHERE
address =
sql_address
AND
hash_value =
sql_hash_value
AND
sid = $PID
ORDER BY piece
";
my($proc_csr) = &ora_open($lda, $proc_sql)
|| &page_support("ora_open:
$ora_errno: $ora_errstr\n");
&ora_bind($proc_csr)
|| &page_support("ora_bind:
$ora_errno: $ora_errstr\n");
while(@ora_result = &ora_fetch($proc_csr)) {
write;
}
&ora_close($proc_csr)
|| warn "ora_close($proc_csr): $ora_errno:
$ora_errstr\n";
#
# Close all cursors and logoff Oracle
#
$ora_result[0] = 'End of output';
write;
&ora_logoff($lda)
|| warn "ora_logoff($lda): $ora_errno: $ora_errstr\n";
print '</TABLE>';
print '</SMALL></BODY></HTML>';
#----------------------------------------------------------------
---------------
#
# Procedures and Functions.
#
#----------------------------------------------------------------
---------------
#----------------------------------------------------------------
---------------
# Page support
#----------------------------------------------------------------
---------------
sub page_support {
print "In page_support ....\n";
my($message)=@_;
print $message,"\n";
system("PAGE_SUPPORT $message");
die;
}
#----------------------------------------------------------------
---------------
# Produce report in HTML format
#----------------------------------------------------------------
---------------
format DATA_TOP =
Content-type: text/html
<HTML>
<HEAD><TITLE>Sql Text</TITLE>
<BODY>
<TABLE border cellpadding=4>
<SMALL>
<STRONG>Sql text</STRONG>
<P>
.
#----------------------------------------------------------------
---------------
format DATA_BODY =
@<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<
<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<
$ora_result[0]
.
#----------------------------------------------------------------
---------------
-----------------------------------------------------------
Got questions? Get answers over the phone at Keen.com.
Up to 100 minutes free!
http://www.keen.com
------------------------------
Date: 8 Aug 2000 07:31:29 +0100
From: Jonathan Stowe <gellyfish@gellyfish.com>
Subject: Re: PerlDAP 1.4 and Perl 5.6 compile problems
Message-Id: <8mo9g1$p9$1@orpheus.gellyfish.com>
On Mon, 07 Aug 2000 13:36:49 +1000 Garry Optland wrote:
> Hi,
>
> I am trying to compile PerLDAP 1.4 on a Solaris 5.7 box running Perl
> 5.6, but get lots of errors regarding an undeclared variable as per
> below. I am using gcc, and Perl 5.6 compiled and installed OK, plus
> another 6 modules that I use compiled OK. The module compiles OK on a
> Solaris 5.7 box running Perl 5.004. Would anybody be able to get me
> started to find what is causing the problem. BTW, I am not a C
> programmer.
>
> Error messages:
> API.c: In function `avref2charptrptr':
> API.c:205: `na' undeclared (first use in this function)
>
When you run Makefile.PL supply the POLLUTE argument :
perl Makefile.PL -POLLUTE=1
In the fullness of time most modules will be fixed to work with 5.6 without
this I would hope.
/J\
--
yapc::Europe in assocation with the Institute Of Contemporary Arts
<http://www.yapc.org/Europe/> <http://www.ica.org.uk>
------------------------------
Date: Tue, 8 Aug 2000 15:53:38 +0800
From: Murlimanohar Ravi <eng80956@nus.edu.sg>
Subject: printing backspace in WinNT
Message-Id: <22E71DAEC504D111B78100805FFE9DC73D13A9BF@pfs21.ex.nus.edu.sg>
I've been trying without success to print the backspace character (\b)
using a perl CGI script.
print "Hello";
print "\b";
should ideally output
Hell
When I ran the CGI script my output was
Hello*
I tried running it from the command line and I got just Hello.
I'm using WinNT/IIS. Does the \b character only work for UNIX? If so, is
there a way to delete characters (using backspace or any other methods)?
Besides this, is there a way to delete whole lines of text in a file?
Something like using CTRL-K in pico is what I'm trying to achieve.
Help will be much appreciated.
Murli.
------------------------------
Date: 8 Aug 2000 07:59:26 +0100
From: Jonathan Stowe <gellyfish@gellyfish.com>
Subject: Re: Problem With AT Command, DBI ODBC on NT4
Message-Id: <8mob4e$n7$1@orpheus.gellyfish.com>
On Mon, 07 Aug 2000 18:02:40 GMT bayers@my-deja.com wrote:
> Here's a curious problem. Logged on as administrator, I can run the
> program below from the command prompt, but when I try to run it with
> the AT command, it fails with no error messages. For testing, I am
> running the scedule service as administrator.
>
The schedule service usually runs as the System user with a very limited
range of rights. When you say you are running this as administrator do
you mean you have changed this in the Service Control Panel (or whatever
it calls itself - I havent had to use NT for more than a year :).
In the end of the day you almost certainly have an NT configuration issue
with regard to the user rights of the schedule service and you will almost
certainly be better served asking in some group that discusses NT.
/J\
--
yapc::Europe in assocation with the Institute Of Contemporary Arts
<http://www.yapc.org/Europe/> <http://www.ica.org.uk>
------------------------------
Date: Tue, 08 Aug 2000 07:47:41 GMT
From: Abel Almazan <abel@inlander.es>
Subject: Problems creating a file in IIS
Message-Id: <398FBB0F.AFDBD7F4@inlander.es>
I have permisions to "write" and "read" to the directory, and i use
open OUT,"> filename.ext"; to write it, but the file is not creates or
overwrited if it's not created.
What happens??
------------------------------
Date: Tue, 08 Aug 2000 07:30:19 GMT
From: rgarciasuarez@free.fr (Rafael Garcia-Suarez)
Subject: Re: question
Message-Id: <slrn8ove26.hra.rgarciasuarez@rafael.kazibao.net>
unplug wrote in comp.lang.perl.misc:
>sorry for the unclear question.
>
>below are what I want to do.
>1. Retrieve all the digits from the string.
>2. 3rd space-separated field.
So use the split function to split the string into a list of fields:
$s = "abc efg 30 aaa bbb iii";
my @fields = split / /,$s;
print "$fields[2]\n";
--> outputs 30.
Lookup 'split' in the docs (perldoc -f split).
--
Rafael Garcia-Suarez
------------------------------
Date: Tue, 08 Aug 2000 15:54:27 +0800
From: unplug <unplug@poboxes.com>
Subject: Re: question
Message-Id: <398FBCB3.4258A636@poboxes.com>
How about using the first method, retrieve all the digits from the
string??
Rafael Garcia-Suarez wrote:
>
> unplug wrote in comp.lang.perl.misc:
> >sorry for the unclear question.
> >
> >below are what I want to do.
> >1. Retrieve all the digits from the string.
> >2. 3rd space-separated field.
>
> So use the split function to split the string into a list of fields:
>
> $s = "abc efg 30 aaa bbb iii";
> my @fields = split / /,$s;
> print "$fields[2]\n";
>
> --> outputs 30.
>
> Lookup 'split' in the docs (perldoc -f split).
>
> --
> Rafael Garcia-Suarez
------------------------------
Date: Tue, 08 Aug 2000 08:27:06 GMT
From: rgarciasuarez@free.fr (Rafael Garcia-Suarez)
Subject: Re: question
Message-Id: <slrn8ovhcm.hv4.rgarciasuarez@rafael.kazibao.net>
unplug wrote in comp.lang.perl.misc:
>How about using the first method, retrieve all the digits from the
>string??
$s = "abc efg 30 aaa bbb iii";
$s =~ tr/0-9//cd;
$s now contains '30'.
The tr/// construct is described in the perlop man page.
--
Rafael Garcia-Suarez
------------------------------
Date: Tue, 08 Aug 2000 10:56:38 +0200
From: =?iso-8859-1?Q?Thorbj=F8rn?= Ravn Andersen <thunderbear@bigfoot.com>
Subject: Re: reg expressions - protect html
Message-Id: <398FCB46.B795CDF3@bigfoot.com>
"Godzilla!" wrote:
> Kinda fun isn't it, this writing code to do something
> experts proclaim you can only do with a module. I learn
> more about programming by writing code, then finding my
> bugs and mistakes, fixing them, than I do or would by
> copy and paste of a module reference.
Using modules is like not having to invent the wheel again. Helps
immensely if you want to make a car instead of a lot of different
wheels.
--
Thorbjørn Ravn Andersen "...plus...Tubular Bells!"
http://bigfoot.com/~thunderbear
------------------------------
Date: Tue, 08 Aug 2000 07:02:01 GMT
From: Rashid Saharudin <rashid1218@hotmail.com>
Subject: running a perl script from dos prompt
Message-Id: <8mob98$eg5$1@nnrp1.deja.com>
I would like to run a perlscript using dos prompt where could I insert
the file that I want to remove the blank lines.
For example, if I run "arrays1.pl", I will remove the blank lines in
my "text.txt" file. Is it possible to write something beneath to run
the perl script.
1. perl arrays1.pl "../text.txt"
2. perl arrays1.pl /text.txt
3. perl arrays1.pl path=c:\...\text.txt
Could anyone help me please.
--
RASHID SAHARUDIN
Sent via Deja.com http://www.deja.com/
Before you buy.
------------------------------
Date: Tue, 08 Aug 2000 07:29:28 GMT
From: Bart Lateur <bart.lateur@skynet.be>
Subject: Re: Simple reg expression question
Message-Id: <4edvosokqcs4p6tvn95hd7r35k280porka@4ax.com>
[comp.lang.perl.modules snipped]
Kenny Lim wrote:
>I am just wondering if it's possible that we choose to "either"
>increment only the major or the minor point version.
>
>ie.
>
>ETThread226
>
>Major = 2 (ie. increment to 3)
>
>or
>
>Minor = 26 (ie. increment to 27)
Eh, sorry, your requirement looks ambiguous. What if you have a major
version of 10? How could we know where the major version ends, and the
minor version begins?
If the major version is just one digit, you can do:
s/(\d)(\d+)$/($1+1).$2/e;
to increment the major version, and
s/(\d)(\d+)$/$1.($2+1)/e;
to increment the minor version.
But you'd better have left a marker, for example a dot, between major
and minor version.
--
Bart.
------------------------------
Date: Tue, 8 Aug 2000 12:48:49 +0530
From: "Debjit" <debjit@oyeindia.com>
Subject: Re: Simple regular Expression Question
Message-Id: <8mph27$dif$1@news.vsnl.net.in>
my $srt = "ETThread226";
if($srt =~/(\d{1})(\d+)$/) {
$new_ver = ($1 +1).($2+1); #add 1 to $1 or $2
$srt =~s/\d+$/$new_ver/;
}
print $srt;
------------------------------
Date: 8 Aug 2000 07:25:57 +0100
From: Jonathan Stowe <gellyfish@gellyfish.com>
Subject: Re: totally newbie to perl, I ...
Message-Id: <8mo95l$os$1@orpheus.gellyfish.com>
On Mon, 7 Aug 2000 12:33:39 +0100 ken wrote:
> seb wrote in message <8mlra9$4rs$1@buty.wanadoo.nl>...
>
>>totally newbie to perl, I would like 2 know what do I need to run my first
>>perl script
>>(you know, something like ' Hello World ! ' ;-)) )
>>under W 9x (is it possible ? ) or W 2k.
>
>
>
> If running locally, on w9x then you need a web server of some kind
>
I dont see anywhere in the original post where it says that the program
is to be run by a web server. You seem to be labouring under the
misapprehension that a Perl programmers are written for the Web - you
would be totally wrong.
Anyhow the issue of web servers is best discussed in the more appropriate
comp.infosystems.www.servers.ms-windows.
/J\
--
yapc::Europe in assocation with the Institute Of Contemporary Arts
<http://www.yapc.org/Europe/> <http://www.ica.org.uk>
------------------------------
Date: 8 Aug 2000 07:08:19 +0100
From: Jonathan Stowe <gellyfish@gellyfish.com>
Subject: Re: uploading file
Message-Id: <8mo84j$ni$1@orpheus.gellyfish.com>
On Mon, 7 Aug 2000 10:28:00 -0600 Robin Bank wrote:
> I need to upload two pictures with a cgi script via a form.
>
> Can someone point me in the right direction as to good modules/methods to
> use for this.
>
CGI.pm will help you do this and the activity of file uploading is well
documented in the manpage. You would also do worse than search Deja News
for 'file upload' .
/J\
--
yapc::Europe in assocation with the Institute Of Contemporary Arts
<http://www.yapc.org/Europe/> <http://www.ica.org.uk>
------------------------------
Date: 8 Aug 2000 09:59:49 GMT
From: The WebDragon <nospam@nospam.com>
Subject: re: using perl to fetch finger .plan information
Message-Id: <8molml$31f$0@216.155.32.30>
| he WebDragon wrote:
|
| > I've been fiddling around with Net::Finger, but it seems
| > to me there could be something a little more robust out
| > there (just my impression)
|
| (snipped)
|
| You know better than this, Mr. Dragon. Almost all finger
| connections have been shut down. There may be a handful
| still operating here and there. Nevertheless, you know
| as well as I do, finger is past history or quickly on
| the way to becoming past history, because of all the
actually Finger is alive and well in the gaming community due to the
predilection of well-known game gurus to post information updates to
their .plan files on a regular basis to keep the gaming kiddiez drooling
on the edge of their seats for driblets of wisdom to ooze from the
fingers of their gaming gods. *eyerolls*
in any case I do have a project to finish that requires the use of a
working finger to sites that WILL RESPOND to a proper finger request.
| serious abuse of this feature, namely invasion of privacy
| and criminal internet / real life stalking, of which our
| family was victimized for several years, as you equally
| well know.
no, frankly I haven't a clue, I'm not involved, and don't want to know.
--
send mail to mactech (at) webdragon (dot) net instead of the above address.
this is to prevent spamming. e-mail reply-to's have been altered
to prevent scan software from extracting my address for the purpose
of spamming me, which I hate with a passion bordering on obsession.
------------------------------
Date: Tue, 08 Aug 2000 08:38:11 GMT
From: Steve Button <steve_button@my-deja.com>
Subject: what does foreach (0...10) do ???
Message-Id: <8mogtj$j2u$1@nnrp1.deja.com>
Notice the three dots instead of two. It seems to work, but why??
Is it just luck that it happens to work and could break at some time in
the future?
It seems that :-
foreach (0..10) {print}
and
foreach (0...10) {print}
do the same thing.
Bizarre.
Steve
--
HuntAHome http://www.huntahome.com
Properties throughout the UK and Europe
Subscribe to receive a free daily email of all
matching properties. Free to advertise your property
Sent via Deja.com http://www.deja.com/
Before you buy.
------------------------------
Date: Tue, 08 Aug 2000 09:15:14 GMT
From: rgarciasuarez@free.fr (Rafael Garcia-Suarez)
Subject: Re: what does foreach (0...10) do ???
Message-Id: <slrn8ovk6t.i7u.rgarciasuarez@rafael.kazibao.net>
Steve Button wrote in comp.lang.perl.misc:
>Notice the three dots instead of two. It seems to work, but why??
>
>Is it just luck that it happens to work and could break at some time in
>the future?
>
>It seems that :-
>
>foreach (0..10) {print}
>
>and
>
>foreach (0...10) {print}
>
>do the same thing.
Read the section on range operators in perlop.
--
Rafael Garcia-Suarez
------------------------------
Date: Tue, 08 Aug 2000 09:31:24 GMT
From: Jonathan Stowe <gellyfish@gellyfish.com>
Subject: Re: what does foreach (0...10) do ???
Message-Id: <MrQj5.231$Ei6.40508@news.dircon.co.uk>
On Tue, 08 Aug 2000 08:38:11 GMT, Steve Button Wrote:
> Notice the three dots instead of two. It seems to work, but why??
>
> Is it just luck that it happens to work and could break at some time in
> the future?
>
> It seems that :-
>
> foreach (0..10) {print}
>
> and
>
> foreach (0...10) {print}
>
> do the same thing.
>
> Bizarre.
Read about the 'Range Operators' in the perlop manpage - the
two and three dot versions only behave differently in a scalar context,
they behave the same in a list context.
/J\
------------------------------
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 3946
**************************************