RE: regex like option *values*

2011-03-07 Thread Brian Raven
 -Original Message-
 From: p sena [mailto:senapati2...@yahoo.com]
 Sent: 05 March 2011 05:34
 To: perl-win32-users@listserv.ActiveState.com; Brian Raven
 Subject: RE: regex like option *values*
 __DATA__
 abc0[1-9].ctr.[pad,spd].set.in
 abc[01-22].ctr.[pad,spd].set.in
 abcL[1,2,3].ctr.[pad,spd].set.in
 abcL[1,2,3].ctr.[pad,spd].set.in
 abcL[1,2,3].ctr.[70,001].set.in

 ---

 It should work for lists of ranges, and
 ranges of
 strings as well as
 numbers.

 Regarding incorporating into Getopt::Long,
 see the
 Tips and Tricks
 section of the doco.

 Brian,

 Can this solution be generalized in a way to support
 --option_value=abc0[1-9].ctr.[pad,spd].set.in,xxx0[2- 8].mmm.[rst,spd].
 afr.org types? Means those _DATA_ lines all appear in one line
 separated by comma as above (instead of newline separated). Should it
 be efficient to do in the expand_string() or from the main while
 iteration just before calling expand_string.

 Replying back with a solution I can see. In case of such option value
 supplies it becomes difficlut to do the similar thing as below-
 GetOptions (library=s = \@libfiles);
@libfiles = split(/,/,join(',',@libfiles));
 Such mixed strings can be parsed and returned as a list as below. In
 our context, to be called from the main before the while iteration.
 After that this list's elems can be passed on to the expand_xxx
 routine(s) one by one.

 # Arg- A string which is the option value like #abc0[1-
 9].ctr.[pad,spd].set.in,xxx0[2-8].mmm.[rst,spd].afr.org,some more
 values... sub parse_mix_strings {
 my @x = split (//, $_[0]);
 my $bracket_close;
 my $bracket_open;
 my @elems;
 my @hstrings;
 for (@x) {
 push @elems, $_;
 if ($_ eq '[') {
 $bracket_open = 1;
 }
 if ($_ eq ']') {
 if ($bracket_open == 1) {
 $bracket_close = 1;
 $bracket_open = 0;
 }
 }
 if ($_ eq ','  !$bracket_open  $bracket_close) {
 $elems[$#elems] =~ s/,//;
 push @hstrings, join(,@elems);
 @elems = ();
 }
 }
 push @hstrings, join(, @elems);
 return@hstrings;
 }

 On *another note* leveraging use of the Getopts::Long can be this way
 I think ?

 my %list;
 GetOptions('list=s%' =
   sub { print 1 = $_[1] 2 = $_[2]\n;
 push(@{$list{$_[1]}}, expand_string($_[2])) });

 print Elems = , scalar @{$list-{add}}, \n; # debug print  ,
 @{$list{add}}, \n; # debug skip

 And program can be called as - prog_name.pl --list add=abc0[1-
 2].src.spd.in --list add=volvo[1-5].jeep.sch.edu

Your first idea can be made simpler by choosing a different separator, as comma 
is already being used as a separator for the contents of your square brackets. 
A unique separator means that you only need to call split to get the individual 
strings that you want to expand.

Your second idea can also be simpler. For example...

my @list;
GetOptions('list=s' = sub {push @list, expand_string($_[1]);});

HTH


--
Brian Raven




Please consider the environment before printing this e-mail.

This e-mail may contain confidential and/or privileged information. If you are 
not the intended recipient or have received this e-mail in error, please advise 
the sender immediately by reply e-mail and delete this message and any 
attachments without retaining a copy.

Any unauthorised copying, disclosure or distribution of the material in this 
e-mail is strictly forbidden.
___
Perl-Win32-Users mailing list
Perl-Win32-Users@listserv.ActiveState.com
To unsubscribe: http://listserv.ActiveState.com/mailman/mysubs


RE: Help with Array of Arrays

2011-03-07 Thread Greg Aiken
if you are not in control of the base sql query, then disregard this
comment...

however if you are in control of the sql query that executes to oracle, you
might want to see how oracles 'connect by' function might be able to help
you handle the hierarchical nature of the relationship.  perhaps a different
query can be executed that shifts the burden of dealing with the
hierarchical data handling from your code, to the oracle db engine.

I'm unsure if this might be able to lighten your load, or not, but check it
out.

I'm not a current oracle user, but years ago I tinkered with it, and I
remember how 'connect by' proved to be a helpful friend.

-Original Message-
From: perl-win32-users-boun...@listserv.activestate.com
[mailto:perl-win32-users-boun...@listserv.activestate.com] On Behalf Of
Barry Brevik
Sent: Sunday, March 06, 2011 4:05 PM
To: perl-win32-users@listserv.ActiveState.com
Subject: Help with Array of Arrays

I always get majorly confused when I have to deal with Arrays of Arrays,
Arrays of Hashes etc. The Camel book has a good section on this, but it
is not always enough. That's why each time I do one, I document it in a
file on my disk. However, I have not done this one before.
 
I am extracting Bill of Material (BOM) data from our Oracle system. In
my case, each BOM has any number of line items (array) and each line has
5 data items that I am working with (array of arrays). However, any line
item can be a part that is itself another BOM, so I end up with a sort
of tree structure.
 
As I enumerate each line on the TOP LEVEL BOM, when I come to another
BOM, I have to stop what I'm doing, save my place (yet another array
of arrays), and go down into this next BOM.
 
To save my place, I have an array named stack upon which I push the
entire BOM currently being enumerated, along with several scalars that
have to do with what line item I stopped at and so on. The code below
demonstrates exactly what I'm doing. The code works, so I'm OK there,
but I can't get over the feeling that there is a better way to implement
my stack. If anybody has any advice, I'm all ears.
 
=
use strict;
use warnings;
 
my $i = 2;
my $curlvl = 0;
my @stack = ();
my @thisBOM =
(
  [10, 1, 1, MS51957-59-10, Screw, Pan HD, 2-56 x .5],
  [20, 2, 1, MS51957-59-20, Screw, Pan HD, 4-40 x 1],
  [30, 3, 1, MS51957-59-30, Screw, Pan HD, 6-32 x 1.25]
);
 
# Just print the BOM for reference.
print i.: $i\n;
print curlvl: $curlvl\n;
for my $i (0..$#thisBOM)
{
  print $i: @{$thisBOM[$i]}\n;
}
print \n\n\n;
 
# Save our place.
push @stack, [($i, $curlvl, [@thisBOM])];
 
# re-init the variables.
$i = $curlvl = ''; @thisBOM = ();
 
# Now, recover where we left off.
($i, $curlvl, @thisBOM) = @{pop @stack};
@thisBOM = @{$thisBOM[0]};
 
# Print the BOM again to make sure it came off the stack the way it went
on.
print i.: $i\n;
print curlvl: $curlvl\n;
for my $i (0..$#thisBOM)
{
  print $i: @{$thisBOM[$i]}\n;
}
print \n\n\n;

___
Perl-Win32-Users mailing list
Perl-Win32-Users@listserv.ActiveState.com
To unsubscribe: http://listserv.ActiveState.com/mailman/mysubs




___
Perl-Win32-Users mailing list
Perl-Win32-Users@listserv.ActiveState.com
To unsubscribe: http://listserv.ActiveState.com/mailman/mysubs


RE: Help with Array of Arrays

2011-03-07 Thread Ken Cornetet
My advice would be to use objects. Each BOM can be an object, and each line 
item can be a different object. Keeping track of anonymous arrays and hashes 
can get complicated very fast. Objects are perfect for this sort of thing - 
don't be afraid of them.

You would have one master array or hash that would hold pointers to BOM 
objects, and the BOM objects would have a method that accepted a pointer to a 
line-item object and pushed it into an internal anonymous array.

Here's the general idea (typed off the cuff, so may contain errors, but you'll 
get the idea).

My %boms;

My $bomid = ThisIsBom1

$boms{$bomid} = new BOM($bomid);

My $objLineItem = new LineItem(10, 1, 1, MS51957-59-10, Screw, Pan HD, 
2-56 x .5);
$boms{$bomid}-AddLineItem($objLineItem);

My $objLineItem = new LineItem(20, 2, 1, MS51957-59-20, Screw, Pan HD, 
4-40 x 1);
$boms{$bomid}-AddLineItem($objLineItem);

My $objLineItem = new LineItem(30, 3, 1, MS51957-59-30, Screw, Pan HD, 
6-32 x 1.25);
$boms{$bomid}-AddLineItem($objLineItem);

Exit 0;

Package BOM

sub new {
my $class = shift;
my $id = shift;
my $self  = {};

$self-{id} = $id;
$self-{lineitems} = [];
bless ($self, $class);
return $self;
}

Sub AddLineItem {
My $self = shift;
My $objItem = shift;
Push @{$self-{lineitems}}, $objItem;
}
1;

Package LineItem

Sub new {
My $class = shift;
My $self = shift;
$self{x} = shift;
$self{y} = shift;
$self{z} = shift;
$self{partno} = shift;
$self{$description} = shift;
bless ($self, $class);
return $self;
}
1;




Ken Cornetet 812.482.8499
To err is human - to moo, bovine.

-Original Message-
From: perl-win32-users-boun...@listserv.activestate.com 
[mailto:perl-win32-users-boun...@listserv.activestate.com] On Behalf Of Greg 
Aiken
Sent: Monday, March 07, 2011 11:07 AM
To: bbre...@stellarmicro.com; perl-win32-users@listserv.ActiveState.com
Subject: RE: Help with Array of Arrays

if you are not in control of the base sql query, then disregard this
comment...

however if you are in control of the sql query that executes to oracle, you
might want to see how oracles 'connect by' function might be able to help
you handle the hierarchical nature of the relationship.  perhaps a different
query can be executed that shifts the burden of dealing with the
hierarchical data handling from your code, to the oracle db engine.

I'm unsure if this might be able to lighten your load, or not, but check it
out.

I'm not a current oracle user, but years ago I tinkered with it, and I
remember how 'connect by' proved to be a helpful friend.

-Original Message-
From: perl-win32-users-boun...@listserv.activestate.com
[mailto:perl-win32-users-boun...@listserv.activestate.com] On Behalf Of
Barry Brevik
Sent: Sunday, March 06, 2011 4:05 PM
To: perl-win32-users@listserv.ActiveState.com
Subject: Help with Array of Arrays

I always get majorly confused when I have to deal with Arrays of Arrays,
Arrays of Hashes etc. The Camel book has a good section on this, but it
is not always enough. That's why each time I do one, I document it in a
file on my disk. However, I have not done this one before.
 
I am extracting Bill of Material (BOM) data from our Oracle system. In
my case, each BOM has any number of line items (array) and each line has
5 data items that I am working with (array of arrays). However, any line
item can be a part that is itself another BOM, so I end up with a sort
of tree structure.
 
As I enumerate each line on the TOP LEVEL BOM, when I come to another
BOM, I have to stop what I'm doing, save my place (yet another array
of arrays), and go down into this next BOM.
 
To save my place, I have an array named stack upon which I push the
entire BOM currently being enumerated, along with several scalars that
have to do with what line item I stopped at and so on. The code below
demonstrates exactly what I'm doing. The code works, so I'm OK there,
but I can't get over the feeling that there is a better way to implement
my stack. If anybody has any advice, I'm all ears.
 
=
use strict;
use warnings;
 
my $i = 2;
my $curlvl = 0;
my @stack = ();
my @thisBOM =
(
  [10, 1, 1, MS51957-59-10, Screw, Pan HD, 2-56 x .5],
  [20, 2, 1, MS51957-59-20, Screw, Pan HD, 4-40 x 1],
  [30, 3, 1, MS51957-59-30, Screw, Pan HD, 6-32 x 1.25]
);
 
# Just print the BOM for reference.
print i.: $i\n;
print curlvl: $curlvl\n;
for my $i (0..$#thisBOM)
{
  print $i: @{$thisBOM[$i]}\n;
}
print \n\n\n;
 
# Save our place.
push @stack, [($i, $curlvl, [@thisBOM])];
 
# re-init the variables.
$i = $curlvl = ''; @thisBOM = ();
 
# Now, recover where we left off.
($i, $curlvl, @thisBOM) = @{pop @stack};
@thisBOM = @{$thisBOM[0]};
 
# Print the BOM again to make sure it came off the stack the way it went
on.
print i.: $i\n;
print curlvl: $curlvl\n;
for my $i (0..$#thisBOM)
{
  print $i: 

RE: [OLE] Controlling AutoCAD = 2010 fails with Win32::OLE. Error 0x8001010a.

2011-03-07 Thread Jan Dubois
On Thu, 03 Mar 2011, Manuel Reimer wrote:

Hi Manuel,

[...]
 
 http://through-the-interface.typepad.com/through_the_interface/2010/02/handling-com-calls-rejected-
 by-autocad-from-an-external-net-application.html
 
 This C# and so I tried to port this over to C++ to be able to add this
 to the OLE.xs file. I've attached the patch file with my proof of
 concept code.
 
 As you see in my patch, I commented out the code, initializing OLE in
 multi threading mode, to make the CoRegisterMessageFilter call succeed.

The way to tell Win32::OLE to use OleInitialize() is to call

Win32::OLE-Initialize(Win32::OLE::COINIT_OLEINITIALIZE());

right after you use Win32::OLE.  Put it inside a BEGIN block if you
may call any OLE functionality at compile time (e.g. while loading other
code).
 
 Problem with this patch: It doesn't work. Anything, it does, is crashing
 the Perl interpreter... :-(

It is not crashing for me just running the bundled test suite.  Do you have
some sample script that crashes that doesn't involve AutoCAD, as I don't
have a copy of that application available.

 Is someone here able to have a look at this and perhaps fix this code?

I haven't really looked at your code; just applied the patch, built the
module and ran the tests, with no crash in sight.

So I assume the crash only happens when the MessageFilter is actually
being invoked.  I'll try to look at your implementation to see if I can
find anything that could go wrong, but having a reproducible crash would
make this easier.

Cheers,
-Jan


___
Perl-Win32-Users mailing list
Perl-Win32-Users@listserv.ActiveState.com
To unsubscribe: http://listserv.ActiveState.com/mailman/mysubs


RE: Help with Array of Arrays

2011-03-07 Thread Meir Guttman
Dear Barry,

I'll second Greg's idea. One link I think might help you is Peter Brawley's
and Arthur Fuller's excellent tutorial Trees and Other Hierarchies in
MySQL http://www.artfulsoftware.com/mysqlbook/sampler/mysqled1ch20.html.
This is of course MySQL, not Oracle (which BTW now owns MySQL), but these
two are close enough.

I would be happy to hear about your solution(s)

Meir



-Original Message-
From: perl-win32-users-boun...@listserv.activestate.com
[mailto:perl-win32-users-boun...@listserv.activestate.com] On Behalf Of Greg
Aiken
Sent: Monday, March 07, 2011 6:07 PM
To: bbre...@stellarmicro.com; perl-win32-users@listserv.ActiveState.com
Subject: RE: Help with Array of Arrays

if you are not in control of the base sql query, then disregard this
comment...

however if you are in control of the sql query that executes to oracle, you
might want to see how oracles 'connect by' function might be able to help
you handle the hierarchical nature of the relationship.  perhaps a different
query can be executed that shifts the burden of dealing with the
hierarchical data handling from your code, to the oracle db engine.

I'm unsure if this might be able to lighten your load, or not, but check it
out.

I'm not a current oracle user, but years ago I tinkered with it, and I
remember how 'connect by' proved to be a helpful friend.

-Original Message-
From: perl-win32-users-boun...@listserv.activestate.com
[mailto:perl-win32-users-boun...@listserv.activestate.com] On Behalf Of
Barry Brevik
Sent: Sunday, March 06, 2011 4:05 PM
To: perl-win32-users@listserv.ActiveState.com
Subject: Help with Array of Arrays

I always get majorly confused when I have to deal with Arrays of Arrays,
Arrays of Hashes etc. The Camel book has a good section on this, but it
is not always enough. That's why each time I do one, I document it in a
file on my disk. However, I have not done this one before.
 
I am extracting Bill of Material (BOM) data from our Oracle system. In
my case, each BOM has any number of line items (array) and each line has
5 data items that I am working with (array of arrays). However, any line
item can be a part that is itself another BOM, so I end up with a sort
of tree structure.
 
As I enumerate each line on the TOP LEVEL BOM, when I come to another
BOM, I have to stop what I'm doing, save my place (yet another array
of arrays), and go down into this next BOM.
 
To save my place, I have an array named stack upon which I push the
entire BOM currently being enumerated, along with several scalars that
have to do with what line item I stopped at and so on. The code below
demonstrates exactly what I'm doing. The code works, so I'm OK there,
but I can't get over the feeling that there is a better way to implement
my stack. If anybody has any advice, I'm all ears.
 
=
use strict;
use warnings;
 
my $i = 2;
my $curlvl = 0;
my @stack = ();
my @thisBOM =
(
  [10, 1, 1, MS51957-59-10, Screw, Pan HD, 2-56 x .5],
  [20, 2, 1, MS51957-59-20, Screw, Pan HD, 4-40 x 1],
  [30, 3, 1, MS51957-59-30, Screw, Pan HD, 6-32 x 1.25]
);
 
# Just print the BOM for reference.
print i.: $i\n;
print curlvl: $curlvl\n;
for my $i (0..$#thisBOM)
{
  print $i: @{$thisBOM[$i]}\n;
}
print \n\n\n;
 
# Save our place.
push @stack, [($i, $curlvl, [@thisBOM])];
 
# re-init the variables.
$i = $curlvl = ''; @thisBOM = ();
 
# Now, recover where we left off.
($i, $curlvl, @thisBOM) = @{pop @stack};
@thisBOM = @{$thisBOM[0]};
 
# Print the BOM again to make sure it came off the stack the way it went
on.
print i.: $i\n;
print curlvl: $curlvl\n;
for my $i (0..$#thisBOM)
{
  print $i: @{$thisBOM[$i]}\n;
}
print \n\n\n;

___
Perl-Win32-Users mailing list
Perl-Win32-Users@listserv.ActiveState.com
To unsubscribe: http://listserv.ActiveState.com/mailman/mysubs




___
Perl-Win32-Users mailing list
Perl-Win32-Users@listserv.ActiveState.com
To unsubscribe: http://listserv.ActiveState.com/mailman/mysubs

___
Perl-Win32-Users mailing list
Perl-Win32-Users@listserv.ActiveState.com
To unsubscribe: http://listserv.ActiveState.com/mailman/mysubs


PPD for two modules?

2011-03-07 Thread Arms, Mike
Hi, all.

I am looking for PPD's for the following two modules compiled for ActivePerl 
v5.12.3:

String-CRC  (v1.0)  - note: NOT String-CRC32
Time-modules(v2006.0814)

I did not find them under the ActiveState, bribes, trouchelle, or uwinnipeg 
repositories. Anyone have a PPD source for them?

--
Mike Arms
(marms) AT (sandia.gov)



___
Perl-Win32-Users mailing list
Perl-Win32-Users@listserv.ActiveState.com
To unsubscribe: http://listserv.ActiveState.com/mailman/mysubs


Re: PPD for two modules?

2011-03-07 Thread Christopher Taranto
Hi Mike,

If you install the MinGW PPD (ppm install MinGW), you can then use CPAN to
install the modules directly as in:

perl -MCPAN -e shell

HTH

On Mon, Mar 7, 2011 at 3:05 PM, Arms, Mike ma...@sandia.gov wrote:

  Hi, all.

 I am looking for PPD's for the following two modules compiled for
 ActivePerl v5.12.3:

 String-CRC  (v1.0)  - note: NOT String-CRC32
 Time-modules(v2006.0814)

 I did not find them under the ActiveState, bribes, trouchelle, or uwinnipeg
 repositories. Anyone have a PPD source for them?

 --
 Mike Arms
 (marms) AT (sandia.gov)




 ___
 Perl-Win32-Users mailing list
 Perl-Win32-Users@listserv.ActiveState.com
 To unsubscribe: 
 http://listserv.ActiveState.com/mailman/mysubshttp://listserv.activestate.com/mailman/mysubs


___
Perl-Win32-Users mailing list
Perl-Win32-Users@listserv.ActiveState.com
To unsubscribe: http://listserv.ActiveState.com/mailman/mysubs


Re: PPD for two modules?

2011-03-07 Thread Sisyphus

- Original Message - 
From: Arms, Mike ma...@sandia.gov
To: Perl-Win32-Users@listserv.ActiveState.com
Sent: Tuesday, March 08, 2011 10:05 AM
Subject: PPD for two modules?


Hi, all.

I am looking for PPD's for the following two modules compiled for ActivePerl 
v5.12.3:

String-CRC  (v1.0)  - note: NOT String-CRC32
Time-modules(v2006.0814)

I did not find them under the ActiveState, bribes, trouchelle, or uwinnipeg 
repositories. Anyone have a PPD source for them?

===

ppm repo add sisyphusion
ppm install String-CRC
ppm install Time-modules

Note that Time-modules (which is a pure perl module) fails quite a lot of 
tests, complaining that they're being run in the wrong order.
I suspect it's just a bug in the test script, but I haven't had time to 
check.

Cheers,
Rob 

___
Perl-Win32-Users mailing list
Perl-Win32-Users@listserv.ActiveState.com
To unsubscribe: http://listserv.ActiveState.com/mailman/mysubs