RE: Can I set '$!' ?

From: Daniel Staal (DStaal_at_usa.net)
Date: 12/29/03


Date: Mon, 29 Dec 2003 14:17:33 -0500
To: Perl Newbies <beginners@perl.org>


--As off Monday, December 29, 2003 12:54 PM -0600, Dan Muey is
alleged to have said:

>> I want to be able to return a true or false value from a
>> function in a module and populate the $! variable with the
>> specific errors. Is this possible? Is there documentation on
>> how to do this? I can find docs on how to use $! but not how
>> to set it. Thanks for any help -Ken
>
> Did anyone ever reply to this post?
> I couldn't find it in the archives and I thinnk it's a pretty good
> question.

There were several responses, I can forward them to you if you really
want them. Basically it boiled down to: "Read 'perldoc perlvar' for
how and possible values.", and "Are you sure you want to do that?".

> For instance would it be 'safe' and 'proper', and 'ok', etc... to
> do somethign like:
>
> sub whatever {
> my $foo = shift;
> undef $!;
> if($foo eq 'bar') { return 1; }
> else { $! = "Foo must equal bar";return 0; }
> }

"Foo must equal bar" is not a valid value for $!, most likely. :-)
For what you are doing here I would really prefer you either 'die' or
'warn', depending on what severity you think the problem is. (You
could of course 'croak' or 'carp' instead, as applicable.)

Daniel T. Staal

---------------------------------------------------------------
This email copyright the author. Unless otherwise noted, you
are expressly allowed to retransmit, quote, or otherwise use
the contents for non-commercial purposes. This copyright will
expire 5 years after the author's death, or in 30 years,
whichever is longer, unless such a period is in excess of
local copyright law.
---------------------------------------------------------------



Relevant Pages

  • Re: RE: User Forms
    ... I have the FillCboBoxList sub in the userform module. ... ComboBox named: ComboBox1 ... click on, say, letter A, I want the control to populate my cbo box with ... Right-Click on the Excel icon ...
    (microsoft.public.excel.newusers)
  • Re: How to prompt user to input data
    ... However it does not populate the Insurance_Premium field once you hit ... Private Sub InsuranceSold_Click ... If InsuranceSold Then ... add it below or above the Option Compare Database line and then ...
    (microsoft.public.access.formscoding)
  • RE: Adding values to a combo box
    ... First the reason you're having difficulty with the code being in the Sheet1 ... Private Sub Workbook_Open ... 'Add your code to populate the combobox here ... the combo box is on Sheet1 and the array is on Sheet2. ...
    (microsoft.public.excel.programming)
  • Re: multi threading and AJAX
    ... and each one takes more or less 10 seconds to finish populate his own ... Protected Sub Page_Load(ByVal sender As Object, ... Dim NewThread As Thread = New Thread(AddressOf callDRService) ...
    (microsoft.public.dotnet.framework.aspnet)
  • Re: Dynamically populating Combo Box .?
    ... Sub PopulatecbBox() ... Dim oleConn As New System.Data.OleDb.OleDbConnection ... >> I populate my dataset and set the dataset as the datasource of my combo ... >> strAccNo is a variable within my VB app. ...
    (microsoft.public.dotnet.languages.vb.controls)