[26970] in Perl-Users-Digest
Perl-Users Digest, Issue: 8921 Volume: 10
daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Sun Feb 5 06:06:00 2006
Date: Sun, 5 Feb 2006 03:05:05 -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 Sun, 5 Feb 2006 Volume: 10 Number: 8921
Today's topics:
I just can't get this global/local/my stuff <groleau+news@freeshell.org>
Re: I just can't get this global/local/my stuff <noreply@gunnar.cc>
Re: I just can't get this global/local/my stuff <abigail@abigail.nl>
Re: Morse code audio playout? <zentara@highstream.net>
Re: Obscure utf8/"panic: malloc" bug <nospam-abuse@ilyaz.org>
Re: Perl device IO on Win <tun@invalid.com>
Signal handlers, objects and reference counting. (Jamie)
Re: Signal handlers, objects and reference counting. (Anno Siegel)
Re: using a package (Anno Siegel)
Digest Administrivia (Last modified: 6 Apr 01) (Perl-Users-Digest Admin)
----------------------------------------------------------------------
Date: Sun, 05 Feb 2006 05:10:40 GMT
From: Wes Groleau <groleau+news@freeshell.org>
Subject: I just can't get this global/local/my stuff
Message-Id: <kNfFf.70885$7l4.44588@trnddc05>
my (%DataBase, $The_Key);
dbmopen (%DataBase, $GEDCOM . ".DB", 0644)
or die "dbmopen failed ($!) on $GEDCOM.DB\n";
my %Params = &read_params;
# read_params is reinvented CGI QUERY_STRING parser
my @Keys = split (/,/, $Params{"ID"});
foreach $The_Key ( @Keys )
{
print $Database{$The_Key};
}
-----
The print line gets:
Global symbol "%Database" requires explicit package name at ...
I have compared this version to the earlier version that was working
and can't see the difference (except for adding subs that have not yet
been called).
--
Wes Groleau
"A man with an experience is never
at the mercy of a man with an argument."
-- Ron Allen
------------------------------
Date: Sun, 05 Feb 2006 07:53:55 +0100
From: Gunnar Hjalmarsson <noreply@gunnar.cc>
Subject: Re: I just can't get this global/local/my stuff
Message-Id: <44llo6F2oj2tU1@individual.net>
Wes Groleau wrote:
> my (%DataBase, $The_Key);
>
> dbmopen (%DataBase, $GEDCOM . ".DB", 0644)
> or die "dbmopen failed ($!) on $GEDCOM.DB\n";
>
> my %Params = &read_params;
> # read_params is reinvented CGI QUERY_STRING parser
>
> my @Keys = split (/,/, $Params{"ID"});
>
> foreach $The_Key ( @Keys )
> {
> print $Database{$The_Key};
> }
> -----
>
> The print line gets:
> Global symbol "%Database" requires explicit package name at ...
>
> I have compared this version to the earlier version that was working
> and can't see the difference (except for adding subs that have not yet
> been called).
Perl is case sensitive.
--
Gunnar Hjalmarsson
Email: http://www.gunnar.cc/cgi-bin/contact.pl
------------------------------
Date: 05 Feb 2006 08:28:03 GMT
From: Abigail <abigail@abigail.nl>
Subject: Re: I just can't get this global/local/my stuff
Message-Id: <slrndubdoj.3si.abigail@alexandra.abigail.nl>
Wes Groleau (groleau+news@freeshell.org) wrote on MMMMDXLI September
MCMXCIII in <URL:news:kNfFf.70885$7l4.44588@trnddc05>:
~~ my (%DataBase, $The_Key);
^ Uppercase B
~~
~~ dbmopen (%DataBase, $GEDCOM . ".DB", 0644)
~~ or die "dbmopen failed ($!) on $GEDCOM.DB\n";
~~
~~ my %Params = &read_params;
~~ # read_params is reinvented CGI QUERY_STRING parser
~~
~~ my @Keys = split (/,/, $Params{"ID"});
~~
~~ foreach $The_Key ( @Keys )
~~ {
~~ print $Database{$The_Key};
^ Lowercase b
~~ }
Abigail
--
sub _ {$_ = shift and y/b-yB-Y/a-yB-Y/ xor !@ _?
exit print :
print and push @_ => shift and goto &{(caller (0)) [3]}}
split // => "KsvQtbuf fbsodpmu\ni flsI " xor & _
------------------------------
Date: Sun, 05 Feb 2006 10:40:44 GMT
From: zentara <zentara@highstream.net>
Subject: Re: Morse code audio playout?
Message-Id: <g6lbu19bpg0n2fheh0jiuou6u3k44kll2f@4ax.com>
On Sat, 04 Feb 2006 13:45:03 -0600, "Gan Uesli Starling"
<gan@starling.us> wrote:
>I want to write an open source script which does similar to
>the CGI here...
>
>http://morsecode.scphillips.com/translator.html
>
>He only shares the Java version and not the CGI. So I am
>thinking to trump him by writing my own, as best I can, and
>giving my own away for free.
>
>Some time back I heard of a morse-to-audio playout script
>in Perl which was open source. That would be a good short
>cut to start from...or at least to study first.
>
>Anybody know where I can find it?
Check out
Audio::Data
Audio::Play
Midi::Simple
These can output wav or midi files.
#!/usr/bin/perl
use strict;
use MIDI::Simple;
new_score;
patch_change 1, 41; # Patch 41 = organ of some sort
noop 'c1', 'f', 'o2'; # setup
my $normal = 'en';
my $fast = 'sn';
foreach my $c (split '', '. - .. - ..- ... - .') {
if($c eq ' ') { # interword pause
r $normal;
} elsif($c eq '.') { # dit
n $fast;
r $fast;
} elsif($c eq '-') { # daah
n $normal;
r $fast;
} else {
print "What's \"$c\"? Skipping\n";
}
}
write_score("morse1.midi");
exit;
__END__
You might be able to use MIDI::Realtime for realtime output
from the keyboard.... a simple demo.(You will have to setup
a key-release scheme, to stop the tones.)
#!/usr/bin/perl
use warnings;
use strict;
use MIDI::Realtime;
use Term::ReadKey;
ReadMode('cbreak');
#this works on linux with an SBlive, Alsa 1.0.4, kernel 2.4.22
# on my system, it has a bug when usb-hotplug and usb-midi are used
# and the hotplug-blacklist is not setup properly
my $midi = MIDI::Realtime->new(dev=>'/dev/sequencer',
midi_device=> 1); #1,2,3,4
#5 for external
keyboard
while(1){ #thru USB UM-1
connector
my $char;
if (defined ($char = ReadKey(0)) ) {
print ord($char),"\n"; # input was waiting and it was $char
$midi->patch(ord($char)); #change instrument, 127 gives
"exploding keyboard" :-)
$midi->note(50,1,127); #play note
} else {
# no input was waiting
}
}
ReadMode('normal'); # restore normal tty settings
__END__
--
I'm not really a human, but I play one on earth.
http://zentara.net/japh.html
------------------------------
Date: Sun, 5 Feb 2006 00:01:00 +0000 (UTC)
From: Ilya Zakharevich <nospam-abuse@ilyaz.org>
Subject: Re: Obscure utf8/"panic: malloc" bug
Message-Id: <ds3f7s$1ivv$1@agate.berkeley.edu>
[A complimentary Cc of this posting was sent to
kj
<socyl@987jk.com.invalid>], who wrote in article <ds2prf$le5$1@reader2.panix.com>:
> >With the current state of Perl internals (non-reenterable REx engine),
> >debugging into SWASH* functions can only lead to a disaster
>
> Thanks for this insight. As it turns out, this bug surfaces *only*
> when I run the code in the debugger which means that I cannot debug
> this code using the Perl debugger; this I consider a significant
> hindrance. If I understand what you say correctly, this situation
> means that any Perl code that (directly or indirectly) invokes
> SWASHNEW cannot be debugged using the Perl debugger.
>
> Honestly, I can't understand why utf8 and utf8_heavy are being
> loaded at all.
A (silly, IMO) architecture to support RExen on UTF8 strings.
> Is there a way to "go up the call stack" in the debugger (to examine
> lexical values in the calling environment)?
Do not think so. Likewise for local()ized stuff.
> Also, is there a way to generate a call tree for a Perl program?
dprof?
> >I wrote about this here about a year ago.
> I didn't have much luck when I searched clpm with Google Groups
> for your earlier posts on this, but maybe I didn't use the right
> search keywords. Can you help me narrow down the search?
REx engine debug OR debugger utf8 OR unicode author:Zakharevich group:*perl*
Hope this helps,
Ilya
------------------------------
Date: Sun, 05 Feb 2006 06:58:45 GMT
From: The Unnamed Netizen <tun@invalid.com>
Subject: Re: Perl device IO on Win
Message-Id: <FmhFf.30026$H71.21355@newssvr13.news.prodigy.com>
Todd W wrote:
> "Jack Schmidt" <unnamed.netizen@invalid.com> wrote in message
> news:1139019708.755409@hp-sdd.sdd.hp.com...
>
>>I want to talk to a device through an RS232 port on a
>>PC running WinXP. Looks like I can use the POSIX::Termios
>>class, but I don't know what the file descriptors are for
>>the serial ports. Anybody?
>>
>>Also, what about device IO via USB on the same PC?
>
>
> Check out the misterhouse project or even the misterhouse mailing list.
> There are some serious hardware <-> perl geeks there.
Thanks. Looks like they're heavily into X10, though they do
support RS232.
After more searching on CPAN I found what I need:
Win32::SerialPort. Somehow I overlooked that the first
time. Also, looks like I can use fcntl on "COM1". I had
forgotten all about the COM1 and COM2 stuff.
Device::USB appears to be nothing more than a placeholder.
I guess the way to use USB for now is to study up on
Microsoft's standard USB dlls and interface to them via
WIN32::API :-(
------------------------------
Date: Sun, 05 Feb 2006 04:07:46 GMT
From: nospam@geniegate.com (Jamie)
Subject: Signal handlers, objects and reference counting.
Message-Id: <Lucy113911046869500xdab308@localhost>
Hello Newsgroup,
Say I've got an object that needs to be notified on SIGCONT
(or PIPE or ...)
I can do this:
my($self) = shift;
$SIG{CONT} = sub {
$self->do_whatever();
};
But then.. when the object goes out of scope, it never gets cleaned
up because of the $self in the closure (To say nothing of other things
that might want to be alerted as well) Best I can do is have a global
variable with $self in it, and a cleanup method that determines if it's
the same as global, then undef's it.
What is a good, standard way of dealing with this?
On that note, what is a good way of finding memory leaks?
I've got quite a number of modules with circular references (By design,
they need to be that way unfortunately.)
What I'd like is a tool that'll show me how many (and ideally where/who)
is holding on to a given object so I know where to free it.
Know any good tricks for reference tracking and deleting? Not so much
modules, just handy debugging tricks to track them. (What is the
reference count on variable $foo and ideally, who holds it?)
Jamie
--
http://www.geniegate.com Custom web programming
guhzo_42@lnubb.pbz (rot13) User Management Solutions
------------------------------
Date: 5 Feb 2006 10:12:53 GMT
From: anno4000@lublin.zrz.tu-berlin.de (Anno Siegel)
Subject: Re: Signal handlers, objects and reference counting.
Message-Id: <ds4j35$qva$1@mamenchi.zrz.TU-Berlin.DE>
Jamie <nospam@geniegate.com> wrote in comp.lang.perl.misc:
> Hello Newsgroup,
>
> Say I've got an object that needs to be notified on SIGCONT
> (or PIPE or ...)
>
> I can do this:
>
> my($self) = shift;
> $SIG{CONT} = sub {
> $self->do_whatever();
> };
>
> But then.. when the object goes out of scope, it never gets cleaned
> up because of the $self in the closure (To say nothing of other things
> that might want to be alerted as well) Best I can do is have a global
> variable with $self in it, and a cleanup method that determines if it's
> the same as global, then undef's it.
It isn't clear *which* scope the object goes out of. You can make
$SIG{CONT} local to its block. (Localizing a %SIG element leaves
a tiny gap where the signal handler is undefined. If a signal arrives
in that moment, that's an uncaught exception. It's common practice
anyhow, the risk is small.)
Alternatively you can weaken the reference in $self so it isn't
refcounted. See weaken() in Scalar::Util.
> What is a good, standard way of dealing with this?
>
> On that note, what is a good way of finding memory leaks?
Leaks? Devel::Pee! :)
Sorry, Devel::Peek. It's the standard tool for that purpose, though
I haven't used it personally to find leaks.
> I've got quite a number of modules with circular references (By design,
> they need to be that way unfortunately.)
> What I'd like is a tool that'll show me how many (and ideally where/who)
> is holding on to a given object so I know where to free it.
Devel::Peek shows the refcount of SVs. The count is anonymous, individual
holders are not known.
Anno
--
If you want to post a followup via groups.google.com, don't use
the broken "Reply" link at the bottom of the article. Click on
"show options" at the top of the article, then click on the
"Reply" at the bottom of the article headers.
------------------------------
Date: 5 Feb 2006 10:28:59 GMT
From: anno4000@lublin.zrz.tu-berlin.de (Anno Siegel)
Subject: Re: using a package
Message-Id: <ds4k1b$qva$2@mamenchi.zrz.TU-Berlin.DE>
Nospam <nospam@home.com> wrote in comp.lang.perl.misc:
> I am new to perl and trying to get the above google.pm module to search for
> languages in spanish from span but I am a little stuck on how to go about
> this, can someone give me a sample of how this package module is used?
>
> package VROOM::Search::Google;
>
> use strict;
>
> use VROOM::Search qw(escape_query unescape_sequence);
What is VROOM::Search? It is no on CPAN, so you can't expect it to be
generally known.
[140 lines of code snipped]
Your code is much too long for a Usenet question.
See the posting guidelines for this group. They are posted here frequently.
Anno
--
If you want to post a followup via groups.google.com, don't use
the broken "Reply" link at the bottom of the article. Click on
"show options" at the top of the article, then click on the
"Reply" at the bottom of the article headers.
------------------------------
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 8921
***************************************