Alok Bhatt wrote:

>
> Hi Jai,

Hi Alok,

Please don't top-post.  Instead, follow the material you are responding to, and
trim extraneous matter.

> ....
> > But the waring message output line 37 is
> > different(just behaves as print) from same kind of
> > message at line 57. Any suggestions please..
> > regards,
> > Jay
> ...

> >     36           {
> >     37           warn " Not able to create
> > reg_test_cols \n" ;
>
>  A similar question was posted just yesterday. The
> difference between  between the two lines (37 and 57)
> is that the second line contains a space after "\n".
>  As pointed earlier, you can take take it as a
> debugging option (ie remove \n or add a space and perl
> prints out the line no. too)
>
> :-)
> Alok Bhatt

Not exactly.  It is not the newline "\n" that would give the full output of the
warn function, but the $! variable, which contains the most recent warning or
error message.  It is pretty much the same as with die().  The problem was not
space after the newline, but the presence of the newline.  The $! variable
should not be followed by anything.  If left as the last element of the warn or
die message, it will be unrolled to the line number in the program as well as
the line number in the currently selected filehandle.

warn "Something went wrong in function_name(), while doing something dangerous:
$!";

Greetings! E:\d_drive\perlstuff>perl -w
open IN, 'some_nonexistent_filename' or warn "Something went wrong in main(), "
. "while doing something dangerous:\n $!";
my $stuff = <IN>;
print $stuff;

^Z
Something went wrong in main(), while doing something dangerous:
 No such file or directory at - line 1.
readline() on closed filehandle IN at - line 3.
Use of uninitialized value in print at - line 4.


Joseph


-- 
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
<http://learn.perl.org/> <http://learn.perl.org/first-response>


Reply via email to