RE: help dbd-anydata / dbi-dbd-sqlengine issue

2013-05-20 Thread Brian Raven

> -Original Message-
> From: perl-win32-users-boun...@listserv.activestate.com [mailto:perl-
> win32-users-boun...@listserv.activestate.com] On Behalf Of John
> Sent: 19 May 2013 05:04
> To: pw32-users
> Subject: help dbd-anydata / dbi-dbd-sqlengine issue
>
> Hi
>
> Several years ago I dabbled with DBD::AnyData to read and merge a variety
> of csv data files. Recently I updated my DBI module to version
> 1.625 (and yesterday to 1.627). Since updating DBI my program has failed
> with an error message similar to that below (I have included a test script
> below that produces the error message).
>
> I would like advise on how to raise this with the appropriate
> developers/maintainers.
>
> Have I included enough info here for the developer/maintainer to track the
> problem? If not, what else should I include?
>
> I have provided my current perl version info below, I also have an older perl
> installation (v5.10) on my computer with DBI v1.616 and DBI-DBD-SqlEngine
> v0.03 that do not fail as reported here.
>
> Thanks
> John
>
> #[perl version]###
> I am currently using ActiveState ActivePerl V5.14.
> 12:26>perl -v
>
> This is perl 5, version 14, subversion 2 (v5.14.2) built for 
> MSWin32-x86-multi-
> thread (with 1 registered patch, see perl -V for more
> detail)
>
> The DBI-DBD-SqlEngine module concerned is version 0.06.
>
> #[err msg]#
> DBD::AnyData::db do failed:
> Execution ERROR: Can't call method "complete_table_name" on an
> undefined value at C:/bin/Perl/Perl514/site/lib/DBI/DBD/SqlEngine.pm line
> 1503.
>   called from tst_mkAP.pl at 10.
>
>   at C:/bin/Perl/Perl514/site/lib/DBI/DBD/SqlEngine.pm line 1239
>   [for Statement "CREATE TABLE AP_mem (
>   date_indexINTEGER,
>   amountVARCHAR(15),
>   acc1  VARCHAR(8),
>   acc2  VARCHAR(8),
>   description   VARCHAR(30),
>   voucher   VARCHAR(5),
>   costctr   VARCHAR(5),
>   date  VARCHAR(12)
>)"] at tst_mkAP.pl line 10.
> #[\err msg]#
>
> #[test script]#
> #! perl -w
> use strict;
> use warnings;
> use DBI;
>
> # define transient storage table
> sub mk_APmem {
> my $dbh = shift @_;
>
> $dbh->do(
>qq{CREATE TABLE AP_mem (
>   date_indexINTEGER,
>   amountVARCHAR(15),
>   acc1  VARCHAR(8),
>   acc2  VARCHAR(8),
>   description   VARCHAR(30),
>   voucher   VARCHAR(5),
>   costctr   VARCHAR(5),
>   date  VARCHAR(12)
>)}
> );
>
> my $insert   = qq{
>INSERT INTO AP_mem
>(date_index,  amount,  acc1, acc2, description,   voucher,
> costctr, date) VALUES
>( ?,   ?, ?,?,   ?, ?,
> ?,?)
> };
> # and return insert statement
> return $insert;
> }
>
> my $dbh = DBI->connect('dbi:AnyData(RaiseError=>1):');
>
> my $flags = {
> col_names   => 'Date,Description,AccNum,Debit,Credit'
> };
>
> my $file = "C:\\Documents and Settings\\John\\My
> Documents\\dnload\\10457109_20130514.dat";
>
> #my ($file, $flags, $dbh) = @_;
>
> # define data source
> # $dbh->func('CRU_in', 'CSV', $file, $flags, 'ad_catalog');
> $dbh->func('CRU_in', 'Pipe', $file, $flags, 'ad_catalog');
>
> # define transient storage table and return insert SQL Statement
> my $putAP = mk_APmem($dbh);
>
> print "$putAP\n";
>
> #[\test script]#

Have you tried the method suggested on the documentation? (See BUGS section in 
'perldoc DBI::AnyData').

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.
Please consider the environment before printing this email.

Visit our website at http://www.nyse.com



Note:  The information contained in this message and any attachment to it is 
privileged, conf

RE: confused by use of 'implied' variable

2013-04-08 Thread Brian Raven
From: perl-win32-users-boun...@listserv.activestate.com 
[mailto:perl-win32-users-boun...@listserv.activestate.com] On Behalf Of Greg 
VisionInfosoft
Sent: 05 April 2013 21:16
To: Perl-Win32-Users@listserv.ActiveState.com
Subject: confused by use of 'implied' variable

> im butchering a public script i found on the internet for purpose of doing a 
> CGI file upload.

Be very careful, there is a lot of poor quality scripts out there.

>
> theres one excerpt from the script that ive never used before.  the few 
> lines...
>
> while ( <$upload_filehandle> ) {
>   print UPLOADFILE;
> }
>
> if it were me, i would not write code this way, i write in a way that make it 
> easier for me to quickly
 > understand what i was trying to do.  if it were me coding this in my 'lame' 
 > (for idiots) way, it would look
> more like...
>
> while ( $data = <$upload_filehandle> ) {
>   print UPLOADFILE $data;
> }

Not unreasonable, but you should restrict the scope of your variable to the 
while loop.

while (my $data = <$upload_filehandle> ) {

etc.

>
> but now that ive seen the code, as originally presented, it does cause me to 
> ask the question...
>
> how does one know under what set of circumstances can such 'abbreviated' code 
> be written?  in other words, how > can one know what kinds of features or 
> operations can use the implied variable @_ (which I assume is the
> variable that would be used in this case).

The implied variable here is $_, not @_.

>
> specifically, if i wanted to append to a variable $aggregated_file_contents, 
> each new block of the file as it > was being read and output...
>
> my thought was to try:
>
> while ( <$upload_filehandle> ) {
>   print UPLOADFILE;
>   $aggregated_file_contents.=;

You have to be explicit here. That is...

$aggregated_file_contents .= $_;

> }
>
> as opposed to what i would have normally done ($aggregated_file_contents .= 
> $data;)
>
> yes, i know i can simply try it, to see if it works - but is there a more 
> general rule one can follow that
> tells them when this kind of thing can normally be used, versus when not?

Start with 'perldoc perlvar'. It is the first one listed under General 
Variables.

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: button with multiple font sizes

2013-03-13 Thread Brian Raven
Dan,

Tk::Button only allows for text in a single font, as you have probably 
discovered. However, it does let you use an image. If you can render the text 
you want as an image (e.g. GD?), that that might be a way to go.

HTH

--
Brian Raven

From: perl-win32-users-boun...@listserv.activestate.com 
[mailto:perl-win32-users-boun...@listserv.activestate.com] On Behalf Of Daniel 
Burgaud
Sent: 13 March 2013 01:57
To: Perl-Win32-Users
Subject: TK: button with multiple font sizes

Hi

I need a button with a big label and below it, description of the button.

I dont know how to make a TK button with multiple font size.
If not button, any TK object, clickable, and multiple font size capable.

thanks

Dan.



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


perl-win32-users@listserv.activestate.com

2012-12-21 Thread Brian Raven
From: perl-win32-users-boun...@listserv.activestate.com 
[mailto:perl-win32-users-boun...@listserv.activestate.com] On Behalf Of Greg 
Aiken
Sent: 20 December 2012 22:31
To: Perl-Win32-Users@listserv.ActiveState.com
Subject: learning references/dereferencing (understand $,@,%, but trouble 
understanding &)

> #if one desires to pass a scalar reference into a sub-routine,
> #the easiest way to assign a local scalar to the contents of the scalar 
> reference is...

Depends. Sometimes it is easier store the reference locally, and dereference as 
needed. See below.

> subroutine(\$scalar);
> sub subroutine {
>   my $subroutine_scalar = ${$_[0]};  #note you need the {} brackets, or this 
> doesn't work!
>   print "$subroutine_scalar\n";

   my $ref = shift;
   print "$$ref\n";

> }
>
> #if one desires to pass an array reference into a sub-routine,
> #the easiest way to assign a local array to the contents of the array 
> reference is...
> subroutine(\@array);
> sub subroutine {
>   my @subroutine_array = @{$_[0]};  #note you need the {} brackets, or this 
> doesn't work!
>   print "in subroutine: " . join(' ', @subroutine_array) . "\n";

   my $ref = shift;
   print "in subroutine: @$ref\n";
   print "   first entry is $ref->[0]\n";

> }
>
> #if one desires to pass a hash reference into a sub-routine,
> #the easiest way to assign a local hash to the contents of the hash reference 
> is...
> subroutine(\%hash);
> sub subroutine {
>   my %subroutine_hash = %{$_[0]};  #note you need the {} brackets, or this 
> doesn't work!
>   print "in subroutine: " . join(' ', keys (%subroutine_hash)) . "\n";

   my $ref = shift;
   print "$_ = $ref->{$_}\n" foreach keys %$ref;

> }
>
> all above works fine and is easy for me to understand.  its below that im 
> having difficulty with...
>
> #seeing the 'pattern' of behavior for $, @, % variable types...
> #i, not knowing any better, assumed the same should also be able to be done 
> for & (subroutines)
> #i therefore tried a test to see if i could assign a new subroutine to equal 
> a de-referenced subroutine
> reference
> #i literally copied the same code as used above, but used the & operator 
> instead of ($, @, %)
> #this did not give the expected result...  perl reported:
> #hello CODE(0x237dbc)
> #Can't modify non-lvalue subroutine call at D:\_junk\TEST.PL line 6.
>
> sub subroutine {
>   print "hello @_\n"
> }
> sub2(\&subroutine);
> sub sub2 {
>   &sub3 = &{$_[0]};  #problem is obviously here with this line, seems its not 
> being dereference
>   sub3('world');

The only variable types are scalar array and hash. There is no subroutine 
variable type, but you can store a reference to a subroutine, which is a 
scalar, in a variable. You dereference it when you want to call it.

my $ref = shift;
$ref->('world');

> }

For more detail see 'perldoc perlref'

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: 'mysplit' ???

2012-11-26 Thread Brian Raven
From: perl-win32-users-boun...@listserv.activestate.com 
[mailto:perl-win32-users-boun...@listserv.activestate.com] On Behalf Of Greg 
Aiken
Sent: 26 November 2012 16:19
To: Perl-Win32-Users@listserv.activestate.com
Subject: 'mysplit' ???

> i just ran across a perl recursion example that i am trying to understand...
>
> (url 
> =http://www.shlomifish.org/lecture/Perl/Newbies/lecture2/functions/recursion.html)
>
> sub mysplit
  ^^^
> {
>my ($total, $num_elems, @accum) = @_;
>
>if ($num_elems == 1)
>{
>push @accum, $total;
>print join(",", @accum), "\n";
>
>return;
>}
>
>for (my $item=0 ; $item <= $total ; $item++)
>{
>my @new_accum = (@accum, $item);
>mysplit($total-$item, $num_elems-1, @new_accum);   #<<<<<<<<<<<< 
> 'mysplit'
>}
> }
> mysplit(10,3);
>
> the line of code ive never seen before, and am struggling with to understand 
> - is the following...
>
>   mysplit($total-$item, $num_elems-1, @new_accum);
>
> ive 'googled' the word 'mysplit' and find no results.
>
> might anyone know exactly what 'mysplit' is?

I may have misunderstood your question, but mysplit is the sub defined above 
(see ^^^).

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: How to know a closed Socket?

2012-11-26 Thread Brian Raven
From: perl-win32-users-boun...@listserv.activestate.com 
[mailto:perl-win32-users-boun...@listserv.activestate.com] On Behalf Of Daniel 
Burgaud
Sent: 25 November 2012 16:37
To: Perl-Win32-Users
Subject: How to know a closed Socket?

> Hi
>
> If I opened a socket connection:
>
> $web = new IO::Socket::INET( PeerAddr => "192.168.1.1", PeerPort=>80 );
>
> how do I know if $web is still open for read/write?
> how do i know if 192.168.1.1 is still talking to me?
>
> with files, I just do:
> eof $filehandle;
>
> is there a similar function with sockets?

No. In general you only know that a socket has been closed when you try to read 
or write and it fails with the error code indicating that the socket has 
closed. If you are using select (IO::Select), the socket will become readable 
or writable when that part of the socket closes, so you will find out that the 
socket is closed when you read or write.

In general you can't know if a peer is "talking to you" unless it is actually 
talking to you. A common way to determine the difference between "I have no 
data to send you" and "I am not sending data because I am broken" is to use a 
heartbeat mechanism, i.e. a sender will send a heartbeat message at regular 
intervals, that can be checked by the receiver.

Welcome to network programming.

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: In need to efficiently retrieve HTTP

2012-11-21 Thread Brian Raven
From: perl-win32-users-boun...@listserv.activestate.com 
[mailto:perl-win32-users-boun...@listserv.activestate.com] On Behalf Of Tobias 
Hoellrich
Sent: 21 November 2012 14:45
To: Daniel Burgaud
Cc: Perl-Win32-Users
Subject: RE: In need to efficiently retrieve HTTP

> Hi Daniel - 
> http://stackoverflow.com/questions/6473785/improving-lwpsimple-perl-performance
>  should bring you
> on the right track. If you want to avoid multiple threads/processes then 
> "Keep-Alive" most likely will give
> you the biggest performance gain. The TCP connection stays open after you 
> made the first request and you can
> send more requests over the same connection.
>
> Cheers - T
>
> From: perl-win32-users-boun...@listserv.activestate.com 
> [mailto:perl-win32-users-
> boun...@listserv.activestate.com] On Behalf Of Daniel Burgaud
> Sent: Wednesday, November 21, 2012 7:37 AM
> To: Perl-Win32-Users
> Subject: In need to efficiently retrieve HTTP
>
> Hi All
>
> Basically, I need to fetch thousands and thousands of small 200~4000 byte 
> files (map files). Opening and
> closing a socket connection is too slow a process so much so a single file 
> would take as much as 10 seconds!
>
> Is there any perl script out there that can be used to efficiently fetch HTTP 
> files? A non-closing script? I
> sure wanna do Threaded on this one, but my win32 perl does not have thread 
> capability.
>
> Or perhaps, is there a win32 API for this purpose and can be called from a 
> perl script?

That should probably be 'keep_alive', to be pedantic. However, that will only 
work as long as the files are to be downloaded from the same site (or a small 
number of sites), and that site doesn't drop the connection, which it may well 
do if it doesn't like the idea of 'thousands and thousands' of its files being 
hoovered.

If the OP has permission from the site owner, then that's fine, otherwise what 
he is proposing could be considered rude, or even abusive. Were the OP 
downloading from google maps, for example, he might find that they don't like 
the idea of anybody downloading a lot of files in a short period (see 
https://developers.google.com/maps/faq#usagelimits).


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: Need help with TK DirTree

2012-10-29 Thread Brian Raven
Not the first time a question like this has been asked. Take a look at this 
link, which may point you in a useful direction.

http://www.perlmonks.org/?node_id=170334

--
Brian Raven

From: perl-win32-users-boun...@listserv.activestate.com 
[mailto:perl-win32-users-boun...@listserv.activestate.com] On Behalf Of Daniel 
Burgaud
Sent: 28 October 2012 01:12
To: Perl-Win32-Users
Subject: Need help with TK DirTree

Hi

I am writing a Perl "File Manager" app using TK and DirTree to navigate the 
folders.

$frame->Scrolled( 'DirTree', -command => [\&ListDir]  )->pack( -side => 
'right', -expand => 1, -fill => 'x', );

Here is my problem:

The above will only list the current Drive. It would not allow me to switch 
from "C" to "D" or any other drives i have.

Is there a way to tell DirTree to list from the root?

Dan



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: Is there a range of Standard Perl Exit Codes?

2012-08-15 Thread Brian Raven

From: perl-win32-users-boun...@listserv.activestate.com 
[mailto:perl-win32-users-boun...@listserv.activestate.com] On Behalf Of Ashley 
Hoff
Sent: 15 August 2012 03:52
To: perl-win32-users@listserv.activestate.com
Subject: Is there a range of Standard Perl Exit Codes?

> Greetings All,
> This info seems to be harder to find then I expected, but is there a range of 
> standard exit codes that relate > to Perl keeling over itself?  I have been 
> using my own exit codes where necessary, but am getting some cross
> pollination with the exit codes that Perl assigns itself.  All I want to do 
> is ensure that exit codes that I
> assign are well out of that range.

There could be others, but the only references to exit codes that I am aware of 
are in 'perldoc perlrun' and 'perldoc -f die'.

As far as I can see, the only exit code that perl itself assigns is when 
compilation fails, or it detects a run time error, and the only one I recall 
seeing is 255. Other exit codes are as a result of calls to die or exit by the 
script (including any modules used), including the implied exit(0) when it 
falls off the end.

>From what 'perldoc -f die' says, the exit code could, in theory, be pretty 
>much anything. If you wanted to make the exit code as a result of calling die 
>more predictable, you could try intercepting it by setting $SIG{__DIE__}. You 
>could then call exit with whatever code you wanted, after you have output the 
>error message, that is. However, I would be careful about doing this as there 
>could be some odd side effects, depending on how the modules that you use 
>behave.

It might be worth looking for alternate method of achieving your desired 
result, which isn't entirely clear.

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: trouble understanding/using file handle in a sub routine

2012-08-10 Thread Brian Raven
> -Original Message-
> From: perl-win32-users-boun...@listserv.activestate.com [mailto:perl-
> win32-users-boun...@listserv.activestate.com] On Behalf Of Greg Aiken
> Sent: 10 August 2012 01:22
> To: Perl-Win32-Users@listserv.activestate.com
> Subject: trouble understanding/using file handle in a sub routine
>
> i am using IO::File so that i can use the seekable feature to set the
> file pointer position.
>
>$OUT_BINARY = new IO::File "> test.file";
>binmode ($OUT_BINARY)
>
> if i execute this, the write works:
>
>print $OUT_BINARY $data;
>
> what i want to do (for the sake of pointing out the problem) is to
> instead turn the print statement into a subroutine - where i would call
> it passing in $OUT_BINARY (the file handle) and $data (the data to
> write).
>
> the sub looks like this:
>
>sub write_fp_data {
>
>   #called with:
>   #   file pointer = $_[0]
>   #   data value = $_[1]
>
>   #this attempts to do the write - but fails
>   print $_[0] $_[1];#line 101
>}
>
> and the call to the sub, looks like this:
>
>&write_fp_data($OUT_BINARY, $data);
>
> this all seems 'simple enough', though when using this with the sub
> bombs with:
>
> Scalar found where operator expected at FILE2.PL line 101, near "] $_"
> (Missing operator before  $_?)
> syntax error at FILE2.PL line 101, near "] $_"
> Execution of FILE2.PL aborted due to compilation errors.
>
> im certain this must have something to do with my using $_[0] versus
> $OUT_BINARY in the sub routine - but i cant see what is wrong with this
> code.  would be most appreciative if anyone can see the glaring
> problem!

Perl is misinterpreting your print statement. See 'perldoc -f print' for some 
hints on making your intentions clear.

Note that you don't need IO::File in order to seek. The file descriptor 
returned by open can be positioned by the seek function just fine. In fact, the 
documentation for IO::File says that the single argument constructor is just a 
front tend for open.

Also, hopefully your function does more than just the print statement, 
otherwise there is no point to it. In which case, it might be better to assign 
the parameters to local variables with appropriate names, rather than relying 
on a comment. For example...

sub write_fp_data {
my $file_pointer = shift;
my $data_value = shift;
print $file_pointer $data_value;
}

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: Okay, hand me my dunce-cap

2012-06-25 Thread Brian Raven
From: perl-win32-users-boun...@listserv.activestate.com 
[mailto:perl-win32-users-boun...@listserv.activestate.com] On Behalf Of 
Rothenmaier, Deane
Sent: 15 June 2012 16:48
To: perl-win32-users@listserv.ActiveState.com
Subject: Okay, hand me my dunce-cap

> foreach my $key (124..155) {
>$cs_keys{$key} =~ s{/Zones/}{/Lockdown_Zones/}
> }
>
> I just got hung up on using the map line...

Perhaps I am missing something, but sequential numeric keys suggest array 
rather than hash to me.

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: win32 and modifying a file

2012-06-08 Thread Brian Raven
From: perl-win32-users-boun...@listserv.activestate.com 
[mailto:perl-win32-users-boun...@listserv.activestate.com] On Behalf Of Greg 
Aiken
Sent: 07 June 2012 23:08
To: Perl-Win32-Users@listserv.activestate.com
Subject: win32 and modifying a file

> dear win32 perl users, ive never actually known how to 'modfiy' a file using 
> perl on win32.  up till now, ive > always read file1, found the data i 
> intended to change, and have always created a new file 2 containing the
> changes.  if i wanted to 'simulate' changing file1, when done i could rename 
> file2 to file1.  in other words, > ive never learned how to modify a file 
> directly.
>
> ive read win32 makes it more difficult to do this than on unix os's.
>
> but in any case, today i wanted to ask the group.
>
> assumming 'file1' exists with the following 3 records in it:
>
> A
> B
> C
>
> is there a 'simple' code fragment someone could post that would demonstrate 
> iterating through this file and
> when record 'B' is encountered, we want to change 'B' to 'B_modified' - done 
> in a way where we only access
> 'file1'.  maybe this cant be done, but im asking.
>
> yes i do realize there is another approach, upserp contents of 'file1' modify 
> in memory, delete 'file1', then > recreate it by dumping the in-memory 
> modified contents.  this seems more like a 'hack' than a direct
> manipulation of the original file.

I would call editing a file in place, without a backup, more of a hack. 
Depending on how valuable your data is, making it possible to perform a 
rollback in the event of a problem seems sensible. So, however you do it, 
keeping a backup of the original may be a good idea.

As for the how to do it part, Tie::File has already been suggested, which may 
be a good fit for what you want to do. If your file is small enough to fit in 
memory, then File::Slurp may be worth a look, particularly the edit functions.

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: dbd-anydata - i cant get it to INSERT new records

2012-05-11 Thread Brian Raven
From: perl-win32-users-boun...@listserv.activestate.com 
[mailto:perl-win32-users-boun...@listserv.activestate.com] On Behalf Of Greg 
Aiken
Sent: 11 May 2012 01:15
To: Perl-Win32-Users@listserv.activestate.com
Subject: dbd-anydata - i cant get it to INSERT new records

> dear win32 perl users,

...

> use DBI;
> use DBD::AnyData;
>
> my $dbh = DBI->connect('dbi:AnyData(RaiseError=>1):');
>
>
> #i am trying to insert new record to an existing tab delimited file
> #'oldfile.txt' is an ascii encoded two line file:
> #FIELD1\tFIELD2\n
> #abc\tdef\n
>
> $dbh->func('insertnewrecstooldfile', 'Tab', 'oldfile.txt', 'ad_import');
>
>
>
> #test 1   - attempt using DO with hard-coded 'values'
>
> #$return1 = $dbh->do("INSERT INTO insertnewrecstooldfile (FIELD1,FIELD2) 
> VALUES ('ghi', 'jkl')");
> #print "return1 = $return1\n";
> #$dbh->disconnect;
> #exit;
>
> #result: returns 1, but the file does NOT contain the new record!

>From a quick look at the documentation ('perldoc DBD::AnyData'), it looks like 
>you are creating an in memory table with ad_import, but I can see no sign of 
>the updated table being saved with ad_export. Possibly ad_catalog would do 
>what you want.

[N.B. I haven't used DBD::AnyData, but it looks interesting. Thanks for the 
pointer.]

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: Hash Key function puzzlement -- a point of information query

2012-05-03 Thread Brian Raven

From: perl-win32-users-boun...@listserv.activestate.com 
[mailto:perl-win32-users-boun...@listserv.activestate.com] On Behalf Of 
Rothenmaier, Deane
Sent: 03 May 2012 17:08
To: perl-win32-users@listserv.ActiveState.com
Subject: Hash Key function puzzlement -- a point of information query

> Gurus,
>
> Given something like this:
>
> #!Perl
> use strict;
> use warnings;
>
> my %hash; keys(%hash) = 128;

You have changed the number of hash buckets, not the number of keys.

>
> print "hash has " . scalar(keys(%hash)) . " keys\n";
>
> I should see a printed value of 128, wouldn't you think? But no, it prints: 
> "hash has 0 keys".  What's up wit > dat? What obvious thing am I missing?

That's correct, because you have not added any keys.

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: :localxxxxxlabel

2012-03-22 Thread Brian Raven
> -Original Message-
> From: perl-win32-users-boun...@listserv.activestate.com [mailto:perl-
> win32-users-boun...@listserv.activestate.com] On Behalf Of Duffy, Peter
> Sent: 22 March 2012 15:27
> To: Duffy, Peter; 'perl-win32-users@listserv.ActiveState.com'
> Subject: CGI::localxlabel
>
> Sorry, I've got "local" on the brain at the moment ...
>
> For CGI::local in the below, please read CGI::label
>
> -Original Message-
> From: perl-win32-users-boun...@listserv.activestate.com [mailto:perl-
> win32-users-boun...@listserv.activestate.com] On Behalf Of Duffy, Peter
> Sent: 22 March 2012 14:45
> To: 'perl-win32-users@listserv.ActiveState.com'
> Subject: CGI::local
>
> Apologies in advance for what is probably a braindead question
>
> I'm hitting a weird problem with the CGI.pm module under Windows: to
> cut a very long story short, we're moving a package of perl code from
> one server to another. Everything works fine on the old one, but on the
> new, the web client seems to hang whenever a cgi script tries to output
> the html for a checkbox. Setting $XHTML in the CGI.pm module to 0 seems
> to make it work OK.
>
> The problem seems to be that, when $XHTML is set, the checkbox routine
> tries to call CGI::local - and this call never returns. What is
> baffling me is that CGI::local doesn't seem to be defined anywhere -
> but a test script to use CGI and then call CGI::local compiles and runs
> OK - so it must be finding it somewhere.
>
> I'm obviously missing something! Could someone explain to me where
> CGI::local is defined, and how perl finds it?

Being an html tag, the function to generate it is probably autoloaded. A case 
insensitive search of CGI.pm for 'autoload' may give a bit more insight.

It's possible that your web client doesn't handle xhtml, which is the default 
style now. In which case it is probably better to specify the -no_xhtml pragma 
rather than editing CGI.pm. See 'perldoc CGI' for details.



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: directory listing of "Computer" on win32

2012-03-14 Thread Brian Raven
From: perl-win32-users-boun...@listserv.activestate.com 
[mailto:perl-win32-users-boun...@listserv.activestate.com] On Behalf Of Daniel 
Burgaud
Sent: 13 March 2012 22:53
To: Perl-Win32-Users
Subject: directory listing of "Computer" on win32

> Hi All,
>
> I am clueless how to do a directory list starting at the very root "Computer" 
> which includes all drives.
>
> What I am doing to get a directory tree is this:
> my $directory = "";
>opendir DIR, $directory;
>my @files = readdir DIR;
>closedir DIR;
>
> But it only start at one drive - not all drives. I am missing out on where to 
> start the initial directory.
>
> My main goal is to get all the drives on my computer, so I can do a directory 
> tree on those drives.

To get the logical drives you can use GetLogicalDriveStrings in Win32API::File 
(see the documentation for that module). You will probably need to stat them to 
make sure that they have a valid file system.

I would use File::Find rather than opendir/readdir to traverse the files and 
directories on a drive. Take a look at the documentation for that module as 
well.

For example...

use strict;
use warnings;

use Win32API::File qw{GetLogicalDriveStrings};
use File::Find;

my $dstring;
my $olen = GetLogicalDriveStrings(26*4+1, $dstring);
my @drives = map {s|\\|/|g; $_}
 grep {stat($_)}
 split "\000", $dstring;
print "Drives [@drives]\n";

find(sub { print "$File::Find::name\n"; },
 @drives);

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: perl pattern match option 's' (coerce . to include \n)

2012-03-08 Thread Brian Raven
From: perl-win32-users-boun...@listserv.activestate.com 
[mailto:perl-win32-users-boun...@listserv.activestate.com] On Behalf Of Greg 
Aiken
Sent: 08 March 2012 15:36
To: perl-win32-users@listserv.activestate.com
Subject: Fwd: perl pattern match option 's' (coerce . to include \n)

> hello all,
>
> i read how one may include 's' at end of a pattern match to essentially 
> redefine '.' to include the 'newline
> character'.
>
> today i found a code fragment whereby someone presents how they extract flate 
> encoded streams from pdf files
> using a regex whereby he is using the 's' option.
>
> the problem is that for the particular test pdf file i am trying to process, 
> the definition of 'newline' is
> only (hexOD)
>
> in general, i read that the definition of 'newline' may vary by os, to be 
> either of several values:
> (hex0D)(hex0A) windows
> (hexOD) as in the case of this particular pdf file, or
> (hexOA) for some other operating systems
>
> so is there a way one can go one step further to not only use the 's' pattern 
> match option, but to then also
> define what the actual definition of 'newline' is supposed to be - so as to 
> guarantee a match of what you are > intending to match?
>
> i am familiar with 'input line seperator' $/ (which would be used for reading 
> input from files), and with
> 'output line seperator' $\ (which would be used for - print "something\n", as 
> in writing to files).  but ive
> never heard of the 'pattern matching seperator' - which i think i would need 
> in this case.

Without the /s modifier, . matches any character except \n. With the /s 
modifier, . matches any character including \n. So, unless you need to capture 
the newlines, why would you care?

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: pattern match 'or' operator |

2012-03-08 Thread Brian Raven
From: perl-win32-users-boun...@listserv.activestate.com 
[mailto:perl-win32-users-boun...@listserv.activestate.com] On Behalf Of Greg 
Aiken
Sent: 08 March 2012 15:32
To: perl-win32-users@listserv.activestate.com
Subject: pattern match 'or' operator |

> in pdf files evidently there are two different ways  one may specify the 
> 'length' operator
>
> sometimes one sees;
> \Length
>
> while at other times, the letter L is sufficient;
> \L
>
> i am wanting to do a pattern match for a line of data in a pdf file where i 
> am looking to match EITHER \L or
> \Length
>
> is there a way that using ONE pattern match I can say achieve something like 
> this?
>
> in pseudo code:
>   $record =~ /'Length' | 'L'/
> (where the precedence would be towards the first thing matched, in this case, 
> 'Length')
>
> the only example ive seen which uses the or operator (|), shows this working 
> for a single character only, as
> in:
>   $record =~ /a|b/
>
> ive never seen an example quite like what I would like to do...
>
> if it cant be currently done, perhaps a future enhancement to regex could be 
> in order, by adding a new
> enclosing 'literal delimiter', something like this could one day work 
> (forgive me here, im just thinking
> outside of the box - only as i dont know any better);
>
>   $record =~ /'Length' | 'L'/
>
> thanks for helping me with my understanding of this.

Assuming trailing white space, then qr{\\L(ength)?\b} should match both. 
However, depending on what you are trying to achieve, it might be advisable to 
use a module that knows how to parse PDF files.

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: Quick memory-recovery question--a point of information

2012-03-08 Thread Brian Raven
From: perl-win32-users-boun...@listserv.activestate.com 
[mailto:perl-win32-users-boun...@listserv.activestate.com] On Behalf Of 
Rothenmaier, Deane C.
Sent: 08 March 2012 15:00
To: perl-win32-users@listserv.ActiveState.com
Subject: Quick memory-recovery question--a point of information

> Hi, gurus. This should be an easy one, and it is a minor one... I have an 
> array which is declared and used
> inside a lexical scope, viz.:
>
> {
> my @chunk = split( /\n/, $data_line); # $data_line is a chunk of "lines", 
> separated by newlines, in one scalar > string.
>   ...
>   # Do stuff with members of @chunk
>   ...
>   undef @chunk;
> }
>
> Now here's my question, am I gaining anything in terms of memory use by 
> explicitly undef-ing the array, or can > I expect more or less the same 
> result if I just leave disposing of the array's memory to leaving the scope?
> The Camel tells me that undef @x recovers the memory allocated to @x, and 
> that leaving a scope does, well,
> something, to the allocation of a variable declared inside the scope, but is 
> mute on whether the net result is > the same.

I would expect the undef to be unnecessary. Unless you stored a reference to 
the array somewhere during that scope, it will get garbage collected when the 
scope exits. If you wanted to recover the memory before the end of scope for 
some reason, although I can't think of a good one one at the moment, then by 
all means use undef, or possibly @chunk = ().

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: accessing other file version information

2012-01-31 Thread Brian Raven
From: perl-win32-users-boun...@listserv.activestate.com 
[mailto:perl-win32-users-boun...@listserv.activestate.com] On Behalf Of Geoff 
Horsnell
Sent: 31 January 2012 14:15
To: perl-win32-users@listserv.activestate.com
Subject: accessing other file version information

> Further to my previous email, I can now access the "File Version" information.

Glad to hear it.

> However, is there a general (or any) access method for the other "info" 
> fields that Perlapp allows one to set? > Can one retrieve the "Comments" 
> field for example?

If you are using either Win32::Exe or Win32::File::VersionInfo, as mentioned 
before, then the documentation for both suggests that Comments should be easily 
retrieved, assuming it is there.

http://search.cpan.org/~mdootson/Win32-Exe-0.17/lib/Win32/Exe.pm#get_version_info
http://search.cpan.org/~alexeyt/Win32-File-VersionInfo-0.03/VersionInfo.pm


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: Using the --info data from Perl

2012-01-30 Thread Brian Raven
From: perl-win32-users-boun...@listserv.activestate.com 
[mailto:perl-win32-users-boun...@listserv.activestate.com] On Behalf Of Geoff 
Horsnell
Sent: 30 January 2012 14:32
To: perl-win32-users@listserv.activestate.com
Subject: Using the --info data from Perl

> Is there any way that I can access the fields set by the perlapp -info 
> parameter? I am thinking of setting the > product version via this method, 
> and wonder if I can then access that field from within the Perl program I am 
> > compiling. Is it possible?

Never used perlapp, so there may be a better way.

Assuming that you can locate the executable ($0 perhaps), then either 
Win32::File::VersionInfo or Win32::Exe should get you that.

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: Window 7 x64, @inc search question

2012-01-09 Thread Brian Raven

From: perl-win32-users-boun...@listserv.activestate.com 
[mailto:perl-win32-users-boun...@listserv.activestate.com] On Behalf Of Styma, 
Robert E (Robert)
Sent: 09 January 2012 14:02
To: Jan Dubois; perl-win32-users@listserv.ActiveState.com
Subject: RE: Window 7 x64, @inc search question

> Well I tried upgrading to the newest Perl 5.14 which is also 64 bit
> capable.  I discovered that Tk.pm is not yet available from ppm.
> So I backed off to 5.12 which says Tk.pm is available on the ppm
> web site.  For reasons I have not yet figured out, I get timeouts
> accessing ppm4.activestate.com.

Firewall/proxy settings?

That address gets me redirected to http://code.activestate.com/ppm. Looking up 
Tk suggests that the latest version (804.030) fails to build, and the previous 
version (804.029) fails some tests for Perl 5.14. Which is a shame. Fortunately 
for me all of my Tk scripts are all on Linux.

Do you feel up to building it yourself? The above suggests that 804.029 might 
be the version to try, if you think you can live with the failed tests.


> Just as a slightly off topic question.  Since my original question was
> answered with a top post, is this acceptable on this list?  The guys on
> the Fedora lists get all bent out of shape if someone top posts.

My preference with regard to top posting is probably with the Fedora guys, as 
this post might suggest. However, a lot of the posters to this list seem to 
prefer top posting (or just use a mail agent that encourages it). I would 
complain, but I think I would be swimming against the tide. Plus, I can find 
more interesting things to do than get worked up about it.

> There are various references to incompatibilites between pm modules
> on 5.6 and 5.14 although I have not gotten far enough (not havimg Tk) to
> be sure if any of them affect the local .pm modules in my site.lib.  Is there
> a summary of what sort of things break between 5.6 and 5.14?
> Sorting that out from the release notes is about as effective as ploughing
> ahead and just debugging.

The might be something in the delta documentation for core modules (see perldoc 
perl.*delta). For non core modules, their Changes file might be useful.

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: RE: File::Find::Rule problem

2011-12-14 Thread Brian Raven
> -Original Message-
> From: perl-win32-users-boun...@listserv.activestate.com [mailto:perl-
> win32-users-boun...@listserv.activestate.com] On Behalf Of
> arvinport...@lycos.com
> Sent: 13 December 2011 21:10
> To: kl...@psu.edu
> Cc: perl-win32-users@listserv.ActiveState.com
> Subject: Re: RE: File::Find::Rule problem
>
> > I have tried running both scripts without being able to reproduce the
> > problem. But then I am running Perl 5.14.1 and File::Find::Rule
> > version 0.33, so it could be version specific.
> >
> > I notice that the Changes file for the module has...
> >
> > 0.33 Monday 19th September, 2011
> > Fixes the case where name("foo(*") hits an error with mismatched
> > parentheis. Reported by Jan Engelhardt.
> >
> > It might be worth upgrading File::Find::Rule to the later version
> > (Perl as well, if you can). It might make a difference.
> >
> > HTH
> >
> >
> > --
> > Brian Raven
> >
>
> Thank you both so much for testing this. Nice to know I'm not crazy or
> stupid - this time. I also realize I posted this to the win32 mailing
> list by mistake, so double thanks for helping out.
>
> I've upgraded to version 0.33 and I'm getting better results with plain
> strings, so yes, the version was the precise issue. I still can't make
> it work reliably passing in qr// regular expressions though. I'm
> creating a module for somebody else who's just learning perl. I want
> them to be able to pass in plain strings to exclude directories with no
> need to escape meta characters but also wanted to give the option to
> pass in regular expressions in case that level of control might be
> needed. So the plain string part is working perfectly now with the
> upgrade. What I will do is create separate methods, one for plain
> strings, the other for regex strings and compile the latter in the back
> end as you do in your example.

There is no need to escape meta characters, or compile a string into a regex, 
as File::Find::Rule::name does that anyway to any parameter that isn't a regex 
(using Text::Glob::glob_to_regex - check the source).

Can you say more about your problem with regular expressions? A small example 
perhaps?

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: File::Find::Rule problem

2011-12-13 Thread Brian Raven
t;
> =
> ==  1a >>(?-xism:Kland\,\ Dan)<<
>
> D:/My Documents/projects/dave/test/should-print.txt
>
> =
> ==  1b >>Kland, Dan<<
>
> D:/My Documents/projects/dave/test/should-print.txt
>
> =
> ==  2a >>(?-xism:\(Kland\,\ Dan\))<<
>
> D:/My Documents/projects/dave/test/should-print.txt
>
> =
> ==  2b >>(Kland, Dan)<<
>
> D:/My Documents/projects/dave/test/should-print.txt
>
> =
> ==  3a >>(?-xism:84\-33)<<
>
> D:/My Documents/projects/dave/test/should-print.txt
>
> =
> ==  3b >>84-33<<
>
> D:/My Documents/projects/dave/test/should-print.txt
>
> =
> ==  4a >>(?-xism:84\-33\ )<<
>
> D:/My Documents/projects/dave/test/should-print.txt
>
> =
> ==  4b >>84-33 <<
>
> D:/My Documents/projects/dave/test/should-print.txt
>
> =
> ==  5a >>(?-xism:84\-33\ \(Kland\,\ Dan\))<<
>
> D:/My Documents/projects/dave/test/should-print.txt
> D:/My Documents/projects/dave/test/84-33 (Kland, Dan)/test.pl D:/My
> Documents/projects/dave/test/84-33 (Kland, Dan)/test.pl~
>
> =
> ==  5b >>84-33 (Kland, Dan)<<
>
> D:/My Documents/projects/dave/test/should-print.txt
> D:/My Documents/projects/dave/test/84-33 (Kland, Dan)/test.pl D:/My
> Documents/projects/dave/test/84-33 (Kland, Dan)/test.pl~
>
> =
> ==  6a >>(?-xism:84\-33\ Kland\,\ Dan)<<
>
> D:/My Documents/projects/dave/test/should-print.txt
> D:/My Documents/projects/dave/test/84-33 (Kland, Dan)/test.pl D:/My
> Documents/projects/dave/test/84-33 (Kland, Dan)/test.pl~
>
> =
> ==  6b >>84-33 Kland, Dan<<
>
> D:/My Documents/projects/dave/test/should-print.txt
> D:/My Documents/projects/dave/test/84-33 (Kland, Dan)/test.pl D:/My
> Documents/projects/dave/test/84-33 (Kland, Dan)/test.pl~
>
> =
> ==  7a >>(?-xism:84\-32)<<
>
> D:/My Documents/projects/dave/test/should-print.txt
> D:/My Documents/projects/dave/test/84-33 (Kland, Dan)/test.pl D:/My
> Documents/projects/dave/test/84-33 (Kland, Dan)/test.pl~ D:/My
> Documents/projects/dave/test/84-33 Kland, Dan/test2.pl
>
> =
> ==  7b >>84-32<<
>
> D:/My Documents/projects/dave/test/should-print.txt
> D:/My Documents/projects/dave/test/84-33 (Kland, Dan)/test.pl D:/My
> Documents/projects/dave/test/84-33 (Kland, Dan)/test.pl~ D:/My
> Documents/projects/dave/test/84-33 Kland, Dan/test2.pl
>
> =  END OF OUTPUT  ==
>
> It appears that the parentheses are being ignored.
> The following names, produce the same results.
> And, they never seem to eliminate the directory with the parentheses.
>
> ==  5a >>(?-xism:84\-33\ \(Kland\,\ Dan\))<< ==  5b >>84-33 (Kland,
> Dan)<< ==  6a >>(?-xism:84\-33\ Kland\,\ Dan)<< ==  6b >>84-33 Kland,
> Dan<<
>
> Also, the following should not have excluded the directory "84-33
> Kland, Dan", but it did.
> ==  2a >>(?-xism:\(Kland\,\ Dan\))<<
>
> So, there does seem to be something amiss.
>
> Ken

I have tried running both scripts without being able to reproduce the problem. 
But then I am running Perl 5.14.1 and File::Find::Rule version 0.33, so it 
could be version specific.

I notice that the Changes file for the module has...

0.33 Monday 19th September, 2011
Fixes the case where name("foo(*") hits an error with mismatched
parentheis.  Reported by Jan Engelhardt.

It might be worth upgrading File::Find::Rule to the later version (Perl as 
well, if you can). It might make a difference.

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: Capturing STDERR (Specifically from Getopt::Long)

2011-12-02 Thread Brian Raven
From: perl-win32-users-boun...@listserv.activestate.com 
[mailto:perl-win32-users-boun...@listserv.activestate.com] On Behalf Of Ashley 
Hoff
Sent: 02 December 2011 01:47
To: perl-win32-users@listserv.ActiveState.com
Subject: Capturing STDERR (Specifically from Getopt::Long)

> Greetings,
> I have been playing around with Getopt::Long and really want to capture the 
> STDERR message to a variable when > a non-existent argument is used.  I will 
> use this variable to form the basis of an email and log entry when
> the script falls over, instead of just issuing a die command.
> Initially, I started with the code found here -
> http://www.perlhowto.com/parsing_command_line_parameters_with_getopt_long to 
> see if I could get it
> working.  While the code in itself works, the print statement "print "Unknown 
> option: @_\n" if ( @_ );" in the > subroutine doesn't seen to work (example 
> code below from above link):
> [code]
> #!/usr/bin/perl
> use Getopt::Long;
>
> my ($help, @url, $size);
>
> #-- prints usage if no command line parameters are passed or there is an 
> unknown
> #   parameter or help option is passed
> usage() if ( @ARGV < 1 or
>  ! GetOptions('help|?' => \$help, 'url=s' => \@url, 'size=i' => 
> \$size)
>  or defined $help );
>
> sub usage
> {
>  print "aUnknown option: @_\n" if ( @_ );
>  print "usage: program [--url URL] [--size SIZE] [--help|-?]\n";
>  exit;
> }
> [/code]

Not entirely surprising, as sub is called with no arguments, i.e. @_ is empty. 
That example does not appear to have been tested very well!

> I have also tried closing the STDERR and then writing the STDERR to a 
> variable, but this seemed to screw up
> the STDERR for the rest of the script:
> [code]
> #!/usr/bin/perl
> use Getopt::Long;
>
> my $sleep = "";
> my $size = 0;
> my $debug = 0;
> my $message = "";
>
> close(STDERR);
> open(STDERR, ">>", \$message) or die "can't open\n";
> GetOptions('sleep=s' => \$sleep, 'size' => \$size, 'debug' => \$debug);
> print "It was no good with $message\n";
> print "test another line\n";
> opendir (DIRS,"C:\\asdf") or die "died $!\n";
> [/code]

By screwed up, did you mean that the original STDERR has been closed?

> I have also tried to close and reopen the STDERR.
> What would the be the easiest way to capture the STDERR from Getopt::Long, to 
> be re-used later, without
> breaking STDERR?
> By the way, I am using Perl V5.8.9

The easiest way may be to use a temporary $SIG{__WARN__} handler to capture 
warnings from GetOptions, e.g. something like...

{
# Capture warnings from GetOptions
local $SIG{__WARN__} = sub { $message .= $_[0];};
GetOptions('sleep=s' => \$sleep, 'size' => \$size, 'debug' => \$debug);
}

That should work as long as GetOptions uses 'warn' to report errors.

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: Re:Problem with regex

2011-11-17 Thread Brian Raven
> -Original Message-
> From: perl-win32-users-boun...@listserv.activestate.com [mailto:perl-
> win32-users-boun...@listserv.activestate.com] On Behalf Of Barry Brevik
> Sent: 17 November 2011 17:29
> To: perl Win32-users
> Subject: Re:Problem with regex
>
> ...
>
> Yes, I've been convinced to use Text::CSV, but for some reason the
> ActiveState ppm does not actually install it. It complains about not
> being able to find some other module that it depends on.

Don't know if it helps, but I seem to have installed Text::CSV_XS on 
Activestate 5.14.1 build 1401.


--
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 error msg

2011-11-07 Thread Brian Raven
--
Brian Raven

> -Original Message-
> From: perl-win32-users-boun...@listserv.activestate.com [mailto:perl-
> win32-users-boun...@listserv.activestate.com] On Behalf Of Barry Brevik
> Sent: 04 November 2011 23:56
> To: perl Win32-users
> Subject: Help with error msg
>
> I've been programming Perl for quite a while, but I've just recently
> started to 'use strict' because, well it seems like the right thing to
> do.

It almost always is. Keep it up.

>
> However, I'm getting this runtime error: "Use of uninitialized value in
> join or string at test56.pl line 40." Line 40 is the one where the same
> message is in the comment.

I think that is a warning rather than an error, i.e. nothing to do with 'use 
strict'. 'use warnings' is good for you, and your code, as well.

>
> I realize that the sample code has some elements specific to my
> environment, but it is the best I could do, and it is pared down quite
> a
> bit.
>
> Thanks,
> Barry Brevik
> --
> use strict;
> use warnings;
> use Win32::ODBC;
> use Win32::Console;
>
> # Un-buffer STDOUT.
> select((select(STDOUT), $| = 1)[0]);
>
> # Set up a DSN-less connection.
> my $connectStr = "DRIVER=Microsoft ODBC for Oracle; SERVER=prod;
> UID=APPS; PWD=apps";
>
> my $SQLsentence = < select
>   fa.asset_number
> , fa.asset_description
> , fa.manufacturer_name
> , fa.serial_number
> , fa.owned_leased
> , fa.new_used
> , fa.category_description
>
> from
>   fafg_assets fa
>
> order by
>   fa.category_description, fa.asset_description
> SQL
>
> getOutFile();
>
> if (my $db = new Win32::ODBC($connectStr))
> {
>   # Execute our SQL sentence.
>   unless ($db -> Sql($SQLsentence))
>   {
> # Loop through the table.
> while (scalar $db -> FetchRow(1, SQL_FETCH_NEXT))
> {
>   my @data = $db -> Data();
>
>   print OUTFILE '"', (join '","', @data), '"', "\n";
> }
>   }
>
>   $db -> Close();
> }
>
> #
> sub getOutFile
> {
>   my $filename = "c:\\temp\\asset.csv";
>
>   if (open OUTFILE, '>', $filename)
>   {
> print "  Output file $filename has been CREATED.\n\n";
>   }
> }

I can't accurately identify the line from your description, but the join 
statement seems a likely candidate. If so, it looks like your call to 
$db->Data() is returning one or more undef values, probably from a null field 
in your database. To avoid such warning you need to check for undefs. If you 
just want to replace them with something printable, then something like this 
could do the trick...

my @data = map {$_ ||= "NULL"} $db -> Data();

HTH



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: How to split up a string with carriage returns into an array

2011-11-07 Thread Brian Raven

From: perl-win32-users-boun...@listserv.activestate.com 
[mailto:perl-win32-users-boun...@listserv.activestate.com] On Behalf Of Paul 
Rousseau
Sent: 04 November 2011 20:38
To: perl Win32-users
Subject: RE: How to split up a string with carriage returns into an array

...

> I forgot to mention I use the following code to assign $msg.
>
> $msg = $element->as_trimmed_text();
>
> (where element points to this line in an htm file.)

Try using some other means of getting the test, for example $element->as_text. 
See 'perldoc HTML::Element' for more info.

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: How to Extract a Date from a File

2011-11-03 Thread Brian Raven

> -Original Message-
> From: perl-win32-users-boun...@listserv.activestate.com [mailto:perl-
> win32-users-boun...@listserv.activestate.com] On Behalf Of Brian Raven
> Sent: 03 November 2011 10:37
> To: perl Win32-users
> Subject: RE: How to Extract a Date from a File
>
> From: perl-win32-users-boun...@listserv.activestate.com [mailto:perl-
> win32-users-boun...@listserv.activestate.com] On Behalf Of Paul
> Rousseau
> Sent: 02 November 2011 16:08
> To: perl Win32-users
> Subject: How to Extract a Date from a File
>
> ...

> Using regular expressions is not usually recommended.

Sorry that should read " Using regular expressions is not usually recommended 
for parsing HTML."


--
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: How to Extract a Date from a File

2011-11-03 Thread Brian Raven
From: perl-win32-users-boun...@listserv.activestate.com 
[mailto:perl-win32-users-boun...@listserv.activestate.com] On Behalf Of Paul 
Rousseau
Sent: 02 November 2011 16:08
To: perl Win32-users
Subject: How to Extract a Date from a File

> Hello Perl folks,
>
>
> I would like to know if there is an eloquent way of extracting a date string 
> from a file.
>
> My code goes like this:
>
>   open (INFILE, "<$sourcedir\\$filename") || die "Can not open 
> $sourcedir\\$filename $!\n";
>   @filecontents = ;
>   close INFILE;
>   @filecontents = map {chomp; $_} @filecontents;
>
> #
> # Within the file contents, look for the text, CurrentWeekLabel
> #
> # Here is a text sample.
> #
> #   
> # id="CurrentWeekLabel">Week Of:
>  style="font-weight:bold;">2011/10/29 -  style="font-weight:bold;">2011/11/04
> # id="PreviousWeekLinkButton"
> class="LinkButton" href="javascript:OnPreviousWeekLinkButtonClick ()"
> href="javascript:__doPostBack('PreviousWeekLinkButton','')">Prev id="Label20"> |  
> onclick="SelectWeekButtonClick('PopupCalendar1', 'SelectWeekLinkButton'); 
> return false;"
> id="SelectWeekLinkButton" class="LinkButton" 
> href="javascript:__doPostBack('SelectWeekLinkButton','')">Select > 
> Week |  class="LinkButton"
> href="javascript:OnNextWeekLinkButtonClick ()"
> href="javascript:__doPostBack('NextWeekLinkButton','')">Next
> # class="StatusLabel">
> #   
> #
> # Obtain the year, month and day following the text, StartWeekLabel
> #
>  @ans = grep (/StartWeekLabel.+\>(\d{4})\/(\d{2})\/(\d{2})\<\/span/si, 
> @filecontents);
> #
> # Build the start date from the matches.
> #
> $start_date = $1 . $2 . $3
>
> I was wondering if there was a neat way to avoid using @ans as a temporary 
> variable, and extract the
> "2011/10/29" straight into $start_date so that $start_date = "20111029"

Using regular expressions is not usually recommended. Prefer to use the modules 
that specialise in doing that. Also, there may be alternate ways to extract the 
date elements, and modules to validate them. For example...

---
use strict;
use warnings;

use HTML::TreeBuilder;
use Date::Calc qw{check_date};

my $root = HTML::TreeBuilder->new_from_file(*DATA);
defined $root or die "Failed to parse\n";
my $element = $root->look_down("id", "StartWeekLabel");
defined $element or die "Failed to locate id=StartWeekLabel\n";
my $rawdate = $element->as_trimmed_text();
print "Raw date '$rawdate'\n";
my @date = split "/", $rawdate;
if ((check_date(@date))) {
print "Date looks OK: '", @date, "'\n";
}
else {
print "That date looks invalid\n";
}

__DATA__

Week Of: 2011/10/29 - 2011/11/04
Prev | Select Week | Next


---

--
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: Making directories

2011-10-26 Thread Brian Raven
> -Original Message-
> From: perl-win32-users-boun...@listserv.activestate.com [mailto:perl-
> win32-users-boun...@listserv.activestate.com] On Behalf Of Barry Brevik
> Sent: 24 October 2011 23:53
> To: perl-win32-users@listserv.ActiveState.com
> Subject: Making directories
>
> I'm still on Perl v5.8.8. I was writing an app today that needs to
> create a sub directory if it does not already exist.
>
> Originally, I used  mkdir(  ). Notice that there is no 2nd arg.
> After I did this, the app copies a bunch of files into that sub
> directory, which works fine. HOWEVER, when the same app tries to write
> newer copies of the same files (named the same), I get a "permission
> denied" error.
>
> So I changed the app by setting the umask, and also specifying a
> permissions mask in the mkdir function (see below). I deleted the sub
> directory and ran the new app. Now the sub directory seems to be wide
> open, but when you click on the directory and check properties, it has
> Read Only checked!
>
> I am uncomfortable using unix permission masks on a Windows machine,
> but
> at the same time I would rather not load a module for such a simple
> thing.
>
> Does anyone have advice for me about how they create directories with
> Perl?
>
> Barry Brevik
>
> =
> use strict;
> use warnings;
>
> umask 0;
>
> my $thisPath = "c:\\temp\\megabom\\newdir";
>
> unless (-d $thisPath) {mkdir $thisPath, 0777;}
>
> if (-r $thisPath) {print "  Sub folder is read for everyone.\n\n";}
> if (-w $thisPath) {print "  Sub folder is write for everyone.\n\n";}
> if (-x $thisPath) {print "  Sub folder is execute for everyone.\n\n";}

I understand that the read only attribute on a directory only prevents its 
deletion, but I could be wrong about that. That, and the fact that your first 
copy is successful, suggests that you have an issue with file permissions 
rather than directory permissions. That is the files being copied are read 
only, which is why the second copy fails.

The answer probably depends on how you are copying files. For example, 
according to the doco, File::Copy::cp preserves the original permissions while 
File::Copy::copy sets default permissions on the target.

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: GuiTest and Locked Screen

2011-09-21 Thread Brian Raven

> -Original Message-
> From: perl-win32-users-boun...@listserv.activestate.com [mailto:perl-
> win32-users-boun...@listserv.activestate.com] On Behalf Of Edwards,
> Mark (CXO)
> Sent: 19 September 2011 03:21
> To: Perl-Win32-Users (perl-win32-users@listserv.ActiveState.com)
> Subject: GuiTest and Locked Screen
>
>
> I have a simple Win32::GuiTest example where I find a Notepad window,
> print its handle and title and then send some keys to it.   When I open
> Notepad and the run the script I see...
>
> 4915356: Untitled - Notepad
>  Notepad pops up on top of other windows and "Testing 123" shows up in
> Notepad as expected.
>
> Here's the problem.  I need this to work with the screen locked.  When
> I lock the screen and give it time to run, I still get the handle and
> window title but no keys get sent to Notepad.  It seems like it never
> get set as the foreground window since it's not on top after I unlock
> the screen.
>
> I tried SetForegroundWindow, SetActiveWindow and SetFocus but none
> seems to make it the current window.
>
> Any suggestions?
>
> ###
> ##
> use warnings;
> use strict;
> use Win32::GuiTest qw(SetFocus SetActiveWindow FindWindowLike
> SetForegroundWindow SendKeys GetWindowText);
>
> sleep 15;  #Give me time to lock the screen
> my ($winid)=FindWindowLike(0, "Notepad");
> print "$winid: ", GetWindowText($winid), "\n";
> #SetForegroundWindow($wind);
> #SetActiveWindow($winid);
> SetFocus($winid);
> sleep 3;
> SendKeys("Testing 123~");

AIUI, Win32::GuiTest works by sending window events to specific windows, as the 
windowing system does. It doesn't entirely surprise me that locking the screen, 
and therefore the windowing system, prevents that from working. It's kind of 
what locking the screen is designed to do.

Another method of communicating with, or controlling, the other application 
that doesn't use the windowing system might work better. OLE, for example.

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

2011-09-08 Thread Brian Raven
> -Original Message-
> From: perl-win32-users-boun...@listserv.activestate.com [mailto:perl-
> win32-users-boun...@listserv.activestate.com] On Behalf Of Barry Brevik
> Sent: 07 September 2011 18:48
> To: Tobias Hoellrich; perl-win32-users@listserv.ActiveState.com
> Subject: RE: Help with array
>
> The Camel book seems to say that splice will only remove or change
> elements and move them *down* if necessary.
>
> You must think I'm a raging newb, but I gotta admit, I've never used
> splice. Thanks, I'll check it out!

Everybody's a 'newb' at stuff that haven't tried before. It might help to think 
of inserting elements into an array as replacing a section of length 0, when 
you read 'perldoc -f splice'.

It might also be worth taking a look at slices, described in 'perldoc perldata'.

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: Keyboard handler

2011-09-02 Thread Brian Raven
> -Original Message-
> From: perl-win32-users-boun...@listserv.activestate.com [mailto:perl-
> win32-users-boun...@listserv.activestate.com] On Behalf Of Barry Brevik
> Sent: 01 September 2011 17:33
> To: perl-win32-users@listserv.ActiveState.com
> Subject: Keyboard handler
>
> This is a bit of a selfish post, but since list traffic is low right
> now, here goes.
>
> I'm developing a routine that essentially loops looking for keyboard
> input. If it has any, it processes the key otherwise it performs some
> other (short) processes and loops around again to check for keyboard
> input.
>
> I've been writing a routine that uses Win32::Console in the manner
> shown
> below.
>
> Anyway, writing this has become way complex, and I've lost my way. I'm
> wondering if anyone out there has some example code that they would be
> willing to share?
>
> Barry Brevik
> =
> my $STDIN = new Win32::Console(STD_INPUT_HANDLE);
> $STDIN->Mode(ENABLE_PROCESSED_INPUT);
>
> while (1)
> {
>   # Read keyboard event.
>   my @input = $STDIN->Input();
>   if (defined $input[0] and $input[0] == 1)
>   {
> 
>   }
>
>   
> }

Not sure what you mean. That code doesn't see very complex.

In case you haven't spotted them, there are a few FAQs that may help. See 
'perldoc -q key' to start with.

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: List vs. Array

2011-08-22 Thread Brian Raven
> -Original Message-
> From: perl-win32-users-boun...@listserv.activestate.com [mailto:perl-
> win32-users-boun...@listserv.activestate.com] On Behalf Of David
> Jelinek
> Sent: 19 August 2011 21:35
> To: perl-win32-users@listserv.ActiveState.com
> Subject: Re: List vs. Array
>
> On 08/19/2011 04:24 PM, Barry Brevik wrote:
> > Since list traffic seems to be overly light, I'll post this slightly
> > off-topic query.
> >
> > All of my Perl books seem to use the word "list" and "array"
> > interchangeably. Is there a difference between a list and an array?
> > (believe it or not, I'm not a newb).
> Here's a link that discusses the topic:
> https://www.socialtext.net/perl5/array_vs_list

Also a FAQ. See 'perldoc -q "list.*array"'.

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: MS Access Update Memo Field with 750 characters

2011-07-07 Thread Brian Raven
> -Original Message-
> From: perl-win32-users-boun...@listserv.activestate.com [mailto:perl-
> win32-users-boun...@listserv.activestate.com] On Behalf Of Claus Kick
> Sent: 07 July 2011 11:49
> To: Perl-Win32-Users@listserv.ActiveState.com
> Subject: MS Access Update Memo Field with 750 characters
>
> Hello everyone,
>
> I am having troubles with updating a memo field in an access database.
>
> Currently I am using the following
>
> my $dbh = DBI->connect("dbi:ADO:$dsn", $user, $password, $att ) or die
> $DBI::errstr;
>
> sub update_country_releases
> {
>   my $db = shift;
>
>   foreach (keys %country_releases)
>   {
>   my $primkey = $_.":ZZZ";
>   my $sth = $db->prepare('UPDATE PROD_INT set COUNTRY =
> \''.$country_releases{$_}.'\' where ROW_ID = \''.$primkey.'\'');
>   $sth->execute;
>   if ($sth->errstr)
>   {
>   print $sth->errstr;
>   }
>   }
> }
>
> No error during insert. However, I have written a test sub routine
> which compares what should be there with what actually is in the
> database.
> This sub routine returns an error. Looking into it, I realized that
> the only difference is the length of the value.

Is it possible that the SQL parser is changing the strings? One way to avoid 
that is to use parameter binding. Also, I suggest using Perl's quoting 
operators which can make your SQL statements easier to read. So, assuming 
RaiseError => 1 when you connect, your sub could look something like this.

sub update_country_releases {
my $db = shift;

my $sql = qq{UPDATE PROD_INT set COUNTRY = ? where ROW_ID = ?};
my $sth = $db->prepare($sql);

foreach (keys %country_releases) {
$sth->execute($country_releases{$_}, $_ . ":ZZZ");
}
}

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: Writing To Win Event Logs using Win32::EventLog

2011-04-13 Thread Brian Raven
From: perl-win32-users-boun...@listserv.activestate.com 
[mailto:perl-win32-users-boun...@listserv.activestate.com] On Behalf Of Ashley 
Hoff
Sent: 13 April 2011 07:56
To: perl-win32-users@listserv.ActiveState.com
Subject: Writing To Win Event Logs using Win32::EventLog


> Hello,
> First time reader, first time poster.
> I am trying to use Win32::EventLog to write out to the Windows Event Log (via 
> the $handle->Report() method)
> and am having issues with getting the description (as viewed by the windows 
> Event Viewer) right.
> Initially, I was getting the standard Windows message "The description for 
> Event ID ( n ) in Source ( My
> Source) cannot be found. The local computer may not have the necessary 
> registry information or message DLL
> files to display messages from a remote computer." message.  I hacked the 
> registry under
> "Hkey_Local_Machine=>System=>CurrentControlSet=>Services=>EventLog=>Application=>My
>  Source" to include the
> following: EventMessageFile = %SystemRoot%\System32\EventCreate.exe.  (Well, 
> it wasn't really a hack.  In my
> Perl script, I sent a simple information event to the log, using EventCreate 
> via a cmd call, which registered > the above).
> While this has worked to get rid of the above message and the additional 
> information I want included, I am now > getting the box standard MS response 
> "For more information, see Help and Support Center at >
> http://go.microsoft.com/fwlink/events.asp.";  While this one is less confusing 
> then the above, it's probably
> something that I would rather not be there.
> I also tried to hack the registry using the PerlMsg.dll, but this didn't work 
> (I had a return to the original > message) and was simply a guess and a real 
> long shot.
> I am using the ActivePerl 5.8.9 distribution.  I also have PDK V9 available.  
> This is all installed on a
> Windows XP SP3 box.
> Does anyone have any advice/methods on getting exactly what I want written to 
> the Event Logs?
> Cheers and thanks in advance.
> Ashley

This link may help.

http://www.perlmonks.org/?node_id=737505

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: 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, 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 
>
> And program can be called as -  --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: trying to create first simple perl 'filter' program on windows

2011-03-04 Thread Brian Raven


From: perl-win32-users-boun...@listserv.activestate.com 
[mailto:perl-win32-users-boun...@listserv.activestate.com] On Behalf Of Glenn 
Linderman
Sent: 04 March 2011 00:18
To: perl-win32-users@listserv.ActiveState.com
Subject: Re: trying to create first simple perl 'filter' program on windows

> On 3/3/2011 4:07 PM, Greg Aiken wrote:
> im wanting to write a simple perl 'filter' program in windows.
> I basically took the base code found here...
>
>
> when invoked as a true filter, type test.txt | filter.pl, it croaks with 'the 
> process tried to write to a
> nonexistent pipe'.
>
> I am not sure if what I am trying to do can be achieved with such simple code 
> on windows.
>
> Bug in your version of Windows.  Workaround:type test.txt | perl filter.pl

More likely a bug (or feature?) of the command shell. It works using the cygwin 
shell, as long as you put the appropriate line at the start of your script, 
e.g. "#!c:/perl/bin/perl".

Another work around is to turn your script into a batch file. See the provided 
script pl2bat for help with that.

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: regex like option *values*

2011-03-03 Thread Brian Raven
> -Original Message-
> From: p sena [mailto:senapati2...@yahoo.com]
> Sent: 03 March 2011 15:40
> 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.
>>
>> HTH
>> --
>> Brian Raven
>
> Thanks Brian,
>
> This solution should work only for brackets irrespective of numbers or
> strings inside them right? The curly braces are not required it seems.
>
> This feature is not there in Getopt::Long and can this be implemented
> in it or it is configurable from it?

As I said, see 'perldoc Getopt::Long'. A small change to the suggestion in 
"Tips and Techniques" would look like..

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

I haven't tried it but it looks like it should work.

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: regex like option *values*

2011-03-03 Thread Brian Raven
> -Original Message-
> From: perl-win32-users-boun...@listserv.activestate.com [mailto:perl-
> win32-users-boun...@listserv.activestate.com] On Behalf Of p sena
> Sent: 02 March 2011 17:16
> To: perl-win32-users@listserv.ActiveState.com
> Subject: regex like option *values*
>
> Hi,
>
> I want to use option and values like:-
>
> --option_name abc0[1-9].ctr.{pad,spd}.set.in
>
> or --option_name abc[01-22].ctr.{pad,spd}.set.in
>
> or --option_name abcL{1,2,3}.ctr.{pad,spd}.set.in
>
> or --option_name abcL[1,2,3].ctr.{pad,spd}.set.in
>
> or --option_name abcL{1,2,3}.ctr.{70,001}.set.in
>
> etc possibilities. This should in fact expand those option values into
> the right number of values/quantities i,e; --option_name will hold
> multiple values. Instead of supplying values one after another I just
> want to club them in a regex like style. I am already using Getopt::Long.
>
> What could be best way to handle this type of passing option values?
> Is there any existing module for this ?

I could be wrong, but I doubt that an existing module would do what you want. 
Generating all possible strings that match a regex is hard in the general case, 
if not impossible.

However, if you limit the expressions you want to expand and simplify your 
syntax a bit, it's not too difficult. Here's a quick hack that, I think, does 
pretty much what you want.

---
use strict;
use warnings;

while () {
chomp;
print "Expanding: $_\n";
my @result = expand_string($_);
print "$_\n" for @result;
}

# Expand string to array of strings based on lists & ranges in square
# brackets. Note recursion not strictly necessary, but it simplifies
# the code.
sub expand_string {
my $str = shift;
my @result;
if ($str =~ /^(.*?)\[([^]]+)\](.*)$/) {
my ($pre, $post) = ($1, $3);
my @bits = expand_list($2);
foreach my $bit (@bits) {
push @result, expand_string("$pre$bit$post");
}
}
else {
push @result, $str;
}
return @result;
}

# Return array from comma separated list of strings and ranges.
sub expand_list {
my @vals = split /\s*,\s*/, $_[0];
my @result;
foreach my $v (@vals) {
if ($v =~ /^([^-]+)-([^-]+)$/) {
push @result, eval "'$1'..'$2'";
die $@ if $@;
}
else {
push @result, $v;
}
}
return @result;
}

__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.

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: isue with file-find and search/replace function

2011-02-28 Thread Brian Raven
From: perl-win32-users-boun...@listserv.activestate.com 
[mailto:perl-win32-users-boun...@listserv.activestate.com] On Behalf Of Conor 
Lillis
Sent: 28 February 2011 11:27
To: perl-win32-users@listserv.ActiveState.com
Subject: isue with file-find and search/replace function

> HI all
> I have an issue where I am trying to replicate a folder structure to another 
> server with a different root
> folder structure.
> Basically what I have is as follows:
> Source dir = c:\temp
> Dest dir = linux file system (so I need to strip the c:\temp from the SCP 
> command I am generating)
> Here is the script

use strict;
use warnings;

> my $dir = "c:\\temp";

Try "c:/temp"

> chomp($dir);
> print "The folder name is $dir\n\n";
> find(\&UploadStuff, $dir);
> sub UploadStuff
> {
>my $file = $_;
>my $currentdir = $File::Find::dir;
>my $currentfile = $File::Find::name;
>if (!-d $file)
>{
>my $scpfile = $file;
>print "Current Dir before stripping path\t- $currentdir\n";
>$currentdir =~ s/$dir//i;
>print "scpfile = $scpfile\nCurrent Dir after stripping path\t- 
> $currentdir\n";
>exit;
>}
> }
> And output :
> The folder name is c:\temp
> Current Dir before stripping path   - c:\temp/SMTPSVCLOG
> scpfile = smtpsvc_20100228.log
> Current Dir after stripping path- c:\temp/SMTPSVCLOG

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: spurious deaths in script execution due to read-only Config?

2011-02-23 Thread Brian Raven
-Original Message-
From: perl-win32-users-boun...@listserv.activestate.com
[mailto:perl-win32-users-boun...@listserv.activestate.com] On Behalf Of
Christian Walde
Sent: 23 February 2011 15:57
To: perl-win32-users@listserv.activestate.com
Subject: Re: spurious deaths in script execution due to read-only
Config?

...

> Try reading the whole bug i linked. It has a detailed description of
what happens and when and where the 
> offending error is triggered and how it can be prevented.
>
> Summary:
>
> Grep makes $_ point at $Config{foo}, on first load ActivePerl::Config
tries to load File::Basename, which 
> triggers Exporter.pm, which goes "local $_". At THAT point an attempt
to autovivify is made causing the whole > thing to crash down.
>
> Solution: Make sure $_ isn't pointing at %Config when Exporter.pm
happens. This can be done as simple as this:
>
>  map { require ActiveState::Path } 1;
>
> (Though i'm sure more elegant solutions exist.)

Right, I hadn't followed that link.

I do recall 'perldoc perlsub' warning about localising tied hashes &
arrays being broken, and %Config::Config is a tied hash, I believe.

Regarding your work around. Map in a void context is usually frowned
upon. Perhaps grep or possibly ...

for ('now') { require ActiveState::Path }

... should have the same effect, i.e. aliasing $_ to something
(hopefully) innocuous.

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: spurious deaths in script execution due to read-only Config?

2011-02-23 Thread Brian Raven
-Original Message-
From: perl-win32-users-boun...@listserv.activestate.com
[mailto:perl-win32-users-boun...@listserv.activestate.com] On Behalf Of
Chris Wagner
Sent: 23 February 2011 14:25
To: perl-win32-users@listserv.activestate.com
Subject: Re: spurious deaths in script execution due to read-only
Config?

> It's the standard behavior of Perl.
>
> use Data::Dump "pp"; 
> %a = qw/x 1 y 1 z 1/;
> grep { $_ } $a{bob};
> pp %a;
> ^D
> ("y", 1, "bob", undef, "x", 1, "z", 1)
>
>
> At 02:18 PM 2/22/2011 +0100, Christian Walde wrote:
> >On Tue, 22 Feb 2011 13:46:55 +0100, Chris Wagner
 wrote:
> >> At 08:54 PM 2/21/2011 +0100, Christian Walde wrote:
> >>>  use Config;
> >>>  # print 1 if $Config{foo}; # enabling this removes the crash
> >>>  grep { $_ } $Config{bar}; # this crashes
> >>>
> >>> These two lines on their own will cause ActivePerl of any version
to exit
> >>> with the error message above.
> >>Hi.  U can't do that because Perl must autovivify $Config{bar} in
order to
> >> have a value to put into $_.  HTH.
> >
> >Good guess, that's almost what happens. The problem happens a bit
deeper in
> the guts and is actually caused by Exporter.pm, where it tries to do
local
> $_ and by doing so triggers autovivification. (grep/map only do an
aliasing
> of %Config to $_, which is fine.)
> >
>> I remembered this morning that there is a bug tracker for ActivePerl,
> started to write up an error report and in doing so ended up
formulating a
> possible for for ActiveState:
http://bugs.activestate.com/show_bug.cgi?id=89447

While autovivication is part of Perl's normal behaviour, I'm not sure
that it is cause of this problem. The fact that un-commenting the line
before the grep in the OP's code makes the problem go away tends to
confirm this.

I suspect that it is related to the Activestate overriding of Config
('use diagnostics' will give a stack trace) but I can't see how it
causes that error, i.e. "%Config::Config is read-only".

Note that inhibiting the activestate override
($ENV{ACTIVEPERL_CONFIG_DISABLE} = 1) also seems to make the problem go
away.

Maybe somebody from Activestate has a clue.

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: Invalid type 'Q' in pack

2011-02-15 Thread Brian Raven
-Original Message-
From: perl-win32-users-boun...@listserv.activestate.com
[mailto:perl-win32-users-boun...@listserv.activestate.com] On Behalf Of
Mark Dootson
Sent: 15 February 2011 03:39
To: Michael Cohen
Cc: perl-win32-users@listserv.ActiveState.com
Subject: Re: Invalid type 'Q' in pack

> Hi,
>
> There is no Q template for 32bit Perl as you have noticed.
>
> One solution may be 
>
> define your struct as two DWORDS for each DWORD64, then split and join

> as necessary in your Perl code.
>
> 'pack' and 'unpack' are your friends in splitting / joining your
DWORD64 
> / DWORDs
>
> If you could get at the pack / unpack inside Win32::API::Struct 
> directly, then 'a8' would work as a replacement for 'Q' I think.
Spoken 
> without testing of course.
>
> regards
>
> Mark
>
>
>
> On 15/02/2011 02:54, Michael Cohen wrote:
> > I am trying to replace an old and unsupported Win32 library. In
doing
> > so, I am attempting to get the following piece of code to work prior
to
> > adding it to my own library:
> >
> >  Cut Here -
> > #!/usr/bin/perl -w
> > use strict;
> >
> > use Win32;
> > use Win32::API;
> >
> > Win32::API::Struct->typedef('MEMORYSTATUSEX', qw(
> > DWORD dwLength;
> > DWORD dwMemoryLoad;
> > DWORD64 ullTotalPhys;
> > DWORD64 ullAvailPhys;
> > DWORD64 ullTotalPageFile;
> > DWORD64 ullAvailPageFile;
> > DWORD64 ullTotalVirtual;
> > DWORD64 ullAvailVirtual;
> > DWORD64 ullAvailExtendedVirtual;
> > ));
> >
> > Win32::API->Import('kernel32',
> > 'BOOL GlobalMemoryStatusEx(LPMEMORYSTATUSEX lpBuffer)');
> >
> > # my $memoryInfo = Win32::API::Struct->new('MEMORYSTATUSEX');
> > tie my %memoryInfo, 'Win32::API::Struct', 'MEMORYSTATUSEX';
> >
> > my $rc = GlobalMemoryStatusEx(\%memoryInfo);
> >
> > printf ("TotalPhys = %d\n", $memoryInfo{ullTotalPhys});
> >
> > print ("Finished\n");
> >
> >  Cut Here -
> >
> > When I try to run this program on a x86 version of ActivePerl 5.8.9
> > Build 828, I get the error:
> > Invalid type 'Q' in pack at C:/Perl/lib/Win32/API/Struct.pm line
230.
> > when it gets to line 25 (actual call of the Win32 API).
> >
> > Since I need to run this bit of code on both the 32-bit and 64-bit
> > Windows, how can I get this to work?
> >
> > API Info: http://msdn.microsoft.com/en-us/library/aa366589

I would say that it is primarily an issue with Win32::API::Type which
seems to specify Q/q as the template character for a number of types
that are (I think) valid for 32 bit windows. It should perhaps either
provide a suitable diagnostic if support for 64 bit integer values is
not available, or perform the necessary conversion. You might want to
take that up with the module's maintainer.

I don't know if it is possible/practical to build a 32 bit version of
Perl with support for 64 bit integers. That would either be a question
for Activestate, or you if you want to try building Perl yourself.

I agree with the Mark's suggested work around of using 2 DWORDs instead
of DWORD64, with some extra work at your end to combine them. I leave
determining the word order as an exercise for the reader, but you may
also want to consider using Math::BigInt to store the combined values,
just to be on the safe side.

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: experiencing Out of memory errors

2011-01-26 Thread Brian Raven
-Original Message-
From: perl-win32-users-boun...@listserv.activestate.com
[mailto:perl-win32-users-boun...@listserv.activestate.com] On Behalf Of
John Deighan
Sent: 26 January 2011 15:18
To: perl-win32-users@listserv.ActiveState.com; us...@httpd.apache.org;
modp...@perl.apache.org
Subject: experiencing Out of memory errors

> We have an Apache/mod_perl application running under Windows Server
2003
> that periodically experiences
> "Out of memory" errors (they appear in the Apache error logs) which
> forces Apache to restart. Our application does, in fact, use a lot of
> memory, and we believe that this is not due to a bug or memory leak.
> What we would like is to run this application in a 64 bit environment,
thus
> allowing us to use more than the 2 GB memory that the Apache process
('httpd')
> is limited to (the "Out of memory" errors always occur as the memory
usage
> of the httpd process approaches this 2 GB limit).
>
> We know that we will need to run a 64 bit version of Windows on 64 bit
> hardware to accomplish this. Furthermore, we know that ActiveState has
a
> binary Perl install of a 64 bit Perl. However, we're not aware of
either a
> 64 bit Apache (though recently I found the blackdot site -
> http://www.blackdot.be/ - that provides a Windows compatible binary
build
> of 64 bit apache, though I know very little about it) or a 64 bit
mod_perl.
> However, we're also not sure if either of these are needed to escape
the
> 2 GB memory limitation. E.g., can 64 bit Perl be used with a 32 bit
> Apache and/or mod_perl?
>
> Any help with accomplishing what we need would be greatly appreciated,
> including the possibility of hiring someone on a contract basis to
> help us.

Unless it is fairly easy to create a 64 bit setup, it might be worth
expending some effort in checking whether your belief that you don't
have a memory leak is sustainable. This may help.

http://modperlbook.org/html/14-2-6-Memory-Leakage.html

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: Where's Tk?

2010-12-17 Thread Brian Raven
-Original Message-
From: activeperl-boun...@listserv.activestate.com
[mailto:activeperl-boun...@listserv.activestate.com] On Behalf Of Brian
Raven
Sent: 17 December 2010 17:25
To: Sisyphus; activep...@activestate.com;
perl-win32-us...@activestate.com
Subject: RE: Where's Tk?

> ...
> 
> I had already added the bribes repository, but ppm (gui and command
> line) reports zero packages. However a fully qualified manual install,
> as suggested on the bribes web site, i.e.
> 
> ...

Just a quick follow-up. I deleted the bribes repo from ppm and added it
again. My ppm now sees the packages in the bribes repo. Whatever was
stopping it before seems to have gone away now.


-- 
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: Where's Tk?

2010-12-17 Thread Brian Raven
-Original Message-
From: Sisyphus [mailto:sisyph...@optusnet.com.au] 
Sent: 16 December 2010 22:26
To: Brian Raven; activep...@activestate.com;
perl-win32-us...@activestate.com
Subject: Re: Where's Tk?

> - Original Message - 
> From: "Brian Raven" 
> To: ; 
> Sent: Friday, December 17, 2010 12:02 AM
> Subject: Where's Tk?
>
>
> >I have Activestate Perl 5.12.2 (build 1202) installed. I can see some
Tk
> > extension packages in the PPM gui, but no sign of Tk itself.
> > 
> > Is there a problem, or is just me looking in the wrong place?
>
> There's a ppm package for Tk-804.029 at the bribes repo.
> You should be able to grab it with:
>
> ppm repo add bribes
> then
> ppm install Tk

I had already added the bribes repository, but ppm (gui and command
line) reports zero packages. However a fully qualified manual install,
as suggested on the bribes web site, i.e.

ppm install http://www.bribes.org/perl/ppm/Tk.ppd

worked just fine. Tk is now installed.

Thanks to Sysyphus for the pointer, and to everybody else that
responded.


-- 
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


Where's Tk?

2010-12-16 Thread Brian Raven
I have Activestate Perl 5.12.2 (build 1202) installed. I can see some Tk
extension packages in the PPM gui, but no sign of Tk itself.

Is there a problem, or is just me looking in the wrong place?


-- 
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: does anyone know how to get a TRUE ntfs directory listing? usingPerl, or otherwise

2010-12-10 Thread Brian Raven
From: perl-win32-users-boun...@listserv.activestate.com 
[mailto:perl-win32-users-boun...@listserv.activestate.com] On Behalf Of Jan 
Dubois
Sent: 09 December 2010 20:00
To: gai...@visioninfosoft.com; perl-win32-users@listserv.ActiveState.com
Subject: RE: does anyone know how to get a TRUE ntfs directory listing? 
usingPerl, or otherwise

> From: perl-win32-users-boun...@listserv.activestate.com 
> [mailto:perl-win32-users-
> boun...@listserv.activestate.com] On Behalf Of Greg Aiken
> Sent: Thursday, December 09, 2010 11:43 AM
> To: perl-win32-users@listserv.ActiveState.com
> Subject: does anyone know how to get a TRUE ntfs directory listing? using 
> Perl, or otherwise
> >
> > does anyone know how to;
> >
> > a. get a TRUE ntfs directory listing?  meaning listing all of the files 
> > and/or directories found at any 
> > given directory level?
> > ...

> You can run `dir /a` to see files with the "system" and "hidden" attributes, 
> but you will still not see the 
> NTFS metadata entries.  They cannot be manipulated at the file system level 
> and are rather pointless to copy 
> as some of their content depends on the disk geometry (think "file allocation 
> table").
>
> There are many other things to consider though: there is file system 
> redirection happening when you run 32-bit > apps on 64-bit Windows, there are 
> "alternate data streams" on files etc.

What Jan said, especially about copying, plus...

Sysinternals (http://technet.microsoft.com/en-us/sysinternals/default) has some 
utilities that will give you info on NTFS meta data files and ADS. There is 
even a Perl module on CPAN (and hopefully on PPM) to help with ADS 
(Win32::StreamNames).

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: how to best convert an array containing hexadecimal values to asciivalue?

2010-11-24 Thread Brian Raven
From: perl-win32-users-boun...@listserv.activestate.com 
[mailto:perl-win32-users-boun...@listserv.activestate.com] On Behalf Of Greg 
Aiken
Sent: 23 November 2010 21:44
To: perl-win32-users@listserv.ActiveState.com
Subject: how to best convert an array containing hexadecimal values to 
asciivalue?

> and im kind of lost with pack...  ive unsuccessfully tried...
>
> $ascii_string = pack("H*", @hex_array) and 
> $ascii_string = pack("h*", @hex_array) 
>
> but neither yields the proper output.
>
> I know I could write an ultra low level code that directly converts each hex 
> byte to decimal, then call chr 
> with the decimal value, but certainly that's 'too much work' in perl.
>
> any help would be appreciated.
>
> it would be as if were starting with 
>
> @hex_array = ('5c','00','3f','00','3f','00','5c','00','53','00',...);

Your are not too far out with pack, as it happens, but you haven't got it quite 
right. Your template only unpacks the first string in the array. Try:

$ascii_string = pack("(H2)*", @hex_array);

Have another read through 'perldoc -f pack'. I usually have to whenever I use 
it.

Also, I notice that all of your characters seem to be followed by a null byte. 
Are these perhaps 16 bit characters, or will you strip the null bytes out at 
some point?

-- 
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: Checking for Available Port

2010-11-02 Thread Brian Raven
Edwards, Mark (CXO) <mailto:mark.r.edwa...@hp.com> wrote:
> I thought of something like that but would rather implement it using
> some kind of Perl socket routine.  I'll be using this on Windows and
> different flavors of Unix and the output format of netstat differs.  

It does differ, but not by much in my experience. I expect that it would
be simpler to manage the differences in netstat output than the
differences in discovering information about open sockets from different
operating systems. Those OS differences are (mostly) encapsulated by
netstat. For example, the following seems to work on Win32 and Linux.

sub tcp_port_state {
my $port_to_check = shift;
foreach (`netstat -na`) {
next unless /tcp/i;
my ($local, $state) = get_tcp_fields($_);
my $port = (split /:/, $local)[-1];
if ($port == $port_to_check) {
return $state;
}
}
return "NOT IN USE";
}

sub get_tcp_fields {
my @flds = split " ", $_[0];
if ($^O =~ /cygwin|win32/i) {
return @flds[1,3];
}
else {
return @flds[3,5];
}
}

Also, I notice that there is a module, Net::Netstat::Wrapper, that may
be of interest.

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: Checking for Available Port

2010-11-01 Thread Brian Raven
Edwards, Mark (CXO) <> wrote:
> I'm writing a simple port listener script using
> 
> $local=IO::Socket::INET->new(Proto=>"tcp",
> LocalPort=>$port,
> Listen=>1,
> Reuse=>1,) or die "Can't open listening port: $!\n";
> 
> Everything works fine except I want to check to see if the port is
> available before I try to open it.  In some cases, if the machine is
> already listening on a port, the script dies as expected.  In other
> cases the script runs but isn't really listening.  Sometimes it takes
> over a LISTENING port.  I want to check for LISTENING or ESTABLISHED
> ports. 

Use something like `netstat -na`. For example:

sub tcp_port_state {
my $port_to_check = shift;
foreach (`netstat -na`) {
next unless /tcp/i;
my ($proto, $local, $remote, $state) = split;
my ($ip, $port) = split /:/, $local;
if ($port == $port_to_check) {
return $state;
}
}
return "NOT IN USE";
}

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: lame question "\\\\.\\pipe\\pipename" vs '\\.\pipe\pipename'

2010-10-20 Thread Brian Raven
From: perl-win32-users-boun...@listserv.activestate.com
[mailto:perl-win32-users-boun...@listserv.activestate.com] On Behalf Of
Greg Aiken
Sent: 20 October 2010 18:10
To: perl-win32-users@listserv.activestate.com
Subject: lame question ".\\pipe\\pipename" vs '\\.\pipe\pipename'

> forgive my ignorance here, but I thought single quoted, or
apostrophized [however you call this character] (') text strings were
supposed to be 
> interpreted by perl in an unaltered manner.
> 
> sample code, indicating how to reference a named pipe in the
Win32::Pipe module, shows something like this...
> 
> ".\\pipe\\pipename  " (note enclosed in
quotes)
> 
> I thought the excessive quantities of backslashes seemed silly, so I
instead used single quotes and tried...
> 
> '\\.\pipe\pipename' (note enclosed in apostrophies)
> 
> only to find that my client pipe program did not work.
> 
> I then did a simple test print program;
> print '\\.\pipe\pipename';
> 
> and I was surprised to see what actually printed to the screen was
instead;
> \.\pipe\pipename (note the first \ is not shown in output!)
> 
> this explained why my client pipe program was working...
> 
> but it left me scratching my head to ask, "why is the backslash
character being interpreted as a special perl operator when it is found
within 
> apostrophies?"   
> 
> I thought that only happened when the backslash is found within
quotes, such as (print "\x43"), which should print a capital C

>From 'perldoc perldata':

String literals are usually delimited by either single or double quotes.
They work much like quotes in the standard Unix shells: double-quoted
string literals are subject to backslash and variable substitution;
single-quoted strings are not (except for \' and \\).

Unless you are using the string as a command line argument, then /
should work, and not need escaping.

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: Win32::OLE on MS Word using Selection.Find.Execute

2010-09-13 Thread Brian Raven
Peter Buck <> wrote:
>   Does anyone have an example of a perl script acting on MS Word
> documents using Win32::OLE and Selection.Find.Execute?  I have read
> the  
> Win32 man page but its examples for Excel and Access don't help.  I
> found a Powershell script that does what I want but can't translate.
> The parts I'm confused on are (1) setting the parameters used in the
> Selection.Find.Execute() invocation (particularly the boolean values,
> since perl doesn't do booleans) and the actual invocation of
> Selection.Find.Execute().  
> 
> I did find an example using $search-> Execute() but this doesn't
> appear to allow setting all the parameters that
> Selection.Find.Execute() does.  
> Also, it operates on $doc-> Content->Find while
> Selection.Find.Execute() operates on $doc->Selection (if I'm right). 
> And I'm using Homekey(6) to take me to the top of the document, which
> is linked to Selection and doesn't seem to work in my
> $doc->Content->Find attempts.
> 
> Any help or direction to documentation much appreciated.

The primary documentation for OLE apps is the Visual Basic Reference.
The OLE browser supplied with Activestate Perl is also very useful, I
find. Other than that, googling for examples can be useful, followed by
an amount of trial and error. The amount of trial and error needed will
depend on how closely the results of your googling match what you are
trying to do.

> 
> Thanks - Toolsmith
> 
> # ExpandAcronyms.ps1
> # read acronym list, expand acronyms in target MS Word document #
> syntax: ExpandAcronyms wordDocument 
> 
> function make-change {
>  $FindText = $args[0]
>  $FullText = $args[1]
>  $ReplaceText = "$FullText ($FindText)"
> 
>  $ReplaceAll = 1
>  $FindContinue = 1
>  $MatchCase = $True
>  $MatchWholeWord = $True
>  $MatchWildcards = $False
>  $MatchSoundsLike = $False
>  $MatchAllWordForms = $False
>  $Forward = $True
>  $Wrap = $FindContinue# don't want it wrapping, wish I
> knew 
> what this meant
>  $Format = $False
> 
>  $objWord.Selection.HomeKey(6) > Null
>  $result = $objSelection.Find.Execute($FindText,$MatchCase,
>  $MatchWholeWord,$MatchWildcards,$MatchSoundsLike,
>  $MatchAllWordForms,$Forward,$Wrap,$Format,
>  $ReplaceText,$ReplaceAll)
>   if ( $result -eq $true ) {
>   "$Findtext|$FullText"
>  }
> 
> }
> 
> if ( $args.count -lt 1 ) {
>  cd $env:temp
>  $strWordFile = [string](resolve-path(Read-Host "Enter Path of
>  Word file to be processed")) } else { $strWordFile =
> [string](resolve-path($args[0])) } 
> 
> 
> $objWord = New-Object -ComObject word.application
> $objWord.Visible = $True
> $objDoc = $objWord.Documents.Open($strWordFile)
> 
> $objSelection = $objWord.Selection
> 
> $d = get-content "d:/temp/acronyms.txt"# read file of acronym
> | 
> definition
> foreach ( $l in $d ) {
>  ($acro, $def) = $l.split('|')# build
> array 
> of acronym, definition
>  make-change $acro $def
> }
> "Finished"
> $objWord.Selection.HomeKey(6) > Null

That looks like shell script rather than Perl (Powershell perhaps?).
Your Perl code would have been more useful.

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: Changing Subject color using MIME::Lite

2010-08-23 Thread Brian Raven
From: perl-win32-users-boun...@listserv.activestate.com
[mailto:perl-win32-users-boun...@listserv.activestate.com] On Behalf Of
A F
Sent: 22 August 2010 18:31
To: Howard Tanner
Cc: perl-win32-users@listserv.ActiveState.com
Subject: Re: Changing Subject color using MIME::Lite

> Is there any other mail module that allows that? 

The colour that a subject is displayed in is a function of your MUA
(e.g. Outlook, Thunderbird etc...), and not (directly) dependant on the
contents of the email, which is a text only medium, and 7 bit ASCII at
that (see http://tools.ietf.org/rfc/rfc5322.txt). Your MUA may be
capable of being configured to display subjects in different colours
based on either the subject text, or a header field, as already
suggested. As far as I am aware there is no standard for this, so for
your idea to work you emails will have to be read by a specific
configuration of a specific MUA. If that's not possible or feasible,
then you may want to rethink your requirement.
 
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: Need help with TK: scrollable adjustable columns of text

2010-08-19 Thread Brian Raven
From: perl-win32-users-boun...@listserv.activestate.com
[mailto:perl-win32-users-boun...@listserv.activestate.com] On Behalf Of
Daniel Burgaud
Sent: 19 August 2010 04:19
To: Perl-Win32-Users
Subject: Need help with TK: scrollable adjustable columns of text

> hi
> 
> I am trying to write a TK application that will display a scrolled
text 
> with adjustable columns similar to the PPM's display.
> 
> currently, what I have researched is using pannedwindow.
> however this is good for simple labels wherein one side isnt
> sync to the other.
> 
> What i need is scrolledtext + adjustable columns.

I am not entirely clear what you are asking for, but have you looked at
Tk::Hlist? It doesn't have adjustable columns, but I notice that there
is a Tk::Hlistplus on CPAN which looks like it does. It seems to be in
the PPM archive under the package name Tk-MK.

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: Tk, Tkx, PerlApp, etc

2010-06-09 Thread Brian Raven
Jon Bjornstad <> wrote:
> I have a large Perl/Tk application that
> I've been working on for almost 10 years and continue to enjoy
> fiddling with: 
> 
>   http://www.suecenter.org
> 
> I recently noticed that ActiveState Perl 5.10.1.1007 does not include
> Tk in the distribution and that 
> it is not available via ppm either.

I have that version installed, as well as Tk 804.028. According to my
ppm GUI (I have just checked), it is available from the Activestate
repository.

>   Rather Tkx
> is recommended.   Is this all due to Nick's passing
> or has Perl/Tk simply 'run its course' and something better has taken
> its place? 
> 
> I can certainly continue using the existing Perl and Tk that I have
> but do wonder about directions for the future. 
> 
> How difficult will it be to transform a Perl/Tk application into
> using Tkx with the different 
> syntax of widget creation, etc?   Is it worth the
> trouble?

It might be worth considering Tkx if you want to do any more than
tinkering with your existing app, or you have some spare time. Its on my
'would be nice' list but I haven't needed to develop any gui scripts for
a while, so I haven't tried it yet, but I think that the result look
quite good (e.g. the ppm gui). I came across the following Tk tutorial
(it may well have been somebody on this list that provided the pointer),
which gives its example code in multiple languages, including Perl using
Tkx.

http://www.tkdocs.com/tutorial/index.html

If you do go for it, and come up with any useful advice for converting
PerlTk to Tkx, then please share.

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: Extract nested zip file

2010-05-14 Thread Brian Raven
From: perl-win32-users-boun...@listserv.activestate.com
[mailto:perl-win32-users-boun...@listserv.activestate.com] On Behalf Of
Kprasad
Sent: 14 May 2010 09:22
To: perl-win32-users@listserv.ActiveState.com
Subject: Extract nested zip file

> Hi
>  
> Could anyone tell me that how to extract nested zip file, i.e.,
abc.zip contains another zip file 
> named xyz.zip.
> My requirement is to not to extract parent zip (abc.zip) but directly
extract child zip 'xyz.zip.
 
I have never tried anything like that myself, but the obvious (to me)
guess for a place to start would be a module that specialises in zip
files like Archive::Zip, possibly in combination with
Archive::Zip::MemberRead.

HTH

-- 
Brian Raven 

Please consider the environment before printing this email.

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: Use DLL files at Unix server

2010-04-23 Thread Brian Raven
Kprasad <mailto:kpra...@aptaracorp.com> wrote:
> I've to give this script to someone else department and they should
> not be able to modify or see the code. 

Ultimately, you can't prevent anyone seeing your source code. the best
you can do is make it harder to do so. (See
<http://search.cpan.org/~smueller/PAR-1.000/lib/PAR/FAQ.pod#Can_PAR_comp
letely_hide_my_source_code?>).

If you want to distribute your script as a standalone executable, the
PAR module or applications like Perl2Exe can help with that. If you just
want to obscure your script (i.e. your recipients already have Perl
installed), have a look at the source filtering modules like
Filter::Crypto.

HTH

-- 
Brian Raven 

Please consider the environment before printing this email.

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: Use DLL files at Unix server

2010-04-23 Thread Brian Raven

From: perl-win32-users-boun...@listserv.activestate.com
[mailto:perl-win32-users-boun...@listserv.activestate.com] On Behalf Of
Kprasad
Sent: 23 April 2010 05:11
To: rex njoku; perl-unix-us...@listserv.activestate.com;
perl-win32-users@listserv.ActiveState.com
Subject: Re: Use DLL files at Unix server

> Thankx a lot for your response.
> What else can we use at unix server instead of directly using .pl
(source) file?

What's wrong with using Perl source directly?

Seriously, without knowing what you are trying to do, it is difficult to
give advice.

See <http://catb.org/~esr/faqs/smart-questions.html>.

-- 
Brian Raven 

Please consider the environment before printing this email.

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: parsing email headers

2010-03-24 Thread Brian Raven

From: perl-win32-users-boun...@listserv.activestate.com
[mailto:perl-win32-users-boun...@listserv.activestate.com] On Behalf Of
Paul Rogers
Sent: 24 March 2010 15:17
To: perl-win32-users@listserv.ActiveState.com
Subject: RE: parsing email headers

> Thank you for your reply.  I suppose I should have been a bit more
specific.
> 
> I have indeed been using Mail::POP3Client.  However, it's the dates
that I think could prove tricky.  > The code down below does indeed
narrow down to the date (assuming I work with the "Date:" header).  
> Dates appear to be in "DD MMM " format (e.g. 24 Mar 2010). But
will that apply regardless of the 
> sender's local language settings?  RFC822 seems to point to an
English-based month in the date syntax, > but is that always be the
case?
> 
> If I use the first "Received:" header entry (likely more reliable for
my purposes) it's trickier 
> because the datestamp generally won't appear until the next line (the
"Received:" header appears to 
> almost always be stored on two separate lines).  As in. . .
> 
> ##
> From  Mon Mar 01 14:40:24 2010
> Received: from transit120.info.aa.com [64.73.138.120] by coservers.net
>   (SMTPD32-8.15) id A6005870134; Mon, 01 Mar 2010 14:40:00 -0400
> To: p...@coservers.net
> Message-Id: <20060501133309.a56b.2778496-52...@aadvantage.info.aa.com>
> ##
> 
> I can imagine writing code to handle parsing the Received header under
this scenario, but it seems 
> like the module should be able to do this for me.

CPAN is your friend.

For example, I tried
<http://search.cpan.org/search?query=datetime%3A%3Aformat&mode=all>, and
on the fourth page I saw DateTime::Format::Mail, which sounds pretty
much like what you are asking for.

BTW, it seems to be available vie ppm as well.

HTH

-- 
Brian Raven 

Please consider the environment before printing this email.

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: Perl Regex

2010-02-26 Thread Brian Raven

From: perl-win32-users-boun...@listserv.activestate.com
[mailto:perl-win32-users-boun...@listserv.activestate.com] On Behalf Of
Kprasad
Sent: 26 February 2010 15:56
To: perl-win32-users@listserv.ActiveState.com
Subject: Perl Regex

> Hi All
>  
> What will be the perfect Regular Expression to convert below mentioned
'Search Text' to 'Replacement 
> Text' while 'Single Line' option is ON.
>  
> When I use below mentioned Regex
>
]+)?>((?!<\/index-entry>).*?)\s*
([0-9]+)
>  
> And replaces wrongly

I think it is going to be hard to be of much help. Mostly because you
don't show us any Perl.

First, a regular expression can't change anything, it can only match.

Second, I find it easier to work out what is going on with non-trivial
regular expressions if I use the 'x' switch, which allows me to break
the RE over multiple lines, and include comments. Particularly useful
with the 'qr' quoting operator. Your RE, for example, might look like
this.

my $re=qr{]+)?>
  ((?!<\/index-entry>).*?)
  
  \s*
  
  ([0-9]+)
  
  }x;

However, as you don't provide any information on how that RE is used,
its going to be difficult to say what might be going wrong. If you could
provide a small example script, that we could cut & paste & run, it
would make it much easier.

Finally, your data looks a lot like XML. A dedicated parser will
generally do a more reliable job of parsing XML that regular
expressions, even Perl regular expressions.

HTH

-- 
Brian Raven 

Please consider the environment before printing this email.

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: HTML Parsing Question

2010-02-04 Thread Brian Raven

From: perl-win32-users-boun...@listserv.activestate.com
[mailto:perl-win32-users-boun...@listserv.activestate.com] On Behalf Of
Paul Rousseau
Sent: 04 February 2010 16:44
To: perl Win32-users
Subject: HTML Parsing Question

> Hello,
>  
>I have an HTML file that contains the following snippet:
>  
>  isReferenceObject="true" linkSize="true" linkConnections="true" 
> linkAnimations="linkWithoutExpression"
linkBaseObject="System_Bar.Group1">
>  exposeToVba="notExposed" isReferenceObject="true" linkSize="true"
linkConnections="true" 
> linkAnimations="linkWithoutExpression"
linkBaseObject="System_Bar.Button1" style="recessed" 
> captureCursor="false" highlightOnFocus="true" tabIndex="1">
>  repeatRate="0.25"/>
>  foreColor="black">
>  strikethrough="false" caption="Overviews"/>
> 
> 
>  backStyle="solid" foreColor="black">
>  underline="false" strikethrough="false" caption=""/>
> 
> 
> 
>  toolTipText="" exposeToVba="notExposed" isReferenceObject="true"
linkSize="true" 
> linkConnections="true" linkAnimations="linkWithoutExpression"
linkBaseObject="System_Bar.Button24" 
> style="recessed" captureCursor="false" highlightOnFocus="true"
tabIndex="2">
>  repeatRate="0.25"/>
>  foreColor="black">
>  strikethrough="false" caption="Oil Treating"/>
> 
> 
>  backStyle="solid" foreColor="black">
>  underline="false" strikethrough="false" caption=""/>
> 
> 
> 
>   .
>   .
>   . 
> 

I'm not an html expert, but is 'group' a valid tag? The parser seems to
be silently ignoring it. It works if you change it group to form.
 
> I want to obtain the parent name for all "button" tags. I am having
trouble extracting the parent 
> name. For example, I can find "Button1" and "Button24" but I can not
get to either item's parent name, > "Group1". 
 
> Here is my code so far. (I believe it's something trivial; I feel I am
so close.)
>  
> foreach $filename (@filenames)
>   {
> print "filename is $filename";
>$tree = HTML::TreeBuilder->new();
>$tree->parse_file("$sourcedir\\$filename");
>@Ans = $tree->look_down('_tag' => 'button');
>foreach $button (@Ans)
>  {
> print "button is " . $button->attr('name');   # prints "button
is Button1"
> print "button tag is " . $button->tag;  # can also use
${$button}{_tag}   # prints "button tag is 
> button"
> print "button parent hash pointer is " . $button->parent;   # can also
use ${$button}{_parent} # 
> prints "button parent hash pointer is HTML::Element=HASH(0x1afa5c4)"
> #
> #print Dumper($button->parent);
> #
> foreach $key (keys %{$button->parent})
>   {
>print "key is $key"; # prints four keys: _parent,
_content, _tag, _implicit
>   }
> print "button _parent value is " . ${$button}{_parent};  # prints
"button _parent value is 
> HTML::Element=HASH(0x1afa5c4)"
> print "button _tag value is " . ${$button}{_tag};  # prints "button
_tag value is button"
> 
>   $parent = $button->parent;
> print "parent tag is " . ${$parent}{_tag}; # prints "parent
tag is body"
> print "parent content is " . ${$parent}{_content};   # prints "parent
content is ARRAY(0x1afa7b0)"
> foreach $key (@{${$parent}{_content}})
>{
> #print "content item is $key";
>}
> #print "parent name is " . $parent->attr('name');
>   $groupid = $button->look_up('_tag', => 'group');
> #  print "group id is " . $groupid;
>  } Alw2ays
> #   $tree->dump;
> # print $tree->as_HTML;
>   }

Apart from your code being poorly laid out (which may well be the result
of emailing), you appear to either not be using 'use strict;' or you are
declaring variables in a larger scope than necessary. Both of which are
not recommended, if you will excuse the double negative. Always code
with 'use strict; use warnings;' at the top of your code, and declare
variables in the smallest scope necessary.

HTH

-- 
Brian Raven 
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: Random Read/Write a binary file

2009-12-07 Thread Brian Raven
From: perl-win32-users-boun...@listserv.activestate.com
[mailto:perl-win32-users-boun...@listserv.activestate.com] On Behalf Of
Daniel Burgaud
Sent: 05 December 2009 11:50
To: Perl-Win32-Users
Subject: Help: Random Read/Write a binary file

> Hi All
> 
> I have files previously created in binmode.
> 
> ie,
> 
> open SFILE, "filename.dat";
> binmode SFILE;
> print SFILE $buffer;
> close SFILE;
> 
> 
> Now, I want to Append this file somewhere in the middle.
> my $i = (-s "filename.dat") / 2;
> open SFILE, "filename.dat";
> binmode SFILE;
> seek SFILE $i, 0;
> print SFILE $data;
> close SFILE;
> 
> this does not seem to work.
> 
> How do I properly open a file for random read/write?
> 
> 
> if I open it with 
> open SFILE, "filename.dat";
> seek SFILE $i, 0;
> It does not append.
> 
> If I open it with
> open SFILE, ">>filename.dat";
> seek SFILE $i, 0;
> It keeps appending at the end
> 
> if I open it with
> open SFILE, ">>filename.dat";
> seek SFILE $i, 0;
> it writes at that location alright, but first half of data are blank.
> 
> HELP! :(

I hope that is not real code. If it is, you are missing a lot of error
checking.

The answer depends on what you mean by "append in the middle". If you
mean to just overwrite part of your file, the the answer is essentially
a FAQ (see 'perldoc -q update'), but given the apparent age of that
answer I would add advice to localise file handles and use the 3 arg
form of open.

If you mean to insert some data into the file then the general answer is
to simply read from your original file and create a new output file.

HTH

-- 
Brian Raven 
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: WIN32::OLE WMI Out params

2009-12-03 Thread Brian Raven
Michael <> wrote:
> Hi,
> 
> I'm a novice regarding Perl, and need some help converting a VBScript
> to a PerlScript. 
> 
> The following VBScript returns some data from HP OpenView. The
> GetChildNodeGroups method returns the number of ChildGroups, 
> 
> and the [out] parameter NodeGroups returns an array which contains a
> list of OV_NodeGroup. 
> 
>> From the documentation:
> 
> sint32 GetChildNodeGroups(
>   [out] OV_NodeGroup NodeGroups[],
>   [in, optional] boolean IncludeSubGroups)
> 
> Description
> Returns a list of node groups (instances of OV_NodeGroup) that are
> children of this node group. 
> 
> Return Value
> Number of node groups (children) in the out parameter NodeGroups.
> 
> ' VBScript Begin
> 
> Option Explicit
> 
> Dim objWMIService, objOV_NodeGroup, objGetRoot, objChildGroups,
> arrNodes, objItem 
> 
> Set objWMIService =
> GetObject("winmgmts:root\HewlettPackard\OpenView\data") 
> 
> Set objOV_NodeGroup = objWMIService.Get("OV_NodeGroup") Set
> objGetRoot = objOV_NodeGroup.GetRoot() objChildGroups =
> objGetRoot.GetChildNodeGroups(arrNodes, True)  
> 
> WScript.Echo "Child Group Count: " & objChildGroups & vbCrLF
> 
> For Each objItem In arrNodes
>   WScript.Echo "Name: " & objItem.Name
> Next
> 
> ' VBScript End
> 
> The problem is that I can't find out how to get the array (@arrNodes)
> in Perl. 
> 
> # PerlScript Begin
> use strict;
> use warnings;
> use Win32::OLE qw(in with);
> use Data::Dumper;
> 
> my $objWMIService =
> Win32::OLE->GetObject("winmgmts:root/HewlettPackard/OpenView/data")
> or die "WMI connection failed.\n"; my $objOV_NodeGroup =
> $objWMIService->Get("OV_NodeGroup"); my $objGetRoot =
> $objOV_NodeGroup->GetRoot();  
> 
> my @arrNodes;
> 
> my $objChildGroups = $objGetRoot->GetChildNodeGroups("@arrNodes",
> "True"); 

And you were doing so well up to this point. I really don't think that
you want to pass an empty array, interpolated into a string, as an
output parameter. In fact, I would expect that it might even produce a
run-time error. Does it?

I don't know the answer, but from my limited Perl/OLE experience, my
first guess would be that the function would want to return an OLE
container object in the output parameter, and so would expect it to be a
reference to a scalar. For example:

my $nodes;
use constant TRUE => 1;
my $objChildGroups = $objGetRoot->GetChildNodeGroups(\$nodes, TRUE);

> 
> print "Child Group Count: " . $objChildGroups . "\n";
> 
> print @arrNodes . "\n";

If I am right, and I may well not be, this would probably need to be
something like:

for my $obj (in $nodes) {
print "Name: $obj->{Name}\n";
}

> 
> # PerlScript End
> 
> Any help would be appreciated.

HTH, in lieu of somebody coming up with a more certain answer.

-- 
Brian Raven 
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: need help installing guitest

2009-11-18 Thread Brian Raven

From: perl-win32-users-boun...@listserv.activestate.com
[mailto:perl-win32-users-boun...@listserv.activestate.com] On Behalf Of
Daniel Burgaud
Sent: 18 November 2009 13:52
To: Perl-Win32-Users
Subject: need help installing guitest

> hi
> 
> After a reinstall of windows xp, i reinstalled perl as well..
> now comes the fun part: I could not install Win32-guitest.
> 
> PPM is no help either.. I've already added the other reposities
> and guitest isnt there.
> 
> Currently, I just dumped my old perl installation into the new xp
system.
> but im stuck using old perl version this way unfortunately.
> 
> What is the procedure for installing guitest? i forgot it the last
> time i installed it a year back.

I am running version 5.10.0, build 1004, and ppm is telling me that
version 1.54 of Win32-Guitest is available from both the uwinnipeg and
bribes repositories.

Which version of Avtivestate perl are you using? Which repositories have
you tried?

HTH

-- 
Brian Raven 
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: How do I create arrays in OO format?

2009-11-16 Thread Brian Raven
Serguei Trouchelle <> wrote:
> Brian Raven wrote:
> 
>> Read the documentation on OO that comes with Perl (perldoc perl$_
>> foreach qw{boot toot tooc bot}). Also Damian Conway's book comes
>> highly recommended. I can't remember toe title off-hand, but you can
>> google for it.
> 
> "Perl Best Practices"

That's not the book I was thinking of, although it comes highly
recommended. It has been on my to-read list for some time.

I was thinking of (from Damian's Wiki page):

"Object Oriented Perl: A Comprehensive Guide to Concepts and Programming
Techniques (Manning Publications, 2000, ISBN 188491)"

> 
> Also, "ppm install Perl::Critic" and then "perldoc perlcritic"

Now THAT sounds interesing.

-- 
Brian Raven 
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: How do I create arrays in OO format?

2009-11-12 Thread Brian Raven
Jason Lowder <> wrote:
> Hi,
> 
> I'm trying to make my perl source as OO as possible (fairly new to
> it) and while I can set values in set methods, I can't seem to figure
> out how to set arrays or hashes this way.  
> 
> My code:
> 
> package SQLfunctions;
> ...
> sub createPositionData {
>  my ($self, @posData) = @_;
>  $self->{...@_positiondata} = @posData if defined(@posData);
>  return $self->{...@_positiondata};
> }

Assuming that you object is a blessed hash ref. The code to store an
array in it might look something like:

sub createPositionData {
 my ($self, @posData) = @_;
 $self->{posData} = \...@posdata if @posData > 0;
 if (wantarray) {
 return @{$self->{posData}};
 }
 else {
 return $self->{posData};
 }
}

> 
> 1;
> 
> our $mySQL = SQLfunctions->new;
> $mySQL->createPositionData(1,2,3,4,5);
> 
> 
> I've tried other variations with no luck.  The if defined line also
> complains about being deprecated so clearly there is another means of
> doing this.  I have plenty of methods like this for single value
> variables, but can't find examples of how to pass arrays or hash
> values.
> 
> Any suggestions?

Read the documentation on OO that comes with Perl (perldoc perl$_
foreach qw{boot toot tooc bot}). Also Damian Conway's book comes highly
recommended. I can't remember toe title off-hand, but you can google for
it.

For things like storing arrays in hashes, 'perldoc perldsc' would be
useful.

HTH

-- 
Brian Raven 
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: Hitting a maximum number of SOCKET connections? Continued...

2009-11-04 Thread Brian Raven
Anders Boström <> wrote:
> Hello again,
> I have received test result from 2 people that tested the example,
> and both failed in the same way. 
> To clarify the previous explanation of the problem.
> Its seen on the server side!
> When the client has sent 63 PING's, the server stops showing the rest
> of the PING's (64-100).  They will the show up one by one, when the
> client starts to close the connections.  
> 
> It seems that only 63 sockets can deliver messages to the server at
> one time. 
> The other sockets are silent seen from the server.
> 
> Still - if anybody could explain why this is, I would be very happy.

I can confirm that select on win32 only seems to consider the first 64 file 
descriptors. Perhaps somebody from Activestate could check that the change to 
allow 2000 file descriptors reported for build 1001 works , and has not been 
regressed..

I have just tried your code on Linux, and it seems to work as expected, i.e. 
pings seen on the server immediately after they are sent. So you may want to 
consider switching OS.

HTH

-- 
Brian Raven 
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: Hitting a maximum number of SOCKET connections?

2009-11-04 Thread Brian Raven
Anders Boström <mailto:anders.bost...@mollehem.se> wrote:
> I have installed 5.10, but the problem still occures.
> The demo in http://www.mollehem.se/bilder/socketDemo.zip illustrates
> it. 
> 
> Any clue?

I have build 1004, and your code worked OK here, i.e. all 100 sockets opened 
and pinged. Even when I increased the number of sockets to 200. It may be that 
the new version isn't installed properly. What does 'perl -v' say? You did 
uninstall the previous version first, right?

BTW, I added 'use strict; use warnings;' to the start of your scripts, and 
fixed the issues raised before running them. I strongly suggest that you do the 
same.

-- 
Brian Raven 
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: Hitting a maximum number of SOCKET connections?

2009-11-03 Thread Brian Raven
Anders Boström <> wrote:
> Hej,
> I have a server implemented in Perl.
> It handles multiple connection with the use of "IO::Select".
> 
> All work well with the first 63 concurrent clients, but if client 64
> and upwards sends messages, they will not be seen on the server as
> long as the other 63 client are connected to the server. Is there a
> limit that I have hit, or whats going on?  
> I have tested it on Win XP, and Win Server 2003.
> 
> I have made a small demo program (based on a tutorial snippet I
>found) that illustrates the problem.
> http://www.mollehem.se/bilder/socketDemo.zip 
> It consist of one server and one client.
> The client opens 100 connections. Then it starts sending "ping" on
> each connection. 1-63 can be seen on the server side, but not 64-100. 
> Then the client starts closing the connections, and for each closed
> connection, one more ping is seen on the server! 
> 
> I would be very happy for an explanation!

64 is the default limit on the number of file handles that you can call select 
with in win32. According to the doco ("ActivePerl 5.10 Change Log"), this was 
increased to 2000 for build 1001, so you might want to upgrade your Perl.

HTH

-- 
Brian Raven 
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: How to passing a hex number in Win32::API call

2009-10-27 Thread Brian Raven
Su, Yu (Eugene) <> wrote:
> Hi,
> 
> I have a DLL from FTDI (ftd2xx.dll www.ftdichip.com) for a USB
> device. I try to write a simple perl script to list a number of (FTD)
> USB devices connected to a PC. My code below got an error on invalid
> parameter;   
> 
> Argument "M-\0\0\0\0\" isn't numeric in subroutine entry at demo.pl
> line # 
> 
> I guess I did not pass a hex data in the function call properly. Can
> someone help me? 
> 
> Thanks.
> 
> Eugene
> 
>  code snippet ###
> 
> use strict;
> use Win32::API;
> use Carp;
> use warnings;
> 
> # from FTD2xx programmer guide:
> # FT_ListDevices(PVOID numDevs,PVOID NULL,DWORD FT_LIST_NUMBER_ONLY)
># FT_LIST_NUMBER_ONLY is defined in FTD2xx.h as #define
> FT_LIST_NUMBER_ONLY = 0x8000 # my $function = new
> Win32::API("ftd2xx", "FT_ListDevices", "PPN", "N"); if (not defined
> $function) { die "Can't import API FT_ListDevices: $!\n"; } my
> $DevBuffer = " " x 80; my $FT_LIST_NUMBER_ONLY=pack('N', 0x8000);
> my $status=$function->Call($DevBuffer,0,$FT_LIST_NUMBER_ONLY); 
> print "status: $status\n";
> print "DeviceNumber: $DevBuffer";

I think that you problem is the 'pack'. Why do you think you need it?.
Just use 0x8000 in your function call, or if you want to define it
as a constant, 'use constant FT_LIST_NUMBER_ONLY => 0x8000;' is more
nearly equivalent to the #define you quote, and will add to your codes
readability. For example, you dould write it something like this:

use strict;
use warnings;
use Win32::API;

use constant FT_LIST_NUMBER_ONLY => 0x8000;

my $function = new Win32::API("ftd2xx", "FT_ListDevices", "PPN", "N");
die "Can't import API FT_ListDevices: $!\n" unless defined $function;
my $DevBuffer = " " x 80;
my $status=$function->Call($DevBuffer, 0 ,FT_LIST_NUMBER_ONLY);
print "status: $status\n";
print "DeviceNumber: $DevBuffer";

HTH

-- 
Brian Raven 
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: Strange Perl/Tk action

2009-10-26 Thread Brian Raven
Geoff Horsnell <> wrote:
> Unfortunately, it would be rather a lot of code. I will try to
> describe the action with example segments. 

Which is why it is generally advisable to try to create a small example
script that illustrates the problem.

> 
> ...
> 
> sub create_all_menus {
>   $mode = "A";
>   $menub = $tl->Menu(-type => "menubar");
>   $tl->configure (-menu => $menub);
>   $widget1 = menub->cascade(-label => "Edit, -underline => 0,
>   -tearoff => 0); $widget->pack(-side => "top", -anchor => "nw");
>   &create_menu1 ($widget1);
> ...
> }
> 
> sub create_menu1 {
>   my $widget = shift;
> 
>   $state = "disabled";
>   if ($mode eq "A") {
> $widget->command(-label => "B", -underline => 0, -command =>
> \&switchToB); $widget->command(-label => "A", -underline => 0,
>   -command => \&switchToA, -state => $state); } else {
> $widget->command(-label => "B", -underline => 0, -command =>
> \&switchToB, -state => $state); $widget->command(-label => "A",
>   -underline => 0, -command => \&switchToA); }
> }
> ...
> sub switchToA {
>   $mode = "A";
>   &create_all_menus (...);  # repaint all menu buttons } Sub
>   switchToB { $mode = "B";
>   &create_all_menus (...);  # repaint all menu buttons }
> 
> After calling the "create_all_menus" from the main program, option
> "A" is greyed out and option "B" is active. When "B" is selected for
> the first time, option "B" is then greyed out and option "A" is
> active. At the same time, the height of the "canvas" window
> containing these menu buttons is reduced by about 0.2 cm. Subsequent
> selection of the "A" or "B" menu option (whichever is currently
> active) has no further effect on the size of the window.  
> 
> I hope this makes better sense.
> 
> TIA
> 
> Geoff
> 
> -Original Message-
> From: Jack [mailto:goodca...@hotmail.com]
> Sent: Saturday, October 24, 2009 10:51 PM
> To: 'Geoff Horsnell'; perl-win32-users@listserv.activestate.com
> Subject: RE: Strange Perl/Tk action
> 
> 
> It's hard to follow your description. Can you upload some sample code
> that 
> shows the problem?
> 
> "Shrinkage is always bad" ;)
> 
> Jack
> 
> 
> From: perl-win32-users-boun...@listserv.activestate.com
> [mailto:perl-win32-users-boun...@listserv.activestate.com] On Behalf
> Of 
> Geoff Horsnell
> Sent: October-24-09 10:05 AM
> To: perl-win32-users@listserv.activestate.com
> Subject: Strange Perl/Tk action
> 
> 
> 
> I have created a GUI using the Tk "canvas" widget that contains a
> menu list 
> with two mutually exclusive menu items - say "A" and "B". When "A" is
> selected, "B" should be disabled (greyed out) and vice versa.
> Therefore, 
> when the currently active option is selected, the menu list needs to
> be 
> repainted switching the active and disabled items. However, the first
> time 
> that this happens, the height of the canvas window shrinks - by about
> the 
> height of the menu tab. The height of the window remains unchanged
> for all 
> subsequent menu actions. I have printed out the variable containing
> the 
> nominated height of the window before and after making the selection
> and it 
> does not change. I can compensate for this action by making the
> original 
> window height slightly larger in the first place. However, I would
> rather 
> that the shrinkage did not happen at all. Has anyone seen this happen
> for 
> themselves and does anyone know how to prevent the window from
> shrinking in 
> the first place?
> 
> Any suggestions would be most welcome.

I may have missed something from your description and code, but it seems
to me that using radio buttons in your menu would be preferable, not to
mention simpler, than recreating it. The widget demo has examples if you
need them.

HTH

-- 
Brian Raven 
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: Using .cgi file as form action

2009-10-06 Thread Brian Raven
From: perl-win32-users-boun...@listserv.activestate.com
[mailto:perl-win32-users-boun...@listserv.activestate.com] On Behalf Of
Kprasad
Sent: 06 October 2009 15:15
To: perl-win32-users@listserv.ActiveState.com
Subject: Using .cgi file as form action

> Hi
>  
> I'm using HTML form to execute a .cgi script and I want the output of
cgi script should display in the same 
> window in which Form is displayed.
>  
> Anyone can suggest that how to do it.

I would have thought that the simplest way would be for the cgi program
to output both the form, and when data is entered on the form, the
output as well.

This isn't really a Perl question, but as this is a Perl forum here is a
simplistic example of what I mean.

--
use strict;
use warnings;

use CGI::Pretty qw{:standard *form *select};
use CGI::Carp qw{fatalsToBrowser};

my @options = ("This", "That", "The other");

my $sel = param("selection") || "";

print header;
print start_html("Simple form");
output_form();
output_data() if $sel ne "";
print end_html;

sub output_form {
print h1("This is a form");
print start_form({method => "post", action=>"simple_form.pl"});
print strong("Select something: ");
print Select({name => "selection"},
 map {option($_ eq $sel ? {selected => 1} : {}, $_)}
@options);
print p();
print submit("Use that");
print end_form;
print hr();
}

sub output_data {
print h2("You selected something");
print "It was ", strong($sel);
}
--

HTH

-- 
Brian Raven 
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: need help with Tk: I could not figure the error

2009-09-03 Thread Brian Raven
From: Daniel Burgaud [mailto:burg...@gmail.com] 
Sent: 03 September 2009 03:00
To: Brian Raven
Cc: Perl-Win32-Users
Subject: Re: need help with Tk: I could not figure the error

> Hi
> 
> When I moved all the variables within the subroutines outside, this
script suddenly worked flawlessly.
> 
> What gives?
> 
> Wasnt it highly desireable to "localize" variables to make it more
organized?
> yet when i did just that, it fails to run. Only when I made all
variables GLOBAL
> that it worked.

I have rewritten your code a bit to be more like how I would approach
it. Note no nested subs, no interfering with the main event loop,
passing variables need by callbacks as parameters rather than hoping
that they are in scope, and avoiding some code duplication. It seems to
do pretty much what I understand you were trying to do.


use strict;
use warnings;
use Tk;

my $BGColor0 = "#D8D0C8"; 
my $BGColor1 = "#D0D0D0"; 
my $BGColor2 = "#808080";
my $BGColor3 = "#5090C0";
my $BGColor4 = "#4070A0";
my $BGColor5 = "#80C080";
my $BGColor6 = "#408040";
my $BGColor7 = "#FF";
my $BGColor8 = "#E0E0E0";
my $BGColor9 = "#FF8080";

my $mw = MainWindow->new;
$mw->title("MainWindow");
$mw->Button(-text => "Get Number",
-command => sub {my $n = GetNumber('Enter Number');
 print "Got '$n'\n";})->pack( );

MainLoop;

sub AddNumber {
my ($numref, $key, $top) = @_;
if ('0123456789' =~ $key) {
$$numref .= $key;
} elsif ($key eq 'period' && $$numref !~ /\./) {
$$numref .= '.';
} elsif ($key eq 'Return') {
$top->destroy;
} elsif ($key eq 'Escape') {
$$numref = '';
$top->destroy;
} elsif ($key eq 'BackSpace') {
chop($$numref);
chop($$numref) if substr($$numref,-1) eq '.';
}
}

sub Keyboard {
my ($numref, $widget, $top) = @_;
my $e = $widget->XEvent;# get event object
my $key = $e->K;
AddNumber($numref, $key, $top);
}

sub MakeButton {
my ($top, $widget, $label, $value, $numref, $fontsize) = @_;
$fontsize ||= 30;
my @buttonargs = (-borderwidth=>3,
  -bg=>$BGColor3,
  -activebackground=>$BGColor4,
  -width=>4,
  -height=>1,
  -text => $label,
  -font=>['Courier',$fontsize,'bold']);
if (ref($value) eq 'CODE') {
return $widget->Button( @buttonargs,
-command => $value );
}
return $widget->Button( @buttonargs,
-command => [\&AddNumber, $numref, $value,
$top]);
}

sub GetNumber {
my $title = shift;
my $number = 0;

my $top = $mw->Toplevel(-title=>$title);
$top->resizable(0,0);
$top->transient($top->Parent->toplevel);

$top->Label( -borderwidth=>2,
 -bg=>$BGColor3,
 -fg=>'#00',
 -font=>['Arial',20,'bold'],
 -relief=>'groove',
 -anchor=>"c",
 -text=>$title)->pack( -side=>"top",
   -expand=>1,
   -fill=>'x' );

$top->Label( -borderwidth=>4,
 -bg=>$BGColor7,
 -fg=>'#00',
 -font=>['Arial',40,'bold'],
 -relief=>'groove',
 -anchor=>"e",
 -textvariable=>\$number)->pack( -side=>"top",
 -expand=>1,
 -fill=>'x' );

my $frame = $top->Frame( -borderwidth=>2 )->pack( -side=>'left',
  -expand=>1,
  -fill=>'both');
MakeButton($top, $frame, 7, 7, \$number)
->grid(MakeButton($top, $frame, 8, 8, \$number),
   MakeButton($top, $frame, 9, 9, \$number),
-sticky=>'news');
MakeButton($top, $frame, 4, 4, \$number)
->grid(MakeButton($top, $frame, 5, 5, \$number),
   MakeButton($top, $frame, 6, 6, \$number),
-sticky=>'news');
MakeButton($top, $frame, 1, 1, \$number)
->grid(MakeButton($top, $frame, 2, 2, \$number),
   MakeButton($top, $fr

RE: need help with Tk: I could not figure the error

2009-09-02 Thread Brian Raven
From: perl-win32-users-boun...@listserv.activestate.com
[mailto:perl-win32-users-boun...@listserv.activestate.com] On Behalf Of
Daniel Burgaud
Sent: 02 September 2009 15:27
To: Perl-Win32-Users
Subject: need help with Tk: I could not figure the error

> I have this test script below.
> 
> A toplevel containing a button that invokes another toplevel.
> The first time I invoke this second window, all works fine and returns
properly without error.
> 
> however, when I reenter again (clicking on "Get Number" button) I get
this error message.
> 
> Tk::Error: not a Tk object
>  Tk::die_with_trace at x.pl line 46
>  main::AddNumber at x.pl line 66
>  main::__ANON__ at C:/Perl/lib/Tk.pm line 252
>  (eval) at C:/Perl/lib/Tk.pm line 252
>  Tk::__ANON__ at C:/Perl/lib/Tk/Button.pm line 111
>  Tk::Button::butUp at x.pl line 79
>  (eval) at x.pl line 79
>  main::GetNumber at x.pl line 17
>  main::__ANON__ at C:/Perl/lib/Tk.pm line 252
>  (eval) at C:/Perl/lib/Tk.pm line 252
>  Tk::__ANON__ at C:/Perl/lib/Tk/Button.pm line 111
>  Tk::Button::butUp at x.pl line 20
>  (eval) at x.pl line 20
>  Tk callback for .toplevel.frame.button5
>  Tk::__ANON__ at C:/Perl/lib/Tk.pm line 252
>  Tk::Button::butUp at C:/Perl/lib/Tk/Button.pm line 111
>  
>  (command bound to event)
> 
> Hoping for help.
> 
> thanks.
> Dan
> 
> 
> 
>


> use strict;

perl will give you a clue if you add "use warnings;" here. It will even
give some advice if you make it "use diagnostics;".

> use Tk;
> ...

HTH

-- 
Brian Raven 
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: need help: TK windows - no task bar icon pls

2009-09-01 Thread Brian Raven
From: perl-win32-users-boun...@listserv.activestate.com
[mailto:perl-win32-users-boun...@listserv.activestate.com] On Behalf Of
Daniel Burgaud
Sent: 01 September 2009 11:08
To: Perl-Win32-Users
Subject: need help: TK windows - no task bar icon pls

> Hi
> 
> I have a perl script with a main TK:
> 
> my $MW = MainWindow->new();
> 
> 
> Within, I have routines that requires a popup.
> 
> sub POPUP {
> my $popup = $MW->TopLevel();
> .
> .
> .
>   while(1) {
> usleep 5000;
> $popup->focus;
>   .
>   .
>   .
>  }
> }
> 
> I do not like to use dialog or dialogbox because i need a popup that
> performs complex task, dialog or dialogbox is not up to task.
> 
> My problem is, this popup creates "another" task bar icon separate
from
> the mainwindow. how do I make it not create another task bar icon?
> Dialog/DialogBox does not have this taskbar icon...

As DialogBox derives directly from TopLevel, I expect that the answer
lies somewhere in DialogBox.pm, probably in its Populate and Show
methods. My first guess would be that it is something to do with the
calls to transient, withdraw and Popup, although I can see no
documentation for Popup in TopLevel or its obvious base classes.

Unless somebody comes up with a better answer, try copying DialogBox.pm,
make mods to it and see what happens. If you discover the answer from
that, don't forget to let us know what it is.

HTH

-- 
Brian Raven  
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: CPAN install directory usage

2009-07-01 Thread Brian Raven

From: Perl Perl [mailto:perl.solut...@gmail.com] 
Sent: 01 July 2009 14:37
To: Brian Raven
Cc: perl-win32-users@listserv.activestate.com
Subject: Re: CPAN install directory usage

> Hi Brian Raven,
>  
>  I don't know by which way my system admin has install the
module. Here my task is to use that 
> module in my script. I forgot to add one more thing in the last mail.
> I have received a mail saying TK.pm is installed in below path. But I
am not getting how to use the same at 
> Windows side. 
> Please find the given path as well for your kind reference.
>  
> 
> The Tk package is installed in the vob release of perl.
> 
> Please check the following path: /vobs/vob_verif/tools/Perl/lib/Tk.pm
> 
> The way to run a perl script on windows is to open up a command prompt
and a view and call perl by:
> 
> V:\view_MAIN\vob_verif\tools\Perl\bin\perl
> 
> You can use Tk by running a script with use Tk.pm, it will work.
>  
>  
> I have changed my sript with the given path ( By different means), but
still getting the error, please find the > script and error as below.
>  
> 
> #!/usr/bin/perl -w
> 
> use lib 'V:/vobs/vob_verif/tools/Perl/lib/Tk.pm';
> 
> #use lib 'V:/vobs/vob_verif/tools/Perl/lib';
> 
> #use lib '/vobs/vob_verif/tools/Perl/lib/Tk.pm';
> 
> #use lib '/vobs/vob_verif/tools/Perl/lib';
> 
> use FindBin qw($RealBin);
> 
> use Tk;
> 
> Error Message : 
> 
> 
> V:\view_MAIN\vob_verif>v:\view_MAIN\vob_verif\tools\Perl\bin\perl.exe
Test.pl
> Can't locate Tk/Event.pm in @INC (@INC contains:
/vobs/vob_verif/tools/Perl/lib 
> v:/view_MAIN/vob_verif/tools/Perl/site/lib
v:/view_MAIN/vob_verif/tools/Perl/lib .) at 
> v:/view_MAIN/vob_verif/tools/Perl/lib/Tk.pm line 13.
> BEGIN failed--compilation aborted at
v:/view_MAIN/vob_verif/tools/Perl/lib/Tk.pm line 13.
> Compilation failed in require at Test.pl line 6.
> BEGIN failed--compilation aborted at Test.pl line 6.

You will notice that this is a different error message. It is no longer
complaining that it can't find Tk.pm, but 
Tk/Event.pm.

The directory that contains Tk.pm should also contain a directory called
Tk, which contains a lot of modules associated with Tk, including
Tk::Event (Tk/Event.pm). If it doesn't then, then Tk is not properly
installed.

HTH

-- 
Brian Raven 
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: CPAN install directory usage

2009-07-01 Thread Brian Raven
From: perl-win32-users-boun...@listserv.activestate.com
[mailto:perl-win32-users-boun...@listserv.activestate.com] On Behalf Of
Perl Perl
Sent: 01 July 2009 13:24
To: perl-win32-users@listserv.activestate.com
Subject: CPAN install directory usage

> Hi All,
>  
>  I have one doubt, about usage of CPAN install diretory at Windows
side. I have found that TK module is 
> install at "C:/Perl/site/lib C:/Perl/lib" . but confuse with the usage
part.  
> Please find the sanpshot from the screen as below.
> 
> V:\view_MAIN\vob_verif>perl -MTk -e 1
> Can't locate Tk.pm in @INC (@INC contains: C:/Perl/site/lib
C:/Perl/lib .).
> BEGIN failed--compilation aborted.
> 
> V:\view_MAIN\vob_verif>perl -e "print qq(@INC)"
> C:/Perl/site/lib C:/Perl/lib .
> 
> I tried, different ways to embed the above installed directory path in
my script, but I am getting the result 
> as Can't locate Tk.pm in @INC.
>  
> Please find my script as below, made this one very short for debuging
pupose.
> 
> #!/usr/bin/perl -w
> use lib "C\:\\Perl\\site\\lib";
> 
> #use lib "C:\/Perl\/site/lib C:\/Perl\/lib";
> use Tk;
> 
> Please find the error message,
> 
> V:\aec_MAIN\platform_verif>perl Test.pl
> Can't locate Tk.pm in @INC (@INC contains: C:\Perl\site\lib
C:/Perl/site/lib C:/
> Perl/lib .) at Test.pl line 5.
> BEGIN failed--compilation aborted at Test.pl line 5.
> 
> 
> This is at Windows OS. Could you please help me to overcome this?

It is not really clear from the above, but it looks like Tk has not been
installed, or at least not properly.

The big question is why don't you install it using ppm, rather than from
CPAN. It is much easier as all of the hard work of building it has
already been done. It works fine for me.

-- 
Brian Raven 
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: :FTP pasv_xfer() using problem

2009-06-18 Thread Brian Raven

From: perl-win32-users-boun...@listserv.activestate.com
[mailto:perl-win32-users-boun...@listserv.activestate.com] On Behalf Of
Kprasad
Sent: 18 June 2009 14:52
To: perl-win32-users@listserv.ActiveState.com
Subject: Net::FTP pasv_xfer() using problem

> Hi
>  
> Please provide solution for below mentioned problem, message showing
while executing below mentioned script
>  
> CODE:
>  
> #!/usr/bin/perl 

The first thing wrong with your code is the absence of "use strict;" and
"use warnings;" at the start.

> use Net::FTP;
> use File::stat;
> ##I'm hoping to use pasv_xfer(sourcefile, dest_server) to do a server
to server passive transfer

Here's a clue ..^^^

>  
> $ftpout = Net::FTP->new("192.168.180.188", Debug => 0)
> or die "Cannot connect to 192.168.180.188: $@"; #destination
server
>   $ftpout->login("tj","tj") or die "Cannot login ",
$ftpout->message;
> warn "Failed to set binary mode\n" unless $ftpout->binary();
> $pwddirout=$ftpout->pwd();
> $ftpdest="$pwddirout/training";
> print "Destination Directory $ftpdest\n";
> 
>$ftpin = Net::FTP->new("192.168.180.192", Debug => 0)
> or die "Cannot connect to 192.168.180.192: $@"; #source server
>  $ftpin->login("iop123","iop312") or die "Cannot login ",
$ftpin->message;
>  
>  $pwddir=$ftpin->pwd();
>  warn "Failed to set binary mode\n" unless $ftpin->binary();
>  $ftpin->pasv_xfer("ApJ306023.xml", $ftpdest);

You haven't specified the destination server. Perhaps $ftpout?

>  $lsize = stat("c:/temp/apj_697_1_106ej.zip")->size;
>  print "SIZE:- $lsize";
>  $ftpout->quit() or die "FTP: Couldn't quit.";
>  $ftpin->quit() or die "FTP: Couldn't quit.";
> 
>  
> MESSAGE: Can't call method "port" without a package or object
reference at C:/Perl/lib/Ne
> t/FTP.pm line 1122.

HTH

-- 
Brian Raven 
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: LWP Help

2009-06-17 Thread Brian Raven

From: perl-win32-users-boun...@listserv.activestate.com
[mailto:perl-win32-users-boun...@listserv.activestate.com] On Behalf Of
steve silvers
Sent: 17 June 2009 17:27
To: perl-win32-users@listserv.activestate.com
Subject: LWP Help

> I have my below snippet that when I run it from my website, it returns
the query to Yahoo, but all the links 
> are screwed up?

That's a bit vague. What do you mean by "screwed up"?

>  
> How do I fix this? Also how can I add multiple searches to this for
one call.
>  
> Thanks in advance.
>  
> #!/usr/bin/perl

"use strict; use warnings;" missing. Please include them.

> use LWP::UserAgent;
> print "Content-type: text/html\n\n";
> my $ua = new LWP::UserAgent;
> my $url =
"http://search.yahoo.com/search?p=trucks&fr=yfp-t-501&toggle=1&cop=mss&e
i=UTF-8";
> my $response = $ua->get($url);
> if($response->content_type ne "text/html"){
> die("Recieved content-type ".$response->content_type.", was
> looking for text/html.")
> }
> my $content = $response->content; # $content now holds the html page
from google.
> print $content;

Just a guess, but are the links in the returned document relative? If
so, hava a look at the example code in the doco for HTML::LinkExtor.

HTH

-- 
Brian Raven 
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: Compilation (Building ) of project once the file is saved + Perl/Tk

2009-06-08 Thread Brian Raven
From: perl-win32-users-boun...@listserv.activestate.com
[mailto:perl-win32-users-boun...@listserv.activestate.com] On Behalf Of
Perl Perl
Sent: 08 June 2009 14:23
To: perl-win32-users@listserv.activestate.com
Subject: Compilation (Building ) of project once the file is saved +
Perl/Tk

> Hi All,
>  
>  I am doing this activity on Perl/TK.
>  
>  I have to build my project, once the project(file) is created.
Problem I am facing here is, the size of  
> the created project file is showing as 0, and content is nill, which
avoiding me to to build the project.
> If I close the wideget then I can see the file with file size and data
content.
>  
> Let me update you all, I have different buttons like Create, Update
and Build. 
> Build button calles the above functions, which "saves" and "build" the
project.
>  
> sub Compile_M3 {
> 
>$Filename = $filename . "\_" . "CPU" . "\." . "pjt";

Why escape _ and .? Your code could be simpler.

my $Filename = $filename . "_CPU.pjt";
or
my $Filename = "${filename}_CPU.pjt";

>chomp($Filename);

Why? If $filename has a record separator at the end, then you are too
late. Also, try to avoid confusingly similar variable names, like
$Filename and $filename, that only differ in the case of one letter. Its
far to easy to use the wrong one. If the variables are also global, this
can lead to hard to find bugs.

> 
> $info = "Saving '$Filename'";
> open (FH, ">$Filename");
> print FH $x->get("1.0", "end");
> $info = "Saved.";

So when do you close the file? If you use a localised file handle you do
not actually need to close the file explicitly. For example (and notice
the check for success, which should always be done)

open my $fh, ">", $Filename or die "Failed to open $Filename: $!\n";
print $fh $x->get("1.0", "end");

But it is better to explicitly close the file, and, especially as it is
an output file, to test if it was successful:

close $fh or die "Failed to close $Filename: $!\n";


>  
> ## Script to build by project ( Here I am giving some dummy command to
avoid any conflict with the organization > norms.
> #system("/View/Vobs>tools/Perl/bin/perl tools/Compile
tools/Perl/bin/perl tools/pjtCompile.pm  /View/Vobs/
> $Filename");
> }

Also, it looks like you are (a) using global variables, or (b) not
including 'use strict;' at the start of your code. Try to avoid (a), and
always do (b).

HTH

-- 
Brian Raven 
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: inserting the file paths in between the two arrays ( text widget ) : Perl/TK

2009-06-05 Thread Brian Raven
From: Perl Perl [mailto:perl.solut...@gmail.com] 
Sent: 05 June 2009 13:16
To: Brian Raven
Cc: perl-win32-users@listserv.activestate.com
Subject: Re: inserting the file paths in between the two arrays ( text
widget ) : Perl/TK

> Thanks a lot HTH ( Brian),
> 
>   This worked for me.
 
Glad to hear it.

BTW, HTH is an acronym, not my name
(http://www.acronymfinder.com/HtH.html), and so is BTW, BTW.

HAND
(There's another one.)

-- 
Brian Raven 
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: inserting the file paths in between the two arrays ( text widget ) : Perl/TK

2009-06-04 Thread Brian Raven

From: perl-win32-users-boun...@listserv.activestate.com
[mailto:perl-win32-users-boun...@listserv.activestate.com] On Behalf Of
Perl Perl
Sent: 04 June 2009 17:22
To: perl-win32-users@listserv.activestate.com
Subject: inserting the file paths in between the two arrays ( text
widget ) : Perl/TK

> Dear All,
>   I have written a script, which has to enter the file path
(Paths ), in between the text. For this I 
> have used below approach.
> 1) I divide the file in two parts, in which file path(s) has to be
inserted.
>  -> Here @File_Part1 stores the first prart of file.
>  -> @File_Part2 stores the second part of file.
> 2) Then script will capture the file path entry into @File_Parth
array.
> 3) Now I will insert the @File_Path array in between @File_Part1 and
@File_Part2, to achive our goal.
>   But the problem is, The widget is diplaying(inserting) only last
file pathselected with Tk::Pathenty. But > my aim is to insert the
number of file path as selected with Tk::PathEntry tk module.
> Plese help me to overcome this. Please find the code below for your
kind reference.

...
 
> ## This function will the capture the file path entrires and store
into an array, @File_Part.
> 
> sub Capture {
>  @File_Path =$path;

You have just told Perl to replace the contents of @File_Path with
$path. That is, the array will only ever contain the last value that is
assigned to it. I would guess that you would prefer to append the $path
to the array. In which case see 'perldoc -f push'.

>  #open (FILE,">>f1.txt") or die "Can't open $!";
> #foreach (@File_Path) {
>  # print FILE $_;
>  # $t -> insert ("end", $_);
> 
>  #}
> }

HTH

-- 
Brian Raven 
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: Advice requested, porting unix perl app to windows

2009-06-03 Thread Brian Raven
Dennis Daupert <> wrote:
> Hello group,
> 
> Most of my perl programming is on unix; my windows knowledge is
> limited. 
> So, please be gentle ;-)
> 
> I have an app that produces data files on one unix machine, then uses
> scp to move those over to another machine for further processing. The
> system architecture dictates the two-machine arrangement. Management
> has asked me to port that app to a windows-based system with the same
> two-machine architecture.
> 
> I don't know of a free (as in both beer and non-beer) windows
> equivalent to scp OR sftp. I'm seeking advice on a solid, dependable,
> and secure way to move files between machines without incurring
> additional expense. I've wondered whether there may be Perl modules
> that will map drives and copy files across that would do so on an
> automated schedule, and I've been searching CPAN. But before heading
> too far down that path, I thought I'd ask the list for advice.  

There are command line tools in cygwin and putty. There are also perl
modules, e.g. Net::SSH2.

HTH

-- 
Brian Raven 
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: Activeperl 5.10 + thread + join = random crashes

2009-06-03 Thread Brian Raven
jean-philippe.ulpi...@infineon.com
<mailto:jean-philippe.ulpi...@infineon.com> wrote: 
> Hi Brian,
> 
> Thanks for your reply,
> 
> Sorry, I should have specified that these crashes are sporadic.
> Sometimes it does not crash at all but when it crashes, it is usually
> maximum after 15 join.  
> 
> Hence it is hard to provide a piece of code to reproduce the problem.
> 
> Another thing I should have mentioned is that I am using embedded
> perl. A C function performs a call in perl which starts a new thread. 
> 
> Do you know if such behaviour is known by perl ?
> 
> FYI, here is a stack that I could get after one crash:
> I print a debug info specifying how many join were already done +
> that a join is being done. 
> Right after the join I print another info to specify that the join is
> done. 
> 
> 
> Join trial= 4
> Trying to join thread threadedRunRegressionTest0 $VAR1 = bless(
> do{\(my $o = '83144192')}, 'Thread' ); 
> 
> [New LWP 8]
> [LWP 8 exited]
> [New LWP 8]
> [New LWP 9]
> [LWP 9 exited]
> [New LWP 9]
> 
> Program received signal SIGSEGV, Segmentation fault.
> [Switching to LWP 3]
> 0x000c in ?? ()
> (gdb) #0  0x000c in ?? ()
> #1  0xfb5b2648 in TclObj_free ()
>from
>
/home/swmdev/perl/ActivePerl-5.10.0.1004-sun4-solaris-2.8-cc-287188/site
/lib/auto/Tk/Tk.so

Interesting that this is at the top of your stack. You are aware that Tk
is not thread safe?

Of course that may not be your problem, but it is a pretty good
candidate. In fact Tk can be used in a threaded Perl program, but it
must be done with great care.

HTH

-- 
Brian Raven 
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: Activeperl 5.10 + thread + join = random crashes

2009-06-03 Thread Brian Raven
jean-philippe.ulpi...@infineon.com <> wrote:
> Hi,
> 
> I am using threads and perl and after a particular number of thread
> creation/destruction (2 to 15) perl crashes when doing a join. 
> 
> I saw a similar problem dated from July 2004:
> http://aspn.activestate.com/ASPN/Mail/Message/perl-win32-users/2131329
> 
> Any idea if I am facing the same problem on Perl 5.10 ?
> Any idea if there is any workaround ?

Perhaps you could provide more detail. A small example script that
demonstrates the problem would be good.

For example, the following script, which creates a lot more than 15
threads, has run to completion on my box every time so far (Activestate
Perl 5.10.0 build 1004, on XP):

use strict;
use warnings;

use threads;
my $at_a_time = 20;
for (1..10) {
print "--\n";
print "Iteration $_\n";
for (1..$at_a_time) {
my $thr = threads->create(\&threadsub);
}
print "Waiting for threads to finish\n";
while (threads->list(threads::all) > 0) {
foreach my $thr (threads->list(threads::joinable)) {
my $result = $thr->join();
my $id = $thr->tid();
print "Result for thread $id is $result\n";
}
select undef, undef, undef, 0.1;
}
print "All threads finished\n";
}

sub threadsub {
my $id = threads->tid();
print "Thread $id starting\n";
my $delay = int(rand(5)) + 1;
sleep $delay;
print "Thread $id terminating\n";
return $delay;
}

HTH

-- 
Brian Raven 
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: Problem iwth perl tk : Creation of file based on options

2009-05-27 Thread Brian Raven
From: perl-win32-users-boun...@listserv.activestate.com
[mailto:perl-win32-users-boun...@listserv.activestate.com] On Behalf Of
Perl Perl
Sent: 27 May 2009 15:40
To: perl-win32-users@listserv.activestate.com
Subject: Problem iwth perl tk : Creation of file based on options

> Hi All,
>  
>I have to create files based on the ext1 - ext2 and write few
lines of code there. The created file 
> should have to option like like update and save so that user can edit
the file in future. 

Sorry, I didn't understand that.

> For this I choose the Radiobatton option of Perl/Tk. Here I am doing a
very silly mistake, and it is just due 
> to little knowlege towards Perl/TK (started learning Perl/TK for 2
days). 
> So Request you to let me know where I am doing the mistake. 
> It will great help, if you help me to overcome this issue. 
>  
>  
> #!/usr/bin/perl -w
> use  Tk;
> use strict;
> our ($filename);
> $filename = "DMM";
> 
> 
> my $mw = MainWindow -> new;
> my $rb_value = "red";
> $mw -> configure( -background => $rb_value);
> my $val;
> foreach ( qw ( ext1 ext2 ext3) ) {
>  $mw -> Radiobutton ( -text => $_,
> -value => $_,
> -variable => \$val,
> -command => \&set_bg) -> pack (-side => 'left');
> }
> MainLoop;
> 
> sub set_bg {
>  my $Data = "Hello World";
>  print " Selcted CPU is  : $val\n";
>  #$mw -> configure ( - background => $rb_value);
>  $mw -> configure ( -textvariable => $rb_value);

This is clearly the line that is causing the problem. It is complaining
that -textvariable is not a valid configuration option for that widget.
As I have no idea what you are trying to do, the best I can say is don't
do that.

>  print " File name is : $filename\n";
> if ( $rb_value eq "ext1" ) {
>   $filename = $filename . "\_" . $rb_value;
>   print " Edited name is : $filename \n";
>   open ( FILE, $filename ) or die " Can't open the $filename $!";
>   print FILE $Data; 
>  }
> 
> } 
> 
>  
> 
> /Perl/GUI>perl Radio.pl
>  Selcted CPU is  : ext1
> Tk::Error: Can't set -textvariable to `red' for
MainWindow=HASH(0x982af0): unknown option "-textvariable" at 
> /apps/perl/modules-0812/lib/x86_64-linux-thread-multi/Tk/Configure.pm
line 46.
>  at
/apps/perl/modules-0812/lib/x86_64-linux-thread-multi/Tk/Derived.pm line
294
> 
>  Tk callback for .
>  Tk::Derived::configure at
/apps/perl/modules-0812/lib/x86_64-linux-thread-multi/Tk/Derived.pm line
306
>  main::set_bg at Radio.pl line 26
>  Tk::BackTrace at
/apps/perl/modules-0812/lib/x86_64-linux-thread-multi/Tk.pm line 124
>  Tk::Derived::configure at
/apps/perl/modules-0812/lib/x86_64-linux-thread-multi/Tk/Derived.pm line
306
>  main::set_bg at Radio.pl line 26
>  Tk callback for .radiobutton
>  Tk::__ANON__ at
/apps/perl/modules-0812/lib/x86_64-linux-thread-multi/Tk.pm line 250
>  Tk::Radiobutton::Invoke at
/apps/perl/modules-0812/lib/x86_64-linux-thread-multi/Tk/Radiobutton.pm
line 42
>  
>  (command bound to event)

HTH

-- 
Brian Raven 
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: question about recursion

2009-05-22 Thread Brian Raven

From: perl-win32-users-boun...@listserv.activestate.com
[mailto:perl-win32-users-boun...@listserv.activestate.com] On Behalf Of
Greg Aiken
Sent: 21 May 2009 22:02
To: perl-win32-users@listserv.ActiveState.com
Subject: question about recursion

> given:
> 
> a. that its generally considered to be 'bad form' to use global
variables inside of sub-routines.

Make that "avoid globals as much as possible".

> b. that I need to write a recursive sub-routine to solve a
mathematical problem.

It isn't uncommon for mathematical problems that have a mathematical
solution that is recursive to be more effectively solved computationally
using iteration.

> 
> the sub-routine will recursively call itself until the 'answer' is
derived.  when the innermost call finishes 
> executing, the program will drop through to the previous call, and so
forth...  until it drops out of the 
> original first call to the function.
> 
> at present, I am 'cheating' here by using a global variable to control
this recursive behavior.  when the 
> innermost loop finds the 'answer', the global variable is set to
$weve_found_answer=1; 
> 
> the sub-routines then look to the value of $main::weve_found_answer to
determine if it should stop recursively > calling itself because the
answer has already been found - or continue to recursively call itself
again.
> 
> for now it 'works' but its not following the 'don't use globals unless
there is no better way' principle...
> 
> so I ask...  'is there a better way of allowing each sub routines
instantiation, at any nested level of the 
> recursive call, be able to know when the answer has been found?'
> 
> if anyone has any insights or experience with this, I would be very
interested to learn from your experience

Without more detail it is hard to say (some example code would be useful
here). However, you should be able to use the return value from your
recursive sub, rather than a global.

HTH

-- 
Brian Raven 
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: LWP Help please

2009-05-18 Thread Brian Raven
From: perl-win32-users-boun...@listserv.activestate.com
[mailto:perl-win32-users-boun...@listserv.activestate.com] On Behalf Of
steve silvers
Sent: 17 May 2009 21:10
To: perl-win32-users@listserv.activestate.com
Subject: LWP Help please

> I have looked over the LWP documentation but still have trouble
putting the pieces together. Can someone give 
> me a snippet that shows me how to query google for something, "and
display the results". The examples only show > how to match on something
and just print that out. How do I display the results, or format the
results?

Retrieving the results of a google query can be very easy using
LWP::Simple, as you can no doubt see from the documentation.

In order to give a sensible answer to your question "How do I display
the results, or format the results?" we will need to know what you mean
by that, at least something less vague. As LWP is mainly concerned with
retrieving data, it is unlikely to be involved, as your question seems
to be more related to doing something with the data after retrieving it.

HTH

-- 
Brian Raven 
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: Win32-TaskScheduler problem with remote systems

2009-05-15 Thread Brian Raven
David Evans <> wrote:
> Hey guys
> 
> I hope you can help.  Trying to create scheduled tasks on remote
> machines with Win32-TaskScheduler, the code appears to create the
> task successfully but it creates the task locally, not the specified
> remote machine.   
> 
> ***CODE***
> use Win32::TaskScheduler;
> 
> $scheduler = Win32::TaskScheduler->New();
> 
> %trig=(
> 'BeginYear' => 2009,
> 'BeginMonth' => 5,
> 'BeginDay' => 13,
> 'StartHour' => 17,
> 'StartMinute' => 37,
> 'TriggerType' =>
> $scheduler->TASK_TIME_TRIGGER_MONTHLYDOW,
> 'Type'=>{
> 'WhichWeek' => $scheduler->TASK_FIRST_WEEK |
> $scheduler->TASK_LAST_WEEK, 'DaysOfTheWeek'
> => $scheduler->TASK_FRIDAY |
> $scheduler->TASK_MONDAY, 'Months' =>
> $scheduler->TASK_JANUARY | $scheduler->TASK_APRIL |
> $scheduler->TASK_JULY | $scheduler->TASK_OCTOBER, }, );
> $tsk="wibble"; 
> 
> foreach $k (keys %trig) {print "$k=" . $trig{$k} . "\n";}
> $hostName = "remsvr";
> $usr = "remuser";
> $pwd = "rempw";
> $scheduler->NewWorkItem($tsk,\%trig);
> print($scheduler->SetTargetComputer($hostName));
> print(" set $hostName\n");
> print($scheduler->SetAccountInformation($usr,$pwd));
> print(" set $usr\n");
> $scheduler->SetApplicationName("winword.exe");
> $scheduler->Save();
> ***END CODE***
> 
> ***OUTPUT***
> C:\Scripting\File_Distro>Schedule-test.pl
> BeginYear=2009
> Type=HASH(0x22704c)
> StartHour=17
> BeginMonth=5
> StartMinute=37
> TriggerType=4
> BeginDay=13
> 1 set \\remsvr
> 1 set remuser
> ***END OUTPUT***
> 
> This is the example straight out of the docs with the
> SetAccountInformation and SetTargetComputer functions added. 
> 
> Windows XP SP2
> Perl 5.8.8 822 [280952]
> Win32-TaskScheduler 2.0.2
> 
> Any help would be greatly appreciated.

This is just a guess, but the example script
(http://cpansearch.perl.org/src/UNICOLET/Win32-TaskScheduler2.0.3/Exampl
e.pl) calls SetTargetComputer before calling Activate, so perhaps you
should try moving the call to before NewWorkItem, which creates a new
active task, in your script.

As I said, just a guess.

HTH

-- 
Brian Raven 
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: use system() function

2009-05-13 Thread Brian Raven

From: perl-win32-users-boun...@listserv.activestate.com
[mailto:perl-win32-users-boun...@listserv.activestate.com] On Behalf Of
mohammed.must...@wipro.com
Sent: 13 May 2009 06:30
To: jcm1...@gmail.com; Perl-Win32-Users@listserv.ActiveState.com
Subject: RE: use system() function

> Hi Chang Min Jeon,
>  
> Please use back stick operator here, instead of system command,
because system command doesn't return 
> anything.

Not so. From 'perldoc -f system':

"The return value is the exit status of the program as returned by the
"wait" call."

HTH

-- 
Brian Raven 
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: use system() function

2009-05-13 Thread Brian Raven

From: perl-win32-users-boun...@listserv.activestate.com
[mailto:perl-win32-users-boun...@listserv.activestate.com] On Behalf Of
Chang Min Jeon
Sent: 13 May 2009 01:14
To: Perl-Win32-Users@listserv.ActiveState.com
Subject: use system() function

> hello
> 
> I trying to modify file using perl one line like below.
> 
> my $cmd = "perl -pi -e's/aaa/bbb/' ";

That might not work in Win32 platforms. The command shell doesn't know
how to handle single quotes. You should use double quotes. Try something
like:

my $cmd = qq{perl -pi -e "s/aaa/bbb/g" };

> 
> open(MAKEFILES, '<', $ARGV[0]) or die "file open error";
> my @filelist = ;
> foreach my $file (@filelist) {
> chomp($file);
> my $command =  $cmd.$file;
> print $command,"\n";
> !system($command) or die "shell command not work";

Personally I prefer something like:

system $command;
$? == 0 or die "Command '$command' failed with exit code $?\n";

A bit more verbose perhaps, but I think that the intent is clearer.

> }
> close(MAKEFILES);
> 
> but system function does not work.
> 
> It print
> 
> ./Windowset/Common/Makefile.gmk
> perl -pi -e's/-+g -+dwarf2//' ./Windowset/Common/Makefile.gmk
> : No such file or directory.mmon/Makefile.gmk
> ./Windowset/Special/Makefile.gmk
> perl -pi -e's/-+g -+dwarf2//' ./Windowset/Special/Makefile.gmk
> : No such file or directory.cial/Makefile.gmk

It seems fairly clear that the above output was not produced by the code
that you supplied. This only serves to confuse those who might be able
to help. As it is, I can't reproduce the behaviour you describe. A
small, self-contained example script, that we could simply cut&paste and
run would be better, along with the output generated when you ran the
same code.

Also, what happens when you execute those commands manually?

HTH

-- 
Brian Raven 
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: expanding hash database

2009-04-29 Thread Brian Raven
Shain Edge <> wrote:
> I'm looking on how to create an expanding hash database.
> 
> How do I add to and navigate such a beast within the program itself?
> 
> Something of an example:
> 
> root:
> add energy
> root -> energy
> 
> add inorganic
> root --> energy
>  \-> inorganic
> 
> then adding a subroot to energy
> add solar
> root --> energy --> solar
>  \-> inorganic
> 
> and then increasing expansion as needed.

Have a look at 'perldoc perldsc' for starters.

HTH

-- 
Brian Raven 
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: :Socket question (client receive - when # of bytes to be receivedis NOT known in advance)

2009-04-22 Thread Brian Raven
From: perl-win32-users-boun...@listserv.activestate.com
[mailto:perl-win32-users-boun...@listserv.activestate.com] On Behalf Of
Greg Aiken
Sent: 22 April 2009 00:36
To: perl-win32-users@listserv.activestate.com
Subject: IO::Socket question (client receive - when # of bytes to be
receivedis NOT known in advance)

> method 1 (below) does work to receive a response from a server.  but
requires I know in advance the number of 
> bytes to receive.
>  
> I am wondering if something like method 2 may be used in the case of
where one does NOT know in advance how 
> many bytes the server will be sending.  ive attempted to try this
using the code presented in method 2, but 
> this fails miserably.  was hoping someone in the group had a working
alternative method to share.
>  
>  
> use IO::Socket;
>  
> $http_get_request = << "HTTP_GET";
> GET /index.htm HTTP/1.1
> Host: google.com
> Keep-Alive: timeout=15, max=60
> Connection: keep-alive
>  
> HTTP_GET
>  
> #setup client socket
> $main::socket = new IO::Socket::INET 
> ( Proto  => "tcp", PeerAddr => "google.com", PeerPort => "80", );
> $main::socket->autoflush(1);
>  
> #send http1.1 (persistent connection) request for data
> $main::socket->send($http_get_request);
>  
>  
> #receive the http1.1 response...
>  
> #method 1
> #this method works
> #but requires i know how many bytes to receive
> #which I dont always know - so i dont like this method
> $main::socket->recv($response, 8192);
> print $response;
>  
> #method 2
> #cant something like this be done instead?
> #i would prefer to use this pseudo-code method
> #as there is no hard-coded number of bytes to receive
> #is there a way to achieve this?
> #  while ( $main::socket->recv($block, 8192) ) {
> # $response .= $block;
> #  }
> #  print $response;

I hope you are not trying to reinvent that particular wheel. If so, see
'perldoc lwptut' and 'perldoc lwpcook'. At its simplest, it is little
more than a one-liner.

If you are just using that as an example, thenyour method 2 is a
perfectly reasonable way to read an unknown amount of data from a
socket. The while loop will read until the socket is closed. For
anything more fine grained than that, or it is your responsibility to
close the socket, then you will need to know how to recognise when to
start and stop reading from the socket, which depends on the protocol
that is being used. It can also depend on what else you are trying to
do, if anything.

HTH

-- 
Brian Raven 
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: active perl 5.8.8 build 820 inconsistent behavior with $input =;

2009-04-16 Thread Brian Raven
From: perl-win32-users-boun...@listserv.activestate.com
[mailto:perl-win32-users-boun...@listserv.activestate.com] On Behalf Of
Greg Aiken
Sent: 16 April 2009 16:25
To: perl-win32-users@listserv.activestate.com
Subject: active perl 5.8.8 build 820 inconsistent behavior with $input
=; 

> I seem to be experiencing inconsistency when I invoke;
> 
> $user_input = ;
> 
> in some programs the behavior is as expected.  at that point in the
program I type in some input from keyboard > then the moment I press the
'enter' key, the program flow returns back to the executing Perl
program.
> 
> other times, I get a rather unusual response.  
> 
> I type in user input from the keyboard and when I press the 'enter'
key, instead of having program flow return > back to the program, the
enter key is instead OUTPUT TO THE DOS CONSOLE SCREEN and the cursor
drops down one 
> line on the console screen!  when this happens, the program flow does
NOT return back to the program and my 
> program just hangs there.
> 
> any explanation for this?
> 
> more importantly, whats the fix?
> 
> today it just happened again.  the relevant block of code is here...

Actually, I think the relevant block of code may be further down.

[Some stuff deleted]

> sub assign_xml_request_from_xml_file {
> open (IN, "xml.request");
> undef $/;

You have just globally changed the input record separator to slurp mode,
for all input. This may be the cause of your problem. This is one of the
few instances where 'local' is needed, i.e. to temporarily change the
value of a special variable. Make that:

local $/;

> my $xml_request = ;
> return $xml_request;
> }
> 
> sub assign_http_request_from_http_file {
> open (IN, "http.request");
> undef $/;
> my $http_request = ;
> return $http_request;
> }

The above two functions look identical apart from the filename, so why
not use a single function. For example, here is one I wrote earlier:

sub read_file {
my $fn = shift;
open my $fd, "<", $fn or die "Failed to open $fn: $!\n";
local $/;
my $data = <$fd>;
close $fd;
return $data;
}

Note the 3 argument form of open, and the localised file handle. Or
course, if you can install File::Slurp, you don't even need to write
one.

Also, its better to call subs without the '&' prefix, unless you know
what that does, and you need it.

HTH

-- 
Brian Raven 
 

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: running a dos program from perl

2009-04-01 Thread Brian Raven
From: perl-win32-users-boun...@listserv.activestate.com
[mailto:perl-win32-users-boun...@listserv.activestate.com] On Behalf Of
Spencer Chase
Sent: 01 April 2009 01:44
To: perl-win32-users@listserv.ActiveState.com
Subject: running a dos program from perl

> Greetings Perl-win32-users,
> 
> I need to run a dos program with parameters about 1500 times with
different parameter sets. I have a perl 
> script that creates batch files with the program call and parameters
and these work fine. I am trying to find a > way to automatically run
all the batch files. The dos program also requires confirmation from the
keyboard 7 
> time to run to completion. If I run the program from a batch file I
just need to hit "enter" 7 times before the > first one is needed and
the program runs to completion so the keystrokes are buffered and used
by the program 
> appropriately. 
> 
> Is there any way to run this program from perl and have the perl
script supply the 7 required enters? I don't 
> understand enough about threads and processes to figure out how this
might be done. I have tried calling the 
> batch files using system, backticks and system and can not get even
close. 

I suggest taking a look at 'perldoc perlipc', as well as  'perldoc
IPC::Open2' and 'perldoc IPC::Open3'. Installing IPC::Cmd and/or
IPC::Run may help simplify things a bit.

HTH

-- 
Brian Raven 

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: Reset in ANSIColor sets the background to black

2009-04-01 Thread Brian Raven
From: perl-win32-users-boun...@listserv.activestate.com
[mailto:perl-win32-users-boun...@listserv.activestate.com] On Behalf Of
Perl Help
Sent: 31 March 2009 23:33
To: Sisyphus
Cc: perl-win32-users@listserv.activestate.com
Subject: Re: Reset in ANSIColor sets the background to black

> Hi Rob,
> 
> I am facing another problem with this code. When I call the function
twice in the same script, it throws me the > following error:
> 
> Error Msg: Test[This is in Red color as expected for the first
function call]
> Use of uninitialized value in bitwise and (&) at test.pl line 12.
> 
> My Script is :
> 
> #33 START #3
> use strict;
> use warnings;
> use Win32::Console;
> 
> ErrorMsg('Test');
> ErrorMsg('Test');
> 
> sub ErrorMsg {
>my $error = shift;
>my $console = Win32::Console->new(STD_OUTPUT_HANDLE);
>my $CurrentConsoleColor = $console->Attr;
>my $BackgroundColor = $CurrentConsoleColor & 
>
(BACKGROUND_RED|BACKGROUND_BLUE|BACKGROUND_GREEN|BACKGROUND_INTENSITY);
># This sets the text color on DOS in red with intensity
>
$console->Attr(FOREGROUND_RED|FOREGROUND_INTENSITY|$BackgroundColor);
>print "\nError Msg: $error \n";
>$console->Attr($CurrentConsoleColor);
> }
> 3 END 
> 
> I tried to delete the handle to the console but then I do not get any
output at all.
> Also, in actual world my sub ErrorMsg is defined in a .pm file and
this function is called by multiple scripts > and I can not get handle
to win32 console in script and pass it to the module due to some project
restrictions. > ALso, this error happens because I am trying to call  my
$console = Win32::Console->new(STD_OUTPUT_HANDLE) 
> twice in the same script. Is there a way I can still call it twice in
the same script? 
> 
> Any help is much appreciated. 

It certainly looks like it causes problems if you create a second
instance of Win32::Console. If there is nothing in the documentation
about this being a 'feature', it might be worth raising it with the
module's maintainers.

As you say your ErrorMsg sub is in a separate module, it will be fairly
easy to keep the Win32::Console in a package scope variable that is only
initialised once. For example:

use strict;
use warnings;

package MyErrorModule;

use base qw{Exporter};
use Win32::Console;
use Carp;

our @EXPORT = qw{ErrorMsg};

our $console;

sub ErrorMsg {
   my $error = shift;
   $console = Win32::Console->new(STD_OUTPUT_HANDLE)
   unless defined $console;
   defined $console
   or croak "Failed to get console: $!\n";
   my $CurrentConsoleColor = $console->Attr;
   defined $CurrentConsoleColor
   or croak "Failed to get current console colour: $!\n";
   my $BackgroundColor = $CurrentConsoleColor &
(BACKGROUND_RED|BACKGROUND_BLUE|BACKGROUND_GREEN|BACKGROUND_INTENSITY);
   # This sets the text color on DOS in red with intensity
   $console->Attr(FOREGROUND_RED|FOREGROUND_INTENSITY|$BackgroundColor);
   print "\nError Msg: $error \n";
   $console->Attr($CurrentConsoleColor);
}

1;

HTH

-- 
Brian Raven 

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: what is the most robust and accurate way to determine the BOOTvolume?

2009-03-31 Thread Brian Raven
From: perl-win32-users-boun...@listserv.activestate.com
[mailto:perl-win32-users-boun...@listserv.activestate.com] On Behalf Of
Greg Aiken
Sent: 30 March 2009 23:01
To: perl-win32-users@listserv.activestate.com
Subject: RE: what is the most robust and accurate way to determine the
BOOTvolume?

> I discovered (on my computer) that ENV vars named 'SystemRoot' and
'SystemDrive' exist.
> 
> Does anyone know if these would be present on all Windows computers?  
> 
> If so, it would seem the answer here would be to merely look at
$ENV{'SystemDrive'}
> 
> Can anyone think of a reason where these ENV vars would not exist?

First, do you mean boot volume or system volume. They are often the
same, but not necessarily. See http://support.microsoft.com/kb/314470.

Second, if you really mean 'robust and accurate' you should be careful
of relying on environment variables, as they can be easily changed or
removed. It might be safer to use a win32 API call. For example (and
this is the fiest time I have tried this):

use strict;
use warnings;

use Win32::API;

my $proto = 'UINT GetSystemDirectory(LPTSTR lpBuffer, UINT uSize)';
Win32::API->Import('kernel32', $proto)
or die "Failed to import $proto: $^E\n";
my $buflen = 20;
my $buf = ' ' x $buflen;
my $result = GetSystemDirectory($buf, $buflen);
if ($result == 0) {
die "GetSystemDirectory failed: $^E\n";
}
elsif ($result > $buflen) {
die "GetSystemDirectory buffer needs to be at least $result
bytes\n";
}

print "System directory is ", substr($buf, 0, $result), "\n";

HTH

-- 
Brian Raven 

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


  1   2   >