[23658] in Perl-Users-Digest
Perl-Users Digest, Issue: 5865 Volume: 10
daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Thu Nov 27 09:05:46 2003
Date: Thu, 27 Nov 2003 06:05:09 -0800 (PST)
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, 27 Nov 2003 Volume: 10 Number: 5865
Today's topics:
Re: aternative grouping and map, deuglification (Greg Bacon)
Re: Curses %$#@! <nobull@mail.com>
Re: Curses %$#@! <tore@aursand.no>
DBI error handling <purschke@uni-muenster.de>
Re: DBI error handling <tore@aursand.no>
Emacs modules for Perl programming (Jari Aalto+mail.perl)
Re: floating point <eddhig22@yahool.com>
Re: floating point <bernard.el-haginDODGE_THIS@lido-tech.net>
Re: floating point (Anno Siegel)
Re: How to create a DBM database in Perl <jvandervloet@hotmail.com>
Re: How to create a DBM database in Perl <noreply@gunnar.cc>
Re: mod_perl <tore@aursand.no>
Re: module load question <tore@aursand.no>
number formatting.. <jaan.kronberg@mail.ee>
Re: number formatting.. <Paul.E.Boardman@umist.ac.uk>
Packages and returning errors <someone@somewhere.com>
Re: Packages and returning errors <bernard.el-haginDODGE_THIS@lido-tech.net>
Re: Packages and returning errors (Anno Siegel)
Re: Packages and returning errors <nobull@mail.com>
Re: Packages and returning errors <tore@aursand.no>
Re: Regex Question <nobull@mail.com>
Socket Problem... (Hobbit HK)
Re: went to 5.8.1 and now my while statement fails <tore@aursand.no>
Digest Administrivia (Last modified: 6 Apr 01) (Perl-Users-Digest Admin)
----------------------------------------------------------------------
Date: Thu, 27 Nov 2003 13:26:57 -0000
From: gbacon@hiwaay.net (Greg Bacon)
Subject: Re: aternative grouping and map, deuglification
Message-Id: <vsbut1s88pjp08@corp.supernews.com>
In article <776e0325.0311260712.7b0c39cf@posting.google.com>,
Sara <genericax@hotmail.com> wrote:
: [...]
: I wish other delimiters had been chosen for alternative grouping, like
:
: <CAT|DOG>
:
: Since Alterntaive grouping is often not related to capturing $-vars..
Your wish is granted:
(?:pattern)
(?imsx-imsx:pattern)
This is for clustering, not capturing; it groups
subexpressions like "()", but doesn't make back-
references as "()" does. So
@fields = split(/\b(?:a|b|c)\b/)
is like
@fields = split(/\b(a|b|c)\b/)
but doesn't spit out extra fields. It's also
cheaper not to capture characters if you don't
need to.
Any letters between "?" and ":" act as flags
modifiers as with "(?imsx-imsx)". For example,
/(?s-i:more.*than).*million/i
is equivalent to the more verbose
/(?:(?s-i)more.*than).*million/i
I even took time to modify your perlre manpage accordingly.
Just another Perl djini,
Greg
--
WARNING! In the considerations of safety, you should NEVER let a male
dolphin attempt anal sex with you.
-- http://www.dolphinsex.org/
------------------------------
Date: 27 Nov 2003 12:37:46 +0000
From: Brian McCauley <nobull@mail.com>
Subject: Re: Curses %$#@!
Message-Id: <u9fzgac7hh.fsf@wcl-l.bham.ac.uk>
Default@IO_Error_1011101.xyz writes:
> Subject: Re: Curses %$#@!
Your question has nothing to do with Curses.
[ lots of stuff caused by not realising Perl module names are case
sensative ]
Perl module names are case sensative.
--
\\ ( )
. _\\__[oo
.__/ \\ /\@
. l___\\
# ll l\\
###LL LL\\
------------------------------
Date: Thu, 27 Nov 2003 14:10:01 +0100
From: Tore Aursand <tore@aursand.no>
Subject: Re: Curses %$#@!
Message-Id: <pan.2003.11.27.05.45.27.881463@aursand.no>
On Thu, 27 Nov 2003 05:05:24 +0000, Default wrote:
> <cry>
> Not getting any sort of error at all, the program just ends.
Please use the subject of your post as the subject of your post.
> #!
> use Strict;
> use Warnings;
What OS are you running? Does it really allow module names to be written
this way? On Linux, I can't even run this script;
#!/usr/local/bin/perl
#
use Strict;
use Warnings;
That's because there _are no_ modules named 'Strict' and/or 'Warnings'.
They are named 'strict' and 'warnings'.
--
Tore Aursand <tore@aursand.no>
"A teacher is never a giver of truth - he is a guide, a pointer to the
truth that each student must find for himself. A good teacher is
merely a catalyst." -- Bruce Lee
------------------------------
Date: Thu, 27 Nov 2003 13:44:32 +0100
From: Lars Purschke <purschke@uni-muenster.de>
Subject: DBI error handling
Message-Id: <3FC5F1B0.8050001@uni-muenster.de>
Hi!
I've a perl script which inserts data to a database. Sometime I get an
error on the execute() statement. Now I want the script not to die but
to exit the loop and to try again with the next record. Does anyone know
how to realize that?
my $dbh = DBI->connect("dbi:ODBC:$dsn", "xyz", "xyz",
{ PrintError => 0,
RaiseError => 0}) or die "$DBI::errstr\n";
while( my(@row) = $sth->fetchrow_array ) {
die $sth->errstr if $sth->err;
$stmt = "Insert into .... ";
$rs = $dbh->prepare($stmt);
$rs->execute();
}
thanks
lars
------------------------------
Date: Thu, 27 Nov 2003 14:42:44 +0100
From: Tore Aursand <tore@aursand.no>
Subject: Re: DBI error handling
Message-Id: <pan.2003.11.27.13.37.05.389136@aursand.no>
On Thu, 27 Nov 2003 13:44:32 +0100, Lars Purschke wrote:
> I've a perl script which inserts data to a database. Sometime I get an
> error on the execute() statement. Now I want the script not to die but
> to exit the loop and to try again with the next record.
Well. You could start by telling Perl _not_ to die when something goes
wrong. That would be a grand opener. :-)
You could also check the return value of the execute() method. As it says
in the DBI documentation;
An "undef" is returned if an error occurs. A successful "execute"
always returns true regardless of the number of rows affected, even if
it's zero (see below). It is always important to check the return status
of "execute" (and most other DBI methods) for errors if you're not using
"RaiseError".
So;
my $sth = $dbh->prepare( ... );
if ( $sth->execute() ) {
# Everything went fine, obviously
}
else {
# An error occured
}
$sth->finish();
See 'perldoc DBI' for more information.
--
Tore Aursand <tore@aursand.no>
"A teacher is never a giver of truth - he is a guide, a pointer to the
truth that each student must find for himself. A good teacher is
merely a catalyst." -- Bruce Lee
------------------------------
Date: 27 Nov 2003 11:49:34 GMT
From: <jari.aalto@poboxes.com> (Jari Aalto+mail.perl)
Subject: Emacs modules for Perl programming
Message-Id: <perl-faq/emacs-lisp-modules_1069933732@rtfm.mit.edu>
Archive-name: perl-faq/emacs-lisp-modules
Posting-Frequency: 2 times a month
URL: http://tiny-tools.sourceforge.net/
Maintainer: Jari Aalto <jari.aalto@poboxes.com>
Announcement: "What Emacs lisp modules can help with programming Perl"
Preface
Emacs is your friend if you have to do anything comcerning software
development: It offers plug-in modules, written in Emacs lisp
(elisp) language, that makes all your programmings wishes come
true. Please introduce yourself to Emacs and your programming era
will get a new light.
Where to find Emacs/XEmacs
o Unix:
http://www.gnu.org/software/emacs/emacs.html
http://www.xemacs.org/
o Unix Windows port (for Unix die-hards):
install http://www.cygwin.com/ which includes native Emacs 21.x.
XEmacs port is bundled in XEmacs setup.exe available from
XEmacs site.
o Pure Native Windows port
http://www.gnu.org/software/emacs/windows/ntemacs.html
ftp://ftp.xemacs.org/pub/xemacs/windows/setup.exe
o More Emacs resources at
http://tiny-tools.sourceforge.net/ => Emacs resource page
Emacs Perl Modules
Cperl -- Perl programming mode
ftp://ftp.math.ohio-state.edu/pub/users/ilya/perl
http://www.perl.com/CPAN-local/misc/emacs/cperl-mode/
<ilya@math.ohio-state.edu> Ilya Zakharevich
CPerl is major mode for editing perl files. Forget the default
`perl-mode' that comes with Emacs, this is much better. Comes
standard in newest Emacs.
TinyPerl -- Perl related utilities
http://tiny-tools.sourceforge.net/
If you ever wonder how to deal with Perl POD pages or how to find
documentation from all perl manpages, this package is for you.
Couple of keystrokes and all the documentaion is in your hands.
o Instant function help: See documentation of `shift', `pop'...
o Show Perl manual pages in *pod* buffer
o Grep through all Perl manpages (.pod)
o Follow POD references e.g. [perlre] to next pod with RETURN
o Coloured pod pages with `font-lock'
o Separate `tiperl-pod-view-mode' for jumping topics and pages
forward and backward in *pod* buffer.
o Update `$VERSION' variable with YYYY.MMDD on save.
o Load source code into Emacs, like Devel::DProf.pm
o Prepare script (version numbering) and Upload it to PAUSE
o Generate autoload STUBS (Devel::SelfStubber) for you
Perl Module (.pm)
TinyIgrep -- Perl Code browsing and easy grepping
[TinyIgrep is included in Tiny Tools Kit]
To grep from all installed Perl modules, define database to
TinyIgrep. There is example file emacs-rc-tinyigrep.el that shows
how to set up dattabases for Perl5, Perl4 whatever you have
installed
TinyIgrep calls Igrep.el to to do the search, You can adjust
recursive grep options, set search case sensitivity, add user grep
options etc.
You can find latest `igrep.el' module at
<http://groups.google.com/groups?group=gnu.emacs.sources> The
maintainer is Jefin Rodgers <kevinr@ihs.com>.
TinyCompile -- To Browse grep results in Emacs *compile* buffer
TinyCompile is a minor mode for *compile* buffer from where
you can collapse unwanted lines or shorten file URLs:
/asd/asd/asd/asd/ads/as/da/sd/as/as/asd/file1:NNN: MATCHED TEXT
/asd/asd/asd/asd/ads/as/da/sd/as/as/asd/file2:NNN: MATCHED TEXT
-->
cd /asd/asd/asd/asd/ads/as/da/sd/as/as/asd/
file1:NNN: MATCHED TEXT
file1:NNN: MATCHED TEXT
End
------------------------------
Date: Thu, 27 Nov 2003 22:10:09 +1100
From: Edo <eddhig22@yahool.com>
Subject: Re: floating point
Message-Id: <3FC5DB91.3090306@yahool.com>
Josef Möllers wrote:
> Edo wrote:
>
>>Hello
>>why my sub cal which is suppose to return 0.879222 when it is
>>my $ca = cal (\@abc, \@xyz);
>>$ca returns 1.
>>
>>how can I get it to return whatever the exact value the sub calculates?
>
>
> How are we to tell?
> What does your sub look like?
> How do you know it returns 1?
>
> Too many questions, too little information ...
>
code
65: my $ca = cal (\@abc, \@xyz);
code
debugging
DB<1> b 65 $ca =1
DB<2> p $ca
1
DB<3> p cal (\@abc, \@xyz)
0.870588235294118
DB<4> q
------------------------------
Date: Thu, 27 Nov 2003 11:09:30 +0000 (UTC)
From: "Bernard El-Hagin" <bernard.el-haginDODGE_THIS@lido-tech.net>
Subject: Re: floating point
Message-Id: <Xns94407B61BE9AFelhber1lidotechnet@62.89.127.66>
Edo <eddhig22@yahool.com> wrote in news:3FC5DB91.3090306@yahool.com:
> Josef Möllers wrote:
>> Edo wrote:
>>
>>>Hello
>>>why my sub cal which is suppose to return 0.879222 when it is
>>>my $ca = cal (\@abc, \@xyz);
>>>$ca returns 1.
>>>
>>>how can I get it to return whatever the exact value the sub calculates?
>>
>>
>> How are we to tell?
>> What does your sub look like?
>> How do you know it returns 1?
>>
>> Too many questions, too little information ...
>>
>
> code
> 65: my $ca = cal (\@abc, \@xyz);
> code
[...]
Show the body of function cal()!
--
Cheers,
Bernard
------------------------------
Date: 27 Nov 2003 11:28:48 GMT
From: anno4000@lublin.zrz.tu-berlin.de (Anno Siegel)
Subject: Re: floating point
Message-Id: <bq4n5g$il$3@mamenchi.zrz.TU-Berlin.DE>
Edo <eddhig22@yahool.com> wrote in comp.lang.perl.misc:
> Josef Möllers wrote:
> > Edo wrote:
> >
> >>Hello
> >>why my sub cal which is suppose to return 0.879222 when it is
> >>my $ca = cal (\@abc, \@xyz);
> >>$ca returns 1.
> >>
> >>how can I get it to return whatever the exact value the sub calculates?
> >
> >
> > How are we to tell?
> > What does your sub look like?
> > How do you know it returns 1?
> >
> > Too many questions, too little information ...
> >
>
> code
> 65: my $ca = cal (\@abc, \@xyz);
> code
Oh man. We need to know *what cal() does*.
> debugging
>
> DB<1> b 65 $ca =1
>
> DB<2> p $ca
> 1
> DB<3> p cal (\@abc, \@xyz)
> 0.870588235294118
> DB<4> q
Look at Jay Tilton's reply again, I think he's right.
Your statement evaluates cal() in scalar context. The debugger evaluates
it in array context and shows all values it returns, that's why you see
"0.870588235294118" instead of 1.
But we can't know for sure until you deign to disclose what cal()
really does.
Anno
------------------------------
Date: Thu, 27 Nov 2003 12:21:13 GMT
From: "joeri" <jvandervloet@hotmail.com>
Subject: Re: How to create a DBM database in Perl
Message-Id: <Z_lxb.46109$p7.1418367@phobos.telenet-ops.be>
"Topher" <chris@mkttl.co.uk> wrote in message
news:f4487ccf.0311270246.5a82a5c@posting.google.com...
> Hi,
>
> I would appreciate some help with this. I am trying to create an admin
> section for my local table tennis (yes, it's a manly sport I know...)
> site and am having trouble creating any databases.
>
> The code I have for doing this is as follows:
>
> ## write
>
> dbmopen (%clubs, $const_database_path."clubs", 0666);
>
> die("club id already exists!") if ($clubs{$club_id} ne "");
>
> $clubs{$club_id} =
$club_name."§".$club_short_name."§".$club_location1."§".$club_location2."§".
$club_location3."§".$club_location4."§".$club_postcode."§".$club_map_href."§
".$club_map_text."§".$club_website_href."§".$club_notes."§".$club_secretary_
name."§".$club_secretary_add1."§".$club_secretary_add2."§".$club_secretary_a
dd3."§".$club_secretary_add4."§".$club_secretary_postcode."§".$club_secretar
y
>
home_tel."§".$club_secretary_mobile_tel."§".$club_secretary_work_tel."§".$cl
ub_secretary_email;
>
>
> dbmclose (%clubs);
>
>
What doesn't seem to be working for you? What do you expect this code to do?
J
------------------------------
Date: Thu, 27 Nov 2003 14:27:04 +0100
From: Gunnar Hjalmarsson <noreply@gunnar.cc>
Subject: Re: How to create a DBM database in Perl
Message-Id: <bq4u62$1tpju9$1@ID-184292.news.uni-berlin.de>
Topher wrote:
> I am trying to create an admin section for my local table tennis
> (yes, it's a manly sport I know...) site and am having trouble
> creating any databases.
>
> The code I have for doing this is as follows:
>
> ## write
>
> dbmopen (%clubs, $const_database_path."clubs", 0666);
Should better be:
dbmopen (%clubs, $const_database_path."clubs", 0666)
or die "Couldn't open database\n$!";
or something like that. That will result in an error message if e.g.
$const_database_path does not contain a valid path (which I doubt it
does, see below).
> die("club id already exists!") if ($clubs{$club_id} ne "");
>
> $clubs{$club_id} =
> $club_name."§".$club_short_name."§".$club_location1."§".
> $club_location2."§".$club_location3."§".$club_location4."§".
> $club_postcode."§".$club_map_href."§".$club_map_text."§".
> $club_website_href."§".$club_notes."§".$club_secretary_name."§".
> $club_secretary_add1."§".$club_secretary_add2."§".
> $club_secretary_add3."§".$club_secretary_add4."§".
> $club_secretary_postcode."§".$club_secretaryhome_tel."§".
> $club_secretary_mobile_tel."§".$club_secretary_work_tel."§".
> $club_secretary_email;
Without knowing anything about the rest of your application, including
how all those variables are populated, I have a feeling that your data
structure leaves room for improvements. :) But if you want advice in
that respect, you'd better explain more about what you are actually doing.
<snip>
> I have a file 'mkttl.conf', which is linked to earlier on in the
> script using require("mkttl.conf");
>
> In mkttl.conf I define $const_database_path as
> $ENV{"SITE_ROOT"}."\mkttl_concept\databases\"
That does certainly not seem to be correct. Is there really a
$ENV{"SITE_ROOT"} variable? And using backslashes within doublequotes
does likely result in something else but what you expect.
I would _guess_ that this is what you should have in mkttl.conf:
$const_database_path =
$ENV{DOCUMENT_ROOT} . '/mkttl_concept/databases/';
--
Gunnar Hjalmarsson
Email: http://www.gunnar.cc/cgi-bin/contact.pl
------------------------------
Date: Thu, 27 Nov 2003 14:10:00 +0100
From: Tore Aursand <tore@aursand.no>
Subject: Re: mod_perl
Message-Id: <pan.2003.11.27.05.37.06.121576@aursand.no>
On Thu, 27 Nov 2003 02:21:22 +0000, Lenny Challis wrote:
> Tell me, what is the best way to "learn" or atleast understand how
> mod_perl works? I have seen mod_perl o'reilly books, but cant afford
> them :(
There are (links to) a lot of documentation here:
http://perl.apache.org/
--
Tore Aursand <tore@aursand.no>
"A teacher is never a giver of truth - he is a guide, a pointer to the
truth that each student must find for himself. A good teacher is
merely a catalyst." -- Bruce Lee
------------------------------
Date: Thu, 27 Nov 2003 14:10:01 +0100
From: Tore Aursand <tore@aursand.no>
Subject: Re: module load question
Message-Id: <pan.2003.11.27.05.42.22.166134@aursand.no>
On Wed, 26 Nov 2003 23:29:59 -0500, Chuck Mattern wrote:
> I've only had a chance to do a cursory read of the code but one thing
> that intrigued me was a directive to use a module that was inside of a
> loop, with each iteration the module was called again. Is it possible
> that this is part of the memory consumption?
No;
perldoc -f use
See for yourself; Move the 'use' parts out of the loops and let the
program run for a while, and you should see that it still eats up memory.
Alas, your problem seems to be elsewhere.
--
Tore Aursand <tore@aursand.no>
"A teacher is never a giver of truth - he is a guide, a pointer to the
truth that each student must find for himself. A good teacher is
merely a catalyst." -- Bruce Lee
------------------------------
Date: Thu, 27 Nov 2003 15:11:25 +0200
From: "Jaan Kronberg" <jaan.kronberg@mail.ee>
Subject: number formatting..
Message-Id: <3fc5f7fb$0$155$bb624dac@diablo.uninet.ee>
Hello there,
my $somenumber = 1000000;
I'd like to format this $somenumber to look like 1.000.000,00
Can it be done with sprintf? Other ways?
Thx,
jk
------------------------------
Date: Thu, 27 Nov 2003 13:27:16 -0000
From: "Paul Boardman" <Paul.E.Boardman@umist.ac.uk>
Subject: Re: number formatting..
Message-Id: <3fc5fc2b$1@news.umist.ac.uk>
"Jaan Kronberg" <jaan.kronberg@mail.ee> wrote in message
news:3fc5f7fb$0$155$bb624dac@diablo.uninet.ee...
> my $somenumber = 1000000;
>
> I'd like to format this $somenumber to look like 1.000.000,00
> Can it be done with sprintf? Other ways?
perldoc -q "numbers with commas"
should get you on your way.
Paul
------------------------------
Date: Thu, 27 Nov 2003 12:12:46 -0000
From: "Bigus" <someone@somewhere.com>
Subject: Packages and returning errors
Message-Id: <bq4pnv$m0a@newton.cc.rl.ac.uk>
Hi
I'm attempting to put together my first package, but there's something
pretty fundamental that I haven't sussed out:
Say you are using the DBI module and you've just performed an query and you
want to see if it returned any errors, you could do something like:
if ( $db->errstr ) {print "That failed - ".$db->errstr;}
What I don't get is what exactly is "errstr"? I guess it's a function but
how would it work if I have a bit of code that goes:
if ( $blah < $blahh ) {
$rtnError = "Below practical size";
return;
}
and I then want to test $instance->rtnError in the same way as DBI.
Thanks
Bigus
------------------------------
Date: Thu, 27 Nov 2003 12:34:06 +0000 (UTC)
From: "Bernard El-Hagin" <bernard.el-haginDODGE_THIS@lido-tech.net>
Subject: Re: Packages and returning errors
Message-Id: <Xns944089B96E5BFelhber1lidotechnet@62.89.127.66>
"Bigus" <someone@somewhere.com> wrote in
news:bq4pnv$m0a@newton.cc.rl.ac.uk:
> Hi
>
> I'm attempting to put together my first package, but there's something
> pretty fundamental that I haven't sussed out:
>
> Say you are using the DBI module and you've just performed an query
> and you want to see if it returned any errors, you could do something
> like:
>
> if ( $db->errstr ) {print "That failed - ".$db->errstr;}
>
> What I don't get is what exactly is "errstr"? I guess it's a function
> but how would it work if I have a bit of code that goes:
>
> if ( $blah < $blahh ) {
> $rtnError = "Below practical size";
> return;
> }
> and I then want to test $instance->rtnError in the same way as DBI.
Then you would write a method which returns $rtnError and call *it*,
instead of trying to get at $rtnError on your own.
--
Cheers,
Bernard
------------------------------
Date: 27 Nov 2003 12:39:06 GMT
From: anno4000@lublin.zrz.tu-berlin.de (Anno Siegel)
Subject: Re: Packages and returning errors
Message-Id: <bq4r9a$7gd$1@mamenchi.zrz.TU-Berlin.DE>
Bigus <someone@somewhere.com> wrote in comp.lang.perl.misc:
> Hi
>
> I'm attempting to put together my first package, but there's something
> pretty fundamental that I haven't sussed out:
>
> Say you are using the DBI module and you've just performed an query and you
> want to see if it returned any errors, you could do something like:
>
> if ( $db->errstr ) {print "That failed - ".$db->errstr;}
>
> What I don't get is what exactly is "errstr"? I guess it's a function but
> how would it work if I have a bit of code that goes:
It is a method (i.e. a special kind of subroutine) that is applicable to
the object $db. I'd guess it returns the last error that happened with
the database.
> if ( $blah < $blahh ) {
> $rtnError = "Below practical size";
> return;
> }
> and I then want to test $instance->rtnError in the same way as DBI.
What is "$instance"? And why do you want to use a method to return
you own error strings? Mind you, there might be a reason, but offhand
I don't see it.
If you want that behavior, you'll have to build your own class with
am errstr method and take care that $instance is a correctly initialized
object in it.
Anno
------------------------------
Date: 27 Nov 2003 12:35:05 +0000
From: Brian McCauley <nobull@mail.com>
Subject: Re: Packages and returning errors
Message-Id: <u9k75mc7ly.fsf@wcl-l.bham.ac.uk>
"Bigus" <someone@somewhere.com> writes:
> I'm attempting to put together my first package, but there's something
> pretty fundamental that I haven't sussed out:
>
> Say you are using the DBI module and you've just performed an query and you
> want to see if it returned any errors, you could do something like:
>
> if ( $db->errstr ) {print "That failed - ".$db->errstr;}
>
> What I don't get is what exactly is "errstr"? I guess it's a function but
> how would it work if I have a bit of code that goes:
>
> if ( $blah < $blahh ) {
> $rtnError = "Below practical size";
> return;
> }
> and I then want to test $instance->rtnError in the same way as DBI.
The last error message is conceptually no different from any other bit
of instance data. However you are storing the rest of your instance
data, store the error the same way. Create an accesor...
sub rtnError {
my $self = shift;
# Do whatever is needed to retrice the last error from $self
# for example if this class is based on a blessed hash you could
# say something like...
$self->{last_error};
}
--
\\ ( )
. _\\__[oo
.__/ \\ /\@
. l___\\
# ll l\\
###LL LL\\
------------------------------
Date: Thu, 27 Nov 2003 14:42:45 +0100
From: Tore Aursand <tore@aursand.no>
Subject: Re: Packages and returning errors
Message-Id: <pan.2003.11.27.13.29.39.80842@aursand.no>
On Thu, 27 Nov 2003 12:35:05 +0000, Brian McCauley wrote:
> The last error message is conceptually no different from any other bit
> of instance data. However you are storing the rest of your instance
> data, store the error the same way. Create an accesor... [...]
Amen. A little digression, though; I've learned to _never_ return only
the last error message, but _all_ the error messages (or warnings) in my
application(s).
Why? Well. There are times when the _last_ error message really is a
error caused by a previous error "longer up in the error stack" (or
whatever I should call it).
So - at least make sure that your error accessor can return an array, too;
sub errstr {
my $self = shift;
# blah
my @errors = @{ $self->{'_errors'} };
return ( wantarray ) ? @errors : $errors[-1];
}
--
Tore Aursand <tore@aursand.no>
"A teacher is never a giver of truth - he is a guide, a pointer to the
truth that each student must find for himself. A good teacher is
merely a catalyst." -- Bruce Lee
------------------------------
Date: 27 Nov 2003 12:39:13 +0000
From: Brian McCauley <nobull@mail.com>
Subject: Re: Regex Question
Message-Id: <u9brqyc7f2.fsf@wcl-l.bham.ac.uk>
hjkmax@netscape.net (max) writes:
> How do I deal with escaped backslash in patterns?
This is covered in the FAQ "How can I split a [character] delimited
string except when inside [character]?"
--
\\ ( )
. _\\__[oo
.__/ \\ /\@
. l___\\
# ll l\\
###LL LL\\
------------------------------
Date: 27 Nov 2003 04:14:03 -0800
From: hobbit_hk@hotmail.com (Hobbit HK)
Subject: Socket Problem...
Message-Id: <22ee5d47.0311270414.23c2ab7f@posting.google.com>
I'm using AtivePerl 5.8 on WinXP and trying to do a script which
listens and writes to the same socket (with fork of course...). Now,
everything works great until I'm trying to write to the socket... The
program just stucks, I think because I'm trying to read and write
simultaneously... If I comment the read part everything goes smooth
(except I can't get msgs :)), here's the code:
use IO::Socket;
$|=1;
($host, $port) = @ARGV;
$port=23 if !$port;
$sock=new IO::Socket::INET->new(PeerAddr=>$host, PeerPort=>$port,
Proto=>'tcp') or die "Can't connect to $host on port $port! $!\n";
$sock->autoflush(1);
print "[Connected to $host on port $port]\n";
die "Can't fork! $!\n" unless defined($kidpid=fork());
if ($kidpid) {
while (sysread($sock, $byte, 1)==1) {
print "$byte";
}
kill 9, $kidpid;
}
else {
while (defined($msg=<STDIN>)) {
print "$msg\n";
}
}
------------------------------
Date: Thu, 27 Nov 2003 14:10:00 +0100
From: Tore Aursand <tore@aursand.no>
Subject: Re: went to 5.8.1 and now my while statement fails
Message-Id: <pan.2003.11.27.05.39.43.325304@aursand.no>
On Thu, 27 Nov 2003 04:23:34 +0000, pui ming Wong wrote:
> while( $msg = &read_message ) {
> $count++;
> print "count line is $count";
> }
Change this to:
while ( $msg = read_message() ) {
print "Message is: '$msg'\n";
$count++;
print "Count line is: $count\n";
}
And tell us what you (don't) see.
--
Tore Aursand <tore@aursand.no>
"A teacher is never a giver of truth - he is a guide, a pointer to the
truth that each student must find for himself. A good teacher is
merely a catalyst." -- Bruce Lee
------------------------------
Date: 6 Apr 2001 21:33:47 GMT (Last modified)
From: Perl-Users-Request@ruby.oce.orst.edu (Perl-Users-Digest Admin)
Subject: Digest Administrivia (Last modified: 6 Apr 01)
Message-Id: <null>
Administrivia:
The Perl-Users Digest is a retransmission of the USENET newsgroup
comp.lang.perl.misc. For subscription or unsubscription requests, send
the single line:
subscribe perl-users
or:
unsubscribe perl-users
to almanac@ruby.oce.orst.edu.
To submit articles to comp.lang.perl.announce, send your article to
clpa@perl.com.
To request back copies (available for a week or so), send your request
to almanac@ruby.oce.orst.edu with the command "send perl-users x.y",
where x is the volume number and y is the issue number.
For other requests pertaining to the digest, send mail to
perl-users-request@ruby.oce.orst.edu. Do not waste your time or mine
sending perl questions to the -request address, I don't have time to
answer them even if I did know the answer.
------------------------------
End of Perl-Users Digest V10 Issue 5865
***************************************