[19835] in Perl-Users-Digest
Perl-Users Digest, Issue: 2030 Volume: 10
daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Mon Oct 29 11:05:34 2001
Date: Mon, 29 Oct 2001 08: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: <1004371512-v10-i2030@ruby.oce.orst.edu>
Content-Type: text
Perl-Users Digest Mon, 29 Oct 2001 Volume: 10 Number: 2030
Today's topics:
(RELDATE => $href -> {RELDATE}) =~ tr|/|-| (EED)
Re: (RELDATE => $href -> {RELDATE}) =~ tr|/|-| <bernard.el-hagin@lido-tech.net>
Re: (RELDATE => $href -> {RELDATE}) =~ tr|/|-| (EED)
Re: (RELDATE => $href -> {RELDATE}) =~ tr|/|-| <bernard.el-hagin@lido-tech.net>
@INC <Al@yahoo.com>
Re: @INC <Laocoon@eudoramail.com>
Re: @INC <simon.oliver@umist.ac.uk>
Re: Any good free syntax coloring editors for Perl on W (Philip S Tellis)
Re: Any good free syntax coloring editors for Perl on W <goldbb2@earthlink.net>
Re: CGI param/regex difficulties <goldbb2@earthlink.net>
Re: CGI param/regex difficulties <simon.oliver@umist.ac.uk>
Re: CGI param/regex difficulties <simon.oliver@umist.ac.uk>
digital signature (TD)
Re: error on host by running my script, but it works of <johni@pa.press.net>
Re: File parseing and testing for existing data <goldbb2@earthlink.net>
Re: files in the process of being written to <dtweed@acm.org>
Re: files in the process of being written <bernie@fantasyfarm.com>
Re: files in the process of being written (Garry Williams)
for sale: Perl Developer's Guide, Peschko & DeWolfe, <H.S@chello.nl>
Re: https and writing files <tedapke@apkesoftware.com>
Logic Question (Drew Myers)
Re: Logic Question (EED)
Re: Performance gap in Benchmark.pm with/without Tk int (Anno Siegel)
Re: Performance gap in Benchmark.pm with/without Tk int <goldbb2@earthlink.net>
Re: printing html (Philip S Tellis)
Re: regexp and printing \0,\1 etc... <perl.news@lfjr.net>
Re: regexp and printing \0,\1 etc... <goldbb2@earthlink.net>
Re: regexp and printing \0,\1 etc... <perl.news@lfjr.net>
Re: Regexp for email address (Philip S Tellis)
Re: Regexp for email address <Laocoon@eudoramail.com>
Re: Regular expression stumps me ... (Philip S Tellis)
Re: selecting lines for single spacing <krahnj@acm.org>
Sorting SGML <L.N.Jewell@remove_this.leeds.ac.uk>
Re: Sorting SGML <simon.oliver@umist.ac.uk>
Re: Sorting SGML <simon.oliver@umist.ac.uk>
Re: Sorting SGML (Tad McClellan)
Re: Stripping Duplicates From Arrays <johni@pa.press.net>
Re: Stripping Duplicates From Arrays <mmanso@yahoo.com>
Re: Stripping Duplicates From Arrays <jurgenex@hotmail.com>
Digest Administrivia (Last modified: 6 Apr 01) (Perl-Users-Digest Admin)
----------------------------------------------------------------------
Date: Mon, 29 Oct 2001 15:12:41 +0100
From: "Alexander Farber (EED)" <eedalf@eed.ericsson.se>
Subject: (RELDATE => $href -> {RELDATE}) =~ tr|/|-|
Message-Id: <3BDD63D9.EDE24D62@eed.ericsson.se>
Hi,
is there a cool way to set a hash value and simultaneously substitute
some chars? I am fetching dates from Sybase and would like them to be
2001-10-29 instead of 2001/10/29 - but the following doesn't work of course:
sub files_before ($$)
{
my $dbh = shift;
my $end = shift;
my (@load, $sth);
$sth = $dbh -> prepare ('select FILEPATH, ACANUMBER, REVISION, "RELDATE" =
convert (char (10), RELDATE, 111) from LOADFILES
where RELDATE <= ? order by RELDATE');
$sth -> execute ($end);
while (my $href = $sth -> fetchrow_hashref) # create a list of hashes
{ # ordered by the RELDATE
push @load, {
FILEPATH => $href -> {FILEPATH},
ACANUMBER => $href -> {ACANUMBER},
REVISION => $href -> {REVISION},
(RELDATE => $href -> {RELDATE}) =~ tr|/|-|,
};
}
return \@load;
}
# Thank you
# Alex
------------------------------
Date: Mon, 29 Oct 2001 14:28:15 +0000 (UTC)
From: Bernard El-Hagin <bernard.el-hagin@lido-tech.net>
Subject: Re: (RELDATE => $href -> {RELDATE}) =~ tr|/|-|
Message-Id: <slrn9tqpee.3nk.bernard.el-hagin@gdndev25.lido-tech>
On Mon, 29 Oct 2001 15:12:41 +0100, Alexander Farber (EED)
<eedalf@eed.ericsson.se> wrote:
> Hi,
>
> is there a cool way to set a hash value and simultaneously substitute
> some chars? I am fetching dates from Sybase and would like them to be
> 2001-10-29 instead of 2001/10/29 - but the following doesn't work of course:
[snipped part of code]
while (my $href = $sth -> fetchrow_hashref){
$href->{RELDATE} =~ tr#/#-#;
push @load, { FILEPATH => $href -> {FILEPATH},
ACANUMBER => $href -> {ACANUMBER},
REVISION => $href -> {REVISION},
RELDATE => $href -> {RELDATE} };
}
Cheers,
Bernard
------------------------------
Date: Mon, 29 Oct 2001 15:31:26 +0100
From: "Alexander Farber (EED)" <eedalf@eed.ericsson.se>
Subject: Re: (RELDATE => $href -> {RELDATE}) =~ tr|/|-|
Message-Id: <3BDD683E.4314B7CC@eed.ericsson.se>
Bernard El-Hagin wrote:
>
> On Mon, 29 Oct 2001 15:12:41 +0100, Alexander Farber (EED)
> <eedalf@eed.ericsson.se> wrote:
> >
> > is there a cool way to set a hash value and simultaneously substitute
> > some chars? I am fetching dates from Sybase and would like them to be
> > 2001-10-29 instead of 2001/10/29 - but the following doesn't work of course:
>
> [snipped part of code]
>
> while (my $href = $sth -> fetchrow_hashref){
> $href->{RELDATE} =~ tr#/#-#;
> push @load, { FILEPATH => $href -> {FILEPATH},
> ACANUMBER => $href -> {ACANUMBER},
> REVISION => $href -> {REVISION},
> RELDATE => $href -> {RELDATE} };
> }
Thanks, but it isn't cool.
------------------------------
Date: Mon, 29 Oct 2001 14:32:56 +0000 (UTC)
From: Bernard El-Hagin <bernard.el-hagin@lido-tech.net>
Subject: Re: (RELDATE => $href -> {RELDATE}) =~ tr|/|-|
Message-Id: <slrn9tqpn7.3nk.bernard.el-hagin@gdndev25.lido-tech>
On Mon, 29 Oct 2001 15:31:26 +0100, Alexander Farber (EED)
<eedalf@eed.ericsson.se> wrote:
> Bernard El-Hagin wrote:
>>
>> On Mon, 29 Oct 2001 15:12:41 +0100, Alexander Farber (EED)
>> <eedalf@eed.ericsson.se> wrote:
>> >
>> > is there a cool way to set a hash value and simultaneously substitute
>> > some chars? I am fetching dates from Sybase and would like them to be
>> > 2001-10-29 instead of 2001/10/29 - but the following doesn't work of course:
>>
>> [snipped part of code]
>>
>> while (my $href = $sth -> fetchrow_hashref){
>> $href->{RELDATE} =~ tr#/#-#;
>> push @load, { FILEPATH => $href -> {FILEPATH},
>> ACANUMBER => $href -> {ACANUMBER},
>> REVISION => $href -> {REVISION},
>> RELDATE => $href -> {RELDATE} };
>> }
>
> Thanks, but it isn't cool.
Oh, sorry, I thought it was supposed to work, not be cool. Silly me.
Cheers,
Bernard
------------------------------
Date: Mon, 29 Oct 2001 17:19:06 +0530
From: "Al" <Al@yahoo.com>
Subject: @INC
Message-Id: <9rjfoe$gl@nntpb.cb.lucent.com>
Hi,
How do I edit the paths of @INC...
I have installed perl5.6.1 on a system under '/usr/local/perl_5.6.1' and
automounted it so that all the other systems can see it as
'/usr/local/perl'.
But when I am installing one of the sysadm tools on another system ( a
system which has perl automounted on it ) I get the following error..
pod2man --release=1.0.33 --center=rrdtool rrdtool.pod > rrdtool.1
Can't locate Getopt/Long.pm in @INC (@INC contains:
/usr/local/perl_5.6.1/lib/5.6.1/sun4-solaris-multi
/usr/local/perl_5.6.1/lib/5.6.1
/usr/local/perl_5.6.1/lib/site_perl/5.6.1/sun4-solaris-multi
/usr/local/perl_5.6.1/lib/site_perl/5.6.1
/usr/local/perl_5.6.1/lib/site_perl
/usr/local/perl_5.6.1/lib/site_perl/5.6.1/sun4-solaris-multi
/usr/local/perl_5.6.1/lib/site_perl/5.6.1 .) at /usr/local/perl/bin/pod2man
line 15.
The system is unable to locate Getopt/Long.pm cuz the path
'/usr/local/perl_5.6.1' doesn't exist on the server,
So how and where do I edit the paths for @INC.
Thanks in advance for your help.
regards
-Al
------------------------------
Date: Mon, 29 Oct 2001 13:07:20 +0100
From: Laocoon <Laocoon@eudoramail.com>
Subject: Re: @INC
Message-Id: <Xns9149857E73699Laocooneudoramailcom@62.153.159.134>
perldoc -q "include path"
------------------------------
Date: Mon, 29 Oct 2001 12:18:43 +0000
From: Simon Oliver <simon.oliver@umist.ac.uk>
To: Al <Al@yahoo.com>
Subject: Re: @INC
Message-Id: <3BDD4923.435234DC@umist.ac.uk>
perldoc -q "include path"
Al wrote:
>
> Hi,
> How do I edit the paths of @INC...
>
> I have installed perl5.6.1 on a system under '/usr/local/perl_5.6.1' and
> automounted it so that all the other systems can see it as
> '/usr/local/perl'.
>
> But when I am installing one of the sysadm tools on another system ( a
> system which has perl automounted on it ) I get the following error..
>
> pod2man --release=1.0.33 --center=rrdtool rrdtool.pod > rrdtool.1
> Can't locate Getopt/Long.pm in @INC (@INC contains:
> /usr/local/perl_5.6.1/lib/5.6.1/sun4-solaris-multi
> /usr/local/perl_5.6.1/lib/5.6.1
> /usr/local/perl_5.6.1/lib/site_perl/5.6.1/sun4-solaris-multi
> /usr/local/perl_5.6.1/lib/site_perl/5.6.1
> /usr/local/perl_5.6.1/lib/site_perl
> /usr/local/perl_5.6.1/lib/site_perl/5.6.1/sun4-solaris-multi
> /usr/local/perl_5.6.1/lib/site_perl/5.6.1 .) at /usr/local/perl/bin/pod2man
> line 15.
>
> The system is unable to locate Getopt/Long.pm cuz the path
> '/usr/local/perl_5.6.1' doesn't exist on the server,
> So how and where do I edit the paths for @INC.
> Thanks in advance for your help.
> regards
> -Al
------------------------------
Date: 29 Oct 2001 03:52:11 -0800
From: philip@ncst.ernet.in (Philip S Tellis)
Subject: Re: Any good free syntax coloring editors for Perl on Windows?
Message-Id: <d1eff1dd.0110290352.4f3e1c2b@posting.google.com>
code2html (search on freshmeat) is a good syntax highlighter, written
in perl, for a host of languages, including perl.
It doesn't `compile' perl code, only perl can compile/parse Perl.
Philip
------------------------------
Date: Mon, 29 Oct 2001 09:26:03 -0500
From: Benjamin Goldberg <goldbb2@earthlink.net>
Subject: Re: Any good free syntax coloring editors for Perl on Windows?
Message-Id: <3BDD66FB.3765FE4A@earthlink.net>
Philip S Tellis wrote:
>
> code2html (search on freshmeat) is a good syntax highlighter, written
> in perl, for a host of languages, including perl.
>
> It doesn't `compile' perl code, only perl can compile/parse Perl.
perltidy does a pretty good job of parsing Perl.
Hmm, going with the idea of perl can parse perl, how about a B::html
module, to output an htmlized version of the code?
--
Klein bottle for rent - inquire within.
------------------------------
Date: Mon, 29 Oct 2001 09:11:04 -0500
From: Benjamin Goldberg <goldbb2@earthlink.net>
Subject: Re: CGI param/regex difficulties
Message-Id: <3BDD6378.30ED5996@earthlink.net>
Paul Bruno wrote:
[snip: data is coming from a textarea, split /\n\n/ doesn't work to
split into paragraphs]
> However, when the script splits on 2 newlines, it doesn't find a
> delimiter, and puts all the data into one array element. However,
> when I changed my pattern to /\n\s*\n/, it matched my test data fine.
> But, because in my test data in the <textarea> I only typed two
> newlines, and nothing else, to separate the data, I'm not sure exactly
> why it is matching on latter pattern above, and not the former.
It's probably a CRLF problem. I would suggest that you do:
# convert all newlines, whatever they might be, to \n
$data =~ m/(\015\012|\012\015?|\015)/ && $data =~ s/$1/\n/g;
# then split on \n\n.
my @paragraphs = split /\n\n/, $data;
--
Klein bottle for rent - inquire within.
------------------------------
Date: Mon, 29 Oct 2001 15:59:56 +0000
From: Simon Oliver <simon.oliver@umist.ac.uk>
Subject: Re: CGI param/regex difficulties
Message-Id: <3BDD7CFC.AFFC1721@umist.ac.uk>
> # convert all newlines, whatever they might be, to \n
> $data =~ m/(\015\012|\012\015?|\015)/ && $data =~ s/$1/\n/g;
> # then split on \n\n.
> my @paragraphs = split /\n\n/, $data;
Am I being dumb...? Why match then subst ?
$data =~ s/\015\012|\015|\012/\n/g;
And please correct me if I'm wrong but which OS uses \012\015? As far as
I know:
Unix = \015
Win32 = \015\012
Mac = \012
And as an aside...
Under Perl qq{\n} inserts whatever the platform determines is the end of
line character (as above) but if you want to create "standard" text as
desrcibed in many RFC's then use CR/LF:
$data =~ s/\015\012|\015|\012/\015\012/g;
--
Simon Oliver
------------------------------
Date: Mon, 29 Oct 2001 16:03:36 +0000
From: Simon Oliver <simon.oliver@umist.ac.uk>
Subject: Re: CGI param/regex difficulties
Message-Id: <3BDD7DD8.2D8E7776@umist.ac.uk>
Correction...
Unix = \012
Win32 = \015\012
Mac = \015
--
Simon Oliver
------------------------------
Date: 29 Oct 2001 07:08:40 -0800
From: tushar08@yahoo.com (TD)
Subject: digital signature
Message-Id: <584a8362.0110290708.7abc27ca@posting.google.com>
Hello All,
Is there any way we can create digital signature using Perl
I am fairly new in this....
Here is what I need....
1) my current XML="<xml data....>"
2) signature = sign XML with private key using MD5 or SHA1
3) encodedsignature = base64.encode(signature)
4) publiccertificate= base64.encode(public cert)
5) now I can post data as
requestxml=XML&digitalsignature=encodedsignature&certificate=publiccertificate
Please help..if there is a better/best way than this....let me know.
T.
------------------------------
Date: Mon, 29 Oct 2001 12:07:58 +0000
From: John Imrie <johni@pa.press.net>
Subject: Re: error on host by running my script, but it works offline, why?...
Message-Id: <3BDD469E.2030908@pa.press.net>
>
> What does this mean?... Is there something wrong with my script?... ?-)
Yes there is somthing wrong with your script
This means that you have not red the FAQ that comes with Perl.
------------------------------
Date: Mon, 29 Oct 2001 09:18:08 -0500
From: Benjamin Goldberg <goldbb2@earthlink.net>
Subject: Re: File parseing and testing for existing data
Message-Id: <3BDD6520.64120B6D@earthlink.net>
Matias P. Silva wrote:
>
> sure thing, this is what a record in my file looks like....
>
> mpsilva,Matias,P,Silva,525 S. Wilson
> Ave.,Pasadena,CA,91106,USGS,mpsilva@usgs.gov,626 583 6798,Sat Oct 27
> 16:21:01 2001,
my $lookingfor = "$userid,$firstName,$midInitial,$lastName";
while( <USERFILE> ) {
next unless index($_, $lookingfor) == 0;
print;
}
--
Klein bottle for rent - inquire within.
------------------------------
Date: Mon, 29 Oct 2001 12:25:24 GMT
From: Dave Tweed <dtweed@acm.org>
Subject: Re: files in the process of being written to
Message-Id: <3BDD494C.E0F97CD2@acm.org>
Just in wrote:
> What I need to do is only FTP if the file has been completed being
> written to.
The usual way of handling this is to have the writing process on the
Unix system use a temporary filename. This can be in the same directory,
in which case, the FTP process on the Windows machine must be programmed
to ignore it, or it can be in a different directory altogether on the Unix
machine. When the writing is finished, the file is renamed by the Unix
machine to a name that the Windows machine will see and accept via FTP.
-- Dave Tweed
------------------------------
Date: Mon, 29 Oct 2001 07:20:00 -0500
From: Bernie Cosell <bernie@fantasyfarm.com>
Subject: Re: files in the process of being written
Message-Id: <uvhqtts0ihe79lhinbvijdmpqmg0f40c61@news.supernews.net>
"Just in" <justin.devanandan.allegakoen@intel.com> wrote:
} this didnt get finished, let me continue . . . (see below)
} > The files on the Unix platform are created and written
} > to at any random moment in time. As far as I can figure out
} > the program running as a scheduled task has a nasty
} > habit of FTP'ng files from the Unix workstation over to
} > the 2000 server that haven't been finished being written to
} > (on the Unix workstation).
} >
}
} What I need to do is only FTP if the file has been completed being
} written to.
Basically, in general, you can't. On Unix, there's no real _external_ way
to tell that a file is still open for writing (and certainly not from the
far side of an FTP connection). That's why when this kind of thing is an
issue, you do things like making the utility build the file under a
different name [I tend to use REALNAME~] and then when the file is
complete, do "mv REALNAME~ REALNAME", so at the moment it 'appears' with
its real/public name it is complete and ready-to-go.
Another trick I've had to do in the past is to watch the modified time
and/or file length. Given that I knew something about the application
writing the file, I just set up my prog not to mess with the file until its
length hadn't changed for a minute [checked every minute and didn't
download until two consecutive minutes got me the same length].
but none of this has much/anything to do with Perl....
/Bernie\
--
Bernie Cosell Fantasy Farm Fibers
bernie@fantasyfarm.com Pearisburg, VA
--> Too many people, too few sheep <--
------------------------------
Date: Mon, 29 Oct 2001 12:52:47 GMT
From: garry@ifr.zvolve.net (Garry Williams)
Subject: Re: files in the process of being written
Message-Id: <slrn9tqk8v.s8d.garry@zfw.zvolve.net>
On Sat, 27 Oct 2001 21:26:06 +0800, Just in
<justin.devanandan.allegakoen@intel.com> wrote:
[ snip ]
> The files on the Unix platform are created and written
> to at any random moment in time. As far as I can figure out
> the program running as a scheduled task has a nasty
> habit of FTP'ng files from the Unix workstation over to
> the 2000 server that haven't been finished being written to
> (on the Unix workstation).
>
> What I'm looking for is a way to tell
The FTP protocol cannot help you. Have the process storing the files
touch an indicator file to show it's done. Have the retrieving FTP
process delete that file when it's done.
--
Garry Williams
------------------------------
Date: Mon, 29 Oct 2001 14:51:35 GMT
From: SanHen <H.S@chello.nl>
Subject: for sale: Perl Developer's Guide, Peschko & DeWolfe,
Message-Id: <3erqttcc0nigj5b9ovs66m34rhmkl15qau@4ax.com>
Perl Developer's Guide, Peschko & DeWolfe, incl. CD, McGraw Hill,
2000, Part of ISBN 0-07-212630-2, from US$ 60 for US$20 + shipping
from the Netherlands
send email to h.s@chello.nl (replace s by sanderson)
------------------------------
Date: Mon, 29 Oct 2001 15:41:21 GMT
From: "Ted Apke" <tedapke@apkesoftware.com>
Subject: Re: https and writing files
Message-Id: <BMeD7.30096$IR4.18011349@news1.denver1.co.home.com>
Indeed, it was that simple. I thought I had the directory permissions setup
properly but, I didn't. The error reported "Permission denied", or
something equivalent. I changed the directory where the file was to be
created to 777 and gave the file write permisson to all and was in business.
Thanks.
Ted
"Mina Naguib" <spam@thecouch.homeip.net> wrote in message
news:4BlC7.22077$E03.1258446@wagner.videotron.net...
>
> "Ted Apke" <tedapke@apkesoftware.com> wrote in message
> news:3a7C7.22796$IR4.12821565@news1.denver1.co.home.com...
> > Sorry. I wish there were more details to share. The open fails. Here
is
> a
> > sample script.
> >
> > require 'ctime.pl';
> > if (!open(DEBUGLOG, '>>DebugLog.html'))
> > {
> > $DEBUG_LOG = 0;
> > } else {
> > print DEBUGLOG "===================================<br>\n";
> > print DEBUGLOG "ManRegister.pl Started at ", &ctime($^T),
"<br>\n";
> > }
> >
> > This portion of my script works fine when the cgi is accessed via http.
> If
> > https is used, the open fails, and no debug log is created/written to.
> > There are multiple (3) file writes in the script. All fail.
> >
> > Ideas?
>
> Maybe the HTTP daemon serving the secure connection runs as a different
user
> than the daemon serving the unencrypted connection, and that other user
does
> not have permissions to write to the destination file ?
>
> try this out. of the open() fails, print this:
> print "Content-type: text/html\n\nMY ERROR FOR OPEN() IS $!";
>
> See what that will show you, it could shed mroe light on the source of the
> problem.
>
> >
> > Ted
> >
> >
> > "Mina Naguib" <spam@thecouch.homeip.net> wrote in message
> > news:BQWB7.3519$cE2.162075@weber.videotron.net...
> > >
> > > "Ted Apke" <tedapke@apkesoftware.com> wrote in message
> > > news:5EVB7.20414$IR4.11759583@news1.denver1.co.home.com...
> > > > I'm having a problem writing to a file when the perl CGI script is
> > > accessed
> > > > via a secure connection. The script works fine when the connection
is
> > via
> > > > http, but when run from https it fails. I'm not 100% sure of the
host
> > > > environment but I'd say it is Solaris.
> > > >
> > > > I've done a number of searches, including Google groups, and found
> > nothing
> > > > similar. I'd appreciate any suggestions.
> > >
> > > I also got into my car a few days ago but it didn't take me to work.
Can
> > you
> > > tell me why ?
> > >
> > > Seriously, you provide no details at all. Help us out here. What
exactly
> > is
> > > the error message, if any.. ?
> > >
> > > >
> > > > Thanks in advance.
> > > >
> > > > Ted Apke
> > > >
> > > >
> > > >
> > >
> > >
> >
> >
>
>
------------------------------
Date: 29 Oct 2001 06:21:14 -0800
From: bh_ent@hotmail.com (Drew Myers)
Subject: Logic Question
Message-Id: <d1b6a249.0110290621.2256bb5@posting.google.com>
Hi,
I'm in the process of planning a perl script. I'm having trouble with
some of the logic, and I'm hoping someone here will help.
I have a list of items which may vary from 15-80 items. The number of
items in the list will not vary while the perl script is executing. I
store the items in @totest.
The difficulty I'm having, is I want to do something to all the items,
but in groups of 20. For instance, if there are 15 items in the list,
this is easy:
while (@totest) {
...something...
}
My problem is I don't know how to write the logic if there are more
than 20 items in the list.
A rough sketch of what I want to do would be:
while (@totest) {
if (scalar(@totest) <= 20) {
..do something good..
}
else {
..do something bad..
}
}
However, this doesn't "do something good" on each of the items in
groups of 20.
Any ideas?
TIA,
Drew
------------------------------
Date: Mon, 29 Oct 2001 15:30:22 +0100
From: "Alexander Farber (EED)" <eedalf@eed.ericsson.se>
Subject: Re: Logic Question
Message-Id: <3BDD67FE.9410820F@eed.ericsson.se>
Drew Myers wrote:
> The difficulty I'm having, is I want to do something to all the items,
> but in groups of 20.
Maybe [untested]:
while (@mylist = splice @totest, 0, 20)
{
... # yadda-yadda-yadda
}
------------------------------
Date: 29 Oct 2001 13:06:55 GMT
From: anno4000@lublin.zrz.tu-berlin.de (Anno Siegel)
Subject: Re: Performance gap in Benchmark.pm with/without Tk interface
Message-Id: <9rjk9f$jr4$1@mamenchi.zrz.TU-Berlin.DE>
According to Hans N. <hen20040@bestweb.net>:
> Hello all,
>
> I'm in the process of learning perl/Tk, but I thought my post would be
> more pertinent to this group. I'm messing around with creating a
> graphical interface to the Benchmark.pm module.
>
> I've gone as far as getting a working program to run a benchmark on a
> single chunk of code as well as an optional chunk to be excluded from the
> benchmark test. However, my problem is that testing the exact same piece
> of code in a script without any fancy tricks on a command line completes
> the test in a tenth of the time, if not less, compared to my Tk dabbling.
> I think I have the issue drawn down to using eval, but I wanted to
> consult the group for some well informed advice/information. Take a look
> below for the snippits of code, both are utilizing the timeit() method.
>
> I'm using $x = 3; as the optional block of code inputed by the user.
> The code to benchmark, that I'm using to test the program, is:
> $y = $x**234;
> $z = $x**$y;
> print "$z";
>
> ### Script with Tk:
> sub bench1
> {
> # Grabs user code from Tk text boxes
> $optCode = $optTxt->get("1.0", "end");
> $code1 = $codeTxt1->get("1.0", "end");
> # Runs user input code
> sub One
> {
> $stat->configure(-foreground => 'green3');
> eval($optCode); # Optional block from user
> sub Code1 {
> eval($code1); # Block to benchmark
> }
Well, yes. Code1 is a closure that will eval whatever $code1 contains
each time it is called. Since the code is compiled each time, the
execution time has little to do with what you actually want to measure.
Give only the code string to Benchmark::timethis, it knows what to
do with it.
Anno
------------------------------
Date: Mon, 29 Oct 2001 08:52:58 -0500
From: Benjamin Goldberg <goldbb2@earthlink.net>
Subject: Re: Performance gap in Benchmark.pm with/without Tk interface
Message-Id: <3BDD5F3A.D7C64B7D@earthlink.net>
Hans N. wrote:
>
> Hello all,
>
> I'm in the process of learning perl/Tk, but I thought my post
> would be more pertinent to this group. I'm messing around with
> creating a graphical interface to the Benchmark.pm module.
>
> I've gone as far as getting a working program to run a
> benchmark on a single chunk of code as well as an optional chunk to be
> excluded from the benchmark test. However, my problem is that testing
> the exact same piece of code in a script without any fancy tricks on a
> command line completes the test in a tenth of the time, if not less,
> compared to my Tk dabbling.
If you really and truly were running the *exact* same piece of code,
then you wouldn't get such a difference.
> I think I have the issue drawn down to using eval, but I wanted to
> consult the group for some well informed advice/information.
[snip]
> sub Code1 {
> eval($code1); # Block to benchmark
> }
I assume at this point, $code1 contains a string like '$x = 3' ?
[snip]
> eval($x = 3); # Simulate optional block from Tk version
First this does $x=3, then passes the result of that expression (3) to
eval... so it's rather like doing eval('3')
Which do you think should be faster, eval('$x = 3') or eval('3') ?
--
Klein bottle for rent - inquire within.
------------------------------
Date: 29 Oct 2001 04:23:34 -0800
From: philip@ncst.ernet.in (Philip S Tellis)
Subject: Re: printing html
Message-Id: <d1eff1dd.0110290423.73a45c1f@posting.google.com>
> when i try to print a webpage with my script, the quotes from the html
> errors up the program, how can i keep it from doing this?
I'd really suggest that you use a Templating solution for this.
Something like HTML::Template really helps in separating the HTML from
the perl.
------------------------------
Date: Mon, 29 Oct 2001 14:15:44 GMT
From: "M G" <perl.news@lfjr.net>
Subject: Re: regexp and printing \0,\1 etc...
Message-Id: <kwdD7.20661$CN5.1421078@typhoon.mn.mediaone.net>
In fact, I get this kind of result from a stream , and some
users are using \[0-9a-zA-Z] in their filenames.
I need to be sure that I report the exact name without
interpreting at all the sequence.
totototo\0tut
test\vtoto
etc....
(just found another case where this is not a number following the \)
G.
"Bart Lateur" <bart.lateur@skynet.be> wrote in message
news:m7bqttge0hmj5kqio7qbd69fja28n8f92f@4ax.com...
> M G wrote:
>
> >$toto="totototo\0ut";
> >
> >printf("%s\n",$toto);
> >---
> >
> >How to get the printf to output
> >
> >totototo\0ut
> >
> >and not
> >
> >totototo^@ut
> >
> >I tried to escape it with regexp (s/\\/\\\\/) but visibly didn't help
>
> Of course not. That is because the '\0' already got replaced by a null
> byte in your string. EIther you prevent that conversion, as Laocoon did,
> or you must replace the null byte back to a backslash plus an octal
> number:
>
> $toto="totototo\0ut";
> $toto =~s/([\000-\037])/sprintf "\\%03o", ord $1/ge;
> print $toto;
> ->
> totototo\000ut
>
> perhaps you like your octal code to be shorter, but that's not safe if
> the control character is followed by a digit:
>
> $_ = "\00012";
> s/([\000-\037])/sprintf "\\%o", ord $1/ge;
> print;
> ->
> \012
>
> A more elaborate substitution can deal with that:
>
> $_ = "1\0014\0028\003A";
> s/([\000-\037])(?=(\d?))/sprintf length($2)?"\\%03o":"\\%o",
> ord $1/ge;
> print;
> ->
> 1\0014\0028\3A
>
> As you can see, the 3 octal digits are compressed to a minimum only if
> the control character isn't followed by a digit. "\48" would be
> converted safely, except that perl complains if you try to eval it:
>
> print "\248";
> ->
> Illegal octal digit '8' ignored at...
> ?8
>
> --
> Bart.
------------------------------
Date: Mon, 29 Oct 2001 09:34:32 -0500
From: Benjamin Goldberg <goldbb2@earthlink.net>
Subject: Re: regexp and printing \0,\1 etc...
Message-Id: <3BDD68F8.A056F189@earthlink.net>
M G wrote:
>
> In fact, I get this kind of result from a stream , and some
> users are using \[0-9a-zA-Z] in their filenames.
> I need to be sure that I report the exact name without
> interpreting at all the sequence.
>
> totototo\0tut
> test\vtoto
Assuming that you get something such as appears above when you print the
data in your stream, then you should use 'test\vtoto' or "test\\vtoto".
Do any escaping at the point the string is created, not afterwards.
--
Klein bottle for rent - inquire within.
------------------------------
Date: Mon, 29 Oct 2001 14:35:42 GMT
From: "M G" <perl.news@lfjr.net>
Subject: Re: regexp and printing \0,\1 etc...
Message-Id: <2PdD7.20663$CN5.1421819@typhoon.mn.mediaone.net>
If I was able to generate the source, believe me, I would simply refuse the
creation of these things first
G
"Benjamin Goldberg" <goldbb2@earthlink.net> wrote in message
news:3BDD68F8.A056F189@earthlink.net...
> M G wrote:
> >
> > In fact, I get this kind of result from a stream , and some
> > users are using \[0-9a-zA-Z] in their filenames.
> > I need to be sure that I report the exact name without
> > interpreting at all the sequence.
> >
> > totototo\0tut
> > test\vtoto
>
> Assuming that you get something such as appears above when you print the
> data in your stream, then you should use 'test\vtoto' or "test\\vtoto".
>
> Do any escaping at the point the string is created, not afterwards.
>
> --
> Klein bottle for rent - inquire within.
------------------------------
Date: 29 Oct 2001 03:42:35 -0800
From: philip@ncst.ernet.in (Philip S Tellis)
Subject: Re: Regexp for email address
Message-Id: <d1eff1dd.0110290342.3254fc56@posting.google.com>
Laocoon <Laocoon@eudoramail.com> wrote in message news:<Xns91495B83CAB4DLaocooneudoramailcom@62.153.159.134>...
> *snip*
> > All I'm trying to do is to take something like the following:
> > TO=FIRST-LAST;CRCG@TESTER.COM;RWBR
> >
> > and turn it into:
> > FIRST-LAST@TESTER.COM;CRCG@TESTER.COM;RWBR@TESTER.COM
> *snip*
>
> $emails =~ s/TO=(.+)(\@\w+\.\w+)/$1/ and $a = $2;
> $emails =~ s/$_/$_$a/ for split ';',$emails;
$emails =~ s/^TO=//;
$emails = join ';', grep { !/\@/ && s/$/\@tester.com/ } split /;/, $emails
OR
$emails =~ s/^TO=//;
$emails =~ s{
(^|;)
([^;]+?)
(;|$)
} {
$2 !~ /\@/ && $2 .= "\@tester.com";
"$1$2$3";
}ex;
TIMTOWTDI
Philip
------------------------------
Date: Mon, 29 Oct 2001 13:04:08 +0100
From: Laocoon <Laocoon@eudoramail.com>
Subject: Re: Regexp for email address
Message-Id: <Xns914984F316654Laocooneudoramailcom@62.153.159.134>
philip@ncst.ernet.in (Philip S Tellis) wrote in
news:d1eff1dd.0110290342.3254fc56@posting.google.com:
> Laocoon <Laocoon@eudoramail.com> wrote in message
> news:<Xns91495B83CAB4DLaocooneudoramailcom@62.153.159.134>...
>> *snip*
>> > All I'm trying to do is to take something like the following:
>> > TO=FIRST-LAST;CRCG@TESTER.COM;RWBR
>> >
>> > and turn it into:
>> > FIRST-LAST@TESTER.COM;CRCG@TESTER.COM;RWBR@TESTER.COM
>> *snip*
>>
>> $emails =~ s/TO=(.+)(\@\w+\.\w+)/$1/ and $a = $2; $emails =~
>> s/$_/$_$a/ for split ';',$emails;
>
> $emails =~ s/^TO=//;
> $emails = join ';', grep { !/\@/ && s/$/\@tester.com/ } split /;/,
> $emails
This does not work if its a different server than tester.com.
> OR
>
> $emails =~ s/^TO=//;
> $emails =~ s{
> (^|;)
> ([^;]+?)
> (;|$)
> } {
> $2 !~ /\@/ && $2 .= "\@tester.com";
> "$1$2$3";
> }ex;
Same here.
Obtain the name before and use a variable in the regex.
>
> TIMTOWTDI
>
> Philip
Regards
Lao
------------------------------
Date: 29 Oct 2001 04:12:52 -0800
From: philip@ncst.ernet.in (Philip S Tellis)
Subject: Re: Regular expression stumps me ...
Message-Id: <d1eff1dd.0110290408.3d8892ee@posting.google.com>
> > >of any character'. Is there a dirrence btw
> > >
> > > s|^.*/$source_root/||o;
> > >
> > >and
> > >
> > > s|.*/$source_root/||o;
> > >
> > >that I'm not seeing?
> >
> > Prevention of useless backtracking in case of a failure to match. In
[snip]
>
> Unless of course perl optomizes .* at the beginning into ^.*
.* is not at the beginning. It's at the beginning of the regex only.
The regex can still match anywhere within the string, and there's no
reason for perl to optimise away from that. Such optimisations would
only break very valid regexes at other places. Remember, . doesn't
match a newline unless /s is specified.
Philip
------------------------------
Date: Mon, 29 Oct 2001 11:35:10 GMT
From: "John W. Krahn" <krahnj@acm.org>
Subject: Re: selecting lines for single spacing
Message-Id: <3BDD3F95.86B57857@acm.org>
hugo wrote:
>
> I have a double-spaced input file and I would like to give
> the user the option to
> bundle several lines together single-spaced. For example,
> if you have the lines:
>
> some text here
>
> Subsequently here is some text
>
> which is now double spaced
>
> and should be single spaced.
>
> and some more text here
>
> I would like to give the reader the option to put in a keyword, which in
> this case would be "Subsequently" and a number of lines, say 3. This
> would bundle
> 3 lines single spaced so that we end up with:
>
> some text here
>
> Subsequently here is some text
> which is now double spaced
> and should be single spaced.
>
> and some more text here
>
> I would like the user to be able to repeat this process for several
> keywords and number of lines.
> At the end I would like to have an output file, with all specified lines
> now single-spaced and the remainder double-spaced.
>
> I have tried to get this to work, but I am afraid I am getting rather
> seriously stuck.
>
> Can anyone help me with this?
>
> Any help, particularly a code example, will be greatly appreciated.
Here is one way to do it:
#!/usr/bin/perl -w
use strict;
@ARGV > 2 or die "usage: $0 keyword lines file1 file2 ... filen\n";
my $keyword = shift;
my $lines = ( (shift) - 1 ) * 2;
my $count;
while ( <> ) {
if ( /$keyword/ .. (++$count == $lines) ) {
print if /\S/;
}
else {
print;
}
}
__END__
John
--
use Perl;
program
fulfillment
------------------------------
Date: Mon, 29 Oct 2001 13:34:28 GMT
From: "Nik" <L.N.Jewell@remove_this.leeds.ac.uk>
Subject: Sorting SGML
Message-Id: <pan.2001.10.29.13.34.28.470.20404@remove_this.leeds.ac.uk>
Hi
I'm looking for a way to efficiently sort some SGML records. An example
would be the following (there are around 5000):
<ENTRY>
<PERSNAME ID="PierreAbailard">Abailard, Pierre
<GENDER>M</GENDER>
<PERSDATE FROM="1079" TO="1142">1079–1142</PERSDATE>
<SOURCE><BIBL INDEX="DSB"><I>DSB</I></BIBL></SOURCE>
</PERSNAME>
</ENTRY>
<ENTRY>
<PERSNAME ID="HenryLAbbot">Abbot, Henry Larcom
<GENDER>M</GENDER>
<PERSDATE FROM="1831" TO="1927">1831–1927</PERSDATE>
<SOURCE><BIBL INDEX="WBI"><I>WBI</I></BIBL></SOURCE>
</PERSNAME>
</ENTRY>
What I need to do is sort them on the Surname in the PERSNAME ID.
I'm no perl expert (as you'll be able to tell in a moment) and I am not sure of
the most efficient way to do this. One idea I had was to concatenate
each record into a single line with separators, use regexps to extract the names
and make them keys for the records in a hash, and sort the keys, and then
outputting them again.
Is this the most efficient strategy? I'm not looking for code., just strategic
suggestions.
Thanks
Nik
------------------------------
Date: Mon, 29 Oct 2001 13:49:42 +0000
From: Simon Oliver <simon.oliver@umist.ac.uk>
To: Nik <L.N.Jewell@remove_this.leeds.ac.uk>
Subject: Re: Sorting SGML
Message-Id: <3BDD5E76.1326A67F@umist.ac.uk>
There are probably better ways but how about using a Query langauge?
You could make the SGML look like XML by enclosing the records in a
single tag like so:
<SGML>
...
</SGML>
Then use something like XML::QL
or via DBI + DBD::AnyData import as XML and use SQL SELECT statements?
--
Simon Oliver
------------------------------
Date: Mon, 29 Oct 2001 13:50:00 +0000
From: Simon Oliver <simon.oliver@umist.ac.uk>
To: Nik <L.N.Jewell@leeds.ac.uk>
Subject: Re: Sorting SGML
Message-Id: <3BDD5E88.43B5B9AA@umist.ac.uk>
There are probably better ways but how about using a Query langauge?
You could make the SGML look like XML by enclosing the records in a
single tag like so:
<SGML>
...
</SGML>
Then use something like XML::QL
or via DBI + DBD::AnyData import as XML and use SQL SELECT statements?
--
Simon Oliver
------------------------------
Date: Mon, 29 Oct 2001 15:51:44 GMT
From: tadmc@augustmail.com (Tad McClellan)
Subject: Re: Sorting SGML
Message-Id: <slrn9tqrm0.njd.tadmc@tadmc26.august.net>
Nik <L.N.Jewell@remove_this.leeds.ac.uk> wrote:
>
>I'm looking for a way to efficiently sort some SGML records. An example
>would be the following (there are around 5000):
>
><ENTRY>
><PERSNAME ID="PierreAbailard">Abailard, Pierre
><GENDER>M</GENDER>
><PERSDATE FROM="1079" TO="1142">1079–1142</PERSDATE>
><SOURCE><BIBL INDEX="DSB"><I>DSB</I></BIBL></SOURCE>
></PERSNAME>
></ENTRY>
>
><ENTRY>
><PERSNAME ID="HenryLAbbot">Abbot, Henry Larcom
><GENDER>M</GENDER>
><PERSDATE FROM="1831" TO="1927">1831–1927</PERSDATE>
><SOURCE><BIBL INDEX="WBI"><I>WBI</I></BIBL></SOURCE>
></PERSNAME>
></ENTRY>
>
>What I need to do is sort them on the Surname in the PERSNAME ID.
>
>One idea I had was to concatenate
>each record into a single line with separators,
You don't need to do that part. You can deal with them as multiple
lines just fine (if the data is really formatted as you have shown it).
>use regexps to extract the names
^^^^^^^^^^^^^^^^^^^^^^
Oh. You don't want to Do It Right. You want a dirty hack. That
might be possible.
The Right Way to process SGML is with a module that does a real
parse of the SGML.
But if you are _certain_ that the elements ("records") are always
formatted prettily like you have shown above, then you can
probably just set $/ = "</ENTRY>\n\n" to read a "record at a time".
>and make them keys for the records in a hash, and sort the keys, and then
>outputting them again.
>
>Is this the most efficient strategy?
^^^^^^^^^^^^^^
You have not said what it is that you are aiming to optimize,
so we cannot really answer the question.
Since there is such a small number of elements, I'll assume you
want to optimize programmer labor rather than execution speed.
Yes, using a hash would be a straightforward way of coding up
what you need done.
>I'm not looking for code., just strategic
>suggestions.
If you need to parse "arbitrary SGML", then you must use a
Real Parser.
If you decide to risk the dirty hack approach, then:
1) parse the data
2) do the hack
3) parse the data again
and realize that it may still be broken...
--
Tad McClellan SGML consulting
tadmc@augustmail.com Perl programming
Fort Worth, Texas
------------------------------
Date: Mon, 29 Oct 2001 11:57:36 +0000
From: John Imrie <johni@pa.press.net>
Subject: Re: Stripping Duplicates From Arrays
Message-Id: <3BDD4430.8050405@pa.press.net>
Miguel Manso wrote:
> my @array = (qw/1 1 1 2 3 4 5 5 5 6 7/);
> my %hash;
> @array = @hash{@array}=();
>
That looked quite cool. Pitty it don't work.
------------------------------
Date: Mon, 29 Oct 2001 15:21:04 +0000
From: "Miguel Manso" <mmanso@yahoo.com>
Subject: Re: Stripping Duplicates From Arrays
Message-Id: <pan.2001.10.29.15.21.04.449.14129@yahoo.com>
My mistake... that's the problem of writing code without trying it :)
Here's the correct one:
my @array = (qw/1 1 1 2 3 4 5 5 5 6 7/);
my %hash;
@hash{@array}=();
@array = keys %hash;
In article <3BDD4430.8050405@pa.press.net>, "John Imrie"
<johni@pa.press.net> wrote:
> Miguel Manso wrote:
>
>> my @array = (qw/1 1 1 2 3 4 5 5 5 6 7/); my %hash;
>> @array = @hash{@array}=();
>>
>>
> That looked quite cool. Pitty it don't work.
--
Miguel Manso - <mmanso@prodigio.com>
Departamento Técnico
Prodigio - Produções Digitais Online, S.A.
Tel: +351 22 0106000 - Fax: +351 22 0106001
------------------------------
Date: Mon, 29 Oct 2001 07:25:00 -0800
From: "Jürgen Exner" <jurgenex@hotmail.com>
Subject: Re: Stripping Duplicates From Arrays
Message-Id: <3bdd74d3@news.microsoft.com>
"John Imrie" <johni@pa.press.net> wrote in message
news:3BDD4430.8050405@pa.press.net...
> That looked quite cool. Pitty it don't work.
Did you check the FAQ?
It describes 5 (in words: five) different ways to do remove duplicates from
an array.
Does none of those work for you?
jue
------------------------------
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 2030
***************************************