Re: Help with subroutine

2011-03-15 Thread Chris Wagner
I think ur notation is what's confusing u.  I don't think it's making a copy
but it would be better to write the $num construct as:

$nums->{$i} = $numbernames[$i];


HTH.



At 09:51 AM 3/2/2011 -0800, Barry Brevik wrote:
>I have a subroutine to which I want to pass a hash by reference. In the
>real program, the hash in the caller starts out empty, and the
>subroutine adds values to it.
> 
>The hash eventually becomes quite large, so I want the subroutine to add
>values to the caller's hash. The following sample code does this, BUT I
>have a concern that the subroutine might be making a local copy of the
>caller's hash.
>
>The code below shows how I am doing it now. It appears to work as
>intended, but how can I ensure that the sub is not making a local copy
>of the hash??
>
>Thanks in advance:
>
>use strict;
>use warnings;
>
>my %numbers = ();
>
>makeNumbers(\%numbers);
>
>foreach my $key (keys(%numbers))
>{
>  print "$key  $numbers{$key}\n";
>}
>
>#---
>sub makeNumbers
>{
>  my @numbernames = qw(zero one two three four five);
>
>  if (my $nums = shift)
>  {
>for (my $i = 0; $i < 6; $i++)
>{
>  ${%{$nums}}{$i} = $numbernames[$i];
>}
>  }
>}
>


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


RE: spurious deaths in script execution due to read-only Config?

2011-02-24 Thread Chris Wagner
I see what ur saying but I guess I see nothing wrong with %Config being read
only and croaking if touched.



At 05:18 PM 2/23/2011 -, Brian Raven wrote:
>I do recall 'perldoc perlsub' warning about localising tied hashes &
>arrays being broken, and %Config::Config is a tied hash, I believe.
>
>Regarding your work around. Map in a void context is usually frowned
>upon. Perhaps grep or possibly ...
>
>for ('now') { require ActiveState::Path }
>
>... should have the same effect, i.e. aliasing $_ to something
>(hopefully) innocuous.




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


Re: spurious deaths in script execution due to read-only Config?

2011-02-23 Thread Chris Wagner
It's the standard behavior of Perl.

use Data::Dump "pp"; 
%a = qw/x 1 y 1 z 1/;
grep { $_ } $a{bob};
pp %a;
^D
("y", 1, "bob", undef, "x", 1, "z", 1)


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


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


Re: spurious deaths in script execution due to read-only Config?

2011-02-22 Thread Chris Wagner
Hi.  U can't do that because Perl must autovivify $Config{bar} in order to
have a value to put into $_.  HTH.



At 08:54 PM 2/21/2011 +0100, Christian Walde wrote:
>  use Config;
>  # print 1 if $Config{foo}; # enabling this removes the crash
>  grep { $_ } $Config{bar}; # this crashes
>
>These two lines on their own will cause ActivePerl of any version to exit
with the error message above. I'm not sure what exactly causes this or
whether i should send this to the p5p mailing list, but i figured here is
better for a start.


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


Re: help intercepting STDIO

2010-10-21 Thread Chris Wagner
So what u want to do is read the output from ffmpeg and write it
asynchronously to the Tk window?  So that u can monitor the process without
having to wait for the process to finish.  First is there any way to make a
Tk window take its input from a file handle?  That would be the easy way to go.

The "real" way to do it is to open the file handle in non blocking mode and
set up a loop to read from it.  If there's no buffer data it sleeps a moment
and tries again.  If there is something to read it writes it to wherever.
Look into Term::ReadKey which should do the job.  If u need more than that
u'll have to go into Fcntl and sysread.  It doesn't work in ActivePerl so u
would have to use Cygwin Perl.

HTH.


At 10:43 AM 10/19/2010 +0800, Daniel Burgaud wrote:
>Hi
>
>I am trying to write a GUI application that will convert videos to another
>format using
>a program called FFMPEG.
>
>FFMPEG is basically text based apps which displays text "status" to standard
>output.
>
>I would like my application to intercept these strings in real-time and
>displays it on my very
>own Tk Window
>
>Questions:
>#1. How do I intercept these strings?
>
>#2. How do I call FFMPEG from within a perl script?
>* Do I use backtick?
>* Do I use Syscalls?
>
>Thanks
>Dan




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


Re: ActiveState - how times have changed

2010-08-26 Thread Chris Jones
Thank you for your comments David.
Well, it will inspire those same developers who are marketing their 
own Windows Perl versions with graphical debuggers and they are 
willing to help with the setup.  But then I would have to use the 
built in http server and yet another program to learn and tweak.

I will likely upgrade, I don't have time to fiddle with an 
alternative - I did get an offer of a $50 discount as a long time 
customer.  I guess this is what happens when a small startup goes 
public and the bean counters take over.

At 01:28 PM 24/08/2010, David Kaufman wrote:
>Hi Spencer,
>
>Perhaps I reacted a bit too harshly.  I'm actually a happy long-time
>user and even a huge *fan* of ActiveState.  It's just that, as a loyal
>customer, I feel burned.  I feel "fired" in fact:
>
>2007-03-21  $49.95
>PDK Deployment Tools 7 Upgrade - SKU: pdkdt_upgrade_prod_as09
>
>2004-04-11  $59.95
>PDK Deployment Tools 6 Upgrade - SKU: pdkdt_upgrade_prod_as09
>
>2004-01-23  $79.95
>Perl Dev Kit 5 Upgrade - SKU: PDKU
>
>2002-04-02  $79.95
>Perl Dev Kit 4 Full - SKU: PDK
>
>1999-12-09  $0.00
>Perl Dev Kit 1 (Beta/Promo?) - SKU: PDK
>
>1998-04-02  $0.00
>Perl Debugger 1 (Beta/Promo?) - SKU: perlde_new_prod_as09
>
>As you can see (they do keep good records...) no, I have not ever paid
>over $100 dollars for PDK up until now, and having fallen behind a
>version or two, I apparently don't qualify for even the $150 upgrade
>price!
>
>To remain an PDK user and an ActiveState customer, they're forcing me to
>pony up $295.
>
>Version 7: fifty dollars.
>Version 9: three hundred.
>
>Seriously?  There is no marketing in the world that will convince me
>that it's six times as good, six times as bug free, or six times more
>fun to use.  I know this is the way software is sold in Redmond, but
>even they know they will surely lose the share of the market for whom
>they increase the cost of their product 600%, right?  I mean, they're
>surely not dumb.
>
>The only reason I can think of is that they don't want us.  They
>increased the price that much for me because either
>
>a) I'm a statistical anomaly, such an infinitesimal percentage of their
>installed user base that they don't care about losing me,
>

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


ActiveState - how times have changed

2010-08-23 Thread Chris Jones
Getting a new computer, with a new operating system, is an 
eye-opener.   I thought I would just upgrade my beloved Komodo 
personal edition to find that Personal is no longer a concept at 
ActiveState.  PDK or Komodo - $295US if you want a graphical debugger 
for old Perl cgi scripts running on Windows 7?

Times have changed since I first started supporting ActiveState back 
in 1999 or so.




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


Re: Use DLL files at Unix server

2010-04-24 Thread Chris Wagner
In that case u should use SETUID.  U make a compiled C wrapper that
possesses the SETUID bit and does nothing but execute the Perl script.  The
user runs the wrapper and can't read or execute the real script.


The C code is
#include 
int main(int argc, char *argv[]) {
execv("PATH", argv);
return 1;
}

Replace PATH with the Perl script.


At 03:21 PM 4/23/2010 +0530, Kprasad wrote:
>I've to give this script to someone else department and they should not be 
>able to modify or see the code.
>
>Kanhaiya



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


Re: How to make 2 lines into one

2010-03-11 Thread Chris Wagner
It seems like what u want to do is collapse vertical white space.  Is that
text file u attached really what u have to work with?  This looks like it
was generated from a spreadsheet or CSV file of some kind and it would be
much easier to deal with that.


At 01:11 AM 3/10/2010 -0800, James T. wrote:
>Thanks Steffen,
>
>I've have a new input file 'state.txt' and the expected output file
'stateout.txt' and it is becoming more complicated.
>
>I will need to make info from 3 lines into 1 line in some cases.
>



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


Re: Perl Regex

2010-02-26 Thread Chris Wagner
It looks like what u want to do is attribute folding.  That's when u take a
nested XML tag and make it an attribute of an enclosing tag.  Ur doing
something slightly different which is merging equal depth tags.  The right
way to do this is with an XML parser.  Look into XML::Simple to get started.
U would read in the XML to a hash, manipulate the data in the hash, and then
write out a new XML file.

Regex can do this in a degenerate case but it becomes unmanageable fast.
But since u asked

$xml =~
s{(\s*)([^<]*)\s*([^<]*)(\s*)}{$1$2$4}sg;

HTH


At 09:25 PM 2/26/2010 +0530, Kprasad wrote:
>Hi All
>
>What will be the perfect Regular Expression to convert below mentioned
'Search Text' to 'Replacement Text' while 'Single Line' option is ON.
>
>When I use below mentioned Regex
>]+)?>((?!<\/index-entry>).*?)\s*([0
-9]+)
>
>And replaces wrongly
>
>arousal disordersdisorders of arousal
>
>.
>
>Search Text:
>
>
>APOE e4 variant 18
>
>
>arousal disorders disorders of arousal
>
>
>arterial blood gas tests 32
>
>
>asthma 28--9, 295
>
>
>Correct Replacement Text should be:
>
>
>APOE e4 variant
>
>
>arousal disorders disorders of arousal
>
>
>arterial blood gas tests
>
>
>asthma
>
>


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


Re: HTML Parsing Question

2010-02-05 Thread Chris Wagner
Hi.  The big issue is the ignore unknown tag setting.  Also the module does
not like a missing  and .

Also this isn't HTML.  U might be better served by using XML::Simple.
Printf is ur friend.

use HTML::TreeBuilder;

$html = '

.


';

$tree = HTML::TreeBuilder->new();
$tree->ignore_unknown(0);
$tree->warn(1);
$tree->parse($html); $tree->eof;

@Ans = $tree->look_down('_tag' => 'button');
foreach $button (@Ans) {
printf "button is %s\n", $button->attr('name'); # prints "button is 
Button1"
printf "button tag is %s\n", $button->tag;  
# can also use ${$button}{_tag}  prints "button tag is button"
printf "button parent hash pointer is %s\n", $button->parent;   
# can also use ${$button}{_parent} 
# prints "button parent hash pointer is HTML::Element=HASH(0x1afa5c4)"

foreach $key (keys %{$button->parent}) {
print "key is $key\n";
# prints four keys: _parent, _content, _tag, _implicit
}
printf "button _parent value is %s\n", ${$button}{_parent};  
# prints "button _parent value is HTML::Element=HASH(0x1afa5c4)"
printf "button _tag value is %s\n", ${$button}{_tag};  
# prints "button _tag value is button"

$parent = $button->parent;
printf "parent tag is %s\n", ${$parent}{_tag};
# prints "parent tag is body"
printf "parent content is %s\n", ${$parent}{_content};
# prints "parent content is ARRAY(0x1afa7b0)"
#   foreach $key (@{${$parent}{_content}}) {
#   #   print "content item is $key";
#   }

#print "parent name is " . $parent->attr('name');

$groupid = $button->look_up('_tag', => 'group');
#  print "group id is " . $groupid;
}

#   $tree->dump;

 print $tree->dump; #as_HTML;


button is Button1
button tag is button
button parent hash pointer is HTML::Element=HASH(0x19b9224)
key is _parent
key is visible
key is linkanimations
key is linkbaseobject
key is wallpaper
key is tooltiptext
key is name
key is linksize
key is linkconnections
key is isreferenceobject
key is _content
key is exposetovba
key is _tag
button _parent value is HTML::Element=HASH(0x19b9224)
button _tag value is button
parent tag is group
parent content is ARRAY(0x19b90c8)
button is Button24
button tag is button
button parent hash pointer is HTML::Element=HASH(0x19b9224)
key is _parent
key is visible
key is linkanimations
key is linkbaseobject
key is wallpaper
key is tooltiptext
key is name
key is linksize
key is linkconnections
key is isreferenceobject
key is _content
key is exposetovba
key is _tag
button _parent value is HTML::Element=HASH(0x19b9224)
button _tag value is button
parent tag is group
parent content is ARRAY(0x19b90c8)




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


Re: Help with Win32::Input

2010-02-05 Thread Chris Wagner
I would use Term::ReadKey to to do non blocking reads in this situation.  It
even accepts drag and drop file names while in the background.


At 04:21 PM 2/5/2010 -0800, Barry Brevik wrote:
>I am writing an app that continously loops looking for files to appear
>in a certain directory, and when they do, it reads those files and does
>some work with them.
> 
>...BUT...


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


RE: inconsistent behavior using perl.exe via 'Send To'

2009-12-11 Thread Chris Wagner
AS has a built in utility called pl2bat for converting Perl scripts to batch
files.  It should work out of the box.



At 08:48 AM 12/10/2009 -0800, gai...@visioninfosoft.com wrote:
>in bat form, the bat file would need to look something like
>start "window title" c:\perl\bin\perl.exe c:\script.pl %~f1 %~f2 %~f3 etc...
>(to pass all selected file name parameters into the perl script)
>
>I haven't been able to determine if there is some maximum f# that a batch
>script should be able to accept.  if the user were to control-click a couple
>hundred jpg files to be 'sent to' this script for processing, do you feel
>the bat file should just do %~f1 %~f2 %~f3 ... %~f200?
>
>or is there a more generic way to specify to send 'any arbitrary number' of
>selected file name parameters to the script?
>
>thanks.
>


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


Re: Net::cmd and dialog

2009-12-09 Thread Chris Wagner
U should use the DumpLog constructor option.  That captures a raw log of the
communication so u can see what is actually being sent and received.  I've
had to refer to it numerous times to get my statements working.


At 05:48 PM 11/30/2009 -0800, James T. wrote:
>Hi all,
>
>Is there a way to run a script that take standard input.
>My remote script is called 'restore'. When it is run , it require a "Yes or
NO" answer before it can run"
>My  Perl program telnet find but cannot seems to pass the "Y" or "N" for
the restore script to run.
>
>
>use Net::Telnet;
>
>$ip = "hulk";
>$user = "user102";
>$password = "";
>
>   print "Running  ...\n";
>  $t = new Net::Telnet(-Timeout=>36000,-Errmode=>"return");
>  $t->open($ip);
>  $t->waitfor(Match=>'/login/i');
>  $t->print("$user");
>  $t->waitfor(Match=>'/Pass/i');
>  $t->print("$password");
>  @pass=$t->waitfor(Match=>'/%/');
>  
>  $t->cmd('cd TOOLS'); 
>  $t->print('restore');
>  $t->waitfor(Match=>'/Are you sure/i');
>  $t->print("y");
>
>


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


Re: inconsistent behavior using perl.exe via 'Send To'

2009-12-09 Thread Chris Wagner
I would try wrapping the functionality in a batch file.


At 02:23 PM 12/9/2009 -0800, gai...@visioninfosoft.com wrote:
>I have two computers.  one is XP pro, the other XP home.  likely there are
>some 'non-standard' softwares installed to the xp home system (this is not
>my own pc, so im less familiar with the variety of software installed to
>it).
>


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


Re: Resolve hostname by specified nameserver

2009-10-24 Thread Chris Wagner
Why can't u use Net::DNS?  It's pure Perl so there shouldn't be any trouble
using it anywhere on Windows.  It doesn't have to be installed globally to
use it.  U can copy it into ur own directory and do a use lib in ur script
to load it.  Even in the worst case scenario u can copy all of the Net::DNS
code directly in ur own script.


At 04:34 PM 10/20/2009 +0200, rocku wrote:
>Hello,
>I need to resolve a hostname by a specified nameserver. Currently I am 
>using nslookup throught backticks, but it's output differs slightly 
>between Windows versions and is hard to parse. I wanted to use Socket 
>and something like inet_ntoa(inet_aton('hostname')) but this way I have 
>no option to specify the nameserver to query. I am aware about Net::DNS, 
>but unfortunately I cannot use it because it's not standard in 
>ActivePerl 5.10. An ideal solution would be some WMI function, but I 
>cannot find any for the task. Maybe using Win32::API?
>
>So my question is - how to query a specific nameserver about a DNS 'A' 
>record?


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


Re: need help from a new hand for perl

2009-08-25 Thread Chris Wagner
At 03:43 PM 8/19/2009 -0500, Fei Shi wrote:
>Only when I run the code below I have a little problem:
>*cat ids_overlap_* | sort -u > "a file name"*
>
>I have 3 files named as *ids_overlap_*(21Us/coding/ram)*. The error message
>is:
>*The system cannot find the file specified.
>cat.exe: write error : invalid argument*


Why are there star characters there?  If u are trying to run that line from
within a perl script it won't work.

system 'cat ids_overlap_* | sort -u > "a file name"';
or
@return = `cat ids_overlap_* | sort -u > "a file name"`;





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


Re: need help from a new hand for perl

2009-08-18 Thread Chris Wagner
At 04:39 PM 8/18/2009 -0500, Fei Shi wrote:
> But there is an error coming out when I tried to run this command
>their demo: "perl auto_blast.pl 454_aligned.fa precursors. fa-b >
>signatures".
>
>The error message is as follows:
>*Copying subject file 'cp' is not recognized as an internal or external

Yep, it looks like that perl script is not Windows compatible.  It's using
Unix shell commands instead of the pure Perl equivalents.  One thing u can
do is install Cygwin and use its version of Perl to try running the script.
Cygwin provides a Unix like shell for Windows.  cygwin.com




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


RE: Perl and memory...

2009-07-29 Thread Chris Wagner
At 12:30 PM 7/28/2009 -0700, Jan Dubois wrote:
>It is also not clear to me if you were looking at physical or
>virtual memory allocation.  In some ways it doesn't make sense
>to obsess about returning memory to the OS too much: if you don't
>use it anymore, it will just get paged out to disk.  And other
>processes have their own virtual memory anyways.

Sergei's test script showed the physical and virtual usage dropping after
thread joining.  In my situation (Solaris, ActivePerl) I believe the problem
was exceeding some 32 bit resource limit.  It was a 100 thread 2GB of memory
monster that ran for several days.  I had to reduce the thread usage to 60
even after adding the multiprocess component to keep it from crashing with
resource messages.  The problem was that individual threads would
occasionally need very large memory spaces.  Once they were done and moved
on to smaller tasks, the memory would never be made available to other
threads.  So once enough threads had run across large memory tasks, the
whole process would crash.  So when ur obstacle is resource limits,
regaining memory is critical.




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


Re: Perl and memory...

2009-07-28 Thread Chris Wagner
At 06:48 PM 7/28/2009 +0300, Serguei Trouchelle wrote:
>I'm not sure. Ending thread on Windows deallocates memory as it said in
MSDN, but I'm not exactly sure how Perl handles 
>all this stuff.

So that could be Windows specific?  The application I made was on Solaris.
I actually thought it was a memory leak in my code.  After I found out Perl
couldn't free() memory I gave up on trying to shrink the process size and
implemented a multiprocess system to deal with the memory issue.  It was
ActiveState Perl though.  Jan?




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


Re: Perl and memory...

2009-07-28 Thread Chris Wagner
At 01:31 AM 7/25/2009 +0300, Serguei Trouchelle wrote:
>Or, as your question partially suggests, use threads: ending a thread will
release the memory back to OS.

Really?  Is that documented anywhere?  Knowing that could've saved me a lot
of trouble on a massively threaded long running application I made a while ago.

Perlthrtut should have that kind of information.  Who maintains that?




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


Re: Substitution problem

2009-07-23 Thread Chris Wagner
Hi.  I'm not totally sure what ur asking but it seems that u want to do
variable substitution in an XML file.  If the variable names are already in
the text u need an eval.

$text = eval "\"$xmlfile\"";

That will replace $1 with whatever it's current value is.  However, this
isn't really the right way to substitute text.  

Another way: $xmlfile =~ s/\$1/$new/;   ## works with any token

If u can give a more generic description of what u have to do, maybe we can
help more.


At 06:58 PM 7/15/2009 +0530, Kprasad wrote:
>Here is the Perl code which I'm using for substitution in xml file
UIIE_A_123456.xml.
>I'm getting search string and replacement string for substitution from
another file (cleanup.txt)
>
>But after substitution, variable of replaced string doesn't interpolated as
defined in 'cleanup.txt' i.e., 
>http://cats.tfinforma.com/dtd/tfja/dtd/TFJA.dtd";>
>SHOULD BE
>http://cats.tfinforma.com/dtd/tfja/dtd/TFJA.dtd";>
>
>Perl Code:
>
>#!/usr/bin/perl -w -s
>
> $/ = undef;
> open(INFILE," $_=;xml_cleanup();
> close(INFILE);
> open(OUTFILE,">c:/UIIE_A_123456") or die "Cannot Open: xml";
> print OUTFILE $_;
>
>
>sub xml_cleanup
>{
> open(IN," $cleanup=;
> close(IN);
> while ($cleanup=~/(.*?)<\/text>(.*?)<\/with>/gc)
> {
>  $txt="";
>  $rep="";
>  $txt=$1;$rep=$2;
>  if($_ =~ s/$txt/$rep/g){print "Replaced $txt with $rep\n";}
>  else{print "Not found $txt\n";}
> }
>}
>
>File: UIIE_A_123456.xml
>
>http://cats.tfinforma.com/dtd/tfja/dtd/TFJA.dtd";>




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


Re: Differentiating MS office files from other Files?

2009-07-23 Thread Chris Wagner
Hi.  U should check out the `file` utility provided by Cygwin.

D:\GE>file -pk TNAdoc_draft1.doc
TNAdoc_draft1.doc: Microsoft Office Document


At 12:39 AM 7/16/2009 -0700, imagine2200 wrote:
>Hej everyone,
>
>   I want to know if their is any way in perl
>to differentiate Microsoft Office files from other files. For example,
>the program should receive a file as input and should print whether
>this is MS office file or not?
>
>
>Can someone kindly help me in this regard?




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


Re: CPAN install directory usage

2009-07-01 Thread Chris Wagner
There should not be stars in front of any of the Perl statements.  Although
I don't think that is the main problem here.  If it can find Tk.pm it should
be able to find Events.pm.  U'll need to go into the Tk directory and
manually verify the presence and permissions of all the files Tk needs.
Install it on ur own PC to compare.  If there is any difference, contact ur
sysadmin to get the Tk installation fixed.


At 08:47 PM 7/1/2009 +0530, Perl Perl wrote:
>Hi Chirs Wagner,
>
>TK.pm is located at gvinen lib path. I included the library path as
>you said, but still i am facing same issue.
>Please find the library path and file located there for your kind reference.
>
>Library path :  V:\view_MAIN\vob_verif\tools\Perl\lib
>* 06/29/2007  08:54 PM18,676 Tk.pm
>*
>Script :
>
>#!/usr/bin/perl -w
>
>*use lib 'V:\view_MAIN\vob_verif\tools\Perl\lib';
>*use FindBin qw($RealBin);
>
>use Tk;
>V:\view_MAIN\vob_verif>v:\view_MAIN\vob_verif\tools\Perl\bin\perl.exe
>Test.pl
>Can't locate Tk/Event.pm in @INC (@INC contains:
>V:\view_MAIN\vob_verif\tools\Perl\lib
>v:/view_MAIN/vob_verif/tools/Perl/site/lib
>v:/view_MAIN/vob_verif/tools/Perl/lib .) at
>V:\view_MAIN\vob_verif\tools\Perl\lib/Tk.pm line 1
>3.
>BEGIN failed--compilation aborted at
>V:\view_MAIN\vob_verif\tools\Perl\lib/Tk.pm line 13.
>Compilation failed in require at Test.pl line 6.
>BEGIN failed--compilation aborted at Test.pl line 6.
>
>I am not sure, but would like to bring one point to notice, am I doing any
>mistake here with respect to "library path inclusion in Windows side,  *use
>lib 'V:\view_MAIN\vob_verif\tools\Perl\lib';  *
>
>Regards,
>Mujju




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


Re: Archive::Zip problem

2009-07-01 Thread Chris Wagner
read( $fileName ) 

Read zipfile headers from a zip file, appending new members. Returns 
AZ_OK or error code.

my $zipFile = Archive::Zip->new();
my $status = $zipFile->read( '/some/FileName.zip' );



At 10:06 AM 7/2/2009 +0530, Kprasad wrote:
>Hi All
>I've simple perl program which should be used to extract two .zip files at
the same time. Directory for unzipping will be the name of individual zip file.
>Problem: First zip's content extract perfectly but after unzipping Second
zip it contains the files of first zip too.
>I've two zip files i.e., first.zip and second.zip which respectively
contains 3 files and two files and after extraction 'c:/onfly/first' should
contain 3 files and c:/onfly/second' should contain 2 files only.



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


Re: CPAN install directory usage

2009-07-01 Thread Chris Wagner
Hi.  The first thing u need to do is manually check what directory Tk.pm is
in.  Do a search if necessary.  So if Tk.pm is located in V:\x\y\z\Tk.pm,
put `use lib "V:/x/y/z";` at the top of ur script.  That should be all u
need.  If that doesn't work then there could be permissions issues.  Let us
know how it goes.

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


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


Re: use case for activeState

2009-06-22 Thread Chris Wagner
Not to be melodramatic, but u can create the entire Internet using
ActiveState Perl.  U could build Yahoo, Google, and Amazon for starters.
It's really suitable for every conceivable task other than audio video.


At 01:47 PM 6/18/2009 -0400, Pipirilo wrote:
>Is there a webpage in which I can see what kind of projects or products are 
>using ActiveState products?
>I want to know what I can do with this tools. Will it allow me to create 
>desktop as well as web applications? You know those kind of questions.
>Basically, I want to know why to use ActiveState products?
>
>I've been working with MS .NET for desktop and web applications for quite a 
>while, and it doesn't fit my expectations. I've used ORACLE long time ago, 
>and that is a very good tool, I miss it.



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


Re: Need help with my code

2009-06-22 Thread Chris Wagner
Hi.  I can understand why nobody on the other list responded to u.  I'm
taking an educated guess at what ur question is.  "It doesn't work" isn't a
good question.  Sorry to bust ur chops but asking well constructed questions
is the best way to get help.

Why are u using Tie::File?  With small files and not writing to them, it
doesn't buy u anything.  One bug seems to be that it doesn't support grep{}.
If I take out Tie::File the code seems to work.  That moves the problem to
ur regex's in &bootInfo.

The problem I believe is that none of the regex's in ur first big while{}
loop match anything.  That loop eats up all of the file and so the later
while{} loops have nothing to do.  Work on those regex's in that if/else
block and that should solve ur problem.  Put a lot of printf's throughout ur
code so u can track the state of the variables at critical points.

Some tips.  Comment ur code!  If u ever want ur work to be examined by
others (or even urself in the future), self document it with judicious
comments that explain what is going on at every steep.  This will greatly
help ur own code development.  Don't let one loop eat into the next section.
At each iteration check to see if ur spilling over into the next section and
bail out of the loop.  Don't jam alot of line checking into the loop
conditionals.  Don't use regular expressions when u can use index().  If u
are confident in the consistent formatting of ur data files, go directly to
the line numbers, don't scan for everything.  e.g. once u find LAN info, the
adaptors are 3 lines after that.  Use for(x;y;z) instead of while{}, it
keeps the loop business in one spot.  If ur not confident in ur ability to
control the cursor ($idx), go ahead and build an index ahead of time.  That
way u know to look at only lines 2 - 19 for boot information for example.

Hope that helps.  If u need more help, try to tell us what ur looking for in
the file and what formats the file can take.


At 11:59 AM 6/19/2009 -0700, James T. wrote:
> It works file file 'file1.txt' as it get some information
> on the "BOOT INFORMATION" but when running it with
> 'file2.txt' , it only get
> information on "BOOT PROCESSOR INFORMATION" but not the
> "BOOT INFORMATION"
> 
> Can someone tell me what's wrong with my &bootInfo
> subroutine ?
> I think the problem might in line 43
> while ( $idx <= $#{$data} and $data->[$idx] !~ m/(The
> current root cell is)|AutoBoot/)
> but I am not sure.



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


Re: question about recursion

2009-05-22 Thread Chris Wagner
Hey.  Yeah deep recursion is something I don't really want to deal with. :)
I've only used recursion once and that was to walk a data structure.  For
this kind of problem, which is a convergence problem, I would use a loop.
I'm assuming that there is a variance value that is computed and compared to
a tolerance value.  When the variance is within tolerance, u have "the answer".

Here's what I would do:

($variance, $answer) = &solver($variance, $answer) while $variance > $tolerance;
sub solver {
my ($initvari, $initanswr) = @_;
do { something; };
return ($curvari, $curanswr);
}

This gives u de facto recursion with the ease and sanity of iteration.  HTH.



At 02:02 PM 5/21/2009 -0700, gai...@visioninfosoft.com wrote:
>given:
>
>a. that its generally considered to be 'bad form' to use global variables
>inside of sub-routines.
>
>b. that I need to write a recursive sub-routine to solve a mathematical
>problem.
>
> 
>
>the sub-routine will recursively call itself until the 'answer' is derived.
>when the innermost call finishes executing, the program will drop through to
>the previous call, and so forth.  until it drops out of the original first
>call to the function.
>
> 
>
>at present, I am 'cheating' here by using a global variable to control this
>recursive behavior.  when the innermost loop finds the 'answer', the global
>variable is set to $weve_found_answer=1; 
>
> 
>
>the sub-routines then look to the value of $main::weve_found_answer to
>determine if it should stop recursively calling itself because the answer
>has already been found - or continue to recursively call itself again.
>
> 
>
>for now it 'works' but its not following the 'don't use globals unless there
>is no better way' principle.
>
> 
>
>so I ask.  'is there a better way of allowing each sub routines
>instantiation, at any nested level of the recursive call, be able to know
>when the answer has been found?'
>
> 
>
>if anyone has any insights or experience with this, I would be very
>interested to learn from your experience
>
> 
>
>thanks, greg
>


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


Re: use system() function

2009-05-13 Thread Chris Wagner
Hi.  Maybe if u gave a more high level description of what ur trying to do
we might be able to help u more. I think what ur going for is a find/replace
on a list of files?  If so, this is not the way to do it.

A generic find/replace would be like:

foreach $file (@files) {
open FILE, "<", $file;
my $text = join "", ;
close FILE;
$text =~ s/aaa/bbb/g;
open OUT, ">", $file;
print OUT $text;
close OUT;
}

But beware, that kind of simplistic find/replace is not very robust.


At 09:14 AM 5/13/2009 +0900, Chang Min Jeon wrote:
>hello
>
>I trying to modify file using perl one line like below.
>
>my $cmd = "perl -pi -e's/aaa/bbb/' ";
>
>open(MAKEFILES, '<', $ARGV[0]) or die "file open error";
>my @filelist = ;
>foreach my $file (@filelist) {
>chomp($file);
>my $command =  $cmd.$file;
>print $command,"\n";
>!system($command) or die "shell command not work";
>}
>close(MAKEFILES);
>
>but system function does not work.
>




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


Re: IO::Socket question (client receive - when # of bytes to be receivedis NOT known in advance)

2009-04-24 Thread Chris Wagner
If ur just trying to pull data from websites I would highly recommend LWP or
WWW-Mechanize.  No need to reinvent any wheels.  If this is just a
demonstration and ur trying to do something else, what u need here is
nonblocking read.  As u accumulate more of the response u can inspect it to
see when to expect the end.  Check out Fnctl to put the filehandle into
nonblocking mode.  U then go into a read loop and check the return value of
read().  

Unfortunately Fnctl is broken on Windows.  U may have to use Cygwin.  Jan?


At 04:36 PM 4/21/2009 -0700, gai...@visioninfosoft.com wrote:
>method 1 (below) does work to receive a response from a server.  but
>requires I know in advance the number of bytes to receive.
>
>#method 2
>
>#cant something like this be done instead?
>#i would prefer to use this pseudo-code method
>#as there is no hard-coded number of bytes to receive
>#is there a way to achieve this?
>#  while ( $main::socket->recv($block, 8192) ) {
># $response .= $block;
>#  }
>#  print $response;



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


Re: running a dos program from perl

2009-04-03 Thread Chris Wagner
I would use Expect for this kind of thing.

At 08:44 PM 3/31/2009 -0400, Spencer Chase wrote:
>Greetings Perl-win32-users,
>
>I need to run a dos program with parameters about 1500 times with different
parameter sets. I have a perl script that creates batch files with the
program call and parameters and these work fine. I am trying to find a way to 


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


RE: what is the most robust and accurate way to determine the BOOTvolume?

2009-03-31 Thread Chris Wagner
Hi.  The "right way" to retrieve this kind of information is from WMI.  If u
never used it download Scriptomatic from Microsoft and start exploring.  I
don't think it flat out tells u the information ur looking for but I think u
can figure it out by cross referencing some things.  The branches u'll
probably be interested in are Win32_OperatingSystem, Win32_LogicalDisk*, and
Win32_Disk*.  But be careful to differentiate between the system device and
the boot device.  They're not necessarily the same thing and u can get
burned by Microsoft's obtuse terminology and numbering system.  For example
on my system, what boot.ini calls disk 0 part 1, is really disk 1 part 0.
Some branches use the latter numbering, others the former. *shakes fist*


At 03:00 PM 3/30/2009 -0700, gai...@visioninfosoft.com wrote:
>I discovered (on my computer) that ENV vars named 'SystemRoot' and
>'SystemDrive' exist.
>
> 
>
>Does anyone know if these would be present on all Windows computers?  
>
> 
>
>If so, it would seem the answer here would be to merely look at
>$ENV{'SystemDrive'}
>
> 
>
>Can anyone think of a reason where these ENV vars would not exist?
>
> 


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


RE: trouble understanding unicode

2009-03-27 Thread Chris Wagner
Sorry for being contrarian here, but this is wrong.  Unconditionally blowing
away control characters is not the right way to do anything.  Using Perl's
own encoding disciplines is the right way to do this.  While this tr// may
work in this case and on other simple files, u just don't know what
legitimate unicode is in there that u want to keep.  Especially on Windows.


At 09:22 AM 3/27/2009 +0900, justin.allegak...@maptek.com.au wrote:
>Here's the preferred way of opening files along with the magic tr operator:
>
>use strict;
>use warnings;
>use Fatal qw( open );
>
>my $file = 'msinfo.txt';
>
>open my $FILE, '<', $file;
>while ( <$FILE> )
>{
>tr/\x20-\x7f//cd;
>
>print "$_\n";
>}
>close $FILE;
>
>
>__END__




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


Re: New to Perl and stuck

2009-03-03 Thread Chris Wagner
Hi.  Try this with the directory name as the command line argument.  Let me
know if u have any questions.  I really recommend getting one of the
O'Reilly books to really get into Perl.


%estparms = map {$_, 1} (18,21..24,28..31,206..208);
%popparms = map {$_, 1} (220,223..226,229..233,424..426);
$dir = $ARGV[0] or die;
@files = glob "$dir/*.txt";
foreach $file (@files) {
my $lineno = 0;
open FILE, $file;
while (my $line = ) {
push @estlines, $line if exists $estparms{$lineno};
push @poplines, $line if exists $popparms{$lineno};
$lineno++;
}
close FILE;
print "FILE\n$file\n";
print "ESTIMATION\n", join "\n", @estlines, "";
print "POPULATION\n", join "\n", @poplines, "";
}

At 11:44 AM 3/3/2009 -0600, Bryan Keller wrote:
>Hi all,
>
>The following gets me the lines I need for any single txt file.
>
>#!usr/bin/perl
>use warnings;
>use strict;
>
>my @output = <>;
>print "$ARGV";
>print ("\nESTIMATION\n");
>print @output[18,21..24,28..31,206..208];
>print "\nPOPULATION\n";
>print @output[220,223..226,229..233,424..426];
>
>These txt files are in groups of 25 (in folders).  My goal is to automate
this so that after specifying a folder, Perl will pull the specified lines
from each of the 25 txt files in that folder and write them to a single
output file.
>
>I would greatly appreciate any help or suggestions!
>
>Bryan
>
>-
>Bryan Keller, Doctoral Student/Project Assistant
>Educational Psychology - Quantitative Methods
>The University of Wisconsin - Madison
>___
>Perl-Win32-Users mailing list
>Perl-Win32-Users@listserv.ActiveState.com
>To unsubscribe: http://listserv.ActiveState.com/mailman/mysubs
>


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


Re: Commaring Two dates or month

2009-02-25 Thread Chris Wagner
Hi.

use Time::Local;
%months = qw/Jan 1 Feb 2 Mar 3/; # etc.
($day, $mon, $yr) = split/-/, "5-Feb-09";
##$time = timelocal($sec,$min,$hour,$mday,$mon,$year); see perldoc Time::Local
$time = timelocal(0,0,0,$day,$months{$mon} - 1, $yr + 100);
$now = time();
$diff = $now - $time;
print "now $now, time $time, diff $diff\n";
printf "Days from then to now is %s", int ($diff / 86400);

To see if something's installed do perldoc Package::Name.  Also try ppm.  HTH.


At 11:38 PM 2/24/2009 +0530, Perl Perl wrote:
>Dear All,
>
> I have to compare two dates. And populate the result based on that.
>First date I have received from previous script, which in this form
>5-Feb-09.
>And I have to compare this date with current date, locatime() . With the
>localtime() I will get the current Day (24),Month (2) & year (2009 )
>
>I will split the old date as below and get the result as below.
>
>$Old_Day = 5;
>$Old_Month = Feb.
>
>And then I convert Feb to 2 ( Month number ) by using scalar veriable. ( The
>thing repeated for all months ).
>


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


Re: long lasting command execution from cgi

2008-12-09 Thread Chris Wagner
Have the CGI script redirect the browser to the file.  The file will be
displayed to the browser as it is written.  Just tell the user to refresh
the browser to see more of the file as it is being written out.


At 08:22 PM 12/5/2008 -0800, [EMAIL PROTECTED] wrote:
>Yes, just the output file to display, however that file gets created
completely after say 4-5 minutes.
>
>  Regards & Thanks  Prabir Senapati  mailto: [EMAIL PROTECTED]
>
>
>--- On Sat, 12/6/08, Chris Wagner <[EMAIL PROTECTED]> wrote:
>
>> From: Chris Wagner <[EMAIL PROTECTED]>
>> Subject: Re: long lasting command execution from cgi
>> To: [EMAIL PROTECTED], perl-win32-users@listserv.ActiveState.com
>> Date: Saturday, December 6, 2008, 1:22 AM
>> It sounds like u just want to display the the output file in
>> the web
>> browser.  A simple redirect will do that.  Are u looking
>> for something more
>> than that?
>> 


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


Re: NET::SSH2 - No Output

2008-12-05 Thread Chris Wagner
At 04:10 PM 12/5/2008 -0500, listmail wrote:
>> I have to chime in.  That kind of construct is just plain wrong. :)  U need
>> an if{} block to test for every possible return type of $chan->read().  i.e.
>> blank, undef, valid number, invalid number, and other junk.  U've fallen
>Uh, I think you are just complaining about one of your pet peeves :) -- 

Yep. :)


>for him.  The docs or Channel.pm code do not seem to indicate the return 
>types you have mention here beyond -- bytes read or undef -- so I'm not 
>sure how you would code against all of those conditions unless you are 

Ur right it does depend on what the docs say, I was just trying to be
generic in describing a good practice.  If the module itself restricts what
the call can return then u don't have to check all that, just leaving an
else{} block is sufficient.  If undef or a number is the only legal return
value then the if{} block only needs to check for those specifically.


>If he's really concerned about ensuring that he gets all of the output 
>-- he needs to consider using $channel->exec otherwise even with adding 
>delays (ie. using select calls) *inside* the while loop it still may not 
>be long enough of a wait for read to be able to pull in all the output 
>as it will probably return undef several times.  Unless, that is, he's 
>ok with adding in several seconds of delays as needed to cover all types 
>of commands or scripts he'd run.

Ur right.  The problem is no terminator to the read.  *No* amount of loop
delay will guarantee that all the data has been read.  I ran into that
myself with some IPC I was working on.  I ended up creating a mini protocol
to solve the problem since I had control of both processes.






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


Re: NET::SSH2 - No Output

2008-12-05 Thread Chris Wagner
At 02:04 PM 12/4/2008 -0600, SelfSimilar wrote:
>> try something like
>> 
>> print $buf while (($len = $chan->read($buf,512))||0) > 0);
>
>Thank you for the suggestion. Unfortunately, it get the same error warning
>
>Use of uninitialized value in numeric gt (>) at SFTP_test2.pl line 21

I have to chime in.  That kind of construct is just plain wrong. :)  U need
an if{} block to test for every possible return type of $chan->read().  i.e.
blank, undef, valid number, invalid number, and other junk.  U've fallen
into the one liner trap.  Laziness *is* the cardinal virtue of the
programmer, but u can still be burned by it.




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


Re: long lasting command execution from cgi

2008-12-05 Thread Chris Wagner
It sounds like u just want to display the the output file in the web
browser.  A simple redirect will do that.  Are u looking for something more
than that?


At 10:58 PM 12/4/2008 -0800, [EMAIL PROTECTED] wrote:
>I wonder whether I can query on Unix Perl here. However I would appreciate
if someone please try to shed some light on-


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


Re: AdminMisc and hard drive recognition

2008-12-03 Thread Chris Wagner
Hi.  I'ld recommend using WMI for these kinds of things.  It's more robust
and u'll have far more cabability than with any of the Win32* modules.
Download Scriptomatic from Microsoft to learn how to use it.


At 09:52 AM 12/2/2008 -0600, [EMAIL PROTECTED] wrote:
>Hi, list.
>
>My PC has two physical hard drives. I'm trying to use Win32::AdminMisc to 
>read the individual sizes and cylinder, sector, and head counts for them. 
.




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


Re: RegExp matching over multiple lines

2008-10-21 Thread Chris Wagner
Hi.  Ur problem probably has to do with how ur eating the HTML file.  A
regex with /s needs the entire file in one variable.  If u do a line by line
with  it won't work since u won't have everything in one var.  Give
this a try.

$file = join "", ;
@divmatches = $file =~ m/]*>(.+?)<\/div>/sg;

As others have said using one of the HTML modules is the best way to handle
general parsing, but in trivial cases simple regex's like this are fine.


At 09:46 AM 10/21/2008 -0700, Andy Postulka wrote:
>I'm having difficulty using RegExp to match/extract across several lines in
an HTML file.
>
>I want to match and extract everything between a pair of HTML tags. 
>This Match/Extraction can occur over multiple lines in an HTML file.
> 
>I'm using the following RegExp to test the HTML file for a Match/Extraction
>
>/(.*?)<\/div>/s


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


Re: problem with FIRSTKEY in tied hash implementation

2008-10-01 Thread Chris Wagner
Hi.  I've had similar problems in other areas with the kind of problem ur
describing.  The problem is ur using "in-band signaling", as we say in the
telecom world.  Remember when kids could whistle into a phone and make free
long distance calls?  That was because of in-band signaling, the control
information and data were in the same channel.  So they came up with out of
band signaling so that control data can be transmitted unambiguously and
without interference from the data stream.  History lesson over. :)

What u could do is unconditionally return array context where the first
element represents the response type, and the second value is the real data.
U'll have to handle that in ur code but it should solve the clobbering
problem.  Another possiblity is to return the undef in list context.  keys()
always wants to return a list anyway.

As for the case insensitive thing, just do lc() on lookup. ;)
($key) = grep { lc $string eq lc $_ } keys(%hash);

Also does simply doing keys(%$hTied) give the proper list of keys even with
undef present?  If so u would work around by doing @keys = ... and iterating
over that list.

HTH


At 02:42 PM 9/30/2008 -0400, John Deighan wrote:
>foreach my $key (keys(%$hTied)) {
>print("$key = $hTied->{$key}\n");
>}
>
># --- the above prints nothing, as if the hash %$hTied has no keys, but
>So, understanding the problem, I figured that I'd go into my library and 
>simply fix the problem. So, I looked at my FIRSTKEY function. What it is 
>supposed to do is to retrieve the first key, and the first value and 
>return the first key in scalar context, or the pair first key and first 
>value if in list context. If there are no keys in the hash, it's 
>supposed to return undef in scalar context, but the empty list if in 
>array context. Well, we've got a serious logical problem if the first 
>key in the hash is undef - since returning undef in scalar context is 
>how we're supposed to indicate that there are no keys.
>


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


Re: Beginner Problems working with spaced filenames and directories on win

2008-09-23 Thread Chris Wagner
I would put some print statements in there to verify that the variables
contain what u think they contain.  Also Data::Dump::pp is ur friend.

e.g. print "\$top: $top\n";

Another thing I noticed.  Normally u want "opendir DIR, $top", not $DIR.  If
$DIR is undef, that code will fail.  A best practice is to always have an
else{} block after any if{} blocks to catch and debug errors.  The same goes
for unless{} blocks.  Use if(not..){} so u can use the else{} to catch errors.


At 02:59 PM 9/23/2008 -0400, Dennis Daupert wrote:
>===
>Here's the code:
>
>sub dir_walk {
>  my ($top, $filefunc, $dirfunc) = @_;
>  my $DIR;,
>
>  if ( -d $top ) {  # << FAILS HERE
>my $file;
>unless (opendir $DIR, $top) {
>  warn "Couldn't open directory $top: $!; skipping.\n";
>  return;
>}




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


Re: WSDL

2008-09-12 Thread Chris Wagner
At 05:19 PM 9/12/2008 -0700, Glenn Linderman wrote:
>You have "#expression".  Maybe you need 
>"/trees/config/trends/~trend/display_colors/background.value"?  OR maybe 
>you need "$expression"?  Or maybe this is just a typo in the email?

Heh, no, that is just placeholder text. ;)  The /trees... thing is one
possible expression.




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


WSDL

2008-09-12 Thread Chris Wagner
Greetings and felicitations.

I've been trying to use SOAP::WSDL to grab some data but I'm having trouble
figuring out how to do it in Perl.  We have an HVAC system that provides a
WSDL interface that I need to poll values from.  The vendor gave us some
example VB code that should poll the thing but I can't seem to figure out
how to make the Perl equivalent.

VB Code:
Dim client As MSSOAPLib30.SoapClient30
Set client = CreateObject("MSSOAP.SOAPClient30")
client.MSSoapInit ("http://"; & host & "/_common/services/EvalService?wsdl")
test = client.getValue(user, passwd,
"/trees/config/trends/~trend/display_colors/background.value")


I made an attempt to duplicate that VB with OLE and it seemed to run, but I
got no output.


$o = Win32::OLE->new('MSSOAP.SOAPClient30');
$o->MSSoapInit("http://$host/_common/services/EvalService?wsdl";);
$val = $o->getValue($user, $pass, "#expression");


Anybody have any experience with WSDL or other ideas?  Thanks in advance.





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


Re: Run perl on window using cygwin+Eclipse+EPIC

2008-09-10 Thread Chris Wagner
I think what ur asking is why does this work under Cygwin but not under
Eclipse?  Or vice versa?  It all depends on what "shell like thing" the ``
command is being filtered through.

Cygwin paths and Windows paths are not interchangable.  If u run it under
Cygwin the paths will be like /c/perl/perl.exe and find can grok that and do
something useful.  But under Windows that path is C:\perl\perl.exe, which
find will choke on if invoked under a unix like shell.  The find command
will see C:perlperl.exe.  U have to double the backslashes or convert them
to forward slashes to keep shell translation from destorying ur command line.

[attic:/d/backups]$ find d:\backups
find: `d:backups': No such file or directory


At 02:45 PM 9/10/2008 +1200, Jing LI wrote:
>I have one Perl script which works when executing it directly in Cygwin
>window.  
> 
>It uses find to find a type of file in a directory and its subdirectories: 
> 
>my @jarfiles = split(' ',`find $bin_location -name "*.jar"`); 
> 
>But when run or debug it in Eclipse, it has error: 
>sh: find: No such file or directory.  
> 
>I have set the Perl interpreter in Eclipse->Window->Preferences->perl EPIC.
> 
>The scripts I work on work fine on linux, and I tested it works find in
>Cygwin. I really want to know how to run it in Eclipse+EPIC+cygwin as it
>allows me to debug the perl scripts.  




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


Re: Referenced data changing

2008-09-10 Thread Chris Wagner
Ohayou.  I think what ur asking is why does @code change when u loop over it
with foreach, ne?  This is because foreach only takes a reference to the
list values, it doesn't create a copy.  So changing the iterand changes the
original value.  If u don't want this u have to make ur own copy of the
variable.

foreach $i (@list) {
my $j = $i;
&dosomething($j);
}

See?



At 02:30 PM 9/9/2008 +0900, =?iso-2022-jp?B?GyRCRUQ4fRsoQiAbJEI5QBsoQg==?=
wrote:
>Hello,
>
>I'm just maintain this odd script.
>On the code;
>  foreach my $val (@{$$code{"1"}}) {
>I think $val is lexical but in the 2nd call of test_val
>the data is changed.
>I don't want it.
>I must code like;
>my $val2 = $val;
>$val2 =~ s/^0+//;
>to avoid the changing.
>
>I cann't understand why?
>
>#!/usr/bin/perl
>use strict;
>print "TEST1 start...\n";
>my %code;
>push @{$code{"1"}}, "01";
>push @{$code{"1"}}, "02";
>push @{$code{"1"}}, "03";
>
>for (1..2) { test_val($_, \%code) }
>
>sub test_val {
>  my $p = shift;
>  my $code = shift;
>  print "test_val p=$p\n";
>  foreach my $val (@{$$code{"1"}}) {
>print "val=$val\n";
>$val =~ s/^0+//;
>print "val=$val\n";
>  }
>}
>
>__END__
>
>
>C:>TEST1.pl
>TEST1 start...
>test_val p=1
>val=01
>val=1
>val=02
>val=2
>val=03
>val=3
>test_val p=2
>val=1
>val=1
>val=2
>val=2
>val=3
>val=3
>
>Regards,
>H.T.
>___
>Perl-Win32-Users mailing list
>Perl-Win32-Users@listserv.ActiveState.com
>To unsubscribe: http://listserv.ActiveState.com/mailman/mysubs
>


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


Encryption recommendations

2008-08-08 Thread Chris O
Hi All!

I need to encrypt txt files on a shared linux web server, then decrypt
& read them on a win32 box. What module(s) are recommended for this?

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


Track mouse position

2008-06-06 Thread Chris O
The idea of better employee monitoring has been discussed at my
office. I'd like to create a compiled executable to be distributed via
group policy that will track mouse movement (or lack of) and report
activity/inactivity to a local server. I want to know when an employee
is working and when they're away from their desk.

I already know how to compile a perl script, distribute it to all
workstations, and have it report back to a server. I need to know
what's the best way to implement tracking of mouse movement. Ideas?

Also, the workstation OS is XP Pro if it makes any difference.

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


Re: mail message truncated when using net::smtp

2008-05-17 Thread Chris Lindsley
Hi,

I found the problem.  I knew I had sent larger messages before and I
tried sending one of those with my new code.  It worked like a champ.
I noticed that none of my previous messages had as long a paragraph as
existed in the new message.  So, I tried breaking up the problem
paragraph by putting some \n's in.  The message sent successfully.  No
truncation.

It seems that the smtp server I'm using must have a line length limit.
 Maybe all smtp servers have that limit.  Just thought I'd post this
in case others had this issue.

Thanks,

Chris

On Fri, May 16, 2008 at 4:21 PM, Chris Lindsley <[EMAIL PROTECTED]> wrote:
> Hi,
>
> I am using the net::smtp module to send an email.  I'm trying to send
> an email of about 2400 characters.  It is getting truncated at a
> little over 1800 characters.  Does anyone know of parameters I can add
> to up the call to up the message length?
>
>
> perl -v
>
> This is perl, v5.10.0 built for MSWin32-x86-multi-thread
> (with 3 registered patches, see perl -V for more detail)
>
> Copyright 1987-2007, Larry Wall
>
> Binary build 1002 [283697] provided by ActiveState http://www.ActiveState.com
> Built Jan 10 2008 11:00:53
>
> Perl may be copied only under the terms of either the Artistic License or the
> GNU General Public License, which may be found in the Perl 5 source kit.
>
> Complete documentation for Perl, including FAQ lists, should be found on
> this system using "man perl" or "perldoc perl".  If you have access to the
> Internet, point your browser at http://www.perl.org/, the Perl Home Page.
>
> Thanks!
>
> Chris
>
___
Perl-Win32-Users mailing list
Perl-Win32-Users@listserv.ActiveState.com
To unsubscribe: http://listserv.ActiveState.com/mailman/mysubs


mail message truncated when using net::smtp

2008-05-16 Thread Chris Lindsley
Hi,

I am using the net::smtp module to send an email.  I'm trying to send
an email of about 2400 characters.  It is getting truncated at a
little over 1800 characters.  Does anyone know of parameters I can add
to up the call to up the message length?


perl -v

This is perl, v5.10.0 built for MSWin32-x86-multi-thread
(with 3 registered patches, see perl -V for more detail)

Copyright 1987-2007, Larry Wall

Binary build 1002 [283697] provided by ActiveState http://www.ActiveState.com
Built Jan 10 2008 11:00:53

Perl may be copied only under the terms of either the Artistic License or the
GNU General Public License, which may be found in the Perl 5 source kit.

Complete documentation for Perl, including FAQ lists, should be found on
this system using "man perl" or "perldoc perl".  If you have access to the
Internet, point your browser at http://www.perl.org/, the Perl Home Page.

Thanks!

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


RE: draw boxes around tablular data ???

2008-05-16 Thread Chris O
> However, the customer wants the printed production orders to have boxes
> drawn around the tabular data.

> Currently, the tabular data is formatted via printf's to generate
> aligned columns, written to a TXT file, and send to a line printer.

> Please, give me some ideas HOW to draw boxes around this tabular data.

--

You could use an image file format or PDF to display the text. Then, draw
boxes around it.

- Chris

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


Re: module to access a remote machine

2008-04-10 Thread Chris Wagner
At 12:39 PM 4/10/2008 -0700, raj esh wrote:
>Hi all,
>   
>  This is raj. I want your help in the solving this problem. What module
can be used to get a file (this is not a system file this is my own created
file) from a remote win 2003 server machine when FTP,Telnet,SSH service on
that box is disabled.I am unable to find a correct module for this type of
probelm. 

Hi.  U should take a look at the Win32::lanman module.  U can script the
login to the box and then do a normal file copy.  There are also a bunch of
other Win32 modules that might help out with what u need.  Another way to do
it is with the WMI interface.  Get Scriptomatic from Microsoft to learn how
to use that.





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


RE: Perl tree data & HTML

2008-04-10 Thread Chris Wagner
At 12:58 PM 4/9/2008 +0100, Brian Raven wrote:
>use CGI::Pretty qw{:standard};


I'ld be cautious about using CGI::Pretty.  I've had it randomly mangle
output.  It would chop the final character of whatever was passed to it at
random times and then quit doing it later.  I couldn't figure out what was
wrong but just switching to plain CGI fixed it.




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


PerlEX,Modules, Sharing variables

2008-02-27 Thread Chris O
I'm attempting my first PerlEX app and I'm failing miserably. :-(

The goal is for my module to access variables stored in the calling
script. The following example works when run as CGI but fails as
PerlEX. Am I on the right path here or is there a better way?



# --
# test.plex
# --

BEGIN {
use strict;
use test_package qw(&test_sub1 &test_sub2);
our $cached_when=(localtime);
}

our %hash = (
'Bob' => {
Age => '7',
Type => 'Foo',
}
);

print "Content-type: text/html\npragma: no-cache\n\n";

&test_package::test_sub1();

&test_package::test_sub2();



# --
# test_package.pm
# --

package test_package;

use strict;
use vars qw($VERSION @ISA @EXPORT @EXPORT_OK);

require Exporter;

@ISA = qw(Exporter AutoLoader);
@EXPORT_OK = qw(&test_sub1 &test_sub2);
$VERSION = '0.01';

sub test_sub1{

for my $subkey (sort keys %{$main::hash{'Bob'}}){
print "SubKey: $subkey = $main::hash{'Bob'}{$subkey}\n";
}
}

sub test_sub2{
print 'Cached: '.$main::cached_when."\n";
print 'Now: '.(localtime)."\n";
}


1;
__END__


test.plex
Description: Binary data


test_package.pm
Description: Binary data
___
Perl-Win32-Users mailing list
Perl-Win32-Users@listserv.ActiveState.com
To unsubscribe: http://listserv.ActiveState.com/mailman/mysubs


RE: MSVCR71.dll error in ActivePerl-5.10.0.1002-MSWin32-x86-283697.msi

2008-02-26 Thread Chris O
> Does installing msvcr71.dll (into one of your "path" folders) fix the
> problem ?

> Rob


It appears to be a library issue at compile. Jan mentioned that
dbd-odbc makes reference to msvcr71.dll. He's working on it. The dll
is installed on the machine in question and works when I revert to
5.8.

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


MSVCR71.dll error in ActivePerl-5.10.0.1002-MSWin32-x86-283697.msi

2008-02-25 Thread Chris O
FYI, there appears to be a problem with the latest active perl release
(ActivePerl-5.10.0.1002-MSWin32-x86-283697.msi). After installation,
when I try to use any DBI related module, perl crashes and windows
displays the error "this application has failed to start because
MSVCR71.dll was not found". This is on server 2003 sp1.

I found some info at http://support.microsoft.com/kb/895994 related to
this error.


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


Re: My first 2 Scripting Games commentaries are online now

2008-02-20 Thread Chris Wagner
Ooo there's a picture up there?  I'm not going to go there now because I
think it's better for his appearence to remain a mystery. :P

At 09:37 AM 2/21/2008 +0800, Foo JH wrote:
>Hey Jan, now I know how you look...no guru-beard? I'm disappointed.
>
>Jan Dubois wrote:
>> Feel free to check them out, even if you are not taking part in
>> the Games, and let me know what you think:
>>
>>
http://www.microsoft.com/technet/scriptcenter/funzone/games/games08/experts.mspx





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


Re: Adding matched files to zip archive

2008-01-29 Thread Chris Wagner
At 11:39 AM 1/29/2008 -0500, Tseng, Joe  [CONTRACTOR] wrote:
>$objZip->addTreeMatching( $workingdir, 'config', "\.(ini|txt)");
> 
>But the following line doesn't work for adding what is remaining to
>another archive directory :
> 
>$objZip->addTreeMatching( $workingdir, 'results', "!\.(ini|txt)");

If that final argument is supposed to be regex code then u want a negative
lookahead assertion.  "\.(?!(ini|txt))"  That should do what u want.  U
should also read the regex manpage.  HTH





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


Re: vague error message

2008-01-08 Thread Chris Rodriguez


John Mason Jr <[EMAIL PROTECTED]> wrote:  Chris Rodriguez wrote:
> Hi everybody,
> I've been getting an error message I don't know what to do about:
> Perl has caused an error in PERL58.DLL.  Perl will now close.
> If you continue to experience problems, try restarting your computer.
> 
> It doesn't appear within the DOS window (I believe it's called, from 
> which I enter the command to run a program.)  A separate window appears 
> for the message.  Well, restarting didn't help.  This always happens at 
> the same point of one particular program.  That’s a "master" script I 
> have which runs a slew of other scripts over and over.  I goes through 
> once just fine, but on the second time through, when it gets to a 
> particular script... thud.  And there's nothing wrong with that 
> particular "sub" script.  It runs just fine by itself (and on the first 
> time through).
> Does anyone know what's going on?
> Thank you,
> Chris
> 


Is it possible to create a sample script that is as small as possible 
and exhibits the behavior you observed?


John

___
Perl-Win32-Users mailing list
Perl-Win32-Users@listserv.ActiveState.com
To unsubscribe: http://listserv.ActiveState.com/mailman/mysubs
Never mind - I figured it out myself.
  Thank you!
  Chris

   
-
Never miss a thing.   Make Yahoo your homepage.___
Perl-Win32-Users mailing list
Perl-Win32-Users@listserv.ActiveState.com
To unsubscribe: http://listserv.ActiveState.com/mailman/mysubs


vague error message

2008-01-04 Thread Chris Rodriguez
Hi everybody,
  I've been getting an error message I don't know what to do about:
  Perl has caused an error in PERL58.DLL.   Perl will now close.
  If you continue to experience problems, try restarting your computer.
  
  It doesn't appear within the DOS window (I believe it's called, from which I  
enter the command to run a program.)  A  separate window appears for the 
message.   Well, restarting didn't help.   This always happens at the same 
point of one particular program.  That’s a "master" script I have which runs a  
slew of other scripts over and over.  I  goes through once just fine, but on 
the second time through, when it gets to a  particular script... thud.  And 
there's  nothing wrong with that particular "sub" script.  It runs just fine by 
itself (and on the first time through).
  Does anyone know what's going on?
  Thank you,
  Chris
  
   
-
Be a better friend, newshound, and know-it-all with Yahoo! Mobile.  Try it now.___
Perl-Win32-Users mailing list
Perl-Win32-Users@listserv.ActiveState.com
To unsubscribe: http://listserv.ActiveState.com/mailman/mysubs


Re: Strange behavior with print

2008-01-03 Thread Chris Wagner
At 10:17 AM 1/3/2008 -0800, Mike Gillis wrote:
>You might want to take a look at PerlIO::eol, an IO layer which does 
>basically what you're asking for.
>
> From the docs:
>
>"This layer normalizes any of CR, LF, CRLF and Native into the 
>designated line ending. It works for both input and output handles."

Cool, I'll check that out.  It would be nice if this kind of functionality
as well as the ability to return the NLS could be incorporated into PerlIO core.



>open my $crfile, "<", $filename or die("Couldn't open $filename: $!");
>my @lines;
>{
>local $/ = "\r";
>@lines = <$crfile>;
>}

Right.  I just felt like doing split there for some reason. ;)





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


RE: Strange behavior with print

2007-12-29 Thread Chris Wagner
At 05:27 PM 12/28/2007 -0800, Jan Dubois wrote:
>I'm not sure what you are trying to say here.  While reading a file
>in text mode on Windows, it does not really matter if the lines are
>terminated by CRLF or LF alone; the CR will be stripped and at the
>Perl level you always have just a LF, just like on Unix.

What I was specifically thinking of was handling DOS text files on Unix.
Activestate on Unix has no conception of CRLF as a new line sequence
out-of-the-box.  This is a case where u have to manually inspect the file
and either set $/ (and reread the file) or strip the CR's.  Having a :text
IO discipline would fulfill portability.  What I did was create a chomp2
function that does s/[\cM]?\cJ$//.


>Files with CR line endings are extremely rare nowadays; as far as I

Rare, true, but irrelevant.  I have an app that spits out CR new line
sequences the output of which I parse with a perl script.  Normally I just
slurp smaller files into an array but in this case I had to add a split /\r/
to get the lines from the file handle.  Not a burden at all but unelegant.


>And anyways, you cannot know the line endings of a file until you have
>read all of it, which is not really practical for a streaming IO layer.

Eh, not really.  If u have something that u know is a text file u can be
pretty sure of the line ending after hitting the first one.  A :text
discipline could function by reading in bytes until it hits a CRLF, LF, or
CR. At that point it would set that as $/ for that handle.  It would be nice
if there were a method for getting $/ on a per handle basis.  What if u need
to read in two files of different line endings at the same time and write
them out to similarly ended new files?  How do u set $/ in that case?  AFAIK
$/ is global and doesn't have a per handle character.

psuedo code:
open FILE, "<:text", "obnoxious.txt";
$LE = textmode(FILE); #$LE will be a discipline ref suitable for open()
open OUTPUT, ">:$LE", "newfile.txt"; #OUTPUT will have the same NLS as FILE

Portable and elegant. :)





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


RE: Strange behavior with print

2007-12-28 Thread Chris Wagner
I see what ur saying and actually agree with u.  But PerlIO automatically
(this is one automatic thing I don't like) translates between CRLF and LF on
Windows systems.  As Jan said setting binmode() will solve ur problem.  

I personally feel that binmode should be the default everywhere and it
should be the programmer's responsibility to decide how to interpret the new
line sequences.  FYI there are three possible new line sequences, CR, CRLF,
and LF, depending on what system ur on.  In this day and age it's no longer
useful to assume what kind of new line sequences u have based on ur system
type.  U might very well have to deal with all three at the same time or a
contrary type to ur system's native type.

It would be nice if there were a :text IO layer that would automatically
determine the new line sequence of a particular text file and do the
translation, or not, automatically.  Currently u have to do an obnoxious
manual inspection of the file to know what $/ is. *cough*Jan*cough* ;)

HTH


At 11:24 AM 12/27/2007 -0500, Bullock, Howard A. wrote:
>I appear that perl's print command when using a file handle is changing
>each occurrence of chr(10) to (chr(13) chr(10)). This does not seem to
>be a helpful or proper action when working with defined literal strings.
>
>I can make some sense out of
>file:///C:/Perl/html/lib/Pod/perlport.html#newlines but do see how that
>is relevant to literal printing strings.





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


Re: Happy 20th Birthday, Perl!

2007-12-18 Thread Chris Wagner
Omedetou gozaimas Perl-san!! ^^






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


XMPP/Jabber example

2007-12-04 Thread Chris O
Hey Guys and Gals!

I may be going out on a limb here, but can anyone send me an example
of how to connect, send, and receive messages via XMPP? I've tried
many basic examples online, but none of them have options for
encryption. I'm using a default install of soapbox 07 server
w/encryption.

http://www.coversant.com/Products/SoapBoxServer/Overview/tabid/99/Default.aspx

Thanks!

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


Re: Cygwin perl and fork();

2007-09-04 Thread Chris Wagner
At 03:22 PM 9/4/2007 +0100, George wrote:
>I've made the sure the data is actually coming back by putting a print 
>in the while loop and that shows that it's coming back from the child. 
>All the data makes it back, but the while loop doesn't finish and the 
>timeout alarm hits, so the child gets reaped.  When it's reaped it 
>returns "Interrupted system call".
>   while() {
> #last if $_ eq "# DONE";
> if ($_ eq "# DONE") { close(CHILD); }
> push @lines,$_;
> print "#DEBUG CHILD: $_" if $DEBUG;
>   }

I've never heard of munin but I see one problem right here.  This while loop
will never exit.  The <> operator only fires when a new line sequence is
encountered.  However ur equality test doesn't have a \n in it and there's
no chomp() on $_. Try this:

while() {
chomp $_;
#last if $_ eq "# DONE";
if ($_ eq "# DONE") { close(CHILD); }
push @lines, $_;
print "#DEBUG CHILD: $_" if $DEBUG;
}

This way when the child script prints a "# DONE\n" the loop will recognize it.




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


Re: Back-up drives to CD and other drives

2007-08-23 Thread Chris Wagner
Hi.  What I do is use several small bash scripts that use rsync.  Each mini
script (one-liner) backs up a certain directory tree or a whole disk.  They
can be scheduled or run manually.  So usually after I do my email I run that
rsync script to backup my email client.

D:\backups>cat eudorabackup.sh

echo backing up eudora...
rsync -v -rlt --progress --ignore-errors --stats -i --delete 
/f/internet/eudora/ /d/backups/f_drive/internet/eudora

This method is really portable across systems.  U can backup to another disk
or another machine running rsync, Windows or unix.  One drawback to rsync
though is that is doesn't handle Unicode file names or inherited
permissions.  Rsync is part of Cygwin.

At 10:20 PM 8/22/2007 -0700, Suresh Govindachar wrote:
>On Windows, if you have used perl to make periodic 
>back-ups of your hard-drives to CDs and/or other 
>hard-drives, would you please share your experience
>(for example, what commands, modules and methods 
>worked and what didn't work)?  Include, pros and cons
>of 
>invoking native Windows' back-up commands v.s. 
>invoking unix-on-windows commands. 


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


Re: File::Remove cann't remove 'Japan'

2007-08-15 Thread Chris Wagner
Once again greetings Ta-kun.  I haven't had much success dealing with wide
characters from Perl.  There are two interfaces Windows provides for
accessing file names, ANSI and Unicode.  Code I've tried in the past would
only use the ANSI interface so u can't deal with anything with a codepoint
above 255.  What I would do is try to use WMI and delete the files that way.
I haven't tried it but from what I understand it's capable of dealing with
the wide characters.  I have no idea what Perl internals are Unicode aware
or what modules might be aware or even how to find out.  The
Win32::OLE->GetObject("winmgmts:) thing.  If u haven't downloaded
Scriptomatic from Microsoft u should get that from them.  Hope that helps, ja.

At 04:18 PM 8/15/2007 +0900, =?iso-2022-jp?B?GyRCRUQ4fRsoQiAbJEI5QBsoQg==?=
wrote:
>Hello,
>Any one is using File::Remove, and on multi byte platform?
>
>I'm using it on WindowsXP with Shift-JIS, a code for Japanese.
>And I can't remove a directory named "Japan"(\x93\xfa, \x96\x7b).
>Also it's return code is true.
>I know "\x7b" means "{".
>
>C:\>perl -MFile::Remove=remove -le "$File::Remove::debug++; print (remove
'@@%%')"
>missing: @@__
>@@__
>




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


RE: control M's

2007-06-26 Thread Chris Rodriguez
Thanks everyone for the overwhelming response!  I tried Jack's  solution first 
because it was so easy.  It turns out there's a  simple button on my ftp window 
to choose between binary or ASCII (or  Auto).  Voila!  Works like a charm!  
This has been  immensely helpful!
  Chris
  P.S. Thanks also, Jack, for including the link to an explanation for  why 
this happens.  Interesting how 'un-standardized' computers  are.  I guess it's 
still a new technology.

Jack D <[EMAIL PROTECTED]> wrote:  The problem likely occurs when you "upload" 
(assuming you meant ftp when you
said that. Ensure you ftp the file in "ASCII" mode when going from windows
to unix or vice versa. This will automatically remove any CR's.

http://en.wikipedia.org/wiki/Newline#Common_problems

Jack




 From: [EMAIL PROTECTED]
[mailto:[EMAIL PROTECTED] On Behalf Of
Chris Rodriguez
 Sent: Monday, June 25, 2007 2:41 PM
 To: [EMAIL PROTECTED]
 Subject: control M's
 
 
 Hi everyone,
 I wrote a cgi script in PERL which won't execute.  I'm told it's
because I have control M's at the end of each line, and that this happens
when editing programs in Windows (which I do, with Notepad).  I found a free
program on the web
(http://www.scriptarchive.com/scripts/snippets/rm_cont_m.pl) which claims to
remove them.  I ran it and uploaded the new program, but it still doesn't
work.  It may be that there's another problem with the script, then again,
maybe the control M's are still there.  I'd like to rule out the latter.
Can anyone advise me on dealing with this?  How can I remove them?  How can
I tell if they're there or not?  How can I type up a script so that they
never appear in the first place, etc.?
 
 Thank you,
 Chris

   
-
You snooze, you lose. Get messages ASAP with AutoCheck
 in the all-new Yahoo! Mail Beta. ___
Perl-Win32-Users mailing list
Perl-Win32-Users@listserv.ActiveState.com
To unsubscribe: http://listserv.ActiveState.com/mailman/mysubs


Re: download window instead of executing

2007-06-25 Thread Chris Wagner
At 10:36 AM 6/25/2007 -0700, Dan Jablonsky wrote:
>just a quick questions: why do I get a download window
>when I'm trying to execute a .pl file in the browser?
>It's something very simple but I forgot how one fixes
>this.

Hi. What do u mean by execute in the browser?  That doesn't make sense.  Are
u trying to run the script as a CGI and have it print its output to the
browser? If so then u don't have the script in the web server's CGI
directory.  If u want to have the script execute anywhere, not just in the
CGI dir, u have to enable script aliasing in the webserver's configuration
so that it will recognize .pl as an executable extension.




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


Re: control M's

2007-06-25 Thread Chris Wagner
That's a common problem with DOS versus unix file format.  U can use the
commandline tool dos2unix to convert it after u upload it.  DOS creates new
lines explicitly with the sequence CRLF while unix just uses LF (making the
CR implicit).

A simple workaround so that the file remains valid on both Windows and unix
is to add -I/dev/null to the shebang line at the beginning of the script.
This is a fix because it's the trailing CR at the end of that line that's
messing up ur script.  The system is looking for an interpretor literally
named "/usr/bin/perl^M".  It's blindly splitting the line on LF characters.
The -I/dev/null will "eat" the CR at the line's end allowing the system to
locate /usr/bin/perl.

So like this:
#!/usr/bin/perl -I/dev/null

This doesn't hurt anything since /dev/null can never affect ur program on
unix and it simple doesn't exist on Windows.  U can tell if they're there or
not by viewing the file with vi/vim on the unix box.  It will print them as
^M if present.


At 01:40 PM 6/25/2007 -0700, Chris Rodriguez wrote:
>Hi everyone,
>  I wrote a cgi script in PERL which won't execute.  I'm told it's  because
I have control M's at the end of each line, and that this  happens when
editing programs in Windows (which I do, with  Notepad).  I found a free
program on 




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


control M's

2007-06-25 Thread Chris Rodriguez
Hi everyone,
  I wrote a cgi script in PERL which won't execute.  I'm told it's  because I 
have control M's at the end of each line, and that this  happens when editing 
programs in Windows (which I do, with  Notepad).  I found a free program on the 
web  (http://www.scriptarchive.com/scripts/snippets/rm_cont_m.pl) which  claims 
to remove them.  I ran it and uploaded the new program, but  it still doesn't 
work.  It may be that there's another problem  with the script, then again, 
maybe the control M's are still  there.  I'd like to rule out the latter.  Can 
anyone advise  me on dealing with this?  How can I remove them?  How can I  
tell if they're there or not?  How can I type up a script so that  they never 
appear in the first place, etc.?
  
  Thank you,
  Chris
  
   
-
Boardwalk for $500? In 2007? Ha! 
Play Monopoly Here and Now (it's updated for today's economy) at Yahoo! Games.___
Perl-Win32-Users mailing list
Perl-Win32-Users@listserv.ActiveState.com
To unsubscribe: http://listserv.ActiveState.com/mailman/mysubs


Re: Perl-Win32-Users Digest, Vol 11, Issue 10

2007-06-19 Thread Chris Wagner
At 08:53 AM 6/20/2007 +0530, jagdish eashwar wrote:
>I got an idea after your suggestion that I should explore the Text::Wrap
>module. If  I can get perl to split the string after every so many
>characters, I'll have achieved what I want.  Is that possible?

That's exactly what Text::Wrap does.  If u just want to brutally
unconditionally wrap the text u can repeatedly do substr()'s on it and join
each piece with new lines.




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


Re: Truncating decimal number

2007-06-19 Thread Chris Wagner
At 03:50 PM 6/19/2007 -0700, John Townsend wrote:
>I don't need to round the number, I just want it to drop everything
>after the 6th decimal point. This should be easy, but I'm drawing a
>blank.

If u really need to truncate it and can't use sprintf for some reason u can
do this.

sub trunc {
my ($num, $places) = @_;
my ($int, $frac) = split /\./, $num;
return $num if length $frac == $places;
if ($places > length $frac) {
$frac .= "0" x $places;
}
$frac = substr $frac, 0, $places;
return "${int}.${frac}" if $frac;
return $int;
}
###
print trunc 11.23456, 4;
print "\n";
print trunc 5.6, 3;
^D
11.2345
5.600





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


RE: control characters in perl

2007-06-19 Thread Chris Wagner
At 09:40 AM 6/19/2007 -0700, Michael Higgins wrote:
>> Do word processors insert any character for word wraps like 
>> they do for new lines(\n)? If yes, what is the corresponding 
>> perl control character? I need to split a multi line string 
>> from a word table cell at the word wraps. 

Not that I know of.  AFAIK they calculate the wrap everytime.  Check out the
Text::Wrap module.




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


Re: Net::SNMP and threads

2007-06-17 Thread Chris Wagner
At 06:26 PM 6/17/2007 -0700, Bill Luebkert wrote:
>I thought you could only start 64 threads on doze ?  What happens with just
>50 threads instead of 100 ?

I've had over 70 running on XP.  The script is actually running on Solaris.
That's why I said I was "just asking". :P




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


Net::SNMP and threads

2007-06-17 Thread Chris Wagner
Greetz all, my email was toasted but now I finally got it fixed.

I wanted to ask here if anybody had any experience using Net::SNMP with
threads.  I'm working on a script that uses it to poll device data with 100
concurrent threads.  The memory usage however goes up forever, until it
crashes.  I wrote two test scripts that make a single snmp call, the routing
table, and just let the data expire.  Nothing is saved, just call and let
die. Then I ran that on 1000 devices.  The non threaded version runs fine,
no memory bloat.  The 100 thread version however starts at around 450 MB but
goes to 1.4 GB.  Serious trouble there.

I'm not really trying to get into troubleshooting it here, just wanted to
know if any of u have used it or know of a fix or workaround.  I contacted
the author and he's not sure what's wrong, though he is looking in to it.

Ja.




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


Re: Redirecting STDOUT

2007-04-01 Thread Chris Rodriguez


Bill Luebkert <[EMAIL PROTECTED]> wrote: Chris Rodriguez wrote:
> Hi everyone,
> I saw the following on another PERL list-serve:
> 
> "If you are on windows, then see perlfaq8 if ActiveState perl for
> how to redirect STDOUT and STDERR when doing backticks."
> 
>  I'd like to be able to capture STDOUT as a string. But nothing on  perlfaq8 
> struck me as relevant. Did I miss something? How do I do this?  I frequently 
> get drastic errors (my computer shuts down!) when I try to  use backticks.

Did you read:

 How can I capture STDERR from an external command?

Also check out the perlop man page under:

 qx/STRING/
 `STRING`

 ...

 $output = `cmd`;
# or grab STDERR as well
 $output = `cmd 2>&1`;

Hi.  "cmd" refers to any command, right?  Neither formulation works for me.  If 
I do:
$output = `perl -c somescript.pl`;
  I see "somescript.pl syntax OK" on the screen, and the variable $output 
remains unassigned.  If I do:
  $output = `perl -c somescript.pl 2>&1`;
  I get a message saying "This program has performed an illegal operation..." 
and I have to turn off my computer.
I've had the same problem using qx too.  Could it be that I'm using PERL 5.6?
  
  Chris

 
-
Never miss an email again!
Yahoo! Toolbar alerts you the instant new Mail arrives. Check it out.___
Perl-Win32-Users mailing list
Perl-Win32-Users@listserv.ActiveState.com
To unsubscribe: http://listserv.ActiveState.com/mailman/mysubs


Redirecting STDOUT

2007-03-30 Thread Chris Rodriguez

Hi everyone,
I saw the following on another PERL list-serve:

"If you are on windows, then see perlfaq8 if ActiveState perl for
how to redirect STDOUT and STDERR when doing backticks."

I'd like to be able to capture STDOUT as a string.  But nothing on perlfaq8 
struck me as relevant.  Did I miss something?  How do I do this?  I frequently 
get drastic errors (my computer shuts down!) when I try to use backticks.

Thanks,
Chris


 
-
 Get your own web address.
 Have a HUGE year through Yahoo! Small Business.___
Perl-Win32-Users mailing list
Perl-Win32-Users@listserv.ActiveState.com
To unsubscribe: http://listserv.ActiveState.com/mailman/mysubs


Re: Compiling Perl

2007-03-21 Thread Chris Wagner
At 05:34 PM 3/20/2007 -0400, Nelson R. Pardee wrote:
>In order to avoid installing Perl on a bunch of PC's, I'd like to compiler
>a couple of Perl programs. Any recommendations? I didn't see anything
>recently in the archives but I might have missed it. Thanks in advance.

I don't think the "actual compiler" works on Windows yet but u can use a
module to translate the Perl code into C code which u can then theoretically
compile with any good C compiler.  I tried it once and it didn't work
although I didn't try very hard and I gave up after a few hours.  Other
people seem to have gotten it to work.  The translation doesn't give u
editable C code but a horrid nasty opcode tree.  If u can get it to compile
I'ld love to hear how u did it.  I don't remember the module or the procedure.




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


Re: how to round a floating-point value to an integer value

2007-03-19 Thread Chris Wagner
At 08:39 AM 3/19/2007 -0500, [EMAIL PROTECTED] wrote:
>I have a recollection from a computer math class many years ago that you 
>should never, ever, round intermediate numbers in a calculation. The 
>"rounding" itself then becomes part of the next step, then the next, and 
>so on. While that may not be an issue with simple addition/subtraction, 
>multiplication (or worse, exponentiation), could turn a little rounding 
>into a huge error at the end.

Of course u should never round when u don't have to.  But at some point it
has to happen, whether u do it urself in some code or the arithmetic engine
does it on its floats.  Decimal to binary conversions are lossy and
computers can't hold infinite precision numbers.





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


Re: how to round a floating-point value to an integer value

2007-03-19 Thread Chris Wagner
At 04:34 AM 3/18/2007 +, [EMAIL PROTECTED] wrote:
>Do 'human rounding principles' say that you would expect 10 / 3 rounded
>to 2 DP would produce 3.34 or 3.33? How about -10 / 3?

10/3 rounded to two places is 3.33.  3.34 is simply wrong.  To say that 3.34
is 10/3 rouned to two places means that ur using another rounding scheme
that people don't use.  Same with -10/3.

>I assume that if you asked someone to calculate the digits of pi, you'd
>expect them to stop some time. How do 'human rounding principles' say
>they should deal with that.

There's no rounding involved when u stop a calculation.  If u calculate pi
to 100 digits and stop, the 100th digit has not been rounded.  If u wanted
to round that to 90 digits then that's rounding.  The criteria is pick the
value that has the least error from the actual value.

>My point was just that I can't think of a single practical case where
>you would be worried about whether 1.5 displayed as 1 or 2, and floating
>point numbers would have any place in your calculation. If your floating
>point answer is crud, then fiddling with it at the end of your
>calculation so it looks pretty just makes it cruddier.

Rounding to an integer is just the current example.  Rounding is usually
done to 2-3 places because that's all the precision most things need.  A
case where rounding makes a huge difference is in estimating.  If u round
wrong ur estimate will be no good.  Usually though rounding is just for
human convenience.





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


Re: subs, eval, and BEGIN

2007-03-19 Thread Chris Wagner
It actually does work in the BEGIN block too.  I feel ur pain.  Eval's can
be a total [EMAIL PROTECTED]

At 01:13 AM 3/19/2007 -0700, Glenn Linderman wrote:
>Why not?  tr said it compiled the strings at compile time, compile time 
>sounded like a begin block, but of course eval is also compile time.  It 
>was evolutionary, without quite enough thought at all points in time.  
>That wasn't the only bug




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


Re: subs, eval, and BEGIN

2007-03-18 Thread Chris Wagner
How come u were trying to put it in a begin block?

At 06:28 PM 3/18/2007 -0700, Glenn Linderman wrote:
>So I'm trying to make a sub to tr iso-8859-1 to unaccented ASCII 
>equivalents.  Maybe one already exists, somewhere, but now that I've 
>gotten this far, I'm confused:
>
>#!perl
>BEGIN {




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


Re: What to do when perl.exe bombs???

2007-03-18 Thread Chris Wagner
Sorry, I've got no clue.  I would file bug reports with Activestate and the
module authors and see what shakes out.




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


RE: how to round a floating-point value to an integer value

2007-03-17 Thread Chris Wagner
I decided to write my own rounding algorithm that takes it out of Perl's
hands and does all the math itself using strings.  Since it uses strings it
operates on the same literal value that a human would be looking at rather
than an opaque object.  Floats are better thought of as opaque objects than
numbers.  When u feed a float to the function Perl will stringify it first.

Here's the function.  It handles negative numbers and rounding to an
integer.  This rounding can be considered zero centered because an up round
moves the number away from zero and a down round moves the number toward
zero. It's not all encompassing though.  Asking it to round something like
-.00 will come back unpretty but still valid.  Canonicalizing everything to
a standard presentation will take some more code. The printf's are just
there for informational output.

sub sround {
my ($num, $digits) = @_;
my $neg;
printf "num $num %0.32f $digits\n", $num;
my ($int, $frac) = split /\./, $num;
return $num if length $frac <= $digits;
$neg = "-" and substr($int, 0, 1, "") if substr($int, 0, 1) eq "-";
## perform multiplication by 10^x
$int .= substr($frac, 0, 1, "") foreach (1 .. $digits);
## actually round the low digit
$int += 1 if substr($frac, 0, 1) >= 5;
printf "int %0.25s - frac %0.32s\n", ($int, $frac);
$frac = "";
## perform division by 10^x
substr($frac, 0, 0, substr($int, -1, 1, "")) foreach (1 .. $digits);
$frac = ".${frac}" if length $frac;
$neg = "" unless "${int}${frac}" =~ m/[1-9]/;
## build and return final rounded number
return "${neg}${int}${frac}";
}

I've tested it some and it handles everything %f dies on.
printf "$_ -> %.0f\n", $_ foreach (-.5, 0.5, 1.5, 2.5, 3.5, 4.5, 5.5, 6.5,
7.5, 8.5, 9.5);
print "$_ -> ", &sround($_, 0), "\n" foreach (-.45, -.5, 0.5, 1.5, 2.5, 3.5,
4.5, 5.5, 6.5, 7.5, 8.5, 9.5);
^D
-0.5 -> -0
0.5 -> 0
1.5 -> 2
2.5 -> 2
3.5 -> 4
4.5 -> 4
5.5 -> 6
6.5 -> 6
7.5 -> 8
8.5 -> 8
9.5 -> 10
-0.45 -> 0
-0.5 -> -1
0.5 -> 1
1.5 -> 2
2.5 -> 3
3.5 -> 4
4.5 -> 5
5.5 -> 6
6.5 -> 7
7.5 -> 8
8.5 -> 9
9.5 -> 10

D:\backups>perl \round.pl 3.4 0
posix::modf:
num 3.4 3.5000 0
int 3.0 - frac 0.5000
4
sround:
num 3.4 3.5000 0
int 3 - frac 4
3

QED



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


Re: how to round a floating-point value to an integer value

2007-03-17 Thread Chris Wagner
At 05:32 PM 3/17/2007 +, Mark Dootson wrote:
>If you are using floating point arithmetic, you want unbiased rounding,
>'even' if you don't realise that this is good for you.

That's all good for rounding intermediate numbers in a calculation but the
OP was trying to round for display.  In this case whatever rounding function
u use has to output a string consistent with human rounding principles.
Floating point numbers that a machine uses internally have no real relation
to the real numbers that humans use.  And the conversion is lossy.




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


RE: how to round a floating-point value to an integer value

2007-03-16 Thread Chris Wagner
At 12:48 AM 3/17/2007 -0500, [EMAIL PROTECTED] wrote:
>Incidentally, perl is a typeless language, compounding the problem even
more. That is, perl 
>converts a variable or literal to an integer, a floating point double, or
text string on-the-fly as 
>needed. A single line of perl code may hide several such conversions within
the perl core, 
>with each operation adding more onto the error until it becomes noticeable.

Which is probably the single biggest flaw in Perl.  It borders on the
Microsoft-esque in the things it does behind ur back trying to figure out
what it thinks u *want*.  And u had *better* want it mister!  Probably only
javascript has a worse arithmetic engine.





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


RE: how to round a floating-point value to an integer value

2007-03-16 Thread Chris Wagner
At 08:04 PM 3/16/2007 -0400, Su, Yu \(Eugene\) wrote:
>I expect 
>print sprintf("%.0f %.0f %.0f %.0f %.0f %.0f %.0f %.0f %.0f %.0f", 0.5,
1.5, 2.5, 3.5, 4.5, 5.5, 6.5, 7.5, 8.5, 9.5);
>will give me 
>1 2 3 4 5 6 7 8 9 10
>but instead I get 
>0 2 2 4 4 6 6 8 8 10
>How to round a floating-point value to an integer value using (.5) up rule?

Hmm, that's what I would expect too.  This even-favoring rounding strikes me
as a total crock.  I'm glad I haven't had to do anything so far that relies
on s/printf's %f format.  But I think I know what's happening.  First let me
quote O'Reilly which suggests ur expectation was correct.

***Discussion

Rounding can seriously affect some algorithms, so the rounding method used
should be specified precisely. In sensitive applications like financial
computations and thermonuclear missiles, prudent programmers will implement
their own rounding function instead of relying on the programming language's
built-in logic, or lack thereof.

Usually, though, we can just use sprintf. The f format lets you specify a
particular number of decimal places to round its argument to. Perl looks at
the following digit, rounds up if it is 5 or greater, and rounds down
otherwise. ***

Now if I change ur code to add a width argument it puts out the rounding we
would expect.
printf "$_ -> %1.0f\n", $_ foreach (0.5, 1.5, 2.5, 3.5, 4.5, 5.5, 6.5, 7.5,
8.5, 9.5);
^D
0.5 -> 1
1.5 -> 2
2.5 -> 3
3.5 -> 4
4.5 -> 5
5.5 -> 6
6.5 -> 7
7.5 -> 8
8.5 -> 9
9.5 -> 10

It even works with %0.0f as the format.  Omitting the "m" in the %m.nx
formula makes it blow up.  The output is padded to m characters in length.
The m is supposed to be optional so I'ld say this definately classifies as a
bug.  Even perldoc endorses the OP's usage:
# these examples are subject to system-specific variation
printf '<%f>', 1;# prints "<1.00>"
printf '<%.1f>', 1;  # prints "<1.0>"
printf '<%.0f>', 1;  # prints "<1>"


The problem is this: the presence or absence of the format width changes the
rounding algorithm for %f.  What is m defaulting to? undef?  I don't know
what Perl's internal handling of floats is but it seems that the f format is
eating a different number of bits with and without the m and rounding on
that, leading to the flip flop behavior.  I've been playing around with f
and b packs and unpacks and I can't see any logic to when it rounds up or
when it rounds down.

D:\backups>perl
printf "2.5 -> %.0f\n", 2.5;
printf "2.5 -> %0.0f\n", 2.5;
^D
2.5 -> 2
2.5 -> 3

The strangeness continues:
D:\backups>perl
printf "2.55 -> %.1f\n", 2.55;
printf "2.55 -> %0.1f\n", 2.55;
^D
2.55 -> 2.5
2.55 -> 2.5

I did some reading and it seems IEEE floats are just stupid when it comes to
"rounding".  This is not rounding.  Is there a way to display Perl's
internal binary representation of a float?

But as was already stated, %d is the right way to take an arbitrary number
to an integer.  Moral of the story: %f doesn't work.





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


RE: localtime failing on DST change

2007-03-13 Thread Chris O
On Tue, 13 Mar 2007, Bill Luebkert wrote:
> My 'localtime' function output doesn't reflect DST since the Sunday
> changeover.

Jan Wrote:
>This is expected if you have the TZ environment variable set because
>Microsoft didn't release an updated MSVCRT.dll.

Works fine for me on windows... but I'm having the same issue on Fedora. :-(

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


Re: Perl Load Times

2007-03-12 Thread Chris Wagner
At 06:34 PM 3/12/2007 -0400, Nelson R. Pardee wrote:
>If I haven't run any Perl programs in awhile, it takes a bit to start up.
>Subsequent executions startup pretty quickly. Is this possibly a caching
>of Perl itself by Windows? other? 2 Ghz processor, 1 G ram.

Ur exactly right.  Once u run Perl once, the files get stored in the system
cache.  The slowest part of the execution is physically reading the files
off the hard disk.  Once that's done, and it's in the cache, the program can
load pretty fast.






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


Re: How to generate file signatures?

2007-03-12 Thread Chris Wagner
Another caveat that I might as well throw out there is that checksums become
less reliable the larger the file size.  There are an infinite number of
files that correspond to each checksum value.  That applies to MD5, SHA,
Tigers, everything.  And for each size of file there is a large, though not
infinite, number of files that correspond to each checksum.  What ur hoping
for is that files u compare using checksums already share substantial
similarity.  So that if a few bytes are off, or even hundreds of thousands,
the fundamental similarity of the files will prevent the checksums from
being the same.  I know that sounds backwards but it's because checksums
rely on the random dissimilarity of files with the same checksum.  Like
files that digest to the same checksum will be wildly different and there's
no way they would be mistaken as the same file by a person.  For very large
files I would throw in a few more random comparisons of actual data from
various parts of the file. Obviously only for files of the same size.





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


Re: STDIN not available/@ARGV empty

2007-03-09 Thread Chris Wagner
It doesn't work for me either.  On my system it opens printargs.pl in
notepad. Editing is the default action under Explorer.  The shell shouldn't
care about Explorer's settings.  Now if I change the default action to Run,
it works as expected.  Better to use bash for these sorts of things. :)
D:\backups>assoc .pl
.pl=Perl

D:\backups>ftype Perl
Perl="C:\Perl\bin\perl.exe" "%1" %*

D:\backups>echo %pathext%
.pl;.COM;.EXE;.BAT;.CMD;.VBS;.VBE;.JS;.JSE;.WSF;.WSH

D:\backups>printargs a b c  ## opens in notepad
## Change default action to Run
D:\backups>printargs a b c
ARGS:
'a'
'b'
'c'

At 04:55 PM 3/9/2007 -0800, Bill Luebkert wrote:
>For some reason, that's never really worked for me :




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


Re: How to generate file signatures?

2007-03-09 Thread Chris Wagner
>Dennis Daupert wrote:
>> Hello list,
>> 
>> Now that management has moved us off Unix and onto windows
>> 
>> We develop software packages, and use a perl script to generate
>> checksum signatures to validate our packages.
>> 
>> On Solaris, we use cksum; on linux, md5sum.
>> 
>> What do people use on windows?

Here's what I do.  No reading in the entire file.  This method is also
portable to any platform.

my $fh = FileHandle->new();
if (! $fh->open("${dir}${file}")) {
warn "$0: $!\n";
next;
}
binmode($fh);
my $buffer;
my $bytesRead;
my $totalbytes = 0;
$md5 = Digest::MD5->new;
while ($bytesRead = $fh->read($buffer, 32768)) {
$md5->add("$buffer");
$totalbytes += $bytesRead;
# print "${totalbytes}\n"
}
print $md5->hexdigest;






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


Fill PDF Form Fields

2007-03-06 Thread Chris O
Anyone know how to fill in form fields on a PDF? I've looked at a few
modules on cpan & googled a bit, but can't seem to find anything .

Thanks,

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


Re: checking for infinite loops

2007-03-05 Thread Chris Wagner
At 04:01 PM 3/4/2007 -0800, Bill Luebkert wrote:
>What's the exact message ?  I added $^E in code below which may help.

Using this format to get the most recent Windows error message is good for
clarity's sake.  $^E is context sensitive while this form is unambiguous.

Win32::FormatMessage(Win32::GetLastError());





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


Re: checking for infinite loops

2007-03-04 Thread Chris Rodriguez
Hi all,
  Thanks very much to everyone for this list-serve, and  especially to Rob 
and Bill for helping me so much with this.  I'm basically using Bill's code 
(below) and  I have it doing what I want.  So yay,  mission accomplished, 
basically, but two peculiar glitches gum things up and  slow me down.  I'd like 
to ask about  those as it would be sweet to get around them.
  I have to repeatedly check a bunch of scripts for the  possibility 
they may have infinite loops.   I occasionally get an error message reading:
  Win32::Process::Create infinite2.pl : at Bills_code.pl: line  46.
  That refers to the line in the code that's similar to the  message 
itself.  Win32::Process… etc.
  What does this mean?   At first it seemed innocuous - the program kept 
running, though it  seemed to exit a loop early or something, not dealing with 
the remaining  scripts.  Now it sometimes shuts the  program down completely.  
What's going  on here?
  A second issue is that this all runs many thousand times  slower than 
it used to.  When I run  Bill's code on my 4 'infinite' scripts, the printout 
looks like so:
  Starting infinite1.pl
  Starting infinite2.pl
  Starting infinite3.pl
  Starting infinite4.pl
   
  Then the next several lines are printouts of $num and $diff  which appear 
once each second due to the sleep (1) line.  The first times I tried this, 
those first 4  lines appeared essentially instantaneously.   Now it takes a 
second or two for each line to appear.  The rest prints out at normal speed, so 
I  can locate the problem to that first part, which is either the subroutine or 
 the for loop in which it's located.  Not  a problem when doing 4 little test 
scripts like this, but when I have to do a  whole bunch it adds up and it's 
kind of a drag.  And once this happens, everything on my computer turns  
sluggish.  Try to say, close a window by  clicking the x in the upper 
right-hand corner - the window closes all right -  like 5 seconds later.
  Thanks all,
  Chris
  
Bill Luebkert <[EMAIL PROTECTED]> wrote:use strict;
use warnings;
use Win32::Process;

my $timeout = 10 * 1000; # timeout after 10 seconds

my @children = (); # you could make this a hash and store more than
   # the object (script name and pid for example)

for (1 .. 2) {  # start 2 children scripts
 my $obj = run_process ("infinite${_}.pl");
 push @children, $obj;
}

my $start = Win32::GetTickCount(); # start timer
while (1) { # check for children still running or timeout
 my $num = 0;
 for (my $ii = 0; $ii < @children; ++$ii) {
  next if $children[$ii] == 0;
  ++$num;
  my $res = $children[$ii]->Wait(200);
  $children[$ii] = 0 if $res == 1;
 }
 last if not $num; # none running if 0

 my $diff = Win32::GetTickCount() - $start;
 print "num=$num, diff=$diff\n";
 last if $diff > $timeout; # timeout after n seconds
 sleep 1;  # give up some CPU
}

print "kill remaining scripts if any\n";
foreach my $obj (@children) { # kill any scripts still running
 next if $obj == 0;
 my $pid = $obj->GetProcessID();
 my $exit = 0;
 Win32::Process::KillProcess($pid, $exit);
 print "kill $pid ($exit)\n";
}
exit 0;

sub run_process {
 my $script = shift;
print "Starting $script\n";
my $pobj;
Win32::Process::Create($pobj, 'C:\perl\bin\perl.exe', "perl $script", 0,
   DETACHED_PROCESS, '.') or die "Win32::Process::Create $script: $!";
return $pobj;
}
  

 
-
8:00? 8:25? 8:40?  Find a flick in no time
 with theYahoo! Search movie showtime shortcut.___
Perl-Win32-Users mailing list
Perl-Win32-Users@listserv.ActiveState.com
To unsubscribe: http://listserv.ActiveState.com/mailman/mysubs


Re: More efficient regex

2007-02-28 Thread Chris Wagner
I'm guessing that u want to cannocalize the capitalization of string words
right?  Like BOB JONES -> Bob Jones.  There is a faster way to check for
mixed casedness.

%tolowers = map {$_, 1} ('A', 'The', 'If', 'Is', 'It', 'Of', 'Our',
'An','On', 'In', 'But', 'With', 'Has', 'Had', 'Have');
%touppers = map {$_, 1} ('N','S','E','W','NE','NW','SE','SW','PO','BOX');
$uppers = $text =~ tr/A-Z/A-Z/; #count uppercase letters
$lowers = $text =~ tr/a-z/a-z/; #count lowercase letters

if ($uppers and not $lowers) { #all upper case
&fixcase($text);
}
elsif ($lowers and not $uppers) { #all lower case
&fixcase($text);
}

sub fixcase {
my $text = $_[0];
my @text = map {ucfirst(lc($_))} split / /, $text;
foreach $i (@text) { $tolowers{$i} and $i = lc $i; }
foreach $i (@text) { $touppers{uc $i} and $i = uc $i; }
$text = join " ", @text;
# do whatever else
return $text;
}

That should do it and be about as efficient as possible. :)  If u have to
deal with sentences then u'll need a few more lines to deal with periods and
commas.

These O'Reilly gems are useful too.
Finding all-caps words 
@capwords = m/(\b[^\Wa-z0-9_]+\b)/g;
Finding all-lowercase words 
@lowords = m/(\b[^\WA-Z0-9_]+\b)/g;
Finding initial-caps word 
@icwords = m/(\b[^\Wa-z0-9_][^\WA-Z0-9_]*\b)/;

At 12:12 PM 2/28/2007 -0500, Chris O wrote:
>In the sample below, I'm checking $foo for all caps or all lowercase. Is
>there a more efficient regex method?
>
>$foo='APPLE JONES PARKER';
>
>if(($foo!~/[A-Z]/)or($foo!~/[a-z]/)){
>   $foo=&title_case($foo);
>}
>
>print $foo."\n";
>
>sub title_case{
>  my($string) = @_;
>  my @exception_words = ('A', 'The', 'If', 'Is', 'It', 'Of', 'Our',
>'An','On', 'In', 'But', 'With', 'Has', 'Had', 'Have');
>  my @exception_stuff = ('N','S','E','W','NE','NW','SE','SW','PO','BOX');
>  
>  $string =~ s/([\w']+)/\u\L$1/g;
>  foreach(@exception_words){$string =~ s/\b$_\b/lc($_)/ge;} # Make Exception
>Words LC
>  foreach(@exception_stuff){$string =~ s/\b$_\b/$_/gei;} # Make Exception
>Stuff Correct Case
>  
>  $string =~ s/(.)/\u$1/; # Uppercase the first letter
>  return $string;
>}



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


  1   2   3   4   5   6   7   8   >