[28055] in Perl-Users-Digest
Perl-Users Digest, Issue: 9419 Volume: 10
daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Mon Jul 3 06:05:58 2006
Date: Mon, 3 Jul 2006 03:05:05 -0700 (PDT)
From: Perl-Users Digest <Perl-Users-Request@ruby.OCE.ORST.EDU>
To: Perl-Users@ruby.OCE.ORST.EDU (Perl-Users Digest)
Perl-Users Digest Mon, 3 Jul 2006 Volume: 10 Number: 9419
Today's topics:
editing text file in perl <hara.acharya@gmail.com>
Re: editing text file in perl <noreply@gunnar.cc>
Re: editing text file in perl <bart@nijlen.com>
Re: editing text file in perl <scobloke2@infotop.co.uk>
How to eliminate the extra 0's in printing to html line cibalo@gmx.co.uk
Re: How to eliminate the extra 0's in printing to html <bart@nijlen.com>
Re: How to eliminate the extra 0's in printing to html <SteffenNetz@freenet.de>
Re: How to eliminate the extra 0's in printing to html anno4000@zrz.tu-berlin.de
Re: languages with full unicode support <find@my.address.elsewhere>
Re: need simple beep and taint mode anno4000@zrz.tu-berlin.de
Re: need simple beep and taint mode <bart@nijlen.com>
Re: need simple beep and taint mode <bart@nijlen.com>
Re: need simple beep and taint mode anno4000@zrz.tu-berlin.de
Re: need simple beep and taint mode <bart@nijlen.com>
new CPAN modules on Mon Jul 3 2006 (Randal Schwartz)
Perl variable scope <howachen@gmail.com>
Re: Perl variable scope anno4000@zrz.tu-berlin.de
Re: Perl variable scope <howachen@gmail.com>
Re: Perl variable scope <howachen@gmail.com>
Re: Problem with Multi- threaded Server <janicehwang1325@yahoo.com>
Re: Professional IDE for a cross-platform Perl applicat <David.Squire@no.spam.from.here.au>
Re: test value <josef.moellers@fujitsu-siemens.com>
Digest Administrivia (Last modified: 6 Apr 01) (Perl-Users-Digest Admin)
----------------------------------------------------------------------
Date: 3 Jul 2006 00:10:53 -0700
From: "king" <hara.acharya@gmail.com>
Subject: editing text file in perl
Message-Id: <1151910653.733620.36240@m73g2000cwd.googlegroups.com>
I want to edit a perticular line in a 50 lines text file using perl.
File handle can be used for this.
But how can i edit a string present in say 20th line using perl
script.
------------------------------
Date: Mon, 03 Jul 2006 09:26:16 +0200
From: Gunnar Hjalmarsson <noreply@gunnar.cc>
Subject: Re: editing text file in perl
Message-Id: <4grv0uF1oscbrU1@individual.net>
king wrote:
> I want to edit a perticular line in a 50 lines text file using perl.
That's a FAQ.
perldoc -q "change one line"
--
Gunnar Hjalmarsson
Email: http://www.gunnar.cc/cgi-bin/contact.pl
------------------------------
Date: 3 Jul 2006 00:27:07 -0700
From: "Bart Van der Donck" <bart@nijlen.com>
Subject: Re: editing text file in perl
Message-Id: <1151911627.346555.104440@p79g2000cwp.googlegroups.com>
king wrote:
> I want to edit a perticular line in a 50 lines text file using perl.
>
> File handle can be used for this.
> But how can i edit a string present in say 20th line using perl
> script.
#!perl
use strict;
use warnings;
my $file = 'file.dat';
my $line_counter = 0;
my $new_content;
open my $F, '<', $file || die "Cant open $file: $!";
flock($F, 1) || die "Cant get LOCK_SH on $file: $!";
while(<$F>) {
$line_counter ++;
if ($line_counter == 20) {
# do something on 20th line, eg. change it
$_ = "this is new content of line 20\n";
}
$new_content.= $_;
}
close $F || die "Cant close $file: $!";
# report
print $new_content;
Hope this helps,
--
Bart
------------------------------
Date: Mon, 03 Jul 2006 10:44:12 +0100
From: Ian Wilson <scobloke2@infotop.co.uk>
Subject: Re: editing text file in perl
Message-Id: <IuCdnXLa1OxtezXZRVnyug@bt.com>
Bart Van der Donck wrote:
> king wrote:
>
>
>>I want to edit a perticular line in a 50 lines text file using perl.
>>
>>File handle can be used for this.
>>But how can i edit a string present in say 20th line using perl
>>script.
>
>
> #!perl
> use strict;
> use warnings;
> my $file = 'file.dat';
> my $line_counter = 0;
> my $new_content;
>
> open my $F, '<', $file || die "Cant open $file: $!";
> flock($F, 1) || die "Cant get LOCK_SH on $file: $!";
> while(<$F>) {
> $line_counter ++;
> if ($line_counter == 20) {
> # do something on 20th line, eg. change it
> $_ = "this is new content of line 20\n";
> }
> $new_content.= $_;
> }
> close $F || die "Cant close $file: $!";
>
> # report
> print $new_content;
>
I prefer to keep simple jobs simple :-)
perl -pi -e 'if ($.==20) {s/^.*$/new content for line 20/;}' file.dat
or
perl -pi -e '($. == 20) && s/^.*$/new content for line 20/;' file.dat
------------------------------
Date: 3 Jul 2006 01:52:58 -0700
From: cibalo@gmx.co.uk
Subject: How to eliminate the extra 0's in printing to html lines?
Message-Id: <1151916778.880287.288550@h44g2000cwa.googlegroups.com>
Hello,
The following script produces two extra 0's at the end of the lines ---
see below.
#!/usr/bin/perl
print "Content-type: text/html\n\n";
print "# which sendmail<br>";
$out = system("which sendmail");
print "$out<br>\n";
print "<br>";
print "# which perl<br>";
$out = system("which perl");
print "$out<br>\n";
print "<br>";
And the browser displays as:
# which sendmail
/usr/sbin/sendmail 0
# which perl
/usr/bin/perl 0
Please help me to eliminate the two extra 0's at the end of the lines.
I have no idea where these 0's are coming from.
Thank you very much in advance!!!
------------------------------
Date: 3 Jul 2006 01:59:44 -0700
From: "Bart Van der Donck" <bart@nijlen.com>
Subject: Re: How to eliminate the extra 0's in printing to html lines?
Message-Id: <1151917184.279189.123110@75g2000cwc.googlegroups.com>
cib...@gmx.co.uk wrote:
> The following script produces two extra 0's at the end of the lines ---
> see below.
> #!/usr/bin/perl
> print "Content-type: text/html\n\n";
> print "# which sendmail<br>";
> $out = system("which sendmail");
> print "$out<br>\n";
> print "<br>";
> print "# which perl<br>";
> $out = system("which perl");
> print "$out<br>\n";
> print "<br>";
>
> And the browser displays as:
> # which sendmail
> /usr/sbin/sendmail 0
>
> # which perl
> /usr/bin/perl 0
>
> Please help me to eliminate the two extra 0's at the end of the lines.
> I have no idea where these 0's are coming from.
I see the same results here. The problem is that you can't trust the
return value of the 'system'-command. The following should work:
$out = `which perl`;
--
Bart
------------------------------
Date: Mon, 3 Jul 2006 11:15:26 +0200
From: Steffen Netz <SteffenNetz@freenet.de>
Subject: Re: How to eliminate the extra 0's in printing to html lines?
Message-Id: <20060703111526.00003d62@suna20>
Bart Van der Donck wrote:
> cib...@gmx.co.uk wrote:
>
> > The following script produces two extra 0's at the end of the lines ---
> > see below.
> > #!/usr/bin/perl
> > print "Content-type: text/html\n\n";
> > print "# which sendmail<br>";
> > $out = system("which sendmail");
> > print "$out<br>\n";
> > print "<br>";
> > print "# which perl<br>";
> > $out = system("which perl");
> > print "$out<br>\n";
> > print "<br>";
> >
> > And the browser displays as:
> > # which sendmail
> > /usr/sbin/sendmail 0
> >
> > # which perl
> > /usr/bin/perl 0
> >
> > Please help me to eliminate the two extra 0's at the end of the lines.
> > I have no idea where these 0's are coming from.
>
Hi,
perldoc system
gives as return of system:
The return value is the exit status of the program
as returned by the "wait" call.
Thus, you get the right value (0) in your $out-Variable.
try the `cmd` syntax and take care of the return values
everytime.
Steffen
------------------------------
Date: 3 Jul 2006 09:21:20 GMT
From: anno4000@zrz.tu-berlin.de
Subject: Re: How to eliminate the extra 0's in printing to html lines?
Message-Id: <4gs5sgF1nvg4gU2@news.dfncis.de>
Bart Van der Donck <bart@nijlen.com> wrote in comp.lang.perl.misc:
> cib...@gmx.co.uk wrote:
>
> > The following script produces two extra 0's at the end of the lines ---
> > see below.
> > #!/usr/bin/perl
> > print "Content-type: text/html\n\n";
> > print "# which sendmail<br>";
> > $out = system("which sendmail");
> > print "$out<br>\n";
> > print "<br>";
> > print "# which perl<br>";
> > $out = system("which perl");
> > print "$out<br>\n";
> > print "<br>";
> >
> > And the browser displays as:
> > # which sendmail
> > /usr/sbin/sendmail 0
> >
> > # which perl
> > /usr/bin/perl 0
> >
> > Please help me to eliminate the two extra 0's at the end of the lines.
> > I have no idea where these 0's are coming from.
>
> I see the same results here. The problem is that you can't trust the
> return value of the 'system'-command.
You can trust it to be what it it supposed to be, but that is not the
output of the invoked command.
> The following should work:
>
> $out = `which perl`;
Read "perldoc -f system" with attention to the third paragraph to see
*why* this works.
Anno
------------------------------
Date: Sun, 02 Jul 2006 17:28:50 -0500
From: Matthias Blume <find@my.address.elsewhere>
Subject: Re: languages with full unicode support
Message-Id: <m2hd1zzlnh.fsf@hanabi.local>
Oliver Bandel <oliver@first.in-berlin.de> writes:
>>>Oliver Bandel wrote:
>>>
>>>>こんいちわ Xah-Lee san ;-)
>>>
>>>Uhm, I'd guess that Xah is Chinese. Be careful
>>>with such things in real life; Koreans might
>>>beat you up for this. Stay alive!
>> And the Japanese might beat him up, too. For butchering their
>> language. :-)
>
> OK, back to ISO-8859-1 :) no one needs so much symbols,
> this is enough: äöüÄÖÜß :)
There are plenty of people who need such symbols (more people than
those who need ß, btw).
Matthias
PS: It should have been こんにちは.
------------------------------
Date: 3 Jul 2006 08:36:34 GMT
From: anno4000@zrz.tu-berlin.de
Subject: Re: need simple beep and taint mode
Message-Id: <4gs38iF1nvg4gU1@news.dfncis.de>
Yohan N. Leder <ynleder@nspark.org> wrote in comp.lang.perl.misc:
> Very quick question this time.
If you don't know the answer, how do you know it's a "quick question"?
> How to do a 'print "\a";' still produces
> a beep when script is in taint mode. It works fine without -T, but
> nothing in speaker when I'm back to taint mode. If it has some
> importance, this test has been done using ActivePerl 5.8.8.817 under Win
> 2K. What's the trick ?
I can't reproduce your findings. If your diagnosis is indeed correct,
this looks like a rather messy problem.
Anno
------------------------------
Date: 3 Jul 2006 01:47:59 -0700
From: "Bart Van der Donck" <bart@nijlen.com>
Subject: Re: need simple beep and taint mode
Message-Id: <1151916479.250856.169390@m73g2000cwd.googlegroups.com>
Yohan N. Leder wrote:
> Very quick question this time. How to do a 'print "\a";' still produces
> a beep when script is in taint mode. It works fine without -T, but
> nothing in speaker when I'm back to taint mode. If it has some
> importance, this test has been done using ActivePerl 5.8.8.817 under Win
> 2K.
Yes - I get a beep too under WinXP ActivePerl 5.8.4. This same beep can
be achieved by e.g. typing "echo", space, control-G and then Enter.
This should work in most/all terminals, as CTRL-G corresponds to
dec/hex 07 (BEL, bell, 0000111 in 7-bit ASCII) as the de-facto bell
signal.
The same would probably happen when displaying binaries in your
terminal, something like:
open my $F, '<', 'image.gif' || die "Cant open: $!";
print while(<$F>);
close $F || die "Cant close: $!";
My conclusion:
You can't know at Perl level whether or not the terminal will beep at
any character. It's just up to the shell. I would say this hasn't any
real importance too. Unless you want to program a singing shell or so
:-)
Hope this helps,
--
Bart
------------------------------
Date: 3 Jul 2006 02:29:13 -0700
From: "Bart Van der Donck" <bart@nijlen.com>
Subject: Re: need simple beep and taint mode
Message-Id: <1151918953.610951.295490@b68g2000cwa.googlegroups.com>
Sherm Pendley wrote:
> [...]
> Perl doesn't actually beep; 'print "\a";' simply sends an ASCII control
> character to stdout. It's up to whatever's collecting your script's output
> to decide how to respond to that character.
> [...]
Then you're actually saying that \a would be an alias to hex/dec 7 on
Yohan's terminal, because no other ASCII control character seems to
produce a beep on DOS-ish terminals:
#!perl
print "char $_ is ",chr($_),"\n" for (0..31);
=for nobody
ASCII CONTROL CHARACTERS
Dec Hex ASCII KEY
0 00 NUL (null) Ctrl-@
1 01 SOH (start of heading) Ctrl-A
2 02 STX (start of text) Ctrl-B
3 03 ETX (end of text) Ctrl-C
4 04 EOT (end of transmission) Ctrl-D
5 05 ENQ (enquiry) Ctrl-E
6 06 ACK (acknowledge) Ctrl-F
7 07 BEL (bell) Ctrl-G
8 08 BS (backspace) Ctrl-H
9 09 HT (horizontal tab) Ctrl-I
10 0A LF (line feed) Ctrl-J
11 0B VT (vertical tab) Ctrl-K
12 0C FF (form feed) Ctrl-L
13 0D CR (carriage return) Ctrl-M
14 0E SO (shift out) Ctrl-N
15 0F SI (shift in) Ctrl-O
16 10 DLE (data link escape) Ctrl-P
17 11 DC1 (device control 1) Ctrl-Q
18 12 DC2 (device control 2) Ctrl-R
19 13 DC3 (device control 3) Ctrl-S
20 14 DC4 (device control 4) Ctrl-T
21 15 NAK (negative acknowledge) Ctrl-U
22 16 SYN (synchronous idle) Ctrl-V
23 17 ETB (end of trans. block) Ctrl-W
24 18 CAN (cancel) Ctrl-X
25 19 EM (end of medium) Ctrl-Y
26 1A SUB (substitute) Ctrl-Z
27 1B ESC (escape) Ctrl-[
28 1C FS (file separator) Ctrl-\
29 1D GS (group separator) Ctrl-]
30 1E RS (record separator) Ctrl-^
31 1F US (unit separator) Ctrl-_
=cut
__END__
Maybe \a might be considered short for 'alarm' or 'alert'...
I might be wrong about this, but I rather think that \a doesn't refer
to an ASCII control character, but to a "somewhere far higher"
character. The fact that \a corresponds to a beep on some shells,
doesn't necessarily imply a relation to Hex 07.
--
Bart
------------------------------
Date: 3 Jul 2006 09:54:59 GMT
From: anno4000@zrz.tu-berlin.de
Subject: Re: need simple beep and taint mode
Message-Id: <4gs7rjF1of474U1@news.dfncis.de>
Bart Van der Donck <bart@nijlen.com> wrote in comp.lang.perl.misc:
> Sherm Pendley wrote:
>
> > [...]
> > Perl doesn't actually beep; 'print "\a";' simply sends an ASCII control
> > character to stdout. It's up to whatever's collecting your script's output
> > to decide how to respond to that character.
> > [...]
>
> Then you're actually saying that \a would be an alias to hex/dec 7 on
> Yohan's terminal, because no other ASCII control character seems to
> produce a beep on DOS-ish terminals:
That is exactly what he's saying, and it's true too.
[snip]
> Maybe \a might be considered short for 'alarm' or 'alert'...
Perl calls it "alarm (bell)" (see perlop). It's a backslash escape
like "\n" and many more.
> I might be wrong about this,
You are, unnecessarily.
> but I rather think that \a doesn't refer
> to an ASCII control character, but to a "somewhere far higher"
> character. The fact that \a corresponds to a beep on some shells,
> doesn't necessarily imply a relation to Hex 07.
No seed to guess:
print "okay\n" if "\a" eq "\cG" and "\a" eq chr 7;
prints okay and removes all doubt.
Anno
------------------------------
Date: 3 Jul 2006 03:03:02 -0700
From: "Bart Van der Donck" <bart@nijlen.com>
Subject: Re: need simple beep and taint mode
Message-Id: <1151920976.697368.206120@m73g2000cwd.googlegroups.com>
anno4000@zrz.tu-berlin.de wrote:
> Bart Van der Donck <bart@nijlen.com> wrote in comp.lang.perl.misc:
> > [...]
> > but I rather think that \a doesn't refer
> > to an ASCII control character, but to a "somewhere far higher"
> > character. The fact that \a corresponds to a beep on some shells,
> > doesn't necessarily imply a relation to Hex 07.
>
> No seed to guess:
>
> print "okay\n" if "\a" eq "\cG" and "\a" eq chr 7;
>
> prints okay and removes all doubt.
It does. I see.
--
Bart
------------------------------
Date: Mon, 3 Jul 2006 04:42:07 GMT
From: merlyn@stonehenge.com (Randal Schwartz)
Subject: new CPAN modules on Mon Jul 3 2006
Message-Id: <J1t927.1s6z@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.
Acme-Tests-0.03
http://search.cpan.org/~gugod/Acme-Tests-0.03/
How much do you know ?
----
BerkeleyDB-0.29
http://search.cpan.org/~pmqs/BerkeleyDB-0.29/
Perl extension for Berkeley DB version 2, 3 or 4
----
CGI-Application-4.07_01
http://search.cpan.org/~markstos/CGI-Application-4.07_01/
Framework for building reusable web-applications
----
CGI-FileManager-0.04
http://search.cpan.org/~szabgab/CGI-FileManager-0.04/
Managing a directory structure on an HTTP server
----
Cache-Memcached-XS-0.01
http://search.cpan.org/~jcaron/Cache-Memcached-XS-0.01/
client library for memcached (memory cache daemon) using libmemcache
----
Catalyst-Action-RenderView-0.03
http://search.cpan.org/~mramberg/Catalyst-Action-RenderView-0.03/
Sensible default end action.
----
Catalyst-Plugin-C3-0.01000_04
http://search.cpan.org/~blblack/Catalyst-Plugin-C3-0.01000_04/
Catalyst Plugin to subvert NEXT to use Class::C3
----
DBIx-ORM-Declarative-0.09
http://search.cpan.org/~jschneid/DBIx-ORM-Declarative-0.09/
Perl extension for object-oriented database access
----
Directory-Scratch-0.01
http://search.cpan.org/~jrockway/Directory-Scratch-0.01/
Easy-to-use self-cleaning scratch space.
----
ExtUtils-Install-1.41
http://search.cpan.org/~yves/ExtUtils-Install-1.41/
install files from here to there
----
Gearman-1.00
http://search.cpan.org/~bradfitz/Gearman-1.00/
----
Gtk2-Ex-FormFactory-0.65
http://search.cpan.org/~jred/Gtk2-Ex-FormFactory-0.65/
Makes building complex GUI's easy
----
HTML-Prototype-Useful-0.05
http://search.cpan.org/~mramberg/HTML-Prototype-Useful-0.05/
Some useful additions for the Prototype library.
----
HTML-Template-Compiled-0.69
http://search.cpan.org/~tinita/HTML-Template-Compiled-0.69/
Template System Compiles HTML::Template files to Perl code
----
Jcode-2.06
http://search.cpan.org/~dankogai/Jcode-2.06/
Japanese Charset Handler
----
Language-l33t-0.02
http://search.cpan.org/~yanick/Language-l33t-0.02/
a l33t interpreter
----
List-MoreUtils-0.22
http://search.cpan.org/~vparseval/List-MoreUtils-0.22/
Provide the stuff missing in List::Util
----
MasonX-Request-HTMLTemplate-0.06
http://search.cpan.org/~ebruni/MasonX-Request-HTMLTemplate-0.06/
Add templates to the Mason Request object
----
Module-Pluggable-Ordered-1.5
http://search.cpan.org/~apeiron/Module-Pluggable-Ordered-1.5/
Call module plugins in a specified order
----
Net-Akismet-0.02
http://search.cpan.org/~nikolay/Net-Akismet-0.02/
Perl interface to Akismet - comment and trackback spam fighter
----
POE-Component-Client-HTTP-0.76
http://search.cpan.org/~rcaputo/POE-Component-Client-HTTP-0.76/
a HTTP user-agent component
----
POE-Component-IRC-4.94
http://search.cpan.org/~bingos/POE-Component-IRC-4.94/
a fully event-driven IRC client module.
----
Params-Util-0.15
http://search.cpan.org/~adamk/Params-Util-0.15/
Simple, compact and correct param-checking functions
----
Text-vCard-1.97
http://search.cpan.org/~llap/Text-vCard-1.97/
a package to edit and create a single vCard (RFC 2426)
----
Time-Simple-0.05
http://search.cpan.org/~lgoddard/Time-Simple-0.05/
A simple, light-weight ISO 8601 time object.
----
Time-Simple-0.051
http://search.cpan.org/~lgoddard/Time-Simple-0.051/
A simple, light-weight ISO 8601 time object.
----
Unicode-Japanese-0.37
http://search.cpan.org/~hio/Unicode-Japanese-0.37/
Japanese Character Encoding Handler
----
Video-DVDRip-0.97.12
http://search.cpan.org/~jred/Video-DVDRip-0.97.12/
GUI for copying DVDs, based on an open Low Level API
----
WWW-Search-DrugBank-0.02
http://search.cpan.org/~diberri/WWW-Search-DrugBank-0.02/
Access DrugBank's database of pharmaceuticals
----
Win32API-File-0.1001
http://search.cpan.org/~yves/Win32API-File-0.1001/
Low-level access to Win32 system API calls for files/dirs.
----
Wx-Package-Win32-0.08
http://search.cpan.org/~mdootson/Wx-Package-Win32-0.08/
----
XML-Quick-0.02
http://search.cpan.org/~robn/XML-Quick-0.02/
Generate XML from hashes (and other data)
----
YAML-0.61
http://search.cpan.org/~ingy/YAML-0.61/
YAML Ain't Markup Language (tm)
----
gearmand-1.00
http://search.cpan.org/~bradfitz/gearmand-1.00/
Gearman client/worker connector.
----
gearmand-1.01
http://search.cpan.org/~bradfitz/gearmand-1.01/
Gearman client/worker connector.
----
perlindex-1.502
http://search.cpan.org/~ulpfr/perlindex-1.502/
index and query perl manual pages
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: 3 Jul 2006 02:19:56 -0700
From: "howa" <howachen@gmail.com>
Subject: Perl variable scope
Message-Id: <1151918396.654048.4540@m73g2000cwd.googlegroups.com>
Hi,
Conside the following simple program:
#-----------------------------------------------------
sub test {
my $i = "999";
return \$i;
}
print ${test()};
#-----------------------------------------------------
i can still get "999", althought $i is a local variable in a procedure.
i want to ask : is it safe to use reference in the way?
or when the garbage collection will clear the reference?
thanks...
------------------------------
Date: 3 Jul 2006 09:24:17 GMT
From: anno4000@zrz.tu-berlin.de
Subject: Re: Perl variable scope
Message-Id: <4gs621F1nvg4gU3@news.dfncis.de>
howa <howachen@gmail.com> wrote in comp.lang.perl.misc:
> Hi,
>
> Conside the following simple program:
>
> #-----------------------------------------------------
> sub test {
> my $i = "999";
> return \$i;
> }
>
> print ${test()};
> #-----------------------------------------------------
>
> i can still get "999", althought $i is a local variable in a procedure.
>
> i want to ask : is it safe to use reference in the way?
>
> or when the garbage collection will clear the reference?
This is a FAQ. See "perldoc -q safe".
Anno
------------------------------
Date: 3 Jul 2006 02:41:48 -0700
From: "howa" <howachen@gmail.com>
Subject: Re: Perl variable scope
Message-Id: <1151919708.564126.106740@m73g2000cwd.googlegroups.com>
anno4000@zrz.tu-berlin.de =E5=AF=AB=E9=81=93=EF=BC=9A
> howa <howachen@gmail.com> wrote in comp.lang.perl.misc:
> > Hi,
> >
> > Conside the following simple program:
> >
> > #-----------------------------------------------------
> > sub test {
> > my $i =3D "999";
> > return \$i;
> > }
> >
> > print ${test()};
> > #-----------------------------------------------------
> >
> > i can still get "999", althought $i is a local variable in a procedure.
> >
> > i want to ask : is it safe to use reference in the way?
> >
> > or when the garbage collection will clear the reference?
>=20
> This is a FAQ. See "perldoc -q safe".
>=20
> Anno
great thanks...
------------------------------
Date: 3 Jul 2006 02:45:34 -0700
From: "howa" <howachen@gmail.com>
Subject: Re: Perl variable scope
Message-Id: <1151919934.825472.227270@v61g2000cwv.googlegroups.com>
howa =E5=AF=AB=E9=81=93=EF=BC=9A
> anno4000@zrz.tu-berlin.de =E5=AF=AB=E9=81=93=EF=BC=9A
>
> > howa <howachen@gmail.com> wrote in comp.lang.perl.misc:
> > > Hi,
> > >
> > > Conside the following simple program:
> > >
> > > #-----------------------------------------------------
> > > sub test {
> > > my $i =3D "999";
> > > return \$i;
> > > }
> > >
> > > print ${test()};
> > > #-----------------------------------------------------
> > >
> > > i can still get "999", althought $i is a local variable in a procedur=
e=2E
> > >
> > > i want to ask : is it safe to use reference in the way?
> > >
> > > or when the garbage collection will clear the reference?
> >
> > This is a FAQ. See "perldoc -q safe".
> >
> > Anno
>
> great thanks...
one more thing...
if a variable type is an object, will be pass by reference by default?
e=2Eg.
return $a; # where $a is an object, will this pass by ref by default?
(php and java will do this automatically)
thx..
------------------------------
Date: 2 Jul 2006 18:04:26 -0700
From: "janicehwang1325@yahoo.com" <janicehwang1325@yahoo.com>
Subject: Re: Problem with Multi- threaded Server
Message-Id: <1151888666.587257.39580@p79g2000cwp.googlegroups.com>
Thanks for the information. This is very useful to me. However, I
couldn't change my boss's requirement as I had inform him of the
problems I am facing. Therefore, I still need to do a lot of research
regarding this. Sigh.
xhoster@gmail.com wrote:
> xhoster@gmail.com wrote:
> > "janicehwang1325@yahoo.com" <janicehwang1325@yahoo.com> wrote:
> > > Ya, I miss that part and I amend my program by putting the close with
> > > SSL_no_shutdown. However, this only help when the client program ends
> > > the connection and the server program would not hang. It does not
> > > actually solve the segmentation fault problem.
> >
> > The SSLeay module seems to be fundamentally unsafe for threads. I tried
> > a few things to hack it with CLONED, etc. but haven't been able to. The
> > mere existence of a thread is enough to trigger the problem, the thread
> > doesn't need to do anything with the socket at all. By changing the
> > "close" parameters, I could make it segfault either ealier (upon the
> > initial close) or later (half way through the 2nd accept) but couldn't
> > get rid of it altogether.
>
> Just an addition, the SSLeay module is not fundamentally unsafe for
> threads, it is just the way that IO::Socket::SSL interacts with it that is
> unsafe.
>
> If I disable IO::Socket::SSL::DESTROY, the seg faults stop but it leaks
> like a sieve. If I re-enable that but disable
> IO::Socket::SSL::SSL_Context::DESTROY, then it still solves the seg-fault
> and still leaks, but a lot less. So you would need to find a way to make
> sure that that DESTROY only happens in one of the threads, either the
> parent or the child, and not in both. Something like DBI's
> InactiveDestroy.
>
> Or just fork instead of threads. Ask your boss "How much are you willing
> to spend to accomplish your stupid and arbitrary requirements?"
>
>
> Xho
>
> --
> -------------------- http://NewsReader.Com/ --------------------
> Usenet Newsgroup Service $9.95/Month 30GB
------------------------------
Date: Mon, 03 Jul 2006 07:56:50 +0100
From: David Squire <David.Squire@no.spam.from.here.au>
Subject: Re: Professional IDE for a cross-platform Perl application
Message-Id: <e8af3i$301$1@news.ox.ac.uk>
Bob wrote:
> David, the Wikipedia reads correctly. There is no further ground for
> misunderstandings. Also, the word "Integrated" in "Integrated
> Development Environment" should (must) ring you a bell. Your
> disagreement on "A is part of B" vs "B can be a part of A" is just
> playing with words.
Fine Bob, you can be right, and the rest of the world can be wrong.
We'll get along just fine.
Bye.
------------------------------
Date: Mon, 03 Jul 2006 08:39:43 +0200
From: Josef Moellers <josef.moellers@fujitsu-siemens.com>
Subject: Re: test value
Message-Id: <e8ae71$57m$1@nntp.fujitsu-siemens.com>
Shane wrote:
> John Bokma wrote:
>=20
>=20
>>Josef Moellers <josef.moellers@fujitsu-siemens.com> wrote:
>>
>>
>>>John Bokma wrote:
>>>
>>>>Shane <shane@weasel.is-a-geek.net> wrote:
>>>>
>>>>
>>>>
>>>>>I have some nasty code, that I want to check the value of something
>>>>>held in a scalar, but there is 'no' value held in there
>>>>>
>>>>>Data::Dumper tells me the $val =3D []
>>>>
>>>>
>>>>$val contains a reference to an empty array, like:
>>>>
>>>>my @array =3D ();
>>>>my $val =3D \@array;
>>>
>>>if (@$val =3D=3D 0) {
>>> print "Empty\n";
>>>}
>>
>>@$val or print "Empty\n";
>>
>=20
>=20
>=20
> Apologies for the delay between your answer and my reading the post
>=20
> To make matters slightly more complicated $val is an arrayref, in a has=
h
> If I use the following if @($hash->{$val}) I get=20
Shouldn't that be @{$hash->{$val}}
(curlies iso parentheses)?
Josef
--=20
Josef M=F6llers (Pinguinpfleger bei FSC)
If failure had no penalty success would not be a prize
-- T. Pratchett
------------------------------
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 V10 Issue 9419
***************************************