Re: Win32::SerialPort problem

2006-05-31 Thread Foo Ji-Haw
I've used Win32::SerialPort as well. Are you using the ActivePerl 
distribution? If so, try installing the PPD from 
http://theoryx5.uwinnipeg.ca/ppms/


David Ressler wrote:

I'm trying to use Win32:SerialPort on an XP system. Apparently the standard
Windows Perl installation doesn't contain it, so I downloaded and installed it.
THAT seems to require Win32:API which I didn't find either. I tried to download
it from CPAN but I got an error trying to unpack it, so I copied what appeared
to be the correct files from another computer. However, when I try to execute a
script that contains "use  Win32::SerialPort;" at line 12 I get the error:

Can't locate loadable object for module Win32::API in @INC (@INC contains:
C:/Perl/lib C:/Perl/site/lib .) at C:/Perl/lib/Win32API/CommPort.pm line 5
Compilation failed in require at C:/Perl/lib/Win32API/CommPort.pm line 5.
BEGIN failed--compilation aborted at C:/Perl/lib/Win32API/CommPort.pm line 5.
Compilation failed in require at C:/Perl/lib/Win32/SerialPort.pm line 4.
BEGIN failed--compilation aborted at C:/Perl/lib/Win32/SerialPort.pm line 4.
Compilation failed in require at C:\Inetpub\wwwroot\pos\cgi-bin\ComPortSetup.pl
line 12.
BEGIN failed--compilation aborted at C:\Inetpub\wwwroot\pos\cgi-bin\ComPortSetup

Line 5 of CommPort.pm is "use Win32::API", and the line in Win32\API.pm that
seems to be failing is "bootstrap Win32::API;"

The script works fine on the other computer mentioned above.

I suspect there may be some error in the sloppy way I tried to install this. Can
anyone shed some light or suggest what to do?

Thanks,
Dave


___
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: Problems with slaches

2006-05-24 Thread Foo Ji-Haw



I wouldn't go so far as to saay always - usually would be a better choice.
You have to be careful in situations like shelling out to a command
interpreter for example.
  

Ok. 'Most of the time' then.

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


Re: Problems with slaches

2006-05-22 Thread Foo Ji-Haw
You can always use '/' as the directory delimiter, even in Windows. Perl 
on Win32 translates / properly.


Gerardo Carvallo Velasco wrote:


Hello to everyone;
I am a beginner in Perl and I have the next problem:
I should copy a file from winXP (local) to a Linux server.
When I select the file to be copied from a form it appear with the 
this format: c:\path\file
in my script I try to change the "\" for "/" using the following 
instruction:

sub uploadFile{
  $file = $data{'our_file'};
  $file =s/\\/\//g;
  $target = "C:/myfiles/documents/drcarvallo/TargetFile.txt";
  unlink $target if(-e $target);
  open(FILE,"<$file");
  open(FILE1, ">>$TargetFile") || &show_error("$filepath:  Can't open 
because ($!).");

  while (){
$line = $_;
chomp($line);
flock(FILE1,2) if $UseFlock;
print FILE1 "$line\n";
flock(FILE1,8) if $UseFlock;   
  }

  close(FILE1);
  close(FILE);
  return 1;
}

When conclude the script, copy to selected path a file without data.  
However, if I change the slashes ("\" to "/") the file is made correc.


Could somebody indicate me how make it correctly?

Thank an regards.



Gerardo Carvallo


Nuevo MSN Messenger Una forma rápida y divertida de enviar mensajes 




___
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: breaking out of a for/foreach loop...

2006-04-17 Thread Foo Ji-Haw

last?

bruce wrote:

ok..

i'm embarassed.. how does one break out of a for/foreach loop??

i thought it was exit/break... 


pointers?

thanks

-bruce

___
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: Perl book sale at Suntec City (Singapore)

2006-03-26 Thread Foo Ji-Haw
Carrefour. On the second floor beside the DVD shelves. The books are new 
but a bit dusty. There's also a chunk of Java and .Net books as well, 
but the good ones are probably gone by now.


Warning: books are not sold cheap for nothing. These are usually a bit 
out-versioned. But for Perl stuff it's still ok. I didn't get the Perl 
books on Bioinformatics and Beginning Perl. But they should still be around.



John Serink wrote:

Where at Suntec?

  

-Original Message-
From: [EMAIL PROTECTED] 
[mailto:[EMAIL PROTECTED] On 
Behalf Of Foo Ji-Haw

Sent: Monday, March 27, 2006 10:01 AM
To: perl-win32-users@listserv.ActiveState.com
Subject: Perl book sale at Suntec City (Singapore)


Ok, I know this is relevant to a specific few, but it's too 
good a deal...


I've just gotten my hands on 5 Perl books, for a total of only SGD 40 
(about USD 25). Includes: mod_perl (O Reilly), Perls of Wisdom, 
Template::Toolkit, Perl Algorithms, and Mason.


For those who are travelling enroute to Singapore, let me 
know and I'll 
give you directions. ___
Perl-Win32-Users mailing list 
Perl-Win32-Users@listserv.ActiveState.com

To unsubscribe: http://listserv.ActiveState.com/mailman/mysubs




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


Perl book sale at Suntec City (Singapore)

2006-03-26 Thread Foo Ji-Haw

Ok, I know this is relevant to a specific few, but it's too good a deal...

I've just gotten my hands on 5 Perl books, for a total of only SGD 40 
(about USD 25). Includes: mod_perl (O Reilly), Perls of Wisdom, 
Template::Toolkit, Perl Algorithms, and Mason.


For those who are travelling enroute to Singapore, let me know and I'll 
give you directions.

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


How to best count the number of words in a sentence?

2006-03-23 Thread Foo Ji-Haw

Hi all,

This is probably a fun trivial question: I'd like to count the number of 
words in a string. My command:

my $count = split(/\s+/,$line);

works. But Perl complains about:
Use of implicit split to @_ is deprecated

It works, but it's deprecated. I can assign split to an array, then do a 
scalar() on it. But this cannot be the best method (too much work!).


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


Re: lwp, javascript - forget it.... right?

2006-03-20 Thread Foo Ji-Haw
It's not a Perl Thing. All languages (including Java, .Net) cannot 
'eval' javascript. Since you can access the javascript file, why not 
mimick their encryption?

Hon Shi wrote:

Been all over news, just want to verify with the pros here.
lwp and javascript don't play.  I have a login page uses a javascript
function to encrypt the login.  There's nothing I can do.
I'm dead .. right?

__
Do You Yahoo!?
Tired of spam?  Yahoo! Mail has the best spam protection around 
http://mail.yahoo.com 
___

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: Running a script in the system account

2006-03-19 Thread Foo Ji-Haw



You can use the WinXP schtasks utility to run a script
in the SYSTEM account.



I can't, I'm afraid. I'm running win2k with no plans to change.
  
There is a Perl library that can automate the Windows scheduler, for 
both 2000 and 2003.


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


Re: Implementing or Emulating TSRs in Win32 Console Apps

2006-03-16 Thread Foo Ji-Haw



I would think you  could do a lot of this using PerlTray (part of Activestate 
PDK).
You can bind a hotkey to a callback and handle the sort of thing you want to do.
I interpret Veli's requirement as some kind of a keyboard logger. 
PerlTray can probably register 1 or two (can it be more than 1?) 
hotkeys, but I don't think it can capture all keystrokes and throw it 
back into the keyboard buffer. That's extra API work...IMHO.

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


Re: Driving a POS printer from Perl

2006-03-13 Thread Foo Ji-Haw
Printing gibberish may be a sign that one or more settings may be 
incorrect, potentially the databit, parity, or stopbits. Have you tried 
doing a similar setup in HyperTerminal?


David Ressler wrote:

Here's what prints gibberish:

use Win32::SerialPort;
$port=new Win32::SerialPort('COM2') || &syserr($^E);
$port->databits(8);
$port->baudrate(9600);
$port->parity("none");
$port->stopbits(1);
$port->write("Hello, world!\n");



- Original Message - 
From: "Foo Ji-Haw" <[EMAIL PROTECTED]>

To: "David Ressler" <[EMAIL PROTECTED]>
Cc: 
Sent: Sunday, March 12, 2006 11:32 PM
Subject: Re: Driving a POS printer from Perl


David Ressler wrote:
  

Thanks for the start.

I managed to get Win32::SerialPort to wake up the printer but it's printing
gibberish. I'm setting it to the same baud rate, etc., as the (functioning)
"Generic / Text" printer that I set up using the Windows "Add Printer".

Do you have any code snippits that would suggest things to try? The
documentation has way too much information for me to comprehend. I'm using the
module in another application to drive a modem and it works fine with only two
lines of code. Is this more complicated?



Check your parity and bit length. There is a DIP switch that determines
whether it's 8-bit or 7, even parity or odd. Maybe you can post your
working code for the community to inspect.


___
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: Driving a POS printer from Perl

2006-03-13 Thread Foo Ji-Haw

David Ressler wrote:

Thanks for the start.

I managed to get Win32::SerialPort to wake up the printer but it's printing
gibberish. I'm setting it to the same baud rate, etc., as the (functioning)
"Generic / Text" printer that I set up using the Windows "Add Printer".

Do you have any code snippits that would suggest things to try? The
documentation has way too much information for me to comprehend. I'm using the
module in another application to drive a modem and it works fine with only two
lines of code. Is this more complicated?
  
Check your parity and bit length. There is a DIP switch that determines 
whether it's 8-bit or 7, even parity or odd. Maybe you can post your 
working code for the community to inspect.

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


Re: list dead?

2006-03-12 Thread Foo Ji-Haw
Are you referring to the mailing list archive, or the mailing engine? I 
think the engine is still running fine. I also noticed that the 
archiving stopped at 8/3.



Chris Wagner wrote:

I haven't gotten any list traffic for several days and I don't see the
recent messages that I do have on the website.  Something wrong with the
list?  The website only goes to Mar. 8th even though I got and sent several
messages after that.  Just wondering.






--
REMEMBER THE WORLD TRADE CENTER ---=< WTC 911 >=--
"...ne cede malis"

0100

___
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: Driving a POS printer from Perl

2006-03-12 Thread Foo Ji-Haw

David Ressler wrote:

I have a printer for a POS application (an Epson TM-T88II for the record) that I
need to drive from a Perl script running under CGI. The printer runs OK as a
Generic/Text printer on Serial Port 1 under Windows 2000 (and I assume Windows
XP). Do I need to work through a driver? Can I drive it directly through the
serial port? Where do I look for information that I can use? Any particular
modules I should start with? Do I need detailed info about this particular
printer, or is there "generic" info about driving text-only printers?
  
The last time I handled POS printers on Perl, it's just treating it as a 
simple text-based printer. The same should apply to your instance. But 
if it does auto-cutting as well, you have to feed those commands into 
the serial port.

The Win32::SerialPort module should help you.



Thanks.



___
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: Getting .net based web servives using SOAP method

2006-03-08 Thread Foo Ji-Haw

Hey Paul

You didn't read the section on the perldoc->SOAP::Lite->Interoperability 
-> Microsoft's .NET


SOAP::Lite is rather malleable: it can be bent to accommodate Java, 
.NET, and potentially any other soap servers. Try the code below (untested):


use strict;
use warnings;
#use SOAP::Lite +trace=>'all';
use SOAP::Lite;

my $SOAPClient = SOAP::Lite
   ->uri('http://my.com')
   ->proxy('http://services.abc.net/wservices/Slib.asmx')
   ->on_action(sub{join '', @_});

print $SOAPClient->MAT_DES(
   SOAP::Data->name('param1')->uri('http://my.com')->value(DEV),
   SOAP::Data->name('param2')->uri('http://my.com')->value(12345))
   ->result;

Turn on the tracing to see the xml envelope sent out. Make the necessary 
adjustments as required by the .NET service. param1 and param2 are the 
placeholders for the variable names expected. And what kind of structure 
is DEV? In the example above, I treat it as a string constant.


Good luck, and have fun.

Paul wrote:

Hi Foo Ji-Haw and others

Here the info I have, basically a sample SOAP request

POST /wservices/Slib.asmx HTTP/1.1
Host: my.com
Content-Type: text/xml; charset=utf-8
Content-Length: length
SOAPAction:
"http://services.abc.net/wservices/MAT_DES";


http://www.w3.org/2001/XMLSchema-instance";
xmlns:xsd="http://www.w3.org/2001/XMLSchema";
xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/";>
  
http://services.abc.net/wservices/";>
  string
  string

  


And I need to use SOAP::Lite to make this request:
This is my code and I really don't know what I am
doing
use SOAP::Lite;

  print SOAP::Lite
-> uri('http://my.com')
->
proxy('http://services.abc.net/wservices/Slib.asmx')
-> MAT_DES(DEV,12345)
-> outputxml()
-> result;



--- Foo Ji-Haw <[EMAIL PROTECTED]> wrote:

  

You don't need to use LWP::UserAgent directly to
access SOAP services. 
SOAP::Lite probably uses it internally, and you only
need to focus on 
the SOAP::Lite methods.


You need to explain your difficulties in using
SOAP::Lite. My 
recommendation is that you turn on debugging, so
that you can see the 
SOAP envelope generated. Be sure you've read the
section on 
Interoperability -> Microsoft's .NET.



Paul wrote:


Below is how I was able to use a .NET web service
using LWP perl module with the GET method. How can
  

I


use the same web service using SOAP?
I think I need to use SOAP::Lite module but I
  

couldn't


make it work. Can anybody help?

# Create a user agent object
  use LWP::UserAgent;
  $ua = LWP::UserAgent->new;
  $ua->agent("MyApp/0.1 ");

  # Create a request
  my $req = HTTP::Request->new(GET =>

  

"http://my.com/wservices/Slib.asmx/MAT_DES?mode=DEV&ID=28912";);
  
 

  

$req->content_type('application/x-www-form-urlencoded');
  

  $req->content('match=www&errors=0');

 # Pass request to the user agent and
  

get


a response back
  my $res = $ua->request($req);

  open (FP, ">C:/temp/mm.xml");
 # Check the outcome of the
  

response

  if ($res->is_success) 
   {

  print FP $res->content;
   }
  else 
   {

  print "Bad luck this time\n";
   }
close(FP);



__
Do You Yahoo!?
Tired of spam?  Yahoo! Mail has the best spam
  
protection around 

http://mail.yahoo.com 
___

Perl-Win32-Users mailing list
Perl-Win32-Users@listserv.ActiveState.com
To unsubscribe:
  

http://listserv.ActiveState.com/mailman/mysubs

  
  




__
Do You Yahoo!?
Tired of spam?  Yahoo! Mail has the best spam protection around 
http://mail.yahoo.com 
  


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


Re: old messages?

2006-03-07 Thread Foo Ji-Haw

Yup. I got a load of 'em too. Guess the mailing list server screwed up.
___
Perl-Win32-Users mailing list
Perl-Win32-Users@listserv.ActiveState.com
To unsubscribe: http://listserv.ActiveState.com/mailman/mysubs


Re: Bitmap Display

2006-03-07 Thread Foo Ji-Haw

henry wrote:
OK folks, here's my dilemma. I'm not a TK or Win32:GUI user and am not 
sure if they are the right tools for this. I'm trying to display a 
bitmap with a JPG/BMP/GIF file to tell people to wait while the script 
runs. I'd also like to include a little caption below the pic. I guess 
I'm looking to make it look like some of those application startup 
splash screens. If anyone knows what's a nice quick way to do this 
(one that doesn't include becoming a TK guru) I'd appreciate any help 
or pointer. Thanks in advance.
I'd rather you use Win32::GUI or wxPerl to do the splash screen. They 
have native interfaces for that. Using IE to splash sounds heavy.


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


Re: Processing only certain sections of a file

2006-03-07 Thread Foo Ji-Haw

You mean:
while ($wholefile =~ /(.*?)<\/TEXT>/sig)
{
   # do your stuff
}

Craig Cardimon wrote:

I have this logic to follow:

while()
{
 if(/START/ .. /END/)
{
# process line
}
}

I found this logic in an article 
(http://www.perl.com/pub/a/2004/06/18/variables.html) on Perl's 
Special Variables at Perl.com.


I want to try modifying the logic to process a file that has been 
slurped into a string variable, like so:


while($wholefile)
{
 if(/ .. /<\/TEXT>/)
{
# process line
}
}

I think I'm being stupid here (it's close to the end of the business 
day), because the Perl Command Line Interpreter has scolded my various 
attempts. Any suggestions?



-- Craig
___
Perl-Win32-Users mailing list
Perl-Win32-Users@listserv.ActiveState.com
To unsubscribe: http://listserv.ActiveState.com/mailman/mysubs
___
ActivePerl mailing list
ActivePerl@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: PPM experience

2006-03-07 Thread Foo Ji-Haw

I understand your confusion. If I were to
ppm install Underworld-Revolution

I will expect to:
use Underworld::Revolution;
and not
use Revolution;


Gary D Trosper wrote:


A confusing PPM experience


I'm running PPM v3.1 and ActiveState-Perl v5.8.0 
MSwin32-x86-multi-thread on a WindowsXP system


I recently needed to do some PDF work so I located PDF::Xtract on CPAN.

I decided to try ppm (first timer)

ppm> install PDF::Xtract-> Installation successful

perl -e "use PDF::Xtract;"-> Can't locate PDF/Xtract.pm in 
@INC  (Note my clue was the PDF**Xtract)


I decided to remove and start over

ppm> remove PDF::Xtract-> PDF::Xtract is not installed   
Here's where my confusion started
ppm> install PDF::Xtract-> PDF-Xtract is already 
installed (2nd clue PDF **Xtract)

ppm> query PDF::Xtract-> no matches see help query

Suddenly the light dawns  ppm is expecting the name to be 
PDF**Xtract

ppm> query PDF-Xtract -> listing for PDF-Xtract
ppm> remove PDF-Xtract-> remove successful
ppm> install PDF-Xtract-> installation successful

perl -e "use PDF::Xtract;"-> Can't locate PDF/Xtract.pm in @INC  

I'm stumped so I look in the directories list in @INC and sure enough 
Xtract.pm is located in \perl\site\lib instead of \perl\site\lib\PDF


to test

perl -e "use Xtract;"-> no problema

Case solved and closed.

For those of you who are guru level and are wondering why this person 
is wasting my time with this post...
I can only apologize; but, if your reading this and haven't used ppm 
very much perhaps this experience will save you some
time.  


The errors were all my own and mostly syntactical in nature.

Gary Trosper
RTSC


___
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: Perl Command Line Interpreter problem

2006-03-07 Thread Foo Ji-Haw


I'm using Perl 5.8.3.809 on a machine running Windows XP Professional. 
I'm processing text files of various sizes. The one that is giving me 
problems is 22.5 MB.


One of my co-workers suggested a memory leak. I think I've plugged all 
the possible memory holes, but this file still sinks the script. I am 
using a few arrays, but I re-initialize and undef them after I'm 
finished with them. 

It's hard to say without any real script to analyse.
___
Perl-Win32-Users mailing list
Perl-Win32-Users@listserv.ActiveState.com
To unsubscribe: http://listserv.ActiveState.com/mailman/mysubs


Re: outlook address book

2006-03-07 Thread Foo Ji-Haw

Chris Wagner wrote:

Greets, does anyone know of a module or WMI/OLE method that will let u
interact with the Outlook global address list?  Or an offline copy thereof?
I want to be able to search fields for usernames and bring back all the info.
  

Try the MAPI interface. To get you started:
my $outlook = Win32::OLE->new('Outlook.Application');
return undef if (!$outlook);
my $MAPI = $outlook->GetNamespace("MAPI");
...







--
REMEMBER THE WORLD TRADE CENTER ---=< WTC 911 >=--
"...ne cede malis"

0100

___
Perl-Win32-Users mailing list
Perl-Win32-Users@listserv.ActiveState.com
To unsubscribe: http://listserv.ActiveState.com/mailman/mysubs
___
Perl-Win32-Admin mailing list
Perl-Win32-Admin@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: Scanning a zip file without expanding it

2006-03-07 Thread Foo Ji-Haw

Craig Cardimon wrote:
Is there a way to see the filenames in a *.zip file, open the files, 
and search their contents without extracting that *.zip file?


I'd appreciate a gentle push in the right direction.


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


Re: Need help with variables

2006-03-05 Thread Foo Ji-Haw
If you've defined your $DBH in common.pm, then to access it you have to 
include the namespace:

my $sth = $common::DBH->prepare("..");

And in your common.pm, use our instead of my to share the variable:
our $DBH = DBI->connect ( "DBI:mysql:database=sample; 
host=127.0.0.1","root", "password");



Jaime Teng wrote:

Hi,

In my current web project, I group common functions and global variables 
into a separate file;


my problem is, I could not seem to be able to access these variables



##
common.pm
use strict;
use DBI;
my $HTTP;
my $DBH = DBI->connect ( "DBI:mysql:database=sample; host=127.0.0.1",
"root", "password");

sub function1 {
}
sub function2 {
}
sub function3 {
}
1

##
main.pl
use common.pm
my $sth = $DBH->prepare("..");

I am getting:
Global symbol "$DBH" requires explicit package name at main.pl line 2.

I dont know how to make it work. I appreciate if you could lend me a hand.

This is a web cgi application to be used with modperl, will there
be any "scope" problem? Last time I did a modperl based project was 
more than 5 years ago and have forgotten all about it.


Thanks.
Jaime

___
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: Getting .net based web servives using SOAP method

2006-03-01 Thread Foo Ji-Haw
You don't need to use LWP::UserAgent directly to access SOAP services. 
SOAP::Lite probably uses it internally, and you only need to focus on 
the SOAP::Lite methods.


You need to explain your difficulties in using SOAP::Lite. My 
recommendation is that you turn on debugging, so that you can see the 
SOAP envelope generated. Be sure you've read the section on 
Interoperability -> Microsoft's .NET.



Paul wrote:

Below is how I was able to use a .NET web service
using LWP perl module with the GET method. How can I
use the same web service using SOAP?
I think I need to use SOAP::Lite module but I couldn't
make it work. Can anybody help?

# Create a user agent object
  use LWP::UserAgent;
  $ua = LWP::UserAgent->new;
  $ua->agent("MyApp/0.1 ");

  # Create a request
  my $req = HTTP::Request->new(GET =>
"http://my.com/wservices/Slib.asmx/MAT_DES?mode=DEV&ID=28912";);
 
$req->content_type('application/x-www-form-urlencoded');

  $req->content('match=www&errors=0');

 # Pass request to the user agent and get
a response back
  my $res = $ua->request($req);

  open (FP, ">C:/temp/mm.xml");
 # Check the outcome of the response
  if ($res->is_success) 
   {

  print FP $res->content;
   }
  else 
   {

  print "Bad luck this time\n";
   }
close(FP);



__
Do You Yahoo!?
Tired of spam?  Yahoo! Mail has the best spam protection around 
http://mail.yahoo.com 
___

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


Distributing compiled C library generated by inline

2006-02-27 Thread Foo Ji-Haw

Hi all,

Here's a sharing session on my successful experience on the a/m, with 
lots of excellent support from Sisyphus (thanks dude!).


Problem statement:
Writing a C/C++ extension can be difficult and laborious. Fortunately 
inline.pm helps to automate much of the work, and keep us developer 
dudes focused on the coding. Developers should read up on the fairly 
extensive inline documentation for the reference and tutorial.


Once the libraries are compiled, the C/C++ codes should not be needed 
during implementation/ distribution. This short article describes the 
Lazy Man's Way of doing just that. Note that the recommended method is 
documented in inline-faq. In the following paragraph there are minor 
references to inline-faq, so be sure to have the documentation ready.


The Solution:
1. Read up on Question 3 on the FAQ. Following steps 1+2+3.
2. Within the 'use Inline' config hash, add the following parameter:
CLEAN_AFTER_BUILD=> 0
This is an important line.
3. Write a simple piece of code that will cause the module to be 
compiled using inline.
4. Expect a subdirectory called _Inline/, with a huge bunch of 
subdirectories under it.
5. Follow _Inline/build/ until you see the auto/ subdirectory. Copy this 
directory and everything under it to your installation of Perl, 
typically at

C:/Perl/Site/Lib/. There should be an existing auto/ already.
6. Now you need to point your original Perl module to the compiled 
library. Take out the 'use Inline' line. Add the following lines instead:

require DynaLoader;
our @ISA = qw (DynaLoader);
bootstrap ;

That's it! Have fun!
___
Perl-Win32-Users mailing list
Perl-Win32-Users@listserv.ActiveState.com
To unsubscribe: http://listserv.ActiveState.com/mailman/mysubs


Re: Resolving 'Can't Locate .\Makefile.PL' via PerlTray

2006-02-27 Thread Foo Ji-Haw



What about using Win32::API to access a separate DLL written in C ?
Or does it have to be all Perl ?
  


Thanks for the suggestion. I am so darn rusty on C that no amount of 
WD-40 will work! So writing a DLL in C from scratch is really asking me 
to learn Thai...it's near impossible.


Anyway, I think I've got a plausible solution with some creative 
follow-ups from inline. Look for the mail titiedl 'Distributing compiled 
C library generated by inline'.



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


Re: Resolving 'Can't Locate .\Makefile.PL' via PerlTray

2006-02-27 Thread Foo Ji-Haw

Thanks for coming to my rescue again!

Quick qn: I must be missing something, 'cause when I do 'perl 
Makefile.PL', I get:

Can't open perl script "Makefile.PL": No such file or directory

I'm using MSVC6. Or do I need another compiler?


Indeed it is. I do it often.

In 'perldoc Inline-FAQ' , see the section 'How do I create a binary
distribution using Inline?'. You need to do as suggested in steps 2) to 5).
Not only must The C code be placed in a subdirectory, but I think the
subdirectory needs to be named 'src', and the C file needs to be named the
same as the '.pm' file - ie if the the '.pm' file is named 'Foo.pm', the C
file has to be called 'Foo.c'.

In the 'pm' file you must also specify the Config option
CLEAN_AFTER_BUILD=>0.

After you've run 'perl makefile.pl' and 'nmake' you can then go into the
'build' directory and retrieve the XS file (along with INLINE.h) that Inline
created.

Bundle those 2 files with an appropriate Makefile.PL, and '.pm' file (along
with the usual Changes file, Readme file, test suite etc) and you have a
normal cpan-type distro which can be built in the usual way - and is in no
way dependent upon the Inline module.

The '.pm' file that is part of the final distro will be a little different
to the '.pm' file that you started with. Unlike the original '.pm' file it
will require DynaLoader (and add DynaLoader to @ISA), it will need to call
bootstrap (it's just one line of code - see any XS module's '.pm' file for
an example of how to do that), and it will contain no reference to 'Inline
C'.

The final Makefile.PL also differs from the initial Makefile.PL that was
used. It will 'use ExtUtils::MakeMaker;' instead of 'use
Inline::MakeMaker;'.

I actually wrote a little module (called C2XS) that takes the '.c' file that
you have created for the Inline module to use, and converts that '.c' file
into an '.xs' file. It also creates INLINE.h, iff needed. I could send it to
you if you like - it just saves the bother of running the initial 'perl
Makefile.PL' and 'nmake', and then having to go into the build directory and
retrieve the XS file.

It also means that you need only one '.pm' file (the one that's going to be
part of the final cpan-type distro) and one Makefile.PL (the one that's
going to be part of the final cpan-type distro).

Cheers,
Rob




  


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


Re: Resolving 'Can't Locate .\Makefile.PL' via PerlTray

2006-02-27 Thread Foo Ji-Haw
Thanks Jan, it's a real bummer that inline is not supported on PerlTray, 
'cause I have just painfully written some C codes to extend Perl use 
beyond its existing domain!


Is there any other way I can use my C codes somehow on the PerlTray 
environment? Some form of XS or something?


Just an idea: is it possible to generate XS code via inline, then simply 
write a separate module that called it do that inline is not used?


Jan Dubois wrote:

On Sun, 26 Feb 2006, Foo Ji-Haw wrote:
  

I'm using some inline codes alongside PerlTray. It seems that compiling
an executable results in the following error:
.\Makefile.PL:
error: Can't locate .\Makefile.PL
refby: C:\Perl\lib\ExtUtils\MakeMaker.pm line 181

I'm using Windows 2000 SP4 + 5.8.7 + PDK 6.0.2



The PDK wrapping tools (PerlApp, PerlCtrl, PerlNET, PerlSvc, PerlTray)
don't support the Inline module.

Cheers,
-Jan

PS: You may want to use the PDK mailing list for problems with PDK
tools. That increases the chance other PDK user will see your
message quite a bit. :)



  


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


Re: I need your opinion: perl vs php

2006-02-27 Thread Foo Ji-Haw



I don't want to get too far OT but I am in a similar situation as Jaime and
was also planning to use MySQL. This is the first time I've seen or heard
any comments like this and wanted to "poll the audience" to see what people
think and if Greg's sentiments are the norm.
For me, MySQL is perhaps the easiest database server to implement and 
maintain. It is dead easy to backup a database in 'clear'. Migrate 
databases, and do most of the daily maintainence tasks. As a developer, 
it is acceptably fast, has all the basic to intermediate functions 
expected of a typically database, including support for UTF-8 (solves my 
international language issues).


There is ONE thing about MySQL that gets my goat: it's connection pool 
is not as reliably available as other servers (even against MS SQL). 
Even in low but constant loads, it does not always serve out a database 
connection in the first request, so you have to code specially for 
failed requests. I've installed multiple permutations of the version 5, 
and it is still like this.


MySQL's licence seems to have increased doubly since the year it charges 
for commercial installations (post-3.22). It is still way cheaper than 
MS SQL, but now Postgre is starting to look real sexy, and IBM's 
DB2-lite has also gone free for commercial use.


Personally I prefer MySQL. But the database landscape is changing, and 
loyalty does not survive a product that does not flow with the changing 
times.


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


Re: Threads

2006-02-27 Thread Foo Ji-Haw

Yup. Basically that's it. :)

But don't get too ambitious on Perl's ithreads. They are fun, but not as 
rich as threads from other languages.


Carter Thompson wrote:


Is this really as easy as it seems or am I over looking something?

I have an array with references to tests.  I want to loop through each
element in the array, call a subroutine passing in the test reference
using a thread.   When all tests (threads) have been started I want to
loop through all threads and join so I can retrieve relevant data.

# Start threads.
my @threads = ();
foreach my $ref (@individual_tests) {
$thr = threads->new(\&run_test, $ref);
push(@threads, $thr);
}

# Retrieve data
foreach my $thr (@threads) {
my $results = $thr->join();
 }

# run_test sub
sub run_test {
my $ref = shift;

# do stuff in here.

}



Thanks for looking this over.

Carter.

___
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: Resolving 'Can't Locate .\Makefile.PL' via PerlTray

2006-02-27 Thread Foo Ji-Haw

Need your help guys...

A bit more information to my problem:
1. I can run the codes fine from the command line. It's compiling from 
PerlTray that's giving the error
2. Attached are two simple files that I use to test. To compile from the 
command-line (not using PerlTray) I omit 'use PerlTray'. SampleInline.pm 
basically does nothing.


Appreciate any help I can get...

Foo Ji-Haw wrote:

Hi all,

I'm using some inline codes alongside PerlTray. It seems that 
compiling an executable results in the following error:

.\Makefile.PL:
   error: Can't locate .\Makefile.PL
   refby: C:\Perl\lib\ExtUtils\MakeMaker.pm line 181

I'm using Windows 2000 SP4 + 5.8.7 + PDK 6.0.2
___
Perl-Win32-Users mailing list
Perl-Win32-Users@listserv.ActiveState.com
To unsubscribe: http://listserv.ActiveState.com/mailman/mysubs


use strict;
use warnings;
use SampleInline;
use PerlTray;

print "Hello world!";package SampleInline;
use strict;
use warnings;
use Inline C => DATA =>
LIBS => '-luser32 -kernel32 -lTapi32 ';



1;

__DATA__
__C__

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


Resolving 'Can't Locate .\Makefile.PL' via PerlTray

2006-02-26 Thread Foo Ji-Haw

Hi all,

I'm using some inline codes alongside PerlTray. It seems that compiling 
an executable results in the following error:

.\Makefile.PL:
   error: Can't locate .\Makefile.PL
   refby: C:\Perl\lib\ExtUtils\MakeMaker.pm line 181

I'm using Windows 2000 SP4 + 5.8.7 + PDK 6.0.2
___
Perl-Win32-Users mailing list
Perl-Win32-Users@listserv.ActiveState.com
To unsubscribe: http://listserv.ActiveState.com/mailman/mysubs


Re: I need your opinion: perl vs php

2006-02-26 Thread Foo Ji-Haw
If it's purely a web-based scenario, chances are both platforms will be 
just as good, and just as scalable. The key issue is whether the 
developer (you) can do a better job with the selected tool. Perl can do 
a wonderful job if you use the right framework, and can be just as lousy 
if the coding methodologies and documentation are lax.


As for maintainability, again it depends on what are the post-delivery 
plans: is it going to be you all the way, or are you forwarding it to a 
maintenance team? In Singapore, it's difficult to find a fair PHP 
developer, and near impossible to get a real Perl dude.


I don't know much about mod_php, other than it accelerates PHP scripts. 
But with mod_perl you get to fiddle with parts of the Apache framework 
itself, including access authentication, uri handling, and more. Do you 
need to do that?


Hope this helps.

Jaime Teng wrote:

Hi,

I am in the process of planning a huge project.
It will be web based with heavy database accesses.

Since I am have more programming experience with Perl, 
I prefer using it. However several people have suggested 
using PHP + MySQL + Apache combo.


If you are given the choice, what will you choose?

a) MySQL + Perl + modPerl + Apache + Linux
or
b) MySQL + PHP + Apache + Linux

I hope you could give me some of the insights I dont know
about the two in terms of program efficiency as well as 
"maintainability".


regards,
Jaime

___
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: Tough qn: understanding this (C) error while using inline

2006-02-22 Thread Foo Ji-Haw

Hello Rob,

It's amazing. You are right: if I put ULONG just after the function 
declaration like this:

void StartupTapi (HINSTANCE hInstance) {
   ULONG ret;
   apiVersion = 0x3;
   ...

It's ok. But if I shift the variable only 1 line down:
void StartupTapi (HINSTANCE hInstance) {
   apiVersion = 0x3;
   ULONG ret;
   ...

It complains of 'error C2275: 'ULONG' : illegal use of this type as an 
expression'


Is that a MSVC issue, or more to do with inline.pm?

To be honest, I have no idea what FAR PASCAL means too. I'm trying very 
very hard to port some old sample codes into Perl (the C++ Guy left).


Thanks. Will keep you updated.

Sisyphus wrote:

----- Original Message - 
From: "Foo Ji-Haw" <[EMAIL PROTECTED]>

To: "Sisyphus" <[EMAIL PROTECTED]>
Cc: 
Sent: Tuesday, February 21, 2006 5:42 PM
Subject: Re: Tough qn: understanding this (C) error while using inline


 


Hello guys,

Loading the library helped. I think I've hit the problem you foresaw.
ULONG returns an error during compilation:
error C2275: 'ULONG' : illegal use of this type as an expression

   



That's just because you need to declare *all* variables before any function
calls. The script that you attached should compile ok if you rewrite the
'StartupTapi' function as:

void StartupTapi (HINSTANCE hInstance) {
   //apiVersion = 0x2;
   ULONG ret;
   apiVersion = 0x3;
   ZeroMemory (&lip,sizeof (LINEINITIALIZEEXPARAMS));
   lip.dwTotalSize = sizeof (LINEINITIALIZEEXPARAMS);
   lip.dwOptions = LINEINITIALIZEEXOPTION_USEHIDDENWINDOW;
   // orig line:

   // ULONG ret =
lineInitializeEx(&hla,hInstance,tapilineCallbackFunc,APP_Name,&numDevices,&a
piVersion,&lip);
   //
lineInitializeEx(&hla,hInstance,tapilineCallbackFunc,APP_Name,&numDevices,&a
piVersion,&lip);
} //StartupTapi

(Actually, since the 'ret' variable is not used, there is no need to declare
it at all.)

However, neither StartupTapi() nor tapilineCallbackFunc() will be accessible
to perl because of the HINSTANCE and DWORD arguments they receive. As I
demonstrated earlier, you need to pass those arguments as either SV*'s or
unsigned longs/ints, and then convert them to HINSTANCE/DWORD types from
inside the function. You also need to remove the "FAR PASCAL" from the
script  I don't know what that means, and neither does perl :-)

If you run that script with the '-w' switch on, you'll get a warning about
the absence of functions accessible to perl:

Warning. No Inline C functions bound to Perl
Check your C function definition(s) for Inline compatibility

Cheers,
Rob

 



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


Re: Tough qn: understanding this (C) error while using inline

2006-02-20 Thread Foo Ji-Haw

Hello guys,

Loading the library helped. I think I've hit the problem you foresaw. 
ULONG returns an error during compilation:

error C2275: 'ULONG' : illegal use of this type as an expression

Is it to do with typemaps? I tried to find some good documentation, but 
the only example I got was:

http://apache.osuosl.org/perl/mod_perl-2.0.1/xs/typemap

Which wasn't much help.

Appreciate your advice on this matter. Below is my updated code:

Alternatively, if you know of 'anybody' whom I might be able to engage 
to complete the (probably 'good enough') TAPI port, do let me know. ;)


use Inline C => DATA =>
   LIBS => '-luser32 -kernel32 -lTapi32 ';

__END__
__C__

#include 
#include 
#include 
#include 
#include 

#define _WIN32_WINNT 0x0400
#define MAX_LOADSTRING 100

#define WMUSER_TASKBARNOTIFYWM_USER + 1


#define KEY_ISPRESSED 0x8000
#define KEY_UNPRESSED 0

#define PROFILEAPPNAME "My_TAPI"
#define PROFILEININAME "My_TAPI.ini"

#define APP_Name "My_TAPI"

HLINEAPP hla=0;
DWORD numDevices;
DWORD apiVersion;
DWORD extVersion;
LINEINITIALIZEEXPARAMS lip;
HLINE hline=0;
HCALL hcall=0;
LINEEXTENSIONID leid;  
DWORD lineID=0;

LPLINECALLPARAMS lpCallParams = NULL;
LONG reqid=0;
extern unsigned int LBid;
extern int LB_lineID[255];

typedef struct _LINEDEVCAPSEXTRA {
   LINEDEVCAPS LDC;
   char tempstore[4096];
} LINEDEVCAPSEXTRA;

LINEDEVCAPSEXTRA ldc;

void FAR PASCAL tapilineCallbackFunc( DWORD hDevice, DWORD dwMsg, DWORD 
dwCallbackInstance,
DWORD dwParam1, DWORD dwParam2, DWORD 
dwParam3) {

} //tapilinecallbackFunc

void StartupTapi (HINSTANCE hInstance) {
   //apiVersion = 0x2;

   apiVersion = 0x3;
   ZeroMemory (&lip,sizeof (LINEINITIALIZEEXPARAMS));
   lip.dwTotalSize = sizeof (LINEINITIALIZEEXPARAMS);
   lip.dwOptions = LINEINITIALIZEEXOPTION_USEHIDDENWINDOW;
   // orig line:
   ULONG ret;
   // ULONG ret = lineInitializeEx 
(&hla,hInstance,tapilineCallbackFunc,APP_Name,&numDevices,&apiVersion,&lip);
   // lineInitializeEx 
(&hla,hInstance,tapilineCallbackFunc,APP_Name,&numDevices,&apiVersion,&lip);

} //StartupTapi


use Inline C => DATA =>
LIBS => '-luser32 -kernel32 -lTapi32 ';

__END__
__C__

#include 
#include 
#include 
#include 
#include 

#define _WIN32_WINNT 0x0400
#define MAX_LOADSTRING 100

#define WMUSER_TASKBARNOTIFYWM_USER + 1


#define KEY_ISPRESSED 0x8000
#define KEY_UNPRESSED 0

#define PROFILEAPPNAME "My_TAPI"
#define PROFILEININAME "My_TAPI.ini"

#define APP_Name "My_TAPI"

HLINEAPP hla=0;
DWORD numDevices;
DWORD apiVersion;
DWORD extVersion;
LINEINITIALIZEEXPARAMS lip;
HLINE hline=0;
HCALL hcall=0;
LINEEXTENSIONID leid;   
DWORD lineID=0;
LPLINECALLPARAMS lpCallParams = NULL;
LONG reqid=0;
extern unsigned int LBid;
extern int LB_lineID[255];

typedef struct _LINEDEVCAPSEXTRA {
LINEDEVCAPS LDC;
char tempstore[4096];
} LINEDEVCAPSEXTRA;

LINEDEVCAPSEXTRA ldc;

void FAR PASCAL tapilineCallbackFunc( DWORD hDevice, DWORD dwMsg, DWORD 
dwCallbackInstance, 
 DWORD dwParam1, DWORD dwParam2, DWORD 
dwParam3) {
} //tapilinecallbackFunc

void StartupTapi (HINSTANCE hInstance) {
//apiVersion = 0x2;

apiVersion = 0x3;
ZeroMemory (&lip,sizeof (LINEINITIALIZEEXPARAMS));
lip.dwTotalSize = sizeof (LINEINITIALIZEEXPARAMS);
lip.dwOptions = LINEINITIALIZEEXOPTION_USEHIDDENWINDOW;
// orig line:
ULONG ret;
// ULONG ret = lineInitializeEx 
(&hla,hInstance,tapilineCallbackFunc,APP_Name,&numDevices,&apiVersion,&lip);
// lineInitializeEx 
(&hla,hInstance,tapilineCallbackFunc,APP_Name,&numDevices,&apiVersion,&lip);
} //StartupTapi
___
Perl-Win32-Users mailing list
Perl-Win32-Users@listserv.ActiveState.com
To unsubscribe: http://listserv.ActiveState.com/mailman/mysubs


Re: Tough qn: understanding this (C) error while using inline

2006-02-20 Thread Foo Ji-Haw

Hello Reinhard, Sisyphus, Mark,

Thanks for the helping me past the first roadblock. I am trying to see 
how far I can get with this TAPI implementation (despite my noobness at 
inline coding). I hope I can continue to engage your help through my 
endeavour.


As promised. If I actually got anywhere with this, I will donate my 
codes to the community, if it is worth anything. I think Perl and TAPI 
will be nice. :)



Reinhard Pagitsch wrote:


Sisyphus wrote:

- Original Message - From: "Foo Ji-Haw" 
<[EMAIL PROTECTED]>

To: 
Sent: Friday, February 17, 2006 7:54 PM
Subject: Tough qn: understanding this (C) error while using inline


 


Hi all,

I'm trying my first hand at writing some C code to extend TAPI onto 
Perl

using inline.pm. I didn't get very far though. Appreciate if anyone can
help explain the error (source code is attached).

  



Make sure you have a good look through 'perldoc Inline::C-Cookbook'. 
It has

many helpful examples.

Reinhard's method of linking to the tapi32 library looks a little odd 
to me

... however, I can't say it doesn't work as I haven't tested it.
I usually link to libraries using the construct shown in the demo below.
 


Could it be because I use Perl v5.6.1? It worked the way I replayed.

Reinhard



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


Re: Win32::TieRegistry

2006-02-19 Thread Foo Ji-Haw



use Win32::TieRegistry ( Delimiter=>"/", ArrayValues=>0 );
$key = $Registry->{"LMachine/System/CurrentControlSet/Enum/"} ||
die "$^E\n";


This fails.  Error message is: "The system could not find the
environment option that was entered".  


I used your code and I have the same problems. If I get the registry at

LMachine/System/CurrentControlSet/ and parse through the keys in the hash 
representation, it seems that while the 'Enum' key is there, TieRegistry cannot 
pull out the value for the key.

Can't help you there.


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


Tough qn: understanding this (C) error while using inline

2006-02-17 Thread Foo Ji-Haw

Hi all,

I'm trying my first hand at writing some C code to extend TAPI onto Perl 
using inline.pm. I didn't get very far though. Appreciate if anyone can 
help explain the error (source code is attached).


It seems to complain that _lineInitializeExA (defined in tapi.h I think) 
is not resolved. I just don't know how to continue from here.


If there is any expert on inline C+TAPI, I don't mind sharing the 
success of my coding if you can help me along. Thanks.



error msg:
--

Microsoft (R) Program Maintenance Utility   Version 6.00.8168.0
Copyright (C) Microsoft Corp 1988-1998. All rights reserved.

   C:\Perl\bin\perl.exe C:\Perl\lib\ExtUtils/xsubpp  -typemap 
C:\Perl\lib\E
xtUtils\typemap  inline_pl_d3ab.xs > inline_pl_d3ab.xsc && 
C:\Perl\bin\perl.exe

-MExtUtils::Command -e mv inline_pl_d3ab.xsc inline_pl_d3ab.c
   cl -c  -ID:/  -nologo -Gf -W3 -MD -Zi -DNDEBUG -O1 -DWIN32 
-D_CONSOLE -D
NO_STRICT -DHAVE_DES_FCRYPT -DNO_HASH_SEED -DPERL_IMPLICIT_CONTEXT 
-DPERL_IMPLIC
IT_SYS -DUSE_PERLIO -DPERL_MSVCRT_READFIX -MD -Zi -DNDEBUG -O1
-DVERSION=\"0.

00\"  -DXS_VERSION=\"0.00\"  "-IC:\Perl\lib\CORE"   inline_pl_d3ab.c
inline_pl_d3ab.c
Running Mkbootstrap for inline_pl_d3ab ()
   C:\Perl\bin\perl.exe -MExtUtils::Command -e chmod 644 
inline_pl_d3ab.bs
   C:\Perl\bin\perl.exe -MExtUtils::Mksymlists  -e 
"Mksymlists('NAME'=>\"in
line_pl_d3ab\", 'DLBASE' => 'inline_pl_d3ab', 'DL_FUNCS' => {  }, 
'FUNCLIST' =>

[], 'IMPORTS' => {  }, 'DL_VARS' => []);"
   link -out:blib\arch\auto\inline_pl_d3ab\inline_pl_d3ab.dll -dll 
-nologo
-nodefaultlib -debug -opt:ref,icf  -libpath:"C:\Perl\lib\CORE"  
-machine:x86 inl
ine_pl_d3ab.obj   C:\Perl\lib\CORE\perl58.lib oldnames.lib kernel32.lib 
user32.l
ib gdi32.lib winspool.lib  comdlg32.lib advapi32.lib shell32.lib 
ole32.lib oleau
t32.lib  netapi32.lib uuid.lib ws2_32.lib mpr.lib winmm.lib  version.lib 
odbc32.

lib odbccp32.lib msvcrt.lib -def:inline_pl_d3ab.def
  Creating library blib\arch\auto\inline_pl_d3ab\inline_pl_d3ab.lib and 
object

blib\arch\auto\inline_pl_d3ab\inline_pl_d3ab.exp
inline_pl_d3ab.obj : error LNK2001: unresolved external symbol 
_lineInitializeEx

[EMAIL PROTECTED]
blib\arch\auto\inline_pl_d3ab\inline_pl_d3ab.dll : fatal error LNK1120: 
1 unreso

lved externals
NMAKE : fatal error U1077: 'link' : return code '0x460'
Stop.

A problem was encountered while attempting to compile and install your 
Inline

C code. The command that failed was:
 nmake > out.make 2>&1

The build directory was:
D:\_Inline\build\inline_pl_d3ab

To debug the problem, cd to the build directory, and inspect the output 
files.


at inline.pl line 0
INIT failed--call queue aborted.
use Inline C;

__END__
__C__

#include 
#include 
#include 
#include 
#include 

#define _WIN32_WINNT 0x0400
#define MAX_LOADSTRING 100

#define WMUSER_TASKBARNOTIFYWM_USER + 1


#define KEY_ISPRESSED 0x8000
#define KEY_UNPRESSED 0

#define PROFILEAPPNAME "My_TAPI"
#define PROFILEININAME "My_TAPI.ini"

#define APP_Name "My_TAPI"

HLINEAPP hla=0;
DWORD numDevices;
DWORD apiVersion;
DWORD extVersion;
LINEINITIALIZEEXPARAMS lip;
HLINE hline=0;
HCALL hcall=0;
LINEEXTENSIONID leid;   
DWORD lineID=0;
LPLINECALLPARAMS lpCallParams = NULL;
LONG reqid=0;
extern unsigned int LBid;
extern int LB_lineID[255];

typedef struct _LINEDEVCAPSEXTRA {
LINEDEVCAPS LDC;
char tempstore[4096];
} LINEDEVCAPSEXTRA;

LINEDEVCAPSEXTRA ldc;

void FAR PASCAL tapilineCallbackFunc( DWORD hDevice, DWORD dwMsg, DWORD 
dwCallbackInstance, 
 DWORD dwParam1, DWORD dwParam2, DWORD 
dwParam3) {
} //tapilinecallbackFunc

void StartupTapi (HINSTANCE hInstance) {
//apiVersion = 0x2;
apiVersion = 0x3;
ZeroMemory (&lip,sizeof (LINEINITIALIZEEXPARAMS));
lip.dwTotalSize = sizeof (LINEINITIALIZEEXPARAMS);
lip.dwOptions = LINEINITIALIZEEXOPTION_USEHIDDENWINDOW;
// orig line:
// ULONG ret = lineInitializeEx 
(&hla,hInstance,tapilineCallbackFunc,APP_Name,&numDevices,&apiVersion,&lip);
lineInitializeEx 
(&hla,hInstance,tapilineCallbackFunc,APP_Name,&numDevices,&apiVersion,&lip);
} //StartupTapi
___
Perl-Win32-Users mailing list
Perl-Win32-Users@listserv.ActiveState.com
To unsubscribe: http://listserv.ActiveState.com/mailman/mysubs


Re: SV: Problem loading OLE.dll on Windows 98

2006-02-14 Thread Foo Ji-Haw
You'll have a lot of support if you use ActivePerl for the Win32 
platforn. There are other repositories which allow you to install 
modules without any compilation.


Thomas Mostrup Nymand wrote:


Hi.

Thanks for all the help - I have managed to workaround the problem...

Your hint regarding cygwin made me try ActivePerl instead, and here
Win32::OLE is working fine!

Now I just have to get WinGuiTest working, but thats another story :)



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


Unable to send wide characters via MIME::Lite

2006-02-12 Thread Foo Ji-Haw

Hi all,

I'm trying to send out an email, that occasionally includes wide 
characters (possibly utf-8; the contents are downloaded from the Web). 
It looks like MIME::Lite does not like wide characters by default. Is 
there any way to get around it?


Below is my code snippet:

   my $mail = MIME::Lite->new (
   From=>$config->{SenderEmail},
   To=>$config->{email}->[0],
   Subject=>$config->{MailTitle},
   Type => 'multipart/alternative',
   );
   $mail->attach (
   Type=>'text/plain',
   Data=>'You need to see this in HTML-enabled mode',
   );
   $mail->attach (
   Type=>'text/html',
   Data=>$text,
   );
   $mail->send('smtp','localhost');

$text is the variable that contains the wide character text.

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


Re: Debugging Perl Service?

2006-02-12 Thread Foo Ji-Haw

Paul Sobey wrote:


I have a service written in perl which appears to have a very small
memory leak. Because it runs as a service it's hard to run the debugger.
Is there a way I can print the memory usage of the different variables
in the symbol table from within the script? I'd like to make it write
out some stats once a day so I can get an idea of which
hash/array/whatever is causing the problem.

I don't know if this works, but how about dumping your output into a log 
file or something?

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


Re: SV: Problem loading OLE.dll on Windows 98

2006-02-09 Thread Foo Ji-Haw

Thomas Mostrup Nymand wrote:

Yes, good point, but line 2 is 


use Win32::OLE qw(EVENTS);

so the code below crashes before there is any mention of
"InternetExplorer.Application".


You are right. Can't help you there. Seldom used cygwin.
___
Perl-Win32-Users mailing list
Perl-Win32-Users@listserv.ActiveState.com
To unsubscribe: http://listserv.ActiveState.com/mailman/mysubs


Re: Testing for Directories

2006-02-09 Thread Foo Ji-Haw



-d could fail if a file exists with the same name as a dir you're
expecting to find.  

Hmm, I am under the impression that no file can exist with the same name 
as a subdir in the same path.


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


Re: Testing for Directories

2006-02-08 Thread Foo Ji-Haw

Dirk Bremer wrote:


What is the easiest method to detect whether or not a directory exists?
I will need to create the directory/subdirectory if it is not already
present. The file test -d does not seem to do the trick. 



What's wrong with -d? It' is not a file test. It's a test if the path 
points to a directory.

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


Re: Problem loading OLE.dll on Windows 98

2006-02-08 Thread Foo Ji-Haw



When I try to use Win32::OLE as in the following script:

#!/usr/bin/perl
use Win32::OLE qw(EVENTS);
my $IE  = Win32::OLE->new("InternetExplorer.Application")
   || die "Could not start Internet Explorer.Application\n";

I get the following error:

Can't load
'/usr/lib/perl5/vendor_perl/5.8/cygwin/auto/Win32/OLE/OLE.dll' for
module Win32::OLE: Permission denied at
/usr/lib/perl5/5.8/cygwin/DynaLoader.pm line 230. at r.pl line 2

Permissions seem to be OK on OLE.dll, and Im running the same Cygwin
version on XP without problems.

Any hints would be greatly appreciated!
 

A shot in the dark: different versions of IE may have different object 
names? After all, IE3 on Win98 is pretty far off.


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


Re: XML from DB - well formed

2006-02-08 Thread Foo Ji-Haw

Mario Sanchez wrote:


hello everyone,

can you please point me to a package or script that will first determine
the columns of a database table, then output well formed XML? condition: i
do not know in advance the columns of the table.

example output where "field" = actual field name


  
foo
...
foobar
  
  
poo
...
poobar
  
  


OR something similar.

i know that it can be written rather straightfowardly, but better to see
if the wheel is already invented.
 

May be tricky. Different RDBMS have different ways of extracting table 
information. For MySQL it's 'describe table'. For MSSQL, it's:

|SELECT c.name, c.isnullable, c.length, c.colstat, t.name type
 FROM syscolumns c, systypes t, sysobjects o
 WHERE o.name = '$table' AND o.id = c.id AND c.xtype = t.xtype


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


Re: [Fwd: Re: Where to find the ppd for Win32::Shortcut?]

2006-02-06 Thread Foo Ji-Haw


For the benefit of all, Win32::Shortcut seems to work still, at least 
on W2K. Maybe the work has stopped, cause I'm facing the following 
issues:
1. The required folders are not automatically created when Save() is 
used. This is minor and can be solved by called File::Path::mkpath() 
first.
2. Creating a shortcut to an executable does not seem to work. The 
shortcut is created, but clicking on the link does not call the 
application. I manually set an icon to it, and that seems to help. But 
there should be an easier way to do this. But if the shortcut is to a 
URL. that's ok. 


Correction to my previous post: Creating a shortcut to an application 
works only if you set the ShowCmd parameter, as in the following example:

$link->{ShowCmd} = SW_SHOWNORMAL;



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


[Fwd: Re: Where to find the ppd for Win32::Shortcut?]

2006-02-06 Thread Foo Ji-Haw

>There is documentation for Win32::Shortcut, but it is not distributed in


the standard way, i.e. as POD in the .pm file or as a separate file, so
you have to look a bit harder.

When you search for Win32::Shortcut on search.cpan.org you would have
seen that it is part of the libwin32 package. If you follow that link
(http://search.cpan.org/~jdb/libwin32-0.26/) and scroll down you will
see the some html documentation under "Other Files". Note that the
documentation seems quite old, circa 1997, which may be part of the
reason for it being "non-standard".
 


Thanks Brian for the response.

For the benefit of all, Win32::Shortcut seems to work still, at least on 
W2K. Maybe the work has stopped, cause I'm facing the following issues:
1. The required folders are not automatically created when Save() is 
used. This is minor and can be solved by called File::Path::mkpath() first.
2. Creating a shortcut to an executable does not seem to work. The 
shortcut is created, but clicking on the link does not call the 
application. I manually set an icon to it, and that seems to help. But 
there should be an easier way to do this. But if the shortcut is to a 
URL. that's ok.


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


Re: PPM error

2006-01-31 Thread Foo Ji-Haw

Paul wrote:


Hi
I was trying to load the DBI module by using PPM and I
am getting an error
C:\>ppm install DBI
Installing package 'DBI'...
Error installing package 'DBI': Could not locate a PPD
file for package DBI

I am behind a firewall. So is there is way to get
around that


Have you tried:
http://www.xav.com/perl/Components/ppmproxy.htm
___
Perl-Win32-Users mailing list
Perl-Win32-Users@listserv.ActiveState.com
To unsubscribe: http://listserv.ActiveState.com/mailman/mysubs


Re: Need some help w/ comparing dates ...

2006-01-31 Thread Foo Ji-Haw



Can anyone get me started on how to check the date/time stamp of a file
and compare it to the current day? I imagine this type of simple task is
a no-brainer for almost everyone on this list. Poking back through my
book a bit now. All pointers to more info much appreciated. 


stats() will give you the last modified date (among other things). I think:
time - (stats($filename))[9] > 0
should do the trick

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


Changing the substitution charactor in Encoding::encode

2006-01-23 Thread Foo Ji-Haw

Hi all,

I'm trying to 'water down' a utf8-encoded to latin-1. Using 
Encode::encode does the trick, and it replaces character that do not fit 
into latin-1 with a subtitution character (as per the documentation)


Can anyone tell me how I can change this character to something else, 
like a ' '?


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


creating sub-threads

2006-01-12 Thread Foo Ji-Haw

Hi all,

Does anyone know if it is possible for a thread to create its own child 
threads? All the threads that are created seem to be tied to the main 
thread, regardless of the thread they were created from.


I've tried:
threads->self->create

But it's no go either. Complete test code is attached.

Any confirmation on this is appreciated. Thanks.
use strict;
use warnings;
use threads;
use threads::shared;

$|=1;

my %command : shared = (1=>'',2=>'');

my $thread = threads->create(\&startThread,1);
my $thread2 = threads->create(\&startThread,2);
sleep(5);

while (1)
{
print "pinging threads\n";
{
lock %command;
$command{1} = 'PING';
$command{2} = 'PING';
}
sleep 5;
lock %command;
foreach my $id (1..2)
{
if ($command{$id} eq 'PING')
{
print "thread $id looks dead\n";
}
else
{
print "thread $id looks alive\n";
}
}
sleep 5;
}


$thread->join;

sub startThread
{
my $id = shift;

threads->self->create(\&pingThread,$id);
print "Thread $id: started\n";
while (1) 
{ 
die "$id is dead\n" if (int(rand(20)) == 1);
print "$id do stuff\n";
sleep(1);
}
}

sub pingThread
{
my $id = shift;

while (1)
{
{
lock %command;
if ($command{$id} eq 'PING')
{
$command{$id} = 'PONG';
print "$id: I've been pinged!\n";
}
}
sleep (1);
}
}___
Perl-Win32-Users mailing list
Perl-Win32-Users@listserv.ActiveState.com
To unsubscribe: http://listserv.ActiveState.com/mailman/mysubs


Re: Classes as modules?

2006-01-11 Thread Foo Ji-Haw




Well, the two files in question are not huge.  They each have one 
class.  What's the difference between require-ing them later, and 
use-ing them later?  Why is it more difficult to require them?


I don't think it's more difficult to call a require(), use() helps in 
the bigger scheme of things, like determining the scope of your 
variables and methods, and making sure you package similar functions 
together. use() also makes sure at compile time that the libraries are 
available, whereas require() only checks at runtime.


There's more to the difference between the two, and you may want to read 
up the documentation for the details. It seems that best practices go 
strongly with use(), and a lot of add-on support are based on that style 
of development.





I will say that this is not a Perl-thing, but rather a good general 
software development mindset.



Thanks, but this does seem like a Perl-thing.  No other language 
distinguishes between 'package-in-a-file' and 'module'.


I would say ASP, but ASP does not have a concept of a module...

In my previous email, I was assuming that you simply split all the 
functions in into 2 files without using packages, and merging them with 
a require(). If you are already using packages, then go for use().

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


Re: Classes as modules?

2006-01-10 Thread Foo Ji-Haw


OK, looking at 'perlnewmod', it has a section called 'What should I 
make into a module?', which states:


"You should make a module out of any code that you think is going to 
be useful to others."


That settles my question.  The classes I have written for this project 
are specific to this project, thus not useful to others.  Thus, I will 
keep them in .pl files, not try to make modules out of them.


If this is not your first and last time you're using Perl, then it is a 
good practice to create modules to group similar functionalities 
together. Creating a huge .pl file, or lots of .pl files  (and require() 
them later) only makes future debugging and expansion difficult. 
Creating a module is painless, yet it sets you on the right path for any 
complexities that may arise.


I will say that this is not a Perl-thing, but rather a good general 
software development mindset.

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


Re: Classes as modules?

2006-01-08 Thread Foo Ji-Haw


Thanks for your reply.  But supposing I'm going to keep each class in 
it's own file, what is the advantage of making that file a module?  
Doesn't that just let me import the methods of the class into my own 
namespace, from another file?  That would be weird - they're supposed 
to be methods of a class.  They belong in the class' namespace, not mine. 


It may be how Perl searches for the module you created. The module file 
should be named in the same way the module is named. It will be quite 
inefficient to search an entire directory just to find a module.



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


Re: Info on reading COM ports

2006-01-08 Thread Foo Ji-Haw

Rajesh Vattem wrote:


Hi,
I am looking for ways to read a COM port (USB and baud rate > 115200). Can
some one advise me which is the efficient way to do this.


I don't think USB access is available yet.
___
Perl-Win32-Users mailing list
Perl-Win32-Users@listserv.ActiveState.com
To unsubscribe: http://listserv.ActiveState.com/mailman/mysubs


Re: Win32::Ole (MAPI) and Win2K scheduler

2006-01-03 Thread Foo Ji-Haw

LeFevre, Ken wrote:

I created a program using ActiveState's perl 5.8.4, compiled it using 
perlapp 5.3.0 and ran it on Windows 2000 Professional SP4 against 
Outlook 2000 SR-1 (9.0.0.3821).  It runs properly both from a command 
prompt and as a scheduled task.  I released it into production on 
Windows 2000 server SP4 using the identical version of Outlook 2000.  
Again, it runs great from a command prompt.  When I run it as a 
scheduled task, however, it dies because it's not able to get the 
Outlook Application.


Hi there,

I'm afraid I have no solution to your problem, but if you've found help, 
please share with me, as I code to access Outlook as well.


One of the (unrelated) Outlook issues that I deal with, is that with the 
latest Outlook, the user is prompted to grant access to the Perl 
application, when the application starts. Some kind of security measure 
on Microsoft's part, but it does not happen for Outlook 2000.


 
Here's the relevant code:
 
 
Win32::OLE->Initialize(Win32::OLE::COINIT_OLEINITIALIZE); 
die Win32::OLE->LastError(),"\n" if Win32::OLE->LastError(  );
eval { $Outlook = 
Win32::OLE->GetActiveObject('Outlook.Application') };

die "Outlook is not installed" if $@;
unless (defined $Outlook) {
$Outlook = Win32::OLE->new('Outlook.Application', sub 
{$_[0]->Quit;});
or die "Oops, cannot start Outlook";  
<=== dies here under Win2k srvr as a scheduled task
 
As best I can tell, Outlook is registered the same on both machines.  
The same dlls exist on both.  I even set up the scheduled task to run 
under the same userid I used when logging on to the server to run the 
program from the command prompt.  My theory is that there is some sort 
of permissions issue or a difference in the scheduled task environment 
between the two versions of the Win2k OS, but I'm not succeeded at 
finding the problem and how to resolve it.
 
I would greatly appreciate any insight or assistance in getting this 
to run in the new environment.
 
Thanks,
 
Ken




___
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: What's wrong with this code?

2006-01-03 Thread Foo Ji-Haw

Please ignore this thread. I forgot to do this:
use Error qw(:try);

Foo Ji-Haw wrote:


Hello all,

I'm trying to learn exception handling using Error.pm (as recommended 
by perl.com). Trouble is, I can't seem to get it right. Below (and 
attached) is my source code in full:


use strict;
use warnings;
use Error;

$|=1;

try
{
   print "before throw\n";
   if (1)
   {
   print "throw error!";
   callError();
   }
   print "no error\n";
}
catch MyException with
{
   my $exception = shift;
   print "error caught!\n";
   print "caught: $exception\n";
}
finally
{
   print "always executed";
};

sub callError
{
   throw MyException ('Argh!');
}

package MyException;
use Error;
use base qw(Error);
use overload ('""' => 'stringify');

sub new
 {
   my $self = shift;
   my $text = "" . shift;
   my @args = ();

   local $Error::Depth = $Error::Depth + 1;
   local $Error::Debug = 1;  # Enables storing of stacktrace

   $self->SUPER::new(-text => $text, @args);
 }

1;

My issues:
1. finally() is never called
2. catch() block is called even when there is no exception thrown (try 
setting if(0) in the try block)

3. print  "error caught!" is never called even when there is an exception

Any advice is appreciated. Thanks.



use strict;
use warnings;

my $array1 = ['a','b','c'];
my $array2 = ['d','e','f'];

@$array1 = (@$array1,@$array2);
print ''.scalar(@$array1);



___
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


What's wrong with this code?

2006-01-02 Thread Foo Ji-Haw

Hello all,

I'm trying to learn exception handling using Error.pm (as recommended by 
perl.com). Trouble is, I can't seem to get it right. Below (and 
attached) is my source code in full:


use strict;
use warnings;
use Error;

$|=1;

try
{
   print "before throw\n";
   if (1)
   {
   print "throw error!";
   callError();
   }
   print "no error\n";
}
catch MyException with
{
   my $exception = shift;
   print "error caught!\n";
   print "caught: $exception\n";
}
finally
{
   print "always executed";
};

sub callError
{
   throw MyException ('Argh!');
}

package MyException;
use Error;
use base qw(Error);
use overload ('""' => 'stringify');

sub new
 {
   my $self = shift;
   my $text = "" . shift;
   my @args = ();

   local $Error::Depth = $Error::Depth + 1;
   local $Error::Debug = 1;  # Enables storing of stacktrace

   $self->SUPER::new(-text => $text, @args);
 }

1;

My issues:
1. finally() is never called
2. catch() block is called even when there is no exception thrown (try 
setting if(0) in the try block)

3. print  "error caught!" is never called even when there is an exception

Any advice is appreciated. Thanks.
use strict;
use warnings;

my $array1 = ['a','b','c'];
my $array2 = ['d','e','f'];

@$array1 = (@$array1,@$array2);
print ''.scalar(@$array1);___
Perl-Win32-Users mailing list
Perl-Win32-Users@listserv.ActiveState.com
To unsubscribe: http://listserv.ActiveState.com/mailman/mysubs


Re: Why is PerlApp's .exe package smaller than PAR?

2005-12-23 Thread Foo Ji-Haw

If you don't get satisfactory answers here, try the PAR mailing list. (See


http://lists.cpan.org .) I think (not sure) that various aspects of PerlApp
vs PAR have been covered previously on the PAR list - so you might find
something in that list's archive.
 


Thanks Rob.

Thanks for spotting the 'bug'. I realised that while I subscribe to both 
mailing lists, but I also post to perl-win32-users. Thanks.


Merry Christmas, and have a Great New Year!
___
Perl-Win32-Users mailing list
Perl-Win32-Users@listserv.ActiveState.com
To unsubscribe: http://listserv.ActiveState.com/mailman/mysubs


Why is PerlApp's .exe package smaller than PAR?

2005-12-22 Thread Foo Ji-Haw

Hi all,

I'm considering using PerlApp to package my application into an easily 
distributable executable. Comparing PerlApp with PAR, I find that:


1. PerlApp's .exe file is usually smaller than PAR. It can even be less 
than 1MB, which is almost impossible for PAR.
2. PerlApp packages executables with less errors than PAR. PAR sometimes 
report runtime errors with missing modules.


Can someone please tell me why this is so (ok, I know PerlApp is a 
professional packager. I just want to know what is going on)?


Also, I may end up distributing more than 1 Perl application to the same 
host. Is there a way for multiple distributions to share common 
libraries (maybe core dlls) so that the file can be even smaller? I 
don't mind if the libraries are thrown into windows/system32/. That's fine.


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


Re: http mods, working with outlook web interface

2005-12-20 Thread Foo Ji-Haw

Hon Shi wrote:


Has anyone used the http mods to interact with the
outlook web interface?  Just a link to a few examples would
be nice.  Was it stright forward?

(have to read mail with given subject lines and detach files)

Thanks

__
Do You Yahoo!?
Tired of spam?  Yahoo! Mail has the best spam protection around 
http://mail.yahoo.com 
___

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

The Outlook web interface is rather complex. Web scraping it will be 
quite tedious. You're better off talking directly to Exchange for the 
mails instead.

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


Re: Packaging using PAR creates error

2005-12-20 Thread Foo Ji-Haw



In general, they *are* pretty much the same. However, PAR ppm's have been a
little fussy of late. I haven't seen that exact error that you reported, but
I've seen a similar error when a PAR built using perl 5.8.6 was used on perl
5.8.7 (and/or vice versa). That's why I specified Randy's PAR-587 ppm 
because I know it was built using perl 5.8.7, and should therefore work fine
on perl 5.8.7. (And I also know that it's the latest version 0.90.) Of
course, there's no guarantee that it *will* work fine for you - but if it
doesn't work for you, then at least we've eliminated one possible source of
the problem and can concentrate on looking elsewhere.

I presume you're using ActiveState perl. Which build ?

I use 5.8.6 (build 811). This version seems to work great with the 
'bribes' PAR ppm. I have not test on 5.8.7 yet, but I suspect it should 
be ok as well.


For me the problem is solved. I do hope though that installing from 
ActiveState repository can be as trusty as it was.

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


ActiveState PAR not quite the same from other repositories

2005-12-20 Thread Foo Ji-Haw

Hi all,

Just want to share my findings on using 0.90 of the PAR module.

I've had some problems packaging the following code:

use strict;
use warnings;
use threads;

print "Hello world!";

The problem seems to come from the threads module. But Rob (Sisyphus) 
confirmed that the same code works on his copy of ActivePerl 5.8.6 and 
5.8.7.


What I found is that if you installed PAR from the ActivePerl repository:
ppm install PAR

You will get a 'Perl_save_bool' error upon executing. But if you use the 
one from the following:

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

All is well.

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


Detecting 'dead' threads in Perl

2005-12-20 Thread Foo Ji-Haw

Hi all,

Just wondering if anyone is working with ithreads (not the old threading 
model). If so, how do you discover dead threads? Hope you can share your 
experiences. Thanks.

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


Re: Packaging using PAR creates error

2005-12-20 Thread Foo Ji-Haw

Hello Rob,

I am following up on your success and suggestions. On my side, I used 
the ppm to install PAR:


ppm install par

And that gave me my problems. I used the one from 
http://www.bribes.org/perl/ppm/ and it seems to work. So I uninstalled 
'bribes' PAR and reinstall the one from ActiveState (same version 
number, btw). The package failed again.


Odd though. Aren't all repositories the same? Maybe Jan can shed some 
light on this.



Sisyphus wrote:

- Original Message ----- 
From: "Foo Ji-Haw" <[EMAIL PROTECTED]>

To: 
Sent: Tuesday, December 20, 2005 8:09 PM
Subject: Packaging using PAR creates error


 


Hi all,

I use PAR to create the executable Perl files. Most of the time it
works. But when using the threads library, it seems to fail.

I tried to compile the simplest code that replicates this error:
use strict;
use warnings;
use threads;

print "Hello world!";

The error is:
'The procedure entry point Perl_save_bool could not be located in the
dynamic link library perl58.dll'

Have tried both 5.8.6 and 5.8.7 without success.

Appreciate any help in this matter. Thanks.
   



I can't reproduce that error. Your script works fine for me, both as a perl
script and a PAR-built executable, on perl 5.8.7 and PAR-0.90 (also
PAR-0.89). I have a number of 5.8.* builds of perl, and in all of them,
'Perl_save_bool' is exported by the perl58.dll. I can only assume that
there's some problem with your PAR installation ... unless there's some
problem with the way you built the executable - which is unlikely. (Just
build with 'pp -o hello.exe hello.pl'.)

If you're using perl 5.8.7 and don't have the facility to build PAR
yourself, try installing the PAR-587 (version 0.90) ppm from
http://theoryx5.uwinnipeg.ca/ppms/ . Then rebuild the executable and see if
the problem has gone away.

Cheers,
Rob

 



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


Re: Packaging using PAR creates error

2005-12-20 Thread Foo Ji-Haw

Hello Rob,

Thanks for the verification. I will redo the tests and see if the 
problem persists. Damn.


Sisyphus wrote:

- Original Message - 
From: "Foo Ji-Haw" <[EMAIL PROTECTED]>

To: 
Sent: Tuesday, December 20, 2005 8:09 PM
Subject: Packaging using PAR creates error


 


Hi all,

I use PAR to create the executable Perl files. Most of the time it
works. But when using the threads library, it seems to fail.

I tried to compile the simplest code that replicates this error:
use strict;
use warnings;
use threads;

print "Hello world!";

The error is:
'The procedure entry point Perl_save_bool could not be located in the
dynamic link library perl58.dll'

Have tried both 5.8.6 and 5.8.7 without success.

Appreciate any help in this matter. Thanks.
   



I can't reproduce that error. Your script works fine for me, both as a perl
script and a PAR-built executable, on perl 5.8.7 and PAR-0.90 (also
PAR-0.89). I have a number of 5.8.* builds of perl, and in all of them,
'Perl_save_bool' is exported by the perl58.dll. I can only assume that
there's some problem with your PAR installation ... unless there's some
problem with the way you built the executable - which is unlikely. (Just
build with 'pp -o hello.exe hello.pl'.)

If you're using perl 5.8.7 and don't have the facility to build PAR
yourself, try installing the PAR-587 (version 0.90) ppm from
http://theoryx5.uwinnipeg.ca/ppms/ . Then rebuild the executable and see if
the problem has gone away.

Cheers,
Rob

 



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


Packaging using PAR creates error

2005-12-20 Thread Foo Ji-Haw

Hi all,

I use PAR to create the executable Perl files. Most of the time it 
works. But when using the threads library, it seems to fail.


I tried to compile the simplest code that replicates this error:
use strict;
use warnings;
use threads;

print "Hello world!";

The error is:
'The procedure entry point Perl_save_bool could not be located in the 
dynamic link library perl58.dll'


Have tried both 5.8.6 and 5.8.7 without success.

Appreciate any help in this matter. Thanks.
___
Perl-Win32-Users mailing list
Perl-Win32-Users@listserv.ActiveState.com
To unsubscribe: http://listserv.ActiveState.com/mailman/mysubs


socket sysread() timeout

2005-12-19 Thread Foo Ji-Haw

Hi all,

Thanks to John and Bill, I've managed to get my socket disconnect 
detection working.

I'd like to share my check code with all:
   my $BytesRead = $sock->sysread($buffer,1024);
   if (!defined($BytesRead))
   {
   print "WARNING: Connection lost!\n";
   exit;
   }

My next obstacle is with sysread blocking. I tried to do the following:
   my $sock = new IO::Socket::INET (
   PeerAddr => $ARGV[0],
   PeerPort => '8000',
   Proto => 'tcp',
   Reuse=>1,
   );
   $sock->blocking(0);

But it still blocks. Browsing the web, David Smith posted the following 
code:


my $select = = IO::Select->new();
$select->add( $socket );
if( $select->can_read( 0.5 ) )
{
$response = <$socket>;
print $response . "\n";
} else
{
print "No data on socket.\n";
}

I'd like to ask if using IO::Select is the best/ only way to do a 
non-blocking sysread(), or am I missing something?


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


Re: how to detect a disconnected socket?

2005-12-19 Thread Foo Ji-Haw

John Serink wrote:


Ok, if you're using sockets I strongly recommend you ALWAYS using
sysread and syswrite as they baypass standard IO buffereing.

Be careful with sysread, it cand and will return partial reads, you MUST
be prepared for that.

Unless you want your program to block on sysread, you should use
IO::Select. Now, from Stein's nEtwork Programming with Perl, as File
handle is ready for reading when:
1. There is at least 1 byte of data in the file handle's input buffer,
2. There is an EOF on the file handle, the next call to sysread will
return 0 in this case. With normal files this occurs at EOF, with
sockets this occurs when the remote peer closes the connection,
3. There is a pending error on the socket. The next sysread call will
return undef and the error will be in $!.



So, what you are interested in is 2 or 3 or both.
 

Cool. Thanks for the tip John. When you mean partial reads, you don't 
mean to say that any form of data corruption is taking place right? It's 
just that I will have to be responsible for putting Humpty Dumpty (aka 
the fragmented data) back together again?


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


how to detect a disconnected socket?

2005-12-18 Thread Foo Ji-Haw
Hi all, I have the same issue (see subject title) as Trever in the 
mailing list. Unfortunately reading through the mailing list archive it 
seems that his problem was not resolved. I'm hoping to have better luck 
with you guys. :)


Basically, I need to know if my IO::Socket::INET socket connection is 
disconnected by the remote peer, in which case I will have to close the 
socket, reuse the thread for the next connection.


There were some mentions on using IO::Select:
my $select = IO::Select->new($sock);
while ($select->can_read)
{
...
}

But it seems that it does not help in detecting the connection state 
(it keeps returning 1).


Any ideas/ hints will be appreciated. Thanks.
___
Perl-Win32-Users mailing list
Perl-Win32-Users@listserv.ActiveState.com
To unsubscribe: http://listserv.ActiveState.com/mailman/mysubs


Recommendation: Perl Best Practices from O'Reilly

2005-12-11 Thread Foo Ji-Haw

Hi all,

I just purchased this book last week, and I will like to recommend this 
book to all Perl developers striving for Guru-ship. And no, I don't get 
commision for this (so I won't divulge much either).


It's an excellent book that does NOT talk about Perl the language, but 
rather how to do things better; mainly coding styles and techniques. To 
quote:


/Perl Best Practices/ offers a collection of 256 guidelines on the art 
of coding to help you write better Perl code--in fact, the best Perl 
code you possibly can. The guidelines cover code layout, naming 
conventions, choice of data and control structures, program 
decomposition, interface design and implementation, modularity, object 
orientation, error handling, testing, and debugging.


You can get more infomation at:
http://www.oreilly.com/catalog/perlbp/


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


Re: Inet::Socket::INET's line read fails

2005-12-05 Thread Foo Ji-Haw

Thanks for the good tip John and Bill,

Will give sysread a go.

$Bill Luebkert wrote:


Foo Ji-Haw wrote:

 


Hi all,

Just want to share and ask something about reading from the sockets.
Normally my connection to the Other Side receives line inputs. But not 
all the time the eol character is standard across the various remote 
connections; sometimes it's just a 0x0D.


I realise that <$socket> does not always work, even with $/=char(13). 
The safest way so far seems to be 'doing it yourself' with a loop 
repeating getchar() calls until you hit the expected EOL character. It 
works, but I suspect the high hit rate on the function call is not optimal.


If anyone has a better idea (or my $/=char(13) is just plain wrong), 
please reply. Thanks.
   



I prefer to do all my socket stuff like this:

1) Do a can-read or can_write after an IO::Select has set up your
  sockets to decide if it makes sense to read/write.

2) If you get the go ahead from that, do a sysread for x bytes and
  return the number of bytes to the caller (or EOF/ERR condition
  if present) along with the data actually returned.
  For the write, it would be a syswrite for the size requested and
  return the number actually sent (or EOF/ERR condition) - the caller
  will have to keep track whether it all got sent or not and try
  the rest later after another can_write says to.

All your calls should use the same read and write routines as described
above.  You could also check for exceptions when you check the can_xxx
conditions.  If you're asymchronously reading and writing, you probably
want to check for pending writes to do before trying to read more data
to process.  It helps to create an output Q for each socket and not
read on that socket until all the output is out or you'll end up with
a lot of pending output data.

Here are sample routines that I've used :

#- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -

sub read_sock { # my $bytes = read_sock ($S, \$buffer, [$bufoff, [$buflen]])
my $S = shift;
my $bufref = shift;
my $off = shift || 0;
my $len = shift || $::MAX_READ;
my $buffer = $bufref;
if (not ref $bufref) {
DLOG "Usage: read_sock (socket, bufref[, len])\n";
$buffer = \$bufref;
}
if (not defined $$buffer) {
$$buffer = '';  # create a bufref if none exists yet
DLOG "Had to define \$\$bufref\n";
}

DLOG "enter read_sock $S, $buffer, $len\n";

my $bytes = sysread $S, $$buffer, $len, $off;
if (not defined $bytes or $bytes < 0) {  # read error
DLOG "read_sock return ERR: $!\n";
return -1;
} elsif ($bytes == 0) { # eof
DLOG "read_sock return EOF: $!\n";
return 0;
}
DLOG "read_sock return $bytes\n";
return $bytes;

}

#- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -

sub write_sock { # my $bytes = write_sock ($S, \$buffer, [$bufoff, [$buflen]])
my $S = shift;
my $bufref = shift;
my $off = shift || 0;
my $buffer = $bufref;
if (not ref $bufref) {
DLOG "Usage: write_sock (socket, bufref[, off[, len]])\n";
$buffer = \$bufref;
}
my $len = shift || length $$buffer;

DLOG "enter write_sock $S, $buffer, $off, $len\n";

my $bytes = syswrite $S, $$buffer, $len, $off;
if (not defined $bytes or $bytes < 0) {  # write error
DLOG "write_sock return ERR: $!\n";
return -1;
} elsif ($bytes == 0) { # eof
DLOG "write_sock return EOF: $!\n";
return 0;
}
DLOG "write_sock return $bytes\n";
return $bytes;

}

#- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -

sub DLOG (@) {  # this is my debug logging routine $db is open to log 
file

return if not $debug;

foreach (@_) { print $db $_; }

}

#- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -



 



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


Inet::Socket::INET's line read fails

2005-12-05 Thread Foo Ji-Haw

Hi all,

Just want to share and ask something about reading from the sockets.
Normally my connection to the Other Side receives line inputs. But not 
all the time the eol character is standard across the various remote 
connections; sometimes it's just a 0x0D.


I realise that <$socket> does not always work, even with $/=char(13). 
The safest way so far seems to be 'doing it yourself' with a loop 
repeating getchar() calls until you hit the expected EOL character. It 
works, but I suspect the high hit rate on the function call is not optimal.


If anyone has a better idea (or my $/=char(13) is just plain wrong), 
please reply. Thanks.

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


Re: Device-SerialPort.ppd could not be found

2005-12-05 Thread Foo Ji-Haw

Hello Reinhard,

With your link I was able to download the module. Thanks!

There is a small problem that is stopping me from having fun with the 
module. In trying to install the module, I get this error:

D:\>ppm install Device-SerialPort.ppd

Install 'Device-SerialPort' version 0.22 in ActivePerl 5.8.7.813.

Error: Can't call method "list_files" on an undefined value at 
C:/Alcatel/ThirdParty/Perl/site/lib/PPM/Archive/Tar.pm line 31.


I tried 5.8.6 as well, but both return the same error message. Please 
advise.


Reinhard Pagitsch wrote:


Foo Ji-Haw wrote:


Hi all,

It seems that either the site hosting the a/m ppd is down or the file 
is missing. Anyone has any ideas what's going on? Whom can I alert?




Try : 
http://ppm.activestate.com/PPMPackages/zips/8xx-builds-only/Windows/Device-SerialPort-0.22.zip 




regards,
Reinhard



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


Device-SerialPort.ppd could not be found

2005-12-02 Thread Foo Ji-Haw

Hi all,

It seems that either the site hosting the a/m ppd is down or the file is 
missing. Anyone has any ideas what's going on? Whom can I alert?


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


Re: audiere on ActivePerl

2005-11-29 Thread Foo Ji-Haw



Install the binary, add the audiere-1.9.3\bin folder to your path, and use
ppm to install Audio::Audiere from:
http://crazyinsomniac.perlmonk.org/perl/ppm/5.8/

Then use Audio::Audiere to access the audiere-1.9.3 library.

Any problems, yell out and we'll see what we can do about it.


Hello Rob,

Ok, everything works as you described. Thanks! I've got mp3 playing both 
as a stream and as a memory buffer. Cool...


Just to share with you, I don't think getPosition() works. It seems to 
restart the play. Also getFormat() is reported as not available.


But generally if it starts and stop mp3s, it's good enough for me. Thanks!
___
Perl-Win32-Users mailing list
Perl-Win32-Users@listserv.ActiveState.com
To unsubscribe: http://listserv.ActiveState.com/mailman/mysubs


Re: audiere on ActivePerl

2005-11-29 Thread Foo Ji-Haw



My impression is that you could also download the Win32 binary:
http://prdownloads.sourceforge.net/audiere/audiere-1.9.3-win32.zip?download
 


The binary comes only with python and java samples, but no perlalas!
___
Perl-Win32-Users mailing list
Perl-Win32-Users@listserv.ActiveState.com
To unsubscribe: http://listserv.ActiveState.com/mailman/mysubs


Re: Regular Expression

2005-11-29 Thread Foo Ji-Haw



$String = 'Integration Test Lead: \ul\b0  \tab\tab\tab Kimberly
Kim\tab\tab\tab\tab\tab\tab  \par';

How would I extract "Kimberly Kim" from the string using regular
expression. Is there a way using expression to skip "\[characters]" (
like \tab ) and search for only real words, maybe between spaces.

Have you thought of using the \t\t\t as a marker for the start of the 
string you want to capture, like:

$string =~ /\t\t\t([^\t]+)/


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


Re: XP shutting down perl

2005-11-29 Thread Foo Ji-Haw
When I use mysql+perl, the only time I get a similar error, is when I 
have threads that connect to the server. If I am not mistaken, the mysql 
dbd driver is not thread-safe.


Hope this helps.

Ed Bachmann wrote:


Windows XP is intermittantly shutting down perl with this message,
in a big, gray, official-looking Windows message box.:

"Perl Command Line Interpreter has encountered a problem and needs to 
close,"


It reports that the problem is with 'mysql.dll'.
The script is clean, I think.  I'm running with 'use strict' and 'use 
warnings'.

I'm closing all connections and destroying all objects so far as I know.
What is odd is that the script sometimes runs fine.
When it fails, the cause appears to be an SQL call, usually, but not 
always on a

'DROP TABLE IF EXISTS table', but I don't get any diagnostics
because Windows takes over.

Does anyone know how to troubleshoot this kind of problem?
I've replaced perl, MySQL, DBI, and DBD-mysql, with no effect.
Other perl apps are running fine.

My configuration looks like this:
Windows XP SP 2
ActiveState perl, v5.8.7.815 built for MSWin32-x86-multi-thread
DBD-mysql[3.0002]
DBI [1.48]
MySQL: Ver 14.12 Distrib 5.0.15, for Win32 (ia32)

(I  posted this to perl-win32-database a while back with no luck)

___
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


audiere on ActivePerl

2005-11-29 Thread Foo Ji-Haw

Hi all,

I just found out about Audiere, and from the specs it looks really cool. 
Unfortunately, the documentation suggests that one compiles the source 
code to get it working on Windows.


Has anyone any success on this matter (ie getting Audiere to work on 
Windows/ ActivePerl)? If so, please share your experiences/ workarounds. 
Thanks.

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


Re: Can't start ppm command

2005-11-18 Thread Foo Ji-Haw
If you didn't install ActivePerl, chances are you will have problems
running ppm, although running perl will be fine. I don't know what is
the cause, but I think it is either:
1. missing registry settings
2. different directory location

[EMAIL PROTECTED] wrote:

>Hello,
>
>I hear some people around me says they cann't start ppm.
>
>Below is output of one of my PC, WindowsXP SP1.
>I can do it with "ppm3", but someone near me says,
>he cann't start even ppm3.
>
>Is this from the version-up of AP without uninstall?
>Anyone know the work-around?
>
>C:\>ppm
>No Perl script found in input
>
>C:\>ppm3
>PPM - Programmer's Package Manager version 3.2.
>Copyright (c) 2001 ActiveState Corp. All Rights Reserved.
>ActiveState is a division of Sophos.
>
>Entering interactive shell. Using Term::ReadLine::Perl as readline library.
>
>Type 'help' to get started.
>
>ppm> quit
>
>C:\>
>
>Regards,
>Hirosi Taguti
>[EMAIL PROTECTED]
>
>___
>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: Play MP3 from Perl

2005-11-17 Thread Foo Ji-Haw

Hello Glenn,

Maybe the better approach is to create the Windows Media Player ActiveX 
object, and play MP3s from it, since you're staying exclusively on the 
Windows platform. If it can be done on VB, I am sure it is possible on 
ActivePerl as well.


Glenn Linderman wrote:


Hi,

I'm looking for an easy way to play a single MP3 file, on a specified 
audio device.  Seems like most of the players (1) want to use 
playlists (2) don't take command line arguments (3) only play on the 
default device.


I'm looking for something that I can put in the Windows "open with" 
list, with appropriate parameters, so that I can choose to play a file 
on one of three audio devices, selectable by which command I open it 
with (batch files with parameters?).


I guess it wouldn't have to be a Perl solution, even, but if I have to 
write one, that's what I'd want to write it in... and so any hints of 
how to do such a thing in Perl would be welcome too.


CPAN has lots of audio and MP3 stuff, but most of it seems to be for 
Unix.  I found BrailleAmp, which is command line, but is playlist 
oriented also, and maybe it could be modified to do what I want, but I 
don't grok C#, nor do I have a compiler for it.


So the goal is to have a program that takes 2 or more command line 
parameters, among them an audio file, and an audio device to play it 
on, that runs under Windows.


Thanks for any info you can provide toward such a goal.



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


Re: Digest::SHA1 weirdness

2005-11-16 Thread Foo Ji-Haw
I've not had much problems with the digest, even on mp2. This is a wild 
shot, but have you tried the OO version of the digest:


$sha1 = Digest::SHA1->new;
$sha1->add($data);
$digest = $sha1->hexdigest;

Wiswell, Virginia wrote:


Has anyone else ever experienced inconsistencies in digest creation
using the same plaintext? I am encrypting passwords with Digest::SHA1's
sha1_hex function and storing them in a db. When someone logs in, I take
the password, encrypt it the same way and then compare it with the
stored digest. After a few days, Digest::SHA1 starts creating a
different digest for the identical password. Needless to say, this makes
my login process unusable.

I am using this in a web app, but I don't see this as a web problem:
Win2k, IIS 5, ASP using perlscript. The code below is in a module I
created. It used to work fine a year or two ago. Windows was recently
patched, but I don't see how that could affect this.

My code:

sub compareDigest
{
($vi_acct,$vi_data)= @_;

use Digest::SHA1('sha1_hex');
$vi_digest = sha1_hex($vi_data);

	$sth = $dbh->prepare( qq{ SELECT id, digest FROM mytable 
		WHERE id = '$vi_acct' AND digest = '$vi_digest' } );


$sth->execute();
...
--- this is how I initially create the digest to save in the
db
sub createDigest
{
($dp_acct,$dp_data)= @_;

	use Digest::SHA1('sha1_hex'); 


$dp_digest = sha1_hex($dp_data);

$sth = $dbh->prepare(qq{ INSERT INTO mytable (id, digest) VALUES
('$dp_acct', '$dp_digest')} );
$sth->execute();
...

Truly baffled,

virginia

___
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


Reading from a buffer in a IO::Socket::INET

2005-10-31 Thread Foo Ji-Haw

Hello all,

I am trying to read from a socket connection, a text string if any. 
Problem is, the text string does not end with a CR. Socket connection is 
ok. Below is my code snippet:

...
my $buffer;
$sock->blocking(0);
while (my $count = $sock->read($buffer,512))
{
   print "$buffer";
}

The result is that the code hangs forever. Nothing is printed. Is there 
any way for me to read the socket buffer without blocking, or is my code 
missing something?


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


Re: Regular expression

2005-09-15 Thread Foo Ji-Haw
Don't know if this works, but have you tried:

$string = "1\\.2\\.3";

- Original Message - 
From: "Wong, Danny H." <[EMAIL PROTECTED]>
To: "Sisyphus" <[EMAIL PROTECTED]>; "Jan Dubois"
<[EMAIL PROTECTED]>; "perl-win32-users"

Sent: Thursday, September 15, 2005 2:28 PM
Subject: Regular expression


> Hi Perl Gurus,
> I have a regular expression question.
> I have a variable
> $Number = "1.2.3.4"
>
> When I use the variable $Number as part of my regular expression, the
> "." character gets interpret as any character. How do I make it a
> literal "." that I'm searching for?
> Example:
> $String = "This is a numeric string 1.2.3.411 embedded within another
> string 3.4.5.6"
> $String =~ m/$Number/I; This returns "1.2.3.411" true, when it
> shouldn't.
>
> Thanks for your help!
>
> Thanks
> Danny Wong
> SCM Engineer
> PowerTV Inc.,
>
>
> - - - - - - - Appended by PowerTV, A division of Scientific
Atlanta. - - - - - - -
> This e-mail and any attachments may contain information that is
confidential, proprietary, privileged or otherwise protected by law. The
information is solely intended for the named addressee (or a person
responsible for delivering it to the addressee). If you are not the intended
recipient of this message, you are not authorized to read, print, retain,
copy or disseminate this message or any part of it. If you have received
this e-mail in error, please notify the sender immediately by return e-mail
and delete it from your computer.
>
> ___
> 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


Anyone has Perl codes to access Outlook Express Address Book?

2005-09-12 Thread Foo Ji-Haw




Hi all, 
 
I need to access the Address Book in Outlook 
Express (and Outlook too, if possible), possibly via MAPI. Is there any kind 
soul who can share his/ her success with me? Code snippets should be good 
enough!
 
Thanks.
___
Perl-Win32-Users mailing list
Perl-Win32-Users@listserv.ActiveState.com
To unsubscribe: http://listserv.ActiveState.com/mailman/mysubs


Re: [threads] Forced termination

2005-08-25 Thread Foo Ji-Haw
I guess Perl's threading is not quite complete as of 5.8.x. But with forking 
it is possible to kill a child process?


- Original Message - 
From: "$Bill Luebkert" <[EMAIL PROTECTED]>

To: "ajpeck" <[EMAIL PROTECTED]>
Cc: "Perl Win32 mail list" 
Sent: Thursday, August 25, 2005 6:23 PM
Subject: Re: [threads] Forced termination



ajpeck wrote:


Is there a way to forcibly terminate a thread after a specified time
regardless if the thread is finished executing. I have threads which
call certain network functions that have very long hard coded timeouts,
such as 5 mins. A no response of 5 secs is sufficient for me to know
that there is a problem and the nature of it is not needed (device
switched off, network break, etc). These threads only write out a status
result (threads::shared variable) at the very end of the thread
execution, thus terminating the thread early from within the parent
thread and with no result written is good enough for me to know that
there is a problem.

Is there a way to impliment timed thread termination, if so I would
appreciate it very much for a very simple example.


I tried (using Win32::API) to get the current thread ID and store
in a shared vrbl by the sub thread and terminate the sub thread
from the root thread, but I get an error on the TerminateThread :

Bad file descriptor (The handle is invalid)

even though the thread ID looks fine.

So unless that can be resolved, that won't work.

--
 ,-/-  __  _  _ $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 


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


perl ithreads limit?

2005-08-12 Thread Foo Ji-Haw



Hi all, I was testing the stability of modperl 
under high loads (Apache sometimes crashes with an error message on my Windows 
2000, but once I close the message, it's ok again), and I wrote this very simple 
client code:
 
use strict;use warnings;#use SOAP::Lite 
+trace=>'all';use SOAP::Lite;use threads;
 
$|=1;foreach my $index 
(1..80){ threads->new(\&loadTest,$index);}while (1) 
{ sleep (100); }
 
sub loadTest{ my ($index) = 
@_;  print "Starting thread #".$index."\n"; my 
$client = 
SOAP::Lite  ->uri('SimpleApache/SOAP')  ->proxy('http://localhost:7080/soap/')  ->on_fault(sub{print 
STDERR "Cannot connect to SOAP server\n";return 
undef;});  while (1) {  my $result = 
$client->ping;  next if (!$result);  print 
"$index-".$result->result.' '; }}
Notice that I created 80 threads. Seems that after 
running for a short a while I get the attached error message. I also noticed 
that my memory dropped like crazy during runtime. The perl client died, but 
Apache survived (hence my attempt to crash Apache myself failed).
 
Does anyone know what causes the attached message 
to appear? Short of memory (for my system it wasn't at 0 yet; about 17MB of 
physical memory left)?


error.gif
Description: GIF image
___
Perl-Win32-Users mailing list
Perl-Win32-Users@listserv.ActiveState.com
To unsubscribe: http://listserv.ActiveState.com/mailman/mysubs


Re: DBD-mysql module

2005-07-27 Thread Foo Ji-Haw

Hello Scott,

Is 3.0002 the thread-safe version of the dbd?

Scott Campbell wrote:

ActiveState, is it possible for you to update your DBD-mysql module to 
the latest (available via PPM)?

Currently you have 2.9008, while 3.0002 is the latest.
 
If anyone desires the latest, Randy Kobes has it at 
http://theoryx5.uwinnipeg.ca/ppms.
 
Thanks Randy!
 
 
Scott Campbell

Senior Software Developer
Somix Technologies
http://www.somix.com
 




___
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: activeperl + mysql + threads = crash

2005-07-25 Thread Foo Ji-Haw

Hello Reinhard,

Thanks for confirming my concerns. So you say that on 5.6.x it is ok, 
but not on 5.8.x. But threading + mysql is quite a powerful combination 
to give up!


I wonder if anybody in this mailing list has a workaround/ solution.

Reinhard Pagitsch wrote:


Hello,

I tryed it also with Perl v5.8.7 and had the same prroblem as you, on 
the 2nd doIt Perl crashes.

I also found out that Perl crashes in the DBI.pm sub "disconnect_all".
Removing "use threads;"  it works.

regards,
Reinhard

Foo Ji-Haw wrote:


Hello Reinhard,

I am using 5.8.6 of ActivePerl. Thanks for checking out the codes.

Reinhard Pagitsch wrote:


Hello,


Foo Ji-Haw wrote:


Hi all,

I thought I can hit a nice milestone today, but it seems that I 
have hit a strange obstacle instead.
In my tests, the following code will run, but when it terminates an 
error message will be shown.

use strict;
use warnings;
use DBI;
use threads;

doIt();
doIt();

sub doIt
{
  my $dbh = DBI->connect('dbi:mysql:database','username','password');
  my $stmt = $dbh->prepare ('select id from tablename');
  $stmt->execute();
  while (my $record=$stmt->fetchrow_hashref('NAME_lc')) {}
}

Change the database connection parameters (eg. username, password, 
table name) to your database.


My analysis of the problem is as follows:
1. Using the ODBC driver is ok. I've tested with MSSQL connection 
and it's fine.
2. The problem lies with using threads alongside DBI. If I take out 
'use threads' all is well.
3. There are 2x doIt() calls because it only fails on the second 
database connection.
4. It seems to be related to fetchrow_hashref(), because if I take 
that out, all is fine.


Can someone confirm this? Is there anybody who can suggest a 
workaround? Thanks.



There is no problem here, Perl v5.6.1. Which Perl version do you use?

regards,
Reinhard







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


activeperl + mysql + threads = crash

2005-07-25 Thread Foo Ji-Haw

Hi all,

I thought I can hit a nice milestone today, but it seems that I have hit 
a strange obstacle instead.
In my tests, the following code will run, but when it terminates an 
error message will be shown.

use strict;
use warnings;
use DBI;
use threads;

doIt();
doIt();

sub doIt
{
  my $dbh = DBI->connect('dbi:mysql:database','username','password');
  my $stmt = $dbh->prepare ('select id from tablename');
  $stmt->execute();
  while (my $record=$stmt->fetchrow_hashref('NAME_lc')) {}
}

Change the database connection parameters (eg. username, password, table 
name) to your database.


My analysis of the problem is as follows:
1. Using the ODBC driver is ok. I've tested with MSSQL connection and 
it's fine.
2. The problem lies with using threads alongside DBI. If I take out 'use 
threads' all is well.
3. There are 2x doIt() calls because it only fails on the second 
database connection.
4. It seems to be related to fetchrow_hashref(), because if I take that 
out, all is fine.


Can someone confirm this? Is there anybody who can suggest a workaround? 
Thanks.


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