[23410] in Perl-Users-Digest
Perl-Users Digest, Issue: 5628 Volume: 10
daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Tue Oct 7 11:05:51 2003
Date: Tue, 7 Oct 2003 08:05:11 -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 Tue, 7 Oct 2003 Volume: 10 Number: 5628
Today's topics:
Re: About regura expression only for outside of html ta (Anno Siegel)
Re: About regura expression only for outside of html ta (Tad McClellan)
ANNOUNCE: Data::HTMLDumper 0.01 (Phil Crow)
Bizarre copy of ARRAY <Joachim.Fabini@gmx.net>
Re: Bizarre copy of ARRAY (Greg Bacon)
Re: Bizarre copy of ARRAY <skweek@no.spam>
Re: Bizarre copy of ARRAY <Joachim.Fabini@gmx.net>
Re: fastest count of instances in string? (Anno Siegel)
Re: How replace ing2004 to ing-2004 ? please help (Randal L. Schwartz)
Re: Opinions on "new SomeObject" vs. "SomeObject->new() <REMOVEsdnCAPS@comcast.net>
Re: Opinions on "new SomeObject" vs. "SomeObject->new() (Greg Bacon)
Re: Opinions on "new SomeObject" vs. "SomeObject->new() (Anno Siegel)
Re: Opinions on "new SomeObject" vs. "SomeObject->new() (Patriote)
Re: Opinions on "new SomeObject" vs. "SomeObject->new() (Randal L. Schwartz)
Re: Opinions on "new SomeObject" vs. "SomeObject->new() (Quantum Mechanic)
Re: Perl module to clear pop mailbox? <sfandino@yahoo.com>
Re: Perl::Inline compiling problems (Brian K. Michalk)
Re: Perl::Inline compiling problems (Brian K. Michalk)
Reading huge *.txt files? (Math55)
Re: Reading huge *.txt files? <bernard.el-haginDODGE_THIS@lido-tech.net>
Re: Reading huge *.txt files? <HelgiBriem_1@hotmail.com>
Re: Reading huge *.txt files? <hobbes@vkr.NOSPAM.dk>
Re: Reading huge *.txt files? (Tad McClellan)
Re: Reading huge *.txt files? <peter@semantico.com>
Re: Reading huge *.txt files? <kurzhalsflasche@yahoo.co.uk>
Re: Reading huge *.txt files? <twhu@lucent.com>
Re: Reading huge *.txt files? <peter@semantico.com>
Re: Strange behaviour with '\r' character [[ sorry my o <HelgiBriem_1@hotmail.com>
Re: Strange behaviour with '\r' character [[ sorry my o (Tad McClellan)
sysopen problem <Hon.Lee@Sun.COM>
Re: Teach me how to fish, regexp (Roy Johnson)
Re: <bwalton@rochester.rr.com>
Digest Administrivia (Last modified: 6 Apr 01) (Perl-Users-Digest Admin)
----------------------------------------------------------------------
Date: 7 Oct 2003 10:12:01 GMT
From: anno4000@lublin.zrz.tu-berlin.de (Anno Siegel)
Subject: Re: About regura expression only for outside of html tags.
Message-Id: <blu3hh$kau$1@mamenchi.zrz.TU-Berlin.DE>
G&G <chang@naggama.co.kr> wrote in comp.lang.perl.misc:
> Have any idea about regular expression ?
>
>
> I tried to change any numeric letter to Zero like following;
> $aaa = ereg_replace ("|0-9|", "0", $sentence);
> This seems working perfect.
>
> My question is how I can do this function only for outside of html tags.
> I don't want any numeric letters to be changed inside html tags.
HTML cannot reasonably be parsed by a regex alone. Use a HTML parser
from CPAN.
Anno
------------------------------
Date: Tue, 7 Oct 2003 09:32:28 -0500
From: tadmc@augustmail.com (Tad McClellan)
Subject: Re: About regura expression only for outside of html tags.
Message-Id: <slrnbo5jjs.ja2.tadmc@magna.augustmail.com>
G&G <chang@naggama.co.kr> wrote:
> I don't want any numeric letters to be changed inside html tags.
What is a "numeric letter"?
Perhaps you meant "numeric character" instead?
--
Tad McClellan SGML consulting
tadmc@augustmail.com Perl programming
Fort Worth, Texas
------------------------------
Date: Tue, 7 Oct 2003 14:22:02 GMT
From: philcrow2000@yahoo.com (Phil Crow)
Subject: ANNOUNCE: Data::HTMLDumper 0.01
Message-Id: <HME5GF.1DEx@zorch.sf-bay.org>
The new perl module Data::HTMLDumper is available from CPAN. It turns the
output of Data::Dumper into an html table so you can include the following
in a CGI or mod_perl script:
use Data::HTMLDumper;
print Dumper(\%some_hash);
This will dump the output, in html table form, directly into the output.
If you like to use Data::Dumper for debugging at the command line,
and you are now working on the web, you might like Data::HTMLDumper.
The module is simplistic, but effective. It just injects itself between
you and Data::Dumper, tranforming its output with simple pattern matching.
The result is not particularly pretty for people, but quite suitable for
browsers.
------------------------------
Date: Tue, 07 Oct 2003 14:03:53 +0200
From: Joachim Fabini <Joachim.Fabini@gmx.net>
Subject: Bizarre copy of ARRAY
Message-Id: <tt95ovgln1sh0b5a7p85c605dnk7i9spem@4ax.com>
Hi,
Being a complete newbie in Perl, before submitting the bug to
ActiveState I'd like to cross-check if the following error message is
caused by a coding error or by a bug in the debugging part of Perl.
When running the code from the command line everything works as
expected (ActiveState Perl, v. 508, build 806, W32). When invoking the
script using perl -d BugTest.pl, the debugger stops and displays the
following message:
> Bizarre copy of ARRAY in leave at BugTest.pl line 16.
> Debugged program terminated. Use q to quit or R to restart,
> use O inhibit_exit to avoid stopping after program termination,
> h q, h R or h O to get additional info.
Below the script:
-------------------------------------------------------------------------
#!/usr/bin/perl
use strict;
my %Tests =
(
"HTTP" => ["a","b","1K","10K"],
"SMTP" => ["c","d","1K","10K","100K"]
);
for my $CurrentTest (keys %Tests)
{
# Execute test
my ($LocalPath,$RemotePath,@FileSizes) = @{$Tests{$CurrentTest} };
for my $i (0 .. $#{@FileSizes} )
{
print "Test: $CurrentTest, Iteration: $i, FileSize:
@FileSizes[$i]\n";
}
}
-------------------------------------------------------------------------
Thanks in advance for any reply,
Best regards
--Joachim
------------------------------
Date: Tue, 07 Oct 2003 12:17:00 -0000
From: gbacon@hiwaay.net (Greg Bacon)
Subject: Re: Bizarre copy of ARRAY
Message-Id: <vo5blshh6o3icc@corp.supernews.com>
In article <tt95ovgln1sh0b5a7p85c605dnk7i9spem@4ax.com>,
Joachim Fabini <Joachim.Fabini@gmx.net> wrote:
: When running the code from the command line everything works as
: expected (ActiveState Perl, v. 508, build 806, W32). When invoking the
: script using perl -d BugTest.pl, the debugger stops and displays the
: following message:
:
: > Bizarre copy of ARRAY in leave at BugTest.pl line 16.
: > Debugged program terminated. Use q to quit or R to restart,
: > use O inhibit_exit to avoid stopping after program termination,
: > h q, h R or h O to get additional info.
You're abusing syntax. $#{...} expects a reference inside the block,
and to pluck a scalar from an array, say $array[$index]:
#!/usr/bin/perl
use strict;
my %Tests =
(
"HTTP" => ["a","b","1K","10K"],
"SMTP" => ["c","d","1K","10K","100K"]
);
for my $CurrentTest (keys %Tests)
{
# Execute test
my ($LocalPath,$RemotePath,@FileSizes) = @{$Tests{$CurrentTest}};
for my $i (0 .. $#FileSizes )
{
print "Test: $CurrentTest, Iteration: $i, FileSize:\n",
$FileSizes[$i], "\n";
}
}
Hope this helps,
Greg
--
The moral is obvious. You can't trust code that you did not totally create
yourself. (Especially code from companies that employ people like me.)
-- Ken Thompson
------------------------------
Date: Tue, 07 Oct 2003 14:45:59 +0200
From: AlV <skweek@no.spam>
Subject: Re: Bizarre copy of ARRAY
Message-Id: <bluci7$avu$1@news-reader5.wanadoo.fr>
Joachim Fabini wrote:
> Hi,
>
> Being a complete newbie in Perl, before submitting the bug to
> ActiveState I'd like to cross-check if the following error message is
> caused by a coding error or by a bug in the debugging part of Perl.
>
> When running the code from the command line everything works as
> expected (ActiveState Perl, v. 508, build 806, W32). When invoking the
> script using perl -d BugTest.pl, the debugger stops and displays the
> following message:
Try the slight modification below.
> Below the script:
> -------------------------------------------------------------------------
> #!/usr/bin/perl
>
> use strict;
>
> my %Tests =
> (
> "HTTP" => ["a","b","1K","10K"],
> "SMTP" => ["c","d","1K","10K","100K"]
> );
>
>
> for my $CurrentTest (keys %Tests)
> {
> # Execute test
> my ($LocalPath,$RemotePath,@FileSizes) = @{$Tests{$CurrentTest} };
> ### for my $i (0 .. $#{@FileSizes} ) #### Bizarre, indeed! :o)
for my $i (0 .. $#FileSizes )
> {
> print "Test: $CurrentTest, Iteration: $i, FileSize:
> @FileSizes[$i]\n";
> }
> }
------------------------------
Date: Tue, 07 Oct 2003 16:09:58 +0200
From: Joachim Fabini <Joachim.Fabini@gmx.net>
Subject: Re: Bizarre copy of ARRAY
Message-Id: <l4i5ov4n5vuqcut8o18et5kd46tnvse4uh@4ax.com>
On Tue, 07 Oct 2003 14:03:53 +0200, Joachim Fabini
<Joachim.Fabini@gmx.net> wrote:
Thanks to all who replied - replacing $#{@FileSizes} by $#FileSizes
does the job.
Best regards
--Joachim
------------------------------
Date: 7 Oct 2003 12:43:32 GMT
From: anno4000@lublin.zrz.tu-berlin.de (Anno Siegel)
Subject: Re: fastest count of instances in string?
Message-Id: <blucdk$rq9$1@mamenchi.zrz.TU-Berlin.DE>
Eric J. Roode <REMOVEsdnCAPS@comcast.net> wrote in comp.lang.perl.misc:
> -----BEGIN xxx SIGNED MESSAGE-----
> Hash: SHA1
>
> bill <bill_knight2@yahoo.com> wrote in news:blk164$cd5$1@reader2.panix.com:
>
> >
> >
> > What's the fastest way to count how many times a specific character
> > appears in a string? Anything faster than something like
> >
> > for (split //, $string) { ++$count if $_ eq $char }
>
> Probably the fastest way would be to write a C function to do the counting,
> then link to it via XS (or Inline::C).
I don't think a C function can be much faster than a pre-compiled tr///.
In fact, I was courious enough to do a quick benchmark. (Except they're
never really quick.) The Inline code *was* faster -- by 4 %.
Anno
------------------------------
Date: Tue, 07 Oct 2003 14:46:26 GMT
From: merlyn@stonehenge.com (Randal L. Schwartz)
To: "=?iso-8859-1?q?Fran=E7ois?=" <avril@ece.fr>
Subject: Re: How replace ing2004 to ing-2004 ? please help
Message-Id: <be4826debeb3b01daf5846a5065ba324@news.teranews.com>
>>>>> "François" == François <avril@ece.fr> writes:
François> I want to replace an expression abc1234 to abc-1234 how can i do
François> I 've tried
François> s/......./$1$2$3-$4$5$6$7/ but it dont work.
s/abc1234/abc-1234/ would do it, as would $_ = "abc-1234", but since
you've given only one example and no rules, it's hard to generalize
that.
--
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: Tue, 07 Oct 2003 06:41:03 -0500
From: "Eric J. Roode" <REMOVEsdnCAPS@comcast.net>
Subject: Re: Opinions on "new SomeObject" vs. "SomeObject->new()"
Message-Id: <Xns940D4E236DDD6sdn.comcast@206.127.4.25>
-----BEGIN xxx SIGNED MESSAGE-----
Hash: SHA1
tadmc@augustmail.com (Tad McClellan) wrote in
news:slrnbo4j9s.hrf.tadmc@magna.augustmail.com:
> Eric J. Roode <REMOVEsdnCAPS@comcast.net> wrote:
>>
>> I personally think it makes NO sense to create a new object from an
>> existing one
>
>
> That code does not create a new object from an existing one.
>
> "SomeObject" is not an object (bad choice of name), it is a class.
>
I understand that. I was making a general comment on creating objects.
Some of the other people who responded to the OP went off on the tangent of
creating a new object from an existing one, so I thought I'd chip my two
cents in. Apologies if my wording was confusing.
- --
Eric
$_ = reverse sort $ /. r , qw p ekca lre uJ reh
ts p , map $ _. $ " , qw e p h tona e and print
-----BEGIN xxx SIGNATURE-----
Version: PGPfreeware 7.0.3 for non-commercial use <http://www.pgp.com>
iQA/AwUBP4KmQWPeouIeTNHoEQKDawCgyjEuOVUgcyrGkBLCCMZM4upw+asAniH7
PlIpWplGtyAK6XgRpXJD+0l5
=O15d
-----END PGP SIGNATURE-----
------------------------------
Date: Tue, 07 Oct 2003 12:06:26 -0000
From: gbacon@hiwaay.net (Greg Bacon)
Subject: Re: Opinions on "new SomeObject" vs. "SomeObject->new()"
Message-Id: <vo5b22derbned3@corp.supernews.com>
In article <642aea591ecc43a4da321e6220dbeac1@news.teranews.com>,
Randal L. Schwartz <merlyn@stonehenge.com> wrote:
: >>>>> "Tore" == Tore Aursand <tore@aursand.no> writes:
:
: Tore> I prefer the latter, but as long as you design your classes to
: Tore> expect them to be used both ways, there shouldn't be any
: Tore> difference;
:
: Tore> sub new {
: Tore> my $proto = shift;
: Tore> my $class = ref( $proto ) || $proto;
: Tore> }
:
: Please, don't cargo-cult ref($proto) in this matter!
: See my rant on that at <http://www.perlmonks.org/index.pl?node_id=52089>.
Here you argue in horribly obtuse terms: "If you want an instance method
called 'new', I have no idea what it's doing." Bull! In the next two
sentences, you give *two* ideas. If you not sure, read the pods, or use
the source, Luke!
What's worse, at least in the context of Perl, is that you're being
rigidly dogmatic. If you don't like $obj->new, then don't use it!
Greg
--
I also have to confess I was pro-"gun-control." In my defense, I was a
juvenile and gun control is a juvenile notion.
-- James Ostrowski
------------------------------
Date: 7 Oct 2003 13:02:35 GMT
From: anno4000@lublin.zrz.tu-berlin.de (Anno Siegel)
Subject: Re: Opinions on "new SomeObject" vs. "SomeObject->new()"
Message-Id: <bludhb$son$1@mamenchi.zrz.TU-Berlin.DE>
Greg Bacon <gbacon@hiwaay.net> wrote in comp.lang.perl.misc:
> In article <642aea591ecc43a4da321e6220dbeac1@news.teranews.com>,
> Randal L. Schwartz <merlyn@stonehenge.com> wrote:
>
> : >>>>> "Tore" == Tore Aursand <tore@aursand.no> writes:
> :
> : Tore> I prefer the latter, but as long as you design your classes to
> : Tore> expect them to be used both ways, there shouldn't be any
> : Tore> difference;
> :
> : Tore> sub new {
> : Tore> my $proto = shift;
> : Tore> my $class = ref( $proto ) || $proto;
> : Tore> }
> :
> : Please, don't cargo-cult ref($proto) in this matter!
> : See my rant on that at <http://www.perlmonks.org/index.pl?node_id=52089>.
>
> Here you argue in horribly obtuse terms: "If you want an instance method
> called 'new', I have no idea what it's doing." Bull! In the next two
> sentences, you give *two* ideas. If you not sure, read the pods, or use
> the source, Luke!
>
> What's worse, at least in the context of Perl, is that you're being
> rigidly dogmatic. If you don't like $obj->new, then don't use it!
That's not the point. The "ref( $proto) || $proto" thing has become
a sort of idiom that is, often mindlessly, squeezed into many new()
methods, just because it's easy. In my opinion new() rarely needs
to be callable as an object method, and to make it so routinely is
wrong. Objecting a false idiom isn't dogmatism, it's a public
service.
Anno
------------------------------
Date: 7 Oct 2003 06:38:52 -0700
From: patriote@fastmail.fm (Patriote)
Subject: Re: Opinions on "new SomeObject" vs. "SomeObject->new()"
Message-Id: <dced8a08.0310070538.196d56cb@posting.google.com>
"Eric J. Roode" <REMOVEsdnCAPS@comcast.net> wrote in message news:<Xns940CD233996E9sdn.comcast@206.127.4.25>...
> -----BEGIN xxx SIGNED MESSAGE-----
> Hash: SHA1
>
> patriote@fastmail.fm (Patriote) wrote in
> news:dced8a08.0310061336.35f80601@posting.google.com:
>
> > Some programmers use the style
> >
> > $objSome = new SomeObject;
> >
> > instead of
> >
> > $objSome = SomeObject->new();
> >
> > What are the penalties for using the former Java-like syntax if any?
> > I've heard that it can cause problems with inheritance, but I've read
> > no specifics.
>
> I personally think it makes NO sense to create a new object from an
> existing one unless the new object is somehow a child or otherwise a
> descendant of the existing object. Thus, I never do:
>
> $new_object = $old_object->new();
>
> and I never code my new() methods to expect to be called from an existing
> object.
>
> For creating new objects, I think that
>
> $new_object = new Object;
>
> makes intuitive sense -- "give me a new Object". It reads like English.
> On the other hand,
>
> $new_object = Object->new();
>
> makes less sense to me, but at least I don't have to code differently for
> it. Users of my modules can use either syntax.
>
> - --
> Eric
> $_ = reverse sort $ /. r , qw p ekca lre uJ reh
> ts p , map $ _. $ " , qw e p h tona e and print
>
> -----BEGIN xxx SIGNATURE-----
> Version: PGPfreeware 7.0.3 for non-commercial use <http://www.pgp.com>
>
> iQA/AwUBP4ILUmPeouIeTNHoEQLyywCfTwMFSRzrRgkHfvj4/C2yHD3wF9oAoIew
> QOcbChXi6bJH8/rLpl9GRAl7
> =w42G
> -----END PGP SIGNATURE-----
Sorry, my nomenclature was stupid. When I said:
$objSome = SomeObject->new();
I meant:
$objSome = SomeClass->new();
------------------------------
Date: Tue, 07 Oct 2003 14:31:22 GMT
From: merlyn@stonehenge.com (Randal L. Schwartz)
Subject: Re: Opinions on "new SomeObject" vs. "SomeObject->new()"
Message-Id: <51a53c247078236ccbf45909c38c6207@news.teranews.com>
>>>>> "Greg" == Greg Bacon <gbacon@hiwaay.net> writes:
Greg> Here you argue in horribly obtuse terms: "If you want an instance method
Greg> called 'new', I have no idea what it's doing." Bull! In the next two
Greg> sentences, you give *two* ideas. If you not sure, read the pods, or use
Greg> the source, Luke!
I should have said "I have no idea which of the following two it is
doing, or something else entirely." Does that help?
Greg> What's worse, at least in the context of Perl, is that you're being
Greg> rigidly dogmatic. If you don't like $obj->new, then don't use it!
The problem is that your use of ->new is not likely to be confined to
your cubicle. I don't speak for your private code. I speak for code
that you're likely to upload to the CPAN to share with others.
Don't make $instance->new. It obscures more than it communicates.
--
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: 7 Oct 2003 07:54:11 -0700
From: quantum_mechanic_1964@yahoo.com (Quantum Mechanic)
Subject: Re: Opinions on "new SomeObject" vs. "SomeObject->new()"
Message-Id: <f233f2f0.0310070654.739c0c7b@posting.google.com>
"Eric J. Roode" <REMOVEsdnCAPS@comcast.net> wrote in message news:<Xns940CD233996E9sdn.comcast@206.127.4.25>...
> -----BEGIN xxx SIGNED MESSAGE-----
> Hash: SHA1
>
> patriote@fastmail.fm (Patriote) wrote in
> news:dced8a08.0310061336.35f80601@posting.google.com:
>
> > Some programmers use the style
> >
> > $objSome = new SomeObject;
> >
> > instead of
> >
> > $objSome = SomeObject->new();
> >
> > What are the penalties for using the former Java-like syntax if any?
> > I've heard that it can cause problems with inheritance, but I've read
> > no specifics.
>
> I personally think it makes NO sense to create a new object from an
> existing one unless the new object is somehow a child or otherwise a
> descendant of the existing object. Thus, I never do:
>
> $new_object = $old_object->new();
>
> and I never code my new() methods to expect to be called from an existing
> object.
>
> For creating new objects, I think that
>
> $new_object = new Object;
>
> makes intuitive sense -- "give me a new Object". It reads like English.
> On the other hand,
>
> $new_object = Object->new();
>
> makes less sense to me, but at least I don't have to code differently for
> it. Users of my modules can use either syntax.
Not to put too fine a point on it, but what is acceptable syntax for
creating a new instance of a class of a given instance, when that
class isn't known at the time of coding?
In other words, if I know the class, I can do this:
$new_instance = new Class;
or
$new_instance = Class->new();
If I don't know the class ahead of time (determined at runtime, for
instance), I'm looking at one of these:
$new_instance = new $old_instance;
$new_instance = $old_instance->new();
$new_instance = (ref $old_instance)->new();
The last one makes me wish for an alias to 'ref' called 'ClassOf'.
Indeed, getting the 3rd ancestor class might be done like this:
$new_great_great_uncle = (ClassOf($Johny,3))->new();
for certain values of ClassOf.
-QM
------------------------------
Date: Tue, 07 Oct 2003 14:39:48 +0100
From: Salvador Fandino <sfandino@yahoo.com>
Subject: Re: Perl module to clear pop mailbox?
Message-Id: <blufnc$2qc$06$1@news.t-online.com>
AcCeSsDeNiEd wrote:
> Hi folks,
>
> I'm attempting to automatically log into a pop account and clear/delete all the emails in it.
> I know I can do this with some telnet routines, but if there is already a module out there, it would
> safe me time.
Hi,
Some days ago I released yaspi, a perl script to remove Swen from POP3
mail accounts. It could be configured to delete everything not just
infected mails, or just modify the source to suit your needs.
http://yaspi.sourceforge.net
Bye,
- Salva
------------------------------
Date: 7 Oct 2003 06:58:19 -0700
From: michalk@awpi.com (Brian K. Michalk)
Subject: Re: Perl::Inline compiling problems
Message-Id: <c30723e3.0310070558.42868b3@posting.google.com>
Thank you so much. Who would have thought about the subdirectory
thing. I guess it's symlinks for me.
Strange about the AV* thing. I'm doing it for execution efficiency
... why else would I use C? Perl -v says I'm using 5.6.1. Is there
some documentation on this "feature"?
Sisyphus <kalinaubears@iinet.net.au> wrote in message news:<3f8201d2$0$23608$5a62ac22@freenews.iinet.net.au>...
> Caveat:
> 1) The source file ('s1.c') needs to be in a separate directory from
> 'try.pl'. (Or maybe it just needs to be in a directory other than the
> cwd - haven't tested.)
>
> I would think that the 2 opening Config statements in the perl script
> could be combined into one - but I lost interest after my first 2
> attempts to do just that failed :-)
>
> Hope there's something there that helps you find a satisfactory solution.
>
> Incidentally, passing an AV* as an arg to an inline function won't work
> on perl 5.6.0/1. (Just in case it matters.)
>
> Cheers,
> Rob
------------------------------
Date: 7 Oct 2003 07:02:28 -0700
From: michalk@awpi.com (Brian K. Michalk)
Subject: Re: Perl::Inline compiling problems
Message-Id: <c30723e3.0310070602.af60058@posting.google.com>
Sisyphus <kalinaubears@iinet.net.au> wrote in message news:<3f821856$0$23589$5a62ac22@freenews.iinet.net.au>...
> Sisyphus wrote:
>
> > Caveat:
> > 1) The source file ('s1.c') needs to be in a separate directory from
> > 'try.pl'. (Or maybe it just needs to be in a directory other than the
> > cwd - haven't tested.)
> >
>
> 'perldoc inline-faq' tells us that the C source files must be in a
> subdirectory of the perl script.
>
> Cheers,
> Rob
Where did you get that?
http://search.cpan.org/~ingy/Inline-0.44/Inline-FAQ.pod mentions
nothing about this. Perhaps I'm using way outdated documentation?
------------------------------
Date: 7 Oct 2003 06:54:27 -0700
From: magelord@t-online.de (Math55)
Subject: Reading huge *.txt files?
Message-Id: <a2b8188a.0310070554.acaa33f@posting.google.com>
hi, is there a possibility to read large (>1mb) *.txt files in a fast
way? everytime i do that, my program freezes or takes very long to
finish. anyone a idea?
THANKS:-)
------------------------------
Date: Tue, 7 Oct 2003 13:57:26 +0000 (UTC)
From: "Bernard El-Hagin" <bernard.el-haginDODGE_THIS@lido-tech.net>
Subject: Re: Reading huge *.txt files?
Message-Id: <Xns940DA229EC926elhber1lidotechnet@62.89.127.66>
magelord@t-online.de (Math55) wrote in
news:a2b8188a.0310070554.acaa33f@posting.google.com:
> hi, is there a possibility to read large (>1mb) *.txt files in a fast
> way? everytime i do that, my program freezes or takes very long to
> finish. anyone a idea?
You're going to have to be more specific. What is it exactly you're trying
to do? Show a relevant code snippet, please.
Cheers,
Bernard
------------------------------
Date: Tue, 07 Oct 2003 14:25:41 +0000
From: Helgi Briem <HelgiBriem_1@hotmail.com>
Subject: Re: Reading huge *.txt files?
Message-Id: <b1j5ov0raitlgf4j9ddh1cda8jr2b5sc98@4ax.com>
On 7 Oct 2003 06:54:27 -0700, magelord@t-online.de (Math55) wrote:
>hi, is there a possibility to read large (>1mb) *.txt files in a fast
>way? everytime i do that, my program freezes or takes very long to
>finish. anyone a idea?
1MB is large? What are you using, a BBC Commodore?
Anyway,
#!perl
use warnings;
use strict;
my $in = '/full/path/to/bigtextfile';
open IN, $in or die "Cannot open $in:$!\n";
while (<IN>)
{
#do stuff with contents
}
close IN;
__END__
------------------------------
Date: Tue, 7 Oct 2003 16:28:13 +0200
From: "Jesper" <hobbes@vkr.NOSPAM.dk>
Subject: Re: Reading huge *.txt files?
Message-Id: <bluigq$gap$1@news.net.uni-c.dk>
I have the same problem.
I have two txt files (txta and texb) each with 15-20000 lines. Each line
contains a username + info. Now what I want to do is take a line from texta,
retrieve the username from this line, search for the username in txtb and
return the info that's related to the username i txtb. My code looks like:
open (txta, "txta");
@txta= <txta>;
close(txta);
open (txtb, "txtb");
@txtb= <txtb>;
close(txtb);
foreach $txta_line (@txta)
{
#starts by getting the userid
get userid;
--------------------------------------
foreach $txtb_line (@txtb)
{
my (@array) = $txtb_line =~ m!(.*);(.*)!;
if (@array[0]=~m!^$userid$!) { $userinfo = @array[1]; }
}
--------------------------------------
$userinfo = '';
#uses the $userinfo
}
The code between the lines takes 'really' long time (15000 lines are a lot
of lines :)) - is there anyway to optimize the code ?
Regards,
Jesper
BTW I'm using activestate perl 5.6.1
"Bernard El-Hagin" <bernard.el-haginDODGE_THIS@lido-tech.net> wrote in
message news:Xns940DA229EC926elhber1lidotechnet@62.89.127.66...
> magelord@t-online.de (Math55) wrote in
> news:a2b8188a.0310070554.acaa33f@posting.google.com:
>
> > hi, is there a possibility to read large (>1mb) *.txt files in a fast
> > way? everytime i do that, my program freezes or takes very long to
> > finish. anyone a idea?
>
>
> You're going to have to be more specific. What is it exactly you're trying
> to do? Show a relevant code snippet, please.
>
>
> Cheers,
> Bernard
------------------------------
Date: Tue, 7 Oct 2003 09:34:56 -0500
From: tadmc@augustmail.com (Tad McClellan)
Subject: Re: Reading huge *.txt files?
Message-Id: <slrnbo5jog.ja2.tadmc@magna.augustmail.com>
Math55 <magelord@t-online.de> wrote:
> hi, is there a possibility to read large (>1mb) *.txt files in a fast
> way? everytime i do that, my program freezes or takes very long to
> finish. anyone a idea?
You have an error on line 17.
--
Tad McClellan SGML consulting
tadmc@augustmail.com Perl programming
Fort Worth, Texas
------------------------------
Date: Tue, 07 Oct 2003 15:47:38 +0100
From: Peter Hickman <peter@semantico.com>
Subject: Re: Reading huge *.txt files?
Message-Id: <3f82d20b$0$3651$afc38c87@news.easynet.co.uk>
Jesper wrote:
> --------------------------------------
> foreach $txtb_line (@txtb)
> {
> my (@array) = $txtb_line =~ m!(.*);(.*)!;
> if (@array[0]=~m!^$userid$!) { $userinfo = @array[1]; }
> }
> --------------------------------------
> $userinfo = '';
You do realise that this line has just lost all the information you put in
$userinfo three lines previous?
>
> #uses the $userinfo
> }
>
>
> The code between the lines takes 'really' long time (15000 lines are a lot
> of lines :)) - is there anyway to optimize the code ?
The brain dead fix is this...
foreach $txtb_line (@txtb)
{
my (@array) = $txtb_line =~ m!(.*);(.*)!;
if (@array[0]=~m!^$userid$!) {
$userinfo = @array[1];
last;
}
}
That will quit the inner loop once a match is found.
However this is still not the way, even if TIMTOWTDI.
Before you read txta read txtb into a hash
foreach $txtb_line (@txtb}
{
my (@array) = $txtb_line =~ m!(.*);(.*)!;
$lookup{$array[0]} = $array[1];
}
then where you had the inner loop
if($lookup{$userid}) {
$userinfo = $lookup{$userid};
} else {
$userinfo = '';
}
Don't go much faster.
------------------------------
Date: Tue, 07 Oct 2003 16:53:01 +0200
From: Dominik Seelow <kurzhalsflasche@yahoo.co.uk>
Subject: Re: Reading huge *.txt files?
Message-Id: <blujtd$gn17u$1@uni-berlin.de>
Jesper wrote:
Hello Jesper.
> I have the same problem.
> I have two txt files (txta and texb) each with 15-20000 lines. Each line
> contains a username + info. Now what I want to do is take a line from texta,
> retrieve the username from this line, search for the username in txtb and
> return the info that's related to the username i txtb. My code looks like:
>
> open (txta, "txta");
> @txta= <txta>;
> close(txta);
>
Reading the whole file at once is not a good idea, especially if the
files are large.
> open (txtb, "txtb");
> @txtb= <txtb>;
> close(txtb);
>
> foreach $txta_line (@txta)
> {
> #starts by getting the userid
> get userid;
>
> --------------------------------------
> foreach $txtb_line (@txtb)
> {
> my (@array) = $txtb_line =~ m!(.*);(.*)!;
> if (@array[0]=~m!^$userid$!) { $userinfo = @array[1]; }
> }
> --------------------------------------
> $userinfo = '';
>
> #uses the $userinfo
> }
>
>
> The code between the lines takes 'really' long time (15000 lines are a lot
> of lines :)) - is there anyway to optimize the code ?
>
Read the files line-wise. If you need to join them, read the first file
(apparently 'textb') line-by-line and put everything you need into a
hash. Read the second file (apparently 'texta') and use the hash to join
the information. Try to use other names for your files.
HTH,
Dominik
------------------------------
Date: Tue, 7 Oct 2003 10:58:27 -0400
From: "Tulan W. Hu" <twhu@lucent.com>
Subject: Re: Reading huge *.txt files?
Message-Id: <blukck$9l@netnews.proxy.lucent.com>
"Math55" <magelord@t-online.de> wrote in message ...
> hi, is there a possibility to read large (>1mb) *.txt files in a fast
> way? everytime i do that, my program freezes or takes very long to
> finish. anyone a idea?
>
> THANKS:-)
Upgrade your perl to 5.8.1 and use Tie::File.
------------------------------
Date: Tue, 07 Oct 2003 16:05:01 +0100
From: Peter Hickman <peter@semantico.com>
Subject: Re: Reading huge *.txt files?
Message-Id: <3f82d61d$0$17373$afc38c87@news.easynet.co.uk>
Tulan W. Hu wrote:
> "Math55" <magelord@t-online.de> wrote in message ...
>
>>hi, is there a possibility to read large (>1mb) *.txt files in a fast
>>way? everytime i do that, my program freezes or takes very long to
>>finish. anyone a idea?
>>
>>THANKS:-)
>
>
> Upgrade your perl to 5.8.1 and use Tie::File.
>
>
To be honest this is not good advice. His code is grossly inefficient, most of
the improvements will come from a better design than using a module to
implement a bad design.
------------------------------
Date: Tue, 07 Oct 2003 12:54:32 +0000
From: Helgi Briem <HelgiBriem_1@hotmail.com>
Subject: Re: Strange behaviour with '\r' character [[ sorry my other post was wrong typed ]]
Message-Id: <mmd5ovcpngpp2jueg5t3up6f3acenplli0@4ax.com>
On 6 Oct 2003 10:40:49 -0700, i5513@hotmail.com (i5513) wrote:
>Thanks you! I have read on perlre:
>\s Match a whitespace character
>But I didn't know '\r' was whitespace (I thinked about \s was( |\t)).
\s contains 4 different kinds of white space:
\n line feed
\r carriage return
\t tab
space
------------------------------
Date: Tue, 7 Oct 2003 09:37:09 -0500
From: tadmc@augustmail.com (Tad McClellan)
Subject: Re: Strange behaviour with '\r' character [[ sorry my other post was wrong typed ]]
Message-Id: <slrnbo5jsl.ja2.tadmc@magna.augustmail.com>
Helgi Briem <HelgiBriem_1@hotmail.com> wrote:
> On 6 Oct 2003 10:40:49 -0700, i5513@hotmail.com (i5513) wrote:
>
>>Thanks you! I have read on perlre:
>>\s Match a whitespace character
>
>>But I didn't know '\r' was whitespace (I thinked about \s was( |\t)).
>
> \s contains 4 different kinds of white space:
Five , m'lord.
> \n line feed
> \r carriage return
> \t tab
> space
you forgot form feed \f
--
Tad McClellan SGML consulting
tadmc@augustmail.com Perl programming
Fort Worth, Texas
------------------------------
Date: Tue, 07 Oct 2003 11:03:52 +0100
From: Hon Guin Lee - Web Producer - SMI Marketing <Hon.Lee@Sun.COM>
Subject: sysopen problem
Message-Id: <3F828F88.B3BAF345@Sun.COM>
My objective is to open a file if it exists, and if not create a new file from the string variable $FILE, but I have encountered a problem that in some occurences the file can be opened and modified without the compiler throwing error messages otherwise it throws a Permission Denied error (not owner) from just modifying a file within the local web server.
# open the file and allow it to be modified.
# modify file by adding the content or create a new file.
open($FILE, "> $page") || die $!;
sysopen($FILE, $page, O_WRONLY|O_CREAT) || die $!;
sysopen($FILE, $page, O_WRONLY|O_CREAT, 0777) || die $!;
OR
sysopen($FILE, $page, O_WRONLY | O_CREAT, 0777) || die $!;
------------------------------
Date: 7 Oct 2003 06:36:55 -0700
From: rjohnson@shell.com (Roy Johnson)
Subject: Re: Teach me how to fish, regexp
Message-Id: <3ee08638.0310070536.697f7ef3@posting.google.com>
If I may take the last question first:
Henry <henryn@zzzspacebbs.com> wrote in message news:<BBA79042.154E5%henryn@zzzspacebbs.com>...
> Or should I go back to my awk hack that works and which I actually
> understand?
You could always run your awk hack through a2p to see how it deals
with your situation. Could be ugly, could be enlightening.
If you do this:
my @paras = split(/\n{3}(\d+\.(?:\d+.)?) /, $whole_file);
You will have your section headers split out as their own paragraphs,
followed by the paragraphs themselves. Then you just have to put them
back together as you go through the list. (Decide for yourself whether
you want the spaces after the section number retained. My split is
throwing them away.)
If you want three or more newlines, change the {3} to {3,}. Season to
taste.
> I can't even figure out why I seem to need "[0-9][0-9]+" for my 5 digit test
> case when it seems "[0-9]+" ought to suffice.
I agree (although I recommend \d instead of [0-9]). What was [0-9]+
doing wrong that [0-9][0-9]+ fixed?
------------------------------
Date: Sat, 19 Jul 2003 01:59:56 GMT
From: Bob Walton <bwalton@rochester.rr.com>
Subject: Re:
Message-Id: <3F18A600.3040306@rochester.rr.com>
Ron wrote:
> Tried this code get a server 500 error.
>
> Anyone know what's wrong with it?
>
> if $DayName eq "Select a Day" or $RouteName eq "Select A Route") {
(---^
> dienice("Please use the back button on your browser to fill out the Day
> & Route fields.");
> }
...
> Ron
...
--
Bob Walton
------------------------------
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 5628
***************************************