[30971] in Perl-Users-Digest
Perl-Users Digest, Issue: 2216 Volume: 11
daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Tue Feb 17 11:09:47 2009
Date: Tue, 17 Feb 2009 08:09:12 -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 Tue, 17 Feb 2009 Volume: 11 Number: 2216
Today's topics:
Re: Generating html page in UTF-8 <noreply@gunnar.cc>
Re: how do I print the name and value of a scalar <RedGrittyBrick@spamweary.invalid>
Re: how do I print the name and value of a scalar <syscjm@sumire.gwu.edu>
Re: how do I print the name and value of a scalar <devnull4711@web.de>
Re: how do I print the name and value of a scalar <RedGrittyBrick@spamweary.invalid>
Re: how do I print the name and value of a scalar <cartercc@gmail.com>
Re: how do I print the name and value of a scalar <devnull4711@web.de>
Net::SSH2 scp_put not working! <schaitan@gmail.com>
Re: Net::SSH2 scp_put not working! <noreply@gunnar.cc>
Re: Net::SSH2 scp_put not working! <zentara@highstream.net>
Re: Net::SSH2 scp_put not working! <schaitan@gmail.com>
Re: Perl script - Linux to Windows <noreply@gunnar.cc>
Re: Perl script - Linux to Windows <name@champ.com>
Re: Perl script - Linux to Windows <guru.naveen@gmail.com>
Re: Perl script - Linux to Windows <guru.naveen@gmail.com>
Re: Perl script - Linux to Windows <RedGrittyBrick@spamweary.invalid>
Re: Perl script - Linux to Windows <noreply@gunnar.cc>
Re: Perl script - Linux to Windows <jurgenex@hotmail.com>
Re: question on de-referencing expressions <tzz@lifelogs.com>
Read/write with UCS-2* encodings - Possible??? <nospam-abuse@ilyaz.org>
Re: Read/write with UCS-2* encodings - Possible??? <perl@marc-s.de>
Digest Administrivia (Last modified: 6 Apr 01) (Perl-Users-Digest Admin)
----------------------------------------------------------------------
Date: Tue, 17 Feb 2009 12:16:32 +0100
From: Gunnar Hjalmarsson <noreply@gunnar.cc>
Subject: Re: Generating html page in UTF-8
Message-Id: <6vvkgvFm6q02U1@mid.individual.net>
dn.perl@gmail.com wrote:
> I am using a myscript.cgi, written in Perl, to query an Oracle table,
> and display a few fields in a browser. One field is of the type LONG
> or CLOB, depending on which Oracle Server I am querying. If I run the
> "select myfield from mytable" command from a Windows Oracle client, I
> can see the field correctly. If I run the same command within 'sqlplus
> user/password' session within FreeBSD, the text of the CLOB field is
> not shown correctly.
>
> I think the problem is two-fold. I am now passing (hopefully) the
> correct ora_charset to DBI->connect ("db-details", "user",
> "password" , {ora_charset => correct_set}). But the browser still
> would not show the field correctly. I wonder whether I need to specify
> a parameter like 'ora_charset' to the 'encoding type' for the html
> page, and whether some library like 'use utf-8' is available which
> will help solve the issue. If there is any CLPerlM forum FAQ which
> addresses the issue, please do point me to it, and I shall be
> thankful.
When generating the HTML page, myscript.cgi needs to print the correct
content-type header with charset=UTF-8.
--
Gunnar Hjalmarsson
Email: http://www.gunnar.cc/cgi-bin/contact.pl
------------------------------
Date: Tue, 17 Feb 2009 11:10:26 +0000
From: RedGrittyBrick <RedGrittyBrick@spamweary.invalid>
Subject: Re: how do I print the name and value of a scalar
Message-Id: <499a9b24$0$2521$da0feed9@news.zen.co.uk>
Frank Seitz wrote:
> Ben Morrow wrote:
>> Quoth Frank Seitz <devnull4711@web.de>:
>>> cartercc wrote:
>>>>
>>>> What I need is a way to get at the NAME of a variable as well as a
>>>> value.
>>>
>>> AFAIK it's not possible in Perl to get the name of a lexical (my)
>>> variable.
>>
>> It's possible with PadWalker. Whether it's a good
>> idea is of course another matter (nearly always it isn't).
>
> Why? Seems, that this is the thing the OP is looking for.
>
perldoc -q "variable name"
Others have already posted this, to this thread, but I think it bears
repeating.
--
RGB
------------------------------
Date: Tue, 17 Feb 2009 07:29:09 -0600
From: Chris Mattern <syscjm@sumire.gwu.edu>
Subject: Re: how do I print the name and value of a scalar
Message-Id: <slrngplet5.a75.syscjm@sumire.gwu.edu>
On 2009-02-17, cartercc <cartercc@gmail.com> wrote:
> On Feb 16, 10:48 pm, Charlton Wilbur <cwil...@chromatico.net> wrote:
>> The sooner you face this pain, the better off you will be. Your mess of
>> a "solution" is going to cause you more trouble overall than biting the
>> bullet and actually fixing the problem would have.
>
> This didn't start out like this. It started out as a quick and dirty
> little solution to a little problem. It was a database problem and the
It always does. It ALWAYS does. It doesn't change the basic nature of
the solution.
> purpose was to clean up some data, and it was MY automation. When some
> other people saw what a good thing it was, they went to my supervisor,
> and my supervisor came to me, and over a period of time it just grew,
> without any thought given to design and with no planning whatsoever.
And that's how you dug yourself into this hole. The question now is,
will you continue digging the hole deeper or are you going to climb out
of it?
--
Christopher Mattern
NOTICE
Thank you for noticing this new notice
Your noticing it has been noted
And will be reported to the authorities
------------------------------
Date: Tue, 17 Feb 2009 15:33:17 +0100
From: Frank Seitz <devnull4711@web.de>
Subject: Re: how do I print the name and value of a scalar
Message-Id: <700052Flhv82U1@mid.individual.net>
RedGrittyBrick wrote:
> Frank Seitz wrote:
>> Ben Morrow wrote:
>>>
>>> It's possible with PadWalker. Whether it's a good
>>> idea is of course another matter (nearly always it isn't).
>>
>> Why? Seems, that this is the thing the OP is looking for.
>
> perldoc -q "variable name"
>
> Others have already posted this, to this thread, but I think it bears
> repeating.
I want to know what is wrong with PadWalker as a debugging aid. I think
the OP wants to understand/debug his confusing code.
Frank
--
Dipl.-Inform. Frank Seitz; http://www.fseitz.de/
Anwendungen für Ihr Internet und Intranet
Tel: 04103/180301; Fax: -02; Industriestr. 31, 22880 Wedel
------------------------------
Date: Tue, 17 Feb 2009 15:20:24 +0000
From: RedGrittyBrick <RedGrittyBrick@spamweary.invalid>
Subject: Re: how do I print the name and value of a scalar
Message-Id: <499ad5bb$0$16163$db0fefd9@news.zen.co.uk>
Frank Seitz wrote:
> RedGrittyBrick wrote:
>> Frank Seitz wrote:
>>> Ben Morrow wrote:
>>>>
>>>> It's possible with PadWalker. Whether it's a good
>>>> idea is of course another matter (nearly always it isn't).
>>>
>>> Why? Seems, that this is the thing the OP is looking for.
>>
>> perldoc -q "variable name"
>>
>> Others have already posted this, to this thread, but I think it bears
>> repeating.
>
> I want to know what is wrong with PadWalker as a debugging aid. I think
> the OP wants to understand/debug his confusing code.
Ah, your "this" referred to the penultimate sentence you quoted and not
to the last sentence you quoted.
I think Frank was referring to the sentence you have now omitted, namely
"AFAIK it's not possible in Perl to get the name of a lexical (my)
variable."
It's the getting of the name of a lexical variable that nearly always
isn't a good idea.
I don't think Frank intended to suggest that there was anything wrong
with PadWalker as a debugging aid (though he didn't say the opposite
either.)
--
RGB
------------------------------
Date: Tue, 17 Feb 2009 07:43:17 -0800 (PST)
From: cartercc <cartercc@gmail.com>
Subject: Re: how do I print the name and value of a scalar
Message-Id: <a6e9d771-ebea-447f-b3a8-38bfa87a478f@m40g2000yqh.googlegroups.com>
On Feb 17, 4:49=A0am, bugbear <bugbear@trim_papermule.co.uk_trim> wrote:
> cartercc wrote:
> > I, too, am a slow learner. I'm a bright guy, but it takes a long time
> > before something sinks in.
>
> That's a new definition of "bright guy"
>
> =A0 =A0BugBear
Not really. My definition of 'bright guy' includes a lot of
imagination and creativity. You can always look stuff in a book if you
need to, like the parameters and return values of functions for
instance. It also includes a lot of patience and stick-to-it-ness.
Albert Einstein was 'slow.' I'm not in the same category, but I like
to think of thoroughness as the opposite of quick, and I'd rather be
thorough than quick.
Maybe I'm capitalizing on my deficiency! ;-)
CC
------------------------------
Date: Tue, 17 Feb 2009 16:47:03 +0100
From: Frank Seitz <devnull4711@web.de>
Subject: Re: how do I print the name and value of a scalar
Message-Id: <7004fbFlhv82U2@mid.individual.net>
RedGrittyBrick wrote:
> Frank Seitz wrote:
>> RedGrittyBrick wrote:
>>> Frank Seitz wrote:
>>>> Ben Morrow wrote:
>>>>>
>>>>> It's possible with PadWalker. Whether it's a good
>>>>> idea is of course another matter (nearly always it isn't).
>>>>
>>>> Why? Seems, that this is the thing the OP is looking for.
>>>
>>> perldoc -q "variable name"
>>>
>>> Others have already posted this, to this thread, but I think it bears
>>> repeating.
>>
>> I want to know what is wrong with PadWalker as a debugging aid. I think
>> the OP wants to understand/debug his confusing code.
>
> Ah, your "this" referred to the penultimate sentence you quoted and not
> to the last sentence you quoted.
Yes.
> I think Frank was referring to the sentence you have now omitted, namely
> "AFAIK it's not possible in Perl to get the name of a lexical (my)
> variable."
>
> It's the getting of the name of a lexical variable that nearly always
> isn't a good idea.
>
> I don't think Frank intended to suggest that there was anything wrong
> with PadWalker as a debugging aid (though he didn't say the opposite
> either.)
s/Frank/Ben Morrow/g;
Thank you for the clarification. Apparently I misunderstood him because
I am not a native speaker of English.
Frank
--
Dipl.-Inform. Frank Seitz; http://www.fseitz.de/
Anwendungen für Ihr Internet und Intranet
Tel: 04103/180301; Fax: -02; Industriestr. 31, 22880 Wedel
------------------------------
Date: Tue, 17 Feb 2009 04:21:03 -0800 (PST)
From: Krishna Chaitanya <schaitan@gmail.com>
Subject: Net::SSH2 scp_put not working!
Message-Id: <75c35a66-0c9f-4c43-bb4c-9fdc2611246e@u39g2000prn.googlegroups.com>
Hi,
Am trying to use scp_put on an Net::SSH2 object but it fails thus:
====================
Listing 1.pl
---------------
#!/usr/bin/perl
use warnings;
use strict;
use Net::SSH2;
my $ssh2 = Net::SSH2->new();
$ssh2->connect('10.0.1.174') or die;
if ($ssh2->auth_password('inmdev','inmdev')) {
print "Authorization successful\n";
my $chan2 = $ssh2->channel();
$chan2->shell();
$chan2->blocking(0);
print $chan2 "uname -a\n";
print "LINE : $_" while <$chan2>;
$chan2->close();
$ssh2->scp_put("/home/perl_progs/2.pl") or warn "Could not scp
the file 2.pl ";
} else {
print "Authorization failure\n";
}
====================
Output is :
Authorization successful
LINE : Linux IMITS174.localdomain 2.6.9-42.ELsmp #1 SMP Wed Jul 12
23:27:17 EDT 2006 i686 i686 i386 GNU/Linux
Could not scp the file 2.pl at 1.pl line 20.
I've seen source of Net/SSH2.pm on this Linux box and the sub scp_put
has these lines:
my $chan = $self->_scp_put($remote, $mode, @stat[7, 8, 9]);
return unless $chan;
$chan->blocking(1);
There is no such function as _scp_put in this module or elsewhere on
my Linux box (I found out by find with -exec grep). What do I do in
this case? I tried running this program through perl -d and it failed
at this line.
Pls. help. Many thanks in advance.
-Chaitanya
------------------------------
Date: Tue, 17 Feb 2009 13:50:17 +0100
From: Gunnar Hjalmarsson <noreply@gunnar.cc>
Subject: Re: Net::SSH2 scp_put not working!
Message-Id: <6vvq0oFm37ubU1@mid.individual.net>
Krishna Chaitanya wrote:
>
> $ssh2->scp_put("/home/perl_progs/2.pl") or warn "Could not scp
> the file 2.pl ";
Have you tried to make use of the error method?
$ssh2->scp_put("/home/perl_progs/2.pl") or
warn "Could not scp the file 2.pl", $ssh2->error;
--
Gunnar Hjalmarsson
Email: http://www.gunnar.cc/cgi-bin/contact.pl
------------------------------
Date: Tue, 17 Feb 2009 08:36:05 -0500
From: zentara <zentara@highstream.net>
Subject: Re: Net::SSH2 scp_put not working!
Message-Id: <rrelp4l9ptquaftg3ke3tto94hjksqn9in@4ax.com>
On Tue, 17 Feb 2009 04:21:03 -0800 (PST), Krishna Chaitanya
<schaitan@gmail.com> wrote:
>Hi,
>
>Am trying to use scp_put on an Net::SSH2 object but it fails thus:
>
>====================
>Listing 1.pl
>---------------
>
>#!/usr/bin/perl
>
>use warnings;
>use strict;
>
>use Net::SSH2;
>
>my $ssh2 = Net::SSH2->new();
>
>$ssh2->connect('10.0.1.174') or die;
>
>if ($ssh2->auth_password('inmdev','inmdev')) {
> print "Authorization successful\n";
> my $chan2 = $ssh2->channel();
> $chan2->shell();
> $chan2->blocking(0);
> print $chan2 "uname -a\n";
> print "LINE : $_" while <$chan2>;
> $chan2->close();
> $ssh2->scp_put("/home/perl_progs/2.pl") or warn "Could not scp
>the file 2.pl ";
>} else {
> print "Authorization failure\n";
>}
>
>
>====================
>
>Output is :
>
>Authorization successful
>LINE : Linux IMITS174.localdomain 2.6.9-42.ELsmp #1 SMP Wed Jul 12
>23:27:17 EDT 2006 i686 i686 i386 GNU/Linux
>Could not scp the file 2.pl at 1.pl line 20.
>
>I've seen source of Net/SSH2.pm on this Linux box and the sub scp_put
>has these lines:
>
> my $chan = $self->_scp_put($remote, $mode, @stat[7, 8, 9]);
> return unless $chan;
> $chan->blocking(1);
>
>There is no such function as _scp_put in this module or elsewhere on
>my Linux box (I found out by find with -exec grep). What do I do in
>this case? I tried running this program through perl -d and it failed
>at this line.
>
>Pls. help. Many thanks in advance.
>
>-Chaitanya
Sometimes the error messages only hint at the problem.
Your line:
> $ssh2->scp_put("/home/perl_progs/2.pl") or warn "Could not scp
> the file 2.pl ";
Error:
> my $chan = $self->_scp_put($remote, $mode, @stat[7, 8, 9]);
I believe you may not have a remote filename listed?
It should look like
$ssh->scp_put('local_filename', 'full_remote_filename');
# complete full paths from the root /
These ssh modules can be very demanding about full file paths,
both local and remote.
zentara
--
I'm not really a human, but I play one on earth.
http://www.zentara.net/~zentaran/My_Petition_to_the_Great_Cosmic_Conciousness.html
------------------------------
Date: Tue, 17 Feb 2009 06:17:40 -0800 (PST)
From: Krishna Chaitanya <schaitan@gmail.com>
Subject: Re: Net::SSH2 scp_put not working!
Message-Id: <ebaf3266-687f-463b-bfc3-44b06476e48f@a39g2000prl.googlegroups.com>
Hi,
This is from Net::SSH2 documentation of scp_put :
===============================
scp_put ( local [, remote ] )
Send a file with scp; remote path defaults to same as local. local may
be an IO object instead of a filename (but it must have a valid stat
method).
===============================
The code of this function in SSH2.pm is :
sub scp_put {
my ($self, $path, $remote) = @_;
$remote = basename $path if not defined $remote;
my $file = ref $path ? $path : IO::File->new($path, O_RDONLY);
$self->error($!, $!), return unless $file;
my @stat = $file->stat;
$self->error($!, $!), return unless @stat;
my $mode = $stat[2] & 0777; # mask off extras such as S_IFREG
my $chan = $self->_scp_put($remote, $mode, @stat[7, 8, 9]);
return unless $chan;
$chan->blocking(1);
# read and transmit blocks until we're finished
for (my ($size, $count) = ($stat[7]); $size > 0; $size -= $count)
{
my $buf;
my $block = ($size > 8192) ? 8192 : $size;
$count = $file->sysread($buf, $block);
$self->error($!, $!), return unless defined $count;
$self->error(0, "want $block, have $count"), return
unless $count == $block;
die 'sysread mismatch' unless length $buf == $count;
$self->error(0, "error writing $count bytes to channel"), return
unless $chan->write($buf) == $count;
}
# send/receive SCP acknowledgement
$chan->write("\0");
my $eof;
$chan->read($eof, 1);
return 1;
}
So I ran my program through perl -d and when it came to the line
having _scp_put, I printed out values of variables $path and $remote
and their values were "/home/perl_progs/2.pl" and "2.pl" ($remote is
filled up by basename as seen in code above). Now it's clear that both
the local and remote variables have values.....but shouldn't $remote
have some mention of the remote "DIRECTORY" too?
Also, where does _scp_put function exist? It looks from naming
convention like a method from a base class. I even tried doing an "nm"
on libssh2.* in /usr/lib (where I installed libssh2).
Thanks,
Chaitanya
------------------------------
Date: Tue, 17 Feb 2009 12:20:31 +0100
From: Gunnar Hjalmarsson <noreply@gunnar.cc>
Subject: Re: Perl script - Linux to Windows
Message-Id: <6vvkoeFm6q02U2@mid.individual.net>
guru wrote:
> HI
>
> I have written a script which runs successfully in Linux. But When I
> took same script and ran in Windows it is failing.
>
> I tried to figure out if there any problem with following,
>
> 1. Paths handling --> Wheter this should be handled.
> I came to know that perl will handle path structure depending
> on the OS.
> 2. Configuration setting.
>
> Any other parameters I need to look while porting to Windows.
There is a bug at line 126 of the script.
--
Gunnar Hjalmarsson
Email: http://www.gunnar.cc/cgi-bin/contact.pl
------------------------------
Date: Tue, 17 Feb 2009 12:17:37 +0100
From: Noway <name@champ.com>
Subject: Re: Perl script - Linux to Windows
Message-Id: <gne6cr$26u$1@ss408.t-com.hr>
guru wrote:
> HI
>
> I have written a script which runs successfully in Linux. But When I
> took same script and ran in Windows it is failing.
How do you know that it fails under win?
------------------------------
Date: Tue, 17 Feb 2009 03:33:19 -0800 (PST)
From: guru <guru.naveen@gmail.com>
Subject: Re: Perl script - Linux to Windows
Message-Id: <aada34ba-51bc-46e8-8646-e94a14761100@b40g2000pri.googlegroups.com>
On Feb 17, 4:20=A0pm, Gunnar Hjalmarsson <nore...@gunnar.cc> wrote:
> guru wrote:
> > HI
>
> > I have written a script which runs successfully in Linux. But When I
> > took same script and ran in Windows it is failing.
>
> > I tried to figure out if there any problem with following,
>
> > 1. Paths handling --> Wheter this should be handled.
> > =A0 =A0 =A0 =A0I came to know that perl will handle path structure depe=
nding
> > on the OS.
> > 2. Configuration setting.
>
> > Any other parameters I need to look while porting to Windows.
>
> There is a bug at line 126 of the script.
>
> --
> Gunnar Hjalmarsson
> Email:http://www.gunnar.cc/cgi-bin/contact.pl
Thanks Gunnar. I got the answer. This is a general question that I
asked. While porting I faced some problem with path and configuration.
So I asked any other I need to consider.
------------------------------
Date: Tue, 17 Feb 2009 03:35:49 -0800 (PST)
From: guru <guru.naveen@gmail.com>
Subject: Re: Perl script - Linux to Windows
Message-Id: <bd349bc3-23f8-4dc2-89ca-63a832b4f9af@r15g2000prh.googlegroups.com>
On Feb 17, 4:17=A0pm, Noway <n...@champ.com> wrote:
> guru wrote:
> > HI
>
> > I have written a script which runs successfully in Linux. But When I
> > took same script and ran in Windows it is failing.
>
> How do you know that it fails under win?
Scenario is fun1.pl is calling fun2.pl, while passing it is passing
list of files too.
In fun2.pl i am failing to read those file.
What I got is if file is passed like 'filename1' then fun2.pl will
fail to open it, so I passed without '' and it worked.
------------------------------
Date: Tue, 17 Feb 2009 11:43:26 +0000
From: RedGrittyBrick <RedGrittyBrick@spamweary.invalid>
Subject: Re: Perl script - Linux to Windows
Message-Id: <499aa2e0$0$2513$da0feed9@news.zen.co.uk>
guru wrote:
> On Feb 17, 4:17 pm, Noway <n...@champ.com> wrote:
>> guru wrote:
>>> HI
>>> I have written a script which runs successfully in Linux. But When I
>>> took same script and ran in Windows it is failing.
>> How do you know that it fails under win?
>
> Scenario is fun1.pl is calling fun2.pl,
Presumably using system() or backticks.
> while passing it is passing
> list of files too.
> In fun2.pl i am failing to read those file.
>
> What I got is if file is passed like 'filename1' then fun2.pl will
> fail to open it, so I passed without '' and it worked.
Sounds fragile, maybe you should convert fun2.pl to a module fun2.pm so
that you are not dependant on the quirks of shells in various operating
systems.
--
RGB
------------------------------
Date: Tue, 17 Feb 2009 12:46:18 +0100
From: Gunnar Hjalmarsson <noreply@gunnar.cc>
Subject: Re: Perl script - Linux to Windows
Message-Id: <6vvm8pFlm6qsU1@mid.individual.net>
guru wrote:
> On Feb 17, 4:20 pm, Gunnar Hjalmarsson <nore...@gunnar.cc> wrote:
>> guru wrote:
>>> HI
>>> I have written a script which runs successfully in Linux. But When I
>>> took same script and ran in Windows it is failing.
>>> I tried to figure out if there any problem with following,
>>> 1. Paths handling --> Wheter this should be handled.
>>> I came to know that perl will handle path structure depending
>>> on the OS.
>>> 2. Configuration setting.
>>> Any other parameters I need to look while porting to Windows.
>> There is a bug at line 126 of the script.
>
> Thanks Gunnar. I got the answer.
Good.
> This is a general question that I
> asked. While porting I faced some problem with path and configuration.
> So I asked any other I need to consider.
Your problem was not general at all. Next time you ask a question,
please make it easy to help by following the posting guidelines for this
group.
http://www.rehabitation.com/clpmisc/clpmisc_guidelines.html
--
Gunnar Hjalmarsson
Email: http://www.gunnar.cc/cgi-bin/contact.pl
------------------------------
Date: Tue, 17 Feb 2009 07:22:35 -0800
From: Jürgen Exner <jurgenex@hotmail.com>
Subject: Re: Perl script - Linux to Windows
Message-Id: <g00lp49cu2kisgtrkul9nb9h5opevm8p7a@4ax.com>
guru <guru.naveen@gmail.com> wrote:
>I have written a script which runs successfully in Linux. But When I
>took same script and ran in Windows it is failing.
>
>I tried to figure out if there any problem with following,
>
>1. Paths handling --> Wheter this should be handled.
> I came to know that perl will handle path structure depending
>on the OS.
Depends on what you mean. Obviously Windows doesn't have e.g. an
/etc/proc and neither named pipes or sockets as part of the file system
just as you need to consider the concept of drives.
>2. Configuration setting.
Again, depends on what you mean.
>Any other parameters I need to look while porting to Windows.
Did you read 'perldoc perlport'?
jue
------------------------------
Date: Tue, 17 Feb 2009 09:39:36 -0600
From: Ted Zlatanov <tzz@lifelogs.com>
Subject: Re: question on de-referencing expressions
Message-Id: <86r61x843r.fsf@lifelogs.com>
On Sat, 14 Feb 2009 07:00:24 -0800 Jürgen Exner <jurgenex@hotmail.com> wrote:
JE> Ted Zlatanov <tzz@lifelogs.com> wrote:
GH> my %hash = %{ functionReturningReference() };
>>
>> It's worth noting here that if the returned value is undef, the program
>> will die here. This is why I always use an intermediate variable and
>> test if for definedness, even if it takes a few more lines.
JE> If undef is a possible return value according to the function's
JE> specificiation, then that is certainly a very good idea.
JE> If not then something must have gone terribly wrong and die()ing in the
JE> face of an illegal return value is maybe not such a bad thing.
On Sat, 14 Feb 2009 05:57:33 +0100 Gunnar Hjalmarsson <noreply@gunnar.cc> wrote:
GH> If a function, that is supposed to return a hashref, returns undef, it
GH> indicates some sort of failure, so die()ing may be a good thing.
...
GH> That sounds wise if undef is a normal return value.
[note this is under `use strict', see below]
I always try to trap preventable fatal errors. It's almost always (with
very few exceptions) better for the users, no matter what the programmer
thinks. At least the error message should be better than the one Perl
produces in this case ("Can't use an undefined value as a HASH
reference").
On Fri, 13 Feb 2009 19:49:49 -0500 Uri Guttman <uri@stemsystems.com> wrote:
>>> perl -e '%h = %{$x}'
>>> perl -e '%h = %{undef}'
>>>
>>> neither caused a die.
Actually %{undef} looks for the hash named 'undef' so that's only
accidentally the right example (as `use strict' will tell you).
%{undef()} is it.
Sorry I forgot to mention `use strict'. I simply don't program without
it, and tend to forget many people do.
Ted
------------------------------
Date: Tue, 17 Feb 2009 13:17:25 GMT
From: Ilya Zakharevich <nospam-abuse@ilyaz.org>
Subject: Read/write with UCS-2* encodings - Possible???
Message-Id: <slrngple75.bec.nospam-abuse@chorin.math.berkeley.edu>
What should one fix to make UCS-2* encodings work on the file handles
in Perl? E.g., should not
perl -wlpe "BEGIN{binmode STDOUT, q(:encoding(UCS-2));}" < xyz > xyz1
just work? Currently, it requires additional `binmode STDOUT' in
advance, which changes the semantic. And doing
binmode STDOUT;
binmode STDOUT, q(:encoding(UCS-2));
binmode STDOUT, q(:crlf);
does not work, since :crlf layer is put AFTER :encoding, not before it
as expected...
Another indication is that
piconv -t UCS-2
gives wrong results on DOSISH platforms (which is not surprizing,
since the version I have uses q(:encoding(UCS-2))).
For best results, I would prefer a solution which allows doing
binmode STDOUT, q(:encoding(UCS-2));
and
binmode STDOUT, q(:crlf);
in arbitrary order so that the result does not depend on the order
(as now), but works ;-/.
Thanks,
Ilya
------------------------------
Date: Tue, 17 Feb 2009 15:16:51 +0100
From: Marc Lucksch <perl@marc-s.de>
Subject: Re: Read/write with UCS-2* encodings - Possible???
Message-Id: <gnegrp$vq$1@ariadne.rz.tu-clausthal.de>
Ilya Zakharevich schrieb:
> What should one fix to make UCS-2* encodings work on the file handles
> in Perl? E.g., should not
I have no idea about UCS-2, but I had the same problems in UTF16
> binmode STDOUT;
> binmode STDOUT, q(:encoding(UCS-2));
> binmode STDOUT, q(:crlf);
>
> does not work, since :crlf layer is put AFTER :encoding, not before it
> as expected...
>
> Another indication is that
>
> piconv -t UCS-2
>
> gives wrong results on DOSISH platforms (which is not surprizing,
> since the version I have uses q(:encoding(UCS-2))).
To make perl generate UTF-16, UTF-32 files that can be used by the
Windows Editor (CRLF), I used a small trick of which I also put in my
Sofu module:
http://search.cpan.org/~maluku/Sofu-0.3/lib/Data/Sofu.pm#NOTE_on_Unicode
#Write Windows CRLF UTF-16 Files
open my $fh,">:raw:encoding(UTF-16):crlf:utf8","out.sofu";
#Write Unix UTF-16 Files
open my $fh,">:raw:encoding(UTF-16)","out.sofu";
#Same goes for UTF-32
print $fh chr(65279); #Print UTF-8 Byte Order Mark (Some programs
want it, some programs die on it...)
When I tested it, it worked both on Windows and Linux.
Maybe this helps you
Marc "Maluku" Lucksch
------------------------------
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 2216
***************************************