[19869] in Perl-Users-Digest
Perl-Users Digest, Issue: 2064 Volume: 10
daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Sun Nov 4 14:05:48 2001
Date: Sun, 4 Nov 2001 11:05:12 -0800 (PST)
From: Perl-Users Digest <Perl-Users-Request@ruby.OCE.ORST.EDU>
To: Perl-Users@ruby.OCE.ORST.EDU (Perl-Users Digest)
Message-Id: <1004900712-v10-i2064@ruby.oce.orst.edu>
Content-Type: text
Perl-Users Digest Sun, 4 Nov 2001 Volume: 10 Number: 2064
Today's topics:
Re: .cgi program <creafin1998@yahoo.com>
Re: A closure by any^Wsome other name (was Re: What's w (Mark Jason Dominus)
Re: A closure by any^Wsome other name (was Re: What's w <joe+usenet@sunstarsys.com>
Re: ASCII and portability <flavell@mail.cern.ch>
Re: ASCII and portability <mgjv@tradingpost.com.au>
Re: ASCII and portability <bart.lateur@skynet.be>
Can perl open a new browser window without embedding Ja (Qunfeng Dong)
Re: Can perl open a new browser window without embeddin <Laocoon@eudoramail.com>
Re: Can perl open a new browser window without embeddin <tony_curtis32@yahoo.com>
Re: DB module to store references? <prlawrence@lehigh.edu>
Re: Direct iteration over aoh <hbhb@gmx.de>
Re: Direct iteration over aoh <c_clarkson@hotmail.com>
Re: Good Perl Tutorials ??? <bart.lateur@skynet.be>
Re: Handling file in perl.....please help <no_mto@hotmail.com>
Re: i do not understand it(the =~s/.../.../), thanx! <uri@stemsystems.com>
Re: i do not understand it(the =~s/.../.../), thanx! <bart.lateur@skynet.be>
md5 and hashrefs <jens@irs-net.com>
Pattern matching with "(" complains... tansympp@pacific.net.sg
Re: Pattern matching with "(" complains... <ilya@martynov.org>
Re: Pattern matching with "(" complains... <bootsy52@gmx.net>
Re: Pattern matching with "(" complains... (Tad McClellan)
Re: Pattern matching with "(" complains... <tinamue@zedat.fu-berlin.de>
Re: Pattern matching with "(" complains... <bootsy52@gmx.net>
Re: Perl on Windows2000 <Benn_Wolff@HOTMAIL.COM>
Re: Perl on Windows2000 <ketamama@gmx.net>
Re: Processing portions of an array <gellyfish@gellyfish.com>
Re: reading flat-file db and replacing a word <bootsy52@gmx.net>
Re: reading flat-file db and replacing a word (Tad McClellan)
Re: reading flat-file db and replacing a word <bootsy52@gmx.net>
Responding Guidelines ? <stuart@otenet.gr>
Digest Administrivia (Last modified: 6 Apr 01) (Perl-Users-Digest Admin)
----------------------------------------------------------------------
Date: Sun, 4 Nov 2001 11:33:54 -0600
From: "John Smith" <creafin1998@yahoo.com>
Subject: Re: .cgi program
Message-Id: <tuaut67vl0im2e@corp.supernews.com>
It has something to do with my data file size. If I keep the file size down
(around 1500 lines or less), then the program works fine. The 500 server
error starts once I increase the number of lines in the data file. The more
lines I add to the input file, the fewer lines of output I end up with in
the output file. Still working on it.
Weird.
"Tim Hammerquist" <tim@vegeta.ath.cx> wrote in message
news:slrn9u9ek4.553.tim@vegeta.ath.cx...
> Me parece que John Smith <creafin1998@yahoo.com> dijo:
> > I have a very annoying problem occurring with a new cgi program I
wrote.
> > I'm opening a text file and processing data from the file, then placing
the
> > results in another file. Done it a million times with no problems.
This
> > one is a little different in the since that I have 2 'for' loops which
will
> > cause the program to loop approximately 40,000 * (40,000 - n) times,
where n
> > starts at 1 and is incremented. This is more looping than I usually
deal
> > with in a program.
> >
> > Anyway, the problem is that the program writes to my output file about
22-27
> > lines, then terminates. It was consistantly 27 lines, then went down
to 23
> > lines after I made a change, then down to 22 lines after another
change.
> > After undo-ing my changes, then it still consistantly writes only 22
lines,
> > then I get a the "
> > Internal Server Error
> > The server encountered an internal error or misconfiguration and was
unable
> > to complete your request." error that's so common. I am running the
program
> > through my browser and do not have access to telnet.
> >
> > Any advise? It seems like I'm bumping up against some kind of buffer
limit.
> > Like I said part of my output file gets written (only 22 lines out of
about
> > 40,000 that need to be written). I'm totally unfamilar with these
types of
> > limitations in the cgi/perl world
> >
> > Thanks in advance.
>
> You're going to need to give us more details, such as Perl version,
> platform that your perl's running on, the type of data it's processing,
> and an example of the code that processes it.
>
> And unless you're running your script on a pre-286 processor, your
> program should be able to process a lot more than 27 lines before
> croaking.
>
> It sounds like an error in your loop logic (you said it's more than
> you're used to dealing with, right?) but post some code and sample data
> and we'll see what we can do.
>
> Cheers,
> Tim
> --
> You are utterly the stupidest, most self-centered, appallingest excuse
> for an anthropomorphic personification on this or any other plane!
> -- Death, The Sandman
------------------------------
Date: Sun, 04 Nov 2001 17:00:28 GMT
From: mjd@plover.com (Mark Jason Dominus)
Subject: Re: A closure by any^Wsome other name (was Re: What's wrong with File::Find)
Message-Id: <3be5742b.266e$1ce@news.op.net>
In article <m1u1wjrb1s.fsf_-_@halfdome.holdit.com>,
Randal L. Schwartz <merlyn@stonehenge.com> wrote:
>>>>>> "Mark" == Mark Jason Dominus <mjd@plover.com> writes:
>
>Mark> 'Closure' has a specific technical meaning, and this is not it. Folks
>Mark> are of course free to promulgate this alternative, nonstandard usage
>Mark> of 'closure', but I don't really see the point. It will just cut us
>Mark> off from the mainstream of people who are discussing these things
>Mark> seriously.
>
>Then what *easy* word would you suggest to distinguish anonymous
>subroutines that do not include a pad from those that do?
I don't understand why this is so important that it needs a separate
single word, nor why the burden to invent one is on me, instead of on
the person who wants to use it, perhaps you.
I'm just pointing out that you are using the word incorrectly. There
are no doubt lots of cases where you would be able to say something
more simply and succinctly by using existing words in the wrong way.
But you know that as a writer your job is to communicate with your
audience, and that means using words the way other people use them.
Consider the following sentence:
>Since that part of the Perl implementation *is* visible, and *does*
>make a difference (in terms of leaks, for example), we need a handy
>word for that.
See how much briefer it could be:
Since that segment *is* visible, and *does* adjust (from
leaks, perhaps), we need an umbrella.
Oh, but Randal, 'umbrella' doesn't mean "a handy word for that."
Never mind, I guess the succinctness outweights the potential
communication problems. There's glory for you!
>simply because lisp does it
It's not simply because lisp does it. If it were only the lisp people
who used the word in this other way, I would not consider that there
was a problem. This is not a case of us against the lisp world. It
is a case of us against *everyone* else.
--
@P=split//,".URRUU\c8R";@d=split//,"\nrekcah xinU / lreP rehtona tsuJ";sub p{
@p{"r$p","u$p"}=(P,P);pipe"r$p","u$p";++$p;($q*=2)+=$f=!fork;map{$P=$P[$f^ord
($p{$_})&6];$p{$_}=/ ^$P/ix?$P:close$_}keys%p}p;p;p;p;p;map{$p{$_}=~/^[P.]/&&
close$_}%p;wait until$?;map{/^r/&&<$_>}%p;$_=$d[$q];sleep rand(2)if/\S/;print
------------------------------
Date: 04 Nov 2001 13:56:07 -0500
From: Joe Schaefer <joe+usenet@sunstarsys.com>
Subject: Re: A closure by any^Wsome other name (was Re: What's wrong with File::Find)
Message-Id: <m3y9lmjrg8.fsf@mumonkan.sunstarsys.com>
mjd@plover.com (Mark Jason Dominus) writes:
> It's not simply because lisp does it. If it were only the lisp people
> who used the word in this other way, I would not consider that there
> was a problem. This is not a case of us against the lisp world. It
> is a case of us against *everyone* else.
Here again is the foldoc definition:
closure
1. <programming> In a reduction system, a closure is a data structure
that holds an expression and an environment of variable bindings in
which that expression is to be evaluated. The variables may be local or
global. Closures are used to represent unevaluated expressions when
implementing functional programming languages with lazy evaluation.
In a real implementation, both expression and environment are
represented by pointers.
AIUI, the point you are making is that (and overlooking
the major nitpick with classifying Perl as a reduction system),
according to this definition a "closure" does not *require* the
capture of a "local" variable.
If my understanding is correct, than please provide examples of Perl
subroutines that are *not* "closures" according to your definition.
If you cannot, then why not drop the entire concept from Perl altogether
and call everything either an anonymous or a named subroutine?
Yes, I'm arguing reductio ad absurdum :) It might seem nice for Perl
to adopt a "commonly accepted" meaning for the notion of a closure,
but as Perl is not a functional language, I fail to see how verbatim
adoption of such terminology is very wise.
Personally I like Conway's view (in OOP) of "closure" and "anonymous"
as representing orthogonal concepts.
--
Joe Schaefer
perl -wle '$,=" ";{ my @x;sub x {if(@_){push @x,@_; return sub{push @x,@_;@x}}
sub{push @x,@_;@x}}
} print x ("Just")->("another"), x -> ("perl","hacker,")'
------------------------------
Date: Sun, 4 Nov 2001 11:43:14 +0100
From: "Alan J. Flavell" <flavell@mail.cern.ch>
Subject: Re: ASCII and portability
Message-Id: <Pine.LNX.4.30.0111041133520.2514-100000@lxplus023.cern.ch>
On Nov 4, Joachim Ziegler inscribed on the eternal scroll:
> are there still machines today that use something like EBCDIC
Does the Perl ports documentation include any EBCDIC-based machines
(answer: 'yes') and does it include notes on this issue (as far as I
recall, the answer was 'yes').
> if so, are perl-programs ready to run on such machines?
Depends on the programmer and on the nature of the application.
> this means, that if i write something like
>
> print "hello world\n";
>
> does ist print 'hello world' on an EBCDIC machine?
Ill-formed question. Are you asking if it prints the ASCII string
which you quoted there? Clearly not, otherwise it wouldn't work: you
want to supply program scripts in EBCDIC, and get the answer text in
EBCDIC - that's what being an "EBCDIC machine" is about.
But if you want to talk Sockets to an ASCII-based peer, then you want
a different answer.
> are questions like these an important subject in making perl programs
> portable?
CGI.pm includes code that's aimed at running correctly on EBCDIC-based
machines.
------------------------------
Date: Sun, 4 Nov 2001 23:17:20 +1100
From: Martien Verbruggen <mgjv@tradingpost.com.au>
Subject: Re: ASCII and portability
Message-Id: <slrn9uaceg.flu.mgjv@martien.heliotrope.home>
On 4 Nov 2001 02:05:28 -0800,
Joachim Ziegler <ziegler@algorilla.de> wrote:
> hi,
>
> some questions about character encoding and portability:
'k
> does perl depend on ASCII (or an extension of ASCII) being the
> internal character encoding?
It depends on what exactly you mean. I'll just be simple-minded and say:
Lots of things in Perl are ASCII based or ASCII-centric, but no, it
doesn't _depend_ on ASCII encoding.
> are there still machines today that use something like EBCDIC or any
> completely other character encoding?
Yes.
> if so, are perl-programs ready to run on such machines?
Perl is mostly ready. Whether your program is depends on you.
$ grep -il ebcdic /opt/perl/lib/5.6.1/pod/*
/opt/perl/lib/5.6.1/pod/perlbs2000.pod
/opt/perl/lib/5.6.1/pod/perldelta.pod
/opt/perl/lib/5.6.1/pod/perlebcdic.pod
/opt/perl/lib/5.6.1/pod/perlfunc.pod
/opt/perl/lib/5.6.1/pod/perlmodinstall.pod
/opt/perl/lib/5.6.1/pod/perlos390.pod
/opt/perl/lib/5.6.1/pod/perl.pod
/opt/perl/lib/5.6.1/pod/perlport.pod
/opt/perl/lib/5.6.1/pod/perlre.pod
/opt/perl/lib/5.6.1/pod/perltoc.pod
/opt/perl/lib/5.6.1/pod/perlvmesa.pod
> this means, that if i write something like
>
> print "hello world\n";
>
> does ist print 'hello world' on an EBCDIC machine?
Yes, it does.
> are questions like these an important subject in making perl programs
> portable?
Yes, and no. Perl does some work to hide these things from you (in
character classes A-Z should be a 26 letter range, even on EBCDIC
machines), but locales and encodings are always an issue, if you do
anything that depends on them. Perl isn't that different from other
languages that way. This stuff can never totally be hidden from the
programmer. I'd read some of the documentation quoted above, especially
perlebcdic.
Martien
--
|
Martien Verbruggen | That's funny, that plane's dustin'
| crops where there ain't no crops.
|
------------------------------
Date: Sun, 04 Nov 2001 16:56:46 GMT
From: Bart Lateur <bart.lateur@skynet.be>
Subject: Re: ASCII and portability
Message-Id: <hosautg4l8reoaldg2m5jrka2cpu8c51fr@4ax.com>
Joachim Ziegler wrote:
>does perl depend on ASCII (or an extension of ASCII) being the
>internal character encoding?
Not really.
>are there still machines today that use something like EBCDIC or any
>completely other character encoding?
Yup.
>if so, are perl-programs ready to run on such machines?
>this means, that if i write something like
>
>print "hello world\n";
>
>does ist print 'hello world' on an EBCDIC machine?
It will, as EBCDIC, for the simple reason that your source code will
have to be in EBCDIC as well. No other conversion will be necessary to
do the proper thing on and ENCDIC platform.
--
Bart.
------------------------------
Date: 4 Nov 2001 17:44:46 GMT
From: qfdong@iastate.edu (Qunfeng Dong)
Subject: Can perl open a new browser window without embedding Javascript?
Message-Id: <9s3uqe$ec0$1@news.iastate.edu>
Hi there,
Is there a way in perl itself to open a new browser window similar to
javascript's window.open()? Thanks!
Qunfeng Dong
--
Qunfeng Dong
qfdong@iastate.edu
------------------------------
Date: Sun, 4 Nov 2001 19:00:10 +0100
From: Laocoon <Laocoon@eudoramail.com>
Subject: Re: Can perl open a new browser window without embedding Javascript?
Message-Id: <Xns914FC1504E45FLaocooneudoramailcom@62.153.159.134>
`$browser_dir/browser.exe`; # enter the values according to your system..
Incase you want something general, wait for someone else to answer.. :)
Lao
------------------------------
Date: Sun, 04 Nov 2001 12:06:18 -0600
From: Tony Curtis <tony_curtis32@yahoo.com>
Subject: Re: Can perl open a new browser window without embedding Javascript?
Message-Id: <87elne5s2t.fsf@limey.hpcc.uh.edu>
>> On 4 Nov 2001 17:44:46 GMT,
>> qfdong@iastate.edu (Qunfeng Dong) said:
> Hi there,
> Is there a way in perl itself to open a new browser
> window similar to javascript's window.open()? Thanks!
Nope, assuming you're talking about CGI and perl.
CGI programs run on the server. Javascript runs in the
browser (if implemented and enabled).
Of course you can "print" anything you want back to the
client in a perl CGI program, but what happens at the
other end is out of your control.
I would suggest anything further on this subject is
off-topic for clpm, possibly you'd want to ask in
comp.infosystems.www.authoring.cgi
(follow-up set).
hth
t
--
Oh! I've said too much. Smithers, use the amnesia ray.
------------------------------
Date: Sun, 4 Nov 2001 09:31:45 -0500
From: "Phil R Lawrence" <prlawrence@lehigh.edu>
Subject: Re: DB module to store references?
Message-Id: <9s3jf9$f84@fidoii.CC.Lehigh.EDU>
"Andrew Cady" <please@no.spam> wrote:
> "Phil R Lawrence" <prlawrence@lehigh.edu> writes:
> > FWIW, the data I need to sort by is not in the file, so I can't use
> > a plain UNIX utility such as sort. I am noting a unique identifier
> > found on each report in the file and doing a database lookup to sort
> > those unique identifiers by related information found in the
> > database.
Here's a clarification...
Orig File:
-----------
SSN 000-00-0000
blah blah...
foo foo...
SSN 444-44-4444
blah blah...
foo foo...
SSN 222-22-2222
blah blah...
foo foo...
-----------
# all of the following is for concept only...
my (%reports,$key,$lines);
while (<>) {
if (/^SSN/) {
$reports{$key}{lines} = $lines if defined $key;
$lines .= $_;
chomp( $key = $_);
$key =~ s/^SSN//;
} else {
$lines .= $_;
}
}
for (keys %reports) {
$sth_get_sort_address->execute( $_ );
$reports{$_}{sort_address} = $sth_get_sort_address->fetch;
}
# from memory
my @sorted_keys =
sort { $reports{$a}{sort_address} <=>$reports{$a}{sort_address} }
keys $reports;
print OUT $reports{$_}{lines} for @sorted_keys;
> Well, there's no reason you couldn't put the references into the tied
> hash; you don't need the DB to save the values between invocations.
> You could also use indices rather than references. But, you really
> shouldn't be using a hash for this. As I said above, you have to copy
> to a list anyway. The hash's memory use is entirely superfluous;
> don't put it on disk, get rid of it altogether.
I don't know how to tie a hash to a file... can you give me a lead? I only
knew enough to look at the DB modules... You are right that I don't need to
keep the data around in a database.
I don't know how to create file indixes. I am using UNIX, though.
> Store your data in a list. If you need two pieces of data per element
> (one to save, one to sort on), make it a list of lists.
You can see how my method led me to a hash. Perhaps I could use a list of
lists like so:
(
[ $sort_addr, $lines ],
[ $sort_addr, $lines ],
...
)
I fear this may also exceed memory, leading me to the question of how to tie
an array to the filesystem. The whole question is how to get this data
structure out of memory and onto disk.
Thanks,
Phil
------------------------------
Date: Sun, 04 Nov 2001 12:13:28 +0100
From: Holger <hbhb@gmx.de>
Subject: Re: Direct iteration over aoh
Message-Id: <am09utcsp24o1b6138mgeujllqlgebc7lb@4ax.com>
On Fri, 2 Nov 2001 17:40:10 -0600,
trammell@haqq.hypersloth.invalid (John J. Trammell) wrote:
>> My question is whether it can be done directly or more perlish
>> like in the first example. I'm a bit disturbed by the explicit
>> loop.
>
>print join "\n", map $_->{text}, @array;
Thanks. Actually, I was guessing in this direction. But I hardly
have experience with 'map' yet.
Best regards,
Holger
------------------------------
Date: Sat, 3 Nov 2001 22:12:35 -0600
From: "Charles K. Clarkson" <c_clarkson@hotmail.com>
Subject: Re: Direct iteration over aoh
Message-Id: <tuag1t2k7nr82c@corp.supernews.com>
"Holger" <hbhb@gmx.de> wrote in message
news:7g46utgmvblffd5ssse0m4ens9caaq29fi@4ax.com...
: Hi,
:
: I'd like to output some lines I had in an array like this:
:
: #!/usr/local/bin/perl -w
: use strict;
: my @array = ('one','two','three');
: print join("\n", @array, '');
:
: Now I have changed the array to a hashref because I needed
to
: store more data than just the text. I do the output this
way:
:
: #!/usr/local/bin/perl -w
: use strict;
: my @array;
: $array[0] = {text => 'one'};
: $array[1] = {text => 'two'};
: $array[2] = {text => 'three'};
:
: foreach my $line (@array)
: {
: print "$line->{text}\n";
: }
:
: My question is whether it can be done directly or more
perlish
: like in the first example. I'm a bit disturbed by the
explicit
: loop.
print "$$_{text}\n" for @array;
HTH,
Charles K. Clarkson
Clarkson Energy Homes, Inc.
------------------------------
Date: Sun, 04 Nov 2001 15:19:47 GMT
From: Bart Lateur <bart.lateur@skynet.be>
Subject: Re: Good Perl Tutorials ???
Message-Id: <21nautctjvfu08pk3c3ldks5podfnv8m7b@4ax.com>
brown wrote:
>Hi does anyone knows a good site that offers Perl Tutorials, well
>done, easy to naviguate and accurate???
The next tutorial doesn't appear in any overviews IIRC:
<http://www.cs.cf.ac.uk/Dave/PERL/>
--
Bart.
------------------------------
Date: Sun, 4 Nov 2001 18:09:53 +0100
From: "MAGiC MANiAC^mTo" <no_mto@hotmail.com>
Subject: Re: Handling file in perl.....please help
Message-Id: <9s3t20$n6t$1@news.kabelfoon.nl>
is it also possible to let the script wait for xxx seconds,
and automatic retry it xxx times before it shows the error?...
and how can we do this?...
thanks for the help!
René
"Clinton A. Pierce" <clintp@geeksalad.org> schreef in bericht
news:HtXE7.228952$K6.109089479@news2...
> [Posted and mailed]
>
> In article <9rvuir$q4u$1@lust.ihug.co.nz>,
> "fail006" <fail006@hotmail.com> writes:
> > Hi,
> > I am using my script write the output to a file. I have noticed when the
> > file is already open, and if i run my script, there is nothing written
to
> > the file. Although this is fine, but i would like to use my script to
detect
> > if the file is currently open or not. If it is open than a message so be
> > printed out telling the use to close the file and rerun the script.....
> > So my question is how do i know if the file is currently open by notepad
or
> > any other application
> > I programming on Win32 platform (win98)
>
> On Win98 you can't open the file for writing by more than one process.
> IIRC, the second open fails with an appropriate message. This should be
> your clue that something went wrong:
>
> # Untested
> if (! open(FILE, "foo.foo") ) {
> if ($!=~/in use/) {
> print "The file's in use. Try again later.";
> exit;
> } else {
> die $!;
> }
> }
>
> Of course, make sure that the error says that the file is "in use".
> (Print $! to make sure...I don't recall offhand.)
>
>
> --
> 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, 04 Nov 2001 16:43:21 GMT
From: Uri Guttman <uri@stemsystems.com>
Subject: Re: i do not understand it(the =~s/.../.../), thanx!
Message-Id: <x73d3uwko4.fsf@home.sysarch.com>
>>>>> "TH" == Tim Hammerquist <tim@vegeta.ath.cx> writes:
TH> Me parece que hugh1 <weiwe1@yeah.net> dijo:
>> i can not know how to understand it:
<snip of bad GCI parser>
TH> This code is broken.
then tell him to use CGI.pm.
uri
--
Uri Guttman ------ uri@stemsystems.com -------- http://www.stemsystems.com
-- Stem is an Open Source Network Development Toolkit and Application Suite -
----- Stem and Perl Development, Systems Architecture, Design and Coding ----
Search or Offer Perl Jobs ---------------------------- http://jobs.perl.org
------------------------------
Date: Sun, 04 Nov 2001 16:54:28 GMT
From: Bart Lateur <bart.lateur@skynet.be>
Subject: Re: i do not understand it(the =~s/.../.../), thanx!
Message-Id: <pjsautombrqi5fqrc7i609sbho5upblkpm@4ax.com>
hugh1 wrote:
>$name =~ tr/+/ /;
>
>why not use s/+/ /????
Doesn' t work. This will:
s/\+/ /g
and it's just a choice. tr/// might be somewhate faster, but it 's
mostly just a matter of chosen style.
--
Bart.
------------------------------
Date: Sun, 04 Nov 2001 13:58:35 +0100
From: Jens Luedicke <jens@irs-net.com>
Subject: md5 and hashrefs
Message-Id: <9s3e61$ju6$04$1@news.t-online.com>
hi ...
I have an algorithm that creates a threaded Gtk::CTree
based on the Message-ID and the In-Reply-To: Header parts.
I store each node in an hashref and each node is identified
by the Message-ID
Sometimes those Message-ID's and In-Reply-To's vary in their
length, so would it make sense to create md5 digests to 'waste'
the same amout of space to identify each node?
Or is this idea too strange to be useful at all? ;-)
--
jens
------------------------------
Date: 4 Nov 2001 12:26:09 GMT
From: tansympp@pacific.net.sg
Subject: Pattern matching with "(" complains...
Message-Id: <9s3c51$6p7$1@newton.pacific.net.sg>
Hello, :)
Pattern matching with "(" in the text seems to be failing for me. Am I
doing it the wrong way?
For example,
#!/usr/local/bin/perl
$text1="helloworld(";
$text2="helloworld(hello";
if($text2=~/^$text1/){
print "It matched.\n";
}
exit;
Running the above code results in the error:
Unmatched ( before HERE mark in regex m/^helloworld( << HERE / at
./test.pl line 6.
I'm using Perl 5.6.1 on a BSDi box. :)
Thanking in advance.
Regards,
Tan Shao Yi
------------------------------
Date: 04 Nov 2001 15:45:44 +0300
From: Ilya Martynov <ilya@martynov.org>
Subject: Re: Pattern matching with "(" complains...
Message-Id: <87hesaso07.fsf@abra.ru>
>>>>> On 4 Nov 2001 12:26:09 GMT, tansympp@pacific.net.sg said:
tansympp> Hello, :)
tansympp> Pattern matching with "(" in the text seems to be failing for me. Am I
tansympp> doing it the wrong way?
tansympp> For example,
tansympp> #!/usr/local/bin/perl
tansympp> $text1="helloworld(";
tansympp> $text2="helloworld(hello";
tansympp> if($text2=~/^$text1/){
if($text2=~/^\Q$text1\E/){
read 'perldoc perlre'
tansympp> print "It matched.\n";
tansympp> }
tansympp> exit;
tansympp> Running the above code results in the error:
tansympp> Unmatched ( before HERE mark in regex m/^helloworld( << HERE / at
tansympp> ./test.pl line 6.
tansympp> I'm using Perl 5.6.1 on a BSDi box. :)
tansympp> Thanking in advance.
tansympp> Regards,
tansympp> Tan Shao Yi
--
-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-
| Ilya Martynov (http://martynov.org/) TIV.net (http://tiv.net/) |
| GnuPG 1024D/323BDEE6 D7F7 561E 4C1D 8A15 8E80 E4AE BE1A 53EB 323B DEE6 |
-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-
------------------------------
Date: Sun, 04 Nov 2001 15:19:12 +0100
From: "Carsten Menke" <bootsy52@gmx.net>
Subject: Re: Pattern matching with "(" complains...
Message-Id: <pan.2001.11.04.15.19.06.205.1281@gmx.net>
On Sun, 04 Nov 2001 13:26:09 +0100, tansympp wrote:
> Hello, :)
>
> Pattern matching with "(" in the text seems to be failing for me. Am I
> doing it the wrong way?
>
> For example,
>
> #!/usr/local/bin/perl
>
> $text1="helloworld(";
> $text2="helloworld(hello";
>
> if($text2=~/^$text1/){
> print "It matched.\n";
> }
>
> exit;
First you know that the ( has a special meaning in regexp?
So for example if you only want to search the ( you must do the following
for example:
(Untested)
if ($_=~m/\(/)
{
print "Yeepee\n";
}
Second your pattern mathing does not match because:
you are searching helloworld( but text2 is not exactly helloworld(
text2 is helloworld(hello so you have to do something like this
(Untested)
if (/$text2=~m/^$text1.*$/)
{
print "It matched\n";
}
the .* means any character zero or more times.
So think of your regexp as a mask, if you look at your first try,
and if you see throug this mask would you see the whole $text2 string?
No, you would only see helloworld( and that is not the whole $text2
string.
Carsten
P.S. you better define
$text1='helloworld(';
$text2='helloworld(hello';
here
------------------------------
Date: Sun, 04 Nov 2001 15:52:53 GMT
From: tadmc@augustmail.com (Tad McClellan)
Subject: Re: Pattern matching with "(" complains...
Message-Id: <slrn9uakve.2lc.tadmc@tadmc26.august.net>
Ilya Martynov <ilya@martynov.org> wrote:
>>>>>> On 4 Nov 2001 12:26:09 GMT, tansympp@pacific.net.sg said:
>
>tansympp> Pattern matching with "(" in the text seems to be failing for me.
>tansympp> #!/usr/local/bin/perl
That should be:
#!/usr/local/bin/perl
use warnings;
use strict;
Ask for all the help you can get.
>tansympp> $text1="helloworld(";
>tansympp> if($text2=~/^$text1/){
>
> if($text2=~/^\Q$text1\E/){
Or:
$text1 = quotemeta "helloworld("; # perldoc -f quotemeta
>read 'perldoc perlre'
Indeed.
--
Tad McClellan SGML consulting
tadmc@augustmail.com Perl programming
Fort Worth, Texas
------------------------------
Date: 4 Nov 2001 16:48:48 GMT
From: Tina Mueller <tinamue@zedat.fu-berlin.de>
Subject: Re: Pattern matching with "(" complains...
Message-Id: <9s3rhg$10tuo9$2@fu-berlin.de>
Carsten Menke <bootsy52@gmx.net> wrote:
> On Sun, 04 Nov 2001 13:26:09 +0100, tansympp wrote:
>> Pattern matching with "(" in the text seems to be failing for me. Am I
>> doing it the wrong way?
>>
>> $text1="helloworld(";
>> $text2="helloworld(hello";
>>
>> if($text2=~/^$text1/){
>> print "It matched.\n";
>> }
> Second your pattern mathing does not match because:
> you are searching helloworld( but text2 is not exactly helloworld(
> text2 is helloworld(hello so you have to do something like this
> (Untested)
> if (/$text2=~m/^$text1.*$/)
why? m/^$text1/ should be alright (supposing there are no
metacharacters). m/^$text1/ has got an open end, so anything
can follow after $text1
> P.S. you better define
> $text1='helloworld(';
> $text2='helloworld(hello';
why?
regards, tina
--
http://www.tinita.de \ enter__| |__the___ _ _ ___
tina's moviedatabase \ / _` / _ \/ _ \ '_(_-< of
search & add comments \ \ _,_\ __/\ __/_| /__/ perception
------------------------------
Date: Sun, 04 Nov 2001 18:37:11 +0100
From: "Carsten Menke" <bootsy52@gmx.net>
Subject: Re: Pattern matching with "(" complains...
Message-Id: <pan.2001.11.04.18.37.02.515.1281@gmx.net>
On Sun, 04 Nov 2001 17:48:48 +0100, Tina Mueller wrote:
>
>
> why? m/^$text1/ should be alright (supposing there are no
> metacharacters). m/^$text1/ has got an open end, so anything can follow
> after $text1
Look at the $text1 and $text2, isn't ( a metacharacter within a pattern
match?
>> P.S. you better define
>
>> $text1='helloworld(';
>> $text2='helloworld(hello';
>
> why?
Avoid unessary trouble, you'll always on the save site to use '' if there
are no variables to subsitute, so why not? And ( is a metacharacter in
the regexp, so why should he not use ''?
Carsten
------------------------------
Date: Sun, 04 Nov 2001 13:42:10 GMT
From: "Benn Wolff" <Benn_Wolff@HOTMAIL.COM>
Subject: Re: Perl on Windows2000
Message-Id: <SAbF7.20119$wj5.10098431@news1.rdc1.sfba.home.com>
it's in the ActivePerl docs that get installed with the software
read up some in there
"Joseph J. Whalen" <joe.whalen@broadbeam.com> wrote in message
news:r1BE7.10825$ym4.472552@iad-read.news.verio.net...
> I am interested in running Perl on Windows 2000 in order to support perl
CGI
> scripts through IIS. I have a copy of ActivePerl installed on the system.
> In all of the FAQ's that I've seen, it is recommended to also use
> cgi2shell.exe. I can not seem to find this utility anywhere for download.
> My questions:
>
> 1. Is there someplace this can be downloaded from? If so, where.
> 2. Are there any other utilities I can use to replace the functionality
> cgi2shell provides?
> 3. Is there another way to get perl CGI's working under IIS other than the
> path that I've taken.
>
> If anyone has any helpful information please feel free to email me. Thank
> you for any assistance you can provide.
>
>
------------------------------
Date: Sun, 4 Nov 2001 17:49:10 +0100
From: =?iso-8859-1?Q?Daniel_Schr=F6er?= <ketamama@gmx.net>
Subject: Re: Perl on Windows2000
Message-Id: <9s3rit$4pk$1@news.informatik.uni-muenchen.de>
> "Joseph J. Whalen" <joe.whalen@broadbeam.com>
> > I am interested in running Perl on Windows 2000 in order to support perl
> > CGI
> > scripts through IIS. I have a copy of ActivePerl installed on the
system.
"Benn Wolff" <Benn_Wolff@HOTMAIL.COM>
> it's in the ActivePerl docs that get installed with the software
> read up some in there
you find it here:
<local path to
perl>/html/faq/Windows/ActivePerl-Winfaq6.html#How_do_I_configure_Microsoft_
IIS
daniel.
------------------------------
Date: 4 Nov 2001 11:02:19 GMT
From: Jonathan Stowe <gellyfish@gellyfish.com>
Subject: Re: Processing portions of an array
Message-Id: <9s377r$sf8$9@uranium.btinternet.com>
htmailing <htmailing.nospam@yahoo.com> wrote:
> Heiya,
>
> I'm pretty new to Perl and programming, so excuse my cluelessness.
>
> I have an @array which is basically a listing of names and which the script
> processes in a simple manner:
>
> foreach $name (@array) {
> whatever;
> }
>
> What I need to do is to break the @array down into pieces of 50 names (50
> being a variable which I can set) and have them processed 50 at a time.
>
> I cannot figure out how to break down the array and pass "mini-arrays" of 50
> to the sub. Also, if @array contains 160 names, I want the script to pass
> the first 150 to the whatever() sub in 3 mini-arrays, and then the remaining
> 10 should be also passed to whatever().
>
You will want to use an 'array slice' something like :
foreach $name (@array[0 .. 49],@array[150 .. 159])
{
whatever($name);
}
/J\
--
Jonathan Stowe |
<http://www.gellyfish.com> | This space for rent
|
------------------------------
Date: Sun, 04 Nov 2001 15:40:03 +0100
From: "Carsten Menke" <bootsy52@gmx.net>
Subject: Re: reading flat-file db and replacing a word
Message-Id: <pan.2001.11.04.15.40.00.915.1281@gmx.net>
On Sun, 04 Nov 2001 10:30:51 +0100, Andrew Cady wrote:
>
> Why store these in the same file? Why not e.g. store a filename in the
> record, and put the greeting in the file? Or keep them in a separate
> database or something?
Then I have to open another file each time a user logs in, and search
thru the file until the user is matched.
>
>
>> The second reason, why I want to do this is speed. I tell you exactly
>> for what I want to use this code. The examples shown are part of a
>> password file (yes, my boss said encryption is not necessary, was not
>> my idea) So now there are two things which have to be done, it is
>> wanted that at every login (done via CGI), the time of that login gets
>> set, so if I made a temporary copy and the user hits the stop button of
>> his browser what happens than?
>
> That's not how CGI works, and even if it was, it's not how you design
> interfaces. Validate the entire input before you start writing any of
> it to disk.
it is validated, after all validation is passed the process is going to
write the things to the file.
> (What exactly DO you think is going to happen if the user hits "stop"?)
Also I have searched around yesterday what
exactly happens in this case. As far as I understood, it is that if
mod_perl is installed it doesn't care about this until there is a output
to the browser then Apache remarks that the browser is gone and makes
some cleanup. If mod_cgi is used Apache makes some cleanup and closes all
files. But this is only what I understood so far, so quick. I will do a
detailed research on this.
> You should not be storing timestamps in the password file. And you say
> you're worried about disk failure!
These are not really timestamps, they are only for that when the user logs on he gets his
greeting and after that, you last logged on at 10 Feb 1989 for example.
So if this entry would not be correct, it would not be too bad.
> Well so what if it does? You don't lose any data. Even if the rename
> fails, you don't lose any data (POSIX rename() guarantees this, at
> least). Of course, these operations will never fail. They quite
> possibly will never use the physical disk (if the file is only 1 or 2k).
Thanx for this.
> You WILL lose data if two processes try it at once, though, so use a
> database.
Thanx for your pointers
Carsten
------------------------------
Date: Sun, 04 Nov 2001 15:52:52 GMT
From: tadmc@augustmail.com (Tad McClellan)
Subject: Re: reading flat-file db and replacing a word
Message-Id: <slrn9uakm0.2lc.tadmc@tadmc26.august.net>
Louis Erickson <wwonko@rdwarf.com> wrote:
>Carsten Menke <bootsy52@gmx.net> wrote:
>: On Sun, 04 Nov 2001 02:19:44 +0100, Tad McClellan wrote:
>:> Why you do not want to make a copy of the file itself?
>:>
>:> I don't see anything in your description that would preclude just using
>:> the -i command line switch and ripping through your data with a while <>
>:> loop.
>:> Perhaps you have a good reason and just haven't shared it with us?
>: Hmmmh, my reason is not really that good. But maybe I'm a little bit
>: paranoid, but the fear I got, is that every disk writing attempt could
>: fail, and therefore I'm afraid of corrupted data files (inconsistency).
>I would handle this by reading the records, one line at a time, and
>writing out updated records, or skipping a record to be deleted.
In case other readers don't recognize it, the above is "ripping
through the file with -i and a while <> loop".
>I hate to say this, but what you're describing here is a database.
>This is what databases do, and someone ELSE has written and debugged
>and tested that whole big mess of code so you don't have to. A
>good database handles all the problems of multiple people making
>changes to the data at once, and keeping the data consistent
>when errors happen.
>
>I do understand that saying, "We need a database!" is a big step,
>and kind of scary for a lot of people, but it is the right answer.
Right.
>You will also be faster that way, and be able to handle any
>amount of load and many unforseen things, which this code will
>be much harder to maintain. Perl's DBI lets you access many
>databases, such as MySql, ODBC, Sybase, and others.
^^^^^
^^^^^
Note that that particular DB does not provide all that has been
described here.
PostgreSQL is free and does have the "ACID" database properties,
I'd look into using that.
--
Tad McClellan SGML consulting
tadmc@augustmail.com Perl programming
Fort Worth, Texas
------------------------------
Date: Sun, 04 Nov 2001 17:32:47 +0100
From: "Carsten Menke" <bootsy52@gmx.net>
Subject: Re: reading flat-file db and replacing a word
Message-Id: <pan.2001.11.04.17.32.46.225.1281@gmx.net>
On Sun, 04 Nov 2001 08:06:49 +0100, Louis Erickson wrote:
>
> I would also probably consider using a lock file of some sort to keep
> other processes from mangling this file at the same time.
>
> The faq has suggestions on how to do this. There are also more details
> in "The Perl Cookbook" by Christansen & Torkington, published by
> O'Reilly. (See Recipies 7.5, 7.8, 7.9, 7.10, and 7.11 for the things
> I've talked about here.) It is, IMO, a very useful book to have
> around.
I have to admit, that I already got that book :-)
Yes, I have found good examples in this book, also I recently bought the
Camel book, but I had never had the time yet to read it from the
beginning to the end. And according to the style the book was written, it
is possible to read the book from the beginning to the end without
getting bored. :-) (Thanks Larry,Tom and Jon). The mistake I made was,
that I began to learn perl with another book, which indeed gave a good
overview, but hides the details on some things, which if I had known
before, would never had to wonder about why this or that did not happen,
ending up scratching my head.
>
> By making backup copies, you've used as much space as making your
> changes by making a copy of the file.
Space is really not that important.
> If you're worried about speed, try making up a file with that many
> lines, or more in it. Write a Perl program to generate some, or just
> copy and paste data in to your text file, and find out. It may be, you
> can handle big files easily, and it may be that you're not going to be
> fast enough anyway. Test and know.
Yes I do. The file size is 63K and I found that all operations are damn
fast, the only thing I do not know exactly is how much the file will
grow. But we expect not more than 500K to 1MB in total.
> I'm pleased to hear you're worried about a disk operation failing. That
> shows great concern and wisdom. However, the more complex your
> operations, the more likely a failure is. My experience says simple is
> almost always better.
I agree
> I would handle this by reading the records, one line at a time, and
> writing out updated records, or skipping a record to be deleted. Rather
> than trying to write perl for this off the cuff, I'm going to give you a
> little psudeo code of how I might handle this. If you're not familiar
> with that term (hard to say, since you say you're not a native English
> speaker.
Yes I know the term pseudo code it common here as well
>You're doing pretty well, so far.)
Thanx for the flowers :-)
> (While many in this newsgroup seem able to write useful bits of Perl
> quickly and easily, it's not a knack I have; I have to work over it
> slowly and carefully and go one step at a time. By figuring out like
> this ahead of time, I know what I'm doing.)
I think we got something common :-), I also need to think some time when
coding.
##### PSEUDO CODE SNIP ####
Thankx for your proposal, I gladly appreciate your help, thanx
> I do understand that saying, "We need a database!" is a big step, and
> kind of scary for a lot of people, but it is the right answer. You will
> also be faster that way, and be able to handle any amount of load and
> many unforseen things, which this code will be much harder to maintain.
> Perl's DBI lets you access many databases, such as MySql, ODBC, Sybase,
> and others.
I have yet begun thinking of getting knowlegded in MySQl. It is more and
more required, an fortunatley more more web hosts have mysql included in
their offers.
> I hope my psudeo code up there helped, and good luck. What you're doing
> isn't as straightforward as you'd like, and doing it right will be
> tricky.
>
Thanx for all
Carsten
------------------------------
Date: Sun, 4 Nov 2001 16:37:07 +0200
From: "Stuart Gall" <stuart@otenet.gr>
Subject: Responding Guidelines ?
Message-Id: <9s3kcg$34q$1@usenet.otenet.gr>
"Alan J. Flavell" <flavell@mail.cern.ch> wrote in message
news:Pine.LNX.4.30.0111040132390.2170-100000@lxplus023.cern.ch...
> On Nov 3, Stuart Gall inscribed on the eternal scroll:
> Now review the new-users FAQ for this group and take due notice of
> what it says about the importance of partitioning your problem and
> seeking answers in the _right_ places. Thank you.
>
> > If this discussion is to be continued I would really rather do it by
email
>
> You've got an entire Usenet at your disposal. I think most of us are
> too busy to get involved in free one-on-one tutorials. Anyway, when
> you find the right groups you should also be able to find their FAQs,
> which will at least get you past the usual trivial mistakes and get
> you ready to tackle the real meat of the issue. And without
> irritating the regulars...
I think you have the wrong person.
Marteen started the thread, it is not my problem it was marteens. I was
offering to help marteen by email so as not to post here. not requesting
private help myself.
For some reason marteen refused two requests to do this.
Marteens email is invalid, my initial reply was by email but it bounced.
I thought Ah what the hell I wrote the reply Ill post it with a request to
continue by email.
I now see the problem with this strategy. Infuture I will just ignore people
going off topic with invalid email addresses.
The guidelines do not offer any advice for *responding* to an off-topic
question.
Although I think what I did is reasonable
1. Try to reply by email
2. Post a quick answer with a request to continue by email
My error was I should have just ignored the reply to my reply.
Sorry Ill try not to get pulled in in future.
Perhaps the guidelines should include some advice for responding (or not) to
an off-topic question. As far as I can see V1.2 does not.
--
Stuart Gall
------------------------------------------------
This message is not provable.
------------------------------
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 2064
***************************************