[Boston.pm] copying a bigint into an array of "normal" bits

2018-08-28 Thread Greg London



I have a function in a module that I would like to receive a bigint as a
parameter. But the first thing I want the function to do is take the
bigint and unpack it into an array of not-bigint bits.

When I use bigint, everything seems to be a bigint.
But I'm working with some existing data structures that have to be
simple arrays of simple integer/bits. The script calls Dumper on some data
and saves the result to a file, which another script uses as an input. And
I don't want to mess with that script.

I've tried putting "no bigint" in different places and I keep getting
errors of one sort or another.

Any suggestions?

sub myfunc{
   my($bigintparam)=@_;

   my @bitarray;

   # magic.


}

___
Boston-pm mailing list
Boston-pm@mail.pm.org
http://mail.pm.org/mailman/listinfo/boston-pm


Re: [Boston.pm] Image problem?

2017-11-01 Thread Greg London

On Wed, November 1, 2017 7:01 pm, Bill Ricker via Boston-pm wrote:
> Everything has to do it the same way?
> That's not TIMTOWTDI.

Meh, TIMTOWTDI is essentially saying quantity is more important than quality.

___
Boston-pm mailing list
Boston-pm@mail.pm.org
http://mail.pm.org/mailman/listinfo/boston-pm


Re: [Boston.pm] Image problem?

2017-11-01 Thread Greg London

On Wed, November 1, 2017 1:34 pm, Bill Ricker wrote:
> On Wed, November 1, 2017 3:42 am, Shirley Márquez Dúlcey wrote:
>
>> We may have a bit of an image problem.





>> a real OO interface,
> Mouse/Moo/Mouse isn't good enough?

It looks amazing, but someone needs to go back and convert
all of cpan so blessed hashes are upgraded to moose.


Rakudo has what looks like really nice subroutine parameter design.
The problem is dealing with all the code that refers to $_[3] deep
in the middle of a subroutine.

Thats one of the things that makes simple support of someone elses
perl code so hard. They werent forced to name their parameter list
up front.

>> Or if rakudo could run fast, id jump to that.
>
> All in good time.

Its been a lot of christmases in the making.
I havent used it, but apparently python has extensions
That make it static type checked, speeding up run times
And making it more popular for embedded stuff.

I like perl. Its an old friend of mine.
It does some mind blowing amazing things.
But its like that old friend who has some really annoying quirks.

Perl might be the sheldon cooper of programming languages.

Greg

___
Boston-pm mailing list
Boston-pm@mail.pm.org
http://mail.pm.org/mailman/listinfo/boston-pm


Re: [Boston.pm] Image problem?

2017-11-01 Thread Greg London
About 8 years ago, I interviewed at (internationally recognized company
name redacted) and they said they have a policy that perl is explicitly
not allowed.

My resume mentions that I wrote a book about perl.
Interview pretty much ended at that point.

Perl allowed a number of issues to creep in at the beginning and never
fixed them. Named parameters for subroutines is, like, a no brainer. But
perl doesnt have it. The alphabet soup of symbology is annoying and
inconsistent. The class/oo interface is a total hack.

The interviewer stated that perl wasnt allowed because it wasnt "strongly
typed", that it wasnt even "weakly typed". And perl feels like it went out
of its wayto not have compile time checks.

Honestly, perl6 may be better off if it brands itself as "rakudo" instead
of a sequel to perl. The biggest selling point of perl 6 in my opinion is
that it fixes all the things fundementally wrong with perl that made perl
a bad language.


I still use perl because its one of the languages that I pretty much can
code in my sleep. I know how to code most of the things I need to code
without looking anything up. Back in the day, I remember a guy who had a
career in fortran and he was just doing contract work in fortran for old
systems that needded maintenance, and holding out for retirement.

I didnt understand it then. But I get it now.

If there was a programming language that didnt have the language problems
that perl does and implements "computer language" with no fundamental
shortcomings, if it has a good regular expression interface, introspection
so I can hack variables if I need to, a real OO interface, then I'd
probably focus on learning that and phase out writing new perl scripts at
work.

Or if rakudo could run fast, id jump to that.

Ah well.
Greg



On Wed, November 1, 2017 3:42 am, Shirley Márquez Dúlcey wrote:
> We may have a bit of an image problem. Perl was the #1 most disliked
> language in a recent poll on Stack Overflow. Surprisingly, Delphi was #2; I
> didn't think it was known and used widely enough to score that high on the
> list.
>
> https://www.techrepublic.com/article/the-10-programming-languages-develop
> ers-hate-the-most/
>
> ___
> Boston-pm mailing list
> Boston-pm@mail.pm.org
> http://mail.pm.org/mailman/listinfo/boston-pm
>
>


-- 

___
Boston-pm mailing list
Boston-pm@mail.pm.org
http://mail.pm.org/mailman/listinfo/boston-pm


[Boston.pm] Perl readable Audio format with embedded timing data

2017-10-30 Thread Greg London

Is there an audio format that lets you take a song and embed command data
to be executed as the song plays?

And is there a perl module that could read/write such a file.

I thinking of embedding some high level commands into music that would
then inform some perl code as to how to generate some constrained
randomized DMX data packets to some lighting.

But I know nothing of audio formats, so I dont even know if its a thing.
And attempts to google fail miserably.

___
Boston-pm mailing list
Boston-pm@mail.pm.org
http://mail.pm.org/mailman/listinfo/boston-pm


[Boston.pm] Is AI talk for noobs?

2017-10-30 Thread Greg London


I am an AI noob but the upcoming talk sounded interesting.

Was wondering if it was a wading pool talk or scuba with sharks deep dive.

Greg

-- 

___
Boston-pm mailing list
Boston-pm@mail.pm.org
http://mail.pm.org/mailman/listinfo/boston-pm


Re: [Boston.pm] Tech Meeting: Damian's 'Why I Love Perl' keynote (TPC'17)

2017-09-12 Thread Greg London

> NOTE: Parking Alert. Recent changes in MIT Parking Dept web pages
> (parking , visitors, public ) no longer allow un-permitted parking
> after-hours.

Well that sucks.

___
Boston-pm mailing list
Boston-pm@mail.pm.org
http://mail.pm.org/mailman/listinfo/boston-pm


Re: [Boston.pm] Dwim perl and padre?

2017-06-29 Thread Greg London

I am not a cool kid.

My linux machine died and i never replaced it.
But I recently needed to do some perl coding,
So i googled perl download windows and
Ended up at a site with dwim and strawberry perl.

I think it was on perl.org


As for the error message, i spaced out all the

=header

=cut

Lines.  No change.

I commented out the guts of every subroutine, one by one.
No change.

I ended up creating a new file and copying code chunks piece by piece.
The new file never produced the error.

I have no idea what the problem was.
The old file was possessed, I suppose.

Greg




On Wed, June 28, 2017 12:10 pm, Bill Ricker wrote:
> On Wed, Jun 28, 2017 at 11:13 AM, Greg London <em...@greglondon.com>
> wrote:
>
>
>> dwim perl
>
>
> ​i thought the cool kids on Windows (if that isn't already a
> contradiction) were using Chocolatey Perl this year (Vanilla => Strawbery
> => Chocolatey,
> ok, it's a naming convention of sorts), but whichever.
>
> If your POD lacks blank lines around =commands as your example above
> lacks them, that will confuse some parsers.​ I don't know that this is
> your problem but maybe
>
>
>
> --
> Bill Ricker
> bill.n1...@gmail.com https://www.linkedin.com/in/n1vux
>
>


-- 

___
Boston-pm mailing list
Boston-pm@mail.pm.org
http://mail.pm.org/mailman/listinfo/boston-pm

[Boston.pm] Dwim perl and padre?

2017-06-28 Thread Greg London
Anyone have experience with padre?

I just installed dwim perl on a windows 10 machine at home.
I wrote a couple hundred lines of perl using the padre ide.
Somewhere along the line, it started reporting errors at line
numbers that are in the middle of

=head2 subname
Blah
Blah
Bleh
=cut

multiline comment blocks.


I have no idea what the heck happened.
I've tried the basic reboot, reload, rerun stuff.
It keeps giving weird error messages about lines with no code in it.

The code excerp in the error message is often useless too.
One that keeps popping up is it says there is an error near "){"
which occurs dozens of times in my code, and again, the line number
it reports doesnt have code in it, or if it does, doesnt have ){
anywhere near it.

Very odd.
Greg


-- 

___
Boston-pm mailing list
Boston-pm@mail.pm.org
http://mail.pm.org/mailman/listinfo/boston-pm


Re: [Boston.pm] Fwd: script works ok on command line, hangs when run from shell script

2017-05-02 Thread Greg London
So, IT got back to me.
Actually, they were pretty quick this time.
some of my tickets take weeks or months.

The tool has a thing where if you hit control-c
it gives you a tool prompt, at which point the control-D makes it
exit the tool prompt and return to the unix prompt.
But the tool is run inside a csh script and something about the
way csh works, I don't see the tool prompt when its run inside
a shell script unless I also pipe inside the shell script.

So, if the shell script is just calling "tool.exe",
then control-c skips the tool prompt and returns you to the unix prompt.
But once the shell script calls "tool.exe | filter.pl", then
hitting control-C brings up the tool prompt and it hangs.

Here's a dummy version of the tool:
#!/opt/perl_5.8.8/bin/perl
$|=1;
$SIG{'INT'} = sub {
print "tool prompt\n";
my $input=;
exit;
};
my $cnt=0;
while($cnt++<20){
print "$cnt\n";
sleep 2;
}

Here's the filter:
#!/opt/perl_5.8.8/bin/perl
$|=1;
while(<>){
print "filtered: $_";
}

here's the shell.csh script:
#!/bin/csh
tool.pl | filter.pl




If I run it from the command line:
> tool.pl | filter.pl
I let it run a bit, then hit control-C, it hangs until I hit control-D.


If I run the shell script:
> shell.csh
every time I hit control-C, it exits immediately.
it skips over the tool prompt.


So, right there is different behavior between command line and shell
even with the exact same commands.
And then the real tool is even wonkier, isn't perl, so even
more inconsistencies.

The simple fix is to pass an option to the tool to tell it to skip the
tool prompt when it gets a control c and exit immediately.
Luckily the tool has an option to do this.

But the good news is I can use my perl filter now.

Greg

___
Boston-pm mailing list
Boston-pm@mail.pm.org
http://mail.pm.org/mailman/listinfo/boston-pm


Re: [Boston.pm] Fwd: script works ok on command line, hangs when run from shell script

2017-04-29 Thread Greg London
So, this is a work thing, and work is kinda weird about what you can
and cannot use.  We have to use csh. We are also using clearcase,
with a gui from the 1980's. I have worked on military classified
projects, and my current company is the strictest place I've ever
worked at. And we do consumer parts.

Anyway, I talked with someone who is like quasi IT for our group
He couldnt figure it out. So he filed a ticket, and it has gone to
our actual IT group, which is all based in europe. Apparently
having IT people in the same building you work in is 'inefficient'

I am doing a workaround for now.
If I ever find out what the issue is, I'll let folks know.

I will say that I didnt know anything about cshell scriots
until now, and boy I wish I hadnt.  I would have madd the whold
scrit perl, but I am trying to boot something onto an existing
project.

Greg


On Thu, April 27, 2017 1:02 pm, Andrew Feren wrote:
> I'd definitely start by not using csh. It has a pile of problems as a
> scripting language. Especially related to pipes and file descriptors.
>
> http://www.faqs.org/faqs/unix-faq/shell/csh-whynot/
>
>
> -Andrew
>
>
>> On Apr 27, 2017, at 11:18, Bill Ricker  wrote:
>>
>>
>> Apparently i replied off-list.  Here's my reply for those following
>> along at home.
>>
>> // Bill
>>
>>
>> -- Forwarded message --
>>
>>
>>
>> Is your interactive commandline provided by (ba)sh or [tcz]sh ?
>> I see your script is Csh.
>> That's one possible difference since that's where the pipe is actually
>> created and sub-process spawned.
>>
>> $| won't
>> ​do what you want.
>>
>>
>> perldoc -v '$|'
>>
>> HANDLE->autoflush( EXPR )
>> $OUTPUT_AUTOFLUSH
>> $|
>>
>>
>> If set to nonzero, forces a flush right away and after every write or
>> print on the currently selected output channel. Default is 0 (regardless
>> of whether the channel is really buffered by the system or not; $| tells
>> you only whether you've asked Perl explicitly to flush after each
>> write). STDOUT will typically be line buffered if output is to the
>> terminal and block buffered otherwise. Setting this variable is useful
>> primarily when you are outputting to a pipe or socket, such as when you
>> are running a Perl program under rsh and want to see the output as it's
>> happening. This has no effect on input buffering. See getc for that. See
>> select on how to select the output channel. See also IO::Handle.
>>
>> Mnemonic: when you want your pipes to be piping hot.
>>
>>
>> ​ If you want actual non-blocking output in an output pipe or to a
>> file, I _think_ you'll need
>> ​
>> perldoc IO::Handle
>>
>> ​*$io->blocking ( [ BOOL ] )*
>>
>>
>> If called with an argument blocking will turn on non-blocking IO if
>> BOOL is
>> false, and turn it off if BOOL is true.
>>
>> blocking will return the value of the previous setting, or the current
>> setting if BOOL is not given.
>>
>> If an error occurs blocking will return undef and $! will be set.
>> ​as in
>> $io->blocking( 0 ) or croak "$!: io->blocking ( 0 )";
>>
>>
>> ​the "sub init" for SSL-capable netcat script "scnc" does :
>>
>>
>> $SIG{INT}  = sub { $self->exit };
>> $SIG{CHLD} = 'IGNORE';
>>
>>
>> STDOUT->blocking(0);
>> STDOUT->autoflush(1);
>> STDIN->blocking(0);
>> STDIN->autoflush(1);
>> ​
>>
>>
>> ___
>> Boston-pm mailing list
>> Boston-pm@mail.pm.org
>> http://mail.pm.org/mailman/listinfo/boston-pm
>>
>
> ___
> Boston-pm mailing list
> Boston-pm@mail.pm.org
> http://mail.pm.org/mailman/listinfo/boston-pm


-- 

___
Boston-pm mailing list
Boston-pm@mail.pm.org
http://mail.pm.org/mailman/listinfo/boston-pm

[Boston.pm] script works ok on command line, hangs when run from shell script

2017-04-26 Thread Greg London

This may very well be a unix thing, not a perl thing,
but I'm not a unix expert, so I'm not sure.

I have a tool I run in a shell script.

---
#!/bin/csh

tool -options -nobuffer
---

The -nobuffer is trying to get it to flush its output
to STDOUT, rather than buffer it a block at a time.

It prints out extremely long lines to STDOUT.

So, I made a perl script that takes in stdout,
does a s/// on the input, and sends it back to stdout.

---
#!/opt/perl_5.8.8/bin/perl
use warnings;
use strict;
# turn off stdout buffering... hopefully.
$|=1;

if(scalar(@ARGV)==0){
$piped=1;
} elsif(scalar(@ARGV)==1){
$piped=0;
my $inname = $ARGV[0];
$outname = $inname.'.short.log';
}

my $content;

while(<>){
my $line = $_;
my $orig=$line;
if($line=~s///){
if($line=~s///}){
}
}

if($piped){
print $line;
} else {
$content .= $line;
}
}

if($piped==0){
open(my $outh, '>'.$outname) or
die "ERROR: unable to open for write '$outname'";
print $outh $content;
close($outh);
}
---

So, when I run it on the command line, it works fine:

prompt> tool -options -nobuffer | filter.pl

The output looks exactly like I want.
And when I hit -C, it exits immediately.

But when I put it into the shell script:

---
#!/bin/csh

tool -options -nobuffer | filter.pl
---

It looks fine, but it hangs when I hit -C.

I don't know if this is a side effect of the way the shell script works.
If its a side effect of the perl script.
if its something to do with flushing STDOUT.

If I hit control-c when its clearly not in the regular expression area,
I can sometimes get it to exit immediately. But once the tool reaches
a certain point, every line is going through the regular expression,
and at that point, control-C seems to stop execution, but refuses
to give me a prompt back.

I don't think I've ever written a perl script that takes a pipe input
so I don't know if there is some side effect about pipes, perl, and
control-C maybe?

Any ideas?

Greg London

___
Boston-pm mailing list
Boston-pm@mail.pm.org
http://mail.pm.org/mailman/listinfo/boston-pm


[Boston.pm] perl6 lists

2016-06-23 Thread Greg London
Can't seem to wrap my head around perl6 lists.

They're not arrays. They seem to exist almost as literals.
When I assign a list to an array, it stops acting like a literal list.

This works as expected:
for 1,2,3,4 {say "here is $^first";}
here is 1
here is 2
here is 3
here is 4

THis does not work as expected:
my $otherlist = (11,22,33,44);
for $otherlist {say "here is $^first";}
here is 11 22 33 44;

Calling "flat" on the scalar doesn't change the output.
The only thing that seems to get it to do the right thing is to put "@" in
front of the scalar containing the list.

for @$otherlist {say "here is $^first";}
here is 11
here is 22
here is 33
here is 44

so, I can make a literal list 1,2,3 and loop on it,
and I can loop on an array,
but I can't loop on a scalar with a list in it
and I can't flatten a list inside a scalar.

Is there a rule underlying this behavior that makes it consistent?
Because right now, it seems like a couple of arbitrary rules
enforced to get a particular, but inconsistent, behavior.

Greg




___
Boston-pm mailing list
Boston-pm@mail.pm.org
http://mail.pm.org/mailman/listinfo/boston-pm


Re: [Boston.pm] Perl 6 sensitive to white space?

2016-02-17 Thread Greg London


This is going to take some getting used to.



On Wed, February 17, 2016 3:33 pm, Morse, Richard E.,MGH wrote:
> Hi! No, list context is more common.
>
>
> In particular, it isn’t the comma operator. It’s (I think) the
> parenthesis.
>
> `(123, 456)` creates a list of two elements. Lists no longer
> automatically flatten (i.e., (1, (2, 3), 4) is only three elements long).
> If there is a space after a function call, it’s assumed to be a list
> operator, not a function, so the parameters are interpreted in list
> context; this means that (123, 456) creates a single list object which
> gets passed to your function.
>
> Ricky
>
>
>> On Feb 17, 2016, at 4:26 PM, Greg London <em...@greglondon.com> wrote:
>>
>>
>>
>> So perl6 thinks it is an expression,
>> With some kind of weird "comma" operator,
>> Which returns a single thingy of some kind,
>> That gets passed as a single argument to the function?
>>
>>
>> What is the comma operator doing
>> And what is the return thingy of the expression?
>>
>>
>> In perl5, this would have been at most list context of 123 and 455,
>> which would have returned multiple items in a list, and would be visible
>> in A perl 5 sub as $_[0] and $_[1].
>>
>>
>> Is list context gone in perl 6?
>>
>>
>>
>> Greg
>>
>>
>>
>>
>> On Wed, February 17, 2016 11:04 am, Bill Ricker wrote:
>>
>>> That's an ambiguous parse for 1 arg vs 2 arg form, are the parents a
>>> function call or an expression. Space disambiguates it: f( a, a2) is
>>> function, f (a, a2) is an expression whose result is passed to the
>>> function.
>>>
>>> On Wed, Feb 17, 2016 at 11:43 AM, Greg London <em...@greglondon.com>
>>> wrote:
>>>
>>>
>>>
>>>>
>>>> Is perl6 whitespace sensitive?
>>>> Or is this a bug?
>>>>
>>>>
>>>>
>>>> I have a multi() for 1 and 2 artuments
>>>> But a 2 arg call ends up getting into the wrong sub
>>>> Apparently because there is a space between the sub name and the
>>>> Opening parenthesis?
>>>>
>>>>
>>>>
>>>>
>>>>
>>>> multi mysub($arg1) { say "mysub(one): $arg1"; }
>>>>
>>>>
>>>> multi mysub($arg1, $arg2) { say "mysub(two): '$arg1' then '$arg2'";
>>>> }
>>>>
>>>>
>>>>
>>>>
>>>>
>>>> mysub(555); mysub(123, 456); mysub(999); mysub (123, 456);  # a
>>>> space between sub and parenthesis
>>>>
>>>> output:
>>>>
>>>>
>>>>
>>>> mysub(one): 555
>>>> mysub(two): '123' then '456'
>>>> mysub(one): 999
>>>> mysub(one): 123 456<== whoops!
>>>>
>>>>
>>>>
>>>>
>>>>
>>>> --
>>>>
>>>>
>>>>
>>>> ___
>>>> Boston-pm mailing list
>>>> Boston-pm@mail.pm.org
>>>> http://mail.pm.org/mailman/listinfo/boston-pm
>>>>
>>>>
>>>>
>>>
>>>
>>>
>>> --
>>> Bill Ricker
>>> bill.n1...@gmail.com https://www.linkedin.com/in/n1vux
>>>
>>>
>>
>>
>> --
>>
>>
>>
>>
>> ___
>> Boston-pm mailing list
>> Boston-pm@mail.pm.org
>> http://mail.pm.org/mailman/listinfo/boston-pm
>>
>
>
>
> The information in this e-mail is intended only for the person to whom it
> is addressed. If you believe this e-mail was sent to you in error and the
> e-mail contains patient information, please contact the Partners
> Compliance HelpLine at
> http://www.partners.org/complianceline . If the e-mail was sent to you in
> error but does not contain patient information, please contact the sender
> and properly dispose of the e-mail.
>


-- 



___
Boston-pm mailing list
Boston-pm@mail.pm.org
http://mail.pm.org/mailman/listinfo/boston-pm


Re: [Boston.pm] Perl 6 sensitive to white space?

2016-02-17 Thread Greg London

So perl6 thinks it is an expression,
With some kind of weird "comma" operator,
Which returns a single thingy of some kind,
That gets passed as a single argument to the function?

What is the comma operator doing
And what is the return thingy of the expression?

In perl5, this would have been at most list context of 123 and 455, which
would have returned multiple items in a list, and would be visible in
A perl 5 sub as $_[0] and $_[1].

Is list context gone in perl 6?


Greg



On Wed, February 17, 2016 11:04 am, Bill Ricker wrote:
> That's an ambiguous parse for 1 arg vs 2 arg form, are the parents a
> function call or an expression. Space disambiguates it: f( a, a2) is
> function, f (a, a2) is an expression whose result is passed to the
> function.
>
> On Wed, Feb 17, 2016 at 11:43 AM, Greg London <em...@greglondon.com>
> wrote:
>
>
>>
>> Is perl6 whitespace sensitive?
>> Or is this a bug?
>>
>>
>> I have a multi() for 1 and 2 artuments
>> But a 2 arg call ends up getting into the wrong sub
>> Apparently because there is a space between the sub name and the
>> Opening parenthesis?
>>
>>
>>
>>
>> multi mysub($arg1) { say "mysub(one): $arg1"; }
>>
>>
>> multi mysub($arg1, $arg2) { say "mysub(two): '$arg1' then '$arg2'"; }
>>
>>
>>
>>
>> mysub(555); mysub(123, 456); mysub(999); mysub (123, 456);  # a space
>> between sub and parenthesis
>>
>> output:
>>
>>
>> mysub(one): 555
>> mysub(two): '123' then '456'
>> mysub(one): 999
>> mysub(one): 123 456<== whoops!
>>
>>
>>
>>
>> --
>>
>>
>> ___
>> Boston-pm mailing list
>> Boston-pm@mail.pm.org
>> http://mail.pm.org/mailman/listinfo/boston-pm
>>
>>
>
>
>
> --
> Bill Ricker
> bill.n1...@gmail.com https://www.linkedin.com/in/n1vux
>
>


-- 



___
Boston-pm mailing list
Boston-pm@mail.pm.org
http://mail.pm.org/mailman/listinfo/boston-pm


[Boston.pm] Perl 6 sensitive to white space?

2016-02-17 Thread Greg London

Is perl6 whitespace sensitive?
Or is this a bug?

I have a multi() for 1 and 2 artuments
But a 2 arg call ends up getting into the wrong sub
Apparently because there is a space between the sub name and the
Opening parenthesis?



multi mysub($arg1) {
say "mysub(one): $arg1";
}

multi mysub($arg1, $arg2) {
say "mysub(two): '$arg1' then '$arg2'";
}



mysub(555);
mysub(123, 456);
mysub(999);
mysub (123, 456);  # a space between sub and parenthesis

output:

mysub(one): 555
mysub(two): '123' then '456'
mysub(one): 999
mysub(one): 123 456<== whoops!



-- 

___
Boston-pm mailing list
Boston-pm@mail.pm.org
http://mail.pm.org/mailman/listinfo/boston-pm


Re: [Boston.pm] TONIGHT - Tech Meeting - Perl 6 parallel and async features !

2016-02-12 Thread Greg London
Installed rakudo and started playing with some basics and tutorials.
Some pretty cool stuff.

Re the "bind" function, is there a way to "unbind" 2 variables after being
bound?  Bind would be a great way to simulate different hardware signals
tied together with wires. But hardware can connect and disconnect, so an
"unbind" would be needed.

I recall way back when, perl 6 was going to have subroutines you could
call, that would return mid sub, and when called again it would start up
where it last left off. Coroutine? Havent seen that in the rakudo
tutorials I have been working through.  Is rakudo going to support this?
This would be a must-have to simulate hardware in perl.


Kind of thought they might come up in the parrallelism talk, but i guess
its a different variation.


On Tue, February 9, 2016 10:41 am, Bill Ricker wrote:
> TONIGHT.
> Note: MIT E51 has free off-street parking after 3pm, easy-off/easy-on from
>  major highways via Mem Drive / Land Blvd. Detour no longer in effect.
>
> On Sun, Feb 7, 2016 at 11:21 PM, Bill Ricker 
> wrote:
>
>
>> ​Trying again, we were snowed out in January ... can we dig out in
>> time this week ? ​
>>
>
> Theme: Perl 6 for Xmas is "Sixmas"
> ​ continues
>
> 2016
> ​Feb. 9th  ​ - MIT  - E51-376 Perl 6 -
> ​ now with Parallel and Async primitives that work ?!​ (Perl 6 is here:
> Part
> ​4​ ) *Jonathan Worthington*
> Lead Dev of Rakudo Perl 6 and founder of MoarVM
> [appearing via tape delay]
> "Parallelism and concurrency are different, though often confused.
> Asynchrony adds yet another concept into the mix. And there are dozens of
> different approaches to working with these concepts. How do we identify
> what kind of problem we're dealing with, and pick an approach to solving
> it? "In this session, I'll look at a range of different problems - some
> parallel, some concurrent - and show the approaches that may be taken to
> solve them. And, since I've been working on the Perl 6 parallelism and
> concurrency features, I'll show how these solutions look in Perl 6."
>
>
> ... and any comments from anyone who's downloaded it and messed with it
> since Sixmas 
>
> (Note, word is if you had an old RakudoBrew, it needs removal and
> re-clone for the release
>  perl-6> .)
>
>
>
> perl6.org
>
>
>
> *Boilerplate details*
>
>
> - Tech Meetings are held on the 2nd Tuesday of every month at MIT
> building E51, Sloan School Tang Center [not the other Tang building!]
> nearer to Kendall Sq than Mass Ave. (directions
> ).
> - Talk begins at 7:30.
> ​ Gather 7​ish - Refreshments in the hallway prior.
> ​ 7:15ish.​ - RSVP for count encouraged but not required, to
> bill.n1...@gmail.com or Boston-PM list
> , by 4pm
> Tuesday.
>
>
>
> (*NOTE: we're Staying in the wider room 376 second door, not the squarish
>  372 first door that we had some terms.)*
>
>
> Would you like to present for Boston.pm? See our Presenter's Guide
> 
>
>
> --
> Bill Ricker
> bill.n1...@gmail.com https://www.linkedin.com/in/n1vux
>
>
> ___
> Boston-pm mailing list
> Boston-pm@mail.pm.org
> http://mail.pm.org/mailman/listinfo/boston-pm


-- 



___
Boston-pm mailing list
Boston-pm@mail.pm.org
http://mail.pm.org/mailman/listinfo/boston-pm


Re: [Boston.pm] perl 6: continuation? Unbind?

2016-02-12 Thread Greg London
yes, continuation. That was the term.
I remember a perl monger meeting years ago
where someone was doing a presentation about
having continuations in perl6. But that wasn't rakudo.

Anyway, they'd be on my xmas list.

Greg


On Fri, February 12, 2016 8:09 pm, Mike Small wrote:
> "Greg London" <em...@greglondon.com> writes:
>
>
>> Also, I recall way back when, perl 6 was going to have subroutines
>> you could call, that would return mid sub, and when called again it would
>> start up where it last left off. I think its called a Coroutine? Havent
>> seen that in the rakudo tutorials I have
>
> Perhaps you mean a continuation? Though from the last chapter of The
> Scheme Programming Language it would appear that coroutines can be
> implemented in terms of them. I have no idea if Perl 6 has them. Wish I
> could have gone to the meeting but I was too sick.
>
> --
> Mike Small
> sma...@sdf.org
>


-- 



___
Boston-pm mailing list
Boston-pm@mail.pm.org
http://mail.pm.org/mailman/listinfo/boston-pm


[Boston.pm] perl 6: coroutines? Unbind?

2016-02-12 Thread Greg London

Installed rakudo and started playing with some basics and tutorials.
Some pretty cool stuff.

Re the "bind" function, is there a way to "unbind" 2 variables after
being bound?  Bind would be a great way to simulate different
hardware signals tied together with wires. But hardware can connect
and disconnect, so an "unbind" would be needed.

Also, I recall way back when, perl 6 was going to have subroutines
you could call, that would return mid sub, and when called again
it would start up where it last left off. I think its called
a Coroutine? Havent seen that in the rakudo tutorials I have
been working through.  Is rakudo going to support this? This would
be a must-have to simulate hardware in perl.

Kind of thought they might come up in the parrallelism talk, but i guess
its a different variation.

SystemC is a way to simulate hardware using a library in c.
It would be great if perl6 could simulate hardware natively,
with no external library needed.

Also, just a pedantic complaint, but if you want the size of an array,
you should call size(), not elems();



___
Boston-pm mailing list
Boston-pm@mail.pm.org
http://mail.pm.org/mailman/listinfo/boston-pm


[Boston.pm] Unknown error

2016-01-26 Thread Greg London

Good grief.

Just spent an hour debugging a bunch of perl that was giving me the error

"Unknown error"

No line number. No context. No nothing.

It eventually came down to a line that said

use base mymod;

When it should have been

use base "mymod";

I am using an older version of perl, but I do hope the latest version will
catch this and give a better error message.







___
Boston-pm mailing list
Boston-pm@mail.pm.org
http://mail.pm.org/mailman/listinfo/boston-pm


[Boston.pm] perl distro for windows 10?

2016-01-09 Thread Greg London
I broke down and got a Windows laptop.
In my defense, it was mostly because most of the 3d printer
software I tried doesn't work on Linux.

Anyway, I was wondering what perl distro people consider the best of
the best for Windows 10?

Stable. has a bunch of modules standard.
Can install new modules without a lot of pain and suffering.

Greg



___
Boston-pm mailing list
Boston-pm@mail.pm.org
http://mail.pm.org/mailman/listinfo/boston-pm


[Boston.pm] boost::format to sprintf, or how do I get a substitution with a substitution in it?

2015-04-03 Thread Greg London
I've got a rather largish pile of c++ code that makes a lot of calls to
boost::format. I'm having trouble compiling the code on my FPGA platform
(can't figure out how to install boost::format into the tool flow). So, I
thought maybe I'd try to do a perl script to convert all the files to use
sprintf.

So I need to convert
(format(blah %s de %d bleh) % expression1 % expression2 ).str()

to
sprintf(blah %s de %d bleh, expression1 , expression2 )

A single format() call might span multiple lines,
so I figured I'd slurp all the text in at once
and do a search and replace. There might be more
than one occurrence per file, so I'd add the /g modifier.

s/format\((.*?)\)(.*?)\.str\(\)/something/g

The problem is I need $1 and $2 to put into sprintf
but I before I do that, I also need to take the '%'
operators in $2 and replace them with ',' and THEN
put it back in.

Things started to get hairy, and I was wondering
if I'm overlooking a solution that would make this
a lot easier.






___
Boston-pm mailing list
Boston-pm@mail.pm.org
http://mail.pm.org/mailman/listinfo/boston-pm


Re: [Boston.pm] object composition (has-a) with built-in OO system

2014-11-02 Thread Greg London
My experience has been that having a page instance be mangled
in some way to behave like a book is almost always going to be
a regrettable coding decision.

What I sometimes do would be to have the page contain a pointer
to the book in which it is bound, so that the page can call
book level methods.

If a page needed to display page 1 of total, it would need
to call the book method to find out the total number
of pages in the book. It starts getting weird for me if the
page class has or inherits book level methods.

ymmv
Greg


On Sun, November 2, 2014 12:03 am, Adam Russell wrote:
 I would rather have a book have pagesthan just have pages. Perhaps

 The approach I took was to define a package LinkedListNode and then a
  package LinkedList. My idea is that my LinkedList package is a
 wrapper around the head node which would also define some useful
 methods such as print_list(), remove_node(), and so forth.




___
Boston-pm mailing list
Boston-pm@mail.pm.org
http://mail.pm.org/mailman/listinfo/boston-pm


[Boston.pm] ver 5.20 of perl?

2014-06-27 Thread Greg London

one of the IT guys at work just asked what
I thought about installing version 5.20.0 of perl
on all our computers.

We currently have 5.8.8.

I don't even know if 5.20 is considered stable or not.
Buggy? Issues?

Is a different version better?

Thoughts?

My experience with IT
(at every job I've ever worked at)
is usually one of
You have perl 5.4, that should be good enough.
so, I wanted to make the most of this.

Greg






___
Boston-pm mailing list
Boston-pm@mail.pm.org
http://mail.pm.org/mailman/listinfo/boston-pm


Re: [Boston.pm] Tech Meeting - benchmarking Perl5 vs Perl6

2013-12-12 Thread Greg London
 Production ready is hard to define, much like quality.

Yeah, but 1000 times slower is objective and pretty definitive.




 Bill Ricker wrote:
 Tuesday December 10, 2013 E51-376
 Tim King - Benchmarking Perl6 vs Perl5

 * Perl 6's suitability for production. (Your definition may vary.)
 * Experiences of the state and stability of Rakudo.
 * Benchmarks of my favorite P6 features.
 * Lines of P6 code from everyday life.
 * Some comparisons of P6 with P5.

 If you missed the talk, we're working on getting a version posted
 online. (Tim confirmed that the audio capture was successful, and the
 slides have been rendered to video. Need to edit the two together.) A
 PDF of the slides will also be posted.


 Here's an edited version of what I live blogged to our #boston.pm IRC
 room (*spoiler alert*):

 perl6-bench was used as the bench testing framework. It was created by
 Geoffrey Broadwell, and covered in his The Need for Speed talk at
 YAPC::NA 2013
 http://bit.ly/P6BenchTalk

 What remains to make p6 production ready?
 According to Carl Mäsak: Features, concurrency, cpan, speed (a big one).

 Production ready is hard to define, much like quality.

  From a coder's perspective, will p6 code be elegant? Are the sorts of
 modules I need available? Will new p6 version break the code I write
 today? Will it be fast enough?

 Production ready is relative to what you want to use p6 for. The answer
 may be different for a LAN backup script vs. a web application.

 perl6-bench automates creating the sandboxes for each interpreter (p5,
 and several p6 versions). And automates running the tests and logging
 and graphing the times.

 The comparisons are intentionally excluding startup time. Still learning
 p6 and don't yet know how to optimize p6 code.

 NQP = Not Quite Perl. Used as the base language in some of the VMs. They
 compile P6 to NQP.

 First bench test is a trivial while loop. The graph shows p5 hitting
 near 33 million iterations per second. nqp-parrot reaches ~3M itr/s.
 While nqp-jvp, due to optimizations, eventually after enough iterations
 starts to run a bit faster than p5.
 nqp-jvm: just over 33 million iterations per second
 p5: just below 33 million iterations per second
 nqp-parrot: 3M itr/s
 rakudo-jvm: 300K itr/s
 rakudo-parrot: 65K itr/s

 The JVM lead holds true only under some circumstances. Incorporating a
 string concatenation operation causes nqp-jvm performance to plunge
 (peaking at only 65K itr/s, and dropping off with more cycles).
 p5: 8 million iterations per second
 nqp-parrot: 2M itr/s
 nqp-jvm: 65K itr/s (peak; not consistent as iteration count goes up)
 rakudo-parrot: 32K itr/s
 rakudo-jvm: 32K itr/s (peak; not consistent as iteration count goes up)

 Next benchmark is rc-forest-fire (cell automaton algorithm).
 p5: 512 frames/s (all numbers rounded to nearest line on chart)
 nqp-parrot: 64 fps
 niecza: 4 fps
 rakudo-parrot: 0.5 fps

 The test was repeated on a faster machine, adding more interpreters, but
 dropping niecza.
 nqp-jvm: 2048 fps (over a limited range of cycles)
 p5: 1024 fps
 nqp-parrot: 128 fps
 rakudo-jvm: 1 fps
 rakudo-parrot: 0.5 fps

 Next benchmark is fractal-tree, which generates a scalable vector
 graphic of a tree using a fractal algorithm. It is used to test object
 construction and method calls.
 P5: 65k branches per second
 rakudo-jvm: peaked at 128 branches/s

 Moose version of fractal tree hit near 8k branches/s.

 Strong typed version of fractal-tree in p6 is actually slightly slower
 than dynamic types.

 First version of fractal-tree in p6 iterated over arrays multiple times,
 while p5 code iterated once in a bigger loop. The big loop p5 approach
 was then ported to p6. Now p6 version peaks at 256 branches/s.

 Now for some more real-world benchmarks using common CPAN modules that
 have been ported to p6.

 Next benchmark is P5 vs. P6 versions of JSON::Tiny. P6 version uses Perl
 6's custom grammar feature.
 P5: 64 iterations/s
 nqp-jvm: 8 itr/s
 rakudo-jvm: 1 itr/s
 nqp-parrot: 0.5 itr/s
 rakudo-parrot: 0.1 itr/s

 JSON::Tiny was next ported to Marpa::R2 in p5 to see how p5 performs
 while providing a parser syntax similar to a p6 grammar.
 JSON::Marpa: 8 itr/s

 Marpa matched nqp-jvm, though Marpa had more linear performance at low
 iteration counts (before the JVM has had a chance to optimize).

 Next benchmark is HTML::Template.
 p5: 256 pages per second
 rakudo-jvm: 4 pps
 rakudo-parrot: 0.5 pps

 Next is File::Compare.
 p5: 4096 MB/s
 rakudo-jvm: 128 MB/s
 rakudo-parrot: 16 MB/s

 So is p6 ready?
 Because Rakudo's correctness is questionable, when things don't work, it
 leaves you scratching your head wondering if it is your bug or Rakudo's.

 Stability is a really important metric of readiness. The perl6-bench
 couldn't work with the version of rakudo-parrot from just a few months
 ago. Only with the latest version.


  -Tom

 --
 Tom Metro
 The Perl Shop, Newton, MA, USA
 Predictable On-demand Perl Consulting.
 http://www.theperlshop.com/

 

Re: [Boston.pm] ?instances of classA contained in classB, and instances of classB contained in classC ?

2013-12-06 Thread Greg London

 then the code to do stuff is generic across ALL the register  types.

Wouldn't I get that with polymorphism?
If every class had randomValidDate()
and each method handled the different
internal data format, don't I get a
generic interface for all register types?

I'm not familiar with this table driving approach.
is there a short example on the web I could look at?

Greg


 On 12/06/2013 11:47 AM, Me wrote:
 I use this environment for asic verification. So one kind of test is
 to randomize every register with data. But different types of
 registers have different valid data definitions. For example, one
 type of register is 16 bits wide with the top 5 bits representing an
 exponent, and the remaining 11 bits representing the mantissa. There
 are many registers of this type. They might set a voltage, a current
 limit, temperature alarm, and so on. And if the value of the voltage
 is outside the range of the chip, the write to that register needs to
 be rejected by the chip.

 So i was envisioning a class to handle this exponent/mantissa format,
 then have a method like randomValidData(). There are other register
 types that 16 bit mantissa and the exponent is held in yet another
 register. So randomValidData for that type of register would be
 different.

 A lot of testing often needs to write random but valid data to
 registers. So if i have a container of instances of different
 register classes, i could iterate through all registers and fill them
 with valid random data.


 i would do some sort of table driving here. have a collection of small
 subs (or methods) that do the various tasks like generating
 mantissa/exponent data or verifying stuff, etc. this may be a large
 collection but each sub does one small task. then make a dispatch table
 so you can access all the subs (if they are methods, then just the names
 are needed). then for each register type, you assign a list of the subs
 to handle it. one set for generating data and another for verifying.
 there is actually very little coding here other than the subs doing the
 work. then the code to do stuff is generic across ALL the register
 types. it just gets the info for the given register, looks up the worker
 subs it needs and calls them. there is no need for layers of objects or
 complex structures. this can even handle nested stuff, if you define the
 workers that way you just make each register have a nested set of keys
 telling the code what to do.

 this can all be done procedurally too. OO could help but it may not be
 needed. i have done similar things for testing several of my modules. i
 even gave a pm talk on it many moons ago.

 uri

 --
 Uri Guttman - The Perl Hunter
 The Best Perl Jobs, The Best Perl Hackers
 http://PerlHunter.com

 ___
 Boston-pm mailing list
 Boston-pm@mail.pm.org
 http://mail.pm.org/mailman/listinfo/boston-pm



-- 



___
Boston-pm mailing list
Boston-pm@mail.pm.org
http://mail.pm.org/mailman/listinfo/boston-pm


Re: [Boston.pm] Perl community The Rising Costs of Aging Perlers

2013-07-23 Thread Greg London

A few years ago I interviewed with a big-name company that said
perl is forbidden on their projects. The interview was with the
engineering manager. and it seemed like he was driving that decision.

He said perl was too messy, too many ways to do things and
no set way to do things, so you end up with incompatible
chunks of code, and he hated the line noise.

They said they use java instead. According to him, it had
some strong typing built into it.

I politely as I could told him that I worked on vhdl/ada for
several years and strong typing can be a massive amount of
work in and of itself. I don't know java so I don't know
how strong it is.

maybe perl 6's class convention will fix the
million ways to do classes and they're all incompatible
problem. I get a little tired of the line noise myself sometimes.

I would really love to see named, type-checked, subroutine
parameters, with default values of the unassigned ones.
@_ is cute, and it can be cool to have the default paramter
variable be as many paramteres as you want, unlike c++ where
having an undefined number of parameters is a pain to work
with, but sometimes @_ can be a pain to work with too.

Maybe when perl 6 is official, it will remove some of the
consistent complaints about perl from the discussion.

Then again, there's also the coolness factor.

Perl was cool when it was the glue that held the internet together.

I assume java became cool when it became the defacto language for
writing droid apps. Everyone wanted to write the next angry birds
and make a million dollars, so that's good for recruitment
purposes.

Maybe perl5 or perl6 could figure out someway to make perl
the lottery language again. If the next big app was
written in perl and made some kid a chunk of money, that
would help.

We've been looking to hire an electrical engineer and
I would like someone with strong perl. So far the interviewees
have been either weak perl skills (I haven't written my
own perl script, but I've looked at other people's scripts)
or no perl at all.

Since perl is lower priority compared to EE skills, we'll
probably end up with someone with weak skills.

So, my interview for a job a few years ago, and
our current interviewing for someoen now,
would seem to say that perl coders are aging and
not getting replaced.


Greg


 Bill Ricker wrote:
 Three-part article by VM Brasseur @vmbrasseur
 The Rising Costs of Aging Perlers

 I guess this was worth writing down, but weren't we all aware that the
 practitioners of Perl are aging and not enough junior developers are
 being created to sustain the language as a going concern? Pretty much
 any Perl-related metric you look at will tell you this.

 In part 2:

   ...it does not appear as though the Perl community is doing much to
   correct this issue. As I detailed in my earlier post, in many cases
   Perl's new programmer outreach appears fairly crummy if not virtually
   non-existent. This needs to change before Perl starts to face a
   cultural extinction.

 This gives the impression like the #1 problem with Perl is the lack of
 outreach to new developers.

 Making sure new developers have a good experience is a useful way of
 reducing the friction of getting developers from junior to intermediate,
  and yes, if you do a really bad job at it, you'll turn some developers
 away (a quantity I expect amounts to a rounding error), but you have to
 look further up the marketing funnel to find the real problem.
 Developers need a compelling reason to investigate the language in the
 first place. That's not happening these days for both technical and
 perceptual reasons.

 Two of the three prescribed solutions in part 3 actually address the
 marketing problems, rather than the thesis from part 1, developer
 outreach. One was make cool stuff and talk about it. This is a great
 idea, even if not novel. (The Iron Man Blogging Challenge[1] was one
 attempt at that.) But it is less clear how to encourage it to happen,
 other than simply spreading the word.

 The next suggestion is Modernize our dilapidated online communities,
 specifically mentioning PerlMonks. Sounds good, and I'm sure some of
 that wouldn't hurt. But how do you make that happen? Who runs PerlMonks?
 (Apparently it was was recently assimilated by The Perl Foundation.)
 It seems it is equally important to go to the new platforms where
 developers hang out now, like Stack Overflow. (You can find a link to
 the weekly stackoverflow perl report[2] in the Perl Weekly
 newsletter[3].)

 The third and final suggestion is for The Perl Foundation (TPF) to fund
 training, outreach and community building. That's great, and if there
 are sponsors and volunteers interested in pursuing that, fantastic, but
 if I was allocating a limited budget of time and money to solving Perl's
 diminishing relevance, there are higher priority, big picture issues to
 be addressed.

 Maybe my assumptions are wrong, but I'd like to see the stats that show
 that PHP, Python, and Ruby are 

[Boston.pm] Can't locate Test/Warn.pm in cpantesters.org

2013-05-10 Thread Greg London

Hm, so, I just got an email from cpan testers that Parse::Gnaw failed to
pass on every installation. I clicked on one of the links they included:

http://www.cpantesters.org/cpan/report/a3910b85-6dcd-1014-a5d2-5aa324ca0c09

And I see this:

t/gnaw_call.t . ok
Can't locate Test/Warn.pm in @INC (@INC contains: lib
C:\Perl16\cpan\build\Parse-Gnaw-0.600-SugcXd\blib\lib
C:\Perl16\cpan\build\Parse-Gnaw-0.600-SugcXd\blib\arch C:/Perl16/site/lib
C:/Perl16/lib) at t/gnaw_call_nonexistent.t line 11.
BEGIN failed--compilation aborted at t/gnaw_call_nonexistent.t line 11.


How do I get Test::Warn in there?

Greg



___
Boston-pm mailing list
Boston-pm@mail.pm.org
http://mail.pm.org/mailman/listinfo/boston-pm


Re: [Boston.pm] suppressing warnings

2013-05-05 Thread Greg London

Wow, I have never seen warnings used as
an invocant to a method call before.

I'm currently using:
   use Exporter 'import';
   our @EXPORT = qw ( stuff );

but I'll rewrite it to use an import() subroutine and
Exporter's export_to_level() call instead.

Thanks,
Greg


 If your module has an import method, and in that method calls
 warnings-unimport(once) then the unimport should be lexically
 scoped to where your package was used.  Which in the normal case is
 the whole file, so it works.

 On Sat, May 4, 2013 at 2:07 PM, Jordan Adler jordan.m.ad...@gmail.com
 wrote:
 This pragma usage is lexically scoped, too.

 Sent from my iPhone

 On May 4, 2013, at 5:01 PM, Jordan Adler jordan.m.ad...@gmail.com
 wrote:

 Design issues aside,

 no warnings 'once';

 Sent from my iPhone

 On May 4, 2013, at 3:47 PM, Greg London em...@greglondon.com wrote:

 is there a way to suppress this warning from inside testpackage.pm
 somehow?

 I've tried a bunch of things and still haven't found a solution.

 Is this not possible to do in per?
 Or is it so obvious I can't see it?

 Greg



 package file testpackage.pm:

 package testpackage;
 use warnings;
 use strict;
 use Data::Dumper;
 use Exporter 'import';
 our @EXPORT = qw ( somesub );
 sub somesub{
   my ($name)=@_;
   my @caller=caller(0);
   my $package=$caller[0];
   my $evalstr = '$'.$package.'::'.$name.' = 42;';
   eval($evalstr);
 }
 1;


 script file testscript.pl:

 #!/usr/bin/env perl
 use warnings;
 use strict;
 use testpackage;
 somesub('tricky');
 print hello, tricky is '$main::tricky'\n;


 When I run this script, I get the warning:
 Name main::tricky used only once: possible typo at ./testscript.pl


 is there a way to suppress this error from inside testpackage.pm
 somehow?








 ___
 Boston-pm mailing list
 Boston-pm@mail.pm.org
 http://mail.pm.org/mailman/listinfo/boston-pm


 --



 ___
 Boston-pm mailing list
 Boston-pm@mail.pm.org
 http://mail.pm.org/mailman/listinfo/boston-pm

 ___
 Boston-pm mailing list
 Boston-pm@mail.pm.org
 http://mail.pm.org/mailman/listinfo/boston-pm



-- 



___
Boston-pm mailing list
Boston-pm@mail.pm.org
http://mail.pm.org/mailman/listinfo/boston-pm


Re: [Boston.pm] suppressing warnings

2013-05-04 Thread Greg London
 is there a way to suppress this warning from inside testpackage.pm somehow?

I've tried a bunch of things and still haven't found a solution.

Is this not possible to do in per?
Or is it so obvious I can't see it?

Greg



 package file testpackage.pm:

 package testpackage;
 use warnings;
 use strict;
 use Data::Dumper;
 use Exporter 'import';
 our @EXPORT = qw ( somesub );
 sub somesub{
   my ($name)=@_;
   my @caller=caller(0);
   my $package=$caller[0];
   my $evalstr = '$'.$package.'::'.$name.' = 42;';
   eval($evalstr);
 }
 1;


 script file testscript.pl:

 #!/usr/bin/env perl
 use warnings;
 use strict;
 use testpackage;
 somesub('tricky');
 print hello, tricky is '$main::tricky'\n;


 When I run this script, I get the warning:
 Name main::tricky used only once: possible typo at ./testscript.pl


 is there a way to suppress this error from inside testpackage.pm somehow?








 ___
 Boston-pm mailing list
 Boston-pm@mail.pm.org
 http://mail.pm.org/mailman/listinfo/boston-pm



-- 



___
Boston-pm mailing list
Boston-pm@mail.pm.org
http://mail.pm.org/mailman/listinfo/boston-pm


[Boston.pm] expect.pm install

2013-05-02 Thread Greg London
Anyone use Expect.pm?

I'm looking to use it at work, but I seem to be running into some
resistance from IT about installing it (and its bundle) on all
the machines. I was told I can install anything I want locally
within the project source code repository, but that installing
something on every machine is going to get resistance.

So, the question is, is it even possible to intall Expect.pm
and its associated bundle in a source code repository and
have that code run on different machines?

I would assume that modules like
Expect.pm, IO::Stty, IO::Tty, IO::Pty
seem low level enough that they would
be a bit machine specific?




___
Boston-pm mailing list
Boston-pm@mail.pm.org
http://mail.pm.org/mailman/listinfo/boston-pm


Re: [Boston.pm] May, June speakers/topics?

2013-04-28 Thread Greg London
I should be able to present *something* about my new parser by May's meeting.

It might not entirely work by then, but I hope to have it running basic
tests by then.

(it's running basic basic tests now)

Greg


 volunteers/nominees sought

 --
 Bill
 @n1vux bill.n1...@gmail.com

 ___
 Boston-pm mailing list
 Boston-pm@mail.pm.org
 http://mail.pm.org/mailman/listinfo/boston-pm



-- 



___
Boston-pm mailing list
Boston-pm@mail.pm.org
http://mail.pm.org/mailman/listinfo/boston-pm


[Boston.pm] suppressing warnings

2013-04-28 Thread Greg London

package file testpackage.pm:

package testpackage;
use warnings;
use strict;
use Data::Dumper;
use Exporter 'import';
our @EXPORT = qw ( somesub );
sub somesub{
my ($name)=@_;
my @caller=caller(0);
my $package=$caller[0];
my $evalstr = '$'.$package.'::'.$name.' = 42;';
eval($evalstr);
}
1;


script file testscript.pl:

#!/usr/bin/env perl
use warnings;
use strict;
use testpackage;
somesub('tricky');
print hello, tricky is '$main::tricky'\n;


When I run this script, I get the warning:
Name main::tricky used only once: possible typo at ./testscript.pl


is there a way to suppress this error from inside testpackage.pm somehow?








___
Boston-pm mailing list
Boston-pm@mail.pm.org
http://mail.pm.org/mailman/listinfo/boston-pm


Re: [Boston.pm] C++ books

2013-04-17 Thread Greg London
 You can write macros that have varargs,

Dumb hardware engineer question:

Why use macros when you can write a function?



___
Boston-pm mailing list
Boston-pm@mail.pm.org
http://mail.pm.org/mailman/listinfo/boston-pm


Re: [Boston.pm] C++ books

2013-04-17 Thread Greg London

 On Wed, Apr 17, 2013 at 09:29:34AM -0500, Greg London wrote:
  You can write macros that have varargs,
 Dumb hardware engineer question:
 Why use macros when you can write a function?

 In this very simple case it makes no significant difference.

When WOULD it make a difference?

The only thing I can think of is you don't have to make a call
to a subroutine. But all that saves you is dealing with the stack.

My tests are mostly generating stimulus for the dut.
The OK function is probably 0.001% of my processor time.
Even if I use a macro and make my OK function run ten
times faster, its only 0.0001% of my processor time.

Greg



___
Boston-pm mailing list
Boston-pm@mail.pm.org
http://mail.pm.org/mailman/listinfo/boston-pm


Re: [Boston.pm] Test code generation (was C++ books)

2013-04-16 Thread Greg London
 Instead, I generate the test file from a simpler data file that only
 contains the relevant test data.

When I was verifying a hardware-based image converter,
I used that approach. You gave it an image file,
a small file that contained some register settings
that indicated what we wanted the hardware to do.

This went into a golden model and the dut, and a simple
diff at the end gave a pass/fail.

But the environment I'm working on now has
many hundreds of registers. And it's not simply a matter
of selecting the mode for the dut. There are a lot of
sequential operations that need to be done that isn't
simply a matter of data-based testing.

If a fault-bit is set, I need to change the condition
so that the cause of the fault goes away. Then I check
the bit to make sure it's still set because its sticky.
Then I clear the fault, and read it to make sure that
it finally got clear.

I was working on one project where the project manager
suggested data-based testing. We looked at the DUT, and
I said we need an if statement. I looked some more,
and it was clear we needed a looping statement. And
the looping statement needed variables. And rather than
re-inventing a computer language, we dropped the data
approach, and wrote the tests with an existing language.

Greg






___
Boston-pm mailing list
Boston-pm@mail.pm.org
http://mail.pm.org/mailman/listinfo/boston-pm


Re: [Boston.pm] C++ books

2013-04-15 Thread Greg London
 _However_, using C++ is the worst way to write typical business
 application programs -- at least at this point in time.
 There are now two good reasons to use C++; one is to write
 highly optimized code which uses pointer manipulations, ...
 the other is to write for a platform which _only_ supports C++

I'm in the second boat. We do hardware design.
The hardware is designed in verilog and verilog-ams.
These two languages describe the digital and analog
pieces of the chip respectively.

To simulate this stuff, you use basically one of two
possible tools: one by cadence, the other by synopsys.
And if you're heavy in the Verilog-AMS, then you can
really only use cadence.

Up until recently, all verification was written in verilog.
Verilog is an OK language for digital design but a lousy
language for verification. It doesn't support anything
resembling a pointer or reference. Everything is passed
by value. There is nothing in verilog that is intrinsically
an object oriented language. Verilog essentially looks like
basic C, with some of the capabilities (like pointers)
chopped out.

A few years ago, the problems with verilog as a verification
language became a problem in delivering designs on time.
When chips were small, a small, simple testbench was OK.
As chips grew, the problems with a dumb language slowed
things down.

System-Verilog was invented as a language addition which
is intended for simulation/verification, not for the
hardware design. It has object-oriented concepts, you can
create instances of classes. It has pointers. System verilog
is more akin to a specialized flavor of C++ or something like
that.

But this is also not without its problems.

Relatively recently, simulators started putting hooks
in place so that you could pull in code in from another
language and use that instead. This is done through an interface
called DPI. Currently, the two main simulator companies
support DPI for C only. When you cross the boundary
from verilog/system verilog to DPI the language you can
jump into is C.

After you get into C, you can expand into c++.
The interface files the cross the boundary have to be C,
but this can tie into C++ if you want.

So, I've been doing verilog testbenches for years,
system verilog test benches for years, and they all
have their limtations as not being what I would call
a real language. So, I'm trying to write a testbench
in C++, interface it with C, use that to jump the DPI
barrier to verilog, and tie into the hardware simulation.

So, I'm limited to c/c++ because we're tied to hardware
simulators which can only run hardware languages such
as verilog/vhdl and can only interface to one software
language, namely c, which can then tie into c++.

That is, at the moment, my only option for any testbench
that isn't written in verilog or vhdl. The simulator
limits me to c and c++.

Greg



___
Boston-pm mailing list
Boston-pm@mail.pm.org
http://mail.pm.org/mailman/listinfo/boston-pm


Re: [Boston.pm] C++ books

2013-04-15 Thread Greg London
 I get a test file with a lot of code that looks like this:

   printf(
 %s %d: Some useful description and maybe a number %d\n,
 (expected_value == test_value) ? ok : not ok, ++tests,
 some_useful_debugging_info
   );

 I find it manageable, but I'm wondering about the next guy.

I've coded up a library of c++ functions for my infrastructure:

void increment_error_count(){
   err_cnt++;
   if(err_cnt10){
  exit 1;
   }
}

void error(string desc){
   increment_error_count();
   cout  ERROR:   desc  endl;
}

void pass(string desc){
   increment_pass_count();
   cout  pass :   desc  endl;
}

void expected_actual(
   int expected;
   int actual;
   string desc
){
  cout  expected expected, actual=actualendl;
  if(expected==actual){
 pass(desc);
  }else{
 error(desc);
  }
}

Then in the test, your code:

   printf(
 %s %d: Some useful description and maybe a number %d\n,
 (expected_value == test_value) ? ok : not ok, ++tests,
 some_useful_debugging_info
   );


would look something like this:

 expected_actual(expected_value ,test_value, some useful description);

We have a number of actual_expected functions to handle diferent types and
range checking and what not. They all print out the actual and expected
values, so you don't have to do that formatting in the test call.
cause usually if there is a failure, the very next thing we need to  know
is the actual value we got versus the expected value we wanted.

The error logging will stop after some number of errors occurs, so you're
not wasting sim time.

Each test ends by doing an end-of-test-report which prints out pass count
and error count and prints out and overall-result string. the perl script
scrapes this value and puts it in a report.

We have hundreds and hundreds of tests. so the goal is to keep the
tests as absolutely short as possible.





___
Boston-pm mailing list
Boston-pm@mail.pm.org
http://mail.pm.org/mailman/listinfo/boston-pm


Re: [Boston.pm] C++ books

2013-04-12 Thread Greg London
 I missed the original question, but if OP (Greg?) can wait

At the perl meeting, I mentioned that I'm using a lot of c++
at work and groused that I haven't found a good
intro to c++ book.

So, I'm the guy to blame for this thread.

I would like a book that introduces c and c++ from the
point of view of showing the best practices first
and comp-sci theory gets put in the second edition
so I don't have to buy it.

For example, unless I'm missing something fundamental,
I don't see any reason to have parameters to a c++ function
ever be a pointer. If I need an in/out, I pass by reference.

The entire rest of the code treats it like whatever variable
type that is is, and all you do is put an ampersand in front
of the paramter in the function declaration.

The sigils in c++ also seem to have some inconsistencies
similar in flavor to the way perl has an array declared
with @array and indexes into the array with $array[]
but you can also have a scalar called $array.

For the life of me, I cannot wrap my head around the
line noise that is c++ declaring a function or variable
by putting all manner of line noise in the code.

There's also the various and many flavors of a sequence
of characters in c++. You could have an array of chars,
a pointer to an array of chars, a std::string, a sstream,
and I'll be DAMNED if c++ isn't designed so that not one of
them will work in every situation.

Most of my code is using std::string, but sometimes I need
to convert to c_str() and sometimes I need to use streams
and it just makes me want to gouge my eyes out.

So, really, if the way to move text around is with strings
then I'd like a book that starts out introducing strings
and then later on, when some stupid exception to the rule
comes up, it goes into char* or streams and explains the
difference at that point.

That was the sort of book I was looking for.
Probably doesn't exist because no one will agree on the
best way to pass strings around in c++.

But that's how the subject of c++ books came up.
Greg


___
Boston-pm mailing list
Boston-pm@mail.pm.org
http://mail.pm.org/mailman/listinfo/boston-pm


Re: [Boston.pm] Tech Meeting Tuesday Apr 9th, Embedded Perl with Federico, 7, MIT E51-376

2013-04-10 Thread Greg London
 Federico Lucifredi continues his quest to build a hardware-assisted
 automagic hard-drive wiper, using perl in an embedded device. *Shiny
 hardware! Demo! Code*!

Federico,

It was getting late, so I didn't want to throw in another
tangent for how to write your code. But I was thinking you
could replace your printline() function with a closure.

Instead of doing this over and over:

printline($var1,\$y,text,font,$size);

You could take $y and put it inside a lexical block
then make a printline closure that uses $y
(basically, it's a global tothe subroutine, but the
lexical block means no one outside the block can
see $y or muck with it.

Then you don't have to keep passing in \$y every call.

The second, minor bit, is to reorder your parameters
a bit so that the things that change the most are first,
and the things that are usually one value are last.
Then you can take advantage of default values.

The code might look something like this:

# using dummy stubs, cause  I don't remember how your code
# came up with these values
sub calculate_initial_value{return 4;}

sub offset_value{return 8;}

my $printline;

{ # lexical scope hides $y from everyone outside the scope.

my $y = calculate_initial_value();

$printline = sub{

my($text,$size,$font)=@_;
$size||=8;# default value
$font||=normal; # default value;

$y=$y+offset_value();

print text is '$text', size is '$size', font is '$font', y is '$y'\n;

};

} # end lexical scope

#Now call the closure, and you don't have ot pass in $y
#and you don't have to pass in default values

$printline-(hello);
$printline-(world, 6);
$printline-(Bye, 4, bold);






___
Boston-pm mailing list
Boston-pm@mail.pm.org
http://mail.pm.org/mailman/listinfo/boston-pm


Re: [Boston.pm] Tech Meeting Tuesday Apr 9th, Embedded Perl with Federico, 7, MIT E51-376

2013-04-10 Thread Greg London

 Greg London wrote:
 ...replace your printline() function with a closure.
 Instead of doing this over and over:
 printline($var1,\$y,text,font,$size);
 You could take $y and put it inside a lexical block...

 To me this looks like an example of where we suffer by not having OO
 truly baked into the language. It's a pretty natural fit for this
 problem, but not the first thing people shout out, because we tend to
 want to keep small scripts simple and procedural, and not bother with
 the overhead of OO.

Meh. I don't blame that on perl's lack of builtin OO.

I've pasted an OO version and the closure version of my script below.
They're nearly identical. they both take about the same amount of
lines of code. Perl's bolt-on version of classes can fix this
about as easily as perl's closure stuff can fix it.

The problem is I'm not thinking of this script as an OO script.
I suppose one could imagine a class call HD_Label and every
object is a specific label, but I'm not entirely convinced that
that would actually be an improvement.

Given how short the script is, I wasn't even really worried about
$y being passed in by reference every call to printline.
Federico pointed it out as something that annoyed him.
I solved that particular problem with minimal modification to the
rest of his code.

If this were a much larger script, I might suggest rearchitecthing
it from the ground up, converting it from procedural to object
oriented, but it was short enough that I shrugged it off.

What I was left with at the end of the evening was that wiping
a drive this way isn't really secure for data you care about.
It would seem that a drill press with a large bit to drill
a couple holes in the platter at different radii, and
then drill a hole right through the bearing so it can't spin
without grinding, would be the better solution.

So, the printline( \$y  thingy was more a minor afterthought in my mind.

Greg


Here is the OO version:


{

package printline;

sub calculate_initial_value{return 4;}

sub offset_value{return 8;}

sub new{
my $obj={
yval=calculate_initial_value(),
};

return bless($obj,'printline');
}

sub print{
my $obj=shift(@_);
my($text,$size,$font)=@_;
$size||=8;
$font||=normal; # default value;

$obj-{yval}+=offset_value();

print text is '$text', size is '$size', font is '$font', y is '.
($obj-{yval}). '\n;

};

}

my $pl = printline-new();

$pl-print(hello);
$pl-print(world, 6);
$pl-print(world, 4, bold);




Here is the closure version:



sub calculate_initial_value{return 4;}

sub offset_value{return 8;}

my $printline;

{

my $y = calculate_initial_value();

$printline = sub{

my($text,$size,$font)=@_;
$size||=8;
$font||=normal; # default value;

$y=$y+offset_value();

print text is '$text', size is '$size', font is '$font', y is '$y'\n;

};

}

$printline-(hello);
$printline-(world, 6);
$printline-(world, 4, bold);









___
Boston-pm mailing list
Boston-pm@mail.pm.org
http://mail.pm.org/mailman/listinfo/boston-pm


Re: [Boston.pm] Tech Meeting Tuesday Apr 9th, Embedded Perl with Federico, 7, MIT E51-376

2013-04-10 Thread Greg London

 But that's my point. The default, especially with a short script,
 becomes procedural.

Well, I assume it varies from person to person,
and the reason my default is procedural is because
I've got about two decades of procedural programming
under my belt, and only 5 or 10 of the last years
has some smattering of OO laid over it.

It's what I'm familiar with.

I assume kids these days growing up on a plethora
of object oriented languages will have more tendancy
to come up with OO solutions. Because they're familiar
with it.

One could probably argue that my choice of perl may
be unduly influenced more by the fact that I know
perl and less by whether or not perl itself is actually
the best language for the problem I'm looking to solve.

My default, for almost anything that doesn't
have a specific language requirement is to use perl.



___
Boston-pm mailing list
Boston-pm@mail.pm.org
http://mail.pm.org/mailman/listinfo/boston-pm


Re: [Boston.pm] Tech Meeting Tuesday Apr 9th, Embedded Perl with Federico, 7, MIT E51-376

2013-04-10 Thread Greg London
 I do not agree with this assertion.  I've seen closure based solutions
 and OO versions both scale, and both fail.  They are appropriate for
 different problems, and different designs.  But as long as you know
 what they are (and aren't) good at, you can choose either.

I'd agree. I've done quite a few closure constructors like this myself:

sub constructor {
  my($name,$count)=@_;
  my $closure=sub{
 $count++;
 print incremented $name to $count\n;
  };
  return $closure;
}

This sort of thing returns a variable that acts like an object
as far as I'm concerned. And it has zero linguistic overhead.

To do that in a class, you have to have a lexical container
or put it in a separate file. declare the package. create a
constructor subroutine, bless it, and create a incrementor
method/subroutine.

{
 package increment;
 sub new{ return bless({Name=shift(@_),count=shift(@_)}), 'increment'); }
 sub inc{ my $obj=shift(@_); $obj-{count}++;
print incremented .($obj-{Name}). to .($obj-{count}.\n;
 }
}

that's kinda clunky. It's a lot of line noise.

If perl had more high minded classes, Im not sure how it would look.

{
 package increment;
 use Moose;
 has $name;
 has $count;
 sub inc{
  # I don't use moose, making htis up:
  $self=shift(@_);
  $self-count() = $self-count() + 1;
  print incremented .($self-name()). to .($self-count()).\n;
 }
}

I gotta say, the Moose.pm documentation started in second gear
and stripped my clutch.



___
Boston-pm mailing list
Boston-pm@mail.pm.org
http://mail.pm.org/mailman/listinfo/boston-pm


Re: [Boston.pm] Tech Meeting: Embedded Perl with Federico

2013-04-10 Thread Greg London
I have no idea what the signaling looks like on that 4wire connector between 
the platters and controller electronics, but it would seem to me that the right 
bit of hardware hooked directly to those 4 wires would be the best way to wipe 
a drive. If you drive random data onto the data wire and slowly work the head 
from the inside to the outside track, you would wipe out formatting data, 
hidden sectors, sectors marked as bad, etc.

I imagine this would be a standalone board the doesnt even have a concept of 
bios talking through an os. Just drive signals onto the wires and sweep the 
platters.


Connected by DROID on Verizon Wireless

-Original message-
From: Bill Ricker bill.n1...@gmail.com
To: Boston PM Boston-pm@mail.pm.org
Sent: 2013 Apr, Thu, 11 00:28:50 GMT+00:00
Subject: Re: [Boston.pm] Tech Meeting: Embedded Perl with Federico

Notes on Disk technology history, erasure, and those half-mile 3D laser
scanners.

Half mile 3d laser scanner
http://www.theverge.com/2013/4/9/4204582/new-3d-laser-scanner-can-capture-objects-over-half-a-mile-away
 *Security Now* 384 | TWiT.TV
http://twit.tv/show/security-now/384►►http://twit.tv/show/security-now/384


twit.tv › Shows http://twit.tv/shows › Security
Nowhttp://twit.tv/show/security-now


Dec 27, 2012

Take a trip back to 1990 with *Steve* as he details a familiar topic: Hard
drive failure. *...* 1365616800*Security* *...*

** **

The old RLL encodings (still used in BluRay) that gave its name to
generations of disks and controllers
http://en.wikipedia.org/wiki/Run_length_limited

(MFM was an early primitive form of RLL; all family
http://en.wikipedia.org/wiki/Hard_disk_drive_interface )

** **

http://en.wikipedia.org/wiki/Disk_formatting#Disk_reinitialization
Traditionally,
the physical sectors were initialized with a filler value of 0xF6 as per
the INT 1Eh's Disk Parameter
Tablehttp://en.wikipedia.org/w/index.php?title=Disk_Parameter_Tableaction=editredlink=1
(DPT)
during format on IBM compatible machines. … . Some modern formatters wipe
hard disks with a value of 0x00 instead, sometimes also called *zero-filling
*, whereas a value of 0xFF is used on flash disks to reduce
wearhttp://en.wikipedia.org/wiki/Program-erase_cycle
.

** **

http://en.wikipedia.org/wiki/*Gutmann_method*http://en.wikipedia.org/wiki/Gutmann_method
* *Most of the patterns in the Gutmann method were designed for older
MFMhttp://en.wikipedia.org/wiki/Modified_Frequency_Modulation
/RLL http://en.wikipedia.org/wiki/Run_Length_Limited encoded disks.
Relatively modern drives no longer use these older encoding techniques,
making many of the patterns specified by Gutmann
superfluoushttp://en.wiktionary.org/wiki/superfluous
.[1] http://en.wikipedia.org/wiki/Gutmann_method#cite_note-Gutman-1 Moreover,
since about 2001, ATA IDE http://en.wikipedia.org/wiki/Parallel_ATA and
SATA http://en.wikipedia.org/wiki/SATA hard drive manufacturer designs
include support for the “Secure Erase”
standardhttp://cmrr.ucsd.edu/people/Hughes/SecureErase.shtml,
obviating the need to apply the Gutmann method when erasing an entire drive.
[2] http://en.wikipedia.org/wiki/Gutmann_method#cite_note-2

** **

NBER response 2003-2013 update
http://www.nber.org/sys-admin/overwritten-data-gutmann.html


On Wed, Apr 10, 2013 at 4:05 PM, Tom Metro tmetro+boston...@gmail.comwrote:

  Federico Lucifredi continues his quest to build a hardware-assisted
  automagic hard-drive wiper, using perl in an embedded device.

 Federico,

 You showed some slides explaining why drive erasure is important, and
 also mentioned that this task isn't a job responsibility, but you never
 quite explained your motivation for expending all the effort you've put
 into this project. Just a fun problem?


 Was that a dual-CPU motherboard you were using? I gather it was just a
 handy bit of hardware to repurpose.


 Regarding the problems you had hot swapping:

 http://www.tuxradar.com/answers/570

   ...dependent on the hardware in two areas. The drive caddy system you
   use must be hot-swappable; most are... Secondly, your SATA controller
   must handle hot-swapping. It must be able to recognise when a drive
   has been disconnected or connected and communicate this information.
   Provided that happens, the OS should handle hot-swapped SATA drives
   much the same as it does USB or FireWire drives.

 More accurately, if the Linux kernel ATA driver supports the hot
 swapping functionality in your controller chip, then it'll work. The
 next step is to find your controller chip and look up whether the driver
 supports hot swapping with it.

 In older machines I've been using Silicon Image SIL-3114 based cards.
 That's a fairly old chip that doesn't support port multipliers, but does
 support hot swapping. The last card I bought with this chip was:
 http://www.amazon.com/Vantec-6-Port-SATA-Host-Card/dp/B002PX9BX2/

 As I mentioned, using a 2-slot drive dock may also be adding a layer of
 complication, as 

Re: [Boston.pm] Tech Meeting Tuesday Apr 9th, Embedded Perl with Federico, 7, MIT E51-376

2013-04-09 Thread Greg London

Checked my calendar.
I'll be there.

Greg

 Have a speaker, one RSVP, and me so far. Who else is coming?


 On Sun, Apr 7, 2013 at 5:13 PM, Bill Ricker bill.n1...@gmail.com wrote:

 *Tuesday, April 9, 2013, MIT E51-376 7pm-10pm*
 Embedded Perl with Federico

 Federico Lucifredi continues his quest to build a hardware-assisted
 automagic hard-drive wiper, using perl in an embedded device. *Shiny
 hardware! Demo! Code*!

 Location MIT E51-376
 (MITDirectionshttp://boston.pm.org/kwiki/index.cgi?MITDirections)


 Talk begins at 7:30. Refreshments in the hallway prior.

 *note* back in room E51-37*6* this term.
 --

  please RSVP for refreshments.
 
  Our WIKI http://boston.pm.org/kwiki/
 
* Tech Meetings are held on the 2nd Tuesday of every month at MIT
  (directions http://boston.pm.org/kwiki/index.cgi?MITDirections ).
o NOTE - Sometimes the lot has filled early, overflow is to
  Hayward lots (avoid MEDICAL RESERVED spaces!). See alternatives
  http://boston.pm.org/kwiki/index.cgi?MITDirections
  RSVP for count encouraged but not required, to
 bill.n1...@gmail.commebill.n1...@gmail.com
  or Boston-PM list, by 3pm Tuesday.




 --
 Bill
 @n1vux bill.n1...@gmail.com

 ___
 Boston-pm mailing list
 Boston-pm@mail.pm.org
 http://mail.pm.org/mailman/listinfo/boston-pm



-- 



___
Boston-pm mailing list
Boston-pm@mail.pm.org
http://mail.pm.org/mailman/listinfo/boston-pm


Re: [Boston.pm] Perl and recursion

2013-04-05 Thread Greg London

 function calls are relatively expensive.
 Certainly more so than iteration or array operations.

Maybe we could get a new pragma:

no overhead 'subs';

;/

I've been fighting a perl script problem for a while now
and just recently figured out a potential solution
that just happens to involve a whole lot of subroutine
calls, including potential recursion.






___
Boston-pm mailing list
Boston-pm@mail.pm.org
http://mail.pm.org/mailman/listinfo/boston-pm


[Boston.pm] symbol table stuff?

2013-03-09 Thread Greg London
(1) given a string containing the name of a scalar,
how would I tell if that variable already exists in the symbol table?

i.e. given MyPackage::Varname, how would I tell if
$MyPackage::Varname was already declared?
and if it is an array reference?


(2) given a reference to an array, would it be possible to
convert that reference back into a package name?

i.e. how would I get this code:

package MyOtherPackage;
our $FancyArrayRef= [ 1,2,3 ];

my $arrref=$FancyArrayRef;

my $name = magicsubroutinehere($arrref);

to end up with $name equal to MyOtherPackage::FancyArrayRef?






___
Boston-pm mailing list
Boston-pm@mail.pm.org
http://mail.pm.org/mailman/listinfo/boston-pm


[Boston.pm] perl constants

2013-03-05 Thread Greg London

OK, I've been coding since 5am, so I assume I'm just tired,
but I can't figure this out.

I have a bunch of perl constants that I put in a module.
I'm trying to use that module in two different places.
I'm getting an error:

Bareword CONSTANTNAME not allowed while strict subs in use


Here's a simplified testcase.


FILENAME: constant1.pm

sub NUM_MUSKETEERS() {3}

1;


FILENAME: mod1.pm


package mod1;

use warnings;
use strict;

use constant1;

foreach my $i (1..NUM_MUSKETEERS){
print mod1: $i\n;
}

1;


FILENAME: mod2.pm


package mod2;

use warnings;
use strict;

use constant1;

foreach my $i (1..NUM_MUSKETEERS){
print mod2: $i\n;
}

1;



FILENAME: script.pl
-

#!/usr/bin/perl

use warnings;
use strict;
use mod1;
use mod2;






___
Boston-pm mailing list
Boston-pm@mail.pm.org
http://mail.pm.org/mailman/listinfo/boston-pm


Re: [Boston.pm] perl constants

2013-03-05 Thread Greg London

 the one thing that
 seems a bit odd is that Greg's example didn't have separate packages for
 the separate files

yeah, I did something like this a long time ago, and can't
remember how I did it exactly.

Basically, I pulled the file in like a #include
so no enclosing package because I wanted the constants
to be #included directly into the package that was doing
the #include.

It's vaguely coming back to me that use just reads the
file once, and after the first use perl just calls
the import function. So, whatever I did way back when,
I didn't use the use directive.

I might have slurped the file and evaled it or something.
Probably going to programmer hell for that.

Anyway, I can't remember what I did, so I put a package around
it and use the Exporter module to export the constants.

Is there a way to tell Exporter to export all the subs
in the package? I'm not very familiar with Exporter,
but reading the docs, it is kind of funny that its an
export module that discourages people from exporting.

If exporting is really, really bad, then the module shouldn't
exist at all. If the module exists, then let me export
everything if I really want to.

A file full of constants is only useful if they're exported.

Greg


 On Tue, 2013-03-05 at 08:12 -0500, Jordan Adler wrote:
 Using the constant pragma is best.  Perldoc constant.

 the constant pragma (or Readonly) does express intent better than
 prototyped subroutines named with uppercase letters that return constant
 values. That doesn't apply to the problem here.

 The issue here seems to be how to have a module full of constants that
 can be used in a (or more likely many different) modules, and the
 constant pragma doesn't implement that part of the solution.
 Mike's suggestion about exporting makes sense, but the one thing that
 seems a bit odd is that Greg's example didn't have separate packages for
 the separate files. Exporting is from one package to another, and a
 separate file doesn't create an implicit package. (it could be the
 packages were stripped in the simplified example posted but were in
 Greg's original code.)


 ___
 Boston-pm mailing list
 Boston-pm@mail.pm.org
 http://mail.pm.org/mailman/listinfo/boston-pm



-- 



___
Boston-pm mailing list
Boston-pm@mail.pm.org
http://mail.pm.org/mailman/listinfo/boston-pm


[Boston.pm] Data::Dumper formatted for linked lists?

2013-02-08 Thread Greg London


Is there a module out there for dumping linked lists in a legible manner?

I like that Data::Dumper gives you an output that can be evaled back in,
but when you give it a linked list, it gives you an output that's totally
unreadable.





___
Boston-pm mailing list
Boston-pm@mail.pm.org
http://mail.pm.org/mailman/listinfo/boston-pm


Re: [Boston.pm] Data::Dumper formatted for linked lists?

2013-02-08 Thread Greg London
 I'm not sure how it can be done generically

Well, this is what I have for dumping a linked list where
the element is an array. [0] is payload. [1] is next. [2] is prev:


sub DumpLLArray{
my($element, $next,$prev)=@_;

$next=1 unless(defined($next));
$prev=2 unless(defined($prev));

use Data::Dumper;
use Storable 'dclone';

while($element){
print element is $element :\n;

my @copy;

# make a deep copy of everything but next/prev
for(my $i=0; $iscalar(@$element); $i++){
my $deepcopy;
if(($i == $next) or ($i == $prev)){
if(defined($element-[$i])){
$deepcopy=($element-[$i]).'';
} else {
$deepcopy='undef';
}
} else {
my $dclone=dclone ([$element-[$i]]);
$deepcopy=$dclone-[0];
}

push(@copy,$deepcopy);

}

# print out this element
print Dumper \@copy;

print \n;
$element=$element-[$next];
}

}



The idea is for every element in the list, make a deep copy of
the element except for next/prev. Then you can call Dumper on
the copy of that element.

I think the above code is fairly generic that it should print
out a linked list regardless of what the actual payload is.

One could make a similar version for hashes.

As long as nothing in an element references any other element
it should be OK.   If an element might point to another element,
then you'd probably have to replace dclone with something that
will dclone everything BUT another element.

Should be able to detect an element by calling ref() on everything
as you manually dclone the data down. If ref() is the same as ref()
of the original element, then snip it and replace it with a stringification.

Greg


Greg




 I'm not sure how it can be done generically because there is no generic
 linked list structure in perl, right?  There is an array, though, so
 convert to an array and then use data dumper.  if the array is in the
 reverse order, Data::Dumper will indicate it's already printed the next
 portion and it'll look pretty.

 $ perl -lwe 'sub lldumper {
   my ($node) = @_;
   my @list;
   while ($node) {
 die q(usage: lldumper($hashref) where $hashref-next is another hash
 ref) unless ref $node eq HASH;
 unshift @list,$node;
 $node = $node-{next};
   }
   return Dumper (@list);
 }
 use Data::Dumper;
 print lldumper({1=2,next={a=b}});'
 $VAR1 = {
   'a' = 'b'
 };
 $VAR2 = {
   'next' = $VAR1,
   '1' = 2
 };

 Duane

 On Feb 8, 2013, at 10:48 AM, Greg London em...@greglondon.com wrote:



 Is there a module out there for dumping linked lists in a legible
 manner?

 I like that Data::Dumper gives you an output that can be evaled back
 in,
 but when you give it a linked list, it gives you an output that's
 totally
 unreadable.





 ___
 Boston-pm mailing list
 Boston-pm@mail.pm.org
 http://mail.pm.org/mailman/listinfo/boston-pm


 Duane Bronson
 nerdmach...@gmail.com
 http://www.nerdlogic.com/
 5 Goden St.
 Belmont, MA 02478
 617.515.2909


 ___
 Boston-pm mailing list
 Boston-pm@mail.pm.org
 http://mail.pm.org/mailman/listinfo/boston-pm



-- 



___
Boston-pm mailing list
Boston-pm@mail.pm.org
http://mail.pm.org/mailman/listinfo/boston-pm


[Boston.pm] caller returns a less than useful line number

2013-02-05 Thread Greg London
Well, this is somewhat disappointing:

Put this in a file called test.pl

sub mysub{
my @callinfo=caller(0);
my $linenum=$callinfo[2];
print linenum is '$linenum'\n;
}


our @array=(
mysub('a'),
mysub('b')
);


Then run it and you get something like this:

perl test.pl
linenum is '10'
linenum is '10'


If you change it to
our @array=(
mysub('a', __LINENUM__ ),
mysub('b', __LINENUM__ )
);

You get 11 and 12 passed into the mysub routine.

Which would be OK I suppose, except perl doesn't have text macros
that I know of.

argh

Greg



___
Boston-pm mailing list
Boston-pm@mail.pm.org
http://mail.pm.org/mailman/listinfo/boston-pm


[Boston.pm] CPAN.pm module? h2xs replacement?

2013-01-17 Thread Greg London
So, is the CPAN.pm module still the recommended way to install perl modules?

What is the recommended way for creating modules to upload to CPAN?
Used to be h2xs a long time ago.

I'm a bit out of date.

Greg



___
Boston-pm mailing list
Boston-pm@mail.pm.org
http://mail.pm.org/mailman/listinfo/boston-pm


[Boston.pm] off-topic: schematic/pcb software

2012-03-13 Thread Greg London

Apologies for the off topic post.

Actually, one thing that is indirectly perl related. Did any of you happen
to be one of the lucky ones to get your hands on a
raspberry pi?

http://uk.rs-online.com/web/generalDisplay.html?id=raspberrypi

It's a linux machine the size of a credit card, costs $40 american,
and it runs perl. It also sold out within minutes of going on sale.



Secondly, does anyone have any hands-on direct experience with some free
(free as in beer or low cost) schematic/PCB software that is good enough
that they'd recommend? I have a small schematic I'd like to enter and turn
into a PCB. I've downloaded three different software packages and they all
are disappointing. It would be nice if the schematic and PCB was linked so
the traces on the pcb are more likely to match the schematic.

Thanks,
Greg


-- 



___
Boston-pm mailing list
Boston-pm@mail.pm.org
http://mail.pm.org/mailman/listinfo/boston-pm


Re: [Boston.pm] Perl Suppresion

2011-12-10 Thread Greg London
I had an interview with Apple for a hardware design job a year or so ago.   
They said they explicitly forbid the use of perl for any of their glue  
function scripting needs. they said they use java.


I think I was unable to entirely suppress how much I thought this was a  
stupid idea in the middle of the interview. I wasnt offered a job, but I  
dont think I wouod have been happy if I had taken a job there with such a  
dogmatic approach to that.


I do hope that perl 6 might make a better name for itself in terms of how  
much of the code is line noise. but the interviewer said one of the reasons  
that they didnt allow perl was because it wasnt strongly typed.


I mentioned during the interview I had 5 or so years doing Ada and VHDL for  
avionics projects, and that strongly typed is probably a good idea when  
peoples lives depend on solid code. but that when youre trying to write a  
glue script to take log files from a regression and generate a report, you  
dont want to spend your time converting strings to integers and integers to  
floats and so on.


i spent some time teaching myaelf Java after that interview just so i could  
at least answer 'what does this snippet of code do?' interview questions.


I have to say I was not impressed with Java. 
Connected by DROID on Verizon Wireless


-Original message-
From: Uri Guttman u...@stemsystems.com
To: boston-pm@mail.pm.org
Sent: Sat, Dec 10, 2011 00:20:47 GMT+00:00
Subject: Re: [Boston.pm] Perl Suppresion

On 12/09/2011 06:38 PM, John Tsangaris wrote:

I am sure this has been hashed and rehashed, but is the corporate world
suppressing Perl? I realize people pick and choose the languages they
support and list on their websites, but I was looking up the youtube api
and see on code.google.com that they have dev guides for Java, .NET,
PHP, and Python with client libraries for those as well as Objective-C
and Javascript. This being only one example, I see a systemic omission
of Perl from anything popular. Is this accurate ? Why is Perl omitted :
I must be seeing things.


there is a Net::Google on cpan so google probably doesn't need to 
provide that. hard to find an api/protocol without a cpan module for it. 
one module says Interface to the Google AJAX Search API. so as long as 
google publishes the api, perl will be hacked for it. this also means 
the other lang communities are too dumb to write their own libs to 
published apis. :)


uri

___
Boston-pm mailing list
Boston-pm@mail.pm.org
http://mail.pm.org/mailman/listinfo/boston-pm


___
Boston-pm mailing list
Boston-pm@mail.pm.org
http://mail.pm.org/mailman/listinfo/boston-pm


Re: [Boston.pm] Fwd: [pm_groups] AI Challenge (Google) - Ants - Submission deadline Dec 18

2011-11-15 Thread Greg London
After spending a few hours working on this, it's clear that this is
something requiring far more than a few hours to do well.

I can get the ants to move around in what would be described as a drunken
stupor, but that's about it.

Oh well.

Good luck to anyone who entered the contest.




 -- Forwarded message --
 From: Jay Hannah j...@jays.net

 What a fun challenge! You can download the Perl starter package and post
 it
 and be ranked all within 15 minutes.  :)

 There have been 63 Perl submissions so far:
   http://aichallenge.org/language_profile.php?language=Perl

 But Perl doesn't hold the top 444 spots yet. Please forward to your groups
 to get more Perl people involved.  :)

 Thanks,

 Jay Hannah
 Omaha.pm




 --
 Request pm.org Technical Support via supp...@pm.org

 pm_groups mailing list
 pm_gro...@pm.org
 http://mail.pm.org/mailman/listinfo/pm_groups



 --
 Bill
 @n1vux bill.n1...@gmail.com

 ___
 Boston-pm mailing list
 Boston-pm@mail.pm.org
 http://mail.pm.org/mailman/listinfo/boston-pm



-- 



___
Boston-pm mailing list
Boston-pm@mail.pm.org
http://mail.pm.org/mailman/listinfo/boston-pm


[Boston.pm] geo::google?

2011-11-02 Thread Greg London


I'm trying to install Geo::Google  0.05 on my linux box at home.

I keep getting an install error in the tests

==

 sudo make test
cp lib/Geo/Google.pm blib/lib/Geo/Google.pm
Skip blib/lib/Geo/Google/Segment.pm (unchanged)
Skip blib/lib/Geo/Google/Path.pm (unchanged)
Skip blib/lib/Geo/Google/Location.pm (unchanged)
PERL_DL_NONLAZY=1 /usr/bin/perl -MExtUtils::Command::MM -e
test_harness(0, 'blib/lib', 'blib/arch') t/*.t
t/Geo-Google.t .. 1/72 Usage: JSON::XS::new(klass) at
/home/greg/Downloads/Geo-Google-0.05/blib/lib/Geo/Google.pm line 239.
# Looks like you planned 72 tests but ran 13.
# Looks like your test exited with 255 just after 13.
t/Geo-Google.t .. Dubious, test returned 255 (wstat 65280, 0xff00)
Failed 59/72 subtests

Test Summary Report
---
t/Geo-Google.t (Wstat: 65280 Tests: 13 Failed: 0)
  Non-zero exit status: 255
  Parse errors: Bad plan.  You planned 72 tests but ran 13.
Files=1, Tests=13,  0 wallclock secs ( 0.02 usr  0.00 sys +  0.06 cusr 
0.00 csys =  0.08 CPU)
Result: FAIL
Failed 1/1 test programs. 0/13 subtests failed.
make: *** [test_dynamic] Error 255




line 239 of Google.pm looks like this:

  my $json = new JSON (skipinvalid = 1, barekey = 1, quotapos = 1,
unmapping = 1 );

I installed JSON-XS-2.32, which went in without any errors of any kind.

I have no idea how to fix the call to new in Google.pm.

Anyone know what's wrong?



Or does anyone know of a perl module that can take a street address adn
give me lat/long to within 50 feet or something like that? (don't want it
to just give me a lat/long for the zip code. Need the actuall street
address.)


Greg






___
Boston-pm mailing list
Boston-pm@mail.pm.org
http://mail.pm.org/mailman/listinfo/boston-pm


Re: [Boston.pm] interested in damian training ?

2011-08-10 Thread Greg London

I am interested.
Dont know if my employer is, though.

-Original message-
From: Uri Guttman u...@stemsystems.com
To: boston-pm@mail.pm.org
Sent: Tue, Aug 9, 2011 22:36:13 GMT+00:00
Subject: [Boston.pm] interested in damian training?


hi all,

at oscon i spoke to the inimitable damian conway about bringing him back
to boston for his incredible perl training classes. we had great success
in the past but then the market for them just died with the economy back
then (it was still better than it is now!). but there has been a strong
surge in perl jobs recently and i feel it may be a good time to bring
damian back. if you or your perl shop would be interested in training by
damian, please let me know. i don't have the fees yet but they may be
in the $500-700 per student/day range. there will likely be discounts
for multiple days of training and possibly even some scholarships. the
potential dates would be in early october or if that doesn't work, next
july. if there is a large demand for them, a different date could be
scheduled. 


of course if damian come here for training, he will give a free talk to
boston.pm as he love to do that.

thanx,

uri

--
Uri Guttman  --  uri AT perlhunter DOT com  ---  http://www.perlhunter.com  
--
  Perl Developer Recruiting and Placement Services   
-
-  Perl Code Review, Architecture, Development, Training, Support  
---


___
Boston-pm mailing list
Boston-pm@mail.pm.org
http://mail.pm.org/mailman/listinfo/boston-pm


___
Boston-pm mailing list
Boston-pm@mail.pm.org
http://mail.pm.org/mailman/listinfo/boston-pm


Re: [Boston.pm] module introspection

2011-08-09 Thread Greg London
I vaguely recall doing something rudimentary that  did something kind of  
like this. I think I did something where every verb was a Verb::something.pm  
module. Then I just wrapped a use Verb::something; statement in an  
eval() statement, inside an eval{} block. Simple and dumb, but it worked  
good enough that people used the script.


it was a script for internal use only so there werent huge gaping security  
holes to the outside world. 


-Original message-
From: John Redford eire...@hotmail.com
To: 'L-boston-pm' boston-pm@mail.pm.org
Sent: Tue, Aug 9, 2011 14:18:51 GMT+00:00
Subject: Re: [Boston.pm] module introspection




-Original Message-
 From: Tom Metro
 Sent: Monday, August 08, 2011 12:48 PM
 Subject: [Boston.pm] module introspection

 I have a command line utility I am developing that I'd like to be
 extendable with additional verbs such that you can do:

 command verb ...args...

 And I'd like the utility to be able to support new verbs by merely
 having a module added to a designated directory. Thus I'd like my code
 to be able to use some form of introspection to extract the new verbs
 (designated methods) from the modules.


As is often the case, there are swings and roundabouts.

You could take the ksh FPATH approach of mapping one verb to one file --
with the advantage that you only have to load a single file and you know
which one to load based on the verb provided.  This also makes it efficient
to check internally or tell a user what verbs exist, as you just need to
enumerate the file names. If you want to display help information about
all the verbs at once you have to read all the files, but that's an unusual
case and not something to be optimized for (and if you wanted to, you could
simply cache the data in another file and check its content/timestamps
against the names  stamps of the verb files). In this case, you don't need
to introspect -- the loaded file is simply expected to contain the verb
you're looking for -- either by defining it as a named function, or by
putting a function into some existing hash of verb names.

Alternatively, you could require the program to load and evaluate every
verb-defining file, permitting files to define multiple verbs -- a mechanism
that mimics how modules export names would be conventional here. In general,
this would be a worse approach, as you're incurring the worst-case overhead
and loading verbs you aren't using. However, if your program operates as a
long-running, interactive shell, this might be reasonable.

Finally, you could combine the two with the optimization mentioned above --
create a single cache file that combines all the verbs (or perhaps just the
registration data for all the verbs) into a single file, which you load, and
which contains either the full verb definitions or enough information to
efficiently load them when needed.

The first approach is simple, generally efficient and self-evident in its
properties.  The second and third are much fancier, but seem excessively
complicated and subtle for the basic problem described.



___
Boston-pm mailing list
Boston-pm@mail.pm.org
http://mail.pm.org/mailman/listinfo/boston-pm


___
Boston-pm mailing list
Boston-pm@mail.pm.org
http://mail.pm.org/mailman/listinfo/boston-pm


Re: [Boston.pm] backticks tee'd to stdout ?

2011-07-21 Thread Greg London
Oh fer the luv of...

everything is doing what I want now,
*except* when a command has a nonzero exit code,
the script can't seem to see that.

Here's a little shell script called exit_one.csh

   echo EXIT_ONE
   exit 1

Here's the perl script (perl_pipe.pl) that runs it with an open pipe:

   my $pid = open(my $HANDLE2, exit_one.csh|) or die failed to open;

   while($HANDLE2){
print line is $_;
   }
   print \$\? is '$?'\n;
   print \$\@ is '$@'\n;


Running the perl_pipe.pl generates ths following:

   line is EXIT_ONE
   $? is '0'
   $@ is ''

If I open a pipe on a command that has a nonzero exit status,
where do I check that???

Greg



___
Boston-pm mailing list
Boston-pm@mail.pm.org
http://mail.pm.org/mailman/listinfo/boston-pm


Re: [Boston.pm] backticks tee'd to stdout ?

2011-07-21 Thread Greg London
hm. I assumed it did an implied close once the command was done executing.  
once i do an explicit close, $? gets the exit value.


thanks everyone who answered this thread.
Greg

-Original message-
From: Gyepi SAM gy...@praxis-sw.com
To: Greg London em...@greglondon.com
Cc: boston-pm@mail.pm.org
Sent: Thu, Jul 21, 2011 19:41:42 GMT+00:00
Subject: Re: [Boston.pm] backticks tee'd to stdout ?

On Thu, Jul 21, 2011 at 01:44:48PM -0500, Greg London wrote:

If I open a pipe on a command that has a nonzero exit status,
where do I check that???



close($HANDLE2);

after the read loop in order to get its correct exit status.
If you really want to be thorough, do

my $r = close($HANDLE2);

and look at $r to determine whether you even need to look at $?, etc.

man perlfunc#open for details and other useful bits.

-Gyepi


___
Boston-pm mailing list
Boston-pm@mail.pm.org
http://mail.pm.org/mailman/listinfo/boston-pm


Re: [Boston.pm] backticks tee'd to stdout ?

2011-07-19 Thread Greg London
Ah-ha.

I'm not entirely crazy, just extremely forgetful.
I knew I had done a script like this a couple years ago
and I knew it used backticks and I knew it had a timeout feature.

The part I forgot was it used Tk::ExecuteCommand to
manage the process. It also shows the output of the
simulation. and it provides the user with an interactive
way to kill the simulation in the middle.

This script seems to timeout properly and kill the underlying
process so as to not leave any zombies around:

#!/usr/bin/perl

use warnings;
use strict;

use Tk;
use Tk::ExecuteCommand;

my $oscmd=echo \hello\; sleep 3; echo \world\;;

my $top=new MainWindow;
my $ec = $top-ExecuteCommand()-grid(-row=1,-column=1);

$SIG{ALRM} = sub { $ec-kill_command; };
alarm(10);

$ec-configure(-command = $oscmd);
$ec-execute_command;
$ec-update;




I need to add gui support anyway, so I'll just tweak
my script to tee its output during backtick commands
and use Tk::ExecuteCommand to handle the OS command.
There's still the problem of buffering, but I'll deal
with that later.

And apparently I need to read up on pipes in case
this bites me again and I can't use a gui.

Greg




 Don't do that.

 In general, you're going to run into a whole mess of problems with the
 kind
 of thing you want to do, and your best is to control everything and avoid
 the shell. Pipe opens, as Uri suggested, are the way to go, unless you
 need
 bi-/tri-directional support in which case there are
 IPC::Open[23]/IPC::Run.

 But often you can get away, from perlipc:

On most Unix platforms, the CHLD (sometimes also known as CLD)
 sig-
nal has special behavior with respect to a value of 'IGNORE'.
 Setting
$SIG{CHLD} to 'IGNORE' on such a platform has the effect of not
 creat-
ing zombie processes when the parent process fails to wait() on
 its
child processes (i.e. child processes are automatically reaped).
 Call-
ing wait() with $SIG{CHLD} set to 'IGNORE' usually returns -1
 on
such platforms.



-- 



___
Boston-pm mailing list
Boston-pm@mail.pm.org
http://mail.pm.org/mailman/listinfo/boston-pm


Re: [Boston.pm] backticks tee'd to stdout ?

2011-07-19 Thread Greg London
So, if I were to use pipes, with a timeout, would it look something like
this?

#!/usr/bin/perl

use warnings;
use strict;

$SIG{ALRM} = sub { die timeout\n };

alarm(7);

my $pid = open(my $HANDLE,
 echo \A\; sleep 3;
.echo \B\; sleep 3;
.echo \C\; sleep 3;
.echo \D\; sleep 3;
.echo \E\; sleep 3;
.|) or die failed to open;

while($HANDLE){
print line is $_;
}


???

When I run this, it prints out A, then three seconds later, B,
then three seconds later C, then it prints timeout and dies.

I do a ps -ef and don't see any process hanging around.

So, I think this has all the functionality I need.
I can capture the text output and put it in a file
as well as print it out immediately for the user to see,
and then I can do a timeout and there aren't any processes
hanging aroudn that I see.

But since this is a very weird way of doing things for me,
I thought I'd check in before I rewrite the script and
discover I did it all wrong. Again.

Will this work cleanly and reliably?

Greg






 Ah-ha.

 I'm not entirely crazy, just extremely forgetful.
 I knew I had done a script like this a couple years ago
 and I knew it used backticks and I knew it had a timeout feature.

 The part I forgot was it used Tk::ExecuteCommand to
 manage the process. It also shows the output of the
 simulation. and it provides the user with an interactive
 way to kill the simulation in the middle.

 This script seems to timeout properly and kill the underlying
 process so as to not leave any zombies around:

 #!/usr/bin/perl

 use warnings;
 use strict;

 use Tk;
 use Tk::ExecuteCommand;

 my $oscmd=echo \hello\; sleep 3; echo \world\;;

 my $top=new MainWindow;
 my $ec = $top-ExecuteCommand()-grid(-row=1,-column=1);

 $SIG{ALRM} = sub { $ec-kill_command; };
 alarm(10);

 $ec-configure(-command = $oscmd);
 $ec-execute_command;
 $ec-update;




 I need to add gui support anyway, so I'll just tweak
 my script to tee its output during backtick commands
 and use Tk::ExecuteCommand to handle the OS command.
 There's still the problem of buffering, but I'll deal
 with that later.

 And apparently I need to read up on pipes in case
 this bites me again and I can't use a gui.

 Greg




 Don't do that.

 In general, you're going to run into a whole mess of problems with the
 kind
 of thing you want to do, and your best is to control everything and
 avoid
 the shell. Pipe opens, as Uri suggested, are the way to go, unless you
 need
 bi-/tri-directional support in which case there are
 IPC::Open[23]/IPC::Run.

 But often you can get away, from perlipc:

On most Unix platforms, the CHLD (sometimes also known as
 CLD)
 sig-
nal has special behavior with respect to a value of 'IGNORE'.
 Setting
$SIG{CHLD} to 'IGNORE' on such a platform has the effect of not
 creat-
ing zombie processes when the parent process fails to wait() on
 its
child processes (i.e. child processes are automatically reaped).
 Call-
ing wait() with $SIG{CHLD} set to 'IGNORE' usually returns -1
 on
such platforms.



 --





-- 



___
Boston-pm mailing list
Boston-pm@mail.pm.org
http://mail.pm.org/mailman/listinfo/boston-pm


[Boston.pm] backticks tee'd to stdout ?

2011-07-18 Thread Greg London
I have a script that uses backticks to run commands, capture the output and  
append it to a file. Someone requested that the script also output  
immediately to the screen. we are having troubles with some commands  
hanging, amd we want to know where the hang is. so if we could see the last  
output, we would know.


Is there an easy way to tweak backticks so it still captures the output but  
also tees the output to stdout?


also, the command that is hanging, I set an ALRM that has 'die' as its  
callback. but I end up with the backtick command.running as a zombie  
process. I have no idea why its doing that. but I dont think I have ever  
used ALRM either.



___
Boston-pm mailing list
Boston-pm@mail.pm.org
http://mail.pm.org/mailman/listinfo/boston-pm


Re: [Boston.pm] backticks tee'd to stdout ?

2011-07-18 Thread Greg London
I have been assuming that the 'correct' behavior of perl is that when perl  
calls die while it is running a command via bacticks that perl kills  
whatever was run by the backtick command.


is that a correct assumption?

-Original message-
From: Uri Guttman u...@stemsystems.com
To: Greg London em...@greglondon.com
Cc: Boston-pm@mail.pm.org
Sent: Mon, Jul 18, 2011 21:49:47 GMT+00:00
Subject: Re: [Boston.pm] backticks tee'd to stdout ?


GL == Greg London Greg writes:


 GL Is there an easy way to tweak backticks so it still captures the
 GL output but also tees the output to stdout?

you can pipe a command to tee and save it to a file and also to
stdout. the file could be /dev/tty which is the console

you can use open $cmd| and read the handle line by line. then print
each line to stdout and append it to a buffer for processing.

 GL also, the command that is hanging, I set an ALRM that has 'die' as its  

 GL callback. but I end up with the backtick command.running as a zombie  
 GL process. I have no idea why its doing that. but I dont think I have  
ever  
 GL used ALRM either.


possibly because your command has shell chars in it so first a shell is
spawned and it runs your program. you may be killing the shell but not
reaping its child. you can reap it with a SIGCHLD handler. or if you use
the pipe idea above you will get its pid from the open and be able to
kill the process directly if it times out.

uri

--
Uri Guttman  --  uri AT perlhunter DOT com  ---  http://www.perlhunter.com  
--
  Perl Developer Recruiting and Placement Services   
-
-  Perl Code Review, Architecture, Development, Training, Support  
---



___
Boston-pm mailing list
Boston-pm@mail.pm.org
http://mail.pm.org/mailman/listinfo/boston-pm


[Boston.pm] exit codes and $?

2011-07-12 Thread Greg London

I have a perl script which runs a bunch of unix commands via backticks.
After the backticks, the perl script checks $? to see if the command
actually worked.

It works fine for several dozen commands. The last command calls a
verilog simulator tool. According to perl, $? is 256 after calling
the simulator.

When I run the simulator command manually on the command line,
then tell bash to spit out $?, this is what I get

 echo $?
1

Why would perl munge 1 into 256?

Greg


___
Boston-pm mailing list
Boston-pm@mail.pm.org
http://mail.pm.org/mailman/listinfo/boston-pm


Re: [Boston.pm] exit codes and $ ?

2011-07-12 Thread Greg London
ah man, so perl decided to fiddle with the definition but keep the same  
name? that is so messing with my feng shui.


at least I can tell the simulator support guy that the problem isnt my  
script. 


thanks
Greg

-Original message-
From: Bob Rogers rogers-...@rgrjr.dyndns.org
To: Greg London em...@greglondon.com
Cc: boston...@pm.org
Sent: Tue, Jul 12, 2011 14:48:38 GMT+00:00
Subject: [Boston.pm] exit codes and $?

  From: Greg London em...@greglondon.com
  Date: Tue, 12 Jul 2011 09:43:23 -0500

  . . .

  Why would perl munge 1 into 256?

  Greg

Because it's designed that way:

  $CHILD_ERROR
  $?  The status returned by the last pipe close, backtick (``)
  command, successful call to wait() or waitpid(), or from the
  system() operator.  This is just the 16-bit status word
  returned by the traditional Unix wait() system call (or else  
is

  made up to look like it).  Thus, the exit value of the
  subprocess is really ($?  8), and $?  127 gives which
  signal, if any, the process died from, and $?  128 reports
  whether there was a core dump.  (Mnemonic: similar to sh and
  ksh.)

(From perlvar.)  Really, it's not un-munging the 256 back to 1.

-- Bob


___
Boston-pm mailing list
Boston-pm@mail.pm.org
http://mail.pm.org/mailman/listinfo/boston-pm


Re: [Boston.pm] exit codes and $ ?

2011-07-12 Thread Greg London
I guess the question for me as to which is 'authentic' would be answered by  
whoever defined $? first.


I dont know the history well enough to sort that one out though. So I'll  
just say that *someone* is harshing my mellow...


;)

Greg

-Original message-
From: mer...@stonehenge.com (Randal L. Schwartz)
To: Greg London em...@greglondon.com
Cc: Bob Rogers rogers-...@rgrjr.dyndns.org,   boston...@pm.org
Sent: Tue, Jul 12, 2011 15:12:07 GMT+00:00
Subject: Re: [Boston.pm] exit codes and $ ?


Greg == Greg London Greg writes:


Greg ah man, so perl decided to fiddle with the definition but keep the  
same  
Greg name? that is so messing with my feng shui.


Actually, the value returned by Perl is the more authentic value that
returns from wait(2), and also tells you whether core was dumped, and
the signal that killed it (if any).  The shell sweeps all that away, and
loses information.

If anything, yell at your shell for lying to you. :)

--
Randal L. Schwartz - Stonehenge Consulting Services, Inc. - +1 503 777 0095
mer...@stonehenge.com URL:http://www.stonehenge.com/merlyn/
Smalltalk/Perl/Unix consulting, Technical writing, Comedy, etc. etc.
See http://methodsandmessages.posterous.com/ for Smalltalk discussion


___
Boston-pm mailing list
Boston-pm@mail.pm.org
http://mail.pm.org/mailman/listinfo/boston-pm


Re: [Boston.pm] [Bob Rogers] Please confirm your message

2011-07-12 Thread Greg London
Anyone who wants can forge
email header, which can cause you to bounce your spam to anyone else
in the world.

 That is also not true, at least for me.  I have TMDA configured to
 generate challeges only for messages not flagged as spam by a Bayesian
 filter.  So only those spams that could get through a proper spam
 solution will generate blowback.

I don't know anything about TMDA, but reading your explanation
I gather the following:

(1) You filter your email through a regular spam filter.
(2) If it doesn't look like spam, but its not from an address
 that TMDA recognizes, TMDA will generate a challenge email.

The resulting conclusion includes what you said above,
as well as the following:

(A) You acknowlege that spam may get through your Bayesian spam filter
(B) You acknowlege that said spam from (A) will generate blowback.
(C) You give the appearance of realizing (A) and (B) are true,
(D) and you give the appearance of having made the decision that
 (i) sending some blowback spam to someone else is better than
 (ii) getting spam in your own inbox.

You solve your own problems by creating a potential new
problem for everyone else.

Assuming I understand what you've said about TMDA,
I can see why this software generates such strong and
visceral reactions in people.

Greg



___
Boston-pm mailing list
Boston-pm@mail.pm.org
http://mail.pm.org/mailman/listinfo/boston-pm


Re: [Boston.pm] underused perl feature

2011-06-01 Thread Greg London
Code written with the primary purpose of demonstrating the programmer's 
cleverness must put all other requirements as secondary.

--London's Law

-Original message-
From: Chris Devers cdev...@pobox.com
To: Uri Guttman u...@stemsystems.com
Cc: boston-pm@mail.pm.org
Sent: Tue, May 31, 2011 21:03:06 GMT+00:00
Subject: Re: [Boston.pm] underused perl feature

On Tue, May 31, 2011 at 4:44 PM, Uri Guttman u...@stemsystems.com wrote:
                assign = sub { my $x = 'abc' ; $x = qwerty/$x },
                substr = sub { my $x = 'abc' ; substr( $x, 0, 0, 'qwerty/') },

The substr version doesn't look very readable or maintainable.

You're teaching *beginners* to do things this way?

Really?



Again??



:-)


--
Chris Devers

___
Boston-pm mailing list
Boston-pm@mail.pm.org
http://mail.pm.org/mailman/listinfo/boston-pm

___
Boston-pm mailing list
Boston-pm@mail.pm.org
http://mail.pm.org/mailman/listinfo/boston-pm

[Boston.pm] not regular expression

2011-03-23 Thread Greg London
I'm dealing with a perl gui tool that has a regular expression search tool.
The tool takes whatever is in the gui window and then does a regularexpre
ssion search through a bunch fo fields.

THe thing is the text variable isn't within my control and the gui doesn't
let me select ~= or !~. It's always doing the functional equivalent of:

$somehiddenvariable ~= m/my regular expression/

Is there a way in a regular expression between m// to make it behave as if
it were

$somehiddenvariable !~ m/my regular expression/

Even though the code is doing ~=?

???

Greg


___
Boston-pm mailing list
Boston-pm@mail.pm.org
http://mail.pm.org/mailman/listinfo/boston-pm


Re: [Boston.pm] let's bring damian here

2011-03-06 Thread Greg London
I'd be willing to chip in some money.

Greg


 hi all,

 when damian conway has come to boston before he has given some amazing
 talks which bring out massive numbers of boston perl mongers. he has
 come here only when he had training gigs and that isn't likely to
 happen. but toronto did a cool thing at least once. they collected funds
 and paid for a talk by damian. he is usually open to such things if he
 can plan his schedule for a side visit. he usually gets an around the
 world plane ticket which gives him flexibilty in the states. i can't
 quote his expenses for a visit here but i would guess it is less than
 $1k total. i will ask both toronto.pm and damian what it would likely
 cost. anyhow, are people here interested in this? if a few perl using
 companies gave even $50 or $100 and we collected the rest, we could pull
 this off easily. ask at your place for a small donation or donate
 something yourself. at this point i want to just gauge overall interest
 and possible corporate help. i will get back with more info as i get it.

 thanx,

 uri

 --
 Uri Guttman  --  u...@stemsystems.com    http://www.sysarch.com
 --
 -  Perl Code Review , Architecture, Development, Training, Support
 --
 -  Gourmet Hot Cocoa Mix    http://bestfriendscocoa.com
 -

 ___
 Boston-pm mailing list
 Boston-pm@mail.pm.org
 http://mail.pm.org/mailman/listinfo/boston-pm



-- 



___
Boston-pm mailing list
Boston-pm@mail.pm.org
http://mail.pm.org/mailman/listinfo/boston-pm


Re: [Boston.pm] Q: giant-but-simple regex efficiency

2011-02-06 Thread Greg London
was checking out the documentation for parse::gnaw. I alread have a quoted  
alternation subroutine called qa. It takes a list of literals and creates an  
alternation of all of them.  I could simply change the code under the hood  
to be a tree search and then looking for a gigantic list of very similar  
words wouldnt cost any more than a short list.


I was one of the lucky few to buy the new Intel chip with the bug in the IO  
port. am waiting for the replacement desktop. Until then I dont have any way  
to work on Parse::Gnaw to add this feature.


But I will put it on my to-do list. the more I think about this the more I  
see a potential boost it woukd provide. especially for bio searches where  
someone is looking for one of several long but similar chains of dna.


Lastly, folks keep bringing up tokenizing. Parse::Gnaw and Parse::RecDescent  
both do not tokenize. Tokenizing is faster. but but not tokenizing gives  
your grammers more flexibility I think.


-Original message-
From: Charlie creit...@rcn.com
To: Ted Zlatanov t...@lifelogs.com
Cc: boston...@pm.org
Sent: Sun, Feb 6, 2011 16:49:56 GMT+00:00
Subject: Re: [Boston.pm] Q: giant-but-simple regex efficiency

Given how you frame the problem, then the hash lookup isn't even an option!   
No question, 6000+ string searches will be slow vs. a trie.   Given the  
varying requirements we all encounter, day-to-day, I think this is an  
interesting exercise.  Thanks for sharing these modules, Ted.


The OP indicated that the text can be tokenized:
KS Unfortunately, my names can be embedded in larger words of the input
KS text, as long as they are delimited by certain punctuation.

Greg L. pointed out some tools to assist with that.   I was just pointing  
out it is worth his while to make that work.   If input is line oriented, a  
real parser is unlikely to increase the cost by too much.   But it might  
be more complicated than a simple split() expression.


To get a comparison, I tried Regexp::Trie on my Moby Dick dictionary and  
text and it definitely gets the job done in a reasonable time: 22:30 (vs  
09:17 for split+hash).Good to know.


Despite it's better searching performance, Text::Match::FastAlternatives  
will not be usable, since it won't help you mangle the output.   For regex  
to actually work, you need to use it like so:  s/($rtr)/prefix_$1/g.


At 10:02 PM 2/5/2011 -0600, Ted Zlatanov wrote:

On Sat, 05 Feb 2011 18:27:13 -0500 Charlie creit...@rcn.com wrote:

C The sample program below runs in 00:09:04 on 1.15GB  (1024 copies of
C Moby Dick).   Replacing the hard-coded map with 2 entries with 6000
C words taken from the text (randomly selected, unique, 5 chars)  runs
C in 00:09:17.   I.e. the map lookup is trivial and has little impact on
C the overall performance.   A trie might do just a bit better than a
C hash table, but you are optimizing the wrong part of the program.

C my %keywords = ( Foo = 1, Bar = 2 );

C while (  )
C {
Cmy $line = '';
Cmy @tokens = split /\s/;
Cfor my $tkn ( @tokens )
C{
Cif ( '' ne $line ) {
C  $line .= ' ';
C}
Cif ( exists $keywords{$tkn} ) {
C  $line .= 'prefix_';
C}
C$line .= $tkn;
C}
Cprint $line, \n;
C }

You assumed that \s will delimit the tokens.  That's not the case (see
the original message, the interesting data can occur anywhere).  So you
can't tokenize and do a simple hash lookup.  If you benchmark 6000
index() calls vs. 2 index() calls you'll see why a trie makes sense.
You may benefit if you tokenize, which I mentioned in my message:

TZ If you know a boundary (e.g. newline or space or \b or \W) which
TZ always demarcates your strings, you can split your input on that and
TZ feed the pieces to Tree::Trie.

There is often a significant benefit to optimizing this kind of work in
C, as Text::Match::FastAlternatives does, because you may be able to
keep the code in the tight inner loop from busting the instruction
cache.  The performance benefits are huge.

I attach a benchmark of trie vs. fastmatch.  I commented out the index()
benchmark because it was ridiculously slow, on the order of 23 per
second on a fairly recent CPU.  Text::Match::FastAlternatives seems the
best choice, as advertised.

Ted

#!/usr/bin/perl

use warnings;
use strict;
use Data::Dumper;
use Benchmark qw/cmpthese/;
use Text::Match::FastAlternatives;
use Regexp::Trie;

my $text = 'abcd ' x 100;

my @words = 'a' .. 'hzz';

my $fast = Text::Match::FastAlternatives-new(@words);

my $rt = Regexp::Trie-new;
$rt-add($_) foreach @words;
my $rtr = $rt-regexp();
my $word_count = scalar @words;

cmpthese(500,
 {
  # $word_count keywords, index() = sub
  # {
  #  my $found;
  #  foreach (@words)
  #  {
  #   $found += index $text, $_, 0;
  #  }
  # },

  $word_count keywords, fastmatch = sub
  {
   return $fast-match($text)
  },

 

Re: [Boston.pm] Question on optimization/memory allocation

2011-02-04 Thread Greg London
If the question is which is faster, then one could pontificate endlessly  
about potential permutations of perl compiler patterns that may or may not  
come to pass.


Or.

One could download one of the myriad of benchmakrking modules and let  
objective data win over various perl myths.


Greg

-Original message-
From: Michael Small sma...@panix.com
To: Asa Martin asa.mar...@gmail.com
Cc: boston-pm@mail.pm.org
Sent: Fri, Feb 4, 2011 22:37:15 GMT+00:00
Subject: Re: [Boston.pm] Question on optimization/memory allocation

Asa Martin asa.mar...@gmail.com writes:
...

my ($line, @rules);

while ($line = FH) {
chomp $line;
@rules = split(\t, $line);

 do stuff with $rules[0], $rules[1], $rules[2] and $rules[3] ...

Here were my proposed changes:

while (my $line = FH) {
chomp $line;
my ($domain, $subdomain, $rule, $label) = split(\t, $line);

 do stuff with $domain, $subdomain, $rule and $label 

I was told that predeclaring the variables outside the loop saved on
memory allocation, and that using @rules instead of four named variables  

was
also more efficient. I had never considered that this could be the case,  

and

said I didn't think this was true, but didn't really know.


Theoretically, I could imagine your version being faster since you're
giving the compiler more information about the scope and lifetime of the
variables involved.  Perhaps perl could make better decisions about
register usage (I don't know perl internals).  I guess they're thinking
the variables are created anew each loop iteration (which is what, one
increment of a frame pointer or would that hit the heap, assuming it's
not optimized out completely?).

Someone should measure.

Your way is plainly better for readability and maintenance.

- Mike

___
Boston-pm mailing list
Boston-pm@mail.pm.org
http://mail.pm.org/mailman/listinfo/boston-pm


___
Boston-pm mailing list
Boston-pm@mail.pm.org
http://mail.pm.org/mailman/listinfo/boston-pm


Re: [Boston.pm] Q: giant-but-simple regex efficiency

2011-02-04 Thread Greg London
I wrote Parse::Gnaw to parse a file a little bit at a time using a real  
grammer.  I was dealing with multi gigabyte text files that represented a  
gate level version of an ASIC. 

As long as the text you are parsing can be defined in chunks and you can  
flush at the end of a chunk then Parse::Gnaw ought to parse your text. If  
you just want to capture some identifiers, it supports the equivalent of  
capturing parens.


as  for speed, its about three or four times faster than Parse::RecDescent.

Greg London

-Original message-
From: Kripa Sundar kripa.sun...@synopsys.com
To: boston-pm@mail.pm.org boston-pm@mail.pm.org
Sent: Sat, Feb 5, 2011 00:53:35 GMT+00:00
Subject: Re: [Boston.pm] Q: giant-but-simple regex efficiency

Thanks for the prompt replies, folks!

Unfortunately, my names can be embedded in larger words of the input
text, as long as they are delimited by certain punctuation.

If I can figure out all of the permitted punctuation, I will try out
a split() and a hash lookup.

But Regex::Trie seems more likely to help.  (I guess I was hoping that
the Perl regex compiler would automatically do that kind of optimal
regex construction, without the need for a module.)

peace,  || Finding gifts that do not harm:
--{kr.pA}   || http://www.dailygood.org/more.php?n=3159
--
It might look like I'm idle, but at the cellular level I'm really quite  
busy.


___
Boston-pm mailing list
Boston-pm@mail.pm.org
http://mail.pm.org/mailman/listinfo/boston-pm


___
Boston-pm mailing list
Boston-pm@mail.pm.org
http://mail.pm.org/mailman/listinfo/boston-pm


[Boston.pm] Csv in, beautiful chart out ?

2010-11-05 Thread Greg London

We have some statistics in the form of a text file.
We want a graph of those numbers in the form of some sort of image format  
like jpeg or png or whatever.


A coworker has been trying to get a perl module called Chart to do it, but  
has been running into difficulties. He came to me with questions but i don't  
know Chart. Then we got into a discusion of how we *should* be doing this,  
and i had to confess i've had to do this sort of thing many times before,  
but just didn't know what the 'go to' module would be.


Id even be happy if there was a command line interface to open office so i  
could write a command line script to load a comma separated file and spit  
out a graph as a png.


Recommendations?
Greg


___
Boston-pm mailing list
Boston-pm@mail.pm.org
http://mail.pm.org/mailman/listinfo/boston-pm


Re: [Boston.pm] $#{$Queue}

2010-09-28 Thread Greg London

Congrabulashuns. You just won the Evil programmer of the Year award.

;/

What's really sad is the number of people reading this and thinking 'oh. I'd  
like to win that' is a large positive number.


The award ceremony will be held behind the chemical shed. Programmer V will  
be handing out the awards.


-Original message-
From: David Cantrell da...@cantrell.org.uk
To: boston-pm@mail.pm.org
Sent: Tue, Sep 28, 2010 11:50:27 GMT+00:00
Subject: Re: [Boston.pm] $#{$Queue}

On Mon, Sep 27, 2010 at 11:15:17PM -0400, Uri Guttman wrote:


actually the = part is even more amusing. look here:
perl -le '$#foo = -2 ; print $#foo'
-1

you can't set the last index to  -1. which makes sense. which makes the
original code even dumber.


$ perl -le '$[=-1; print $#foo'
-2

--
David Cantrell | Nth greatest programmer in the world

___
Boston-pm mailing list
Boston-pm@mail.pm.org
http://mail.pm.org/mailman/listinfo/boston-pm


___
Boston-pm mailing list
Boston-pm@mail.pm.org
http://mail.pm.org/mailman/listinfo/boston-pm


[Boston.pm] $#{$Queue}

2010-09-27 Thread Greg London


what the heck?

my $Queue = \...@somearray;

if ($#{$Queue} = -1){
  # do something
}

I thought $# was size,
but the code is checking for it to be minus one?

-- 



___
Boston-pm mailing list
Boston-pm@mail.pm.org
http://mail.pm.org/mailman/listinfo/boston-pm


Re: [Boston.pm] $#{$Queue}

2010-09-27 Thread Greg London
Oh god. I'm digging through what might be on the order of.a hundred thousand 
lines of perl code on a system.  The file that snippet came from is over ten 
thousand lines long. My brain is about to implode.
 
Thanks.

-Original message-
From: Ben Tilly bti...@gmail.com
To: Greg London em...@greglondon.com
Cc: boston-pm@mail.pm.org
Sent: Tue, Sep 28, 2010 00:29:52 GMT+00:00
Subject: Re: [Boston.pm] $#{$Queue}

Check perlvar.  It is the index of the last array element, which is
one less than the size.

@$Queue will give you the size in scalar context.

On Mon, Sep 27, 2010 at 5:28 PM, Greg London em...@greglondon.com wrote:


 what the heck?

 my $Queue = \...@somearray;

 if ($#{$Queue} = -1){
  # do something
 }

 I thought $# was size,
 but the code is checking for it to be minus one?

 --



 ___
 Boston-pm mailing list
 Boston-pm@mail.pm.org
 http://mail.pm.org/mailman/listinfo/boston-pm


___
Boston-pm mailing list
Boston-pm@mail.pm.org
http://mail.pm.org/mailman/listinfo/boston-pm

Re: [Boston.pm] Languages to learn in addition to Perl

2010-07-20 Thread Greg London

 Have you heard of not taking it all so seriously?

Ah, my apologies. I never found insult comedy funny.
As far as I could tell, Andrew Dice Clay really was
a racist, a homophobe, and a mysoginist, and not just
kidding around about it.

But, some people found him hilarious.

As far as I could tell, you really meant all those things
you said. I did not realize that you were going for a
humorous approach and didn't really mean any of it.

My mistake.

 Do I really need to scatter grinning parentheses
 across every message

Once might be good. At least for those of us who are
tone deaf to insult comedy. That, or maybe you could
sign your message as John Diceman Redford.  Then at
least I'd get the reference.

Again, my apologies. Please carry on with your routine.
Just because I don't get it doesn't mean there aren't
others out there who found it hilarious.

Sorry,
Greg




___
Boston-pm mailing list
Boston-pm@mail.pm.org
http://mail.pm.org/mailman/listinfo/boston-pm


Re: [Boston.pm] my lang is better than your lang!

2010-07-20 Thread Greg London

  should you learn assembler? is there work in it (yes)? what would
  assembler teach you when using a high level lang?
 Absolutely! I thoroughly enjoyed learning assembler. Though I no longer
 program in it, I still look at the assembler my compilers generate.
 The only assembler code I write these days is for fun, on a Z80,
 although at some point I'm gonna learn ARM assembler too, Just Because.

My last job included doing a lot of ARM assembly coding.
Anything embedded has a pretty good chance of
having an ARM processor in it. So, there's work in it.

ARM has some neat architectural features.
It optimized some instructions in neat ways.

It also has a maddenly annoying feature from
being a RISC processor that to move data around
requires different instructions with different
syntax/formats depending on what your source and
destination is.

But it also has a fairly advanced macro language,
so I wrote an ARM macro that allows you to move
data around from anywhere to anywhere using one command
with the same syntax and same rules.

http://www.telosi.com/index.php?title=Tcopy_macro_arm_keil

The Keil assembler for ARM has a pretty neat macro language.




___
Boston-pm mailing list
Boston-pm@mail.pm.org
http://mail.pm.org/mailman/listinfo/boston-pm


[Boston.pm] multiline comment in perl?

2010-07-20 Thread Greg London
I'm using perl 5.6.1 at work.

I'm trying to use pod as a multiline comment.

This script:

(paste)

my @foods = (
'apple',
'banana',
'cherry',

# this is a multiline comment
=thingy
'potato',
'corn',
=cut
);

(end paste)

gives me an error:

 perl perlbug.pl
String found where operator expected at perlbug.pl line 13, near thingy
'potato'
(Do you need to predeclare thingy?)
syntax error at perlbug.pl line 12, near =
Execution of perlbug.pl aborted due to compilation errors.


If I move the =thingy outside of the array declaration, it's fine.

(paste)

my @foods = (
'apple',
'banana',
'cherry',

);

# this is a multiline comment
=thingy
'potato',
'corn',
=cut

(end paste)

Wassup wit dat?

Greg


___
Boston-pm mailing list
Boston-pm@mail.pm.org
http://mail.pm.org/mailman/listinfo/boston-pm


Re: [Boston.pm] multiline comment in perl?

2010-07-20 Thread Greg London

Gargleblarg!

 This is valid Perl:

 $foo
 =bar
 ;
 print $foo\n;

 You can't have POD in the middle of a statement.

 Ronald


Thanks for the answer though.
Thought I was losing my mind.


-- 



___
Boston-pm mailing list
Boston-pm@mail.pm.org
http://mail.pm.org/mailman/listinfo/boston-pm


Re: [Boston.pm] Languages to learn in addition to Perl

2010-07-19 Thread Greg London
John Redford first wrote:
 But JavaScript is a great scripting language if one wants ...
 no political baggage, no weirdly advocating user community,

John Redford then wrote:
 Just like Perl has CPAN, JavaScript has code you find on the Internet.
 It's not as catchy sounding, but it works the same and
 ***it's more egalitarian.***

 What's wrong with third-party code?  Why should JavaScript tell
 people the only way to do things.  JavaScript is simply allowing
 their user community to come up with solutions and use them.
 There is a lot of lively, active development and many clever ideas.
 ***Like Perl used to be.***

I don't know nothing about JavaScript.
But what you just wrote sounds like political baggage
and someone weirdly advocating for JavaScript.

I have found that programmers and engineers -sometimes-
are unable to see their subjective inclinations for a
language (or hardware system, or whatever), and think
their preference boils down to a purely objective set
of measures that *prove* it is a better language (or system,
or whatever).

I'm starting to come to the belief that listing the
merits and demerits of a programming langauge is about
as useful as writing a review for a restaurant.
A good review might cause some new people to go to the
restuaraunt. But for the most part, people eat where
they're used to eating, where they know the other
customers and the wait staff, where they can get
food they know, and at a place where they know all the
ins and outs needed to know to find cheap parking,
and not accidentally park someplace that will get them towed.

I don't particularly mind the conversation about javascript,
or other languages someone might want to learn. I've learned
a few things myself, so I can't complain.

But I like perl. I'm used to perl. I know what's on the menu.
I know where to park. I know a lot of the wait staff. And
I know a lot of the customers. I know that the Object Oriented
special that's on the menu isn't perfect, but it'll do for me.

Anything you say about how JavaScript is better than Perl,
I would suggest you keep in mind that you're talking to
a bunch of people who are regulars at the perl bar,
and who aren't likely to change just because you say that
the restaurant isn't like it used to be.

People choose their language for objective and subjective reasons.
It's good to keep that in mind. Because if you realize
that it's true about other people, maybe you'll remember its
true about yourself.





___
Boston-pm mailing list
Boston-pm@mail.pm.org
http://mail.pm.org/mailman/listinfo/boston-pm


Re: [Boston.pm] Languages to learn in addition to Perl

2010-07-19 Thread Greg London
As a sub-thread to this topic, there are languages
you should NOT learn. Having worked in Ada and VHDL for
about six years, I'd say that Ada is sort of like Cthulhu:
The more you know Ada, the more likely you are to go insane.



 I don't think anyone has mentioned Haskell yet in this thread.  One of the
 major Perl 6 implementations is done in Haskell, so it could be relevant
 from that angle.

 Also, I would second those who suggest Clojure as a great language to
 learn.

 Rob

 On Wed, Jul 14, 2010 at 12:33 PM, Asa Martin asa.mar...@gmail.com wrote:

 Hi everyone,

 Hope this isn't too off-topic, but I've relocated to the Boston area
 recently and am looking for a job. I've been a Perl hacker since the
 late
 90s and consider it my first (and still favorite) language. However, I'd
 like to update my skillset to include some other languages. I've worked
 in
 the past using some PHP and JavaScript and have a casual knowledge of
 Python
 and Ruby. I've also done a fair about of SQL.

 Any suggestions from this group as to what would make sense to put
 effort
 into learning next to make myself more marketable in the Boston area?

 Should I try and learn Java? If so, any recommendations as to
 books/tutorials?

 What about Ruby or Python? Would those be useful together with Perl or
 are
 they usually mutually exclusive?

 Anything else?

 I don't want to start a language war as to what language is
 theoretically
 best, but instead wondering what languages are practically best,
 i.e.,
 most often coupled (or tripled, etc.) with Perl in this area.

 Of course, actual job offers are welcome too ;-)

 Thanks in advance,

 Asa

 ___
 Boston-pm mailing list
 Boston-pm@mail.pm.org
 http://mail.pm.org/mailman/listinfo/boston-pm


 ___
 Boston-pm mailing list
 Boston-pm@mail.pm.org
 http://mail.pm.org/mailman/listinfo/boston-pm



-- 



___
Boston-pm mailing list
Boston-pm@mail.pm.org
http://mail.pm.org/mailman/listinfo/boston-pm


Re: [Boston.pm] Languages to learn in addition to Perl

2010-07-19 Thread Greg London
John wrote:
 My mild Perl-user-bashing

The point is that you're bashing.

And in doing so, you're invoking extremely bad logic.

 I have found that if you tell a group
 of Perl users that the sky is blue,
 some of them will tell you that Perl
 would be better.

Anecdotal evidence.
Hasty generalization.

This exact same statement remains true even if you
substitute perl for mac or pc or ubuntu or redhat
or wikipedia or just about any project that has any kind
of following.

It informs the reader of nothing.
All that remains then is the insult it conveys
while trying to pretend that it is true only
for perl programmers.

 To whatever degree the people at the perl bar are
 an insular clique of language-isolationists,

Circular logic. Your premise is your conclusion.

It also makes me think of the if by whiskey argument.

if by whiskey you mean the devil's brew, the poison
scourge, the bloody monster, that defiles innocence,
dethrones reason, destroys the home, creates misery and
poverty, then yes, I agree whiskey is bad.

 then my advocacy of learning and using a large
 number of languages is probably offensive,

Ah, I think maybe you ought to re-consider what it
is you're doing that could possibly be landing as
offensive.

I **promise** you it isn't that you're advocating
for the learning of a large number of languages.

Just as a guestimate, I've probably written code
in more than a dozen diffferent computer languages
in my lifetime.

 as it implies that there is something wrong with
 only learning one language

I haven't gone through and reread all the comments
in this thread, but off the top of my head, I don't
recall a single post saying anything of the sort
until now.

No one has said people should only learn perl.

No one.

 and claiming that it's the one true best ever
 language with diamonds, snowflakes and unicorns on top.

Have you ever heard of the concept of strawman?








___
Boston-pm mailing list
Boston-pm@mail.pm.org
http://mail.pm.org/mailman/listinfo/boston-pm


Re: [Boston.pm] Languages to learn in addition to Perl

2010-07-15 Thread Greg London

 James Eshelman ja...@nova-sw.com wrote:
 If Droid is running a JVM

Wikipedia (fwiw) says Android is developed specifically for ARM processors.

http://en.wikipedia.org/wiki/Android_(operating_system)

The Motorola Xtreme, for example, uses a TI OMAP 3630 processor

http://en.wikipedia.org/wiki/Texas_Instruments_OMAP#OMAP3

The 3630 has an ARM Cortex A8 processor in it.

Cortex A8 supports Jazelle and ThumbEE.

http://en.wikipedia.org/wiki/ARM_architecture#Jazelle

Jazelle is Java byte code in hardware.
But Wikipedia says it's fading and being
replaced by ThumbEE.

Thumb is ARM's 16 bit(?) instruction set
(ARM processors are native 32 bit)
which can take up a lot less space,
and use smaller/cheaper hardware than
the full 32 bit implementation.
Not sure what ThumbEE is just yet.

I don't know if Android uses Jazelle or ThumbEE
or if it uses a virtual machine of some kind.

Given how these phones keep processing power down
to extend battery life, I'd hope they do anything
possible to leverage the hardware that's already
there and speed things up.

 then you ought to be able to run Clojure code

I've never heard of Clojure at all.

It compiles down to java byte code?




___
Boston-pm mailing list
Boston-pm@mail.pm.org
http://mail.pm.org/mailman/listinfo/boston-pm


Re: [Boston.pm] Languages to learn in addition to Perl

2010-07-14 Thread Greg London
Mike wrote:
 I hope to try ... Perl 6.

Don't we all...

;/

As for languages I'd like to learn, I'm pondering
what it would take for me to learn Java so I could
try writing a simple app for a droid phone.

Unfortuanately, no one has ported perl to android.



___
Boston-pm mailing list
Boston-pm@mail.pm.org
http://mail.pm.org/mailman/listinfo/boston-pm


Re: [Boston.pm] Boston-pm Digest, Vol 85, Issue 8

2010-07-14 Thread Greg London
arus wrote:
 Greg wrote:
 Unfortuanately, no one has ported perl to android.

 Incorrect.
 There is a port to android available through
 the android script layer.
 I have experimented with it a little and it looks promising.
 http://code.google.com/p/android-scripting/

Cool!

I hope to pick up a Motorola Xtreme as soon as one is available.

I'm a bit concerned about interpreting perl on a
1 ghz ARM-CortexA8 processor, but, really, who cares,
it's perl! On a phone!

Greg




___
Boston-pm mailing list
Boston-pm@mail.pm.org
http://mail.pm.org/mailman/listinfo/boston-pm


Re: [Boston.pm] Languages to learn in addition to Perl

2010-07-14 Thread Greg London


 Date: Wed, 14 Jul 2010 13:54:33 -0500
 Subject: Re: [Boston.pm] Boston-pm Digest, Vol 85, Issue 8
 From: em...@greglondon.com
 To: ac.russ...@live.com
 CC: boston-pm@mail.pm.org

 arus wrote:
  Greg wrote:
  Unfortuanately, no one has ported perl to android.
 
  Incorrect.
  There is a port to android available through
  the android script layer.
  I have experimented with it a little and it looks promising.
  http://code.google.com/p/android-scripting/

 Cool!

 I hope to pick up a Motorola Xtreme as soon as one is available.

 I'm a bit concerned about interpreting perl on a
 1 ghz ARM-CortexA8 processor, but, really, who cares,
 it's perl! On a phone!
 Just another note but there has been the port to Symbian OS
 which has been around for a while. In fact, I was one of the
 more recent persons to have submitted code for that port.
 Currently Symbian is at 5.10 with only a small subset of modules ported.
 If you want a more hardcore mobile project to work on

Certainly, at some point down the road I hope that my
droid-java(perl?) powered death star will allow me to
become the ultimate power in the universe.

But right now I'd be happy if I could do hello world.

anyone know of an excellent Java book that they would
highly recommend (couldn't hurt if it explains java and bytecode)?


 Symbian might be it.
 Then again Symbian has about .0001% of the share of smartphone hype in the
 US
 relative to apple and android, it seems...

 _
 The New Busy is not the too busy. Combine all your e-mail accounts with
 Hotmail.
 http://www.windowslive.com/campaign/thenewbusy?tile=multiaccountocid=PID28326::T:WLMTAGL:ON:WL:en-US:WM_HMP:042010_4

 ___
 Boston-pm mailing list
 Boston-pm@mail.pm.org
 http://mail.pm.org/mailman/listinfo/boston-pm



-- 



___
Boston-pm mailing list
Boston-pm@mail.pm.org
http://mail.pm.org/mailman/listinfo/boston-pm


Re: [Boston.pm] Stlgen.pm alpha version (.012) released to CPAN

2010-06-08 Thread Greg London
CPAN indexed it so you can read the pod or download the tarball here:

http://search.cpan.org/~gslondon/Stlgen-0.012/

Hm, the dependencies link doesn't show Template.pm. Will need to fix that.


Greg


 Readme is already on CPAN here:

 http://www.cpan.org/modules/by-authors/id/G/GS/GSLONDON/Stlgen-0.012.readme


 I've been fiddling with Template::Toolkit a bit lately and came up with
 something odd and interesting (to me anyway).

 I created a module called Stlgen.pm which uses templates to generate C
 code. The C code implements a linked list. The perl code and the
 template
 controls what records are in linked list elements (i.e. characters,
 integers, unsigned longs, strings, whatever you want). It even supports
 multiple records per element, such as name and age and height and
 weight. Each with their own types.

 The templates handle sorting (with a default numeric compare that can be
 overridden by the user in c code to be string compare or whatever they
 want). It implements it with a merged sort, which has been confirmed to
 work, at least with unsigned integers as an example.

 The templates also support a dumper function, which will dump out
 whatever records/types you decide to put in the linked list element.

 Basically, it's the Standard Template Library (STL) container class for
 linked lists, but instead of using the template functionality of C++,
 Stlgen.pm uses the Template::Toolkit from perl and generates instances
 of
 the class in plain C code.

 I have no idea if its been done before, but it was an intriguing
 exercise
 that piqued my interest and I decided to see if it was possible. Mostly
 it
 turned into a learning exercise for Template::Toolkit and how to look at
 a
 linked list in C in completely generic (templatable) terms.

 Anyway, I just got it to the point where the sort function successfully
 sorts a list and decided to archive a somewhere other than my harddrive
 so
 I'd have a backup. And also introduce it to the public and see if this
 was
 at all interesting to anyone else.

 Like I said, I have no idea if someone already has some sort of solution
 for having a configurable linked list in C or not. If I've reinvented
 the
 wheel, then if nothing else, I learned how to do a merged-sort
 algorithm.

 I just uploaded the tarball to cpan, it should show up here somewhere:

 http://www.cpan.org/modules/by-authors/id/G/GS/GSLONDON/

 It is an alpha version. I'm calling it rev 0.012. So it may have some
 bugs. But it creates compilable c code and includes an example main.c
 which fills a list with numbers, sorts it, and dumps the contents.

 The Stlgen.pm module is coded in a fairly generic way such that other
 container templates could be added to it and the same user interface
 would
 work regardless of whether it was a linked list in C or a hash in C or
 some other container in some language that doesn't support those
 containers naitively.

 If anyone does a lot of C coding would be willing to take a peek at my
 module, generate a linked list, and play around with it a bit, I'd
 appreciate any feedback. It is alpha, so don't put it in your
 deliverables.

 Greg



 ___
 Boston-pm mailing list
 Boston-pm@mail.pm.org
 http://mail.pm.org/mailman/listinfo/boston-pm



 --





-- 



___
Boston-pm mailing list
Boston-pm@mail.pm.org
http://mail.pm.org/mailman/listinfo/boston-pm


[Boston.pm] Stlgen.pm alpha version (.012) released to CPAN

2010-06-07 Thread Greg London
I've been fiddling with Template::Toolkit a bit lately and came up with
something odd and interesting (to me anyway).

I created a module called Stlgen.pm which uses templates to generate C
code. The C code implements a linked list. The perl code and the template
controls what records are in linked list elements (i.e. characters,
integers, unsigned longs, strings, whatever you want). It even supports
multiple records per element, such as name and age and height and
weight. Each with their own types.

The templates handle sorting (with a default numeric compare that can be
overridden by the user in c code to be string compare or whatever they
want). It implements it with a merged sort, which has been confirmed to
work, at least with unsigned integers as an example.

The templates also support a dumper function, which will dump out
whatever records/types you decide to put in the linked list element.

Basically, it's the Standard Template Library (STL) container class for
linked lists, but instead of using the template functionality of C++,
Stlgen.pm uses the Template::Toolkit from perl and generates instances of
the class in plain C code.

I have no idea if its been done before, but it was an intriguing exercise
that piqued my interest and I decided to see if it was possible. Mostly it
turned into a learning exercise for Template::Toolkit and how to look at a
linked list in C in completely generic (templatable) terms.

Anyway, I just got it to the point where the sort function successfully
sorts a list and decided to archive a somewhere other than my harddrive so
I'd have a backup. And also introduce it to the public and see if this was
at all interesting to anyone else.

Like I said, I have no idea if someone already has some sort of solution
for having a configurable linked list in C or not. If I've reinvented the
wheel, then if nothing else, I learned how to do a merged-sort algorithm.

I just uploaded the tarball to cpan, it should show up here somewhere:

http://www.cpan.org/modules/by-authors/id/G/GS/GSLONDON/

It is an alpha version. I'm calling it rev 0.012. So it may have some
bugs. But it creates compilable c code and includes an example main.c
which fills a list with numbers, sorts it, and dumps the contents.

The Stlgen.pm module is coded in a fairly generic way such that other
container templates could be added to it and the same user interface would
work regardless of whether it was a linked list in C or a hash in C or
some other container in some language that doesn't support those
containers naitively.

If anyone does a lot of C coding would be willing to take a peek at my
module, generate a linked list, and play around with it a bit, I'd
appreciate any feedback. It is alpha, so don't put it in your
deliverables.

Greg



___
Boston-pm mailing list
Boston-pm@mail.pm.org
http://mail.pm.org/mailman/listinfo/boston-pm


Re: [Boston.pm] Stlgen.pm alpha version (.012) released to CPAN

2010-06-07 Thread Greg London
Readme is already on CPAN here:

http://www.cpan.org/modules/by-authors/id/G/GS/GSLONDON/Stlgen-0.012.readme


 I've been fiddling with Template::Toolkit a bit lately and came up with
 something odd and interesting (to me anyway).

 I created a module called Stlgen.pm which uses templates to generate C
 code. The C code implements a linked list. The perl code and the template
 controls what records are in linked list elements (i.e. characters,
 integers, unsigned longs, strings, whatever you want). It even supports
 multiple records per element, such as name and age and height and
 weight. Each with their own types.

 The templates handle sorting (with a default numeric compare that can be
 overridden by the user in c code to be string compare or whatever they
 want). It implements it with a merged sort, which has been confirmed to
 work, at least with unsigned integers as an example.

 The templates also support a dumper function, which will dump out
 whatever records/types you decide to put in the linked list element.

 Basically, it's the Standard Template Library (STL) container class for
 linked lists, but instead of using the template functionality of C++,
 Stlgen.pm uses the Template::Toolkit from perl and generates instances of
 the class in plain C code.

 I have no idea if its been done before, but it was an intriguing exercise
 that piqued my interest and I decided to see if it was possible. Mostly it
 turned into a learning exercise for Template::Toolkit and how to look at a
 linked list in C in completely generic (templatable) terms.

 Anyway, I just got it to the point where the sort function successfully
 sorts a list and decided to archive a somewhere other than my harddrive so
 I'd have a backup. And also introduce it to the public and see if this was
 at all interesting to anyone else.

 Like I said, I have no idea if someone already has some sort of solution
 for having a configurable linked list in C or not. If I've reinvented the
 wheel, then if nothing else, I learned how to do a merged-sort algorithm.

 I just uploaded the tarball to cpan, it should show up here somewhere:

 http://www.cpan.org/modules/by-authors/id/G/GS/GSLONDON/

 It is an alpha version. I'm calling it rev 0.012. So it may have some
 bugs. But it creates compilable c code and includes an example main.c
 which fills a list with numbers, sorts it, and dumps the contents.

 The Stlgen.pm module is coded in a fairly generic way such that other
 container templates could be added to it and the same user interface would
 work regardless of whether it was a linked list in C or a hash in C or
 some other container in some language that doesn't support those
 containers naitively.

 If anyone does a lot of C coding would be willing to take a peek at my
 module, generate a linked list, and play around with it a bit, I'd
 appreciate any feedback. It is alpha, so don't put it in your
 deliverables.

 Greg



 ___
 Boston-pm mailing list
 Boston-pm@mail.pm.org
 http://mail.pm.org/mailman/listinfo/boston-pm



-- 



___
Boston-pm mailing list
Boston-pm@mail.pm.org
http://mail.pm.org/mailman/listinfo/boston-pm


Re: [Boston.pm] interpolate methods in a string

2010-05-26 Thread Greg London

 Is there a better regexp than \$(\w+) to identify anything that
 the perl parser would identify as a variable?

This seems to be the crux of whether you feel comfortable
using s/// rather than something else.

Unfortunately, I don't know the answer with complete and
absolute certainty.

\w is defined as anything that is a perl identifier.

But it won't see special variables, like $@, and such.

But I don't think you have to worry about that for method names
or subroutine names or whatever. I think they'll always be \w+

There's screwy variable names in perl, but I can't think
of any screwy subroutine or method names.

So, I *think* you'll be safe.

Greg



___
Boston-pm mailing list
Boston-pm@mail.pm.org
http://mail.pm.org/mailman/listinfo/boston-pm


Re: [Boston.pm] filename wildcard on command line and perl module paths

2010-05-23 Thread Greg London
Ben Tilly wrote:
 That is very kludgey.  I would suggest just making people put single
 quotes around the wildcard.  That will be less surprising for
 experienced people.

Oh, man, I don't know why I didn't think of that.
My only defense is I was frantically trying to finish
this at work, on Friday, about an hour after I was
supposed to go home.

I'll fix it Monday.

 After you use it, just look in %INC to figure out where it was found.

OK, I didn't know that one. Cool. Thanks.

Greg



___
Boston-pm mailing list
Boston-pm@mail.pm.org
http://mail.pm.org/mailman/listinfo/boston-pm


[Boston.pm] filename wildcard on command line and perl module paths

2010-05-22 Thread Greg London
Two unrelated perl queries.

First, I have a perl script that needs to pass in via command options a
filename that might include wildcards. This filename will be used by the
script at a later point, from a different directory, so I don't want Unix
to do wildcard replacement when I run the script. But I'd like it to look
like a wildcard so people are familiar with it and don't need to be
explained about it.

I used '@' as my wildcard and then do a s/@/*/g at some point before using
it. It feels a bit klugey though. Is there a better way to do it?

Second, is there a built-in way to find the path to a perl module? I wrote
a subroutine that does a manual search through @INC, PERL5LIB, PERLLIB,
etc, but, again, it feels kind of klugey, and, again, I can't imagine I'm
the first guy to need to do this. Is there a built in way?

Greg



___
Boston-pm mailing list
Boston-pm@mail.pm.org
http://mail.pm.org/mailman/listinfo/boston-pm


Re: [Boston.pm] Newbie question

2010-05-08 Thread Greg London
 but i will strongly differ with your view about
 learning perl from web tutorials.
 99% of them stink to high heaven.

I've taught some short, intro perl classes and
I wrote a short (~150 pages), intro perl book.

http://www.greglondon.com/iperl/index.htm

My experience has been that there's no right way
to teach perl, or really to teach anything.

There are ways that work for a particular student
and ways that don't. And what works for one particular
student may not work for another at all.

I get emails from folks who read impatient perl
and said it was really helpful for them. But I'm
sure it isn't right for everyone trying to learn
perl.

The students are what's important. Not the teachers.

And speaking of which, I don't think we've heard
from our pastry chef turned programmer since the
original question was posted. I hope that means
they found an answer to their question somewhere
in all the responses.

Greg







___
Boston-pm mailing list
Boston-pm@mail.pm.org
http://mail.pm.org/mailman/listinfo/boston-pm


Re: [Boston.pm] domain theft saga

2010-03-30 Thread Greg London
Hm,

Can anyone recommend a good, reliable, secure, host/registrar?
Must have phone support and shouldn't be too expensive.

Greg


 For those of you not on the BLU list, you might find this an interesting
 read:

 http://old.nabble.com/Dreamhost-account-hacked-td28062149s24859.html

 In brief, a directed attack using social engineering was perpetrated
 against my domain registrar, Dreamhost, and due to multiple failures on
 their part, they granted the attacker access to my account, froze me
 out, and hampered my ability to halt the attack.

 This started Saturday night, and by Sunday afternoon, given lax response
 from Dreamhost, the attacker had succeeded in transferring my vl.com
 domain, which is considered of high value due to being only two letters,
 to a foreign registrar located in the Bahamas.

 Included in my posts are laughable chat transcripts between the attacker
 and the Dreamhost support personnel, where support people were more than
 happy to update contact info, supply plain text passwords, and force
 through a domain transfer.

 Clearly, humans were the weakest link in this system.

 The good news is that the attacker never succeeded in compromising my
 email account use as the domain contact (despite a few attempts) and the
 foreign registrar has been convinced that there was enough fishy about
 the transfer to put modifications on hold. So for the time being my name
 server records are safe, and they haven't gained access to my vl.com
 email traffic. (Though I'm pretty sure they only care about the domain
 itself.)

 I've reported the attack to the local police and the FBI.

 Still tonight the attackers made attempts to reset the password on my
 Google hosted account used as the contact address for the domain.
 Undoubtedly so they can leverage it to send a forged letter to the
 foreign registrar.

   -Tom

 --
 Tom Metro
 Venture Logic, Newton, MA, USA
 Enterprise solutions through open source.
 Professional Profile: http://tmetro.venturelogic.com/

 ___
 Boston-pm mailing list
 Boston-pm@mail.pm.org
 http://mail.pm.org/mailman/listinfo/boston-pm



-- 



___
Boston-pm mailing list
Boston-pm@mail.pm.org
http://mail.pm.org/mailman/listinfo/boston-pm


Re: [Boston.pm] Exceptions as control flow

2010-03-19 Thread Greg London
 I don't know, but I would guess that embedded coding standards may be
 liberalizing (for lack of a better word) in response to hardware
 changes.  Actual CPUs, with hardware support for a stack are the norm
 these day, no?  Don't only very high volume, low cost mass market
 products (e.g. remote controls) still use PIC controllers?

Well, there's embedded as in runs windows mobile and then there's
embedded as in must acheive a frame rate of 30 hz.

Hardware improvements cannot guarantee frame rate if the system
architecture cannot guarantee every step is a fixed operation.

i.e. any system that will stop and read a file of undefined length until
EOF is reached is the first kind of embedded, a small desktop.

if you're working on the must achieve a frame rate of 30 hz kind of
device, then you're system architecture is going to be fundamentally
different than desktop applications. It's an entirely different mindset.



___
Boston-pm mailing list
Boston-pm@mail.pm.org
http://mail.pm.org/mailman/listinfo/boston-pm


Re: [Boston.pm] Exceptions as control flow

2010-03-19 Thread Greg London

 ...I think something has been lost here. You seem to be implying that
 writing fast code does not matter for embedded code, because it runs
 against a fixed clock.

The thing being lost is the difference between code that
you think is fast and code that you have *proven* is fast.

the FAA requires that life critical avionics be *proven*
to be fast *and* accurate, *no matter what*.

And while desktop code jockeys will throw a few
test cases at their code (top down testing) and decide
that it is fast enough, the FAA won't let that approach fly.

Proving a system is fast and accurate no matter what inputs
it sees isn't easy.

If you can prove the low level blocks behave a certain way
no matter what input they get, and if you can prove that
putting those blocks together doesn't create any new behaviour,
then you have essentially proven your system.

If your blocks behave a certain way in standalone, but
start behaving differently depending on how the rest of
the system is behaving, then you really haven't proven
anything.

Most FAA requirements prohibit stuff that causes the
system to behave differently depending on how the rest
of the system is behaving. Malloc being a good example.
You can't prove that malloc will always work no matter
what because you don't know what your system might do
with malloc. Even if you get malloc to work perfectly,
how do you *prove* that the system won't try to
allocate more memory than exists? You can't.

What you're doing is you're telling me that you think
using exceptions will be faster than using other
control structures. And maybe you can provide a case
where the real objective measures show that it is
faster. But you haven't *proven* it will be fast and
accurate *no matter what*.




___
Boston-pm mailing list
Boston-pm@mail.pm.org
http://mail.pm.org/mailman/listinfo/boston-pm


  1   2   3   >