[29507] in Perl-Users-Digest
Perl-Users Digest, Issue: 751 Volume: 11
daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Tue Aug 14 00:09:45 2007
Date: Mon, 13 Aug 2007 21: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, 13 Aug 2007 Volume: 11 Number: 751
Today's topics:
Re: File::Find problem? <joe@inwap.com>
Re: File::Find problem? <joe@inwap.com>
Re: how to tranpose a huge text file <nospam-abuse@ilyaz.org>
LAMP / Web Developer for Irvine , CA - 3- 6 months Cont <sbhavani@Hiringdynamics.com>
map not working <pinaki_m77@yahoo.com>
Re: map not working <pinaki_m77@yahoo.com>
Re: Optimized count of files in tree <m@rtij.nl.invlalid>
Re: Pagination II <glex_no-spam@qwest-spam-no.invalid>
Re: Parsing Huge File - must use version of perl compil <joe@inwap.com>
Re: Parsing Huge File <joe@inwap.com>
Re: Pass by reference question <cdalten@gmail.com>
Re: Pass by reference question <mritty@gmail.com>
Re: Pass by reference question <tadmc@seesig.invalid>
Re: Pass by reference question xhoster@gmail.com
Re: perl DBI OO <jtbutler78@comcast.net>
Re: perl DBI OO xhoster@gmail.com
Re: perl DBI OO <jtbutler78@comcast.net>
Perl executing a command (on UNIX) <gil.kovary@gmail.com>
Perl, Pipes and error return codes <njc@cookie.uucp>
Re: Regular Expression: Perl and vi <dummy@example.com>
Digest Administrivia (Last modified: 6 Apr 01) (Perl-Users-Digest Admin)
----------------------------------------------------------------------
Date: Mon, 13 Aug 2007 20:43:56 -0700
From: Joe Smith <joe@inwap.com>
Subject: Re: File::Find problem?
Message-Id: <IKSdnQEfYOqQuFzbnZ2dnUVZ_vShnZ2d@comcast.com>
Monty wrote:
> How about setting the depth of the find()?
That is one of the reasons why I added 'preprocess' to File::find().
our $depth;
find( {
wanted => &your_sub,
preprocess => {return() if ++$depth > $max_depth},
postprocess => {$depth--}
}, @ARGV);
-Joe
------------------------------
Date: Mon, 13 Aug 2007 20:58:53 -0700
From: Joe Smith <joe@inwap.com>
Subject: Re: File::Find problem?
Message-Id: <FJGdnf-Wd7IWtVzbnZ2dnUVZ_uejnZ2d@comcast.com>
Monty wrote:
> How about setting the depth of the find()?
The version of File::Find distributed with perl v5.8.8 for cygwin has a problem.
It does not recognize that Windows Vista has links to directories.
The lstat() function treats these links as actual directories and not
as a symlink. The result is that File::Find processes certain directories
more than once, sometimes infinitely. (The option 'follow_skip' only looks
at symlinks, so is no help here.)
(/cygdrive/c) jms@wiggin# cat /tmp/find
#! /usr/bin/perl
use strict; use warnings;
use File::Find ();
use vars qw/*name *dir *prune/;
*name = *File::Find::name;
*dir = *File::Find::dir;
*prune = *File::Find::prune;
sub wanted;
# Traverse desired filesystems
File::Find::find({wanted => \&wanted}, 'C:/Users');
exit unless @prune;
print "File system loop (hardlink to directory) detected:\n", sort @prune;
sub wanted {
if ((my($dev,$ino,$mode,$nlink,$uid,$gid) = lstat $_) && -d _) {
# print("$name\n");
my $dev_ino = ($dev||1) . ":" . ($ino||2);
if (defined $prune{$dev_ino}) {
push @prune,"$name => $prune{$dev_ino}\n";
print STDERR $prune[-1];
$prune = 1;
} else {
$prune{$dev_ino} = $name; # Watch out for Windows Vista
}
}
}
(/cygdrive/c) jms@wiggin# perl /tmp/find
File system loop (hardlink to directory) detected:
C:/Users/Default/AppData/Local/Application Data => C:/Users/Default/AppData/Local
C:/Users/Default/AppData/Local/Microsoft/Windows/History => C:/Users/Default/AppData/Local/History
C:/Users/Default/AppData/Local/Temporary Internet Files => C:/Users/Default/AppData/Local/Microsoft/Windows/Temporary Internet Files
C:/Users/Default/Application Data => C:/Users/Default/AppData/Roaming
C:/Users/Default/Cookies => C:/Users/Default/AppData/Roaming/Microsoft/Windows/Cookies
C:/Users/Default/Local Settings => C:/Users/Default/AppData/Local
C:/Users/Default/NetHood => C:/Users/Default/AppData/Roaming/Microsoft/Windows/Network Shortcuts
C:/Users/Default/PrintHood => C:/Users/Default/AppData/Roaming/Microsoft/Windows/Printer Shortcuts
C:/Users/Default/Recent => C:/Users/Default/AppData/Roaming/Microsoft/Windows/Recent
C:/Users/Default/SendTo => C:/Users/Default/AppData/Roaming/Microsoft/Windows/SendTo
C:/Users/Default/Start Menu => C:/Users/Default/AppData/Roaming/Microsoft/Windows/Start Menu
C:/Users/Default/Templates => C:/Users/Default/AppData/Roaming/Microsoft/Windows/Templates
C:/Users/Guest/AppData/Local/Application Data => C:/Users/Guest/AppData/Local
C:/Users/Guest/AppData/Local/Microsoft/Windows/History => C:/Users/Guest/AppData/Local/History
C:/Users/Guest/AppData/Local/Temporary Internet Files => C:/Users/Guest/AppData/Local/Microsoft/Windows/Temporary Internet Files
C:/Users/cyg_server/AppData/Local/Application Data => C:/Users/cyg_server/AppData/Local
C:/Users/cyg_server/AppData/Local/Microsoft/Windows/History => C:/Users/cyg_server/AppData/Local/History
C:/Users/cyg_server/AppData/Local/Temporary Internet Files => C:/Users/cyg_server/AppData/Local/Microsoft/Windows/Temporary Internet Files
C:/Users/jms/AppData/Local/Application Data => C:/Users/jms/AppData/Local
C:/Users/jms/AppData/Local/Microsoft/Windows/History => C:/Users/jms/AppData/Local/History
C:/Users/jms/AppData/Local/Temporary Internet Files => C:/Users/jms/AppData/Local/Microsoft/Windows/Temporary Internet Files
C:/Users/jms/Application Data => C:/Users/jms/AppData/Roaming
C:/Users/jms/Cookies => C:/Users/jms/AppData/Roaming/Microsoft/Windows/Cookies
C:/Users/jms/Local Settings => C:/Users/jms/AppData/Local
C:/Users/jms/NetHood => C:/Users/jms/AppData/Roaming/Microsoft/Windows/Network Shortcuts
C:/Users/jms/PrintHood => C:/Users/jms/AppData/Roaming/Microsoft/Windows/Printer Shortcuts
C:/Users/jms/Recent => C:/Users/jms/AppData/Roaming/Microsoft/Windows/Recent
C:/Users/jms/SendTo => C:/Users/jms/AppData/Roaming/Microsoft/Windows/SendTo
C:/Users/jms/Start Menu => C:/Users/jms/AppData/Roaming/Microsoft/Windows/Start Menu
C:/Users/jms/Templates => C:/Users/jms/AppData/Roaming/Microsoft/Windows/Templates
C:/Users/sshd_server/AppData/Local/Application Data => C:/Users/sshd_server/AppData/Local
C:/Users/sshd_server/AppData/Local/Microsoft/Windows/History => C:/Users/sshd_server/AppData/Local/History
C:/Users/sshd_server/AppData/Local/Temporary Internet Files => C:/Users/sshd_server/AppData/Local/Microsoft/Windows/Temporary Internet Files
------------------------------
Date: Mon, 13 Aug 2007 19:12:01 +0000 (UTC)
From: Ilya Zakharevich <nospam-abuse@ilyaz.org>
Subject: Re: how to tranpose a huge text file
Message-Id: <f9qae1$2jti$1@agate.berkeley.edu>
[A complimentary Cc of this posting was sent to
Jie
<jiehuang001@gmail.com>], who wrote in article <1186844895.953259.318160@q4g2000prc.googlegroups.com>:
>
> I really appreciate all the reponses here!!
>
> I did not jump in because I want to test each proposed solution first
> before providing any feedback.
*If* you have 512 MB of memory, and *if* each of your 1e6 x 1e3
entries is compressable to 1 byte, then the following solution should
be the optimal of what is proposed:
a) Preallocate an array of 334 strings of length 1e6 bytes;
b1) Assign '' to each string;
c1) Read file line-by-line, for each line: split; ignore all results
but the first 333; compress each of 333 results to 1 byte; append
each byte to the corresponding string;
d1) When read: for each of the corresponding 333 strings: uncompress
each byte, print space-separated.
b2,c2,d2): Likewise with results 334..666;
b3,c3,d3): Likewise with results 667..1000.
This is 3 passes through the original file. If you skip compression,
you can do the same with 10 passes - should also be not slow with
contemporary hard drives...
Hope this helps,
Ilya
------------------------------
Date: Mon, 13 Aug 2007 11:21:36 -0700
From: Bhavani <sbhavani@Hiringdynamics.com>
Subject: LAMP / Web Developer for Irvine , CA - 3- 6 months Contract
Message-Id: <1187029296.435102.176030@z24g2000prh.googlegroups.com>
LAMP / Web Developer for Irvine , CA - 3- 6 months Contract
Hi ,
We are looking for LAMP / Web Developer for Irvine , CA - 3- 6 months
Contract with my direct client . Interested candidates , pls send me
your resume to sbhavani@hiringdynamcis.com
Job Spec:
__________
=B7 3-5 years experience with the LAMP (Linux, Apache, MySQL, and PHP)
combination of open source systems building consumer based content
websites and applications
Location: Irvine , CA
Duration: 3- 6 months and possible Extension for long terms
Rate: Open
Bhavani S
HD Consulting
Work: 586-795-3074
Fax : 858-712-8964
Email: sbhavani@hiringdynamics.com
------------------------------
Date: Tue, 14 Aug 2007 00:21:42 -0000
From: googler <pinaki_m77@yahoo.com>
Subject: map not working
Message-Id: <1187050902.779055.8310@i38g2000prf.googlegroups.com>
I am trying to create map for the operation I am going to explain. I
have some code like this:
`ifdef FUNCTIONAL
blah1
blah2
blah3
`else
blah4
blah5
blah6
`endif
I want to change it to:
//`ifdef FUNCTIONAL
// blah1
// blah2
// blah3
//`else
blah4
blah5
blah6
//`endif
I define my map as follows:
:map v /`ifdef[CTRL-V][ENTER]ma/`else[CTRL-V][ENTER]mb'a:.,'bs/^/\/\//
[CTRL-V][ENTER]/`endif[CTRL-V][ENTER]I//[CTRL-V][ESC][ENTER]
the above can be broken down into the following steps:
(1) /`ifdef[CTRL-V][ENTER] => search for `ifdef
(2) ma => mark the line as a
(3) /`else[CTRL-V][ENTER] => search for `else
(4) mb => mark the line as b
(5) 'a => go back to line marked as a
(6) :.,'bs/^/\/\//[CTRL-V][ENTER] => add // at the start of lines
from a to b
(7) /`endif[CTRL-V][ENTER] => search for `endif
(8) I//[CTRL-V][ESC] => add // to the start of this line
When I try to execute this sequence by placing the cursor just above
from where the block starts and pressing v, I do not get the desired
change. Instead it shows the message:
E488: Trailing characters
However, if I execute the commands manually one after the other, it
works fine. Please point out if you can see the error. Thank you.
------------------------------
Date: Tue, 14 Aug 2007 00:24:52 -0000
From: googler <pinaki_m77@yahoo.com>
Subject: Re: map not working
Message-Id: <1187051092.050819.307230@l22g2000prc.googlegroups.com>
On Aug 13, 7:21 pm, googler <pinaki_...@yahoo.com> wrote:
> I am trying to create map for the operation I am going to explain. I
> have some code like this:
>
Extermely sorry.. I posted in the wrong group. My apologies.
------------------------------
Date: Mon, 13 Aug 2007 22:29:44 +0200
From: Martijn Lievaart <m@rtij.nl.invlalid>
Subject: Re: Optimized count of files in tree
Message-Id: <pan.2007.08.13.20.29.44@rtij.nl.invlalid>
On Mon, 13 Aug 2007 01:58:42 -0700, Ingo Menger wrote:
> And, in addition, repeat the command to see whether it get's faster the
> second time. Most likely, the directory blocks to be read will be
> already in memory so the 2nd attempt may be that much faster.
Good point! Very important to keep in mind.
M4
------------------------------
Date: Mon, 13 Aug 2007 14:34:40 -0500
From: "J. Gleixner" <glex_no-spam@qwest-spam-no.invalid>
Subject: Re: Pagination II
Message-Id: <46c0b250$0$10306$815e3792@news.qwest.net>
webmaster@valleywebnet.com wrote:
> Thanks to everyone here, I am closer to getting this working but am
> still having a problem....
>
> The script runs and outputs a page, but in the db I have set up all of
> the categories have enough entries to fill multiple pages. So, the
> script runs and always goes to page 2 for some reason.
>
> And if I click on one of the other links for a different page, then I
> get nothing on that one.
>
> Can anyone spot the problem?
[...]
> if (!$limit) {$limit = 5;}
$limit = 5 unless defined $limit;
> my $sql = "select * from valley where category like ?";
Do you really need all of the columns?
>
> my $sth = $dbh->prepare($sql) or die("Error in SQL1\n");
> $sth->execute($find) or die "Error in SQL2 $!\n";
Look at DBI's RaiseError.. Using that you
can eliminate all of your 'or die..' code.
> my $results_per_page = 5;
>
> my $sql = "select * from valley where category like ?
> limit $limit, $results_per_page";
Start with your SQL, once it's correct, then print it
to make sure it's correct, then actually run it.
print $sql;
Then run it on your DB, to see what it products. It looks like
limit and results_per_page are both 5, which probably isn't
what you want.
> $sth->bind_columns( \$ID, \$category, \$name, \$description, \
> $contact, \$phone, \$fax, \$address, \$city, \$state, \$zip, \$email, \
> $url, \$keywords );
A little more readable as:
$sth->bind_columns( \( $ID, $category, $name, ..., $keywords ) );
------------------------------
Date: Mon, 13 Aug 2007 19:40:28 -0700
From: Joe Smith <joe@inwap.com>
Subject: Re: Parsing Huge File - must use version of perl compiled for huge files.
Message-Id: <s5ednS_XQLG2i1zbnZ2dnUVZ_uygnZ2d@comcast.com>
Majnu wrote:
> Hello,
>
> I have a strange problem. I have a flat file of about 6 million rows,
> each row of 600 bytes. I read the file line by line after opening like
> this:
>
> open(IN, "cat $InputFile |") or die "Failed to open the File";
> ##This was changed from open(IN, "< $InputFile") because Perl
> outrightly refused to open the file.
> while(<IN>) {......
>
> The problem is that, at times, Perl just stops after reading 3,334,601
> records.
You neglected to mention which version of perl and which OS, but I
can see the cause of both of your problems.
% perl -le 'print 600*3_334_601'
2000760600
% perl -V | grep large
useperlio=define d_sfio=undef uselargefiles=define
You cannot process more than 2 gigabytes (can't even open a file
bigger than 2 GB) when using a version of perl that expects file
sizes to fit into a signed 32-bit int.
Check your 'perl -V'; I'm sure it is _not_ compiled with 'uselargefiles=define'.
You need to upgrade to perl v5.8.x immediately.
-Joe
------------------------------
Date: Mon, 13 Aug 2007 19:43:56 -0700
From: Joe Smith <joe@inwap.com>
Subject: Re: Parsing Huge File
Message-Id: <s5ednS7XQLFki1zbnZ2dnUVZ_uzinZ2d@comcast.com>
Ian Wilson wrote:
>> open(IN, "cat $InputFile |") or die "Failed to open the File";
>> ##This was changed from open(IN, "< $InputFile")
>
> Your `cat` doesn't seem to be doing anything useful.
It is useful if your shell doesn't handle large files; it allows
programs expecting 32-bit file sizes to process 2GB of data
instead of blowing up immediately. It is a kludge.
-Joe
------------------------------
Date: Mon, 13 Aug 2007 18:17:45 -0700
From: grocery_stocker <cdalten@gmail.com>
Subject: Re: Pass by reference question
Message-Id: <1187054265.734133.111840@b79g2000hse.googlegroups.com>
On Aug 13, 10:08 am, xhos...@gmail.com wrote:
> grocery_stocker <cdal...@gmail.com> wrote:
> > If perl can pass stuff by reference, then why do you have to deference
> > it. Like for example
>
> > @tailings = popmany ( \@a, \@b, \@c, \@d );
>
> You are sticking the backwhacks in front of those arrays, not Perl.
> (If you are using prototypes, then perl will in effect add the backwhacks
> for you, but that is a different matter).
>
Let me get this straight. If I use prototypes, perl will in effect add
backwhacks?! I'm starting to get these really horrible images of some
of the AOL engineers using prototypes in Perl scripts and me wondering
why they were sometimes anal retentive about this. Would you or
someone else care to give me an example of this?
Chad
------------------------------
Date: Mon, 13 Aug 2007 18:49:50 -0700
From: Paul Lalli <mritty@gmail.com>
Subject: Re: Pass by reference question
Message-Id: <1187056190.284983.180040@b79g2000hse.googlegroups.com>
On Aug 13, 9:17 pm, grocery_stocker <cdal...@gmail.com> wrote:
> Let me get this straight. If I use prototypes, perl will in effect
> add backwhacks?!
Yes. Don't use prototypes. Ever.
> Would you or someone else care to give me an example of this?
$ perl -MData::Dumper -e'
sub foo(\@\@) {
print Dumper(@_);
}
my @one = (1, 2, 3);
my @two = (4, 5, 6);
foo(@one, @two);
'
$VAR1 = [
1,
2,
3
];
$VAR2 = [
4,
5,
6
];
Compare and contrast with not using a prototype, in which all of @one
and @two are "flattened" into one big list:
$ perl -MData::Dumper -e'
sub foo {
print Dumper(@_);
}
my @one = (1, 2, 3);
my @two = (4, 5, 6);
foo(@one, @two);
'
$VAR1 = 1;
$VAR2 = 2;
$VAR3 = 3;
$VAR4 = 4;
$VAR5 = 5;
$VAR6 = 6;
Paul Lalli
------------------------------
Date: Tue, 14 Aug 2007 01:53:44 GMT
From: Tad McClellan <tadmc@seesig.invalid>
Subject: Re: Pass by reference question
Message-Id: <slrnfc22aq.l9h.tadmc@tadmc30.sbcglobal.net>
grocery_stocker <cdalten@gmail.com> wrote:
> On Aug 13, 10:08 am, xhos...@gmail.com wrote:
>> grocery_stocker <cdal...@gmail.com> wrote:
>> > If perl can pass stuff by reference, then why do you have to deference
>> > it. Like for example
>>
>> > @tailings = popmany ( \@a, \@b, \@c, \@d );
>>
>> You are sticking the backwhacks in front of those arrays, not Perl.
>> (If you are using prototypes, then perl will in effect add the backwhacks
>> for you, but that is a different matter).
>>
>
> Let me get this straight. If I use prototypes, perl will in effect add
> backwhacks?!
> Would you or
> someone else care to give me an example of this?
In addition to all of the ones in the "Prototypes" section in perlsub?
OK.
-----------------------------
#!/usr/bin/perl
use warnings;
use strict;
sub mypush (\@@) {
my($aref, @list) = @_;
foreach ( @list ) {
$aref->[ @$aref ] = $_;
}
}
my @array = qw/zero one two/;
print "before: @array\n";
mypush @array, 'three', 'four'; # look Ma! No backslash!
print "after: @array\n"; # see if @array got modified
-----------------------------
--
Tad McClellan
email: perl -le "print scalar reverse qq/moc.noitatibaher\100cmdat/"
------------------------------
Date: 14 Aug 2007 02:33:01 GMT
From: xhoster@gmail.com
Subject: Re: Pass by reference question
Message-Id: <20070813223305.470$hq@newsreader.com>
grocery_stocker <cdalten@gmail.com> wrote:
> On Aug 13, 10:08 am, xhos...@gmail.com wrote:
> > grocery_stocker <cdal...@gmail.com> wrote:
> > > If perl can pass stuff by reference, then why do you have to
> > > deference it. Like for example
> >
> > > @tailings = popmany ( \@a, \@b, \@c, \@d );
> >
> > You are sticking the backwhacks in front of those arrays, not Perl.
> > (If you are using prototypes, then perl will in effect add the
> > backwhacks for you, but that is a different matter).
> >
>
> Let me get this straight. If I use prototypes, perl will in effect add
> backwhacks?!
If the contents of the prototype dictate it, yes.
> I'm starting to get these really horrible images of some
> of the AOL engineers using prototypes in Perl scripts and me wondering
> why they were sometimes anal retentive about this. Would you or
> someone else care to give me an example of this?
$ perl -le 'my @x=1..10; foo(@x); sub foo(\@) {print "@_"}; foo(@x)'
main::foo() called too early to check prototype at -e line 1.
1 2 3 4 5 6 7 8 9 10
ARRAY(0x6227e0)
foo(@x) looks like it should send @x as a list, which is what it does
initially (but with the warning), but because of the prototype in effect
the second time the foo-call is compiled, that time it instead sends the
arrayref.
Xho
--
-------------------- http://NewsReader.Com/ --------------------
Usenet Newsgroup Service $9.95/Month 30GB
------------------------------
Date: Mon, 13 Aug 2007 12:03:05 -0700
From: "jtbutler78@comcast.net" <jtbutler78@comcast.net>
Subject: Re: perl DBI OO
Message-Id: <1187031785.959323.324940@19g2000hsx.googlegroups.com>
On Aug 13, 1:06 pm, xhos...@gmail.com wrote:
> "jtbutle...@comcast.net" <jtbutle...@comcast.net> wrote:
> > I have a module that I instantiate a DBI connection from. My question
> > is - I am doing the right way? It works but I dont know know I am
> > making a connection to the DB each time I call getResults or am I only
> > using the first connection I make. I call getResults inside loops or
> > make several calls to it within my application and its a waste to make
> > connections with each call.
>
> You are making a new connection each time you call "new", and just re-use
> that connection each time you call getResults on a given object obtained
> by new. So if your class is only instantiated once per program, then
> you only make one connection. But from the bigger picture, I'd have to
> wonder what the point is. It looks like you just made a simple wrapper
> around DBI which adds no new functionality but takes away a lot of existing
> functionality.
>
> Xho
>
> --
> --------------------http://NewsReader.Com/--------------------
> Usenet Newsgroup Service $9.95/Month 30GB
I made this because I am making the calls all the time and its much
cleaner code-wise.
------------------------------
Date: 13 Aug 2007 19:30:14 GMT
From: xhoster@gmail.com
Subject: Re: perl DBI OO
Message-Id: <20070813153017.098$gD@newsreader.com>
"jtbutler78@comcast.net" <jtbutler78@comcast.net> wrote:
> On Aug 13, 1:06 pm, xhos...@gmail.com wrote:
> > "jtbutle...@comcast.net" <jtbutle...@comcast.net> wrote:
> > > I have a module that I instantiate a DBI connection from. My
> > > question is - I am doing the right way? It works but I dont know
> > > know I am making a connection to the DB each time I call getResults
> > > or am I only using the first connection I make. I call getResults
> > > inside loops or make several calls to it within my application and
> > > its a waste to make connections with each call.
> >
> > You are making a new connection each time you call "new", and just
> > re-use that connection each time you call getResults on a given object
> > obtained by new. So if your class is only instantiated once per
> > program, then you only make one connection. But from the bigger
> > picture, I'd have to wonder what the point is. It looks like you just
> > made a simple wrapper around DBI which adds no new functionality but
> > takes away a lot of existing functionality.
> >
>
> I made this because I am making the calls all the time and its much
> cleaner code-wise.
It is cleaner than just turning on RaiseError and then
calling $dbi->selectall_arrayref as needed?
At least that way you will get the right error messages. With your code,
you're likely to get can't call method on undef value errors instead of the
correct error message, as you only do error checking at one out of 3
potential DBI-error points.
Xho
--
-------------------- http://NewsReader.Com/ --------------------
Usenet Newsgroup Service $9.95/Month 30GB
------------------------------
Date: Mon, 13 Aug 2007 15:00:10 -0700
From: "jtbutler78@comcast.net" <jtbutler78@comcast.net>
Subject: Re: perl DBI OO
Message-Id: <1187042410.087951.281800@d55g2000hsg.googlegroups.com>
On Aug 13, 3:30 pm, xhos...@gmail.com wrote:
> "jtbutle...@comcast.net" <jtbutle...@comcast.net> wrote:
> > On Aug 13, 1:06 pm, xhos...@gmail.com wrote:
> > > "jtbutle...@comcast.net" <jtbutle...@comcast.net> wrote:
> > > > I have a module that I instantiate a DBI connection from. My
> > > > question is - I am doing the right way? It works but I dont know
> > > > know I am making a connection to the DB each time I call getResults
> > > > or am I only using the first connection I make. I call getResults
> > > > inside loops or make several calls to it within my application and
> > > > its a waste to make connections with each call.
>
> > > You are making a new connection each time you call "new", and just
> > > re-use that connection each time you call getResults on a given object
> > > obtained by new. So if your class is only instantiated once per
> > > program, then you only make one connection. But from the bigger
> > > picture, I'd have to wonder what the point is. It looks like you just
> > > made a simple wrapper around DBI which adds no new functionality but
> > > takes away a lot of existing functionality.
>
> > I made this because I am making the calls all the time and its much
> > cleaner code-wise.
>
> It is cleaner than just turning on RaiseError and then
> calling $dbi->selectall_arrayref as needed?
>
> At least that way you will get the right error messages. With your code,
> you're likely to get can't call method on undef value errors instead of the
> correct error message, as you only do error checking at one out of 3
> potential DBI-error points.
>
> Xho
>
> --
> --------------------http://NewsReader.Com/--------------------
> Usenet Newsgroup Service $9.95/Month 30GB
Good call I will make the change. I am still looking into DBIx::Class
as well.
------------------------------
Date: Mon, 13 Aug 2007 20:45:36 -0700
From: gil <gil.kovary@gmail.com>
Subject: Perl executing a command (on UNIX)
Message-Id: <1187063136.707484.143560@w3g2000hsg.googlegroups.com>
Hi,
I'm new at perl programming,
I'd like to execute a UNIX command, which takes no longer than
$time_out seconds.
Is there any easy way to do it, or do I have to use SIGs?
Thans!
------------------------------
Date: Mon, 13 Aug 2007 21:38:23 -0500
From: Neil Cherry <njc@cookie.uucp>
Subject: Perl, Pipes and error return codes
Message-Id: <slrnfc25cv.f8v.njc@cookie.uucp>
I need to run an external script and have its output displayed to
the user while running. No problem something like this works fine:
open(IN, "cat file|");
while(<IN>) {
print ;
}
close IN;
But what if cat returns an error in the middle of cat'ng the file? I
know I can catch the broken pipe (which I'd better catch anyway) but
that doesn't tell me the error returned by cat. How do I figure that
out inside the perl code? I've done some searching but 'perl pipe
error return' mostly get me broken pipe errors. I'm currently trying
to avoid fork, files, while loops of the file, etc as that seems a
little untidy (OK, and I'm also lazy :-).
Thanks
--
Linux Home Automation Neil Cherry ncherry@linuxha.com
http://www.linuxha.com/ Main site
http://linuxha.blogspot.com/ My HA Blog
Author of: Linux Smart Homes For Dummies
------------------------------
Date: Mon, 13 Aug 2007 19:35:55 GMT
From: "John W. Krahn" <dummy@example.com>
Subject: Re: Regular Expression: Perl and vi
Message-Id: <vo2wi.107686$xk5.102852@edtnps82>
googler wrote:
> I am trying to create a list of the differences in regular expression
> for Perl and vi. I have been using both Perl and vi, and get confused
> by this sometimes. There are a few that I already know of.
>
> 1. In Perl, characters like (, { etc when used as metacharacter can be
> used by themselves (without using a \). In vi, they should be escaped
> with a \. (Question: what is the full list of the metacharacters where
> we see this difference?)
>
> 2. In Perl, non-greedy search can be done by using a ? character
> (like .*?). In vi, this is done as .\{-}
>
> 3. In Perl, zero or one match can be achieved by putting a ? character
> after the pattern. In vi, this is done by \=
>
> 4. In Perl, the RE for matching only a particular word is \bword\b .
> In vi, it is \<word\> (Question: does \<word\> work for Perl?)
>
> Please add to the list if you know of any difference that I missed.
Get the book:
http://www.oreilly.com/catalog/regex3/index.html
It should explain most if not all of the differences.
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: 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 751
**************************************