drag'n'drop onto desktop icon ???

2005-05-23 Thread Michael D Schleif
I have a perl program that successfully processes a set of text files.
So far, the UI is to pass the incoming text file to the program on the
command line.

Users want an icon on their desktops, and they want to drag the text
file onto this icon, in order to process the file.

I have not been able to figure out how to do this.

What do you think?

-- 
Best Regards,

mds
mds resource
877.596.8237
-
Dare to fix things before they break . . .
-
Our capacity for understanding is inversely proportional to how much
we think we know.  The more I know, the more I know I don't know . . .
--


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


RE: win32::Lanman Error

2005-05-23 Thread shailja_agrawal
Hello Rob,

I have modified the script like below


if(!Win32::Lanman::NetUserEnum($PDC, FILTER_NORMAL_ACCOUNT,
[EMAIL PROTECTED]))
 {
print Sorry, something went wrong; error: ;
# get the error code
print Win32::Lanman::GetLastError();
print \n;
print Win32::FormatMessage( Win32::Lanman::GetLastError() );
print Win32::Lanman::GetLastError(),  , Win32::GetLastError(),
 ,Win32::FormatMessage(Win32::GetLastError()), \n;

 }

And you were right in probably guessing the error right, the error from
Win32::Lanman::GetLastError() is 1726 (The remote procedure call failed)
and from Win32::GetLastError() is 0 (Request completed successfully).

I am not sure what is going wrong with this simple script as it works
sometimes and throws error other time.

Regards,
Shailja Agrawal



-Original Message-
From: Sisyphus [mailto:[EMAIL PROTECTED] 
Sent: Thursday, May 19, 2005 1:56 PM
To: AGRAWAL,SHAILJA (Non-A-India,ex1);
perl-win32-users@listserv.ActiveState.com
Subject: Re: win32::Lanman Error


- Original Message - 
From: [EMAIL PROTECTED]
To: [EMAIL PROTECTED];
perl-win32-users@listserv.ActiveState.com
Sent: Thursday, May 19, 2005 5:23 PM
Subject: RE: win32::Lanman Error


 Hello Rob,

 Actually, I initially thought that because of the volume of the data
(it
 fetches around 60k records so) I had an impression that it might take
 some time, but your statement has raised an alarm to me.


Sorry - I assumed that because it was a simple script, it would run
quickly
 perhaps that's not the case. I have little experience in this area.

 Also, last night the job failed again but this time I have captured
the
 error successfully (hopefully).

 if(!Win32::Lanman::NetUserEnum($PDC, FILTER_NORMAL_ACCOUNT,
 [EMAIL PROTECTED]))
  {
 print Sorry, something went wrong; error: ;
 # get the error code
 print Win32::Lanman::GetLastError();

Instead, I would have:
print Win32::Lanman::GetLastError(),  , Win32::GetLastError(),  ,
Win32::FormatMessage(Win32::GetLastError()), \n;

If you find that  Win32::Lanman::GetLastError() and
Win32::GetLastError()
report different numbers, then the formatted message is probably
incorrect.
But I expect that Win32::Lanman::GetLastError() and
Win32::GetLastError() to
report the same number (in which case the formatted message should be
correct).

  }

 Result:
 Sorry, something went wrong; error: 53


It would be better if you could get the error message as a string,
rather
than a number (see my attempt to do that, above). The error codes (and
their
meanings) are probably available somewhere on the MS website (among
other
places). I have them listed in my Visual Studio documentation so I
looked up
53 there. It means that the network path was not found. Why would that
happen ?

Was that error thrown by NetUserEnum() or by NetGetDCName() ? I expect
that
if the network path was not found then NetGetDCName(), which gets
called
*before* NetUserEnum(), should fail - or does NetGetDCName() not need to
find the network path ?

Cheers,
Rob


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


Re: drag'n'drop onto desktop icon ???

2005-05-23 Thread $Bill Luebkert
Michael D Schleif wrote:

 I have a perl program that successfully processes a set of text files.
 So far, the UI is to pass the incoming text file to the program on the
 command line.
 
 Users want an icon on their desktops, and they want to drag the text
 file onto this icon, in order to process the file.
 
 I have not been able to figure out how to do this.
 
 What do you think?

Have you tried creating a shortcut to Perl and renaming it to the
name of the Perl script and add the path to the perl script as an
arg ?

Set Properties-Shortcut-Target to something like :

C:\Perl\bin\perl.exe C:\Home\Me\test.pl (adjust the arg to point to 
your script)

And test.pl:

use strict;
use Win32;

my $msg = '';
$msg .= $_\n foreach @ARGV;
Win32::MsgBox($msg);# print args in MsgBox

__END__

-- 
  ,-/-  __  _  _ $Bill LuebkertMailto:[EMAIL PROTECTED]
 (_/   /  )// //   DBE CollectiblesMailto:[EMAIL PROTECTED]
  / ) /--  o // //  Castle of Medieval Myth  Magic http://www.todbe.com/
-/-' /___/__/_/_http://dbecoll.tripod.com/ (My Perl/Lakers stuff)
___
Perl-Win32-Users mailing list
Perl-Win32-Users@listserv.ActiveState.com
To unsubscribe: http://listserv.ActiveState.com/mailman/mysubs


Re: need help with utf8

2005-05-23 Thread Ing. Branislav Gerzo (mail-lists)
[EMAIL PROTECTED] [a], on Monday, May 23, 2005 at 05:12 (UT) wrote:

a typical filename in mail message looks like
a my $name==?UTF-8?B?0L8xX9C80LXRgdGP0YfQvdCw0Y8ucnRm?=;
a i need to convert this to utf8 and then to cp1251
a How precisely to do this ?

I think you have to decode this via MIME, and after to cp1251. But
some characters aren't in 1251, so I use something different:

use Unicode::Normalize;
#decode here via MIME to utf-8
$string = acc($utf8);

sub acc {
(my $str = NFD(decode(utf8, shift))) =~ s/\pM//og;
return $str;
}

-- 

How do you protect mail on web? I use http://www.2pu.net

[Blue Wave Reader v2.30.  Available in 3 flavors!  Try one!]




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


RE: drag'n'drop onto desktop icon ???

2005-05-23 Thread Jack D.
 
 -Original Message-
 From: [EMAIL PROTECTED] 
 [mailto:[EMAIL PROTECTED] On 
 Behalf Of Michael D Schleif
 Sent: May 22, 2005 11:29 PM
 To: perl-win32-users mailing list
 Subject: drag'n'drop onto desktop icon ???
 
 I have a perl program that successfully processes a set of text files.
 So far, the UI is to pass the incoming text file to the 
 program on the command line.
 
 Users want an icon on their desktops, and they want to drag 
 the text file onto this icon, in order to process the file.
 
 I have not been able to figure out how to do this.
 
 What do you think?
 
You can add a DropHandler to the registry manually (or just run the perl
program provided below)

###
use Win32::TieRegistry;
$Registry-Delimiter(/);
$perlKey = $Registry-{HKEY_CLASSES_ROOT/Perl/};
$perlKey-{shellex/} = {
DropHandler/ = {
/={86C86720-42A0-1069-A2E8-08002B30309D}
}};
###

Once that is done - any icon with the .pl extension should receive the
filenames in @ARGV.

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


Re:Re: need help with utf8

2005-05-23 Thread assistent
[EMAIL PROTECTED] [a], on Monday, May 23, 2005 at 05:12 (UT) wrote:

a typical filename in mail message looks like
a my $name==?UTF-8?B?0L8xX9C80LXRgdGP0YfQvdCw0Y8ucnRm?=;
a i need to convert this to utf8 and then to cp1251
a How precisely to do this ?

I think you have to decode this via MIME, and after to cp1251. But
some characters aren't in 1251, so I use something different:

use Unicode::Normalize;
#decode here via MIME to utf-8
$string = acc($utf8);

sub acc {
(my $str = NFD(decode(utf8, shift))) =~ s/\pM//og;
return $str;
}

-- 
thank you!
all  characters are in 1251
so here is snippet:
==
use Encode;
#decode here via MIME to utf-8
use MIME::Base64;   
my $name=0L8xX9C80LXRgdGP0YfQvdCw0Y8ucnRm;
my $utf8=decode_base64($name);
my $x1=decode(utf8,$utf8);
my $x2=encode('cp-1251',$x1);
print x2=$x2\n;
# file name in x2
==
i missed  
my $x1=decode(utf8,$utf8);




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


error in DynaLoader.pm loading DLL on (some) machines

2005-05-23 Thread Bennett Haselton
I have a Perl script installed on my XP Pro Sp2 machine with ActivePerl 
5.8.3 build 809, that uses Net::SSLeay version 1.25 to download https URLs, 
and works fine.  I also have the Web server OpenSA 2.0.2 which runs some 
CGI scripts that use Net::SSLeay to fetch content from third-party https 
sites and those work too.


However, a friend of mine has installed the same script on his machine 
where he has the exact same version of Perl, the exact same version of 
OpenSA, and the exact same version of Net::SSLeay installed, and is seeing 
this odd behavior:


1) If he has this script:

#!c:/perl/bin/perl.exe

eval { require Net::SSLeay } ;
if ($@)
{
print Yes: [EMAIL PROTECTED];
}
else
{
print No.\n;
}

in a file named nph-test.cgi and runs it from the command line with the 
command perl nph-test.cgi, it outputs No.  (That is, the require 
Net::SSLeay statement runs with no problem.)


2) BUT, if he loads the same script in a Web browser from the cgi-bin 
directory of OpenSA, it outputs:


Yes: Can't load 'C:/Perl/site/lib/auto/Net/SSLeay/SSLeay.dll' for
module Net::SSLeay: load_file:The specified module could not be found
at C:/Perl/lib/DynaLoader.pm line 229.
 at C:/OpenSA/Apache2/cgi-bin/nph-test.cgi line 3
Compilation failed in require at C:/OpenSA/Apache2/cgi-bin/nph-test.cgi 
line 3.


(Note, the file C:/Perl/site/lib/auto/Net/SSLeay/SSLeay.dll *does* exist on 
his machine.)


3) On my machine the script works fine (i.e. outputs No, indicating no 
error loading Net::SSLeay) when run from the command line OR loaded via the 
Web server.


Any idea why this error would happen only when the script is run through 
the Web server, and why it would happen only on one machine but not 
another?


The relevant line of DynaLoader.pm says:

# Many dynamic extension loading problems will appear to come from
# this section of code: XYZ failed at line 123 of DynaLoader.pm.
# Often these errors are actually occurring in the initialisation
# C code of the extension XS file. Perl reports the error as being
# in this perl code simply because this was the last perl code
# it executed.

my $libref = dl_load_file($file, $module-dl_load_flags) or
croak(Can't load '$file' for module $module: .dl_error());


I'm not sure what that means though.  What would the extension XS file be 
in this case?  There are no *.xs files in C:\Perl\site\lib\auto\Net\SSLeay.


-Bennett

[EMAIL PROTECTED] http://www.peacefire.org
(425) 497 9002

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


Re: error in DynaLoader.pm loading DLL on (some) machines

2005-05-23 Thread Randy Kobes
On Mon, 23 May 2005, Bennett Haselton wrote:

 I have a Perl script installed on my XP Pro Sp2 machine
 with ActivePerl 5.8.3 build 809, that uses Net::SSLeay
 version 1.25 to download https URLs, and works fine.  I
 also have the Web server OpenSA 2.0.2 which runs some CGI
 scripts that use Net::SSLeay to fetch content from
 third-party https sites and those work too.

 However, a friend of mine has installed the same script on
 his machine where he has the exact same version of Perl,
 the exact same version of OpenSA, and the exact same
 version of Net::SSLeay installed, and is seeing this odd
 behavior:

 1) If he has this script:
  
 #!c:/perl/bin/perl.exe

 eval { require Net::SSLeay } ;
 if ($@)
 {
   print Yes: [EMAIL PROTECTED];
 }
 else
 {
   print No.\n;
 }
  
 in a file named nph-test.cgi and runs it from the command line with the
 command perl nph-test.cgi, it outputs No.  (That is, the require
 Net::SSLeay statement runs with no problem.)

 2) BUT, if he loads the same script in a Web browser from the cgi-bin
 directory of OpenSA, it outputs:
  
 Yes: Can't load 'C:/Perl/site/lib/auto/Net/SSLeay/SSLeay.dll' for
 module Net::SSLeay: load_file:The specified module could not be found
 at C:/Perl/lib/DynaLoader.pm line 229.
   at C:/OpenSA/Apache2/cgi-bin/nph-test.cgi line 3
 Compilation failed in require at C:/OpenSA/Apache2/cgi-bin/nph-test.cgi
 line 3.
  
 (Note, the file C:/Perl/site/lib/auto/Net/SSLeay/SSLeay.dll *does* exist on
 his machine.)

 3) On my machine the script works fine (i.e. outputs No, indicating no
 error loading Net::SSLeay) when run from the command line OR loaded via the
 Web server.

 Any idea why this error would happen only when the script is run through
 the Web server, and why it would happen only on one machine but not
 another?

That error is probably slightly misleading - it can result
from Net::SSLeay not finding the ssl dlls (libeay32.dll
and/or ssleay32.dll). Try adjusting the PATH environment
variable to include the directory where these dlls live (eg,
Apache has a SetEnv directive for doing such things). You'll
also have to ensure that the permissions on the directories
where the dlls are located are such that the dlls are
loadable by the user that the web server is running as.

-- 
best regards,
randy kobes
___
Perl-Win32-Users mailing list
Perl-Win32-Users@listserv.ActiveState.com
To unsubscribe: http://listserv.ActiveState.com/mailman/mysubs


How secure is Perl FTP function

2005-05-23 Thread Ted Yu


$ftp = Net::FTP-new("$ftp_server_name", Debug = 0) or die(""); #server_error, ,$ftp-login("$ftp_user","$ftp_pass");
$ftp-binary;
$ftp-put("$upload_filename");
$ftp-quit;
If I compile the code into an .exe file with ActiveState Perl, can an average hacker look at the machine code to get the username, password, and FTP address? ___
Perl-Win32-Users mailing list
Perl-Win32-Users@listserv.ActiveState.com
To unsubscribe: http://listserv.ActiveState.com/mailman/mysubs


Re: error in DynaLoader.pm loading DLL on (some) m

2005-05-23 Thread Bennett Haselton
 -Original Message-
 From: Randy Kobes [mailto:[EMAIL PROTECTED]
 Sent: Monday, May 23, 2005 05:31 PM
 To: 'Bennett Haselton'
 Cc: perl-win32-users@listserv.ActiveState.com
 Subject: Re: error in DynaLoader.pm loading DLL on (some) machines
 
 On Mon, 23 May 2005, Bennett Haselton wrote:
 
  I have a Perl script installed on my XP Pro Sp2 machine
  with ActivePerl 5.8.3 build 809, that uses Net::SSLeay
  version 1.25 to download https URLs, and works fine.  I
  also have the Web server OpenSA 2.0.2 which runs some CGI
  scripts that use Net::SSLeay to fetch content from
  third-party https sites and those work too.
 
  However, a friend of mine has installed the same script on
  his machine where he has the exact same version of Perl,
  the exact same version of OpenSA, and the exact same
  version of Net::SSLeay installed, and is seeing this odd
  behavior:
 
  1) If he has this script:
   
  #!c:/perl/bin/perl.exe
 
  eval { require Net::SSLeay } ;
  if ($@)
  {
  print Yes: [EMAIL PROTECTED];
  }
  else
  {
  print No.\n;
  }
   
  in a file named nph-test.cgi and runs it from the command line with the
  command perl nph-test.cgi, it outputs No.  (That is, the require
  Net::SSLeay statement runs with no problem.)
 
  2) BUT, if he loads the same script in a Web browser from the cgi-bin
  directory of OpenSA, it outputs:
   
  Yes: Can't load 'C:/Perl/site/lib/auto/Net/SSLeay/SSLeay.dll' for
  module Net::SSLeay: load_file:The specified module could not be found
  at C:/Perl/lib/DynaLoader.pm line 229.
at C:/OpenSA/Apache2/cgi-bin/nph-test.cgi line 3
  Compilation failed in require at C:/OpenSA/Apache2/cgi-bin/nph-test.cgi
  line 3.
   
  (Note, the file C:/Perl/site/lib/auto/Net/SSLeay/SSLeay.dll *does* exist on
  his machine.)
 
  3) On my machine the script works fine (i.e. outputs No, indicating no
  error loading Net::SSLeay) when run from the command line OR loaded via the
  Web server.
 
  Any idea why this error would happen only when the script is run through
  the Web server, and why it would happen only on one machine but not
  another?
 
 That error is probably slightly misleading - it can result
 from Net::SSLeay not finding the ssl dlls (libeay32.dll
 and/or ssleay32.dll). Try adjusting the PATH environment
 variable to include the directory where these dlls live (eg,
 Apache has a SetEnv directive for doing such things). You'll
 also have to ensure that the permissions on the directories
 where the dlls are located are such that the dlls are
 loadable by the user that the web server is running as.

Randy,

Thanks for the tips.  The PATH environment variable on the machine actually 
does already include the c:\OpenSA\Apache2\bin directory containing 
libeay32.dll and ssleay32.dll, but yes I wonder if it's something to do with 
Apache.exe running under a different user.  It's running as the user SYSTEM.

Is there a way that I can run the Perl script from the command line as the 
user SYSTEM, to see if it encounters the same error?  I was going to have him do
runas /user:SYSTEM perl nph-test.cgi

However, if you do that, you get prompted for the password for the built-in 
SYSTEM account, which I believe is not normally accessible to the user.  Is 
there any other way to run it as SYSTEM?

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


Re: How secure is Perl FTP function

2005-05-23 Thread Bennett Haselton
I would think so -- or, even easier, they can run your program under a network 
sniffer and see what data is sent out by the program, since FTP sends usernames 
and passwords unencrypted.

What are you trying to do?  There might be a more secure solution.

-Bennett

 -Original Message-
 From: Ted Yu [mailto:[EMAIL PROTECTED]
 Sent: Monday, May 23, 2005 06:34 PM
 To: perl-win32-users@listserv.ActiveState.com
 Subject: How secure is Perl FTP function
 
 
$ftp = Net::FTP-new($ftp_server_name, Debug = 0) or die(); 
 #server_error,   ,
$ftp-login($ftp_user,$ftp_pass);
 
$ftp-binary;
 
$ftp-put($upload_filename);
 
$ftp-quit;
 
 If I compile the code into an .exe file with ActiveState Perl, can an average 
 hacker look at the machine code to get the username, password, and FTP 
 address?  
 
 
___
Perl-Win32-Users mailing list
Perl-Win32-Users@listserv.ActiveState.com
To unsubscribe: http://listserv.ActiveState.com/mailman/mysubs


Re: How secure is Perl FTP function

2005-05-23 Thread Octavian Rasnita



Yes of course the hacker can do that.
If you don't want that, try using a secure FTP 
connection crypted with SSL.

And then use the module Net::SFTP.

Teddy



  - Original Message - 
  From: 
  Ted Yu 
  To: perl-win32-users@listserv.ActiveState.com 
  
  Sent: Monday, May 23, 2005 9:34 PM
  Subject: How secure is Perl FTP 
  function
  
  
  
$ftp = Net::FTP-new("$ftp_server_name", Debug = 
0) or die(""); #server_error, 
,$ftp-login("$ftp_user","$ftp_pass");
$ftp-binary;
$ftp-put("$upload_filename");
$ftp-quit;
If I compile the code into an .exe file with ActiveState Perl, can an 
average hacker look at the machine code to get the username, password, and 
FTP address? 
  
  

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


Re: How secure is Perl FTP function

2005-05-23 Thread Steve Keith

Yes, you should consider anything that you put into the EXE file as not
secure.
Also, I believe any Net::FTP session sends the info in clear text.  If you
need to be secure, then you should use SSH instead of Net::FTP

Steve


$ftp = Net::FTP-new($ftp_server_name, Debug = 0) or die();
#server_error,   ,
$ftp-login($ftp_user,$ftp_pass);
$ftp-binary;
$ftp-put($upload_filename);
$ftp-quit;

 If I compile the code into an .exe file with ActiveState Perl, can an
average hacker look at the machine code to get the username, password, and
FTP address?

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


CSV: help optimize ???

2005-05-23 Thread Michael D Schleif
I have an ongoing stream of CSV files of varying lengths (some quite
long), and of various CSV formats.  I am using Text::CSV_XS to parse the
records; which works except in that case where the incoming file
surrounds each RECORD with double-quotes.

I find this to be aberrant behaviour.  How can I tell Text::CSV_XS to
ignore double-quotes around records?

I have the following code that normalizes each line prior to parsing
with Text::CSV_XS:

if (
 /^/
   /$/
 tr/// == 2
){
s!(^|$)!!g;
}

Obviously, in the majority of cases this should be a no-op, since
double-quotes surround fields, NOT records.

How can I optimize this sub-routine for minimal processing overhead in
those cases where it does not apply?

-- 
Best Regards,

mds
mds resource
877.596.8237
-
Dare to fix things before they break . . .
-
Our capacity for understanding is inversely proportional to how much
we think we know.  The more I know, the more I know I don't know . . .
--


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


RE: How secure is Perl FTP function

2005-05-23 Thread Bharucha, Nikhil
This is of more concern than somebody getting the UID and Password from
your exe on your server.  I see the code below specifies binary, so the
data is encrypted but the UID and Password you connect on is sent in
text and anyone sniffing your connection can get it.


-Original Message-
From: [EMAIL PROTECTED]
[mailto:[EMAIL PROTECTED] On Behalf Of
Steve Keith
Sent: Monday, May 23, 2005 3:57 PM
To: perl-win32-users@listserv.ActiveState.com
Subject: Re: How secure is Perl FTP function


Yes, you should consider anything that you put into the EXE file as not
secure.
Also, I believe any Net::FTP session sends the info in clear text.  If
you
need to be secure, then you should use SSH instead of Net::FTP

Steve


$ftp = Net::FTP-new($ftp_server_name, Debug = 0) or die();
#server_error,   ,
$ftp-login($ftp_user,$ftp_pass);
$ftp-binary;
$ftp-put($upload_filename);
$ftp-quit;

 If I compile the code into an .exe file with ActiveState Perl, can an
average hacker look at the machine code to get the username, password,
and
FTP address?

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


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


RE: help optimize ???

2005-05-23 Thread Peter Guzis
Below is one possible optimization: the elimination of regular expressions.


## begin code ##


use strict;
use warnings;
use Benchmark;

# populate record list

my @records;

foreach my $record (DATA) {

  chomp ($record);
  push @records, $record;

}

# benchmark

timethese (100, {
  do_regex = \do_regex,
  do_index = \do_index
});

exit;

# find records enclosed in quotes (regex way)

sub do_regex {

  my $record;

  foreach my $record (@records) {

if ($record =~ /^/  $record =~ /$/  $record =~ tr/// == 2) {

  # handle enclosed record

}

  }

}

# find records enclosed in quotes (substr/index)

sub do_index {

  foreach my $record (@records) {

if (substr ($record, 0, 1) eq ''  index ($record, '', 1) == length 
($record) - 1) {

  # handle enclosed record

}

  }

}

__DATA__
Field1,Field2,Field3,Field4,Field5
Field1,Field2,Field3,Field4,Field5
Field1,Field2,Field3,Field4,Field5
Field1,Field2,Field3,Field4,Field5
Field1,Field2,Field3,Field4,Field5
Field1,Field2,Field3,Field4,Field5
Field1,Field2,Field3,Field4,Field5
Field1,Field2,Field3,Field4,Field5
Field1,Field2,Field3,Field4,Field5
Field1,Field2,Field3,Field4,Field5

##
## end code ##
##

Benchmark results (P4/1.3GHz)
-
Benchmark: timing 100 iterations of do_index, do_regex...
  do_index: 21 wallclock secs (19.89 usr +  0.06 sys = 19.95 CPU) @ 50130.34/s (
n=100)
  do_regex: 33 wallclock secs (30.01 usr +  0.05 sys = 30.06 CPU) @ 33263.48/s (
n=100)

I hope this helps.

-Original Message-
From: [EMAIL PROTECTED]
[mailto:[EMAIL PROTECTED] Behalf Of
Michael D Schleif
Sent: Monday, May 23, 2005 1:43 PM
To: perl-win32-users mailing list
Subject: CSV: help optimize ???


I have an ongoing stream of CSV files of varying lengths (some quite
long), and of various CSV formats.  I am using Text::CSV_XS to parse the
records; which works except in that case where the incoming file
surrounds each RECORD with double-quotes.

I find this to be aberrant behaviour.  How can I tell Text::CSV_XS to
ignore double-quotes around records?

I have the following code that normalizes each line prior to parsing
with Text::CSV_XS:

if (
 /^/
   /$/
 tr/// == 2
){
s!(^|$)!!g;
}

Obviously, in the majority of cases this should be a no-op, since
double-quotes surround fields, NOT records.

How can I optimize this sub-routine for minimal processing overhead in
those cases where it does not apply?

-- 
Best Regards,

mds
mds resource
877.596.8237
-
Dare to fix things before they break . . .
-
Our capacity for understanding is inversely proportional to how much
we think we know.  The more I know, the more I know I don't know . . .
--

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


Win32::OLE Can you call ShowOpen Method

2005-05-23 Thread mark
Title: Win32::OLE  Can you call ShowOpen Method 






Hello All,

I would like to use OLE to access the common dialog control. I can get access to a number of methods however the ShowOpen does not work. Is it possible to use show open to get a File Open Dialog. I can do this using Win32::GUI and TK, however it would be neat to do it here. 

Any help would be great.

Mark

Olegui.pl

-w;

use strict;

use Win32::OLE;

my $CommDlg = Win32::OLE-new(MSComDlg.CommonDialog)|| die Could not start Common Dialog\n;

$CommDlg-ShowPrinter;

$CommDlg-AboutBox;

$CommDlg-ShowOpen;



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


Re: help optimize ???

2005-05-23 Thread $Bill Luebkert
Peter Guzis wrote:

 Below is one possible optimization: the elimination of regular expressions.

My version (it handles quoted fields on both ends, but there could be some
better way to strip the s on the substr/index) :

Results:
Rate do_index do_regex
do_index 33473/s   -- -13%
do_regex 38438/s  15%   --


use strict;
use warnings;
use Benchmark qw(cmpthese);

my $test = $debug;

my @init = (
  'YField1,Field2,Field3,Field4,Field5',
  'YField1,Field2,Field3,Field4,Field5',
  'YField1,Field2,Field3,Field4,Field5',
  'YField1,Field2,Field3,Field4,Field5',
  'NField1,Field2,Field3,Field4,Field5',
  'YField1,Field2,Field3,Field4,Field5',
  'NField1,Field2,Field3,Field4,Field5',
  'YField1,Field2,Field3,Field4,Field5',
  'NField1,Field2,Field3,Field4,Field5',
  'YField1,Field2,Field3,Field4,Field5',
);

# benchmark

cmpthese ($test ? 1 : 100, {
do_index = \do_index,
do_regex = \do_regex,
});

exit;

# find records enclosed in quotes (substr/index)

sub do_index {

my @records = @init;
foreach (@records) {

# test for for bracketing s

if (substr ($_, 0, 1) eq '' and substr ($_, -1, 1) eq '') {
$_ = substr $_, 1, -1;
my $i1 = index $_, '';
my $i2 = index $_, ',';
my $r1 = rindex $_, '';
my $r2 = rindex $_, ',';

# test for first and/or last field quoting

if ($i1 != -1 and $i1  $i2 and $r1 != -1 and $r1  $r2) {
printf No - %s\n, substr $_, 1, -1 if $test;
} else {
printf Yes - %s\n, substr $_, 1, -1 if $test;
}
} else {
printf No  - %s\n, $_ if $test;
}
}

}

# find records enclosed in quotes (regex way)

sub do_regex {

my @records = @init;
foreach (@records) {

# test for for bracketing s and first and/or last field quoting

if (/^([^]+,.*,[^]+)$/) {
printf Yes - %s\n, $1 if $test;

} else {
printf No  - %s\n, $_ if $test;
}
}

}

__END__



-- 
  ,-/-  __  _  _ $Bill LuebkertMailto:[EMAIL PROTECTED]
 (_/   /  )// //   DBE CollectiblesMailto:[EMAIL PROTECTED]
  / ) /--  o // //  Castle of Medieval Myth  Magic http://www.todbe.com/
-/-' /___/__/_/_http://dbecoll.tripod.com/ (My Perl/Lakers stuff)
___
Perl-Win32-Users mailing list
Perl-Win32-Users@listserv.ActiveState.com
To unsubscribe: http://listserv.ActiveState.com/mailman/mysubs


Re: Microsoft Word search and replace issue

2005-05-23 Thread Chris Cox
Thanks for your responses Greg and Jan.  I've followed your advice and it's 
working beautifully.

Thanks very much!

Chris

--
Chris Cox
B.IT.(Information Systems) 
Senior Software Engineer

Creatop Interactive Media
Level 1, 240 McCullough Street
Sunnybank. Qld. 4109
Australia
Ph:  1300 85 80 85
Int'l Ph: +61 7 3216 9755
Mobile: +61 412 416600
http://www.creatop.com.au/
[EMAIL PROTECTED]
--

- Original Message - 
From: Greg Chapman [EMAIL PROTECTED]
To: Jan Dubois [EMAIL PROTECTED]
Sent: Friday, May 20, 2005 5:15 PM
Subject: Re: Microsoft Word search and replace issue That is a more efficient 
way to do it; cycle through the collection. 
Good call!

The problem here is that the document contains ActiveX controls and, as 
noted, the only way to access ActiveX controls embedded in a document is 
to cycle through objects in the z-ordered layers of the document, the 
Shapes collection (note that some will have to be searched via the 
InlineShapes collection as well). If the document were to contain 
traditional Word FormFields, the standard Search/Replace tools would 
suffice or, if you prefer to cycle through collections, you would use 
the ActiveDocument.FormFields collection.

While ActiveX controls do look better in an online form than do 
FormFields, the headaches of printing, anchoring the controls within the 
document object, the performance overhead costs, etc., cause most 
template designers to stick to traditional form fields within a document 
template and to use ActiveX controls only on UserForms (custom dialogs) 
where they are much easier to address and have no performance or print 
issues. If there's a chance that you are controlling the document's 
appearance and the way it works, you'll probably greatly benefit by 
going back to FormFields in the doc. Otherwise, I sympathize with you 
all!

Greg Chapman
http://www.mousetrax.com

Jan Dubois wrote:

On Thu, 19 May 2005, Chris Cox wrote:
  

Further on this, I found I had to loop over all the Shapes in the Shapes 
collection. eg:

 use strict;
use Win32::OLE;



You could try:

  use Win32::OLE qw(in);

  

use Win32::OLE::Const 'Microsoft Word';

my $word = Win32::OLE-new('Word.Application');
$word-{visible} = 1;

my $doc = $word-{Documents}-Open(C:\Word\Certificate.doc);



and then

  foreach my $shape (in $doc-Shapes) {
  $shape-{TextFrame}-{TextRange}-{Text} =~ s/#tPreferredName#/Chris/g;
  }

  



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


Re: CSV: help optimize ???

2005-05-23 Thread Chris Wagner
I would focus on finding out why some CSV files are being made wrong.  An
entire line shouldn't be enclosed in its own quotes.  Fixing the problem at
that end would eliminate the need to do clean up after the fact.

At 03:42 PM 5/23/05 -0500, Michael D Schleif wrote:
How can I optimize this sub-routine for minimal processing overhead in
those cases where it does not apply?


A way to optimize this is to realize that a valid line contains a ,
sequence whereas a bad line doesn't.  You only need to test one line of each
file since it should be consistent within a file.  So..

if ( substr($firstline, 0, 1) eq '' ) {## Quoteful file
if ( index($firstline, ',') = 1 ) {
# it's ok
}
else {
# fix bad file
}
}
#else {}## Non quoteful file, it's fine


If there are single column CSV's then u would have to add something to find
out how many columns there are.







--
REMEMBER THE WORLD TRADE CENTER ---= WTC 911 =--
...ne cede males

0100

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


RE: Win32::OLE Can you call ShowOpen Method

2005-05-23 Thread Jack D.
 -Original Message-
 From: [EMAIL PROTECTED] 
 [mailto:[EMAIL PROTECTED] On 
 Behalf Of [EMAIL PROTECTED]
 Sent: May 23, 2005 7:01 PM
 To: perl-win32-users@listserv.ActiveState.com
 Subject: Win32::OLE Can you call ShowOpen Method 
 
 Hello All,
 
 I would like to use OLE to access the common dialog control.  
 I can get access to a number of methods however the ShowOpen 
 does not work.  Is it possible to use show open to get a File 
 Open Dialog.  I can do this using Win32::GUI and TK, however 
 it would be neat to do it here. 
 
 Any help would be great.
 
 Mark
 
 Olegui.pl
 
  -w;
 
 use strict;
 
 use Win32::OLE;
 
 my $CommDlg = Win32::OLE-new(MSComDlg.CommonDialog)|| die 
 Could not start Common Dialog\n;
 
 $CommDlg-ShowPrinter;
 
 $CommDlg-AboutBox;

It looks like OLE wants a few properties to be defined first. Defining only
MaxFileSize did it for me - but I would also add the filters you want too.

  $CommDlg-{MaxFileSize} = 400;
  $CommDlg-{Filter} = All(*.*)|\*.\*;
  $CommDlg-ShowOpen;

Another option is Win32::FileOp::OpenDialog 

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