[28033] in Perl-Users-Digest
Perl-Users Digest, Issue: 9397 Volume: 10
daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Wed Jun 28 06:05:50 2006
Date: Wed, 28 Jun 2006 03:05:04 -0700 (PDT)
From: Perl-Users Digest <Perl-Users-Request@ruby.OCE.ORST.EDU>
To: Perl-Users@ruby.OCE.ORST.EDU (Perl-Users Digest)
Perl-Users Digest Wed, 28 Jun 2006 Volume: 10 Number: 9397
Today's topics:
Re: crash on fork in taint mode <ynleder@nspark.org>
Re: languages with full unicode support <timr@probo.com>
Re: languages with full unicode support <jo@durchholz.org>
new CPAN modules on Wed Jun 28 2006 (Randal Schwartz)
Re: Problem with Multi- threaded Server <janicehwang1325@yahoo.com>
Scalable method for searching in relatively big files <kaz219@gawab.com>
Re: Scalable method for searching in relatively big fil <David.Squire@no.spam.from.here.au>
Re: Scalable method for searching in relatively big fil <no@email.com>
Re: Scalable method for searching in relatively big fil <kaz219@gawab.com>
Re: Scalable method for searching in relatively big fil <kaz219@gawab.com>
Re: Scalable method for searching in relatively big fil <David.Squire@no.spam.from.here.au>
Re: Scalable method for searching in relatively big fil <kaz219@gawab.com>
Re: Scalable method for searching in relatively big fil <kaz219@gawab.com>
Re: Scalable method for searching in relatively big fil <David.Squire@no.spam.from.here.au>
Re: Scalable method for searching in relatively big fil <David.Squire@no.spam.from.here.au>
Single-liner for one-line substitute? <mwp@nospam.com>
Re: Single-liner for one-line substitute? anno4000@zrz.tu-berlin.de
Re: What is Expressiveness in a Computer Language [corr <rossberg@ps.uni-sb.de>
Re: What is Expressiveness in a Computer Language <jo@durchholz.org>
Digest Administrivia (Last modified: 6 Apr 01) (Perl-Users-Digest Admin)
----------------------------------------------------------------------
Date: Wed, 28 Jun 2006 11:48:40 +0200
From: Yohan N. Leder <ynleder@nspark.org>
Subject: Re: crash on fork in taint mode
Message-Id: <MPG.1f0c6ededfb935c09898ac@news.tiscali.fr>
In article <1151443070.093979.120750@y41g2000cwy.googlegroups.com>,
nobull67@gmail.com says...
>
> Yohan N. Leder wrote:
> > Hello. I'm using ActivePerl 5.8.8 build 817 and Apache2 for Windows. The
> > script below crashes on fork() when I run it in taint mode (not if I
> > remove -T).
>
> > Did you seen something like this ?
>
> Yes,
>
> http://groups.google.com/groups/search?q=fork+taint
>
>
So, what's the workaround ?
------------------------------
Date: Wed, 28 Jun 2006 07:24:48 GMT
From: Tim Roberts <timr@probo.com>
Subject: Re: languages with full unicode support
Message-Id: <lib4a299f2oo11gl62fivn1tijdk73o5ip@4ax.com>
"Xah Lee" <xah@xahlee.org> wrote:
>Languages with Full Unicode Support
>
>As far as i know, Java and JavaScript are languages with full, complete
>unicode support. That is, they allow names to be defined using unicode.
>(the JavaScript engine used by FireFox support this)
>
>As far as i know, here's few other lang's status:
>
>C ? No.
This is implementation-defined in C. A compiler is allowed to accept
variable names with alphabetic Unicode characters outside of ASCII.
--
- Tim Roberts, timr@probo.com
Providenza & Boekelheide, Inc.
------------------------------
Date: Wed, 28 Jun 2006 11:39:16 +0200
From: Joachim Durchholz <jo@durchholz.org>
Subject: Re: languages with full unicode support
Message-Id: <e7tj0t$n9i$2@online.de>
Tim Roberts schrieb:
> "Xah Lee" <xah@xahlee.org> wrote:
>> C ? No.
>
> This is implementation-defined in C. A compiler is allowed to accept
> variable names with alphabetic Unicode characters outside of ASCII.
Hmm... that could would be nonportable, so C support for Unicode is
half-baked at best.
Regards,
Jo
------------------------------
Date: Wed, 28 Jun 2006 04:42:07 GMT
From: merlyn@stonehenge.com (Randal Schwartz)
Subject: new CPAN modules on Wed Jun 28 2006
Message-Id: <J1Jzq7.Bx8@zorch.sf-bay.org>
The following modules have recently been added to or updated in the
Comprehensive Perl Archive Network (CPAN). You can install them using the
instructions in the 'perlmodinstall' page included with your Perl
distribution.
Apache2-ModBT-0.018
http://search.cpan.org/~crakrjack/Apache2-ModBT-0.018/
mod_perl interface to mod_bt
----
Best-0.02
http://search.cpan.org/~gaal/Best-0.02/
Fallbackable module loader
----
Best-0.03
http://search.cpan.org/~gaal/Best-0.03/
Fallbackable module loader
----
Best-0.04
http://search.cpan.org/~gaal/Best-0.04/
Fallbackable module loader
----
Bundle-Pugs-SmokeKit-0.05
http://search.cpan.org/~gaal/Bundle-Pugs-SmokeKit-0.05/
Bundle for running Pugs smoke tests
----
CGI-Application-Dispatch-2.00_06
http://search.cpan.org/~wonko/CGI-Application-Dispatch-2.00_06/
Dispatch requests to CGI::Application based objects
----
CGI-Utils-0.09
http://search.cpan.org/~dowens/CGI-Utils-0.09/
Utilities for retrieving information through the Common Gateway Interface
----
Cache-Repository-0.04
http://search.cpan.org/~dmcbride/Cache-Repository-0.04/
Generic repository of files
----
Catalyst-Plugin-AtomServer-0.04
http://search.cpan.org/~btrott/Catalyst-Plugin-AtomServer-0.04/
Atom API server for Catalyst applications
----
Catalyst-Runtime-5.70_02
http://search.cpan.org/~mramberg/Catalyst-Runtime-5.70_02/
Catalyst Runtime version
----
Deco-0.04
http://search.cpan.org/~narked/Deco-0.04/
Module for simulating body tissue during a scuba dive
----
Finance-Bank-IE-0.07
http://search.cpan.org/~waider/Finance-Bank-IE-0.07/
----
Games-Othello-0.01
http://search.cpan.org/~dwright/Games-Othello-0.01/
Perl extension for modelling a game of Othello.
----
IO-Socket-TIPC-1.05
http://search.cpan.org/~infinoid/IO-Socket-TIPC-1.05/
TIPC sockets for Perl
----
JavaScript-XRay-1.02
http://search.cpan.org/~jbisbee/JavaScript-XRay-1.02/
See What JavaScript is Doing
----
Language-BF-0.01
http://search.cpan.org/~dankogai/Language-BF-0.01/
BF virtual macine in perl
----
Language-BF-0.02
http://search.cpan.org/~dankogai/Language-BF-0.02/
BF virtual macine in perl
----
Module-Dependency-1.82
http://search.cpan.org/~timb/Module-Dependency-1.82/
Collection of modules for examining dependencies between parents and children, like Perl files
----
Module-Dependency-1.83
http://search.cpan.org/~timb/Module-Dependency-1.83/
Collection of modules for examining dependencies between parents and children, like Perl files
----
Net-BitTorrent-LibBT-Tracker-0.018
http://search.cpan.org/~crakrjack/Net-BitTorrent-LibBT-Tracker-0.018/
Access a tracker running under libbttracker
----
Net-DNS-ToolKit-0.28
http://search.cpan.org/~miker/Net-DNS-ToolKit-0.28/
tools for working with DNS packets
----
Net-OpenID-JanRain-1.1.1
http://search.cpan.org/~arnesond/Net-OpenID-JanRain-1.1.1/
----
News-Article-NoCeM-0.08
http://search.cpan.org/~leeym/News-Article-NoCeM-0.08/
a module to generate accurate nocem notices
----
Object-InsideOut-1.45
http://search.cpan.org/~jdhedden/Object-InsideOut-1.45/
Comprehensive inside-out object support module
----
Search-Estraier-0.07_2
http://search.cpan.org/~dpavlin/Search-Estraier-0.07_2/
pure perl module to use Hyper Estraier search engine
----
Sub-Exporter-0.970
http://search.cpan.org/~rjbs/Sub-Exporter-0.970/
a sophisticated exporter for custom-built routines
----
WWW-Mediawiki-Client-0.29
http://search.cpan.org/~markj/WWW-Mediawiki-Client-0.29/
----
WWW-Search-Rambler-0.03
http://search.cpan.org/~arto/WWW-Search-Rambler-0.03/
class for searching http://www.rambler.ru.
----
WWW-Search-Yandex-0.05
http://search.cpan.org/~arto/WWW-Search-Yandex-0.05/
class for searching http://www.yandex.ru.
----
WWW-TV-0.01
http://search.cpan.org/~tigris/WWW-TV-0.01/
Parse TV.com for information about TV shows.
----
Win32-Security-EFS-0.05
http://search.cpan.org/~esskar/Win32-Security-EFS-0.05/
Perl interface to functions that assist in working with EFS (Encrypted File System) under Windows plattforms.
If you're an author of one of these modules, please submit a detailed
announcement to comp.lang.perl.announce, and we'll pass it along.
This message was generated by a Perl program described in my Linux
Magazine column, which can be found on-line (along with more than
200 other freely available past column articles) at
http://www.stonehenge.com/merlyn/LinuxMag/col82.html
print "Just another Perl hacker," # the original
--
Randal L. Schwartz - Stonehenge Consulting Services, Inc. - +1 503 777 0095
<merlyn@stonehenge.com> <URL:http://www.stonehenge.com/merlyn/>
Perl/Unix/security consulting, Technical writing, Comedy, etc. etc.
See PerlTraining.Stonehenge.com for onsite and open-enrollment Perl training!
------------------------------
Date: 27 Jun 2006 23:50:01 -0700
From: "janicehwang1325@yahoo.com" <janicehwang1325@yahoo.com>
Subject: Re: Problem with Multi- threaded Server
Message-Id: <1151477401.315395.83190@j72g2000cwa.googlegroups.com>
Here is my testing result today:
- Running on Perl version 5.8.6 on another machine is also having same
segfault problem. I really don't know why another machine can run while
the other can't. any idea?
janicehwang1325@yahoo.com wrote:
> Maybe you can try run the program usign PERL 5.8.6 version. I am still
> testing if the segfault problem have something to do with the version
> of the PERL.
>
> xhoster@gmail.com wrote:
> > "janicehwang1325@yahoo.com" <janicehwang1325@yahoo.com> wrote:
> > > Ya, I miss that part and I amend my program by putting the close with
> > > SSL_no_shutdown. However, this only help when the client program ends
> > > the connection and the server program would not hang. It does not
> > > actually solve the segmentation fault problem.
> >
> > The SSLeay module seems to be fundamentally unsafe for threads. I tried a
> > few things to hack it with CLONED, etc. but haven't been able to. The mere
> > existence of a thread is enough to trigger the problem, the thread doesn't
> > need to do anything with the socket at all. By changing the "close"
> > parameters, I could make it segfault either ealier (upon the initial close)
> > or later (half way through the 2nd accept) but couldn't get rid of it
> > altogether.
> >
> >
> > __SERVER__
> > use threads;
> > use POSIX ":sys_wait_h";
> > use IO::Socket::SSL qw(debug4);
> > use IO::Handle;
> > use strict;
> >
> > my ($sock);
> >
> > unless (@ARGV == 1) { die "usage: perl $0 <Port Number>" };
> > my ($port) = @ARGV;
> >
> > if(!($sock = IO::Socket::SSL->new( Listen => 20, LocalPort => $port,
> > Proto => 'tcp', ReuseAddr => 1,
> > SSL_key_file => 'certs/newkey.pem',
> > SSL_cert_file => 'certs/newcert.pem',
> > )) ) {
> > warn "unable to create socket: ", &IO::Socket::SSL::errstr, "\n";
> > exit(0);
> >
> > }
> >
> > warn "SSL socket created: $sock.\n";
> > while(1){
> >
> > while((my $s = $sock->accept())) {
> > warn "I accepted $s";
> > print "new thread here .. \n";
> > my $thread = threads->create(sub {sleep 5});
> > $thread->join;
> > warn "joined";
> > $s->close(SSL_no_shutdown => 1);
> > }
> > }
> >
> >
> > __CLIENT__
> > #!/usr/bin/perl
> >
> > use POSIX ":sys_wait_h";
> > use IO::Socket::SSL;
> > use IO::Handle;
> > use strict;
> > use warnings;
> >
> > unless (@ARGV == 1) { die "usage: perl $0 <Port Number>" };
> > my ($port) = @ARGV;
> > my $sock = IO::Socket::SSL->new("localhost:$port") or die "$! $@ ",
> > &IO::Socket::SSL::errstr; use Data::Dumper;
> > warn "SSL socket created: $sock.\n";
> > warn Dumper $sock;
> >
> > print $sock "asldfjalsdjfsadlfj\n";
> > __END__
> >
> > --
> > -------------------- http://NewsReader.Com/ --------------------
> > Usenet Newsgroup Service $9.95/Month 30GB
------------------------------
Date: 28 Jun 2006 01:26:07 -0700
From: "KaZ" <kaz219@gawab.com>
Subject: Scalable method for searching in relatively big files
Message-Id: <1151483167.738770.268100@p79g2000cwp.googlegroups.com>
Hi,
I want to do this:
I have a file A (the file size can be up to around 40MB, I know it
isn't that big), and I have to read it one line after the other (I use
a while loop for this), and possibly print something into file B,
depending on what is in the line. In each iteration, I have to search
the file A for pattern and the file B to check what has been already
written in it.
Right now, I made the searches with arrays and grep. I put the whole
file A in an array (array @a), file B is an empty array (array @b) at
the beginning, and at the end I write the array @b into file B. I read
directly in the file A each line for the while loop, because I feared
it would interfer with the search if I used the array @a for the while
loop also.
The file A is for the moment only 4MB, and the script take 10 minutes
to complete. So it isn't a scalable solution in my opinion.
I was told to use database or possibly tied hashes, in order to get
more scalability.
Can anybody tell me a bit more about this two methods? I read what a
hash is, but fail to see how it could help me.
Greetings,
------------------------------
Date: Wed, 28 Jun 2006 09:31:27 +0100
From: David Squire <David.Squire@no.spam.from.here.au>
Subject: Re: Scalable method for searching in relatively big files
Message-Id: <e7teov$r7s$1@news.ox.ac.uk>
KaZ wrote:
> Hi,
>
> I want to do this:
>
> I have a file A (the file size can be up to around 40MB, I know it
> isn't that big), and I have to read it one line after the other (I use
> a while loop for this), and possibly print something into file B,
> depending on what is in the line. In each iteration, I have to search
> the file A for pattern and the file B to check what has been already
> written in it.
>
> Right now, I made the searches with arrays and grep. I put the whole
> file A in an array (array @a), file B is an empty array (array @b) at
> the beginning, and at the end I write the array @b into file B. I read
> directly in the file A each line for the while loop, because I feared
> it would interfer with the search if I used the array @a for the while
> loop also.
>
> The file A is for the moment only 4MB, and the script take 10 minutes
> to complete. So it isn't a scalable solution in my opinion.
>
> I was told to use database or possibly tied hashes, in order to get
> more scalability.
>
> Can anybody tell me a bit more about this two methods? I read what a
> hash is, but fail to see how it could help me.
Show us your script, and someone here will be able to help. Without
knowing exactly what kind of search (exact match? regex? whole line?)
you are doing, it is impossible to recommend much.
DS
------------------------------
Date: Wed, 28 Jun 2006 09:41:16 +0100
From: Brian Wakem <no@email.com>
Subject: Re: Scalable method for searching in relatively big files
Message-Id: <4getlcF1ngfqlU1@individual.net>
KaZ wrote:
> Hi,
>
> I want to do this:
>
> I have a file A (the file size can be up to around 40MB, I know it
> isn't that big), and I have to read it one line after the other (I use
> a while loop for this), and possibly print something into file B,
> depending on what is in the line. In each iteration, I have to search
> the file A for pattern and the file B to check what has been already
> written in it.
>
> Right now, I made the searches with arrays and grep. I put the whole
> file A in an array (array @a), file B is an empty array (array @b) at
> the beginning, and at the end I write the array @b into file B. I read
> directly in the file A each line for the while loop, because I feared
> it would interfer with the search if I used the array @a for the while
> loop also.
>
> The file A is for the moment only 4MB, and the script take 10 minutes
> to complete. So it isn't a scalable solution in my opinion.
>
> I was told to use database or possibly tied hashes, in order to get
> more scalability.
>
> Can anybody tell me a bit more about this two methods? I read what a
> hash is, but fail to see how it could help me.
>
> Greetings,
As David has said, you need to show us some code.
Usually replacing regexs with index (where it can be used) will give a big
performance increase. I doubt it needs to take 10 minutes, or even 10
seconds.
--
Brian Wakem
Email: http://homepage.ntlworld.com/b.wakem/myemail.png
------------------------------
Date: 28 Jun 2006 01:59:27 -0700
From: "KaZ" <kaz219@gawab.com>
Subject: Re: Scalable method for searching in relatively big files
Message-Id: <1151485167.040655.141270@75g2000cwc.googlegroups.com>
David Squire wrote:
> Show us your script, and someone here will be able to help. Without
> knowing exactly what kind of search (exact match? regex? whole line?)
> you are doing, it is impossible to recommend much.
>
>
> DS
Hi,
it looks like this:
--------------------------------------------------------------------------------------------------------
open (FILEA, '<', "./filea.txt")
while (defined($line = <FILEA>)) {
@line = split '\t', $line;
$var0 = @line[0];
.....
$var7 = @line[7];
$nb = @line[8];
if ( $var3 eq "blah") {
if ((not grep { /string=$nb;/ } @b) && (not grep { /\t$nb\t/ } @a))
{
push @b, "blah blah blah string=$nb\n";
}
}
elsif ( $var3 eq "other") {
# something similar to the preceding if....
}
elsif ($var6 eq "something") {
# something similar to preceding elsif ....
}
}
open (FILEB, '>', "./path-to-the-file.txt') or die "Can't open
path-to-the-file: $!";
print FILEB @b;
close FILEB;
--------------------------------------------------------------------------------------------------------
I hope it is enough. I can post the complete script, but I have to
"anonymize" it a bit before, I'm sorry.
Thanks for the answer,
kaz
------------------------------
Date: 28 Jun 2006 02:08:45 -0700
From: "KaZ" <kaz219@gawab.com>
Subject: Re: Scalable method for searching in relatively big files
Message-Id: <1151485725.758129.195720@d56g2000cwd.googlegroups.com>
KaZ wrote:
> David Squire wrote:
> > Show us your script, and someone here will be able to help. Without
> > knowing exactly what kind of search (exact match? regex? whole line?)
> > you are doing, it is impossible to recommend much.
> >
> >
> > DS
>
> Hi,
>
> it looks like this:
>
> --------------------------------------------------------------------------------------------------------
> open (FILEA, '<', "./filea.txt")
>
> while (defined($line = <FILEA>)) {
> @line = split '\t', $line;
> $var0 = @line[0];
> .....
> $var7 = @line[7];
> $nb = @line[8];
>
> if ( $var3 eq "blah") {
> if ((not grep { /string=$nb;/ } @b) && (not grep { /\t$nb\t/ } @a))
> {
> push @b, "blah blah blah string=$nb\n";
> }
> }
> elsif ( $var3 eq "other") {
> # something similar to the preceding if....
> }
> elsif ($var6 eq "something") {
> # something similar to preceding elsif ....
> }
>
> }
>
> open (FILEB, '>', "./path-to-the-file.txt') or die "Can't open
> path-to-the-file: $!";
> print FILEB @b;
> close FILEB;
> --------------------------------------------------------------------------------------------------------
>
> I hope it is enough. I can post the complete script, but I have to
> "anonymize" it a bit before, I'm sorry.
>
> Thanks for the answer,
> kaz
Sorry, I made a mistake:
each "if ($var eq "some_string")" is to be replaced by a sub which
search in an excel list, of about 400 rows, using
Spreadsheet::ParseExcel.
I already used this sub in other scripts, and it was slow but still
below 1 minute, so I thought, it was not the reason for the slowness
here. But if you think perl is able to process such a script much
faster normally, then I have to make a text version of it.
------------------------------
Date: Wed, 28 Jun 2006 10:16:39 +0100
From: David Squire <David.Squire@no.spam.from.here.au>
Subject: Re: Scalable method for searching in relatively big files
Message-Id: <e7thdn$s6k$1@news.ox.ac.uk>
KaZ wrote:
> David Squire wrote:
>> Show us your script, and someone here will be able to help. Without
>> knowing exactly what kind of search (exact match? regex? whole line?)
>> you are doing, it is impossible to recommend much.
>>
>>
>> DS
>
> Hi,
>
> it looks like this:
>
> --------------------------------------------------------------------------------------------------------
> open (FILEA, '<', "./filea.txt")
Thanks for trying, but if you really want help here, you need to follow
the posting guidelines, and post a small but *complete* script. This is
not a complete script. Where does @a get its values, for example?
Also, you are unlikely to get help until you post something the reports
no problems when both 'use strict' and 'use warnings' are in place.
Still, I am feeling generous this morning...
>
> while (defined($line = <FILEA>)) {
while (my $line = <FILEA>) {
> @line = split '\t', $line;
> $var0 = @line[0];
> .....
> $var7 = @line[7];
> $nb = @line[8];
my ($var0, ..., $var7, $nb) = split /\t/, $line; # what happens if the
number of fields is wrong?
>
> if ( $var3 eq "blah") {
> if ((not grep { /string=$nb;/ } @b) && (not grep { /\t$nb\t/ } @a))
index would be faster than regexes here, but I strongly suspect that
hashes would be even better... but we don't know what @a is...
I am thinking along the lines of:
my %OutLinesHash; # replacing your @b
...
# in loop
$OutLinesHash{$nb} = "blah blah blah string=$nb\n";
Then you can replace your grep with "if (exists $OutLinesHash{$nb})". I
can't tell about @a, as you haven't told us about it.
If you need to write out the contents of %OutLinesHash in the order you
read them, you can maintain a parallel list of keys, e.g.
my %OutLinesHash; # replacing your @b
my @KeysInOrder;
...
# in loop
if (! exists $OutLinesHash{$nb}) {
$OutLinesHash{$nb} = "blah blah blah string=$nb\n";
push @KeysInOrder, $nb;
}
# to write it out
foreach my $Key (@KeysInOrder) {
print SOMEWHERE $OutLinesHash{$nb};
}
HTH
DS
> {
> push @b, "blah blah blah string=$nb\n";
> }
> }
> elsif ( $var3 eq "other") {
> # something similar to the preceding if....
> }
> elsif ($var6 eq "something") {
> # something similar to preceding elsif ....
> }
>
> }
>
> open (FILEB, '>', "./path-to-the-file.txt') or die "Can't open
> path-to-the-file: $!";
> print FILEB @b;
> close FILEB;
> --------------------------------------------------------------------------------------------------------
>
> I hope it is enough. I can post the complete script, but I have to
> "anonymize" it a bit before, I'm sorry.
>
> Thanks for the answer,
> kaz
>
------------------------------
Date: 28 Jun 2006 02:48:18 -0700
From: "KaZ" <kaz219@gawab.com>
Subject: Re: Scalable method for searching in relatively big files
Message-Id: <1151488098.062999.141710@x69g2000cwx.googlegroups.com>
Thanks for the help, I understood the way I can use the hash.
Regards,
------------------------------
Date: 28 Jun 2006 02:48:30 -0700
From: "KaZ" <kaz219@gawab.com>
Subject: Re: Scalable method for searching in relatively big files
Message-Id: <1151488110.209237.93630@m73g2000cwd.googlegroups.com>
Thanks for the help, I understood the way I can use the hash.
Regards,
------------------------------
Date: Wed, 28 Jun 2006 10:52:23 +0100
From: David Squire <David.Squire@no.spam.from.here.au>
Subject: Re: Scalable method for searching in relatively big files
Message-Id: <e7tjgn$sv5$1@news.ox.ac.uk>
KaZ wrote:
> Thanks for the help
Thank who for what? Please quote context, retaining attributions, when
you reply.
Please read the posting guidelines, posted here several times a week,
and start following them if you wish to continue to receive help from
this group.
DS
------------------------------
Date: Wed, 28 Jun 2006 10:55:46 +0100
From: David Squire <David.Squire@no.spam.from.here.au>
Subject: Re: Scalable method for searching in relatively big files
Message-Id: <e7tjn2$sv5$2@news.ox.ac.uk>
David Squire wrote:
[snip]
>
> # to write it out
> foreach my $Key (@KeysInOrder) {
> print SOMEWHERE $OutLinesHash{$nb};
> }
>
Whoops. That should be:
# to write it out
foreach my $Key (@KeysInOrder) {
print SOMEWHERE $OutLinesHash{$Key};
}
------------------------------
Date: Wed, 28 Jun 2006 10:38:21 +0100
From: Mike Pearson <mwp@nospam.com>
Subject: Single-liner for one-line substitute?
Message-Id: <26j4a297v2tjn6qn8avpn5k1vkbe40jpnl@4ax.com>
Hi -
I know almost no Perl at all, but I occasionally use
perl -pi -e 's/old/new/g' file
for a global search/replace in a file. I've tried to modify this to
change only a string on the first line of a file, leaving the string
unchanged elsewhere in the file, but I haven't been able to find a way
to do this. Simply removing the 'g' has no effect - it still does a
global replace.
Can anyone tell me how to do this?
Thanks -
Mike
------------------------------
Date: 28 Jun 2006 09:54:51 GMT
From: anno4000@zrz.tu-berlin.de
Subject: Re: Single-liner for one-line substitute?
Message-Id: <4gf1vbF1msduhU1@news.dfncis.de>
Mike Pearson <mwp@nospam.com> wrote in comp.lang.perl.misc:
> Hi -
>
> I know almost no Perl at all, but I occasionally use
>
> perl -pi -e 's/old/new/g' file
>
> for a global search/replace in a file. I've tried to modify this to
> change only a string on the first line of a file, leaving the string
> unchanged elsewhere in the file, but I haven't been able to find a way
> to do this. Simply removing the 'g' has no effect - it still does a
> global replace.
The match operator is applied to every line in the file. The /g
modifier changes the behavior of each application. It does not
work across applications.
Here is one way:
perl -pi -e '$. == 1 && s/old/new/g' file
Anno
------------------------------
Date: Wed, 28 Jun 2006 11:56:39 +0200
From: Andreas Rossberg <rossberg@ps.uni-sb.de>
Subject: Re: What is Expressiveness in a Computer Language [correction]
Message-Id: <e7tjon$9a1av$1@hades.rz.uni-saarland.de>
David Hopwood wrote:
>>
>>>(defun blackhole (argument)
>>> (declare (ignore argument))
>>> #'blackhole)
> I believe this example requires recursive types. It can also be expressed
> in a gradual typing system, but possibly only using an unknown ('?') type.
>
> ISTR that O'Caml at one point (before version 1.06) supported general
> recursive types, although I don't know whether it would have supported
> this particular example.
No problem at all. It still is possible today if you really want:
~/> ocaml -rectypes
Objective Caml version 3.08.3
# let rec blackhole x = blackhole;;
val blackhole : 'b -> 'a as 'a = <fun>
The problem is, though, that almost everything can be typed once you
have unrestricted recursive types (e.g. missing arguments etc), and
consequently many actual errors remain unflagged (which clearly shows
that typing is not only about potential value class mismatches).
Moreover, there are very few practical uses of such a feature, and they
can always be coded easily with recursive datatypes.
It is a pragmatic decision born from experience that you simply do *not
want* to have this, even though you easily could. E.g. for OCaml,
unrestricted recursive typing was removed as default because of frequent
user complaints.
Which is why this actually is a very bad example to chose for dynamic
typing advocacy... ;-)
- Andreas
------------------------------
Date: Wed, 28 Jun 2006 11:37:04 +0200
From: Joachim Durchholz <jo@durchholz.org>
Subject: Re: What is Expressiveness in a Computer Language
Message-Id: <e7tisp$n9i$1@online.de>
Paul Rubin schrieb:
> It starts to look like sufficiently powerful static type systems are
> confusing enough, that programming with them is at least as bug-prone
> as imperative programming in dynamically typed languages. The static
> type checker can spot type mismatches at compile time, but the
> types themselves are easier and easier to get wrong.
That's where type inference comes into play. Usually you don't write the
types, the compiler infers them for you, so you don't get them wrong.
Occasionally, you still write down the types, if only for documentation
purposes (the general advice is: do the type annotations for external
interfaces, but not internally).
BTW if you get a type wrong, you'll be told by the compiler, so this is
still less evil than bugs in the code that pop up during testing (and
*far* less evil than bugs that pop up after roll-out).
And the general consensus among FPL programmers is that you get the hang
of it fairly quickly (one poster mentioned "two to three months" - this
doesn't seem to be slower than learning to interpret synax error
messages, so it's OK considering it's an entirely new kind of diagnostics).
Regards,
Jo
------------------------------
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 9397
***************************************