[30023] in Perl-Users-Digest

home help back first fref pref prev next nref lref last post

Perl-Users Digest, Issue: 1266 Volume: 11

daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Sat Feb 9 16:09:55 2008

Date: Sat, 9 Feb 2008 13:09:13 -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           Sat, 9 Feb 2008     Volume: 11 Number: 1266

Today's topics:
        "Use of uninitialized value" warning <christian@altfrau.de>
    Re: "Use of uninitialized value" warning <joost@zeekat.nl>
        Conditional match similar to IDL's where function vorticitywolfe@gmail.com
        how can DBI not let AutoCommit be turned off???? <gbs@netbox.com>
    Re: how can DBI not let AutoCommit be turned off???? <joost@zeekat.nl>
    Re: moving binary data from one RDBMS to Other <rvtol+news@isolution.nl>
    Re: moving binary data from one RDBMS to Other <hjp-usenet2@hjp.at>
        new CPAN modules on Sat Feb  9 2008 (Randal Schwartz)
        PerlCtrl's IDL and enums <Bruce.Axtens@gmail.com>
    Re: problem with '>' character <rvtol+news@isolution.nl>
        Testing on empty variable <"v.niekerk at hccnet.nl">
    Re: Testing on empty variable <jurgenex@hotmail.com>
    Re: Testing on empty variable <joost@zeekat.nl>
    Re: Testing on empty variable <joost@zeekat.nl>
    Re: Testing on empty variable <"v.niekerk at hccnet.nl">
    Re: Testing on empty variable <"v.niekerk at hccnet.nl">
    Re: Tie::IxHash::Easy with "eval()" <ced@blv-sam-01.ca.boeing.com>
    Re: Using END and the die function <stoupa@practisoft.cz>
    Re: Using END and the die function <tadmc@seesig.invalid>
    Re: Using END and the die function <ben@morrow.me.uk>
        Digest Administrivia (Last modified: 6 Apr 01) (Perl-Users-Digest Admin)

----------------------------------------------------------------------

Date: 9 Feb 2008 20:48:24 GMT
From: Christian Neumann <christian@altfrau.de>
Subject: "Use of uninitialized value" warning
Message-Id: <616hsoF1uai4eU1@mid.dfncis.de>

Hi!
I have two variables which I want to compare with the eq operator (perl 
5.8), where one or both of them may be undefined, and if both are 
undefined, they should be equal. The "eq" op works as expected, but 
sometimes I'll get the "Use of uninitialized value in string eq" warning.
Is there a more beautiful way of comparing two possibly undefined 
variables beside of turning off the warning (and endless pre-comparing 
like defined $var1 and ...)?

Thanks,
Christian


------------------------------

Date: Sat, 09 Feb 2008 22:03:11 +0100
From: Joost Diepenmaat <joost@zeekat.nl>
Subject: Re: "Use of uninitialized value" warning
Message-Id: <873as1etbk.fsf@zeekat.nl>

Christian Neumann <christian@altfrau.de> writes:

> Is there a more beautiful way of comparing two possibly undefined 
> variables beside of turning off the warning (and endless pre-comparing 
> like defined $var1 and ...)?

Just write your own "eq":

sub eq_undef {
  my ($s1,$s2) = @_;
  if (defined($s1) and defined($s2)) {
    $s1 eq $s2;
  }
  else {
    defined($s1) == defined($s2);
  }
}


-- 
Joost Diepenmaat | blog: http://joost.zeekat.nl/ | work: http://zeekat.nl/


------------------------------

Date: Sat, 9 Feb 2008 10:32:32 -0800 (PST)
From: vorticitywolfe@gmail.com
Subject: Conditional match similar to IDL's where function
Message-Id: <72ed8c9b-7c4d-4174-ae2a-0092d8ec46b6@i7g2000prf.googlegroups.com>

Hello,

I'm been trying to produce a result similar to IDL's where
function...that returns the indices of where a condition is true.

For example:
@array=(2,4,7,9,10,16,20,82);
print where(@array < 20 and @array >= 10);

this should print 4,5  indicating that at index 4 and index 5 this
condition is true.

previous posts always match if something exists in a string, I want to
mathematically check a condition
>>"What are the indices of elements that match?", you'll need something like
>> @indices = grep $array[$_]=~/something/, 0..$#array;

Do you have any ideas for me?

Thanks for the help!

Jonathan








------------------------------

Date: Fri, 8 Feb 2008 20:53:54 -0800 (PST)
From: gbs <gbs@netbox.com>
Subject: how can DBI not let AutoCommit be turned off????
Message-Id: <014ded1f-80ff-4ed6-80ca-351c2915d724@s13g2000prd.googlegroups.com>

mysqlPP.pm line 299 does not allow AutoCommit to be set to 0; it just
does not! How is this possible?

Greg Silverman
HP
Cupertino, CA


------------------------------

Date: Sat, 09 Feb 2008 13:53:37 +0100
From: Joost Diepenmaat <joost@zeekat.nl>
Subject: Re: how can DBI not let AutoCommit be turned off????
Message-Id: <87wspewasu.fsf@zeekat.nl>

gbs <gbs@netbox.com> writes:

> mysqlPP.pm line 299 does not allow AutoCommit to be set to 0; it just
> does not! How is this possible?

Probably because the author didn't want to implement it. If you're
half-way serious about using MySQL, you should use DBD::mysql instead.

-- 
Joost Diepenmaat | blog: http://joost.zeekat.nl/ | work: http://zeekat.nl/


------------------------------

Date: Sat, 9 Feb 2008 12:37:34 +0100
From: "Dr.Ruud" <rvtol+news@isolution.nl>
Subject: Re: moving binary data from one RDBMS to Other
Message-Id: <fok6t7.1ig.1@news.isolution.nl>

Perl Lover schreef:

> I am looking at the possibility of perl incorrectly reporting 
> two identical binary strings as different.

Maybe you are looking for:

{ use bytes;

  if ($a eq $b) {
      ...
  }
}

See `perldoc bytes`.

-- 
Affijn, Ruud

"Gewoon is een tijger."


------------------------------

Date: Sat, 9 Feb 2008 19:20:09 +0100
From: "Peter J. Holzer" <hjp-usenet2@hjp.at>
Subject: Re: moving binary data from one RDBMS to Other
Message-Id: <slrnfqrrmr.iu0.hjp-usenet2@hrunkner.hjp.at>

On 2008-02-08 19:30, Perl Lover <a@a.com> wrote:
> In article <slrnfqp9pp.b27.hjp-usenet2@hrunkner.hjp.at>, Peter J. Holzer says...
>
>>> When we use BLOB data type to store the
>>> value in Oracle, it shows them as equal.
>>
>>That's new. I understood your previous posting that it doesn't work with
>>blobs if the data is written to a file and read back - which suggested
>>some problem related to file handling.
>
> This is true. It works only with direct feed and not via file.
>
> This is what I wrote originally:
>
> "I am currently writing a perl dbi script to copy data from one rdbms to
> another.
> One of the columns contain binary data. When I copy the data directly (reading
> it from source, feeding it to target), it works fine. However when I save the
> source data first in a file and then use that file to load it to the target it
> messes up the binary data."

How do you "use that file to load it to the target"? Feed it to sqlldr?
Read the data with another perl script and then insert it via DBI? 
In the first case you have to produce the format sqlldr expects. 


> I use print FILEHANDLE to write it to the file.

I don't think this tells us anything we didn't already know.

	hp


------------------------------

Date: Sat, 9 Feb 2008 05:42:17 GMT
From: merlyn@stonehenge.com (Randal Schwartz)
Subject: new CPAN modules on Sat Feb  9 2008
Message-Id: <JvyIIH.BHA@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.

Apache-SWIT-0.32
http://search.cpan.org/~bosu/Apache-SWIT-0.32/
mod_perl based application server with integrated testing. 
----
Bundle-Atoll-0.03
http://search.cpan.org/~icabrera/Bundle-Atoll-0.03/
Perl extension for ALPAGE Linguistic Processing Chain 
----
CGI-JSONRPC-0.07
http://search.cpan.org/~crakrjack/CGI-JSONRPC-0.07/
CGI handler for JSONRPC 
----
Catalyst-Authentication-Store-DBIx-Class-0.103
http://search.cpan.org/~jayk/Catalyst-Authentication-Store-DBIx-Class-0.103/
A storage class for Catalyst Authentication using DBIx::Class 
----
Class-Inflate-0.06
http://search.cpan.org/~kolibrie/Class-Inflate-0.06/
Inflate HASH Object from Values in Database 
----
Config-Validate-0.2.1
http://search.cpan.org/~cmo/Config-Validate-0.2.1/
Validate data structures generated from configuration files. (Or anywhere else) 
----
Config-Validate-0.2.2
http://search.cpan.org/~cmo/Config-Validate-0.2.2/
Validate data structures generated from configuration files. (Or anywhere else) 
----
Crypt-OpenSSL-CA-0.14
http://search.cpan.org/~domq/Crypt-OpenSSL-CA-0.14/
The crypto parts of an X509v3 Certification Authority 
----
DBIx-EnumConstraints-0.03
http://search.cpan.org/~bosu/DBIx-EnumConstraints-0.03/
generates enum-like SQL constraints. 
----
Data-Table-1.53
http://search.cpan.org/~ezdb/Data-Table-1.53/
Data type related to database tables, spreadsheets, CSV/TSV files, HTML table displays, etc. 
----
Date-MonthSet-0.1
http://search.cpan.org/~diz/Date-MonthSet-0.1/
simple interface to a collection of months 
----
DateTime-Format-Natural-0.67
http://search.cpan.org/~schubiger/DateTime-Format-Natural-0.67/
Create machine readable date/time with natural parsing logic 
----
ExtUtils-CBuilder-0.22
http://search.cpan.org/~kwilliams/ExtUtils-CBuilder-0.22/
Compile and link C code for Perl modules 
----
ExtUtils-ModuleMaker-0.51
http://search.cpan.org/~jkeenan/ExtUtils-ModuleMaker-0.51/
Better than h2xs for creating modules 
----
File-chdir-0.10
http://search.cpan.org/~dagolden/File-chdir-0.10/
a more sensible way to change directories 
----
HTML-FillInForm-Lite-0.02
http://search.cpan.org/~gfuji/HTML-FillInForm-Lite-0.02/
Fills in HTML forms with data 
----
HTML-Formulate-0.09
http://search.cpan.org/~gavinc/HTML-Formulate-0.09/
module for producing/rendering HTML forms 
----
HTML-Widgets-NavMenu-1.0100
http://search.cpan.org/~shlomif/HTML-Widgets-NavMenu-1.0100/
A Perl Module for Generating HTML Navigation Menus 
----
JE-0.021
http://search.cpan.org/~sprout/JE-0.021/
Pure-Perl ECMAScript (JavaScript) Engine 
----
JSON-2.06
http://search.cpan.org/~makamaka/JSON-2.06/
JSON (JavaScript Object Notation) encoder/decoder 
----
KSx-Analysis-StripAccents-0.01
http://search.cpan.org/~sprout/KSx-Analysis-StripAccents-0.01/
Remove accents and fold to lowercase 
----
Log-Handler-0.38_07
http://search.cpan.org/~bloonix/Log-Handler-0.38_07/
Log messages to one or more outputs. 
----
Log-Handler-0.38_08
http://search.cpan.org/~bloonix/Log-Handler-0.38_08/
Log messages to one or more outputs. 
----
MSN
http://search.cpan.org/~kenwu/MSN/
----
Microarray-0.42
http://search.cpan.org/~cjones/Microarray-0.42/
A Perl module for creating and manipulating DNA Microarray experiment objects 
----
Net-DNS-0.63
http://search.cpan.org/~olaf/Net-DNS-0.63/
Perl interface to the DNS resolver 
----
Net-Flickr-API-1.68
http://search.cpan.org/~ascope/Net-Flickr-API-1.68/
base API class for Net::Flickr::* libraries 
----
Net-Ping-2.35
http://search.cpan.org/~smpeters/Net-Ping-2.35/
check a remote host for reachability 
----
Net-SFTP-Foreign-1.35
http://search.cpan.org/~salva/Net-SFTP-Foreign-1.35/
Secure File Transfer Protocol client 
----
Net-Whois-Raw-1.41
http://search.cpan.org/~despair/Net-Whois-Raw-1.41/
Get Whois information for domains 
----
Ocsinventory-Agent-0.0.8
http://search.cpan.org/~goneri/Ocsinventory-Agent-0.0.8/
----
POE-Component-WebService-Validator-CSS-W3C-0.01
http://search.cpan.org/~zoffix/POE-Component-WebService-Validator-CSS-W3C-0.01/
non-blocking access to CSS validator. 
----
Parse-Stata-DtaReader-0.6
http://search.cpan.org/~reckon/Parse-Stata-DtaReader-0.6/
CPAN release history 
----
Rose-DB-0.739
http://search.cpan.org/~jsiracusa/Rose-DB-0.739/
A DBI wrapper and abstraction layer. 
----
Rose-DB-Object-0.7665
http://search.cpan.org/~jsiracusa/Rose-DB-Object-0.7665/
Extensible, high performance RDBMS-OO mapper. 
----
Test-DBICSchemaLoaderDigest-0.01
http://search.cpan.org/~tokuhirom/Test-DBICSchemaLoaderDigest-0.01/
test the DBIC::Schema::Loader's MD5 sum 
----
Test-DBICSchemaLoaderDigest-0.02
http://search.cpan.org/~tokuhirom/Test-DBICSchemaLoaderDigest-0.02/
test the DBIC::Schema::Loader's MD5 sum 
----
Test-Harness-3.08
http://search.cpan.org/~andya/Test-Harness-3.08/
Run Perl standard test scripts with statistics 
----
Test-TempDatabase-0.13
http://search.cpan.org/~bosu/Test-TempDatabase-0.13/
temporary database creation and destruction. 
----
Tie-Hash-MultiValue-0.06
http://search.cpan.org/~mcmahon/Tie-Hash-MultiValue-0.06/
store multiple values per key 
----
Tk-Getopt-0.49_54
http://search.cpan.org/~srezic/Tk-Getopt-0.49_54/
User configuration window for Tk with interface to Getopt::Long 
----
URI-Template-0.11
http://search.cpan.org/~bricas/URI-Template-0.11/
Object for handling URI templates 
----
Unicode-EastAsianWidth-1.20
http://search.cpan.org/~audreyt/Unicode-EastAsianWidth-1.20/
East Asian Width properties 
----
Unicode-EastAsianWidth-1.30
http://search.cpan.org/~audreyt/Unicode-EastAsianWidth-1.30/
East Asian Width properties 
----
Win32-Capture-1.1
http://search.cpan.org/~kenwu/Win32-Capture-1.1/
Capature Win32 screen with lightweight Win32::GUI::DIBitmap. 
----
XML-Compile-0.68
http://search.cpan.org/~markov/XML-Compile-0.68/
Compilation based XML processing 
----
XML-Compile-SOAP-0.67
http://search.cpan.org/~markov/XML-Compile-SOAP-0.67/
base-class for SOAP implementations 
----
XML-LibXML-Simple-0.11
http://search.cpan.org/~markov/XML-LibXML-Simple-0.11/
XML::LibXML clone of XML::Simple::XMLin() 
----
XML-OPML-SimpleGen-0.04
http://search.cpan.org/~stephenca/XML-OPML-SimpleGen-0.04/
create OPML using XML::Simple 
----
XML-RSS-1.32
http://search.cpan.org/~shlomif/XML-RSS-1.32/
creates and updates RSS files 
----
XML-XSH2-2.1.1
http://search.cpan.org/~pajas/XML-XSH2-2.1.1/
A powerfull scripting language/shell for XPath-based editing of XML 
----
YAML-YuyuPress-0.05
http://search.cpan.org/~jmerelo/YAML-YuyuPress-0.05/
Tool for making presentacions out of YAML files. 
----
list_versions-0.03
http://search.cpan.org/~zoffix/list_versions-0.03/


If you're an author of one of these modules, please submit a detailed
announcement to comp.lang.perl.announce, and we'll pass it along.

This message was generated by a Perl program described in my Linux
Magazine column, which can be found on-line (along with more than
200 other freely available past column articles) at
  http://www.stonehenge.com/merlyn/LinuxMag/col82.html

print "Just another Perl hacker," # the original

--
Randal L. Schwartz - Stonehenge Consulting Services, Inc. - +1 503 777 0095
<merlyn@stonehenge.com> <URL:http://www.stonehenge.com/merlyn/>
Perl/Unix/security consulting, Technical writing, Comedy, etc. etc.
See PerlTraining.Stonehenge.com for onsite and open-enrollment Perl training!


------------------------------

Date: Sat, 9 Feb 2008 04:05:45 -0800 (PST)
From: axtens <Bruce.Axtens@gmail.com>
Subject: PerlCtrl's IDL and enums
Message-Id: <4d55b011-619d-4cae-ba81-0bc7883e9fd3@1g2000hsl.googlegroups.com>

G'day everyone.

Is there a way to specify enums in the IDL for a PerlCtrl?

Kind regards,
Bruce.


------------------------------

Date: Sat, 9 Feb 2008 12:42:21 +0100
From: "Dr.Ruud" <rvtol+news@isolution.nl>
Subject: Re: problem with '>' character
Message-Id: <fok76k.t4.1@news.isolution.nl>

Petr Vileta schreef:

> s/[\r\n]*$//g;

   s/\*/+/, s/g// for $regex; 

-- 
Affijn, Ruud

"Gewoon is een tijger."


------------------------------

Date: Sat, 09 Feb 2008 20:39:53 +0100
From: Huub <"v.niekerk at hccnet.nl">
Subject: Testing on empty variable
Message-Id: <47ae0189$0$6501$e4fe514c@dreader17.news.xs4all.nl>

Hi,

I'm reading records from an MySQL database in order to print some of 
them. The reading works well. Next is that I want to skip the empty 
records. In CPAN I searched for "if" and found the "switch" statement:

	$naam = "select naam from hvw where lidnr = $record";
	$sth = $dbh->prepare($naam);
	$sth->execute or die "SQL Error: $DBI::errstr\n";
	@naam = $sth->fetchrow_array;
	switch (@naam)
	{
		case " " { $record++; print "empty record: $record\n"; }
		else ( read the rest of the fields from the database and print them }
	}

Problem is that it seems to ignore the 'case " "', because everything is 
printed. Where do I go wrong?

Thanks.


------------------------------

Date: Sat, 09 Feb 2008 19:50:25 GMT
From: Jürgen Exner <jurgenex@hotmail.com>
Subject: Re: Testing on empty variable
Message-Id: <ds0sq3pmblahlrst9cb7eqd2k8saua45lp@4ax.com>

Huub <"v.niekerk at hccnet.nl"> wrote:
>Hi,
>
>I'm reading records from an MySQL database in order to print some of 
>them. The reading works well. Next is that I want to skip the empty 
>records. In CPAN I searched for "if" and found the "switch" statement:
>
>	$naam = "select naam from hvw where lidnr = $record";
>	$sth = $dbh->prepare($naam);
>	$sth->execute or die "SQL Error: $DBI::errstr\n";
>	@naam = $sth->fetchrow_array;
>	switch (@naam)
>	{
>		case " " { $record++; print "empty record: $record\n"; }
>		else ( read the rest of the fields from the database and print them }
>	}

Is there anything wrong with a simple

	for (@naam){
		if ($_ eq '') 
			{$record++; print "empty record: $record\n";
		} else { read the rest of the fields from the database and
print them }
		}
	}

jue
			


------------------------------

Date: Sat, 09 Feb 2008 20:52:12 +0100
From: Joost Diepenmaat <joost@zeekat.nl>
Subject: Re: Testing on empty variable
Message-Id: <87odapx5zn.fsf@zeekat.nl>

Huub <"v.niekerk at hccnet.nl"> writes:

Hi Huub,

I'm assuming you're using the CPAN Switch module.

> 	switch (@naam)

switch() takes a single scalar argument, not a list or array (though it
may be an array reference). You probably want to loop over each element
in @naam (or maybe not, it depends on what's in @naam):

#!perl
use strict;
use warnings;
use Switch;

my @naam = (' ', 'something', 'else');

foreach my $nam (@naam) {
  switch($nam) {
    case " " { print "space\n" }
    else { print "Something else: $nam\n" }
  }
}


-- 
Joost Diepenmaat | blog: http://joost.zeekat.nl/ | work: http://zeekat.nl/


------------------------------

Date: Sat, 09 Feb 2008 20:54:23 +0100
From: Joost Diepenmaat <joost@zeekat.nl>
Subject: Re: Testing on empty variable
Message-Id: <87k5ldx5w0.fsf@zeekat.nl>


Oh, and note that Switch is notorious for causing very unintuitive
bugs. Personally I wouldn't use it for anything serious and take the
occasional ugly if .. elsif .. else construct.

-- 
Joost Diepenmaat | blog: http://joost.zeekat.nl/ | work: http://zeekat.nl/


------------------------------

Date: Sat, 09 Feb 2008 21:04:01 +0100
From: Huub <"v.niekerk at hccnet.nl">
Subject: Re: Testing on empty variable
Message-Id: <47ae0731$0$6508$e4fe514c@dreader17.news.xs4all.nl>

> Is there anything wrong with a simple
> 
> 	for (@naam){
> 		if ($_ eq '') 
> 			{$record++; print "empty record: $record\n";
> 		} else { read the rest of the fields from the database and
> print them }
> 		}
> 	}

Nothing wrong with this. Thank you very much.


------------------------------

Date: Sat, 09 Feb 2008 21:04:54 +0100
From: Huub <"v.niekerk at hccnet.nl">
Subject: Re: Testing on empty variable
Message-Id: <47ae0766$0$6508$e4fe514c@dreader17.news.xs4all.nl>

Joost Diepenmaat wrote:
> Oh, and note that Switch is notorious for causing very unintuitive
> bugs. Personally I wouldn't use it for anything serious and take the
> occasional ugly if .. elsif .. else construct.
> 

I prefer to use "if"...


------------------------------

Date: Sat, 9 Feb 2008 02:21:53 -0800 (PST)
From: "comp.llang.perl.moderated" <ced@blv-sam-01.ca.boeing.com>
Subject: Re: Tie::IxHash::Easy with "eval()"
Message-Id: <5a44d90c-5b17-4eac-bbaa-79f1bc98571f@i12g2000prf.googlegroups.com>

On Feb 5, 4:07 pm, Pat <n...@none.none> wrote:
> Hi,
>
> I'd like to use "Tie::IxHash" to maintain the order of keys in a hash.
> Since the hash can contain other hashes (and so on), I need to use
> "Tie::IxHash::Easy" so that the nested hashes also maintain their ordering.
>
> I'm reading the entire hash from a file.  The format of the file is exactly
> like Data::Dumper so that I can build the hash by simply saying:
>
>    eval($file_contents);
>
> This fails because there's no way to "tie" the internal workings of eval to
> "Tie::IxHash::Easy" so it always just returns a normal hash.  Copying the
> returned into an IxHash has no effect because the ordering is already lost.
>
> So, how can I load an IxHash from a file in Data::Dumper format and
> preserve its order (including nested hashes)?
>

Using MLDBM with Tie::IxHash::Easy and the default serializer seems to
work for a single level, eg.

use MLDBM 'Tie::IxHash::Easy'
tie my %h, 'MLDBM' or die ...;
@h{qw/key1 key2 key3 /} = 1..3;
print Dumper \%h;

and for a multi-level hash, you could theoretically write and then use
a custom serialization package
to do this IIUC (see MLDBM doc.) ... eg.,

use MLDBM 'Tie::IxHash::Easy','MyIxSerializer';
use strict;
use warnings;
 ...

--
Charles DeRykus


------------------------------

Date: Sat, 9 Feb 2008 02:40:32 +0100
From: "Petr Vileta" <stoupa@practisoft.cz>
Subject: Re: Using END and the die function
Message-Id: <foj0mr$2anb$1@ns.felk.cvut.cz>

pgodfrin wrote:
> Greetings,
> I'd like to die() with a return code (no pun intended) - I'm not sure
> how to do it without wrapping some extra code around die. Any
> thoughts?
> 
In similar cases I use some like this

if($?) 
    {
    do_exit($?,"Error generating temp file names");
    }

sub do_exit 
{
my ($return_code,$message)=@_;
warn "$message\n";
exit $return_code;
}
-- 
Petr Vileta, Czech republic
(My server rejects all messages from Yahoo and Hotmail. Send me your
mail from another non-spammer site please.) 

Please reply to <petr AT practisoft DOT cz>



------------------------------

Date: Fri, 8 Feb 2008 17:56:08 -0600
From: Tad J McClellan <tadmc@seesig.invalid>
Subject: Re: Using END and the die function
Message-Id: <slrnfqpr0o.96t.tadmc@tadmc30.sbcglobal.net>

pgodfrin <pgodfrin@gmail.com> wrote:
> On Feb 8, 1:28 pm, nolo contendere <simon.c...@fmr.com> wrote:
>> On Feb 8, 2:07 pm, pgodfrin <pgodf...@gmail.com> wrote:
>>
>>
>> > I'd like to die() with a return code (no pun intended) - I'm not sure
>> > how to do it without wrapping some extra code around die. Any
>> > thoughts?
>>
>> > Here's a snippet:

[ snip snippet ]

>> > This works fine if I explicitly code both steps - first setting the
>> > $return_code and then executing die. But, this kind of statement won't
>> > permit that 'cause of the nature of the or operator:
>>
>> > mkdir($tgt_dir) or die "Mkdir ($tgt_dir) command failed.\n";


>> Would 'exit' suit your needs? Just 'warn' whatever message you want,
>> then call 'exit' with the return code you want.
>
> That would work, but it's still a two step operation, so I couldn't
> use the or operator. 


Sure you could:

   mkdir($tgt_dir) or warn "Mkdir ($tgt_dir) command failed.\n" and exit 42;

Reads like English:

   make the directory or warn and exit


-- 
Tad McClellan
email: perl -le "print scalar reverse qq/moc.noitatibaher\100cmdat/"


------------------------------

Date: Sat, 9 Feb 2008 09:34:46 +0000
From: Ben Morrow <ben@morrow.me.uk>
Subject: Re: Using END and the die function
Message-Id: <mm8085-apa.ln1@osiris.mauzo.dyndns.org>


Quoth pgodfrin <pgodfrin@gmail.com>:
> Greetings,
> I'd like to die() with a return code (no pun intended) - I'm not sure
> how to do it without wrapping some extra code around die. Any
> thoughts?
> 
> Here's a snippet:
> if($?) { $return_code=$?; die "Error generating temp file names\n" ;}
> ...
> END
> {
> if (defined WL) { close WL; }
> print "Script ended. RC=$return_code \n";
> $?=$return_code;
> }

{
    my $ex;

    sub my_die {
        $ex = $_[0];
        die $_[1];
    }

    END { $ex and $? = $ex }
}

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 V11 Issue 1266
***************************************


home help back first fref pref prev next nref lref last post