[30689] in Perl-Users-Digest
Perl-Users Digest, Issue: 1934 Volume: 11
daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Mon Oct 20 06:09:43 2008
Date: Mon, 20 Oct 2008 03:09:08 -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 Mon, 20 Oct 2008 Volume: 11 Number: 1934
Today's topics:
Re: "Escape" in perl <rvtol+news@isolution.nl>
Re: E-commerce script desired <vilain@NOspamcop.net>
Re: Edit file in place using perl script <mushtaqk921@gmail.com>
Re: Edit file in place using perl script <someone@example.com>
new CPAN modules on Mon Oct 20 2008 (Randal Schwartz)
Re: Parsing CSV and " " sln@netherlands.com
Re: Procedural interface to mysql xhoster@gmail.com
Re: Procedural interface to mysql <whynot@pozharski.name>
Re: Procedural interface to mysql <john@castleamber.com>
Scalar variable in void context before a loop (Mark Hobley)
Re: Scalar variable in void context before a loop <tim@burlyhost.com>
Re: Scalar variable in void context before a loop <someone@example.com>
Re: Scalar variable in void context before a loop (Mark Hobley)
split a multiple lines text <bfzhao@gmail.com>
Digest Administrivia (Last modified: 6 Apr 01) (Perl-Users-Digest Admin)
----------------------------------------------------------------------
Date: Mon, 20 Oct 2008 11:10:30 +0200
From: "Dr.Ruud" <rvtol+news@isolution.nl>
Subject: Re: "Escape" in perl
Message-Id: <gdhp5g.1k8.1@news.isolution.nl>
sln@netherlands.com schreef:
> '%'.uc sprintf("%x", ord($1))
After some cleaning it would look more like this:
sprintf "%%%X", ord $1
--
Affijn, Ruud
"Gewoon is een tijger."
------------------------------
Date: Sun, 19 Oct 2008 23:49:53 -0700
From: Michael Vilain <vilain@NOspamcop.net>
Subject: Re: E-commerce script desired
Message-Id: <vilain-6FA8EE.23495319102008@feeder.motzarella.org>
In article
<373345de-5df1-4c6d-b0a4-52b43f6702d7@p59g2000hsd.googlegroups.com>,
jfbryan@gmail.com wrote:
> On Oct 18, 1:07 am, Michael Vilain <vil...@NOspamcop.net> wrote:
> > In article
> > <63c9040e-b750-4a43-b052-526f0822b...@k7g2000hsd.googlegroups.com>,
> >
> > jfbr...@gmail.com wrote:
> > > I am looking for a script (preferably Perl) that will require a
> > > visitor to register (on a web registration page) and then be presented
> > > with various successive affiliate website offers before concluding.
> >
> > There are ecommerce packages out there, some commercial and some free.
> > OScommerce is the one I see offered on web hosting sites. Many of them
> > can be customized to work with your credit card processor. You want to
> > hire a web programmer to find a compatible web hosting company, setup a
> > site for you, acquire the software, configure it, and setup the
> > eCommerce stuff for you. Asking for help off news groups isn't going to
> > get you very far.
> >
> > --
> > DeeDee, don't press that button! DeeDee! NO! Dee...
> > [I filter all Goggle Groups posts, so any reply may be automatically by
> > ignored]
>
> Michael:
>
> Thanks for replying. Based on Tim's and your leads and further
> research, I came across a website with the type of functionality that
> I have in mind.
>
> http://producttestpanel.com and the site claims to use "Accu Offer" as
> an engine
>
> Do you happen to know how I can adopt this for my site?
>
> Thanks,
> James
Haven't a clue. "Buy a man a fish and you feed him for one day. Teach
a man to fish..."
--
DeeDee, don't press that button! DeeDee! NO! Dee...
[I filter all Goggle Groups posts, so any reply may be automatically by ignored]
------------------------------
Date: Mon, 20 Oct 2008 00:25:57 -0700 (PDT)
From: khan <mushtaqk921@gmail.com>
Subject: Re: Edit file in place using perl script
Message-Id: <3c1ac234-2a07-4b6b-ae5c-3ba10cf37139@w24g2000prd.googlegroups.com>
On Oct 17, 10:37=A0pm, Tim Greer <t...@burlyhost.com> wrote:
> khan wrote:
> > Hi,
>
> > I have a requirement where i need to edit the file, based on some
> > tokens.
> > My requirement is something like this:
> > 1. If token1 is found delete that line =A0from the file.
> > 2. If token2 is found replace some part of that line with replacement
> > string.
> > 3. If token3 is found delete that line and next line in the file.
>
> > I wrote a script to do this, but since file-pointer is moved after
> > reading it is not editing the file at correct positions.
> > Please let me know a solution.
>
> > Thanks,
> > -Mushtaq Khan
>
> Please show the code from the script that you said you have already
> created to do this, and people can point out the problem with it.
> --
> Tim Greer, CEO/Founder/CTO, BurlyHost.com, Inc.
> Shared Hosting, Reseller Hosting, Dedicated & Semi-Dedicated servers
> and Custom Hosting. =A024/7 support, 30 day guarantee, secure servers.
> Industry's most experienced staff! -- Web Hosting With Muscle!- Hide quot=
ed text -
>
> - Show quoted text -
Hi,
I want change the file without using the temporary file. Following is
script but it is not working
$File =3D "D:\\PerlProgramming\\Serach-pattren\\file.txt";
open(FILE, "+<",$File) or die "can't open $File: $!";
while (<FILE>) {
if(m/Anand/) {
$_ =3D~ s/Football/Cricket/s; #Susbst Football with Cricket
print FILE $_;
}
elsif(m/Jack/) {
$_ =3D~ s/^.*\n$//s; #Delete the Line
print FILE $_;
}
}
close (FILE);
exit;
#Input file: file.txt
Anand Football
Adam Football
Jack Tennis
Jhon Hockey
#Output with the Above script : file.txt
Anand Football
Adam Football
Jack Tennis
Jhon Hockey
Anand Football
Adam Cricket
Jhon Hockey
Script is adding modified data to the end of file, i really didn't
understand the behaviour of the script.
#Output what i was expecting : file.txt should have lines
Anand Football
Adam Cricket
Jhon Hockey
The following script works but it uses a temporary file for storing
modified data.
I think this is not an efficient way to do this.
$File =3D "D:\\PerlProgramming\\Serach-pattren\\file.txt";
$FileOut =3D "D:\\PerlProgramming\\Serach-pattren\\fileout.txt";
open(FILE, "+<",$File) or die "can't open $File: $!";
open(OUT, ">",$FileOut) or die "can't open $FileOut: $!";
while (<FILE>) {
if(m/Anand/) {
$_ =3D~ s/Football/Cricket/s;
print OUT $_;
}
elsif(m/Jack/) {
$_ =3D~ s/^.*\n$//s; #Delete the Line
print OUT $_;
}
else {
print OUT $_;
}
}
close (FILE);
close (OUT);
system ("del D:\\PerlProgramming\\Serach-pattren\\file.txt /Q");
system ("ren D:\\PerlProgramming\\Serach-pattren\\fileout.txt
file.txt");
exit
------------------------------
Date: Mon, 20 Oct 2008 02:26:10 -0700
From: "John W. Krahn" <someone@example.com>
Subject: Re: Edit file in place using perl script
Message-Id: <O8YKk.6826$TX6.1836@newsfe06.iad>
khan wrote:
>
> On Oct 17, 10:37 pm, Tim Greer <t...@burlyhost.com> wrote:
>>
>> khan wrote:
>>>
>>> I have a requirement where i need to edit the file, based on some
>>> tokens.
>>> My requirement is something like this:
>>> 1. If token1 is found delete that line from the file.
>>> 2. If token2 is found replace some part of that line with replacement
>>> string.
>>> 3. If token3 is found delete that line and next line in the file.
>>> I wrote a script to do this, but since file-pointer is moved after
>>> reading it is not editing the file at correct positions.
>>> Please let me know a solution.
>>
>> Please show the code from the script that you said you have already
>> created to do this, and people can point out the problem with it.
>
> I want change the file without using the temporary file. Following is
> script but it is not working
>
> $File = "D:\\PerlProgramming\\Serach-pattren\\file.txt";
> open(FILE, "+<",$File) or die "can't open $File: $!";
>
> while (<FILE>) {
> if(m/Anand/) {
> $_ =~ s/Football/Cricket/s; #Susbst Football with Cricket
The /s option affects the behaviour of the . character class but you are
not using . in the pattern so the /s is superfluous.
> print FILE $_;
> }
> elsif(m/Jack/) {
> $_ =~ s/^.*\n$//s; #Delete the Line
> print FILE $_;
If you want to delete the line why are you printing it out?
> }
> }
> close (FILE);
> exit;
You are opening the file for input *AND* output ("+<") so you have one
filehandle and one pointer to the data in the file. When you read the
first record the pointer moves to the end of that record and then you
write a record, overwriting the second record in the file and moving the
pointer to the end of what you have just written, and then the next read
starts at that point and moves the pointer, and the next write which
again moves the pointer, etc., etc.
> #Input file: file.txt
> Anand Football
> Adam Football
> Jack Tennis
> Jhon Hockey
> #Output with the Above script : file.txt
> Anand Football
> Adam Football
> Jack Tennis
> Jhon Hockey
> Anand Football
> Adam Cricket
> Jhon Hockey
>
> Script is adding modified data to the end of file, i really didn't
> understand the behaviour of the script.
> #Output what i was expecting : file.txt should have lines
> Anand Football
> Adam Cricket
> Jhon Hockey
>
> The following script works but it uses a temporary file for storing
> modified data.
> I think this is not an efficient way to do this.
Why do you think that it is not efficient?
> $File = "D:\\PerlProgramming\\Serach-pattren\\file.txt";
> $FileOut = "D:\\PerlProgramming\\Serach-pattren\\fileout.txt";
>
> open(FILE, "+<",$File) or die "can't open $File: $!";
> open(OUT, ">",$FileOut) or die "can't open $FileOut: $!";
>
> while (<FILE>) {
> if(m/Anand/) {
> $_ =~ s/Football/Cricket/s;
> print OUT $_;
> }
> elsif(m/Jack/) {
> $_ =~ s/^.*\n$//s; #Delete the Line
> print OUT $_;
> }
> else {
> print OUT $_;
> }
> }
> close (FILE);
> close (OUT);
> system ("del D:\\PerlProgramming\\Serach-pattren\\file.txt /Q");
perldoc -f unlink
> system ("ren D:\\PerlProgramming\\Serach-pattren\\fileout.txt
perldoc -f rename
> file.txt");
> exit
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: Mon, 20 Oct 2008 04:42:22 GMT
From: merlyn@stonehenge.com (Randal Schwartz)
Subject: new CPAN modules on Mon Oct 20 2008
Message-Id: <K90t2M.9MI@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.
Abstract-Meta-Class-0.12
http://search.cpan.org/~adrianwit/Abstract-Meta-Class-0.12/
Simple meta object protocol implementation.
----
Acme-PlayCode-0.01
http://search.cpan.org/~fayland/Acme-PlayCode-0.01/
Play code to win
----
Acme-PlayCode-0.02
http://search.cpan.org/~fayland/Acme-PlayCode-0.02/
Play code to win
----
Acme-PlayCode-0.03
http://search.cpan.org/~fayland/Acme-PlayCode-0.03/
Play code to win
----
Acme-Study-Perl-0.0.1
http://search.cpan.org/~andk/Acme-Study-Perl-0.0.1/
empirical studies about how perl behaves
----
App-Hachero-0.02
http://search.cpan.org/~danjou/App-Hachero-0.02/
a plaggable log analyzing framework
----
Atompub-0.3.2
http://search.cpan.org/~takeru/Atompub-0.3.2/
Atom Publishing Protocol implementation
----
B-Hooks-EndOfScope-0.01
http://search.cpan.org/~flora/B-Hooks-EndOfScope-0.01/
Execute code after a scope finished compilation
----
B-Hooks-EndOfScope-0.02
http://search.cpan.org/~flora/B-Hooks-EndOfScope-0.02/
Execute code after a scope finished compilation
----
B-Hooks-OP-Check-0.12
http://search.cpan.org/~flora/B-Hooks-OP-Check-0.12/
Wrap OP check callbacks
----
B-Hooks-OP-Check-StashChange-0.01
http://search.cpan.org/~flora/B-Hooks-OP-Check-StashChange-0.01/
Invoke callbacks when the stash code is being compiled in changes
----
BerkeleyDB-Manager-0.08
http://search.cpan.org/~nuffin/BerkeleyDB-Manager-0.08/
General purpose BerkeleyDB wrapper
----
Business-3DSecure-Cardinal-0.06
http://search.cpan.org/~drfrog/Business-3DSecure-Cardinal-0.06/
Perl extension for 3DSecure authentication using Cardinal
----
CGI-Application-Plugin-RunmodeDeclare-0.03
http://search.cpan.org/~rhesa/CGI-Application-Plugin-RunmodeDeclare-0.03/
Declare runmodes with keywords
----
CGI-FormBuilder-Source-Perl-0.01
http://search.cpan.org/~evdb/CGI-FormBuilder-Source-Perl-0.01/
read FormBuilder config from Perl syntax files
----
CPAN-Testers-ParseReport-0.0.12
http://search.cpan.org/~andk/CPAN-Testers-ParseReport-0.0.12/
parse reports to www.cpantesters.org from various sources
----
Catalyst-Controller-Atompub-0.5.2
http://search.cpan.org/~takeru/Catalyst-Controller-Atompub-0.5.2/
A Catalyst controller for the Atom Publishing Protocol
----
Catalyst-Controller-Atompub-0.5.3
http://search.cpan.org/~takeru/Catalyst-Controller-Atompub-0.5.3/
A Catalyst controller for the Atom Publishing Protocol
----
Catalyst-View-RRDGraph-0.02
http://search.cpan.org/~jlmartin/Catalyst-View-RRDGraph-0.02/
RRD Graph View Class
----
Data-CloudWeights-0.2.66
http://search.cpan.org/~pjfl/Data-CloudWeights-0.2.66/
Calculate values for an HTML tag cloud
----
DateTime-Format-Natural-0.73_01
http://search.cpan.org/~schubiger/DateTime-Format-Natural-0.73_01/
Create machine readable date/time with natural parsing logic
----
Devel-DProf-20080628_01
http://search.cpan.org/~jaw/Devel-DProf-20080628_01/
tell me why my perl program runs so slowly
----
Devel-Declare-0.002002
http://search.cpan.org/~flora/Devel-Declare-0.002002/
----
Don-Mendo-0.0.3
http://search.cpan.org/~jmerelo/Don-Mendo-0.0.3/
Modules for "La venganza de Don Mendo", Sir Mendo's revenge.
----
ExtUtils-PkgConfig-1.12
http://search.cpan.org/~tsch/ExtUtils-PkgConfig-1.12/
simplistic interface to pkg-config
----
Gnaw-0.05
http://search.cpan.org/~gslondon/Gnaw-0.05/
Define parse grammars using perl subroutine calls. No intermediate grammar languages.
----
Gtk2-1.201
http://search.cpan.org/~tsch/Gtk2-1.201/
Perl interface to the 2.x series of the Gimp Toolkit library
----
Lingua-JA-Regular-Unicode-0.01
http://search.cpan.org/~tokuhirom/Lingua-JA-Regular-Unicode-0.01/
convert japanese chars.
----
MooseX-Declare-0.01_01
http://search.cpan.org/~flora/MooseX-Declare-0.01_01/
Declarative syntax for Moose
----
MooseX-MutatorAttributes-0.11
http://search.cpan.org/~notbenh/MooseX-MutatorAttributes-0.11/
Moose Role to add a quick set method that returns self
----
MooseX-Types-IO-0.01
http://search.cpan.org/~fayland/MooseX-Types-IO-0.01/
IO related constraints and coercions for Moose
----
MooseX-Types-IO-0.02
http://search.cpan.org/~fayland/MooseX-Types-IO-0.02/
IO related constraints and coercions for Moose
----
Net-CIDR-MobileJP-0.16
http://search.cpan.org/~tokuhirom/Net-CIDR-MobileJP-0.16/
mobile ip address in Japan
----
Net-Write-1.04
http://search.cpan.org/~gomor/Net-Write-1.04/
a portable interface to open and send raw data to network
----
OAuth-Lite-1.14
http://search.cpan.org/~lyokato/OAuth-Lite-1.14/
OAuth framework
----
PAR-Repository-0.16_01
http://search.cpan.org/~smueller/PAR-Repository-0.16_01/
Create and modify PAR repositories
----
PAR-Repository-Client-0.20
http://search.cpan.org/~smueller/PAR-Repository-Client-0.20/
Access PAR repositories
----
PDL-2.4.3_01
http://search.cpan.org/~chm/PDL-2.4.3_01/
the Perl Data Language
----
POE-Component-IRC-Plugin-WWW-LimerickDB-0.0101
http://search.cpan.org/~zoffix/POE-Component-IRC-Plugin-WWW-LimerickDB-0.0101/
display random limericks on IRC
----
POE-Component-Syntax-Highlight-CSS-0.0101
http://search.cpan.org/~zoffix/POE-Component-Syntax-Highlight-CSS-0.0101/
non-blocking wrapper around Syntax::Highlight::CSS
----
POE-Component-Syntax-Highlight-CSS-0.0102
http://search.cpan.org/~zoffix/POE-Component-Syntax-Highlight-CSS-0.0102/
non-blocking wrapper around Syntax::Highlight::CSS
----
POE-Component-Syntax-Highlight-HTML-0.0101
http://search.cpan.org/~zoffix/POE-Component-Syntax-Highlight-HTML-0.0101/
non-blocking wrapper around Syntax::Highlight::HTML
----
POE-Component-WWW-LimerickDB-0.0102
http://search.cpan.org/~zoffix/POE-Component-WWW-LimerickDB-0.0102/
non-blocking wrapper around WWW::LimerickDB
----
POE-Component-WWW-LimerickDB-0.0103
http://search.cpan.org/~zoffix/POE-Component-WWW-LimerickDB-0.0103/
non-blocking wrapper around WWW::LimerickDB
----
Perl-Dist-1.08
http://search.cpan.org/~adamk/Perl-Dist-1.08/
Perl Distribution Creation Toolkit
----
PostScript-MailLabels-2.26
http://search.cpan.org/~ajackson/PostScript-MailLabels-2.26/
Modules for creating PostScript(tm) files of mailing address labels.
----
Provision-Unix-0.29
http://search.cpan.org/~msimerson/Provision-Unix-0.29/
provision accounts on unix systems
----
SVN-Dumpfile-0.13.106
http://search.cpan.org/~mscharrer/SVN-Dumpfile-0.13.106/
Perl extension to access and manipulate Subversion dumpfiles
----
Task-BeLike-FAYLAND-0.05
http://search.cpan.org/~fayland/Task-BeLike-FAYLAND-0.05/
Modules Fayland loves!
----
Text-ParseWords-3.25_02
http://search.cpan.org/~chorny/Text-ParseWords-3.25_02/
parse text into an array of tokens or array of arrays
----
WWW-LimerickDB-0.0303
http://search.cpan.org/~zoffix/WWW-LimerickDB-0.0303/
interface to fetch limericks from http://limerickdb.com/
----
WWW-LimerickDB-0.0304
http://search.cpan.org/~zoffix/WWW-LimerickDB-0.0304/
interface to fetch limericks from http://limerickdb.com/
----
Wiki-Toolkit-Plugin-JSON-0.01
http://search.cpan.org/~dom/Wiki-Toolkit-Plugin-JSON-0.01/
A Wiki::Toolkit plugin to output RecentChanges JSON.
----
YUM-RepoQuery-0.1.0
http://search.cpan.org/~rsrchboy/YUM-RepoQuery-0.1.0/
Query a YUM repository for package information
----
perlindex-1.600
http://search.cpan.org/~ulpfr/perlindex-1.600/
index and query perl manual pages
----
perlindex-1.601
http://search.cpan.org/~ulpfr/perlindex-1.601/
index and query perl manual pages
----
perlindex-1.602
http://search.cpan.org/~ulpfr/perlindex-1.602/
index and query perl manual pages
----
perlindex-1.603
http://search.cpan.org/~ulpfr/perlindex-1.603/
index and query perl manual pages
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/>
Smalltalk/Perl/Unix consulting, Technical writing, Comedy, etc. etc.
See http://methodsandmessages.vox.com/ for Smalltalk and Seaside discussion
------------------------------
Date: Sun, 19 Oct 2008 23:21:52 GMT
From: sln@netherlands.com
Subject: Re: Parsing CSV and " "
Message-Id: <sufnf4dmoadhqgj36oqa5e77n92uc9d90a@4ax.com>
On Sun, 19 Oct 2008 08:42:04 -0700 (PDT), hotkitty <stpra123@gmail.com> wrote:
>On Oct 13, 12:28 pm, s...@netherlands.com wrote:
>> On Sat, 11 Oct 2008 21:47:27 GMT, s...@netherlands.com wrote:
>>
>> [snip]
>>
>> Small change's ..
>>
>> - For performance, the transliteration was changed to count $tmp string.
>> - Added the span modifier on the regex loop.
>> Thus the option below to keep newlines, and have the original formatting intact,
>> ie: bullet point location's etc...
>> Just (un)comment the block that is needed. Try it both ways.
>>
>> #############
>> # Csv3 Regex
>> #############
>>
>> #http://www.nasdaq.com//asp/symbols.asp?exchange=Q&start=0
>>
>> use strict;
>> use warnings;
>>
>> my $fname = 'c:\temp\symbols.csv';
>> open CSV, $fname or die "can't open $fname...";
>>
>> my ($row, $tmp) = ('','');
>> my ($parsing, $records, $quotes) = (1,1,0);
my $MarketValueTotal = 0;
>>
>> while ($parsing)
>> {
>> ## Buffer until a full row
>> ## -------------------------
>> if (!($_ = <CSV>)) {
>> $parsing = 0; # eof, parse what's left
>> } else {
>> $tmp = $_;
>>
>> ## this block will trim newlines ---
>> $tmp =~ s/\s+$//s;
>> next if (!length($tmp));
>> $row .= " $tmp";
>> ## ---
>>
>> ## this block will keep newlines ---
>> # $row .= $tmp;
>> ## ---
>>
>> $quotes += $tmp =~ tr/"//;
>> next if (!($quotes % 2 == 0)); # Even number of double quotes?
>> } # Good to go, parse it ...
>>
>> print " (".$records++.") ----------\n";
>>
>> ## Parse the row
>> ## -------------------
my $field = 0;
>> while ($row =~ /\s*"\s*([^"]*?)\s*"\s*,|\s*"\s*(.*?)\s*"\s*$/gs) # span lines
>> {
>> my $val = $1;
>> if (defined $2) {
>> # cleanup the description field
>> # ------------------------------
>> $val = $2;
>> $val =~ s/""/"/g;
>> $val =~ s/\.\.\. More\.\.\.//ig;
>> $val =~ s/ / /ig;
>> }
if ($field++ == 4)
{
if ($val =~ /^[\$,\.\d]+$/)
{
$val =~ s/[\$,]//g;
$MarketValueTotal += $val;
print "val = $val\n";
}
else { print STDERR "'$val' is not numeric, record = ".($records-1)."\n";}
}
>> # print "val = $val\n";
>> }
>> $row = '';
>> $quotes = 0;}
>>
>> close CSV;
>>
print STDERR "Market Value Total = $MarketValueTotal (in millions)\n";
>> __END__
>
output:
'Market Value (millions)' is not numeric, record = 2
'N/A' is not numeric, record = 3122
Market Value Total = 2650685.5 (in millions)
>This works great! Now, I realize that my next question should be
>categorized in the beginner's group but for whatever reason I will
>post here:
>How would I just print out every 4th occurrence of $val (i.e. the
>Market Value column)?
>
Not bad, NASDAQ ~ 2.6 trillion dollars.
sln
------------------------------
Date: 19 Oct 2008 21:04:51 GMT
From: xhoster@gmail.com
Subject: Re: Procedural interface to mysql
Message-Id: <20081019170515.955$4l@newsreader.com>
"Peter J. Holzer" <hjp-usenet2@hjp.at> wrote:
> On 2008-10-19 18:40, Lars Eighner <usenet@larseighner.com> wrote:
> > In our last episode, <ZeKKk.8085$YN3.1052@newsfe12.iad>, the lovely and
> > talented Tim Greer broadcast on comp.lang.perl.misc:
> >> Lars Eighner wrote:
> >>>> What would a "procedural interface" give you that DBI doesn't?
> >>>
> >>> No objects. So it would be faster, simpler, more intuitive, more
> >>> easily made to do what I want to do instead of what someone thinks I
> >>> ought to want to do.
> >>>
> >
> >> Honestly, that would be such a negligible amount of overhead, and it's
> >> pretty intuitive already. If you're worried about speed, you should
> >> consider converting to C and compiling.
> >
> > I'm gathering, then, that I will have to write my own, because all
> > database acess in perl is through the OO DBI.
You could always figure out what the magic package names are and make the
calls procedurally:
$h = get_connection_without_disclosing_password();
print $h;
print $h->selectrow_array("select count(*) from foodata");
print DBI::db::selectrow_array($h,"select count(*) from foodata");
__END__
DBI::db=HASH(0x981a80)
228139983
228139983
You could even make your own wrappers to remember the package names for
you.
> Back in the perl 4 days, there used to be Oraperl, a procedural (because
> perl didn't do OO yet) interface to Oracle. As an interface it still
> exists, but these days it just uses DBI in the background. So it won't
> be any faster, and it doesn't look simpler to me (well it does, but
> that's because it does a lot less - the functionality that Oraperl
> provides is just as simple in DBI).
Sure, but you don't have an irrational hatred of OO like our friend does.
Xho
--
-------------------- http://NewsReader.Com/ --------------------
The costs of publication of this article were defrayed in part by the
payment of page charges. This article must therefore be hereby marked
advertisement in accordance with 18 U.S.C. Section 1734 solely to indicate
this fact.
------------------------------
Date: Mon, 20 Oct 2008 00:38:55 +0300
From: Eric Pozharski <whynot@pozharski.name>
Subject: Re: Procedural interface to mysql
Message-Id: <slrngfna7f.q90.whynot@orphan.zombinet>
On 2008-10-19, Lars Eighner <usenet@larseighner.com> wrote:
> In our last episode,
><slrngfm69g.ksq.hjp-usenet2@hrunkner.hjp.at>, the lovely and talented
>Peter J. Holzer broadcast on comp.lang.perl.misc:
*SKIP*
>> What would a "procedural interface" give you that DBI doesn't?
> No objects. So it would be faster, simpler, more intuitive, more
> easily made to do what I want to do instead of what someone thinks I
> ought to want to do.
Consider this -- Perl's "objects" aren't actually objects in OO sense,
they are "blessed references". Inheritance, methods, constructors etc
are no more than side-effect of blessing *anything* into *package* (not
a class actually).
As soon as you must keep state, you either bless or push responcibility
of knowing what that particular data structure is onto user. In your
case, you must keep state -- you'll end up with hash, I think. And here
either your user must track what that unblessed hash is or Perl will do
that for them.
Next. Don't say that you don't know that these statements are pretty
same: C<$hashref->method($arg);> vs C<method $hashref, $arg;>. The
difference is that in second case there's place for lots of burden.
Next. B<DBI> isn't OO. I see aggregation; I see methods; I don't see
inheritance. Would you like to point at any class that actually
inherits from B<DBI> (OK, I didn't verified that, so I can be
incompetent, as ever)?
And you must know that B<DBI> isn't pure Perl. I think, that any
implementation of the same functionality in pure Perl would be slower.
What functionality would you like to sacrifice for purity? XS on some
API (libmysqlclient in your case)? What you gain in that case? Speed?
Of what? How much time you're going to spend till you'll get working
implementation?
OK. That can be a challenge. I like challenges, they are good cause to
make world better. And I really would like to hear your success story.
But don't complain that you're the only user.
--
Torvalds' goal for Linux is very simple: World Domination
------------------------------
Date: 20 Oct 2008 02:08:00 GMT
From: John Bokma <john@castleamber.com>
Subject: Re: Procedural interface to mysql
Message-Id: <Xns9B3CD6FB1528Dcastleamber@130.133.1.4>
Eric Pozharski <whynot@pozharski.name> wrote:
> Would you like to point at any class that actually
> inherits from B<DBI>
*points at a class I've written for a customer*
Oh, and I found one for you that's on CPAN:
<http://search.cpan.org/src/TIMB/DBI-1.607/lib/DBI/ProxyServer.pm>
-> @ISA = qw(RPC::PlServer DBI);
--
John http://johnbokma.com/ - Hacking & Hiking in Mexico
Perl help in exchange for a gift:
http://johnbokma.com/perl/help-in-exchange-for-a-gift.html
------------------------------
Date: Mon, 20 Oct 2008 06:49:27 +0100
From: markhobley@hotpop.donottypethisbit.com (Mark Hobley)
Subject: Scalar variable in void context before a loop
Message-Id: <7oits5-6d7.ln1@neptune.markhobley.yi.org>
Keywords: perl,scalar,variable,void,context
In my professional perl programming guide, some of the examples put the
variable to be used as an iterator in void context before the loop. For
example:
$l;
for ($l = 0; $l < 10; $l++) {
print $l;
}
I am curious as to what reasons there are for doing this, because there
does not appear to be any mention of it anywhere within the book.
Mark.
--
Mark Hobley
Linux User: #370818 http://markhobley.yi.org/
------------------------------
Date: Sun, 19 Oct 2008 23:10:49 -0700
From: Tim Greer <tim@burlyhost.com>
Subject: Re: Scalar variable in void context before a loop
Message-Id: <KhVKk.3043$B72.2349@newsfe19.iad>
Mark Hobley wrote:
> In my professional perl programming guide, some of the examples put
> the variable to be used as an iterator in void context before the
> loop. For example:
>
> $l;
> for ($l = 0; $l < 10; $l++) {
> print $l;
> }
>
> I am curious as to what reasons there are for doing this, because
> there does not appear to be any mention of it anywhere within the
> book.
>
> Mark.
>
Are you sure it wasn't $| before the loop? Or, perhaps it was a "my
$l"? Can you type the entire code here up to that point (or the
relevant portions anyway) -- the actual code, rather than an example,
so you can get the appropriate answer?
--
Tim Greer, CEO/Founder/CTO, BurlyHost.com, Inc.
Shared Hosting, Reseller Hosting, Dedicated & Semi-Dedicated servers
and Custom Hosting. 24/7 support, 30 day guarantee, secure servers.
Industry's most experienced staff! -- Web Hosting With Muscle!
------------------------------
Date: Sun, 19 Oct 2008 23:16:14 -0700
From: "John W. Krahn" <someone@example.com>
Subject: Re: Scalar variable in void context before a loop
Message-Id: <KmVKk.1579$Kf6.1264@newsfe05.iad>
Mark Hobley wrote:
> In my professional perl programming guide, some of the examples put the
> variable to be used as an iterator in void context before the loop. For
> example:
>
> $l;
> for ($l = 0; $l < 10; $l++) {
> print $l;
> }
>
> I am curious as to what reasons there are for doing this, because there
> does not appear to be any mention of it anywhere within the book.
There is no reason, and in fact if you had had warnings enabled then
perl would have informed you that there was no reason. You should have
these two lines at the beginning of your program:
use warnings;
use strict;
To help you catch mistakes like this.
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: Mon, 20 Oct 2008 09:40:32 +0100
From: markhobley@hotpop.donottypethisbit.com (Mark Hobley)
Subject: Re: Scalar variable in void context before a loop
Message-Id: <0psts5-fg7.ln1@neptune.markhobley.yi.org>
Tim Greer <tim@burlyhost.com> wrote:
> Are you sure it wasn't $| before the loop?
What is that?
> Or, perhaps it was a "my $l"?
Now that would have made more sense. This occurs a couple of times
throughout the book. I bet it is a misprint.
> Can you type the entire code here up to that point (or the
> relevant portions anyway) -- the actual code, rather than an example,
Unfortunately, the entire code is just the example.
Mark.
--
Mark Hobley
Linux User: #370818 http://markhobley.yi.org/
------------------------------
Date: Mon, 20 Oct 2008 02:42:03 -0700 (PDT)
From: bingfeng <bfzhao@gmail.com>
Subject: split a multiple lines text
Message-Id: <a3979d5c-9c09-4fc0-afc2-1105ff03a1d3@k37g2000hsf.googlegroups.com>
Hello,
Assume I have following string:
my $cmds = <<DOC
__begin {
abc;
def;
{foo;bar}
} __end;
__begin {
cde;
} __end;
abc;
bad;
DOC
;
I want to split it into an array, the first item is "__begin {
abc;
def;
{foo;bar}
} __end", the second item is "__begin {
cde;
} __end", and the third is "abc" and the fourth is "bad".
split obviously cannot be used here, so I use following regex:
my @lines = ($cmds =~ /__begin.*?__end|[^;]+/sg);
but it does not work at all. so how can I do with this?
regards,
bingfeng
------------------------------
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 1934
***************************************