[29503] in Perl-Users-Digest
Perl-Users Digest, Issue: 747 Volume: 11
daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Sun Aug 12 03:09:41 2007
Date: Sun, 12 Aug 2007 00:09:06 -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 Sun, 12 Aug 2007 Volume: 11 Number: 747
Today's topics:
Can I perform this Parse in perl? (Non standard address <dafella007@yahoo.com>
Re: Can I perform this Parse in perl? (Non standard add <skye.shaw@gmail.com>
Re: Can I perform this Parse in perl? (Non standard add <skye.shaw@gmail.com>
Re: commandline replace and running out of quotes <dummy@example.com>
Re: File::Find problem? <joe@inwap.com>
Re: Help: Newbie Question <joe@inwap.com>
Re: Help: Newbie Question <openlinuxsource@gmail.com>
Re: how to tranpose a huge text file xhoster@gmail.com
Re: how to tranpose a huge text file <nospam-abuse@ilyaz.org>
new CPAN modules on Sun Aug 12 2007 (Randal Schwartz)
Re: Out of memory in vec <paduille.4061.mumia.w+nospam@earthlink.net>
Re: pass by reference <savagebeaste@yahoo.com>
Re: Q on localizing *STDOUT and fork <rvtol+news@isolution.nl>
Re: Q on localizing *STDOUT and fork xhoster@gmail.com
Re: Question on grep and reading from file xhoster@gmail.com
Re: Using DBI, better option than importing into @array <rvtol+news@isolution.nl>
Re: Windows based perl editor? <rvtol+news@isolution.nl>
Digest Administrivia (Last modified: 6 Apr 01) (Perl-Users-Digest Admin)
----------------------------------------------------------------------
Date: Sat, 11 Aug 2007 18:23:50 -0700
From: Steve <dafella007@yahoo.com>
Subject: Can I perform this Parse in perl? (Non standard address)
Message-Id: <1186881830.047520.232730@q3g2000prf.googlegroups.com>
Can't do this in Excel. Can perl do it?
Ok here is my goal.
On Thursday my local newspaper post Garage sell ads for the up coming
weekend.
I've found these sales are an excellent source for merchandise to
sell
on ebay. And the prices are awesome.
If I open the paper site in Excel I get cells that look like this.
(50
- 100 ads)
How can parse out just the time and address of the sale so I can plan
my routes and which days to visit which house.
(Folks mark the stuff down on the lastday)
1. Come see at: 4785 SE 133rd Dr, City, State 12345 Off Holgate, take
a right on 134th, (Aspen Meadows), stop sign take a right, take a
left
on 133rd and 5th house on the left. Saturday August 11, 2007 10am to
5pm only
2. Lots of Name Brands!! Tons of Clothes for Girls and Boys. Dog
House, Animal Kennel, toys, lego table, infant chairs, girl HOPE TO
SEE YOU THERE, THANK YOU!!!! This Friday & Saturday!! 8/10 & 8/11
10am
- 6pm 2100 SE 118th Ave City, St 12345
3. Lots of Name Brands!! Tons of Clothes for Girls and Boys. Dog
House, Animal Kennel, toys, lego table, infant chairs, girl HOPE TO
SEE YOU THERE, THANK YOU!!!! Fri & Sat Aug 10 & Aug 11 10 am - 6 pm
2100 SE 120th Ave City, St no zip
Steve
------------------------------
Date: Sun, 12 Aug 2007 06:10:18 -0000
From: "Skye Shaw!@#$" <skye.shaw@gmail.com>
Subject: Re: Can I perform this Parse in perl? (Non standard address)
Message-Id: <1186899018.549843.40210@j4g2000prf.googlegroups.com>
On Aug 11, 6:23 pm, Steve <dafella...@yahoo.com> wrote:
> Can't do this in Excel. Can perl do it?
More of less
> Ok here is my goal.
<snip>
<reformatted post>
> On Thursday my local newspaper post Garage sell ads for the up coming
> weekend.
> If I open the paper site in Excel I get cells that look like this:
> 1. Come see at: 4785 SE 133rd Dr, City, State 12345 Off Holgate, take
> a right on 134th, (Aspen Meadows), stop sign take a right, take a
> left
> on 133rd and 5th house on the left. Saturday August 11, 2007 10am to
> 5pm only
>
> 2. Lots of Name Brands!! Tons of Clothes for Girls and Boys. Dog
> House, Animal Kennel, toys, lego table, infant chairs, girl HOPE TO
> SEE YOU THERE, THANK YOU!!!! This Friday & Saturday!! 8/10 & 8/11
> 10am
> - 6pm 2100 SE 118th Ave City, St 12345
>
> 3. Lots of Name Brands!! Tons of Clothes for Girls and Boys. Dog
> House, Animal Kennel, toys, lego table, infant chairs, girl HOPE TO
> SEE YOU THERE, THANK YOU!!!! Fri & Sat Aug 10 & Aug 11 10 am - 6 pm
> 2100 SE 120th Ave City, St no zip
> How can parse out just the time and address of the sale so I can plan
> my routes and which days to visit which house.
Dates/times are easy -for the most part, as for addresses, they can be
tricky, especially if you want to break them up into parts.
The best thing to do is look at each description for something that
will tell you, "Hey there's an address on this line". Addresses and
streets can be complicated, so we won't bother with those. The state
(well, zip too) is the simplest part, so we'll look for them.
In my example, i use a text file with the sample addresses
you posted ("state" switched with "California").
Using Text::CSV to iterate over the spreadsheet's rows, and
Text::Sentence to iterate over the description's lines is left as an
exercise...
[sshaw@localhost ~]$ cat bs.pl
use strict;
use warnings;
my %DAYS = (Monday=>qr!\bMon(?:\.|(?:day))?\b!i,
Tuesday=>qr!\bTues(?:\.|(?:day))?\b!i,
#...
Friday=>qr!\bFri(?:\.|(?:day))?\b!i,
Saturday=>qr!\bSat(?:\.|(?:urday))?\b!i);
my %DATE = (August=>qr!(?:(?:Aug(?:\.|(?:ust))?)|0?8[-/])\s*\d{1,2}!i,
#...
);
my %STATE = (California=>qr!\bCa(?:lifornia)?\b!i,
#...
);
my $addr;
my (@days,@dates,@times);
my $day = join "|",values %DAYS;
my $date = join "|",values %DATE;
my $state = join "|",values %STATE;
while(<>) {
if(/^$/) {
local $"=" - ";
print "$addr: @days, @dates @times\n";
(@days,@dates,@times) = ();
next;
}
# print $_;
while(/($day)/igo) {
push @days,$1;
}
while(/($date)/goi) {
push @dates,$1;
}
while(/(\d{1,2}\s*[ap]m)/goi) {
push @times,$1;
}
if(/(\d{2,}.+[^$state]\s+$state)/oi) {
$addr = $1;
}
}
[sshaw@localhost ~]$ perl bs.pl descs
4785 SE 133rd Dr, City, CA: Saturday, August 11 10am - 5pm
2100 SE 118th Ave City, California: Friday - Saturday, 8/10 - 8/11
10am - 6pm
2100 SE 120th Ave City, Ca: Fri - Sat, Aug 10 - Aug 11 10 am - 6 pm
Of course, this example will not work if an address spans 2 lines, or
if there are several times and/or messages relating to them. i.e.
"Everything must go by 2pm".
If you want more detailed address parsing, i.e. extracting
street,address,state,zip into their own fields, check out
Geo::StreetAddress::US. GEO::StreetAddress::US can't extract the
address from a paragraph, but once you have (or think you have <:^| )
an address, you can pass the the value to it for parsing.
Or you can use its RegExes.
I'm curious to see other suggestions.
------------------------------
Date: Sun, 12 Aug 2007 06:20:14 -0000
From: "Skye Shaw!@#$" <skye.shaw@gmail.com>
Subject: Re: Can I perform this Parse in perl? (Non standard address)
Message-Id: <1186899614.373540.89110@e9g2000prf.googlegroups.com>
On Aug 11, 11:10 pm, "Skye Shaw!@#$" <skye.s...@gmail.com> wrote:
> On Aug 11, 6:23 pm, Steve <dafella...@yahoo.com> wrote:> Can't do this in Excel. Can perl do it?
>
> More of less
>
> > Ok here is my goal.
>
> <snip>
>
> <reformatted post>
>
>
>
> > On Thursday my local newspaper post Garage sell ads for the up coming
> > weekend.
> > If I open the paper site in Excel I get cells that look like this:
> > 1. Come see at: 4785 SE 133rd Dr, City, State 12345 Off Holgate, take
> > a right on 134th, (Aspen Meadows), stop sign take a right, take a
> > left
> > on 133rd and 5th house on the left. Saturday August 11, 2007 10am to
> > 5pm only
>
> > 2. Lots of Name Brands!! Tons of Clothes for Girls and Boys. Dog
> > House, Animal Kennel, toys, lego table, infant chairs, girl HOPE TO
> > SEE YOU THERE, THANK YOU!!!! This Friday & Saturday!! 8/10 & 8/11
> > 10am
> > - 6pm 2100 SE 118th Ave City, St 12345
>
> > 3. Lots of Name Brands!! Tons of Clothes for Girls and Boys. Dog
> > House, Animal Kennel, toys, lego table, infant chairs, girl HOPE TO
> > SEE YOU THERE, THANK YOU!!!! Fri & Sat Aug 10 & Aug 11 10 am - 6 pm
> > 2100 SE 120th Ave City, St no zip
> > How can parse out just the time and address of the sale so I can plan
> > my routes and which days to visit which house.
>
> Dates/times are easy -for the most part, as for addresses, they can be
> tricky, especially if you want to break them up into parts.
>
> The best thing to do is look at each description for something that
> will tell you, "Hey there's an address on this line". Addresses and
> streets can be complicated, so we won't bother with those. The state
> (well, zip too) is the simplest part, so we'll look for them.
>
> In my example
<snip>
> my %DAYS = (Monday=>qr!\bMon(?:\.|(?:day))?\b!i,
> Tuesday=>qr!\bTues(?:\.|(?:day))?\b!i,
> #...
> Friday=>qr!\bFri(?:\.|(?:day))?\b!i,
> Saturday=>qr!\bSat(?:\.|(?:urday))?\b!i);
>
> my $day = join "|",values %DAYS;
> while(/($day)/igo) {
Oops, the "i" modifier is superfluous
------------------------------
Date: Sat, 11 Aug 2007 22:37:55 GMT
From: "John W. Krahn" <dummy@example.com>
Subject: Re: commandline replace and running out of quotes
Message-Id: <7Tqvi.101724$xk5.38649@edtnps82>
John Bagins wrote:
> I am using the inplace edit of commandline perl in a per script.
> How do I insert those doublequotes in the RHS?
> system qq|perl -pi -e "s/(?=#FILE_MARKER)/" $var "/| file_name;
Is that $file_name or 'file_name'?
You probably want something like this:
{ local ( $^I, @ARGV ) = ( '', 'file_name' );
s/(?=#FILE_MARKER)/" $var "/, print while <>;
}
John
--
Perl isn't a toolbox, but a small machine shop where you
can special-order certain sorts of tools at low cost and
in short order. -- Larry Wall
------------------------------
Date: Sat, 11 Aug 2007 22:41:16 -0700
From: Joe Smith <joe@inwap.com>
Subject: Re: File::Find problem?
Message-Id: <yOidnZ675uUaACPbnZ2dnUVZ_oCvnZ2d@comcast.com>
Ron Bergin wrote:
> On Aug 10, 5:45 pm, Tad McClellan <ta...@seesig.invalid> wrote:
>> Ron Bergin <r...@i.frys.com> wrote:
>>> Try changing the open call to this:
>>> open(HDR_FILE, '<', "$_") || die "Can't open file or input: $!";
>
> I'm aware of the reasons for not always quoting "$vars" and I rarely
> do quote them, however, I did in this case to safeguard against the
> possibility of having spaces in the filename, in which case the open
> call would fail if it was not quoted.
Not true for the three-argument open(). Check the docs, and look
for the line "Use 3-argument form to open a file with arbitrary
weird characters in it...". Leading and trailing blanks
are preserved when the file name is in the third arg.
It's the two-argument open() that eats leading and trailing blanks, leading to
open FH,"< ./$_\0" or die;
-Joe
------------------------------
Date: Sat, 11 Aug 2007 23:12:11 -0700
From: Joe Smith <joe@inwap.com>
Subject: Re: Help: Newbie Question
Message-Id: <sJednQxFy55bOSPbnZ2dnUVZ_ternZ2d@comcast.com>
Amy Lee wrote:
> My problem is how use Perl to convert the fasta header from
>> 16jh_0101.b1.abi Chromat File descriptions [\n]
> 2| ATCCGTACTGCATCCGTACTGCATCCGTACATCCGTACTGCATCCGTACTGCATCCGTAC[\n]
> 3| (more sequence until the next "\n>" record tag
>
> to
> 16>jh_0101>ATCCGTACTGC............................................
Looks like a straight forward process:
1) Tell perl that you want to use a particular record separator,
2) read in the multi-line record,
3) do basic text transformation,
4) print the results.
For step 1, the key is perl's $/ variable. From "perldoc perlvar":
$/ The input record separator, newline by default. This influ-
ences Perl's idea of what a "line" is. Works like awk's RS
variable, including treating empty lines as a terminator if set
to the null string. (An empty line cannot contain any spaces
or tabs.) You may set it to a multi-character string to match
a multi-character terminator, or to "undef" to read through the
end of file.
Step 2 is very easy. After $/="\n>", $_=<> does exactly that.
$\ = "\n>"; # Input record separator
while (<>) { # Read in one record at a time
... # You need to fill out this section
}
> Thank you very much, I hope that I can get the code.
You expect us to do all the work? I'm afraid you'll be disappointed.
This newsgroup does not do other people's homework - you're expected
to take a stab at the problem, then post what you've tried, and we
can help you from there.
Since I showed you steps 1 and 2, you should be able to figure out
the rest of the program on your own.
-Joe
------------------------------
Date: Sun, 12 Aug 2007 14:34:50 +0800
From: Amy Lee <openlinuxsource@gmail.com>
Subject: Re: Help: Newbie Question
Message-Id: <pan.2007.08.12.06.34.49.906857@gmail.com>
On Sat, 11 Aug 2007 23:12:11 -0700, Joe Smith wrote:
> Amy Lee wrote:
>
>> My problem is how use Perl to convert the fasta header from
>>> 16jh_0101.b1.abi Chromat File descriptions [\n]
>> 2| ATCCGTACTGCATCCGTACTGCATCCGTACATCCGTACTGCATCCGTACTGCATCCGTAC[\n]
>> 3| (more sequence until the next "\n>" record tag
>>
>> to
>> 16>jh_0101>ATCCGTACTGC............................................
>
> Looks like a straight forward process:
> 1) Tell perl that you want to use a particular record separator,
> 2) read in the multi-line record,
> 3) do basic text transformation,
> 4) print the results.
>
> For step 1, the key is perl's $/ variable. From "perldoc perlvar":
>
> $/ The input record separator, newline by default. This influ-
> ences Perl's idea of what a "line" is. Works like awk's RS
> variable, including treating empty lines as a terminator if set
> to the null string. (An empty line cannot contain any spaces
> or tabs.) You may set it to a multi-character string to match
> a multi-character terminator, or to "undef" to read through the
> end of file.
>
> Step 2 is very easy. After $/="\n>", $_=<> does exactly that.
>
> $\ = "\n>"; # Input record separator
> while (<>) { # Read in one record at a time
> ... # You need to fill out this section
> }
>
>> Thank you very much, I hope that I can get the code.
>
> You expect us to do all the work? I'm afraid you'll be disappointed.
>
> This newsgroup does not do other people's homework - you're expected
> to take a stab at the problem, then post what you've tried, and we
> can help you from there.
>
> Since I showed you steps 1 and 2, you should be able to figure out
> the rest of the program on your own.
>
> -Joe
Okay, thank your advice very much.
Regards,
Amy Lee
------------------------------
Date: 12 Aug 2007 00:45:03 GMT
From: xhoster@gmail.com
Subject: Re: how to tranpose a huge text file
Message-Id: <20070811204506.825$sM@newsreader.com>
Ted Zlatanov <tzz@lifelogs.com> wrote:
> On 11 Aug 2007 01:17:08 GMT xhoster@gmail.com wrote:
>
>
> x> One of the major gene-chip companies was very proud that in one of
> x> their upgrades, they started using a database instead of plain files
> x> for storing the data. And then their customers were very pleased
> x> when in a following upgrade they abandoned that, and went back to
> x> using plain files for the bulk data and using the database just for
> x> the small DoE metadata.
>
> I can give you many examples where databases improved a business;
Well I should hope you could, and so can I. I just don't think from what
we have seen that this is particularly likely to be one of those cases.
>
> x> And I really doubt that any single database design is going to support
> x> everything that anyone may ever want to do with the data, either.
>
> My point is that the single-task program to transpose a file will be
> much less useful than the database setup for general use. You're taking
> the argument to an absurd extreme ("everything that anyone may ever
> want").
While it may or may not be useful for purposes invisible to us, I don't
think it will be very useful for the one desired task which we *do* know
about.
> x> I think you are missing the big picture. Once you make a seekable
> x> file format, that probably does away with the need to transpose the
> x> data in the first place--whatever operation you wanted to do with the
> x> transposition can be probably be done on the seekable file instead.
>
> Usually the rewrite is for another program that wants that data as
> input, so no, you can't do "whatever" operation on the seekable file
> without rewriting the consumer program's input routine.
If the program you are trying to use only accepts one input format and you
are unwilling to change it, then what is putting the data it needs into a
database rather than into the necessary format going to get you? If I have
to make gigantic transposed file, I'd far rather start with the given text
file than with a database containing that data.
Xho
--
-------------------- http://NewsReader.Com/ --------------------
Usenet Newsgroup Service $9.95/Month 30GB
------------------------------
Date: Sun, 12 Aug 2007 06:19:37 +0000 (UTC)
From: Ilya Zakharevich <nospam-abuse@ilyaz.org>
Subject: Re: how to tranpose a huge text file
Message-Id: <f9m8pp$1heq$1@agate.berkeley.edu>
[A complimentary Cc of this posting was sent to
Ted Zlatanov
<tzz@lifelogs.com>], who wrote in article <m2d4xu6ptv.fsf@lifelogs.com>:
> On Sat, 11 Aug 2007 03:51:27 +0000 (UTC) Ilya Zakharevich <nospam-abuse@ilyaz.org> wrote:
>
> IZ> Words words words. You can't do *all the things* efficiently.
> IZ> Databases are optimized for some particular access patterns. I doubt
> IZ> that even "good databases" are optimized for *this particular* access
> IZ> pattern.
>
> You mean "SELECT column FROM table" (which is what you need in order to
> write each line of the transposed file)? I think that's a pretty common
> access pattern, and would perform well in most databases.
I have very little experience with databases. However, my hunch
(based on my experience with other types of software) is that they are
not as optimized as an optimistic point of view may imply.
Doing one "SELECT column FROM table" (which results in a megaarray)
may be not *that* slow - given quick enough hardware. Doing it 1000
times would unravel all the missing optimizations in the
implementation of the database.
Hope this helps,
Ilya
------------------------------
Date: Sun, 12 Aug 2007 04:42:17 GMT
From: merlyn@stonehenge.com (Randal Schwartz)
Subject: new CPAN modules on Sun Aug 12 2007
Message-Id: <JMn92H.LJ2@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.
Algorithm-Dependency-Source-DBI-0.01
http://search.cpan.org/~adamk/Algorithm-Dependency-Source-DBI-0.01/
Database source for Algorithm::Dependency
----
Catalyst-Plugin-Cache-FastMmap-0.71
http://search.cpan.org/~mramberg/Catalyst-Plugin-Cache-FastMmap-0.71/
Mmap cache
----
Catalyst-Plugin-Cache-Memcached-0.71
http://search.cpan.org/~mramberg/Catalyst-Plugin-Cache-Memcached-0.71/
Distributed cache
----
Class-C3-Componentised-1.0001
http://search.cpan.org/~ash/Class-C3-Componentised-1.0001/
----
Date-Holidays-AU-0.05
http://search.cpan.org/~ddick/Date-Holidays-AU-0.05/
Determine Australian Public Holidays
----
Date-Holidays-UK-EnglandAndWales-0.02
http://search.cpan.org/~lgoddard/Date-Holidays-UK-EnglandAndWales-0.02/
Public Holidays in England and Wales
----
Geo-ICAO-0.21
http://search.cpan.org/~jquelin/Geo-ICAO-0.21/
Airport and ICAO codes lookup
----
Geo-ICAO-0.22
http://search.cpan.org/~jquelin/Geo-ICAO-0.22/
Airport and ICAO codes lookup
----
Geo-ICAO-0.23
http://search.cpan.org/~jquelin/Geo-ICAO-0.23/
Airport and ICAO codes lookup
----
Graph-0.82
http://search.cpan.org/~jhi/Graph-0.82/
graph data structures and algorithms
----
IPC-Mmap-0.13
http://search.cpan.org/~darnold/IPC-Mmap-0.13/
provides a minimal mmap() interface for both POSIX and Win32
----
Javascript-MD5-1.06
http://search.cpan.org/~rsavage/Javascript-MD5-1.06/
Calculate the MD5 digest of a CGI form field
----
Javascript-SHA1-1.03
http://search.cpan.org/~rsavage/Javascript-SHA1-1.03/
Calculate the SHA1 digest of a CGI form field
----
Lingua-Any-Numbers-0.10
http://search.cpan.org/~burak/Lingua-Any-Numbers-0.10/
Converts numbers into (any available language) string.
----
Locale-Object-0.76
http://search.cpan.org/~hex/Locale-Object-0.76/
An object-oriented representation of locale information.
----
Math-LogRand-0.02
http://search.cpan.org/~lgoddard/Math-LogRand-0.02/
Perl extension to return a random number with log weighting.
----
Module-Runtime-0.004
http://search.cpan.org/~zefram/Module-Runtime-0.004/
runtime module handling
----
Net-Bluetooth-0.40
http://search.cpan.org/~iguthrie/Net-Bluetooth-0.40/
Perl Bluetooth Interface
----
Test-Smoke-1.20
http://search.cpan.org/~abeltje/Test-Smoke-1.20/
The Perl core test smoke suite
----
Time-Fuzzy-0.21
http://search.cpan.org/~jquelin/Time-Fuzzy-0.21/
Time read like a human, with some fuzziness
----
Time-Fuzzy-0.22
http://search.cpan.org/~jquelin/Time-Fuzzy-0.22/
Time read like a human, with some fuzziness
----
Time-Fuzzy-0.30
http://search.cpan.org/~jquelin/Time-Fuzzy-0.30/
Time read like a human, with some fuzziness
----
WWW-Mixi-Scraper-0.06
http://search.cpan.org/~ishigaki/WWW-Mixi-Scraper-0.06/
yet another mixi scraper
----
WWW-Search-AltaVista-2.147
http://search.cpan.org/~mthurn/WWW-Search-AltaVista-2.147/
class for searching www.altavista.com
----
WWW-Search-Jarit-1.003
http://search.cpan.org/~mthurn/WWW-Search-Jarit-1.003/
class for searching www.search.com
----
Weed-0.01_019
http://search.cpan.org/~hooo/Weed-0.01_019/
Don't use it. It's in development. For test purposes only!
----
zxid-0.19
http://search.cpan.org/~sampo/zxid-0.19/
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: Sat, 11 Aug 2007 17:56:03 -0500
From: "Mumia W." <paduille.4061.mumia.w+nospam@earthlink.net>
Subject: Re: Out of memory in vec
Message-Id: <13bsgpra63f4c01@corp.supernews.com>
On 08/11/2007 11:54 AM, Dr.Ruud wrote:
> Mumia W. schreef:
>
>> I have 512mb RAM and 800mb swap,
>
>
> Yeah, millibits won't get you far.
> ;-)
>
Yeah, I keep forgetting. :-)
--
It's a damn poor imagination that can only capitalize scientific
measurement units one way.
------------------------------
Date: Sat, 11 Aug 2007 15:10:24 -0700
From: "Clenna Lumina" <savagebeaste@yahoo.com>
Subject: Re: pass by reference
Message-Id: <5i6qf8F3ns4d1U1@mid.individual.net>
Billy Patton wrote:
> anno4000@radom.zrz.tu-berlin.de wrote:
>> Billy Patton <bpatton@ti.com> wrote in comp.lang.perl.misc:
>>> Larry wrote:
>>>> The following code snippet shows how I do "pass by reference" in
>>>> Perl. It works fine, but I'm wondering... is there a less verbose
>>>> way to do this?
>>
>> [...]
>>
>>> Do you really want side effects ?
>>> Passing by reference does this.
>>> Guess this is too simple to make that decision.
>>>
>>> sub squareMe($) {
>>> my ($arg) = @_;
>>> $arg *= $arg;
>>> }
>>>
>>> my $n=7;
>>> $n = squareMe $n; # no side effects
>>> I hate it when my variables get changed somewhere else and I have to
>>> track it down for debugging!
>>
>> That raises the question why you are using the mutator "*=" at all.
>> It doesn't do anything useful.
>>
>> sub square_me {
>> my $arg = shift;
>> $arg*$arg;
>> }
>>
>> would be exactly equivalent, as would be
>>
>> sub square_me { $_[0]*$_[0] }
>>
>> Anno
>
> The beauty of perl "Always more than one way to skin a cat" :)
Just how many ways do you need to skin a cat :-P yeeesh
(Seriously though, it's one the things I really love about Perl)
--
CL
------------------------------
Date: Sat, 11 Aug 2007 23:47:20 +0200
From: "Dr.Ruud" <rvtol+news@isolution.nl>
Subject: Re: Q on localizing *STDOUT and fork
Message-Id: <f9lhv6.1bk.1@news.isolution.nl>
xhoster@gmail.com schreef:
> open my $pipe, '|-', "/usr/bin/sort -n > $filename", or die $!;
>
> Alas, this requires you to use the shell-interpreted-version of the
> open rather than the shell-less version.
Isn't there "concept" in Perl to change "SHELLMETAS"? (name as is used
in `man procmailrc`)
I often undefine SHELLMETAS in a .procmailrc, to prevent the shell being
used.
--
Affijn, Ruud
"Gewoon is een tijger."
------------------------------
Date: 12 Aug 2007 00:13:12 GMT
From: xhoster@gmail.com
Subject: Re: Q on localizing *STDOUT and fork
Message-Id: <20070811201315.605$EQ@newsreader.com>
"Dr.Ruud" <rvtol+news@isolution.nl> wrote:
> xhoster@gmail.com schreef:
>
> > open my $pipe, '|-', "/usr/bin/sort -n > $filename", or die $!;
> >
> > Alas, this requires you to use the shell-interpreted-version of the
> > open rather than the shell-less version.
>
> Isn't there "concept" in Perl to change "SHELLMETAS"? (name as is used
> in `man procmailrc`)
Well, there is the 4 or more form of open. That suppresses the shell.
>
> I often undefine SHELLMETAS in a .procmailrc, to prevent the shell being
> used.
But that would defeat the purpose. The ">" redirection has to be
interpreted by the shell, otherwise there is no point to doing it that way.
You could always pass $filename through quotemeta, although for all I know
that might backwhack some things which are ordinary to the shell but become
special when backwhacked.
Xho
--
-------------------- http://NewsReader.Com/ --------------------
Usenet Newsgroup Service $9.95/Month 30GB
------------------------------
Date: 12 Aug 2007 00:02:27 GMT
From: xhoster@gmail.com
Subject: Re: Question on grep and reading from file
Message-Id: <20070811200230.511$ng@newsreader.com>
googler <pinaki_m77@yahoo.com> wrote:
> > > I have another question. Is there a way to read a particular line in
> > > a file when I know the line number (without using a loop and reading
> > > each line at a time)? I guess the below code would work.
> > > @lines = <MYFILE>;
> > > $myline = $lines[$linenum-1];
> > > But this will read the entire file into the array @lines and can take
> > > up a lot of memory if the file is huge. Is there a more efficient
> > > solution?
> >
> > Unless you know how long each line is, or have otherwise pre-computed
> > some kind of index into the file, you need to read the entire file at
> > least up to the desired line and count newlines, either implicitly or
> > explicitly.
>
> OK, say I know how long each line is. How can it help in reading the n-
> th line from the file directly? Can you please explain. Thanks.
Compute where in the file the desired line starts, and use "seek" to
jump to it. See perldoc -f seek.
Xho
--
-------------------- http://NewsReader.Com/ --------------------
Usenet Newsgroup Service $9.95/Month 30GB
------------------------------
Date: Sun, 12 Aug 2007 00:26:23 +0200
From: "Dr.Ruud" <rvtol+news@isolution.nl>
Subject: Re: Using DBI, better option than importing into @array
Message-Id: <f9lkah.1b0.1@news.isolution.nl>
Jason schreef:
> # Push subjects into Perl array
> my $filelist = $dbh->selectall_arrayref("SELECT `id`, `lastmodified`,
> `subject` FROM $forum_subjects ORDER BY lastmodified DESC");
There is an index on the lastmodified column?
> # 0 and 20 are dynamic in the real script
> for ($count=0; $count < 20; $count++) {
> ($id, $lastmodified, $subject) = split(/\|:\|/, $filenames[$count]);
>
> my $topiclist = $dbh->selectall_arrayref("SELECT `id`, `subject`,
> `postdate`, `username`, `email`, `comment` FROM $forum_posts WHERE
> id=" . $dbh->quote($id) . " ORDER BY postdate ASC");
21 queries where 1 would suffice. You do at least have an index on the
postdate column?
--
Affijn, Ruud
"Gewoon is een tijger."
------------------------------
Date: Sun, 12 Aug 2007 01:03:00 +0200
From: "Dr.Ruud" <rvtol+news@isolution.nl>
Subject: Re: Windows based perl editor?
Message-Id: <f9lm9k.18k.1@news.isolution.nl>
Bill H schreef:
> The biggest thing I really
> want is the incremental backup so that I can walk back through
> previous versions of a program if I discover that changes I made
> "broke" something else.
Use a VCS and commit with each save.
--
Affijn, Ruud
"Gewoon is een tijger."
------------------------------
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 V11 Issue 747
**************************************