[25570] in Perl-Users-Digest
Perl-Users Digest, Issue: 7814 Volume: 10
daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Tue Feb 22 21:05:55 2005
Date: Tue, 22 Feb 2005 18:05:18 -0800 (PST)
From: Perl-Users Digest <Perl-Users-Request@ruby.OCE.ORST.EDU>
To: Perl-Users@ruby.OCE.ORST.EDU (Perl-Users Digest)
Perl-Users Digest Tue, 22 Feb 2005 Volume: 10 Number: 7814
Today's topics:
Re: '+<' mode for opening files xhoster@gmail.com
Re: '+<' mode for opening files <spamtrap@dot-app.org>
Re: '+<' mode for opening files <abigail@abigail.nl>
Re: '+<' mode for opening files <noreply@gunnar.cc>
Re: '+<' mode for opening files <abigail@abigail.nl>
Re: '+<' mode for opening files xhoster@gmail.com
Re: [perl-python] exercise: partition a list by equival <iketo2@netscape.net>
Re: help about array and hash <1usa@llenroc.ude.invalid>
Re: How to NOT use utf8. <flavell@ph.gla.ac.uk>
Re: Need help with CGI/ DBI error (permissions?) <1usa@llenroc.ude.invalid>
Re: Need help with CGI/ DBI error (permissions?) <1usa@llenroc.ude.invalid>
Re: Need help with CGI/ DBI error (permissions?) <flavell@ph.gla.ac.uk>
Re: Need help with CGI/ DBI error (permissions?) <tadmc@augustmail.com>
Re: Need help with CGI/ DBI error (permissions?) <1usa@llenroc.ude.invalid>
Re: perl null value ? <tadmc@augustmail.com>
Re: perl null value ? <abigail@abigail.nl>
Re: Regex for "search query" string nick.p.doyle@gmail.com
Re: Regex for "search query" string <1usa@llenroc.ude.invalid>
Re: Regex for "search query" string <tadmc@augustmail.com>
Re: Regex for "search query" string <tadmc@augustmail.com>
Re: Regular expression problem <noreply@gunnar.cc>
Return HTML between tags with HTML::TokeParser ? <michael.wagg@gmail.com>
Re: Return HTML between tags with HTML::TokeParser ? <1usa@llenroc.ude.invalid>
Re: Return HTML between tags with HTML::TokeParser ? <maqo@umich.edu>
Re: Web Application Installation Script nospam@geniegate.com
Re: Write-Only Socket <No_4@dsl.pipex.com>
Digest Administrivia (Last modified: 6 Apr 01) (Perl-Users-Digest Admin)
----------------------------------------------------------------------
Date: 22 Feb 2005 19:20:45 GMT
From: xhoster@gmail.com
Subject: Re: '+<' mode for opening files
Message-Id: <20050222142045.631$9t@newsreader.com>
"Paul Lalli" <mritty@gmail.com> wrote:
> Greetings.
>
> I am attempting to understand what is the use of opening files for both
> reading and writing.
It is useful for treating files like a big old low-level random-access
array of bytes. You use it in conjuction with seek and tell (or sysseek).
...
> Can someone please explain this result to me? It looks as though perl
> appended the file with whatever data I had already read, followed by the
> output I actually printed. Is this what is supposed to happen?
Whenever you switch between reading and writing, you have to do a "seek".
Otherwise weird crap (like what you observed) will happen.
> Is
> there a way (using this method of opening a file for simultaneous read &
> writes) to just print new data to the file, without printing copies of
> any data that's already been read?
my $line = <$fh>;
print "Line is: $line";
seek($fh,0,2); #seek to end of file
print $fh "A\n";
print $fh "B\n";
Xho
--
-------------------- http://NewsReader.Com/ --------------------
Usenet Newsgroup Service $9.95/Month 30GB
------------------------------
Date: Tue, 22 Feb 2005 14:26:47 -0500
From: Sherm Pendley <spamtrap@dot-app.org>
Subject: Re: '+<' mode for opening files
Message-Id: <kvqdnW6JYo7lGobfRVn-2A@adelphia.com>
Paul Lalli wrote:
> I am attempting to understand what is the use of opening files for both
> reading and writing. I have read both
> perldoc -f open
> and
> perldoc perlopentut
> but I am confused. The above documentation refers to using '+<' mode as
> 'updating', and suggests -i is a better alternative. That's all well
> and good, but I would still like to understand what specifying a mode of
> '+<' actually *does*.
Each file handle has a "cursor" - the current position at which reading and
or writing will take place. The cursor is automatically moved to just past
the end of each read/write to the file.
But, you can also move the cursor manually - have a look at
perldoc -f seek
perldoc -f tell
Say you want to access a specified record in a file of fixed-length records,
read it, make some changes to it, and then write it back without writing
the whole file:
# Assuming an already open $fh, strict, warnings, etc...
seek($fh, $record_size * $record_number, SEEK_SET);
read($fh, $record_data, $record_size);
# ... Do some stuff to $record_data
seek($fh, $record_size * $record_number, SEEK_SET);
print $fh $record_data;
As you can probably see by now, it's not so useful for variable-sized
records like lines of text. It won't automatically resize anything, for
example - if the data you write back is longer than the data you read, it
overwrites the beginning of the next record. The most common use of seek()
for text files is simply to "rewind" back to offset 0, overwriting the
contents of a file you've just finished reading.
It's great for fixed-size records like EDI though.
sherm--
--
Cocoa programming in Perl: http://camelbones.sourceforge.net
Hire me! My resume: http://www.dot-app.org
------------------------------
Date: 22 Feb 2005 22:18:18 GMT
From: Abigail <abigail@abigail.nl>
Subject: Re: '+<' mode for opening files
Message-Id: <slrnd1nbta.p92.abigail@alexandra.abigail.nl>
Paul Lalli (mritty@gmail.com) wrote on MMMMCXCIII September MCMXCIII in
<URL:news:6gLSd.68077$g16.42650@trndny08>:
// Greetings.
//
// I am attempting to understand what is the use of opening files for both
// reading and writing. I have read both
// perldoc -f open
// and
// perldoc perlopentut
// but I am confused. The above documentation refers to using '+<' mode as
// 'updating', and suggests -i is a better alternative. That's all well
// and good, but I would still like to understand what specifying a mode of
// '+<' actually *does*.
//
// For example, a sample input file contains the five lines:
// 1
// 2
// 3
// 4
// 5
//
// Executing the following script:
// #!/usr/bin/perl
// use strict;
// use warnings;
// open my $fh, '+<', 'input.txt' or die "Cannot open: $!\n";
// my $line = <$fh>;
// print "Line is: $line";
// print $fh "A\n";
// __END__
//
// results in output of:
// Line is: 1
//
// and the input file now contains:
// 1
// 2
// 3
// 4
// 5
// 1
// A
Really? What version of Perl, and what OS? Because that's wrong. What
should be in the input file is:
1
A
3
4
5
// Can someone please explain this result to me? It looks as though perl
// appended the file with whatever data I had already read, followed by the
// output I actually printed. Is this what is supposed to happen? Is
// there a way (using this method of opening a file for simultaneous read &
// writes) to just print new data to the file, without printing copies of
// any data that's already been read?
What happens if you open a file is there is a "file pointer", a little
pointer remembering where you are in the file. If you read a line, perl
will read starting from the point where the file pointer is at - and up
to and including the next newline. The file pointer will be set to the
next (and hence still unread) character. And if you write to the file,
Perl will start writing from whereever the file pointer is at the moment.
So, if you first read the first line, the file pointer will be positioned
on the 2, which is right after the newline. You write two characters, the
A, and a newline, so the A overwrites the 2, and the newline the newline
following the 2. And that should result in the file:
1
A
3
4
5
Abigail
--
perl -Mstrict='}); print "Just another Perl Hacker"; ({' -le1
------------------------------
Date: Tue, 22 Feb 2005 23:35:01 +0100
From: Gunnar Hjalmarsson <noreply@gunnar.cc>
Subject: Re: '+<' mode for opening files
Message-Id: <381q9mF5kkk7iU1@individual.net>
Abigail wrote:
> Paul Lalli wrote:
>> For example, a sample input file contains the five lines:
>> 1
>> 2
>> 3
>> 4
>> 5
>>
>> Executing the following script:
>> #!/usr/bin/perl
>> use strict;
>> use warnings;
>> open my $fh, '+<', 'input.txt' or die "Cannot open: $!\n";
>> my $line = <$fh>;
>> print "Line is: $line";
>> print $fh "A\n";
>> __END__
>>
>> results in output of:
>> Line is: 1
>>
>> and the input file now contains:
>> 1
>> 2
>> 3
>> 4
>> 5
>> 1
>> A
>
> Really? What version of Perl, and what OS? Because that's wrong. What
> should be in the input file is:
>
> 1
> A
> 3
> 4
> 5
Paul's post surprised me too, but I repeated his result on my W98 box
(perl 5.8.0). On Linux I get the expected result.
Explicitly using seek() produced the expected result on W98 as well.
--
Gunnar Hjalmarsson
Email: http://www.gunnar.cc/cgi-bin/contact.pl
------------------------------
Date: 22 Feb 2005 22:55:07 GMT
From: Abigail <abigail@abigail.nl>
Subject: Re: '+<' mode for opening files
Message-Id: <slrnd1ne2a.p92.abigail@alexandra.abigail.nl>
Gunnar Hjalmarsson (noreply@gunnar.cc) wrote on MMMMCXCIII September
MCMXCIII in <URL:news:381q9mF5kkk7iU1@individual.net>:
;; Abigail wrote:
;; > Paul Lalli wrote:
;; >> For example, a sample input file contains the five lines:
;; >> 1
;; >> 2
;; >> 3
;; >> 4
;; >> 5
;; >>
;; >> Executing the following script:
;; >> #!/usr/bin/perl
;; >> use strict;
;; >> use warnings;
;; >> open my $fh, '+<', 'input.txt' or die "Cannot open: $!\n";
;; >> my $line = <$fh>;
;; >> print "Line is: $line";
;; >> print $fh "A\n";
;; >> __END__
;; >>
;; >> results in output of:
;; >> Line is: 1
;; >>
;; >> and the input file now contains:
;; >> 1
;; >> 2
;; >> 3
;; >> 4
;; >> 5
;; >> 1
;; >> A
;; >
;; > Really? What version of Perl, and what OS? Because that's wrong. What
;; > should be in the input file is:
;; >
;; > 1
;; > A
;; > 3
;; > 4
;; > 5
;;
;; Paul's post surprised me too, but I repeated his result on my W98 box
;; (perl 5.8.0). On Linux I get the expected result.
I could understand the A to be printed at the end - if a separate file
pointer for writing was maintained. But where is the extra 1 coming from?
;;
;; Explicitly using seek() produced the expected result on W98 as well.
;;
I looked in perlport, but I didn't find anything related to this issue.
Didn't read it cover to cover though.
Abigail
--
perl -wle 'print prototype sub "Just another Perl Hacker" {};'
------------------------------
Date: 22 Feb 2005 23:50:06 GMT
From: xhoster@gmail.com
Subject: Re: '+<' mode for opening files
Message-Id: <20050222185006.260$GS@newsreader.com>
Abigail <abigail@abigail.nl> wrote:
> //
> // results in output of:
> // Line is: 1
> //
> // and the input file now contains:
> // 1
> // 2
> // 3
> // 4
> // 5
> // 1
> // A
>
> Really? What version of Perl, and what OS? Because that's wrong. What
> should be in the input file is:
>
> 1
> A
> 3
> 4
> 5
I got the same results as Paul, with:
Summary of my perl5 (revision 5.0 version 8 subversion 0) configuration:
Platform:
osname=linux, osvers=2.4.21-1.1931.2.393.entsmp,
archname=i386-linux-thread-multi uname='linux porky.devel.redhat.com
2.4.21-1.1931.2.393.entsmp #1 smp thu aug 14 14:47:21 edt 2003 i686
i686 i386 gnulinux ' config_args='-des -Doptimize=-O2 -g -pipe
-march=i386 -mcpu=i686 -Dmyhostname=localhost
-Dperladmin=root@localhost -Dcc=gcc -Dcf_by=Red Hat, Inc.
-Dinstallprefix=/usr -Dprefix=/usr -Darchname=i386-linux
-Dvendorprefix=/usr -Dsiteprefix=/usr
-Dotherlibdirs=/usr/lib/perl5/5.8.0 -Duseshrplib -Dusethreads
-Duseithreads -Duselargefiles -Dd_dosuid -Dd_semctl_semun -Di_db
-Ui_ndbm -Di_gdbm -Di_shadow -Di_syslog -Dman3ext=3pm -Duseperlio
-Dinstallusrbinperl -Ubincompat5005 -Uversiononly -Dpager=/usr/bin/less
-isr' hint=recommended, useposix=true, d_sigaction=define
usethreads=define use5005threads=undef useithreads=define
usemultiplicity=define useperlio=define d_sfio=undef
uselargefiles=define usesocks=undef use64bitint=undef use64bitall=undef
uselongdouble=undef usemymalloc=n, bincompat5005=undef
Xho
--
-------------------- http://NewsReader.Com/ --------------------
Usenet Newsgroup Service $9.95/Month 30GB
------------------------------
Date: 19 Feb 2005 20:04:20 +0800
From: Isaac To <iketo2@netscape.net>
Subject: Re: [perl-python] exercise: partition a list by equivalence
Message-Id: <87ekfclprv.fsf@sinken.local.csis.hku.hk>
>>>>> "Xah" == Xah Lee <xah@xahlee.org> writes:
Xah> Try to write a Python code for this. In the Python code, the
Xah> input should be a list of couples. (for Perlers, sketch out
Xah> the algorithm on paper and try to code in Python directly.)
Xah> I'll post Perl & Python code tomorrow.
Here is my take to this problem of "connected component", in Perl. It
should be using expected O(m+n) time (optimal except that one can make
it worst-case if enough time is spent on it), although the space
requirement is a bit high (could be O(m+n) as well). Conversion to
Python is left as an exercise. :)
sub merge {
my @list = @{shift()};
my %elt_set = map { $_->[0], -1, $_->[1], -1 } @list;
my %adj_set = map { $_, {} } keys %elt_set;
$adj_set{$_->[0]}{$_->[1]} = $adj_set{$_->[1]}{$_->[0]} = 1
for @list;
my $id = 0;
my $fill;
$fill = sub {
my $elt = shift;
$elt_set{$elt} == -1 or return;
$elt_set{$elt} = $id;
&{$fill}($_)
for keys %{$adj_set{$_}};
};
for (keys %elt_set) {
++$id;
&{$fill}($_);
}
my %result_set = map { $_, [] } (1 .. $id);
while (my ($key, $val) = each %elt_set) {
push(@{$result_set{$val}}, $key);
}
return [grep { @$_ } values %result_set];
}
Regards,
Isaac.
------------------------------
Date: 22 Feb 2005 19:37:34 GMT
From: "A. Sinan Unur" <1usa@llenroc.ude.invalid>
Subject: Re: help about array and hash
Message-Id: <Xns960594C99C9D2asu1cornelledu@132.236.56.8>
"sonet" <sonet.all@msa.hinet.net> wrote in news:cvftol$e2p$1
@netnews.hinet.net:
> undef %saw;
WTF?
> @saw{@in} = (); #why? @saw not $saw, @saw is array or
> hash?<===============
> @out = sort keys %saw; # remove sort if undesired
Do you need lumber?
>
> undef @ary;
> @ary[@in] = @in; #why? @saw not $saw<===============
I don't mean to be disrespectful here but are you suffering from some
mental problem that cuases you to repeat "@saw not $saw" ad infinitum? I
tried saying that repeatedly and did not do anything for me. What does it
do for you?
Please read the posting guidelines posted here frequently for advice on
how to help others help you. First, make sure to always put
use strict;
use warnings;
in your scripts. With that:
use strict;
use warnings;
undef %saw;
@saw{@in} = ();
@out = sort keys %saw;
undef @ary;
@ary[@in] = @in;
@out = grep {defined} @ary;
__END__
generates the following messages:
C:\Documents and Settings\asu1\My Documents> t.pl
Global symbol "%saw" requires explicit package name at C:\Documents and
Settings
\asu1\My Documents\t.pl line 4.
Global symbol "%saw" requires explicit package name at C:\Documents and
Settings
\asu1\My Documents\t.pl line 6.
Global symbol "@in" requires explicit package name at C:\Documents and
Settings\
asu1\My Documents\t.pl line 6.
Global symbol "@out" requires explicit package name at C:\Documents and
Settings
\asu1\My Documents\t.pl line 7.
Global symbol "%saw" requires explicit package name at C:\Documents and
Settings
\asu1\My Documents\t.pl line 7.
Global symbol "@ary" requires explicit package name at C:\Documents and
Settings
\asu1\My Documents\t.pl line 10.
Global symbol "@ary" requires explicit package name at C:\Documents and
Settings
\asu1\My Documents\t.pl line 11.
Global symbol "@in" requires explicit package name at C:\Documents and
Settings\
asu1\My Documents\t.pl line 11.
Global symbol "@in" requires explicit package name at C:\Documents and
Settings\
asu1\My Documents\t.pl line 11.
Global symbol "@out" requires explicit package name at C:\Documents and
Settings
\asu1\My Documents\t.pl line 12.
Global symbol "@ary" requires explicit package name at C:\Documents and
Settings
\asu1\My Documents\t.pl line 12.
Execution of C:\Documents and Settings\asu1\My Documents\t.pl aborted due
to com
pilation errors.
What are you trying to do?
Sinan
------------------------------
Date: Tue, 22 Feb 2005 21:02:23 +0000
From: "Alan J. Flavell" <flavell@ph.gla.ac.uk>
Subject: Re: How to NOT use utf8.
Message-Id: <Pine.LNX.4.61.0502222049530.26079@ppepc56.ph.gla.ac.uk>
On Mon, 21 Feb 2005, pkaluski wrote:
> Alan J. Flavell wrote:
> > Sure it;s "possible", though only to those who read the
> > documentation.
>
> Alan, don't you think you are kind of impolite writing the text
> above?
You could be right: it's hard to tell. I don't know you - I only
responded on the basis of the amount of information you had provided,
and the fact that you seemed to have pre-decided the solution before
even making it clear to us what the problem was.
Usenet tends to be like that.
> I do not consider utf8 topic an obvious one.
Neither do I, which is why I'd hoped for more detail so that the
real problem could be understood...
> "use bytes" was described as working only in the current lexical
> scope.
Well, after all, if you're calling a module which is designed to use
the unicode facilities of Perl 5.8+, then I hardly think that module
is likely to be amused when it finds that you've disabled its ability
to do what it was designed to do.
> So I asked simple question,
Actually no, you asked what is really a very complicated question -
especially considering that it was almost entirely lacking any context
in terms of problem domain, circumstances, external modules called,
etcetera etcetera etcetera.
If you're processing text, then you *need* to know what encoding has
been used. If you're processing binary data, then you shouldn't be
treating it as text. That's been my attitude since, well, around 1965
I suppose it was, when I first grasped the difference, although I'd
been doing it - in a sense - without realising the point, since I met
my first computer in 1958.
> "Is it possible to switch UTF8 totaly off in perl on Windows?"
I asked you before why you thought that Windows was somehow relevant
to this question, but you still have not supplied any answer to that.
> Was this question so difficult to understand?
Yes, it was, IMHO. That's why I asked you several supplementary
questions, to help in understanding the problem in its context - but
which you have chosen - it seems - to ignore.
good luck
------------------------------
Date: 22 Feb 2005 20:02:04 GMT
From: "A. Sinan Unur" <1usa@llenroc.ude.invalid>
Subject: Re: Need help with CGI/ DBI error (permissions?)
Message-Id: <Xns960598F071FBFasu1cornelledu@132.236.56.8>
"patrickg" <pat@patmail.com> wrote in
news:%gLSd.105743$JF2.40208@tornado.tampabay.rr.com:
> "A. Sinan Unur" <1usa@llenroc.ude.invalid> wrote in message
> news:Xns9605854249894asu1cornelledu@132.236.56.8...
>
>> It is a web server + OS configuration issue.
> You really haven't shown that
Again, missing the point: It is your responsibility to show that the
issue is a Perl issue.
On the other hand, if you really are looking for a clue-by-four
<URL:
http://www.microsoft.com/resources/documentation/iis/6/all/proddocs/en-
us/gs_getstarted.mspx>
Use care when configuring NTFS permissions for your Web site.
Inappropriately set permissions can deny valid users access to required
files and directories. For example, even though a user has the correct
user rights to view and execute a program, the user might not have
permission to access a particular dynamic-link library (DLL) that is
required to run that program. To guarantee users secure and
uninterrupted file access, place related files in the same directory,
and then assign the appropriate NTFS permissions to the directory.
This, of course, is only an example.
> - that's just your guess since you don't have another idea.
Actually, I have a very good idea, but that is not relevant here.
> Kinda like any support rep for any hardware/software product -
> if the solution isn't in their pre-scripted checklist, then
> they say it's an OS issue: "Call Microsoft."
I am not a support rep for anyone. If you can come to terms with that,
your life will become much more meaningful.
>> >> > then I'm not sure which forum would be more appropriate.
>> >>
>> >> That is something for you to ponder.
>
> From clpmisc_guidelines.text:
> off-topic postings will happen from
> time to time. Be gracious when someone helps you find a better
> place to ask your question by pointing you to a more
> applicable newsgroup.
Sure, if I knew what newsgroups deal with IIS, then I would have
mentioned that. No big deal. But how can you expect everyone to rush off
searching the Microsoft newsgroup hierarchy on your behalf.
> Thanks for the help (NOT).
You are still most welcome for the help I have already given you even if
you do not realize it.
>> I don't have to. It is your job to say "thank you, I will look for a
>> forum that deals specifically with IIS + Windows issues" and go away.
>>
>
> From clpmisc_guidelines.text:
> A note to newsgroup "regulars":
>
> Do not use these guidelines as a "license to flame" or other
> meanness.
I have not flamed you. I made a statement of fact: This is not the
appropriate forum to post your question.
> which is why I'm wondering why you replied to begin with.
To point out that you should seek the solution to your problem elsewhere
so that you can solve your problem.
> so you decided to flame instead.
I politely pointed out a fact.
> have the courtesy not to respond to any other questions that I will
> have.
...
> ps - You really should get your egotistic head out of your ass.
Clearly, you are in no position to demand courtesy.
Sinan
------------------------------
Date: 22 Feb 2005 20:26:43 GMT
From: "A. Sinan Unur" <1usa@llenroc.ude.invalid>
Subject: Re: Need help with CGI/ DBI error (permissions?)
Message-Id: <Xns96059D1E83AE1asu1cornelledu@132.236.56.8>
"patrickg" <pat@patmail.com> wrote in
news:%gLSd.105743$JF2.40208@tornado.tampabay.rr.com:
> ps - You really should get your egotistic head out of your ass.
I have trouble understanding why you seem to prefer to waste your time
arguing with me instead of trying to solve your problem.
Then, I thought to myself, while the solution might be obvious to me,
maybe you were frustrated by many fruitless Google searches or something
because finding the right answer required coming up with a magic
combination of keywords.
So, I went to <URL: http://www.google.com/>, typed in
perl iis oracle
in the search box and clicked "I'm Feeling Lucky". Can you guess what
came up:
Solution was to give Read & Execute permissions to the c:\orant
directories to the network/local account that the web server uses.
The perl scripts need to go outside of the perl directories to use
Oracle stuff, so give the web server permission to execute the Oracle
stuff.
The reason it worked from the command line was that I was using my
own
network account that already had permissions to the Oracle
directories.
As I pointed out, this is not a Perl issue, but a web server + OS
configuration issue.
You have shown that you would rather sit on your gentle behind and yell
obscenities at people who are trying to steer you in the right direction
than actually make an effort to help yourself.
*PLONK*
Sinan
------------------------------
Date: Tue, 22 Feb 2005 20:32:17 +0000
From: "Alan J. Flavell" <flavell@ph.gla.ac.uk>
Subject: Re: Need help with CGI/ DBI error (permissions?)
Message-Id: <Pine.LNX.4.61.0502222030190.26079@ppepc56.ph.gla.ac.uk>
On Tue, 22 Feb 2005, A. Sinan Unur wrote:
[quoting killfiled troll writing the usual kind of drivel...]
> I have trouble understanding why you seem to prefer to waste your time
> arguing with me instead of trying to solve your problem.
So stop feeding the troll, feed your killfile instead, and let's all
move on. Please?
------------------------------
Date: Tue, 22 Feb 2005 16:52:57 -0600
From: Tad McClellan <tadmc@augustmail.com>
Subject: Re: Need help with CGI/ DBI error (permissions?)
Message-Id: <slrnd1ndu9.37o.tadmc@magna.augustmail.com>
patrickg <pat@patmail.com> wrote:
> Feel free to killfile me,
OK.
--
Tad McClellan SGML consulting
tadmc@augustmail.com Perl programming
Fort Worth, Texas
------------------------------
Date: Tue, 22 Feb 2005 23:43:45 GMT
From: "A. Sinan Unur" <1usa@llenroc.ude.invalid>
Subject: Re: Need help with CGI/ DBI error (permissions?)
Message-Id: <Xns9605BE875EDDCasu1cornelledu@127.0.0.1>
"Alan J. Flavell" <flavell@ph.gla.ac.uk> wrote in
news:Pine.LNX.4.61.0502222030190.26079@ppepc56.ph.gla.ac.uk:
> On Tue, 22 Feb 2005, A. Sinan Unur wrote:
>
> [quoting killfiled troll writing the usual kind of drivel...]
>
>> I have trouble understanding why you seem to prefer to waste your time
>> arguing with me instead of trying to solve your problem.
>
> So stop feeding the troll, feed your killfile instead, and let's all
> move on. Please?
Looking back, I realize I went over-board. Too much dead time in between
meetings is all I can blame it on. Apologies.
Sinan.
------------------------------
Date: Tue, 22 Feb 2005 11:49:29 -0600
From: Tad McClellan <tadmc@augustmail.com>
Subject: Re: perl null value ?
Message-Id: <slrnd1ms59.2oj.tadmc@magna.augustmail.com>
[ Please do not top-post. Text rarranged into chronological order. ]
jeremiah johnson <jjohnson@psg.com> wrote:
> Alexandre Jaquet wrote:
>> Hi how can make a test if ($var ne null) { print "not null"; } when I'm
> The Perl "null" values are:
Perl does not have a "null".
Only the OP knows what "null" is, we don't have enough
information to answer the question...
The Perl _false_ values are:
> 1) '' The empty string
> 2) '0' Zero in single quotes
The "in single quotes" doesn't belong there, that is syntax (code)
while here we have been speaking of values (data).
2) '0' The 1-character string where the 1 character is the zero digit
is the best I've come up with.
> 3) undef very similar to the NULL in other languages
> 4) .. can't remember the fourth. sorry, tad.
4) 0 Numerically zero
:-)
--
Tad McClellan SGML consulting
tadmc@augustmail.com Perl programming
Fort Worth, Texas
------------------------------
Date: 22 Feb 2005 22:21:03 GMT
From: Abigail <abigail@abigail.nl>
Subject: Re: perl null value ?
Message-Id: <slrnd1nc2f.p92.abigail@alexandra.abigail.nl>
jeremiah johnson (jjohnson@psg.com) wrote on MMMMCXCIII September
MCMXCIII in <URL:news:RkKSd.42339$4q6.25847@attbi_s01>:
}} take your elitist attitude and shove it. i will not be reposting.
*PLONK*
Abigail
--
# Count the number of lines; code doesn't match \w. Linux specific.
()=<>;$!=$=;($:,$,,$;,$")=$!=~/.(.)..(.)(.)..(.)/;
$;++;$*++;$;++;$*++;$;++;`$:$,$;$" $. >&$*`;
------------------------------
Date: 22 Feb 2005 11:10:31 -0800
From: nick.p.doyle@gmail.com
Subject: Re: Regex for "search query" string
Message-Id: <1109099431.912428.296900@z14g2000cwz.googlegroups.com>
In code it would be something like :
$query = "betty and \"the jets\";
while /super regex here/
print $1;
To be displaying :
"the jets"
" and "
betty
mm?
------------------------------
Date: 22 Feb 2005 19:41:56 GMT
From: "A. Sinan Unur" <1usa@llenroc.ude.invalid>
Subject: Re: Regex for "search query" string
Message-Id: <Xns96059586CD070asu1cornelledu@132.236.56.8>
nick.p.doyle@gmail.com wrote in news:1109099431.912428.296900
@z14g2000cwz.googlegroups.com:
Please quote some context when you are replying.
> In code it would be something like :
> $query = "betty and \"the jets\";
> while /super regex here/
> print $1;
That does not compile.
> To be displaying :
> "the jets"
> " and "
> betty
WHat you have here is a pseudo-specification for a mini language. If I were
you, I would be looking at modules with 'Parser' in their names.
> mm?
No thanks. Do you have any mini Mars bars though?
Sinan
------------------------------
Date: Tue, 22 Feb 2005 16:58:49 -0600
From: Tad McClellan <tadmc@augustmail.com>
Subject: Re: Regex for "search query" string
Message-Id: <slrnd1ne99.37o.tadmc@magna.augustmail.com>
nick.p.doyle@gmail.com <nick.p.doyle@gmail.com> wrote:
> " and " means a space, then the letters 'a', 'n' and 'd', then another
> space
> Like in "homer and bart" but not "flanders".
This regex will match that:
/ and /
> "first" as in the order in which things are matched
Matches go left to right in Perl, so put the thing you want
to match first leftmost.
--
Tad McClellan SGML consulting
tadmc@augustmail.com Perl programming
Fort Worth, Texas
------------------------------
Date: Tue, 22 Feb 2005 17:00:46 -0600
From: Tad McClellan <tadmc@augustmail.com>
Subject: Re: Regex for "search query" string
Message-Id: <slrnd1necu.37o.tadmc@magna.augustmail.com>
nick.p.doyle@gmail.com <nick.p.doyle@gmail.com> wrote:
> In code it would be something like :
> $query = "betty and \"the jets\";
> while /super regex here/
> print $1;
If you post Perl code, we will help you fix it.
If not, then you are on your own.
Good luck!
--
Tad McClellan SGML consulting
tadmc@augustmail.com Perl programming
Fort Worth, Texas
------------------------------
Date: Tue, 22 Feb 2005 22:16:37 +0100
From: Gunnar Hjalmarsson <noreply@gunnar.cc>
Subject: Re: Regular expression problem
Message-Id: <381lmfF5jlc8hU1@individual.net>
Willem wrote:
> Anno Siegel wrote:
>>
>> s/([^(|)])/sprintf "%2x", ord $1/eg;
>
> Thanks! This would transform "a(1|2)b" to "61(31|32)62", which is indeed
> what I want. However, I want to exclude the case where parentheses do
> surround other characters than [\d\.\|]. To illustrate
>
> a(1|2)b should yield 61(31|32)62
> a(12)b should yield 612831322962
In the last example, parentheses surround digits, which does not match
your verbal description. Please be exact when describing your problem!
We are not mind readers.
Would this possibly do it?
s{(\([^|)]+(?:\|[^|)]+)+\))|(.)}{
my $hexenc = sub { sprintf '%2x', ord $_[0] };
if ($2) { $hexenc->($2) }
else { local $_ = $1; s/([^(|)])/$hexenc->($1)/eg; $_ }
}eg;
--
Gunnar Hjalmarsson
Email: http://www.gunnar.cc/cgi-bin/contact.pl
------------------------------
Date: 22 Feb 2005 16:44:19 -0800
From: "Maqo" <michael.wagg@gmail.com>
Subject: Return HTML between tags with HTML::TokeParser ?
Message-Id: <1109119459.537290.141800@c13g2000cwb.googlegroups.com>
Is it possible to use HTML::TokeParser to return the raw HTML between
two <A> tags, as opposed to just the text? My source file contains
several blocks of code--containing anchor links for each--that I'm
trying to extract by section while maintaining formatting.
My code:
my $p = HTML::TokeParser->new("file.txt" || die "Can't open file.");
while (my $t = $p->get_tag("a")) {
my $name = $t->[1]{name};
next unless $name && ($name eq "anchor");
print "$name : " . $p->get_text("a");
Example HTML source:
<A NAME='anchor1'></a><p>Some text and HTML formatting</p><BR>
<A NAME='anchor2'></a><p>Some text and HTML formatting</p><BR>
...
<A NAME='anchor10'></a><p>Some text and HTML formatting</p><BR>
The above code returns the "text and formatting" portions nicely,
albeit only as text. Is there an easy way to do this using
HTML::Parser to return the desired portion, with HTML markup included?
Many thanks.
------------------------------
Date: Wed, 23 Feb 2005 01:33:25 GMT
From: "A. Sinan Unur" <1usa@llenroc.ude.invalid>
Subject: Re: Return HTML between tags with HTML::TokeParser ?
Message-Id: <Xns9605D11E918C4asu1cornelledu@127.0.0.1>
"Maqo" <michael.wagg@gmail.com> wrote in news:1109119459.537290.141800
@c13g2000cwb.googlegroups.com:
> Is it possible to use HTML::TokeParser to return the raw HTML between
> two <A> tags, as opposed to just the text? My source file contains
> several blocks of code--containing anchor links for each--that I'm
> trying to extract by section while maintaining formatting.
>
> My code:
>
> my $p = HTML::TokeParser->new("file.txt" || die "Can't open file.");
Cute but counter-productive. Please post real code.
> while (my $t = $p->get_tag("a")) {
> my $name = $t->[1]{name};
> next unless $name && ($name eq "anchor");
> print "$name : " . $p->get_text("a");
>
> Example HTML source:
>
> <A NAME='anchor1'></a><p>Some text and HTML formatting</p><BR>
Am I missing something here? There is no text between <a> and </a>
above.
> The above code returns the "text and formatting" portions nicely,
> albeit only as text.
Once the bugs are fixed, the code above runs successfully and produces
no output at all. That is exactly what I expected to see based on the
sample data you provided. Problem solved.
Hvae you read the posting guidelines?
Sinan
------------------------------
Date: Wed, 23 Feb 2005 01:50:02 GMT
From: Michael Wagg <maqo@umich.edu>
Subject: Re: Return HTML between tags with HTML::TokeParser ?
Message-Id: <ejRSd.9825$rB3.2454645@twister.nyc.rr.com>
A. Sinan Unur wrote:
>>my $p = HTML::TokeParser->new("file.txt" || die "Can't open file.");
>
> Cute but counter-productive. Please post real code.
With the exception of the input filename (which was changed from
"digest.html"), this is the exact code being used.
>>while (my $t = $p->get_tag("a")) {
>>my $name = $t->[1]{name};
>>next unless $name && ($name eq "anchor");
>>print "$name : " . $p->get_text("a");
>>
>>Example HTML source:
>>
>><A NAME='anchor1'></a><p>Some text and HTML formatting</p><BR>
>
>
> Am I missing something here? There is no text between <a> and </a>
> above.
The above code returns the text between one open tag and the next open
tag (<A> -> <A>), not between one open tag and the subsequent closing
tag (<A> -> </A>).
------------------------------
Date: Wed, 23 Feb 2005 00:37:43 GMT
From: nospam@geniegate.com
Subject: Re: Web Application Installation Script
Message-Id: <Lucy1109109840204540x73c6b4@air.tunestar.net>
In: <1109046914.304741.120890@l41g2000cwc.googlegroups.com>, "sganesa" <senthil.ganesan@gmail.com> wrote:
>I have completed web application written in perl. I 'm facing
>difficulty while deploying it in a linux box. Each time, i install, i
>have to install all the perl modules, configure apache, create
>database, test the connection. This kind of tasks are time consuming
>and frustrating. Is there any way to write installation script to do
>these tasks with few user inputs. Please help me folks.
>Thanks in Advance, sGanesa
Unfortunately, there really isn't a ".war" for perl the way there is for JSP. :-(
I find Apache's 'Include' directive handy in this regard, but it's still
a hassle. (Create your own apache config file, then editing Apache's configuration
is a simple 'Include /path/to/your/conf')
For command line utilities, I've actually resorted to putting everything
in 1 HUGE script. (yuck) to overcome this problem. Can't say as I'd recommend
that for a web application, though.
In days gone by.. I had a DB <-> XML library. (Was for a corporation, I couldn't
keep it) that could be used to execute the SQL statements for a given DB. This
was useful, I've ported the idea over to PHP for other uses.
Seems the part I struggle with most is the 'use lib' part of a program. Sure
wish there were some way to override perl's built in 'use' to my own resolver
subroutine. (Some way that didn't involve another module, thus creating
a chicken & egg problem)
Jamie
--
http://www.geniegate.com Custom web programming
guhzo_42@lnubb.pbz (rot13) User Management Solutions
------------------------------
Date: Tue, 22 Feb 2005 23:32:31 +0000
From: Big and Blue <No_4@dsl.pipex.com>
Subject: Re: Write-Only Socket
Message-Id: <7bydnXes_8qRXIbfRVnygg@pipex.net>
Martin Kissner wrote:
>
> The reason is that I wanted to know if it can be done.
>
> [OT]
> The reason why I want to know is that I have noticed that the syslogd on
> my computer (system: Mac OS X) opens an upd port whereas 'man syslogd'
> says:
>
> | Syslogd opens an Internet domain socket as specified in /etc/services.
> | Normally syslogd will only use this socket to send messages
> | outwards, but in `insecure'' mode it will also read messages from this
> | socket.
I see no inconsistency in this at all. In insecure mode it will read
messages. So in secure mode it won't. That doesn't mean the socket is
open write-only, it just means that the daemon never attempts to read
anything from the socket (and being UDP they'll get discarded if an input
queue forms as a result).
> If the socket is r/w the service might be potentially exploitable on the
> application layer although the server is not supposed to read from the
> socket.
If it isn't going to read() (or readfrom()) then I'm not sure how you
think you (or anyone else) could persuade it to do so.
--
Just because I've written it doesn't mean that
either you or I have to believe it.
------------------------------
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.
NOTE: due to the current flood of worm email banging on ruby, the smtp
server on ruby has been shut off until further notice.
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 7814
***************************************