[28064] in Perl-Users-Digest
Perl-Users Digest, Issue: 9428 Volume: 10
daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Thu Jul 6 03:05:53 2006
Date: Thu, 6 Jul 2006 00:05:05 -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 Thu, 6 Jul 2006 Volume: 10 Number: 9428
Today's topics:
Re: date format <someone@example.com>
How to break the lines in printing to html lines? <cibalo@gmx.co.uk>
Re: How to break the lines in printing to html lines? <someone@example.com>
Re: How to break the lines in printing to html lines? <sherm@Sherm-Pendleys-Computer.local>
Re: How to break the lines in printing to html lines? <tadmc@augustmail.com>
Re: How to break the lines in printing to html lines? <penryu@saiyix.ath.cx>
Re: languages with full unicode support <timr@probo.com>
new CPAN modules on Thu Jul 6 2006 (Randal Schwartz)
Re: Reg: "pattern match read eof" error <ermeyers@adelphia.net>
Re: Searching a string in a list of delimited fields <ro.naldfi.scher@gmail.com>
smarter zipcode search algorithm premgrps@gmail.com
Re: smarter zipcode search algorithm <rvtol+news@isolution.nl>
Re: unicode <spam@bsb.me.uk>
Digest Administrivia (Last modified: 6 Apr 01) (Perl-Users-Digest Admin)
----------------------------------------------------------------------
Date: Wed, 05 Jul 2006 23:35:38 GMT
From: "John W. Krahn" <someone@example.com>
Subject: Re: date format
Message-Id: <e1Yqg.131103$771.74161@edtnps89>
Bart Van der Donck wrote:
> spross wrote:
>
>>sorry, i'm a beginner :)
>>i have a file and the first line looks like:
>>
>>%%%%%%%% HEADER Fri Jun 16 17:21:03 MEST 2006 %%%%%%%%%%%%
>>
>>my question: how chan i get the date in this header in a format like:
>>YYYYMMDD
>
> #!perl
> use strict;
> use warnings;
> my $file =
> '%%%%%%%% HEADER Fri Jun 16 17:21:03 MEST 2006 %%%%%%%%%%%%
> 1111111111111111111111
> 2222222222222222222222
> 3333333333333333333333
> ';
> my @m = ('Jan', 'Feb', 'Mar', 'Apr', 'May',
> 'Jun', 'Jul', 'Aug', 'Sep', 'Oct', 'Nov', 'Dec');
> my @ar = split / /, (split /\n/, $file)[0];
A lot of date formats use a leading space for single digit days so splitting
on a single space character will give you an off-by-one error on the day and
year fields.
> $ar[3] =~ s/$m[$_]/@{[sprintf('%02g',$_+1)]}/ for (0..$#m);
Is there a good reason to use a floating-point format ('g') instead of an
integer format ('i', 'd' or 'u')?
> die "Can't find month '$ar[3]'\n" unless $ar[3]=~/^(0|1)[0-9]$/;
Why use an alternation with capturing parentheses instead of a character
class? Where do you use the value stored in $1? So you are saying that 19 is
a valid month?
> print $ar[7], $ar[3], sprintf('%02g',$ar[4]);
John
--
use Perl;
program
fulfillment
------------------------------
Date: 5 Jul 2006 20:21:35 -0700
From: "Ciba LO" <cibalo@gmx.co.uk>
Subject: How to break the lines in printing to html lines?
Message-Id: <1152156095.659345.106220@m73g2000cwd.googlegroups.com>
Hello,
The following script fails to break the lines in listing the directory
contents with long listing format --- see below.
#!/usr/bin/perl
print "Content-type: text/html\n\n";
print "<br>";
$out = exec("ls -l");
print "$out<br>\n";
print "<br>";
And the browser displays as:
total 24 -rwx------ 1 apache apache 132 Jul 6 11:04 test.cgi -rwx------
1 apache apache 134 Jul 6 11:02 test.cgi~ -rwxrwxrwx 1 guest guest 253
Jul 6 10:48 test_a.cgi -rwxrwxrwx 1 guest guest 257 Jul 6 10:47
test_a.cgi~ -rwxrwxrwx 1 guest guest 511 Mar 15 21:18 test_b.cgi
-rwxrwxrwx 1 guest guest 511 Mar 15 21:17 test_c.cgi
Please help me to break the lines in printing to html lines!
Thank you very much in advance!!!
Ciba
------------------------------
Date: Thu, 06 Jul 2006 03:37:29 GMT
From: "John W. Krahn" <someone@example.com>
Subject: Re: How to break the lines in printing to html lines?
Message-Id: <Zz%qg.104705$A8.3932@clgrps12>
Ciba LO wrote:
>
> The following script fails to break the lines in listing the directory
> contents with long listing format --- see below.
> #!/usr/bin/perl
> print "Content-type: text/html\n\n";
> print "<br>";
> $out = exec("ls -l");
The exec() function doesn't return what you seem to think it does.
> print "$out<br>\n";
$out doesn't contain "lines" (in the HTML sense) it contains one string. Read
the documentation for the qx operator in the perlop manual:
perldoc perlop
> print "<br>";
#!/usr/bin/perl
use warnings;
use strict;
print "Content-type: text/html\n\n",
'<br>',
map( "$_<br>\n", qx[ls -l] ),
'<br>';
John
--
use Perl;
program
fulfillment
------------------------------
Date: Wed, 05 Jul 2006 23:39:16 -0400
From: Sherm Pendley <sherm@Sherm-Pendleys-Computer.local>
Subject: Re: How to break the lines in printing to html lines?
Message-Id: <m2bqs3s8pn.fsf@Sherm-Pendleys-Computer.local>
"Ciba LO" <cibalo@gmx.co.uk> writes:
> The following script fails to break the lines in listing the directory
> contents with long listing format --- see below.
> #!/usr/bin/perl
> print "Content-type: text/html\n\n";
> print "<br>";
> $out = exec("ls -l");
> print "$out<br>\n";
> print "<br>";
Exec() does not do what you think it does - the two print statements after
exec() in the above are never executed, and $out does not have the output
of the ls command.
See "perldoc -f exec" for details.
> Please help me to break the lines in printing to html lines!
First sort out the problem with the exec() above.
After that, you have two options. One, you could split $out into lines, and
print a <br> after each line like you're doing above. Or, you could replace
all the \n's in $out with <br> in one go.
The first approach would use split() - see "perldoc -f split". The second
would use regular expressions - see "perldoc perlre".
sherm--
--
Cocoa programming in Perl: http://camelbones.sourceforge.net
Hire me! My resume: http://www.dot-app.org
------------------------------
Date: Wed, 5 Jul 2006 22:57:16 -0500
From: Tad McClellan <tadmc@augustmail.com>
Subject: Re: How to break the lines in printing to html lines?
Message-Id: <slrneap2gs.dec.tadmc@magna.augustmail.com>
Ciba LO <cibalo@gmx.co.uk> wrote:
> The following script fails to break the lines in listing the directory
> contents with long listing format --- see below.
> $out = exec("ls -l");
Where does the output from ls go?
It goes to STDOUT.
In a CGI environment STDOUT ends up at the browser.
There are no <br>s in the output from ls, so there are no <br>
tags for the browser to act on.
> print "$out<br>\n";
If the ls executes, then this print statement is _never_ reached!
(Because your perl process has been replaced by the ls process.
That's what the *and never returns* means in the first line
of the description for the exec function that you are using.
)
> Please help me to break the lines in printing to html lines!
foreach my $line ( `ls -l` ) {
print "$line<br>";
}
--
Tad McClellan SGML consulting
tadmc@augustmail.com Perl programming
Fort Worth, Texas
------------------------------
Date: Thu, 06 Jul 2006 06:36:06 GMT
From: Tim Hammerquist <penryu@saiyix.ath.cx>
Subject: Re: How to break the lines in printing to html lines?
Message-Id: <slrneapbqm.1h2f.penryu@ruri.saiyix>
Ciba LO <cibalo@gmx.co.uk> wrote:
> The following script fails to break the lines in listing the directory
> contents with long listing format --- see below.
> #!/usr/bin/perl
> print "Content-type: text/html\n\n";
> print "<br>";
> $out = exec("ls -l");
> print "$out<br>\n";
> print "<br>";
>
> And the browser displays as:
> total 24 -rwx------ 1 apache apache 132 Jul 6 11:04 test.cgi -rwx------
> 1 apache apache 134 Jul 6 11:02 test.cgi~ -rwxrwxrwx 1 guest guest 253
> Jul 6 10:48 test_a.cgi -rwxrwxrwx 1 guest guest 257 Jul 6 10:47
> test_a.cgi~ -rwxrwxrwx 1 guest guest 511 Mar 15 21:18 test_b.cgi
> -rwxrwxrwx 1 guest guest 511 Mar 15 21:17 test_c.cgi
>
> Please help me to break the lines in printing to html lines!
As stated numerous times elsewhere, $out doesn't contain the lines of
the ls output... nor any output of the command at all.
I won't reiterate what others have said, but I will offer an
alternative solution:
#!/usr/bin/perl
print "Content-type: text/plain\n\n", `ls -l`;
Note the different content-type. If you send content-type text/plain,
the browser will use the newlines included in the output of ls, so you
need not add <br> tags to manually break lines.
Note that this also precludes using any other HTML prettification. If
this is desired, you might look at the <pre> tag.
HTH,
Tim Hammerquist
------------------------------
Date: Thu, 06 Jul 2006 03:51:05 GMT
From: Tim Roberts <timr@probo.com>
Subject: Re: languages with full unicode support
Message-Id: <212pa2tnd3p87dvki0o34qgualu64d9hqc@4ax.com>
Dale King <DaleWKing@gmail.com> wrote:
>Tim Roberts wrote:
>> "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)
>>
>> This is implementation-defined in C. A compiler is allowed to accept
>> variable names with alphabetic Unicode characters outside of ASCII.
>
>I don't think it is implementation defined. I believe it is actually
>required by the spec.
C99 does have a list of Unicode codepoints that are required to be accepted
in identifiers, although implementations are free to accept other
characters as well. For example, few people realize that Visual C++
accepts the dollar sign $ in an identifier.
--
- Tim Roberts, timr@probo.com
Providenza & Boekelheide, Inc.
------------------------------
Date: Thu, 6 Jul 2006 04:42:06 GMT
From: merlyn@stonehenge.com (Randal Schwartz)
Subject: new CPAN modules on Thu Jul 6 2006
Message-Id: <J1yt26.1EKt@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.
Alien-wxWidgets-0.15
http://search.cpan.org/~mbarbon/Alien-wxWidgets-0.15/
building, finding and using wxWidgets binaries
----
Alien-wxWidgets-0.16
http://search.cpan.org/~mbarbon/Alien-wxWidgets-0.16/
building, finding and using wxWidgets binaries
----
App-SimpleScan-1.12
http://search.cpan.org/~mcmahon/App-SimpleScan-1.12/
simple_scan's core code
----
Bundle-Pugs-SmokeKit-0.06
http://search.cpan.org/~gaal/Bundle-Pugs-SmokeKit-0.06/
Bundle for running Pugs smoke tests
----
Bundle-SimpleScan-0.01
http://search.cpan.org/~mcmahon/Bundle-SimpleScan-0.01/
simple_scan and all the current plugins
----
Business-OnlinePayment-Multiplex-0.01
http://search.cpan.org/~mock/Business-OnlinePayment-Multiplex-0.01/
Perl extension using the Business::OnlinePayment interface to add a callback to the content hash
----
Business-PayPal-API-0.33
http://search.cpan.org/~scottw/Business-PayPal-API-0.33/
PayPal API
----
Catalyst-Plugin-Authorization-ACL-0.07
http://search.cpan.org/~dkamholz/Catalyst-Plugin-Authorization-ACL-0.07/
ACL support for Catalyst applications.
----
Catalyst-Plugin-C3-0.01000_05
http://search.cpan.org/~blblack/Catalyst-Plugin-C3-0.01000_05/
Catalyst Plugin to subvert NEXT to use Class::C3
----
Catalyst-Plugin-Static-Simple-0.14
http://search.cpan.org/~mramberg/Catalyst-Plugin-Static-Simple-0.14/
Make serving static pages painless.
----
Catalyst-Plugin-UserAgent-0.01
http://search.cpan.org/~hanenkamp/Catalyst-Plugin-UserAgent-0.01/
Add a singleton LWP::UserAgent to the context
----
Compress-Zlib-1.42
http://search.cpan.org/~pmqs/Compress-Zlib-1.42/
Interface to zlib compression library
----
Crypt-OTP26-0.02
http://search.cpan.org/~osfameron/Crypt-OTP26-0.02/
a classic form of encryption
----
DJabberd-Authen-DBIC-0.01
http://search.cpan.org/~groditi/DJabberd-Authen-DBIC-0.01/
A DBIC authentication module for DJabberd
----
Data-Bind-0.25
http://search.cpan.org/~clkao/Data-Bind-0.25/
Bind and alias variables
----
DateTime-Calendar-Japanese-Era-0.06
http://search.cpan.org/~dmaki/DateTime-Calendar-Japanese-Era-0.06/
DateTime Extension for Japanese Eras
----
DateTime-Format-Pg-0.12
http://search.cpan.org/~dmaki/DateTime-Format-Pg-0.12/
Parse and format PostgreSQL dates and times
----
Devel-Caller-0.10
http://search.cpan.org/~rclamp/Devel-Caller-0.10/
meatier versions of caller
----
Email-Send-2.11
http://search.cpan.org/~rjbs/Email-Send-2.11/
Simply Sending Email
----
File-Read-0.06
http://search.cpan.org/~saper/File-Read-0.06/
Unique interface for reading one or more files
----
File-ReadSimple.1.0
http://search.cpan.org/~nharale/File-ReadSimple.1.0/
Perl extension for making filehandling very easy for not-so good Perl Programmers.
----
Games-EternalLands-0.01
http://search.cpan.org/~franc/Games-EternalLands-0.01/
----
HTML-Template-Compiled-0.70
http://search.cpan.org/~tinita/HTML-Template-Compiled-0.70/
Template System Compiles HTML::Template files to Perl code
----
HTML-Truncate-0.11
http://search.cpan.org/~ashley/HTML-Truncate-0.11/
(beta software) truncate HTML by percentage or character count while preserving well-formedness.
----
Locale-Maketext-Utils-v0.0.1
http://search.cpan.org/~dmuey/Locale-Maketext-Utils-v0.0.1/
Adds some utility methods and failure handling to Local::Maketext handles
----
Net-DBus-0.33.3
http://search.cpan.org/~danberr/Net-DBus-0.33.3/
Perl extension for the DBus message system
----
Net-SynchroEdit-Service-0.039r2
http://search.cpan.org/~kallewoof/Net-SynchroEdit-Service-0.039r2/
Perl extension for SynchroEdit response service functionality
----
Net-UKDomain-Nominet-Automaton-1.01
http://search.cpan.org/~cliffordj/Net-UKDomain-Nominet-Automaton-1.01/
Module to handle the Nominet Automaton for domain registration and modification.
----
POE-Component-IRC-4.95
http://search.cpan.org/~bingos/POE-Component-IRC-4.95/
a fully event-driven IRC client module.
----
Params-Check-0.25
http://search.cpan.org/~kane/Params-Check-0.25/
A generic input parsing/checking mechanism.
----
Perl-Dist-Vanilla-4
http://search.cpan.org/~dagolden/Perl-Dist-Vanilla-4/
Vanilla Perl for win32
----
Perl-Dist-Vanilla-5
http://search.cpan.org/~dagolden/Perl-Dist-Vanilla-5/
Vanilla Perl for win32
----
Perl-Tags-0.22
http://search.cpan.org/~osfameron/Perl-Tags-0.22/
Generate (possibly exuberant) Ctags style tags for Perl sourcecode
----
Perl-Tags-0.23
http://search.cpan.org/~osfameron/Perl-Tags-0.23/
Generate (possibly exuberant) Ctags style tags for Perl sourcecode
----
SWISH-Filter-0.04
http://search.cpan.org/~karman/SWISH-Filter-0.04/
filter documents for indexing with Swish-e
----
SWISH-Filter-0.05
http://search.cpan.org/~karman/SWISH-Filter-0.05/
filter documents for indexing with Swish-e
----
SWISH-Filter-0.06
http://search.cpan.org/~karman/SWISH-Filter-0.06/
filter documents for indexing with Swish-e
----
SWISH-Prog-0.01
http://search.cpan.org/~karman/SWISH-Prog-0.01/
Perlish interface to the Swish-e -S prog feature
----
Search-Tools-0.01
http://search.cpan.org/~karman/Search-Tools-0.01/
tools for building search applications
----
Sledge-Plugin-Paginate-0.01
http://search.cpan.org/~nekokak/Sledge-Plugin-Paginate-0.01/
data paginate plugin for Sledge
----
Sledge-Plugin-RedirectReferer-0.01
http://search.cpan.org/~nekokak/Sledge-Plugin-RedirectReferer-0.01/
----
Sledge-Plugin-RedirectReferer-0.02
http://search.cpan.org/~nekokak/Sledge-Plugin-RedirectReferer-0.02/
referer redirect plugin for Sledge
----
String-Gsub-0.04
http://search.cpan.org/~hio/String-Gsub-0.04/
regex on string object
----
Task-Smoke-0.10
http://search.cpan.org/~gaal/Task-Smoke-0.10/
Install modules required for Pugs-like smoke system
----
Task-Smoke-0.11
http://search.cpan.org/~gaal/Task-Smoke-0.11/
Install modules required for Pugs-like smoke system
----
Test-HTTP-Server-Simple-0.03
http://search.cpan.org/~glasser/Test-HTTP-Server-Simple-0.03/
Test::More functions for HTTP::Server::Simple
----
Text-MeCab-0.08
http://search.cpan.org/~dmaki/Text-MeCab-0.08/
Alternate Interface To libmecab
----
Text-Restructured-0.003014
http://search.cpan.org/~nodine/Text-Restructured-0.003014/
----
Text-Scan-0.27
http://search.cpan.org/~iwoodhead/Text-Scan-0.27/
Fast search for very large numbers of keys in a body of text.
----
Tie-STDOUT-1.02
http://search.cpan.org/~dcantrell/Tie-STDOUT-1.02/
intercept writes to STDOUT and apply user-defined functions to them.
----
WWW-RobotRules-Parser-0.02
http://search.cpan.org/~dmaki/WWW-RobotRules-Parser-0.02/
Just Parse robots.txt
----
Wx-0.51
http://search.cpan.org/~mbarbon/Wx-0.51/
interface to the wxWidgets cross-platform GUI toolkit
----
XML-RSS-FromHTML-0.02
http://search.cpan.org/~bashi/XML-RSS-FromHTML-0.02/
simple framework for making RSS out of HTML
----
XML-RSS-LibXML-0.23
http://search.cpan.org/~dmaki/XML-RSS-LibXML-0.23/
XML::RSS with XML::LibXML
----
ack-1.22
http://search.cpan.org/~petdance/ack-1.22/
grep-like text finder for large trees of text
----
perl-lint-mode-0.02
http://search.cpan.org/~jjore/perl-lint-mode-0.02/
----
perltidy-mode-0.02
http://search.cpan.org/~jjore/perltidy-mode-0.02/
----
threads-1.33
http://search.cpan.org/~jdhedden/threads-1.33/
Perl interpreter-based threads
----
v6-pugs-0.005
http://search.cpan.org/~audreyt/v6-pugs-0.005/
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: Thu, 06 Jul 2006 01:28:49 -0400
From: "Eric R. Meyers" <ermeyers@adelphia.net>
Subject: Re: Reg: "pattern match read eof" error
Message-Id: <UYCdnXvyocgOAjHZnZ2dnUVZ_rSdnZ2d@adelphia.com>
Dinakar wrote:
> Hi,
> I am using the Telnet module for Cisco Routers Testing Automation.
> Recently i am facing an issue with it on one machine. Script is
> quitting the execution printing "pattern match read eof at line 3030".
> Code at line 3030 is "$session->cmd("exit")".
> Here i am exiting from Cisco Router to the Solaris machine.
> The same code is working fine in other solaris machines. It is
> giving the warning "pattern match read eof at line 3030" to the command
> "$session->cmd("exit")". But it is not quitting the execution.
> Please give me your suggestions regarding this error.
>
> Regards
> Dinakar
You have not provided the code context of the error, so it's difficult to
guess, but you made need something like 'while( !eof() ){...}' or 'last if
eof();' in your processing loop. If everything else is configured the
same, then you may want to remove and replace components on that machine to
identify what hardware may be broken or misconfigured.
------------------------------
Date: 5 Jul 2006 23:39:36 -0700
From: "Ronny" <ro.naldfi.scher@gmail.com>
Subject: Re: Searching a string in a list of delimited fields
Message-Id: <1152167975.779634.117490@j8g2000cwa.googlegroups.com>
Paul Lalli schrieb:
> Ronald Fischer wrote:
> > List::MoreUtils,
> > according to the CPAN site, seems to be made for Perl 5.8.4 and beyond
>
> What part of "the CPAN site" suggests that? I see at the bottom of
> List::MoreUtils documentation the notice that the module can be
> distributed with the same terms as either 5.8.4 or any post-5.0 version
> of Perl.
Actually it was this part - the explicit mentioning of 5.8.4 - which
made
me think that it can't be distributed with earlier versions of Perl,
from which
I had concluded that it doesn't run with earlier version. I wondered of
course
what the reference to "post-5.0" meant....
> I further see in the source code of the module:
> package List::MoreUtils;
> use 5.00503;
This is really where I should looked at in the first place. Thank you
for pointing this out.
Ronald
------------------------------
Date: 5 Jul 2006 15:32:29 -0700
From: premgrps@gmail.com
Subject: smarter zipcode search algorithm
Message-Id: <1152138748.856866.214290@l70g2000cwa.googlegroups.com>
Hi,
I have a database with two tables
a) A table of 2 million records with city, zip and associated
information (say XYZ) and
b) zipcode latitude, longitude table having >40,000 records/zip codes
PROBLEM:
I need to find the the XYZs within the the range of a certain zipcode.
This zipcode and radial range in miles is entered by the user (web
interface).
The brute force way is to calculate the distance between the user
zipcode and all the zipcodes in the database. Once the zipcode_range
subroutine gives back the zipcodes within a certain radius, I need to
find all the XYZs from the table #1.
Another approach is to find the zipcodes with a square region (min/max
of the user zipcode latitude/longitude position).
Both the approaches are consuming too much time. Especially if the
radial distance starts increasing.
My questions:
1. Is there any other smart way to do the above task.
2. I am working on a 2.4ghz/512MB RAM machine. Any suggestions how to
increase the performance. Right now each select command to the
2Million record table takes about a minute.
Thanks.
------------------------------
Date: Thu, 6 Jul 2006 01:19:24 +0200
From: "Dr.Ruud" <rvtol+news@isolution.nl>
Subject: Re: smarter zipcode search algorithm
Message-Id: <e8hofl.1ek.1@news.isolution.nl>
premgrps@gmail.com schreef:
> I have a database with two tables
> a) A table of 2 million records with city, zip and associated
> information (say XYZ) and
> b) zipcode latitude, longitude table having >40,000 records/zip codes
>
> PROBLEM:
> I need to find the the XYZs within the the range of a certain zipcode.
> This zipcode and radial range in miles is entered by the user (web
> interface).
>
> The brute force way is to calculate the distance between the user
> zipcode and all the zipcodes in the database. Once the zipcode_range
> subroutine gives back the zipcodes within a certain radius, I need to
> find all the XYZs from the table #1.
>
> Another approach is to find the zipcodes with a square region (min/max
> of the user zipcode latitude/longitude position).
>
> Both the approaches are consuming too much time. Especially if the
> radial distance starts increasing.
>
> My questions:
> 1. Is there any other smart way to do the above task.
> 2. I am working on a 2.4ghz/512MB RAM machine. Any suggestions how to
> increase the performance. Right now each select command to the
> 2Million record table takes about a minute.
This is not a Perl question.
Which RDBMS?
1. Make sure there are indexes on the lattitude and longitude columns of
the zipcode table. I assume that zipcode is the PK.
2. Pre-calculate the (min_lattitude, max_lattitude, min_longitude,
max_longitude) from the user input.
3. Fill a temporary zipcode table (again with the same indexes) with a
selection from the full zipcode table, with only the candidate zipcodes.
Be sure to have the zipcode column left from the comparison:
WHERE (zipcode.lattitude >= min_lattitude AND zipcode.lattitude <=
max_lattitude AND zipcode.longtitude >= min_longtitude AND
zipcode.longtitude <= max_longtitude).
4. If necessary, refine that result (the temporary zipcode table) by
deleting the records that aren't in the radial distance.
That temporary zipcode table can also be a query, on which you run the
second (radial distance) query.
For the city table, have an index on the zipcode, and join that with the
(refined) result.
--
Affijn, Ruud
"Gewoon is een tijger."
------------------------------
Date: 06 Jul 2006 05:42:43 GMT
From: Ben Bacarisse <spam@bsb.me.uk>
Subject: Re: unicode
Message-Id: <44aca2d3$0$4382$da0feed9@news.zen.co.uk>
nicolas_laurent545@hotmail.com wrote:
>
> Tobias Witek a écrit :
>
>> nicolas_laurent545@hotmail.com wrote:
>> > This command perl -pi -e 's/(\p{IsAplha}+)(é)(\s)/($1$2)/g' text.txt
>> > returns
>> > Can't find Unicode property definition "Aplha" at -e line 1, <> line 1.
>> >
>> > What should I do to correct the problem ?
>>
>> I guess you could probably try to spell "Alpha" correctly.
>>
>> I am not an expert in Perl, but that might fix your problem :-D
>
> I am sorry but still have the problem with unicode.
>
> perl -pi -e 's/(\p{IsAlpha}+)(é)(\s)/($1$2)/g' text.txt
> This tell perl to take this as input
> input:détrôné ôperaé ôpéraé tônâné tûtéé
> expected output:(détrôné) (ôperaé) (ôpéraé) (tônâné)
> (tûtéé)
> actual output: détrô(né)ô(peraé)ôpé(raé)tônâ(né)tûtéé
>
There are two separate issues:
(a) the IO layer must use (and expect) UTF-8;
(b) the program source includes a UTF-8 encoded character (é).
My version 5.8.0 is such that "use utf8;" is still required for (b)
and I must turn on UTF-8 encoding of IO using the -C option to achieve
(a), so
perl -C -pi -e 'use utf8; s/(\p{IsAlpha}+)(é)(\s)/($1$2)/g' text.txt
works for me. To avoid the "use utf8;" just write the é as \x{E9} and
you can avoid the -C flag by setting PERL_UNICODE.
I found "perldoc perluniintro" very informative.
--
Ben.
------------------------------
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 9428
***************************************