RE: Soundex - version confusion

2007-03-29 Thread Thomas, Mark - BLS CTR
> > Is there some reason that there seems to be no PPM for 
> Soundex 3.02 at 
 
> Hmm.  Guess no one knows the answer?  

Many years ago I asked a similar question, and the answer I got was that
the soundex algorithm has been superceded by superior ones, such as
metaphone. So I tried Text::Metaphone and indeed got far superior
results. Now there is a DoubleMetaphone which evidently improves upon
Metaphone:
http://search.cpan.org/~maurice/Text-DoubleMetaphone-0.07/DoubleMetaphon
e.pm

Both Text::Metaphone and Text::DoubleMetaphone exist in the AS PPM repo.

- Mark.

___
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-20 Thread Thomas, Mark - BLS CTR
> Remember when one state (Kansas, Nebraska, or Arkansas, I think it
was)
> wanted to declare pi = 3, which would've made all the wheels in the
> state turn square overnight?

This isn't quite true, but the truth is equally weird. It was a bill
with a method to square a circle, which is to find a square with the
same area as a given circle, using only a compass and a straightedge.
(Something proven to be impossible). The bill made several erroneous and
conflicting claims about the value of pi.

http://en.wikipedia.org/wiki/Indiana_Pi_Bill

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


RE: RTF to plaintext conversion

2007-02-20 Thread Thomas, Mark - BLS CTR
Howard Maher wrote:
> Does anyone know of a module or script that can be used to 
> convert a 'fully-editable RTF' file to plaintext?  I don't 
> need to edit RTF, but just convert it to an ASCII flat-text file.

You mean like this? 
http://search.cpan.org/~sargie/RTF-Parser-1.09/lib/RTF/TEXT/Converter.pm

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


IIS Virtual Directory password changes

2007-01-17 Thread Thomas, Mark - BLS CTR
We have an IIS configuration where there are many virtual directories
(150+) that point to a remote share. For each of them you have to
specify a password (in our case they are all the same). Where is this
information stored? Is there a way to make the password change en masse?
 
Also, we need to make the same password change to multiple IIS sites,
also pointing to the same remote share.
 
It's IIS 5.0 on Windows 2000 Server.
 
Thanks,
- Mark.
___
Perl-Win32-Users mailing list
Perl-Win32-Users@listserv.ActiveState.com
To unsubscribe: http://listserv.ActiveState.com/mailman/mysubs


RE: What do you do?

2006-11-07 Thread Thomas, Mark - BLS CTR

You can encrypt the passwords in a file, but keep in mind that anyone
that can access the code can retrieve the password. It's best to also
make sure that the user account only has permission to do what it needs,
and nothing else.

-- 
Mark Thomas 
Internet Systems Architect
___
BAE SYSTEMS Information Technology 
2525 Network Place
Herndon, VA  20171  USA 

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


RE: WWW::Mechanize problem

2006-09-27 Thread Thomas, Mark - BLS CTR
 


> I am having trouble submitting a form because it is using 
> an image to click on. 

I have another idea. Try this:

  $mech->set_fields( $name.x => 1, $name.y => 1 );

where $name is the name of the image. Then submit().
IIRC, this is what real browsers send with an input image.

- Mark.

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


RE: :Mechanize problem

2006-09-27 Thread Thomas, Mark - BLS CTR
David wrote:
> I am having trouble submitting a form because it is
> using an image to click on. 
...
> How do I submit/click on this image. 


Can't you just use Mech's submit() function?

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


RE: Flip-flop operator help

2006-07-14 Thread Thomas, Mark - BLS CTR
 Craig Cardimon wrote:
> I have something like this:
> 
> while ()
> {
>if (// .. /<\/TAG>/)
>{
># process line
>}
> }
> 
> I got this from http://www.perl.com/pub/a/2004/06/18/variables.html.
> 
> My special wrinkle is, I want to process certain sections of 
> a file, but only if that section passes certain criteria.
> 
> I want to be able to begin processing lines, but I want to be 
> able to turn processing off and jump to the next  should 
> the script encounter a line containing, say, the tag .

What kind of file are we talking about? XML? Can you give us a
representative sample? The more you know about the input, the better the
choices you can make w.r.t. parsing.

- Mark.

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


RE: XML Output to Web

2006-05-10 Thread Thomas, Mark - BLS CTR
If character escaping is your only problem, all you have to do is this:

use CGI qw/:all/;
print escapeHTML($xml);

-- 
Mark Thomas 
Internet Systems Architect
___
BAE SYSTEMS Information Technology 
2525 Network Place
Herndon, VA  20171  USA 


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


RE: Finding partly duplicated records

2006-05-08 Thread Thomas, Mark - BLS CTR
There are a couple of modules that may do what you want. Check out
these:

Hash::MultiKey
Data::MultiValuedHash
Tie::AliasHash

But if you know a modicum of SQL and want to store the data, you may
want to use SQLite. What you've described is a many-to-many relationship
between the machines and IPs. You'd have three tables, a machine table,
and IP table, and a pairing table that identifies each combination.

- Mark.
 

> -Original Message-
> From: [EMAIL PROTECTED] 
> [mailto:[EMAIL PROTECTED] On 
> Behalf Of King, Dan
> Sent: Monday, May 08, 2006 2:23 PM
> To: perl-win32-users@listserv.ActiveState.com
> Subject: Finding partly duplicated records
> 
> I am at my wits end on this question.  I feel like the answer 
> is probably simple but it has me beat.
> 
> 
> I have a list of machines and IP addresses.  The combination, 
> $machine and $IPAddress is never duplicated in the list.  However, 
> $IPAddress may be duplicated and $machine may be duplicated.  
> 
> For example:
> 
> m001ws 192.168.20.2
> m002ws 192.168.20.4
> m003ws 192.168.20.6
> m003ws 192.168.20.10
> m004ws 192.168.20.9
> m005ws 192.168.20.20
> m006ws 192.168.20.12
> m009ws 192.168.20.12
> 
> I want to find m003ws with its two IP addresses 
> m003ws 192.168.20.6
> m003ws 192.168.20.10
> 
> and 192.168.20.12 with its two machines.
> m006ws 192.168.20.12
> m009ws 192.168.20.12
> 
> I also have a longer record consisting of about 9 fields where I want 
> to know if there is a duplication within one of the fields.  
> For example
> 
> any time a userid appeared in more than one record.
> 
> I was thinking that these are basically the same problem but I can't 
> seem to find any examples on the web.  I would appreciate any help.  
> By the way, in the real problems I am looking at several thousand 
> 'records' and I need to run these reports once a day.
> 
> Dan
> 
> ___
> Perl-Win32-Users mailing list
> Perl-Win32-Users@listserv.ActiveState.com
> To unsubscribe: http://listserv.ActiveState.com/mailman/mysubs
> 
> 


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


RE: Performance of Data::Dump

2006-05-05 Thread Thomas, Mark - BLS CTR
> Are there modules faster than Data::Dump?

Interesting. I'd never heard of Data::Dump. I always use Data::Dumper.
Have you tried that? It uses XS code so it should be faster.

You can also try Storable.

- Mark.


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


RE: RE help

2006-05-05 Thread Thomas, Mark - BLS CTR
David Hsu wrote:
> I only want the name in last  tag and the   
> (i.e. Susan Miers President)

You may want to look into XPath. Here's a sample:

use XML::XPath;

my $xml = qq(
  
  John Smith,
  Susan  Miers
  President
  
);

my $x = XML::XPath->new(xml=>$xml);

my $name = $x->findvalue('normalize-space(//Name[position()=last()])');
my $title = $x->findvalue('//JobTitle');

print "$name $title\n"; #prints "Susan Miers President"

-- 
Mark Thomas 
Internet Systems Architect
___
BAE SYSTEMS Information Technology 
2525 Network Place
Herndon, VA  20171  USA 


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


RE: Replace Leading Spaces (fwd)

2006-04-13 Thread Thomas, Mark - BLS CTR
I realized that my previous post had the wrong comparison. Here's one
that's short and to the point:

  re1  => q($str = ' 259.00 '; $str =~ s/\s(?=\s*\S)/0/g;),
  re2  => q($str = ' 259.00 '; $str =~ s/ (?= *\d)/0/g;),

Benchmark: timing 100 iterations of re1, re2...
   re1:  3 wallclock secs ( 4.08 usr +  0.00 sys =  4.08 CPU) @
245218.24/s (n=100)
   re2:  4 wallclock secs ( 4.69 usr +  0.00 sys =  4.69 CPU) @
213310.58/s (n=100)

Rate  re2  re1
re2 213311/s   -- -13%
re1 245218/s  15%   --

Using a space is about 15% slower than using \s. Weird, huh?

- Mark.


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


RE: Replace Leading Spaces (fwd)

2006-04-11 Thread Thomas, Mark - BLS CTR
> I think I can explain it. When (5) sees the .*\d, the .* 
> grabs all the characters, then the RE engine backs up until 
> it "releases" a digit to match the \d. (1a), on the other 
> hand, just grabs spaces with \s*; it isn't allowed to grab 
> anything else.

That wasn't it... Surprisingly, replacing the space character with "\s"
made the difference(!)

re1  => q($str = ' 259.00 '; $str =~ s/\s(?=\s*\S)/0/g;),
re2  => q($str = ' 259.00 '; $str =~ s/ (?=.*\d)/0/g;),
re2b => q($str = ' 259.00 '; $str =~ s/\s(?=\s*\d)/0/g;),

 Rate  re2 re2b  re1
re2  183891/s   -- -23% -26%
re2b 239751/s  30%   --  -4%
re1  249066/s  35%   4%   --

Now, can someone explain *that*???

- Mark.


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


RE: Replace Leading Spaces (fwd)

2006-04-11 Thread Thomas, Mark - BLS CTR
$Bill Luebkert wrote:
>  Rate  RE2  RE5  RE3  RE4  RE1 RE1a
> RE2  136761/s   -- -58% -61% -64% -74% -74%
> RE5  326584/s 139%   --  -6% -14% -37% -37%
> RE3  347705/s 154%   6%   --  -9% -33% -33%
> RE4  381098/s 179%  17%  10%   -- -26% -26%
> RE1  516529/s 278%  58%  49%  36%   --  -0%
> RE1a 516529/s 278%  58%  49%  36%   0%   --
> 
> 1  $str =~ s/\s(?=\s*\S)/0/og;
> 1a $str =~ s/\s(?=\s*\S)/0/g;
> 2  1 while ($str =~ s/\s(?=(\d|\.))/0/);
> 3  $str =~ s/^(\s+)(?=\d)/'0' x (length $1)/e;
> 4  $str =~ s/^(\s+)/sprintf "%s", q[0]x length($1)/eg;
> 5  $str =~ s/ (?=.*\d)/0/g;

What surprises me is the substantial difference between the lookahead
expressions, RE1a and RE5. Can anyone explain why there's such a
difference?

- Mark.


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


RE: Replace Leading Spaces

2006-04-07 Thread Thomas, Mark - BLS CTR
> Using a regex, I want to replace each leading space-character 
> with a corresponding zero-character on a one-to-one basis. 
> For an example
> string:
> 
> My $string = ' 259.00 ';
> 
> Note that I don't want to change the trailing space 
> character. The resulting string would look like:
> 
> '0259.00 '

How about

s/ (?=.*\d)/0/g;

Translation: any space with a digit to its right gets replaced with a
zero.

-- 
Mark Thomas 
Internet Systems Architect
___
BAE SYSTEMS Information Technology 
2525 Network Place
Herndon, VA  20171  USA 


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


RE: Want to reduce the speed of execution in Perl script.

2006-04-06 Thread Thomas, Mark - BLS CTR
Yekhande, Seema (MLITS) wrote:
> Do you have any
> idea about why column_average function doesn't works when 
> multiple files
> Are passed using the for routine?
> ...
> sub column_average {
> my ($idx) = @_;
> my $sum = sum map {$_->[$idx] if defined $_->[$idx]} @data;
> return $sum;
> }

This doesn't return an average unless you divide by the number of
entries. If you don't want a null entry to count as a zero in the
average, you'll have to capture the number of defined fields in that
column, i.e.:

sub column_average {
my ($idx) = @_;
my @column = map {$_->[$idx] if defined $_->[$idx]} @data;
return sum(@column) / scalar(@column);
}

- Mark.


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


RE: Efficiency

2006-04-06 Thread Thomas, Mark - BLS CTR
>>   $last{substr($_,0,4)}=$_ for @myArray;
>>   print join "\n", sort values %last;
>
>   Whoops, one thing wrong with this ... since you don't 
> sort before creating your hash, if the order of the data was 
> such that the newer version appears earlier in the array, 
> your results are wrong.
> Anyway you can throw the sort into the first line?

Yep. Wasn't sure if the "overriding" was higher numbers or higher
indices. You can also remove the sort at the end. Here's the update:

$last{substr($_,0,4)}=$_ for sort @myArray;
print join "\n", values %last;

-- 
Mark Thomas 
Internet Systems Architect
___
BAE SYSTEMS Information Technology 
2525 Network Place
Herndon, VA  20171  USA 




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


RE: Efficiency

2006-04-05 Thread Thomas, Mark - BLS CTR
Bill Ng wrote:
> Okay,
> 
>   Here's what I've come up with:
> --
> @list = ("aacs1110", "brbt4332", "rtxa4320", "aacs2000", 
> "brig5621", "brbt5220", "nbvc");
> @list = sort @list;
> 
> foreach $item (@list) {
>   $itemPref = substr($item, 0, 4);
>   $itemVers = substr($item, 4);
> $h{$itemPref} = $itemVers; }
> 
> foreach $pref (keys %h) {
>   push (@finalList, $pref . $h{$pref}); }
> --
> 
> Okay ... 8 lines of code (not counting empty lines) ... 
> anyone got anything else?

Here's one:

  $last{substr($_,0,4)}=$_ for @myArray;
  print join "\n", sort values %last;

I'm sure we could reduce it to a one-liner with a modified Schwarzian
Transform...

- Mark.

-- 
Mark Thomas 
Internet Systems Architect
___
BAE SYSTEMS Information Technology 
2525 Network Place
Herndon, VA  20171  USA 



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


RE: Want to reduce the speed of execution in Perl script.

2006-04-05 Thread Thomas, Mark - BLS CTR
> Actually Regex is taking more time instead of agrep. That's 
> why the idea of using either agrep or find.
> This is small input.txt which I am using it as a input file.
> If there is any other way of increasing the speed of same 
> Perl script, it is really required.

This has a chance of being faster. It uses Text::CSV::Simple--a wrapper
around Text::CSV_XS, which does the parsing in C for speed. Also, it
doesn't need any regular expressions. I think it's simpler code, too.

#!/usr/bin/perl -w

use Text::CSV::Simple;
use List::Util qw(sum);

my $parser = Text::CSV::Simple->new({ sep_char => "\t"});
$parser->want_fields(5,6,7,8,9,10,11); #make total column index 0
my @data = $parser->read_file('input.txt');

printf "Average of 'total' column: %.02f\n", column_average(0);
printf "Average of 'step1' column: %.02f\n", column_average(1);
printf "Average of 'step2' column: %.02f\n", column_average(2);

sub column_average {
my ($idx) = @_;
my $sum = sum map {$_->[$idx] if defined $_->[$idx]} @data;
return $sum/scalar(@data);
}
__END__

You may be able to tweak even more speed out of it by using
Text::CSV::Simple's triggers to sum as you go instead of using
List::Util.

-- 
Mark Thomas 
Internet Systems Architect
___
BAE SYSTEMS Information Technology 
2525 Network Place
Herndon, VA  20171  USA 


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


RE: Pattern matching

2006-03-03 Thread Thomas, Mark - BLS CTR
> Thomas, Mark in
> <[EMAIL PROTECTED]>:
> > > From: Jim Hill [mailto:[EMAIL PROTECTED] 
> > > Thomas, Mark in 
> <[EMAIL PROTECTED]>:
> > > > Jim Hill wrote:
> > > > 
> > > > > | $ini{section}{match} = '$1 $2';
> > > > > ... however that just prints "$1 $2" as a literal string.
> > > > 
> > > > Hint: the above two lines of your post answer your own question.
> > 
> > Single quotes don't interpret variables. Double quotes do. 
> 
> Thanks but, afaict, there are no single quotes anywhere in the
> script I posted although I do understand how it might look that
> way. 

If the one line from your script I quoted above doesn't have single
quotes, I need to get my eyes checked.

- Mark.


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


RE: Pattern matching

2006-03-03 Thread Thomas, Mark - BLS CTR
Jim Hill wrote:
> | $ini{section}{match} = '$1 $2';

> ... however that just prints "$1 $2" as a literal string.

Hint: the above two lines of your post answer your own question.
:-)

- Mark.


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


RE: Tri-grams?

2006-02-22 Thread Thomas, Mark - BLS CTR
And here's the "abuse of a regex" version. I recommend $Bill's version
instead. :)

$_ = "hello how are you hello";
s/([^ ])(?=([^ ][^ ]))/$t{$1.$2}++/eg;

use Data::Dumper;
print Data::Dumper::Dumper(\%t); 

-- 
Mark Thomas 
Internet Systems Architect
___
BAE SYSTEMS Information Technology 
2525 Network Place
Herndon, VA  20171  USA 


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


RE: Yet another regex question

2006-01-17 Thread Thomas, Mark - BLS CTR
> I'd like to thank everybody who came up with suggestions.  
> One thing I 
> forgot to point out is that there are also people with 
> whitespace in their 
> *given* names, which seems to make things even more problematic 

I've updated my solution to accommodate that:

while () {
my @cols =
m/^(\d+)  #id1
  \s(\(\d+\)) #id2
  \s([\w ]+), #lastnames
  \s([^\d]+)  #first name
  \s([\d\.]+) #data1
  \s([\d\.]+) #data2
  \s([\d\.]+) #data3
  \s([\d\.]+) #data4
  \s(\w+) #country code
  \s([\d\.]+) #data5
/x;
printf "%s\n", join "\t", @cols;

}

__DATA__
1 (1) DAVENPORT, LINDSAY 3380.00 16 .00 49.00 USA .00
2 (2) CLIJSTERS, KIM 3206.00 17 .00 .00 BEL .00
28 (28) MOLIK, ALICIA 671.00 15 .00 195.00 AUS .00
29 (33) MEDINA GARRIGUES, ANABEL 660.75 27 30.00 10.00 ESP 2.00
30 (35) KOUKALOVA, KLARA 660.75 23 16.00 20.00 CZE 2.00
77 (84) MONTOYA, INIGO CONQUISTADOR 100.22 23 16.00 20.00 ESP 2.00


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


RE: Yet another regex question

2006-01-12 Thread Thomas, Mark - BLS CTR
 
> I'm fairly good at using regexes to find things, but using them to  
> *replace* things is something I find quite difficult.  I have 
> a text file with lines like this:
> 
> 
> 
> 1 (1) DAVENPORT, LINDSAY 3380.00 16 .00 49.00 USA .00
> 2 (2) CLIJSTERS, KIM 3206.00 17 .00 .00 BEL .00
> [...]
> 28 (28) MOLIK, ALICIA 671.00 15 .00 195.00 AUS .00
> 29 (33) MEDINA GARRIGUES, ANABEL 660.75 27 30.00 10.00 ESP 2.00
> 30 (35) KOUKALOVA, KLARA 660.75 23 16.00 20.00 CZE 2.00
> 
> 
> 
> that I want to turn into a tab-delimited file.  

Well, you haven't let us know what the output is supposed to look like,
but try this for starters:

while () {
my @cols =
m/^(\d+)  #id1
  \s(\(\d+\)) #id2
  \s([\w ]+), #lastnames
  \s(\w+) #first name
  \s([\d\.]+) #data1
  \s([\d\.]+) #data2
  \s([\d\.]+) #data3
  \s([\d\.]+) #data4
  \s(\w+) #country code
  \s([\d\.]+) #data5
/x;
printf "%s\n", join "\t", @cols;
}

__DATA__
1 (1) DAVENPORT, LINDSAY 3380.00 16 .00 49.00 USA .00
2 (2) CLIJSTERS, KIM 3206.00 17 .00 .00 BEL .00
28 (28) MOLIK, ALICIA 671.00 15 .00 195.00 AUS .00
29 (33) MEDINA GARRIGUES, ANABEL 660.75 27 30.00 10.00 ESP 2.00
30 (35) KOUKALOVA, KLARA 660.75 23 16.00 20.00 CZE 2.00


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


RE: need Win32::AdminMisc

2006-01-03 Thread Thomas, Mark - BLS CTR
Craig A Dayton wrote:
Yes, try http://cpan.uwinnipeg.ca/
 
I was impressed with it and be sure to try Par::Webstart.
Randy Kobes has done a good job.
 
-Craig


Huh? That looks like a normal CPAN mirror, and like I said, the module
doesn't exist in CPAN. If it's a roth.net mirror, I don't see it. 

- Mark.


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


need Win32::AdminMisc

2005-12-28 Thread Thomas, Mark - BLS CTR



I'm in need of 
Win32::AdminMisc and roth.net has been down for several days. Why this module 
has never been in CPAN and/or the AS ppd list is a mystery to 
me.
 
Does anyone know 
of a mirror? Or has a cached/downloaded ppm file?
 
Thanks,
- 
Mark.
___
Perl-Win32-Users mailing list
Perl-Win32-Users@listserv.ActiveState.com
To unsubscribe: http://listserv.ActiveState.com/mailman/mysubs


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

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

Just an FYI... We use IndigoSTAR's Perl2Exe Pro and it does exactly
that. If you compile with the -small option it separates perl from your
app into a shared DLL. There's even a tiny option which creates separate
DLLs for used modules. If you distribute many apps to the same systems,
this can save you quite a bit of space.


-- 
Mark Thomas 


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


RE: Recursive classes

2005-12-08 Thread Thomas, Mark - BLS CTR
DZ-Jay wrote:
> The above seems to work exactly as I expected.  However, being new to 
> OOP in Perl (but not to OOP or Perl in general!) I wonder if this is 
> actually the proper way to do it, or if there are some sort of 
> side-effects that I am not aware of -- or worse -- that the 
> fact that it works at all is a side-effect in itself!

Your code looks fine.

Depending on what you're trying to do, you may also want to look at
Tree::Simple, which is a wonderful module that is powerful yet easy to
use, and it is also well-written and documented. It's one of my favorite
modules. You can attach any object or data to the "nodes," and there are
methods to traverse, search, get properties of (i.e. depth, width), and
output the tree in multiple ways (even a cool expanding/collapsing DHTML
tree).

- Mark.

-- 
Mark Thomas 
Internet Systems Architect
___
BAE SYSTEMS Information Technology 
2525 Network Place
Herndon, VA  20171  USA 


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


RE: Checking for internet connection

2005-11-02 Thread Thomas, Mark - BLS CTR
Michael D. Smith wrote:
> Is there a right way/best way to check for an internet connection?

A strategy I use:

Have a list of IPs to check, as high-availability as possible. Set a
relatively low timeout for LWP. Loop through the IPs, checking each, and
repeating the loop at least once. If you don't get a connection after that,
you can be pretty certain there's something down between you and your
destination.

Oh, and use HEAD instead of GET, as it results in smaller, quicker
responses.

This gives you a more thorough check and often takes no longer than a single
fetch via LWP with the default timeout.

- Mark. 


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


RE: spidering/crawling/scraping a site..

2005-10-28 Thread Thomas, Mark - BLS CTR
bruce [mailto:[EMAIL PROTECTED] wrote:
> mark...
> 
> i'm actually faced with a greater issue. i'm looking to
> crawl/extract/download the site. simply scraping each site 
> doesn't get me
> the underlying files for the site, in the correct location/names on my
> server, to allow me to kind of replicate the basic links of the site.

Aside from the questionable legality of what you're asking, keep in mind
that sites using database-backed form-based authentication (as opposed to
HTTP Basic Authentication) are often generated via assembly from includes or
CMSes or other applications, in which case trying to get the "underlying
files" is futile. They may not exist as discrete files on the server.

> this requires a crawler... which is what i was originally 
> looking for/hoping
> for, that allows me to deal with the login (user/passwd) form.

I have given you the information you need to do this. Simply save the files
locally as you crawl them.

- Mark.

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


RE: spidering/crawling/scraping a site..

2005-10-28 Thread Thomas, Mark - BLS CTR
Bruce,

Hehe... Gotta hand it to ya, you posted code this time :)

Here's what's going on. WWW::CheckSite::Spider is using the Mech class you
specify. You specified a class by the name of BA_Mech. So what you have to
do in your BA_Mech class is provide the information you need to log in. Make
BA_Mech a subclass of WWW::Mechanize and override the method(s) you would
need to change. In the case of the standard HTTP server-based Basic
Authentication, you would only need to provide a get_basic_credentials
method with your username and password. But in your case, you'd probably
need to override new() to call SUPER::new then perform the form-based login
before returning the Mech object's handle.

If you're not familiar with OO and subclassing, you will probably find it
easier to use my second suggestion, which was to perform
$mech->extract_links on each page and put the links in an array or hash to
keep track of which ones you still need to follow. Then you follow them
until you're done.

If the result of all this is to mirror pages and /then/ scrape, you're
making it too complicated. Skip the mirroring, and scrape as you fetch.

- Mark.



> -Original Message-
> From: bruce [mailto:[EMAIL PROTECTED] 
> Sent: Thursday, October 27, 2005 5:04 PM
> To: Thomas, Mark - BLS CTR; 'perl-win32-users mailing list'
> Subject: RE: spidering/crawling/scraping a site..
> 
> hi...
> 
> decided to try to use the www::checksite::spider to try to 
> create/write a
> quick spider for the http://jobboardsoftware.biz/demo/admin/login.apsx
> site...
> 
> i blew it!!!
> 
> the following code gives me some sort of hash, but i'm pretty 
> sure i haven't
> correctly filled in the login (user/passwd) form correctly...
> 
> any thoughts??
> 
> i'm not exactly sure what the BA_Mech is doing, or why it 
> might be needed. i
> tried to do the form submit directly from the spider, but the 
> perl code
> threw an error..
> 
> so, basically, i'm guessing!!!
> 
> 
> package BA_Mech;
> use base 'WWW::Mechanize';
> 
> $mech = WWW::Mechanize->new();
> my $start1 = "http://jobboardsoftware.biz/demo/admin/login.aspx";;
> $mech->get($start1);
> $mech->submit_form(
>form_name => 'Form1',
>button=> 'Button1',
>fields => {
>username => 'demo',
>password => 'demo'
>  }
>);
> 
> 
> package Main;
> use WWW::CheckSite::Spider;
> 
> my $start = "http://jobboardsoftware.biz/demo/admin/login.aspx";;
> 
> my $sp = WWW::CheckSite::Spider->new(
> ua_class => 'BA_Mech',
> uri => $start,
> );
> 
> while (my $page = $sp->get_page)
> {
> print $page;
> print "\n";
> }
> die;
> 
> -bruce
> 
> 
> 
> 
> -Original Message-
> From: Thomas, Mark - BLS CTR [mailto:[EMAIL PROTECTED]
> Sent: Thursday, October 27, 2005 10:34 AM
> To: '[EMAIL PROTECTED]'
> Subject: RE: spidering/crawling/scraping a site..
> 
> 
> OK, there's a difference between using standard HTTP 
> authentication (the
> browser dialog box) and form-based authentication (which every site
> implements differently). If it is the former, most mirroring 
> tools can do it
> already. But if authentication is done through the web app like your
> example, you'll have to use Mech.
> 
> - Mark.
> 
> > -Original Message-
> > From: bruce [mailto:[EMAIL PROTECTED]
> > Sent: Thursday, October 27, 2005 1:22 PM
> > To: Thomas, Mark - BLS CTR
> > Subject: RE: spidering/crawling/scraping a site..
> >
> > thanks!!!
> >
> > i would have thought that there would have been a bunch of
> > little/big apps
> > that were used to parse user/passwd protected login fom sites...
> >
> > guess i was wrong..
> >
> >
> > but this isn't for some evil/take over the world project.
> > i've got a few
> > sites that i'm looking at, that are passwd/login protected.
> > rather than
> > loign to the sites, i thought i'd scrape them, and then compare them
> > locally, when i wanted. which is why i was saying i didn't
> > think this was
> > going to be more than a few minutes
> >
> > -bruce
> >
> >
> > -Original Message-
> > From: Thomas, Mark - BLS CTR [mailto:[EMAIL PROTECTED]
> > Sent: Thursday, October 27, 2005 9:51 AM
> > To: '[EMAIL PROTECTED]'
> > Subject: RE: spidering/crawling/scraping a site..
> >
> >
> > O

RE: spidering/crawling/scraping a site..

2005-10-27 Thread Thomas, Mark - BLS CTR
Bruce,

WWW::Mechanize should have no problem with that site. I'd start there. Let
us know if you have any problems doing it. 

- Mark.

-- 
Mark Thomas 
Internet Systems Architect
___
BAE SYSTEMS Information Technology 
2525 Network Place
Herndon, VA  20171  USA 


> the site is http://jobboardsoftware.biz/demo/admin/ with the 
> user/passwd of
> demo/demo.
> 
> any thoughts/ideas as to how i need to approach this?
> 
> if you can point me to a quick/dirty app that i can use to get the
> information, i'd appreciate it..

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


RE: Cross platform issues

2005-10-06 Thread Thomas, Mark - BLS CTR
I wrote:
> $Bill Luebkert wrote:
> > $windoze = 1 if $^O eq 'MSWin32';
> 
> Is this going to break on 64-bit Windows? Just curious. Maybe 
> we should all start using
> 
> $windoze = 1 if index($^O, 'MSWin');

Oops! Index will return 0 in this case. You could use:

  $windoze = !index($^O, 'MSWin');

although that seems a little counter-intuitive. Another option:

  $windoze = $^O =~ /^MSWin/;

- Mark.

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


RE: Cross platform issues

2005-10-06 Thread Thomas, Mark - BLS CTR
$Bill Luebkert wrote:
>   $windoze = 1 if $^O eq 'MSWin32';

Is this going to break on 64-bit Windows? Just curious. Maybe we should all
start using

$windoze = 1 if index($^O, 'MSWin');

- Mark.

-- 
Mark Thomas 
Internet Systems Architect
___
BAE SYSTEMS Information Technology 
2525 Network Place
Herndon, VA  20171  USA 

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


RE: Writing Control Codes to a file?

2005-09-23 Thread Thomas, Mark - BLS CTR



Think about it this way:
 
There is only one value of zero. Representing it as hex does not change 
the value. When the zero is stringified, it is converted to ASCII 30. To get a 
specific ASCII character, use chr(). So what you want is the ASCII NUL which is 
chr(0).
 
- Mark.

  
  
  From: 
  [EMAIL PROTECTED] 
  [mailto:[EMAIL PROTECTED] On Behalf Of 
  Warner, William ASent: Friday, September 23, 2005 8:38 
  AMTo: Perl-Win32-Users@listserv.ActiveState.comSubject: 
  Writing Control Codes to a file?
  
  
  When I write to a file, most 
  everything goes in as 30 or greater. For instance, this 
code:
   
  binmode OUT_FILE;
     
  syswrite OUT_FILE, 0x0;
   
  Puts a 30 in the DOS debug 
  screen’s left pane and puts a 0 in the DOS debug’s right screen. 
  
   
  I understand that an ascii zero is 
  represented by a hex 30, but I expected that outputting a hex value of 0 would 
  give me a hex value into the file, but instead it gives an ascii 0 value in 
  the file. 
   
  I can put one value of less than 
  30 in the file. I can put a space in the file which is hex 20 with this 
  code:
   
  binmode OUT_FILE;
     
  syswrite OUT_FILE, “ “;
   
  since a space is represented by 
  hex 20. How do I put the other 29 values below 30 into a 
  file?
   
  Thanks!
   
  Bill 
  Warner*** 
  The information contained in this message may be privileged and/or 
  confidential and protected from disclosure. If the reader of this message is 
  not the intended recipient, or an employee or agent responsible for delivering 
  this message to the intended recipient, you are hereby notified that any 
  dissemination, distribution or copying of this communication is strictly 
  prohibited. Note that any views or opinions presented in this message are 
  solely those of the author and do not necessarily represent those of Ameren. 
  All emails are subject to monitoring and archival. Finally, the recipient 
  should check this message and any attachments for the presence of viruses. 
  Ameren accepts no liability for any damage caused by any virus transmitted by 
  this email. If you have received this in error, please notify the sender 
  immediately by replying to the message and deleting the material from any 
  computer. Ameren Corporation *** 

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


RE: regex expression to determine if i have a valid email!!

2005-09-16 Thread Thomas, Mark - BLS CTR
Sure. For extra coolness, you could do this via Ajax so that it is validated
on the fly while the user is still filling out the form. 

- Mark.

> -Original Message-
> From: bruce [mailto:[EMAIL PROTECTED] 
> Sent: Friday, September 16, 2005 11:21 AM
> To: Thomas, Mark - BLS CTR; 'perl-win32-users'
> Subject: RE: regex expression to determine if i have a valid email!!
> 
> so mark...
> 
> what you're saying is that i should write a simple perl app 
> that does the
> email validation, and call it from the php app, passing it 
> the email address
> to check
> 
> -bruce
> 
> 
> 
> -Original Message-
> From: [EMAIL PROTECTED]
> [mailto:[EMAIL PROTECTED] Behalf Of
> Thomas, Mark - BLS CTR
> Sent: Friday, September 16, 2005 5:49 AM
> To: '[EMAIL PROTECTED]'; 'perl-win32-users'
> Subject: RE: regex expression to determine if i have a valid email!!
> 
> 
> > i've got a php app
> 
> Say it isn't so! :)
> 
> > i finally figured that someone here, might have the exact
> > soln to my prob!
> 
> 1. Make sure it is formatted correctly, as per RFC 822. To do 
> that, there is
> one big scary regex created by Jeffrey Friedl (author of 
> Mastering Regular
> Expressions). If you check the link that $Bill gave you to 
> Email::Valid, the
> regular expression is in there.
> 
> 2. Make sure the domain is valid, and resolves to an IP address
> 
> 3. Make sure an MX record is defined for the domain, and the 
> mail host is
> accessible.
> 
> 4. (Optional) Check the ip against selected blacklist(s).
> 
> Of course, the easiest way to do this is Perl. Email::Valid 
> does 1-3 for
> you.
> 
> - Mark.
> 
> ___
> Perl-Win32-Users mailing list
> Perl-Win32-Users@listserv.ActiveState.com
> To unsubscribe: http://listserv.ActiveState.com/mailman/mysubs
> 
> 

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


RE: regex expression to determine if i have a valid email!!

2005-09-16 Thread Thomas, Mark - BLS CTR
> i've got a php app

Say it isn't so! :)

> i finally figured that someone here, might have the exact 
> soln to my prob!

1. Make sure it is formatted correctly, as per RFC 822. To do that, there is
one big scary regex created by Jeffrey Friedl (author of Mastering Regular
Expressions). If you check the link that $Bill gave you to Email::Valid, the
regular expression is in there.

2. Make sure the domain is valid, and resolves to an IP address

3. Make sure an MX record is defined for the domain, and the mail host is
accessible.

4. (Optional) Check the ip against selected blacklist(s).

Of course, the easiest way to do this is Perl. Email::Valid does 1-3 for
you.

- Mark.

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


RE: HTML::TokeParser and tags split between lines

2005-09-06 Thread Thomas, Mark - BLS CTR
> I can't pass in the entire file. Some of the 
> files are 60 MB and larger. My machine freezes
> and crashes if I do that.

60MB HTML files? How are those being created? Sounds like you may want to
re-think the process.

HTML::Parser can parse a document in chunks; you may be able to take
advantage of that. Can you make the files XML? Then you can use XML::Twig,
which doesn't keep the entire file in memory.

- Mark

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


RE: HTML::TokeParser and tags split between lines

2005-09-06 Thread Thomas, Mark - BLS CTR
> I'm using HTML::TokeParser to remove HTML. This functions 
> very well when tags are contained on one line.

I used to use TokeParser although now I prefer parsing HTML with XPath.
TokeParser is a stream parser--there aren't any problem with newlines.

> What happens when you're reading a file line by line, and the 
> HTML tag is split between lines? 

Don't do that.

> The HTML I'm dealing with is sometimes broken 
> up. For instance, I'll get lines beginning with "size=2>" 
> which is the 
> end of a tag that began on the previous line.
> 
> Any suggestions or recommendation on cleaning up -- as in removing -- 
> this kind of "broken" HTML?

It's not broken. The spec allows whitespace including newlines in the tags.
The proper way to parse HTML is with a specialized parser. 

-- 
Mark Thomas 
Internet Systems Architect
___
BAE SYSTEMS Information Technology 
2525 Network Place
Herndon, VA  20171  USA 

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


RE: File::Find limit to current directory

2005-08-31 Thread Thomas, Mark - BLS CTR
Darrell Snedecor wrote:
> How can I keep file::find from descending into subfolders of
> $DataFolders_Location?  I can't get prune to work.
...
>   find(\&DelMiscFiles, $DataFolders_Location  );

Why not use readdir()? 

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


RE: RegEx

2005-08-29 Thread Thomas, Mark - BLS CTR
> >Problem
> >
> >If the string does not contain a trailing \ then add one.
> 
> $string .= "\\" unless $string =~ /\\$/;
> or, if you prefer,
> $string .= "\\" if $string !~ /\\$/;

Or

$string =~ s{\\?$}{\\};

-- 
Mark Thomas 
Internet Systems Architect
___
BAE SYSTEMS Information Technology 
2525 Network Place
Herndon, VA  20171  USA 

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


RE: Issue with POST

2005-08-23 Thread Thomas, Mark - BLS CTR
Jim,

When you're using forms-based authentication rather than basic
authentication, it's generally easier to use Mechanize. Mechanize handles
cookies automatically.

  use WWW::Mechanize;
  my $mech = WWW::Mechanize->new();
  $mech->get($url);
  $mech->submit_form(
  fields => {
 UserName => 'XXX',
 PassWord => 'XXX',
}
  );
  print $mech->content();

--
Mark.

--Original Message---

I have some issues with POST 
I need to create spider for this URL.

http://www.governmentsecurity.org/forum/index.php?act=Login&CODE=00
Get is OK and I'm getting the loggin page
I did POST but I'm not logged in. 
Probably I'm not using cookies the correct way.
Thanks for help.

-Jim-

 

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


RE: amazon web services/api...

2005-08-08 Thread Thomas, Mark - BLS CTR
Oops. That didn't exactly answer your question, because it doesn't use the
services API. I didn't see a search by isbn method in Net::Amazon though...
You may want to try it anyway; if it's not there it would certainly be a
glaring omission.

- Mark. 

> -Original Message-----
> From: Thomas, Mark - BLS CTR 
> Sent: Monday, August 08, 2005 10:14 AM
> To: '[EMAIL PROTECTED]'; 
> perl-win32-users@listserv.activestate.com
> Subject: RE: amazon web services/api...
> 
> Try this? (untested, minimally edited paste from the module docs)
> 
> use WWW::Scraper::ISBN::Amazon_Driver;
> $driver = WWW::Scraper::ISBN::Amazon_Driver->new();
> $driver->verbosity(1);
> $driver->search($isbn);
> if ($driver->found) {
> my $book = $driver->book();
> print $book('title');
> } else {
> print $driver->error;
> }
> 
> - Mark.
> 

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


RE: amazon web services/api...

2005-08-08 Thread Thomas, Mark - BLS CTR
Try this? (untested, minimally edited paste from the module docs)

use WWW::Scraper::ISBN::Amazon_Driver;
$driver = WWW::Scraper::ISBN::Amazon_Driver->new();
$driver->verbosity(1);
$driver->search($isbn);
if ($driver->found) {
my $book = $driver->book();
print $book('title');
} else {
print $driver->error;
}

- Mark.

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


RE: Win32:OLE Excel

2005-08-05 Thread Thomas, Mark - BLS CTR
 
> Then delete all the sheets that start with "sheet"
> 
> $SheetTabName  = $Book-> Worksheets($_)->{Name};
> foreach ( 1...$SheetCnt)
> {
> $SheetTabName  = $Book-> Worksheets($_)->{Name};
> if  ( $SheetTabName =~ /^sheet/i )
> {
> $Book->Worksheets("$SheetTabName")->Delete;
> }
> }
> 

Or just

$Book->Worksheets("Sheet $_")->Delete for 1..3;

--
Mark.

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


RE: perl script to parse amazon!!

2005-08-03 Thread Thomas, Mark - BLS CTR
Bruce,

Search.cpan.org is your friend...
http://search.cpan.org/search?query=amazon 

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


RE: Change in "goto" behavior

2005-07-13 Thread Thomas, Mark - BLS CTR
John Deighan wrote:

> We have a goto in our code. I hate it, but there just isn't a good
"switch" or "case" statement in Perl yet

Yes there is, in Perl 5.8. If you're using an older Perl, you can still get
Switch.pm from CPAN.

use Switch;

switch ($val) {
case 1  { print "number 1" }
case "a"{ print "string a" }
case [1..10,42] { print "number in list" }
case (@array)   { print "number in list" }
case /\w+/  { print "pattern" }
case qr/\w+/{ print "pattern" }
case (%hash){ print "entry in hash" }
case (\%hash)   { print "entry in hash" }
case (\&sub){ print "arg to subroutine" }
else{ print "previous case not true" }
}

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


RE: Why is this a problem?

2005-07-01 Thread Thomas, Mark - BLS CTR
Hugh Loebner wrote:
> foreach my $fhkey ( keys %fh){
> open  ( $fh{$fhkey}, ">$fhkey" )  ;
> }

Nobody mentioned this yet: Since you want your filehandles to be unique, why
not use the key of the hash instead of the value? In other words, change the
above to:

foreach my $fhkey ( keys %fh){
open  ( $fhkey, ">$fhkey" )  ;
}

- Mark.


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


RE: Test if string is a number?

2005-06-30 Thread Thomas, Mark - BLS CTR
 
[EMAIL PROTECTED] wrote:
> 0.00 is not a valid internal representation of a number.  
> That can only exist as a string. 

I think "u" need to re-read the subject of this thread.

- Mark.

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


RE: Test if string is a number?

2005-06-30 Thread Thomas, Mark - BLS CTR
> Wow there's been a lot of heavy duty code proposed to do something so
> simple.  The answer is in how Perl converts between the two.
> 
> print "is a number" if $var eq $var + 0;
> print "not a number" if $var ne $var + 0;

That fails on 1e7.

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


RE: Net::Telnet

2005-06-02 Thread Thomas, Mark - BLS CTR
John wrote:
> its does not work on these servers:
> Windows 2000 Pro,
> Windows XP pro,
> Windows 2000 server pro,
> Windows server 2003.
> 
> Reason is, the new windows server uses ANSI codes and you CAN'T turn
> them off like on a UNIX box. These ANSI codes garble up the 
> responses to Net::Telnet.

I'd put it this way: The telnet server in these versions of Windows is
broken. It doesn't follow the RFCs. To make telnet work, use an alternate
telnet server, e.g. http://kpym.sourceforge.net/

-- 
Mark

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


RE: Net::Telnet

2005-06-01 Thread Thomas, Mark - BLS CTR
When Net::Telnet doesn't do what you expect, 99% of the time it's a prompt
issue. Did you set the prompt? The default prompt works with the unix
command line, but you'll have to set it to work with your application.

I highly recommend using the debugging options; they can help you figure out
problems like these. 

-- 
Mark Thomas 
Internet Systems Architect
___
BAE SYSTEMS Information Technology 
2525 Network Place
Herndon, VA  20171  USA 



> -Original Message-
> From: [EMAIL PROTECTED] 
> [mailto:[EMAIL PROTECTED] On 
> Behalf Of Rajesh Vattem
> Sent: Wednesday, June 01, 2005 9:37 AM
> To: perl-win32-users@listserv.ActiveState.com
> Subject: Net::Telnet
> 
> 
> Hi,
>  I am using this module (Net::Telnet) downloaded from CPAN, 
> for a small
> interactive program in which I telnet to a particular host, 
> login and give
> some commands (based on the options you get). I am not able 
> to do this. I am
> able to login but whatever I do after that doesn't seem to happen. Can
> someone suggest what might be going wrong!!!
> 
> After login, the control console shows
> 
> --- Control Console
> ---
> 
>  1- Device Manager
>  2- Network
>  3- System
>  4- Logout
> 
>  - Main Menu, - Refresh, - Event Log
> >
> 
> Please let me know your inputs.
>   <> 
> Thanks & Regards,
> Rajesh.
> 
> 
> 
> **
> The information contained in this email and any attachments
> is likely to be confidential and legally privileged, and is for the
> intended recipient named above only. Any copying, 
> dissemination, disclosure of or use of this email or its 
> attachments unless authorised by us is prohibited, except 
> that you may forward this email and/or attachments to a third 
> party on a strict "need to know" basis. 
> 
> If you have received this email in error, please notify us 
> immediately by replying to the email or by calling 
> +91-80-22297030. Please then delete this email and any full
> or partial copies of it.
> 
> You as the intended recipient must be aware and accept 
> that emailis not a totally secure communications medium.
> 
> Although we have taken all reasonable steps to make 
> sure this email and any attachments are free from viruses, 
> we do not (to the extent permitted by law) accept any liability 
> whatsoever for any virus infection and/or compromise of 
> security caused by this email and any attachment.
> 
> No contract may be formed or documents served by you 
> on or with us by this email or any attachments unless 
> expressly agreed otherwise by us. 
> 
> Any views expressed in this email or attachments by 
> an individual are not necessarily those of UbiNetics 
> India (Private) Limited.
> 
> **
> 
> 

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


RE: Perl code works on Linux, not PRO XP

2005-05-12 Thread Thomas, Mark - BLS CTR
>   The code attached works fine on Linux, but not Windows XP

I don't see how it can, with the Windows batch syntax embedded in there.

 
 
>   C:\testsocket>rod.pl
>
>   As you can see above, the script ran the first time but it
>   didn't run afterwards nor did it produce an error.

You only showed it being invoked once.

Your problem seems to be with the looping construct you're using:

>   system("$program");

is not a proper way to loop. At the very least, change it to

exec $0;

but consider putting in a real loop.

- Mark.

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


RE: Store hash in SQL - Data::Dumper

2005-05-03 Thread Thomas, Mark - BLS CTR

> YAML doesn't support nested hashes. I wish it did.

Yes it does. It supports ANY ARBITRARY perl data structure. I use it
exclusively now instead of Data::Dumper.

-- 
Mark Thomas 
Internet Systems Architect
___
BAE SYSTEMS Information Technology 
2525 Network Place
Herndon, VA  20171  USA 

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


RE: Store hash in SQL

2005-05-02 Thread Thomas, Mark - BLS CTR
YAML should work.
http://search.cpan.org/dist/YAML/
 

> -Original Message-
> From: [EMAIL PROTECTED] 
> [mailto:[EMAIL PROTECTED] On 
> Behalf Of Chris
> Sent: Monday, May 02, 2005 10:31 AM
> To: perl-win32-users
> Subject: Store hash in SQL
> 
> All,
> 
> I'm looking for a way to store a large hash within an SQL 
> field and recall it at a later time. I can't seem to find any 
> modules that will convert hashes to text and back again, but 
> have found plenty of XML modules that don't seem to work. Any ideas?
> 
> - Chris
> 
> ___
> Perl-Win32-Users mailing list
> Perl-Win32-Users@listserv.ActiveState.com
> To unsubscribe: http://listserv.ActiveState.com/mailman/mysubs
> 

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


RE: trying to parse a file...

2005-04-19 Thread Thomas, Mark - BLS CTR
Bruce,

Here's a simple module that parses the Python config file format you
specified. Use it like this:

use ParseConfig;
use warnings;
use strict;

my $cfg = ParseConfig->new('viewcvs.conf');

# Print only the specified root
# use $cfg->show() to print the entire file
$cfg->show('svn_roots');

# Add a name/path pair to the specified root
$cfg->add('svn_roots', test8 => '/foo/bar');
$cfg->show('svn_roots');

# Remove a name/path pair to the specified root
# Unimplemented: this is for you to finish!
#print $cfg->remove('svn_roots', 'test8');

As you can see, I left the "remove" method as an exercise for the reader :)
If you decide to use it, you may want to add a "save" method as well.

Hope this provides enough to get you started.

- Mark.



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


RE: trying to parse a file...

2005-04-18 Thread Thomas, Mark - BLS CTR
Bruce,

I'm not sure what you're looking for. If something distributed with Gforge
is broken, shouldn't you ask its forum or the authors? Or are you trying to
add functionality that doesn't currently exist?

- Mark. 

> -Original Message-
> From: [EMAIL PROTECTED] 
> [mailto:[EMAIL PROTECTED] On 
> Behalf Of bruce
> Sent: Sunday, April 17, 2005 10:42 PM
> To: perl-win32-users@listserv.ActiveState.com
> Subject: trying to parse a file...
> 
> hi,
> 
> i'm trying to modify an app (gforge) that uses python to do 
> some file parsing/processing...
> 
> i have the following shell file that uses python. if i 
> understand it correctly, it's supposed to modify the 
> 'viewcvs.conf' file, and replace/update the section with 'svn_roots'.
> 
> it isn't working correctly... and i'm willing to consider using perl.
> basically, i'd like to continually add to the svn_root: block 
> with an additional line as required. also, can someone tell 
> me what i'd need to do, if i wanted to remove a line of text 
> from the 'svn_root' block if i had a given 'test_x:'
> 
> i need to be able to call the script like 'foo arg1'
> 
> can somebody tell me what i need to do to accomplish this?
> 
> thanks
> 
> bruce
> [EMAIL PROTECTED]
> 
> ---
> viewcvs.conf:
>   .
>   .
>   .
>   #
>   # This setting specifies each of the Subversion roots (repositories)
>   # on your system and assigns names to them. Each root 
> should be given
>   # by a "name: path" value. Multiple roots should be separated by
>   # commas and can be placed on separate lines.
>   #
>   #svn_roots = test2: /svn-gforge/uploadsvn
>   svn_roots = test5: /gforge-svn/test7/svn,
>   test2: /gforge-svn/test7/svn,
>   test3: /gforge-svn/test7/svn,
> 
>   # The 'root_parents' setting specifies a list of 
> directories in which
>   # any number of repositories may reside.  Rather than force 
> you to add
>   .
>   .
>   .
> ---
> 
> 
> 
> 
> [EMAIL PROTECTED] bin]# cat test.sh
> ---
> #! /bin/sh
> 
> python < import sys
> import os
> import string
> import ConfigParser
> r = ConfigParser.RawConfigParser ()
> r.read ("/etc/viewcvs/viewcvs.conf")
> r.set ("general","svn_roots","")
> l = os.listdir ("/var/lib/gforge/chroot/svnroot")
> l2 = []
> for d in l:
>   l2.append (d + ": svn://localhost/" + d) r.set 
> ("general","svn_roots",string.join (l2, ', ')) r.set 
> ("general","cvs_roots","") r.set ("general","default_root", l 
> [0]) r.write (open ("/var/lib/gforge/etc/viewcvs.conf", "w")) EOF
> 
> sed 's,pathname = CONF_PATHNAME .*,pathname = 
> "/var/lib/gforge/etc/viewcvs.conf",' \
> /usr/lib/python2.3/site-packages/viewcvs/viewcvs.py > 
> /var/lib/gforge/etc/viewcvs.py
> ---
> 
> 
> 
> ___
> Perl-Win32-Users mailing list
> Perl-Win32-Users@listserv.ActiveState.com
> To unsubscribe: http://listserv.ActiveState.com/mailman/mysubs
> 

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


RE: smtp on non port 25

2005-04-05 Thread Thomas, Mark - BLS CTR
> Looking at the source of the module, it looks like you can 
> define it in your
> new() statement:
> 
> $smtp = Net::SMTP->new('mailhost', Port => 12345); 

Yes, but then there's the slight problem that the receiving mail server has
to be listening on that port :)

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


RE: smtp on non port 25

2005-04-05 Thread Thomas, Mark - BLS CTR
> I've been using Mail::Sender and looked at Net::SMTP -
> is there a way or any other modules to use another
> port besides port 25?  My isp has shut 25 down.

Have you been connecting directly to the recipient domains? Most ISPs don't
allow that. You should be connecting to your ISP's relay server. If you can
send mail from Outlook Express/Thunderbird/whatever, then you can send it
from Net::SMTP as well--just look in your mail client for the mailhost
you're supposed to be using.

-- Mark.

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


RE: security diff between hidden fields and cookies

2005-03-28 Thread Thomas, Mark - BLS CTR
> I would like to get some opinions on what is safter,
> hidden fields or cookies?

You might be surprised to hear both are equally insecure. In either case,
you're sending data to a browser, and you're assuming the browser will send
it back to you unchanged. Yet either can be manipulated.

The best thing to do is avoid sending important data to the browser
altogether. You can use a sessionID as the previous poster mentions, but be
sure you keep in mind that the SessionID can be manipulated so make sure you
build the proper controls in place to handle that.

-- 
Mark Thomas 
Internet Systems Architect
___
BAE SYSTEMS Information Technology 
2525 Network Place
Herndon, VA  20171  USA 

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


RE: TVGuide

2005-03-28 Thread Thomas, Mark - BLS CTR
I should have also mentioned the XMLTV project
(http://sourceforge.net/projects/xmltv) which is a very popular project for
retrieving TV data. The backend, written in Perl, grabs TV data and formats
it into XML. It is used in PVR software such as MythTV. There are many
front-ends, too, such as TVGuide for Windows
(http://tvguide.sourceforge.net/) and others written in Perl and other
languages (check out the "Related Projects" section of
http://membled.com/work/apps/xmltv/)

Depending on your needs, your work may already be done!

-- Mark. 

> 
> > -Original Message-
> > From: Jerry Kassebaum
> > 
> > I would like to automate tvguide.com.

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


RE: TVGuide

2005-03-28 Thread Thomas, Mark - BLS CTR
I would recommend starting with WWW::Mechanize. It's an easier-to-use layer
on top of LWP with many conveniences for following links, filling out forms,
etc.

Sample code:

use WWW::Mechanize;
my $mech = WWW::Mechanize->new();

$mech->get( $url_to_login_page );

$mech->submit_form(
form_name => 'frmLogin',
fields=> { email  => '[EMAIL PROTECTED]', },
);

# Do more stuff, follow links, etc.

# Print the results
print $mech->content;


Hope this helps.
-- Mark.

> -Original Message-
> From: [EMAIL PROTECTED] 
> [mailto:[EMAIL PROTECTED] On 
> Behalf Of Jerry Kassebaum
> Sent: Monday, March 28, 2005 9:24 AM
> To: perl-win32-users@listserv.ActiveState.com
> Subject: TVGuide
> 
> 
> I would like to automate tvguide.com.
> 
> I have read Spidering Hacks, but I'm stuck.
> 
> Here is the form portion of their code that takes my e-mail 
> address for the 
> log-in:
> 
> 
> 
> *
> 
> 
>   
>  valign="top"
>   align="left"
>   style="padding-left:10px; 
> padding-right:5px; padding-top:15px; 
> padding-bottom:8px;">
>type="hidden" value="">
>type="hidden" value="">
>type="hidden" value="0">
> 
> 
> 
>   Please enter your email address:
>height="14">
>id="email" value="" size="20" 
> style="width:150px">
>  name="go"
>   id="go"
>   src="/myprofile/images/login.gif"
>   align="absmiddle"
>   border="0"
>   hspace="5">
> 
>   
>   
> 
> 
> ***
> 
> 
> 
> 
> 
> 
> Here's what I have so far:
> 
> 
> 
> use LWP;
> $browser=LWP::UserAgent->new;
> $url="http://tvguide.com/";;
> $response=$browser->post($url, ['name'=>'email', 'id'=>'email', 
> 'value'=>'[EMAIL PROTECTED]',]);
> print"$response";
> 
> *
> 
> 
> 
> I get: HTTP::Response=HASH(0x2883cb4)
> 
> 
> Now what?
> 
> 
> ___
> Perl-Win32-Users mailing list 
> Perl-Win32-Users@listserv.ActiveState.com
> To unsubscribe: http://listserv.ActiveState.com/mailman/mysubs
> 

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


RE: Google API

2005-03-25 Thread Thomas, Mark - BLS CTR
> I'm trying to display Google search results from within 
> another site. I've tried DBD::Google (Net::Google) & making 
> direct requests via SOAP::Lite. Both seem to take 3-5 seconds 
> to produce 10 results (too slow for me). Is their a faster way?

How much of that is startup time? Did you try benchmarking 10 or 100
requests? If that is the problem, then you may want to consider a persistent
perl environment (pperl, mod_perl, FastCGI, various ::Service and ::Server
modules).

-- 
Mark Thomas 
Internet Systems Architect
___
BAE SYSTEMS Information Technology 
2525 Network Place
Herndon, VA  20171  USA 

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


RE: current index on sorted array

2005-03-18 Thread Thomas, Mark - BLS CTR
Another solution is to use the Iterator design pattern. Not only can you get
the index, but you can peek at the next value, etc. There are several
modules that implement this. Here's one example:

use Array::Iterator;

my $i = Array::Iterator->new([EMAIL PROTECTED]);

while ($i->hasNext) {
print "Current Value is " . $i->getNext  . "\n";
print "Current Index is " . $i->currentIndex . "\n";
}

-- 
Mark Thomas 
Internet Systems Architect
___
BAE SYSTEMS Information Technology 
2525 Network Place
Herndon, VA  20171  USA 

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


RE: copying structures

2005-03-17 Thread Thomas, Mark - BLS CTR
Peter Eisengrein wrote:

> OK, I sort of get it. But what hash is it a reference to? If 
> you wanted to
> access or modify the hash directly where is it?

You can modify it through either reference. Maybe the following code will
help you. Other references are 'perldoc perldata', 'perldoc perldsc',
Learning Perl, etc.

#---

my $hashref1 = { foo => 'bar' };

my $hashref2 = $hashref1;

# Only the reference is copied
print $hashref1->{foo}; # prints "bar"
print $hashref2->{foo}; # prints "bar"

# You can use either reference to modify the hash
$hashref2->{foo} = 'baz';

print $hashref1->{foo}; # prints "baz"
print $hashref2->{foo}; # prints "baz"

my %newhash = %$hashref1; #dereferenced, therefore values are copied

$hashref1->{foo} = 'qux';

print $hashref1->{foo}; # prints "qux"
print $hashref2->{foo}; # prints "qux"
print $newhash{foo}; # still prints "baz"

#---

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


RE: copying structures

2005-03-17 Thread Thomas, Mark - BLS CTR

> Its great that it's already done but the bigger question, to 
> me, is why does it copy a reference in the second example. I 
> don't get it.

In the first example, it's a list of scalars. The scalars are copied. In the
second example, it's a list of anonymous hash references. The references are
copied. And the scalars they refer to are of course one and the same.

-- 
Mark Thomas 
Internet Systems Architect
___
BAE SYSTEMS Information Technology 
2525 Network Place
Herndon, VA  20171  USA 

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


RE: copying structures

2005-03-17 Thread Thomas, Mark - BLS CTR
One way:

  use Clone;
  $bref = clone ([EMAIL PROTECTED]);

or 

  @b = @{ clone ([EMAIL PROTECTED]) };

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


RE: How do I compare and get difference of two arrays

2005-02-25 Thread Thomas, Mark - BLS CTR
Mike Arms wrote:
> Sasi Kiran Kumar Mungamuru wrote:
> > How Do I compare and get difference of two arrays as my
> > both arrays carries scalar values and my output should be 
> > stored to another array.
> 
> In addition to the excellent responses by $Bill and others
> I would add that I use Mark-Jason Dominus' excellent module, 
> Algorithm::Diff . This enables doing Unix style "diff" on 
> lists as it is sometimes important to know how the lists 
> differ in a concise manner.

I'd like to chime in with List::Compare, another nice module which I use for
this type of thing.

  $lc = List::Compare->new([EMAIL PROTECTED], [EMAIL PROTECTED]);
  @diffs = $lc->get_symmetric_difference();

-- 
Mark Thomas 
Internet Systems Architect
___
BAE SYSTEMS Information Technology 
2525 Network Place
Herndon, VA  20171  USA 

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


RE: Email to fax

2005-02-23 Thread Thomas, Mark - BLS CTR
Does it _have_ to be windows? I have converted many an old PC into hylafax
(www.hylafax.org) servers. Hylafax works great and has an email-to-fax
gateway service. Lots of nice features. But it works only on Unix/Linux.

- Mark.

> -Original Message-
> From: [EMAIL PROTECTED] 
> [mailto:[EMAIL PROTECTED] On 
> Behalf Of Chris
> Sent: Wednesday, February 23, 2005 3:29 PM
> To: perl-win32-users
> Subject: Email to fax
> 
> 
> All,
> 
> I've been presented with the task of creating (or attempting 
> to create) an Email to Fax gateway. Has anyone written code 
> to  accomplish this or have a good idea of how it can be done 
> on the win32 platform? I know I can write code download and 
> phrase incoming messages from a POP server, but what's the 
> best software to use (winfax?) to fax it with and how?
> 
> - Chris
> 
> 
> ___
> Perl-Win32-Users mailing list 
> Perl-Win32-Users@listserv.ActiveState.com
> To unsubscribe: http://listserv.ActiveState.com/mailman/mysubs
> 

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


RE: perl executed out of c#

2005-02-17 Thread Thomas, Mark - BLS CTR
Dan Jablonsky wrote:
> I need to catch an error raised in the script.
> Right now the script contains only one line:
> #!perl
> die("died here");
> Unfortunatelly, I can catch an error like "file not
> found", "no permission" BUT I CANNOT CATCH THE die().
> Any idea how to do it?

The difference is that a file not found error sets errno, the error code
that is returned by die, whereas if no real error occurred, die returns
without an errno. You can set errno via the $! variable before you call die.
See perldoc perlvar.

Try this:

$!=255;
die("died here");

-- 
Mark Thomas 
Internet Systems Architect
___
BAE SYSTEMS Information Technology 
2525 Network Place
Herndon, VA  20171  USA 

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


RE: Matrix Inverse

2005-01-21 Thread Thomas, Mark - BLS CTR
Title: Message



Have you tried 
Math::Matrix?

  
  -Original Message-From: 
  [EMAIL PROTECTED] 
  [mailto:[EMAIL PROTECTED] On Behalf Of 
  Daniel WilsonSent: Friday, January 21, 2005 4:04 
  PMTo: Perl-Win32-Users@listserv.ActiveState.comSubject: 
  Matrix InverseHello Anyone have any example (in 
  Perl) on how to invert a matrix.  I have a 10x10 matrix that needs 
  inverting.Thanks
  Daniel 
  WilsonBayesian Edge 
  Technology & Solutions90 Holiday 
  DriveSuite B-1Solomons, Maryland  20688(410)-394-6426 
  Phone(410)-394-6425 Faxwww.bayesianedge.com 
___
Perl-Win32-Users mailing list
Perl-Win32-Users@listserv.ActiveState.com
To unsubscribe: http://listserv.ActiveState.com/mailman/mysubs


RE: RegEx help

2004-12-14 Thread Thomas, Mark - BLS CTR
Any thoughts?
> >
> >
> >$lines[0] =~/^(.*?,){36}.*?$/
> 
> 
> $lines[0] =~ /^[^,](?:*,[^,]*){36}$/

I like Joe's answer, but if you must use a regex this one works:

print scalar(my @commas = $lines[0] =~ /(,)/g);

- Mark.

___
Perl-Win32-Users mailing list
[EMAIL PROTECTED]
To unsubscribe: http://listserv.ActiveState.com/mailman/mysubs


RE: ADSI OLE and PERL

2004-12-01 Thread Thomas, Mark - BLS CTR
Have you seen the Win32::AD::User module?
http://search.cpan.org/~prefect/Win32-AD-User-0.04/User.pm

It gives you methods to get and set AD user properties via ADSI. The
documentation recommends using Toby Everett's ADSI browser to see what
properties are available:

http://opensource.activestate.com/authors/tobyeverett/

That app and the information on that page look dated but may still be
useful.

Disclaimer: I have not used any of the above; I'm just providing pointers to
potentially useful information.

-- 
Mark Thomas 
Internet Systems Architect
___
BAE SYSTEMS Information Technology 
2525 Network Place
Herndon, VA  20171  USA 



___
Perl-Win32-Users mailing list
[EMAIL PROTECTED]
To unsubscribe: http://listserv.ActiveState.com/mailman/mysubs


RE: numeric vs string scalars...difference?

2004-11-17 Thread Thomas, Mark - BLS CTR
How about 1.02e12?

If you want to know if it looks like a number to perl, this might be handy:

  use Scalar::Util qw(looks_like_number);
  print "Number" if looks_like_number($number);

Scalar::Util is part of the standard library in 5.8.x, I believe.

-- 
Mark Thomas 
Internet Systems Architect
___
BAE SYSTEMS Information Technology 
2525 Network Place
Herndon, VA  20171  USA 


> -Original Message-
> From: [EMAIL PROTECTED] 
> [mailto:[EMAIL PROTECTED] On 
> Behalf Of Paul Rogers
> Sent: Wednesday, November 17, 2004 1:29 PM
> To: [EMAIL PROTECTED]
> Subject: Re: numeric vs string scalars...difference?
> 
> 
> Hi Paul,
> 
> You are absolutely right.  However, the real problem was that 
> I had to 
> dynamically determine whether to use == or eq...thus I needed 
> a way of 
> reliably determining whether a variable was numeric or 
> string. That's where 
> the regex came into play.
> 
> Thanks,
> Paul ---
> 
> - Original Message - 
> From: "Paul Sobey" <[EMAIL PROTECTED]>
> To: "Paul Rogers" <[EMAIL PROTECTED]>
> Cc: <[EMAIL PROTECTED]>
> Sent: Wednesday, November 17, 2004 4:16 AM
> Subject: RE: numeric vs string scalars...difference?
> 
> 
> Hi,
> 
> Isn't eq a string comparison? Try using == instead:
> 
> print "String compares\n" if "45" eq "45.0"; # Fails
> print "Number compares\n" if "45" == "45.0"; # Passes
> 
> Cheers,
> Paul
> 
> 
> 
> ___
> Perl-Win32-Users mailing list 
> [EMAIL PROTECTED]
> To unsubscribe: http://listserv.ActiveState.com/mailman/mysubs
> 

___
Perl-Win32-Users mailing list
[EMAIL PROTECTED]
To unsubscribe: http://listserv.ActiveState.com/mailman/mysubs


RE: Alternative to Expect.pm for ActiveState?

2004-11-12 Thread Thomas, Mark - BLS CTR
> Ordinarily I'd use Expect.pm, but that doesn't seem to have 
> made it to the ActiveState repository yet, and I've 
> completely given up on using CPAN here.
> 
> Are there any suggestions for an ASPerl-friendly alternative?
> 
> If anybody has an alternate approach to this problem, I'm all ears.

Providing "expect" functionality on Windows is difficult because it is
usually implemented via a pseudo-tty, and Windows has no concept of this. So
I have no direct answer, but I will try to give you a few possibilities:

(1) According to the Expect perldocs, the only way to get Expect.pm to work
on Windows is to install cygwin and use it from that environment. You'll
also have to install IO::Pty.

(2) There are native win32 ports of Expect, and you could perhaps generate
expect scripts and then and run expect on the command line via
system()/backticks/etc. http://expect.nist.gov/#windows

(3) If you can set up a Telnet server on the machine, then you can use the
Expect-like functionality of Net::Telnet (connect to 'localhost')

HTH
- Mark.

-- 
Mark Thomas 
Internet Systems Architect
___
BAE SYSTEMS Information Technology 
2525 Network Place
Herndon, VA  20171  USA 



___
Perl-Win32-Users mailing list
[EMAIL PROTECTED]
To unsubscribe: http://listserv.ActiveState.com/mailman/mysubs


RE: Probably need help with a hash to do this

2004-11-10 Thread Thomas, Mark - BLS CTR
 
> Well, actuall none of the posts are right. Allthough I 
> appreciate all the responses.

What you describe is exactly what I gave you. Did it not work for you?

Here's the output using your two-row example:

Intersection: 16,19,50,71,76

Here's the output using your three-row example:

Intersection: 16,19

-- 
Mark Thomas 
Internet Systems Architect
___
BAE SYSTEMS Information Technology 
2525 Network Place
Herndon, VA  20171  USA 

___
Perl-Win32-Users mailing list
[EMAIL PROTECTED]
To unsubscribe: http://listserv.ActiveState.com/mailman/mysubs


RE: Time::ParseDate

2004-11-10 Thread Thomas, Mark - BLS CTR
> Time::ParseDate
> I lost it!  I thought it was in the DdP repository.
> Where did it go?  I just installed this 2 weeks(?) ago with 
> ppm. Now a search is showing up nothing.

ppm install Time-modules

-- 
Mark Thomas 
Internet Systems Architect
___
BAE SYSTEMS Information Technology 
2525 Network Place
Herndon, VA  20171  USA 

___
Perl-Win32-Users mailing list
[EMAIL PROTECTED]
To unsubscribe: http://listserv.ActiveState.com/mailman/mysubs


RE: UNIX utilities in Perl

2004-11-10 Thread Thomas, Mark - BLS CTR
> I am not sure if this is the right list for this question.

Perl-Unix-Users would have been best.


> I am working on Windows, and find I keep writing very
> short Perl scripts to implement UNIX utilities.  I call
> them zap_grep, zap_wc, zap_unique, zap_diff, zap_sort.
> My versions are very crude compared with the UNIX
> originals, and I wondered if somebody had already gone
> through this exercise.

Several years ago, Tom Christiansen started the Perl Power Tools project
with a goal of reimplementing all the Unix utilities in Perl. They got
reasonably far, but the project stagnated around 2001. However, this year a
new site was born for it, so they may have regained momentum:

http://ppt.perl.org/

All the commands you mention have been done. By done, I mean they function
_exactly_ like their Unix counterparts.

Of course, the cygwin project another poster mentioned is also a good bet,
as it gives you all the unix tools and shells, and even compilers, etc.

-- 
Mark Thomas 
Internet Systems Architect
___
BAE SYSTEMS Information Technology 
2525 Network Place
Herndon, VA  20171  USA 

___
Perl-Win32-Users mailing list
[EMAIL PROTECTED]
To unsubscribe: http://listserv.ActiveState.com/mailman/mysubs


RE: Probably need help with a hash to do this

2004-11-10 Thread Thomas, Mark - BLS CTR
My understanding of your problem is different from the other responders. I
believe what you want is the "intersection" of each "row" of numbers. If
this is correct, the following works:

#!perl -w
use strict;
use List::Compare;

my @data = (
'08|10|13|16|19|22|28|32|33|37|41|46|47|50|51|52|53|55|71|76|99',
'06|11|16|19|20|29|31|35|39|44|50|57|58|59|60|62|71|72|76|77|99',
'03|05|06|08|09|10|11|16|17|28|31|41|42|43|45|46|56|61|69|79|99',
'05|07|12|13|15|16|17|19|21|25|41|45|47|48|53|58|63|69|76|79|99',
'01|02|04|07|08|12|17|19|25|27|29|34|38|44|47|60|62|64|73|75|99',
'01|04|06|07|08|09|11|13|14|19|25|26|37|39|41|60|61|62|63|80|99',
'04|07|09|17|19|27|28|29|39|41|46|51|52|54|57|58|60|68|74|80|99'
);

# Turn data into a list of lists
@data = map { [ split /\|/ ] } @data;

my $lc = List::Compare->new( @data );

print "Intersection: ", join ",", $lc->get_intersection;


-- 
Mark Thomas 
Internet Systems Architect
___
BAE SYSTEMS Information Technology 
2525 Network Place
Herndon, VA  20171  USA 

___
Perl-Win32-Users mailing list
[EMAIL PROTECTED]
To unsubscribe: http://listserv.ActiveState.com/mailman/mysubs


RE: 2 Questions: Sorting a Hash and Reading From Columns

2004-11-09 Thread Thomas, Mark - BLS CTR
Grakowsky, Richard (ETS: Communications and Network Services) wrote:
> $myhash{TeamName}{PCT} - Percentage of wins in DD.D format
> [...]
> When I dump the information in this hash I would like to have 
> it ranked by PCT so I tried this...
> 
> foreach $team (sort {$a <=> $b} keys %myhash) {
>   print stuff...
> }
> 
> It's sorting by something, but I don't know what.

by each key of %myhash, because that's what you've told it to sort. So what
it's seeing is { 'Team1Name' <=> 'Team2Name' }, which is a numeric
comparison of strings.

Try this:
  foreach $team (sort {$myhash{$a}{PCT} <=> $myhash{$b}{PCT}} keys %myhash)
{
print "$team\n";
  }

> 
> Second Question: Reading from columns...
> 
> Is there a way that I can read from columns for each line I read in
> rather than a pattern match?  For example...

substr() should do the trick.

> $myhash{PlayDate}{HOMETEAM} =  #substr($line,  9, 11)
> $myhash{PlayDate}{AWAYTEAM} =  #substr($line, 22,  8)

- Mark.


___
Perl-Win32-Users mailing list
[EMAIL PROTECTED]
To unsubscribe: http://listserv.ActiveState.com/mailman/mysubs


RE: Extracting Images Question

2004-11-08 Thread Thomas, Mark - BLS CTR
> I wish it was that easy, I could have a script ftp and grab 
> them. Our company is very funny and does not work well 
> between the different depts, so getting ftp access to a 
> directory on another computer on the other side of the world 
> won't happen. How hard is it to do what I stated in my original post?

It's easy with WWW::Mechanize, as stated in an earlier response.

-- 
Mark Thomas 
Internet Systems Architect
___
BAE SYSTEMS Information Technology 
2525 Network Place
Herndon, VA  20171  USA 

___
Perl-Win32-Users mailing list
[EMAIL PROTECTED]
To unsubscribe: http://listserv.ActiveState.com/mailman/mysubs


RE: RFC Expunge issue with Net::IMAP::Simple .95

2004-11-04 Thread Thomas, Mark - BLS CTR


> -Original Message-
> From: Ben Conrad [mailto:[EMAIL PROTECTED] 
> Sent: Wednesday, November 03, 2004 7:16 PM
> To: 'Thomas, Mark - BLS CTR'; 
> [EMAIL PROTECTED]
> Subject: RE: RFC Expunge issue with Net::IMAP::Simple .95
> 
> 
> Mark,
> 
> Your suggestion did work, however the cmd id is still being 
> passed to the IMAP server:
> 
> 14 Ben EXPUNGE

Yes, it looks like the id is sent with every command. Here's the subroutine:

  sub _send_cmd {
my ( $self, $name, $value ) = @_;
my $sock = $self->_sock;
my $id   = $self->_nextid;
my $cmd  = qq[$id $name $value\r\n];
{ local $\; print $sock $cmd; }
return ($sock => $id);
  }

A Q&D fix would be to add one line as follows (do this INSTEAD of what I
wrote previously):

  sub _send_cmd {
my ( $self, $name, $value ) = @_;
my $sock = $self->_sock;
my $id   = $self->_nextid;
my $cmd  = qq[$id $name $value\r\n];
$cmd = qq[$value $name\r\n] if ($name eq 'EXPUNGE');
{ local $\; print $sock $cmd; }
return ($sock => $id);
  }

-- 
Mark Thomas 
Internet Systems Architect
___
BAE SYSTEMS Information Technology 
2525 Network Place
Herndon, VA  20171  USA 

___
Perl-Win32-Users mailing list
[EMAIL PROTECTED]
To unsubscribe: http://listserv.ActiveState.com/mailman/mysubs


RE: RFC Expunge issue with Net::IMAP::Simple .95

2004-11-03 Thread Thomas, Mark - BLS CTR
The _process_command() routine processes its 'cmd' arguments in order, so
you should be able to simply reverse it. So, instead of
  cmd => [EXPUNGE => $box],
use
  cmd => [$box, 'EXPUNGE'],

looks like this has already been reported as a bug:
http://rt.cpan.org/NoAuth/Bug.html?id=8035

Consider submitting a patch with the above change. It's easy to do and
module authors love it.

- Mark.


> -Original Message-
> From: [EMAIL PROTECTED] 
> [mailto:[EMAIL PROTECTED] On 
> Behalf Of Ben Conrad
> Sent: Wednesday, November 03, 2004 4:36 PM
> To: [EMAIL PROTECTED]
> Subject: RFC Expunge issue with Net::IMAP::Simple .95
> 
> 
> Folks,
> 
> I'm just about done writing a script that deletes messages 
> older than "x" days in IMAP mailboxes.  When I do a 
> $imap->expunge_mailbox( "$box" ) the server (via network 
> sniff) spits out:
> 
> 14 EXPUNGE "Ben"  >>> Net::IMAP::Simple
> 14 BAD EXPUNGE Invalid Syntax   >>> Ipswitch Imail server 7.04
> 15 EXPUNGE>>> Net::IMAP::Simple
> 16 LOGOUT >>> Net::IMAP::Simple
> 15 BAD EXPUNGE Invalid Syntax  >>> Ipswitch Imail server 7.04
> 
> I looked at RFC 1730 (IMAP 4) and it looks like EXPUNGE is 
> supposed to be formatted "mbox EXPUNGE", not "EXPUNGE mbox".  
> I tried that in a telnet window and it worked:
> 
> Ben EXPUNGE
> * 3 EXPUNGE
> * 2 EXPUNGE
> * 1 EXPUNGE
> Ben OK Expunge completed
> 
> I'm not sure why the expunge on logout is failing.
> 
> Microsoft Exchange seems to act in the same way.  Is there a 
> way I can modify simple.pm to reorder the commands, I'm not 
> too familiar with modifying perl modules.
> 
> >> from simple.pm  $VERSION = '0.95';
> sub expunge_mailbox {
> my ( $self, $box ) = @_;
> _escape( $box );
> 
> return $self->_process_cmd(
> cmd => [EXPUNGE => $box],
> final   => sub { 1 },
> process => sub { },
> );
> }
> 
> Help!
> 
> 
> 
> Ben Conrad
> Sr. Network Administrator
> 180 Old Colony Avenue
> Quincy, MA  02170
> Passkey International, Inc.
> [T] 617.237.8225
> [M] 617.852.6206
> [F] 617.328.1461
> http://www.passkey.com
> 
> *The Key to Optimizing Your Group Performance* 
> ___
> Perl-Win32-Users mailing list 
> [EMAIL PROTECTED]
> To unsubscribe: http://listserv.ActiveState.com/mailman/mysubs
> 

___
Perl-Win32-Users mailing list
[EMAIL PROTECTED]
To unsubscribe: http://listserv.ActiveState.com/mailman/mysubs


RE: string to time

2004-11-03 Thread Thomas, Mark - BLS CTR
> given a date string something like
> 
> 11/03/2004 09:30:27
> 
> Is there a perl mod that will turn this into perl's time() in 
> seconds from day zero?


  use Time::ParseDate;
  $seconds = parsedate("11/03/2004 09:30:27");

if it's a UK-style date (March 11) then you change the line to

  $seconds = parsedate("11/03/2004 09:30:27", UK=>1);

-- 
Mark Thomas 
Internet Systems Architect
___
BAE SYSTEMS Information Technology 
2 Massachusetts Ave NE, Ste. 5110
Washington, DC 20212 USA 




> -Original Message-
> From: [EMAIL PROTECTED] 
> [mailto:[EMAIL PROTECTED] On 
> Behalf Of Hon Shi
> Sent: Wednesday, November 03, 2004 12:45 PM
> To: [EMAIL PROTECTED]
> Subject: string to time
> 
> 

> 
> Thanks
> 
> 
>   
> __ 
> Do you Yahoo!? 
> Check out the new Yahoo! Front Page. 
> www.yahoo.com 
>  
> 
> ___
> Perl-Win32-Users mailing list 
> [EMAIL PROTECTED]
> To unsubscribe: http://listserv.ActiveState.com/mailman/mysubs
> 

___
Perl-Win32-Users mailing list
[EMAIL PROTECTED]
To unsubscribe: http://listserv.ActiveState.com/mailman/mysubs


RE: Perl based Faxing

2004-11-02 Thread Thomas, Mark - BLS CTR
I've controlled Hylafax (www.hylafax.org) for years via Perl, long before
the CPAN module (http://search.cpan.org/~arak/Fax-Hylafax-Client-1.01/)
became available. It's a great product, but it's not for Windows.

Interfax (www.interfax.net) offers faxing as a Web Service. They have sample
Perl code at
http://www.interfax.net/en/dev/webservice/samples/fax_perl_sendcharfax.html

-- 
Mark Thomas 
Internet Systems Architect
___
BAE SYSTEMS Information Technology 
2 Massachusetts Ave NE, Ste. 5110
Washington, DC 20212 USA 

___
Perl-Win32-Users mailing list
[EMAIL PROTECTED]
To unsubscribe: http://listserv.ActiveState.com/mailman/mysubs


RE: Mark's brain teasing JAPH [LONG]

2004-10-27 Thread Thomas, Mark - BLS CTR
> That's one convoluted JAPH!

Thanks.

> I like to pick through admirable JAPH's like this in an 
> attempt to learn more Perl idiosyncrasies [...]
> Anyone care to explain what's going on?

How about I tell you how I created it, which I think makes it easier to see
what's going on.

Every JAPH starts out with a small idea on some transormation of the phrase
"Just Another Perl Hacker". I noticed there are repeated letters in that
phrase, so I decided to collapse the phrase down to just the unique letters
and then rebuild the phrase by indexing them.

  # Reduce to unique characters
  $japh = 'Just another Perl hacker';
  $letter{$_}++ foreach split//, $japh;
  print join "", sort keys %letter;

So now I'm working with the string " JPacehklnorstu". But that string
doesn't have to be in any particular order, so it's off to the Internet
Anagram Server (http://www.wordsmith.org/anagram/) to make things
interesting. There are lots of funny results, and I ended up making a few
different versions of the JAPH with them. The one you saw was "steal Porch
Junk".

So now, I just create a list of indices to extract the proper phrase back
out. I could simply use the following:

  @indices = (12,13,0,1,5,3,14,7,1,10,2,8,5,6,2,8,4,5,10,3,9,15,2,8);

But that would be boring. And take up quite a bit of space. I noticed that
the range is 0..15 or one nybble (half a byte). I could pack all 24 indices
in just 12 bytes! I decided to represent the bytes as hex characters:

  # pack 'em into bytes.
  while (@indices) {
$byte = (shift(@indices)<<4)|shift(@indices);
printf('%x',$byte);
  }

So now I'm working with the string "cd0153e71a28562845a39f28". To extract
the indices, I just have to use hex() on each character in that string.

So now, let's put together a first cut at the JAPH, using the techniques
above:

  $_="steal Porch Junk"; @_=split //;  # put the letters in @_
  $_="cd0153e71a28562845a39f28";   # put the indices in $_
  s/(.)/$_[hex($1)]/ge;# replace each index with its letter
  print;   # print it out

Now the fun part... let's obfuscate it a bit. Adding another "e" to the
regex is low-hanging fruit. We just assemble the '$_[hex($1)]' part via
concatenated strings:

  s/(.)/'$_[' . 'hex' . '($1)]'/gee;

I don't like the quotes. Too obvious. Lets change them to q() but use '.'
instead of the parens (anyone who gets confused by this needs to read
perldoc perlop):

  s/(.)/q.$_[. . q.hex. . q.($1)]./gee;

Looking better, but that 'hex' stands out like a sore thumb. Noticing that
the "h" and "e" are in our letter list (@_), I decide to assemble the 'hex',
which is just a string at this point, from those letters ("h" = $_[10], "e"
= $_[2]), leaving the 'x':

  s/(.)/q.$_[. . $_[10] . $_[2] . q.x. . q.($1)]./gee

Better. Now let's get rid of the quotes from the rest of the JAPH too, using
q.. and q==

  $_=q;steal Porch Junk;;split //;
  $_=q=cd0153e71a28562845a39f28=;
  s/(.)/q.$_[. . $_[10] . $_[2] . q.x. . q.($1)]./gee;
  print;

Now let's break up that hex string in the second line. I see it has three
"28"'s, so we can do a substitution. What should we replace it with? The
string "s/" is about as diabolical as any. ";q" would have been a good one
too. I chose the former. In our y// (or y;; to be tricky) lets also replace
the "a"'s with ";". We'll also insert a newline, which we take back out with
a s/\n//;

  $_=q;steal Porch Junk;;split//;$_=q=cd0153e71;
  s/56s/45;39fs/=;
  y;\;s/;a28;;
  s;\n;;;
  s/(.)/q.$_[. . $_[10] . $_[2] . q.x. . q.($1)]./gee;
  print;

Now let's smash it up a bit:

  $_=q;steal Porch Junk;;split//;$_=q=cd0153e71;
  s/56s/45;39fs/=;y;\;s/;a28;;s;\n;;;
  s/(.)/q.$_[..$_[10].$_[2].q.x..q.($1)]./gee;print;
  
Looking kinda JAPHy now, isn't it? There's a few more things we can do. The
y operator can take extra chars at the end without consequence. We'll add
another decoy 's/'. In the first substitution, let's replace '\n' with '$/'.

  $_=q;steal Porch Junk;;split//;$_=q=cd0153e71;
  s/56s/45;39fs/=;y;\;s/;a28s/;;s;$/;;;
  s((.))/q.$_[..$_[10].$_[2].q.x..q.($1)]./gee;print;

Now, let's work on the substitution again. We can split it between lines,
and change s/// to s()//. Also we can change the ';' before print to a '/',
which is interpreted as a divide, but will still evaluate the 'print' with a
warning under -w which we don't care about.

  $_=q;steal Porch Junk;;split//;$_=q=cd0153e71;
  s/56s/45;39fs/=;y;\;s/;a28s/;;s;$/;;;s((.))/
  q.$_[..$_[10].$_[2].q.x..q.($1)]./gee/print;

More stuff: Let's insert some ';' where they won't make a difference, and
remove one from the end. Then I want to pad the last line by 2 chars because
I like to make the lines equal length. We can add $. (which contains nothing
outside a loop) to the substitution string.

  $_=q;steal Porch Junk;;split//;$_=q=cd0153e71;
  s/56s/45;39fs/=;y;\;s/;a28s/;;;s;$/;;;s((.))/;
  q.$_[.$..$_[10].$_[2].q.x..q.($1)]./gee/print;

More can always be done, but at thi

RE: perl from net drive

2004-10-21 Thread Thomas, Mark - BLS CTR
> However - there are more than a few hard references to drive 
> letters (c:) in config.pm, which I understand is something 
> read when perl spins up.  If so, I'm dead.  Is this correct?

Config.pm is written at install time. You must have installed to the C:
drive. Have you tried installing to a full UNC path instead of a drive
letter?

- Mark.

-- 
Mark Thomas [EMAIL PROTECTED] 
Internet Systems Architect DigitalNet, Inc. 

#$_=q;steal Porch Junk;;split//;$_=q=cd0153e71;
#s/56s/45;39fs/=;y;\;s/;a28s/;;;s;$/;;;s((.))/;
#q.$_[..$..$_[10].$_[2].q.x..q.($1)]./gee/print

___
Perl-Win32-Users mailing list
[EMAIL PROTECTED]
To unsubscribe: http://listserv.ActiveState.com/mailman/mysubs


RE: Help with array of arrays!

2004-10-13 Thread Thomas, Mark - BLS CTR
> Gives:
> 0:, 1, 2, 3
> 1:, 1, 2, 3
> 2:, 1, 2, 3
> 3:, 1, 2, 3
> 
> Which is what I'd expect, and is designed to put the data 
> into a csv file.
> 
> First, is this the best way to do it, or is there a neater trick?

This is a neat trick:

  use Template;
  my $template = Template->new || die $Template::ERROR, "\n";
  $template->process('csv.tt', {array => [EMAIL PROTECTED]);

And then the template (csv.tt) contains:

  [% FOREACH row IN array -%]
  [% row.join(",") %]
  [% END %]


> Second, how would I print the results if I didn't know that 
> each individual array was 4 elements long (i.e. the sub 
> arrays could be random lengths)?

The above would work for that, too.

- Mark.

___
Perl-Win32-Users mailing list
[EMAIL PROTECTED]
To unsubscribe: http://listserv.ActiveState.com/mailman/mysubs


RE: Help with program

2004-10-12 Thread Thomas, Mark - BLS CTR
Tom Pollard wrote:
> (3) the number of items in @pts is length(@pts), or scalar(@pts), 
> or 1+$#pts, but not $#pts.

You're 2 for 3. length() is for scalars, not arrays.

- Mark.

___
Perl-Win32-Users mailing list
[EMAIL PROTECTED]
To unsubscribe: http://listserv.ActiveState.com/mailman/mysubs


RE: Trouble printing a field (was: Rejecting adds to a list)

2004-10-07 Thread Thomas, Mark - BLS CTR
Gary,

You seem to be having trouble with some code that's needlessly complex. What
is the $cli object? Do you have any control over it? It would probably be
easier to add an addToBlacklist method so you can say:

  $cli->addToBlacklist($ip) if (not tolerated($ip));


- Mark.

___
Perl-Win32-Users mailing list
[EMAIL PROTECTED]
To unsubscribe: http://listserv.ActiveState.com/mailman/mysubs


RE: Rejecting adds to a list

2004-10-05 Thread Thomas, Mark - BLS CTR
> What I would like is to only include a new IP if 
> $rejected{$_} > $tolerate (which is currently working) and the IP 
> isn't currently in the original IP list.

> 
> my $BlacklistedIPs = $cli->GetBlacklistedIPs();
> foreach (keys %rejected)
> {
> $BlacklistedIPs .= "\\e$_"  if ($rejected{$_} > 
> $tolerate); } $cli->SetBlacklistedIPs($BlacklistedIPs);
> 
> The contents of $BlacklistedIPs looks like:
>  
> 61.144.183.76\e80.15.130.137\e221.224.88.237\e211.211.95.210\e
> 
> Would anyone like to take a stab at this?

my %bl = map {$_=>$tolerate+1} split /\\e/, $cli->GetBlacklistedIPs();
$bl{$_} = $rejected{$_} foreach keys %rejected;
$cli->SetBlacklistedIPs(join "\\e", grep {$bl{$_}>$tolerate} keys %bl);


It would be nicer if your $cli object could get/set lists instead of
delimited strings--it would make the above shorter.

-- 
Mark Thomas Internet Systems Architect
[EMAIL PROTECTED]   DigitalNet, Inc.

$_=q;steal Porch Junk;;split//;$_=q=cd0153e71;
s/56s/45;39fs/=;y;\;s/;a28s/;;;s;$/;;;s((.))/;
q.$_[..$..$_[10].$_[2].q.x..q.($1)]./gee/print

___
Perl-Win32-Users mailing list
[EMAIL PROTECTED]
To unsubscribe: http://listserv.ActiveState.com/mailman/mysubs


RE: XML Twig - perl

2004-09-29 Thread Thomas, Mark - BLS CTR
Bhuvana,

XML questions are best asked on the perl-XML list. Many Twig users frequent
that list (even the author chimes in from time to time).

I'm not all that familiar with Twig, so what I can do is give you working
XML::LibXML code:

my $doc = XML::LibXML->new->parse_file($ARGV[0]);
my @dl_nodes = $doc->findnodes('//dl');
foreach my $dl (@dl_nodes) {

#create replacement dl element
my $new_dl = XML::LibXML::Element->new('dl');
$new_dl->appendText("\n");

#process the old dl element
my $text = $dl->textContent;
foreach $line (split /\s*\n\s*/, $text) {
my ($first, $second) = split /\s+/, $line, 2;
next unless $second; #skip incomplete lines
$new_dl->appendTextChild('first',$first);
$new_dl->appendTextChild('second',$second);
$new_dl->appendText("\n");
}

#now perform replacement
$dl->replaceNode($new_dl);
}
print $doc->toString;




-- 
Mark Thomas[EMAIL PROTECTED] 
Internet Systems Architect DigitalNet, Inc. 


> -Original Message-
> 
> Hello,
> 
> Using xml twig, I am trying to supply two elements in a line 
> with the separator tab.
> 
> Ex:
> 
> 
> ABCCDE
> addeerwe
> sdfsdfserewrwe
> 
> 
> 
> Expected Result:
> 
> 
> ABCCDE
> addeerwe
> sdfsdfserewrwe
> 
> 

___
Perl-Win32-Users mailing list
[EMAIL PROTECTED]
To unsubscribe: http://listserv.ActiveState.com/mailman/mysubs


RE: XML Out.

2004-09-23 Thread Thomas, Mark - BLS CTR
Carter, you didn't say what you wanted to add, and where. I'll make the
assumption you want to add a sibling  node to release version 2.0.
Here are a few options:

OPTION 1
Take another look at XML::Simple. I don't see anything in your XML that
wouldn't be possible to create using XML::Simple. Did you use the KeyAttr
and ForceArray options?

With your sample XML, the following code:

  use XML::Simple;
  my $xs = XML::Simple->new(KeepRoot=>1, ForceArray=>1, KeyAttr=>[]);
  my $ref = $xs->XMLin($xml);
  print $xs->XMLout($ref);

reads it in and prints an XML document equivalent to the input.

OPTION 2
If you're comfortable with OO, and maybe a little adventurous, you may want
to look at the new module Class::XML. This is supposed to allow you to treat
your XML as objects. You do some upfront work including creating a couple
small packages representing your XML constructs (Patch and ProductRelease).
If you also add a "relation" called get_release, adding a patch might be
something like this (completely untested code from a skim of the
docs--consider it pseudocode):

  my $new_patch = Patch->new;
  $new_patch->number(2);
  $new_patch->readme('readme-2.txt');
  $new_patch->file('patchfile.gz');
  $new_patch->desc('Description');
  
  my ($latest_release) = ProductRelease->get_release("2.0");
  $latest_release->patch($new_patch);

OPTION 3
DOM's not hard when you are very familiar with the structure of the XML.
Here's sample XML::LibXML code that adds a new  to release 2.0
(tested).

use XML::LibXML;
my $patches = XML::LibXML->new->parse_file('patches.xml');
my ($release) = $patches->findnodes('//[EMAIL PROTECTED]"2.0"]');

my $new_patch= XML::LibXML::Element->new('patch');
$new_patch->appendTextChild('number','2');
$new_patch->appendTextChild('readme','readme-2.txt');
$new_patch->appendTextChild('file','patchfile.gz');
$new_patch->appendTextChild('desc','Description');

my ($release) = $patches->findnodes('//product-release[version="2.0"]');
$release->appendChild($new_patch);

print $patches->toString(1); #or $patches->toFile($filename);


-- 
Mark Thomas[EMAIL PROTECTED] 
Internet Systems Architect DigitalNet, Inc. 

$_=q;KvtuyboopuifeyQQfeemyibdlfee;; y.e.s. ;y+B-x+A-w+s; ;y;y; ;;print;; 
  

___
Perl-Win32-Users mailing list
[EMAIL PROTECTED]
To unsubscribe: http://listserv.ActiveState.com/mailman/mysubs


RE: Using html SCRIPT tag with PERL

2004-09-09 Thread Thomas, Mark - BLS CTR
That information pertains only to IIS, whereas the OP said he's running
apache.

As long as I'm responding, I'll hop up on my soapbox a little bit. Feel free
to ignore everything after this sentence.

Mixing code and HTML is a bad idea, in general. It's bad when you put HTML
in code (a la CGI.pm) and it's bad when you put code in HTML (a la embperl).
One cannot be maintained without touching the other. It's fine if it's a
small project and you are (and will always be) the only one maintaining it.
Otherwise, I recommend separating the code and the presentation using a
templating system like HTML::Template or Template-Toolkit
(www.template-toolkit.org). I really like the Template Toolkit and use it
all the time, even on smallish projects. It is really easy to use, and often
turns out to be simpler than any alternative. For example, with all the
plugins available for TT, occasionally you don't need _any_ code, just the
templates (triggered by the 'tpage' or 'ttree' command). In any case, it's
worth looking into for any medium-to-large scale effort.

- Mark.



-- 
Mark Thomas[EMAIL PROTECTED] 
Internet Systems Architect DigitalNet, Inc. 

$_=q;KvtuyboopuifeyQQfeemyibdlfee;; y.e.s. ;y+B-x+A-w+s; ;y;y; ;;print;; 
  



> -Original Message-
> From: [EMAIL PROTECTED] 
> [mailto:[EMAIL PROTECTED] On 
> Behalf Of Adam R. Frielink
> Sent: Thursday, September 09, 2004 3:27 PM
> To: ncaa-hoops; [EMAIL PROTECTED]
> Subject: RE: Using html SCRIPT tag with PERL
> 
> 
> Sorry for the double response, I copied the wrong link.
> 
file:///C:/Perl/html/Windows/ActiveServerPages.html

> If you installed your copy of Activeperl in the default directory on 
> your C drive, check out this FAQ.
> 
file:///C:/Perl/html/faq/Windows/ActivePerl-Winfaq7.html


___
Perl-Win32-Users mailing list [EMAIL PROTECTED]
To unsubscribe: http://listserv.ActiveState.com/mailman/mysubs

___
Perl-Win32-Users mailing list
[EMAIL PROTECTED]
To unsubscribe: http://listserv.ActiveState.com/mailman/mysubs


RE: Help with exec command

2004-09-03 Thread Thomas, Mark - BLS CTR
> That being said, the only difference I see in your two 
> examples is that the second one has a space in an argument, 
> which will be seen by the shell as two arguments. You will 
> need to escape it like "my\\ scripts" so that a literal 
> backslash gets through to the shell.

Oops, I was thinking Unix, wasn't I? If you want quotes to get through, try
using qq(), e.g.

my $arg2 = qq("c:/my scripts/another.txt");


- Mark.

-- 
Mark Thomas[EMAIL PROTECTED] 
Internet Systems Architect DigitalNet, Inc. 

$_=q;KvtuyboopuifeyQQfeemyibdlfee;; y.e.s. ;y+B-x+A-w+s; ;y;y; ;;print;; 
  

___
Perl-Win32-Users mailing list
[EMAIL PROTECTED]
To unsubscribe: http://listserv.ActiveState.com/mailman/mysubs


RE: Help with exec command

2004-09-03 Thread Thomas, Mark - BLS CTR
> This works as intended...
> 
> my $arg1 = "c:/my_scripts/file.txt";
> my $arg2 = "c:/my_scripts/another.txt";
> my $program = "c:/my_scripts/cheese.pl";
> my @args = ($arg1, $arg2);
> exec "$program @args";
> 
> HOWEVER, I cannot for the life of me get the following to 
> work, no matter what I try with \"s etc. Is it actually possible?
> 
> my $arg1 = "c:/my scripts/file.txt";
> my $arg2 = "c:/my scripts/another.txt";
> my $program = "c:/my scripts/cheese.pl";
> my @args = ($arg1, $arg2);
> exec "$program @args";

Let me first comment that most of the time when I see people want to use
exec, they really want system() or backticks, perhaps followed by an exit.
At least you'd be able to determine success or capture any error messages,
which I believe would clue you in to the problem. Additionally, people
trying to use exec, system, or backticks on another perl script are usually
better off with include/require/use, sometimes combined with a little OO
refactoring. :-)

That being said, the only difference I see in your two examples is that the
second one has a space in an argument, which will be seen by the shell as
two arguments. You will need to escape it like "my\\ scripts" so that a
literal backslash gets through to the shell.


-- 
Mark Thomas[EMAIL PROTECTED] 
Internet Systems Architect DigitalNet, Inc. 

$_=q;KvtuyboopuifeyQQfeemyibdlfee;; y.e.s. ;y+B-x+A-w+s; ;y;y; ;;print;; 
  

___
Perl-Win32-Users mailing list
[EMAIL PROTECTED]
To unsubscribe: http://listserv.ActiveState.com/mailman/mysubs


RE: Leaving acronyms in all caps

2004-08-13 Thread Thomas, Mark - BLS CTR
Glenn wrote:

> 2 ways that I am aware of:
> 
> 1) Describe the words that form acronyms using rules, such as 
> a maximum 
> length, maximum number of vowels, etc., and then write code that 
> implements those rules.  Be careful of the acronym for Automobile 
> Association of America.
> 
> 2) Find someone else's acronym dictionary, lookup table, or 
> whitelist, 
> and use it.

3) Do the reverse: get a good spelling dictionary (or use Lingua::Ispell),
and treat all small 'words' not contained within as acronyms, and capitalize
them.

Notes:
- This will get you most of the way there, but it is still not perfect. No
solution will be able to distinguish beween acronyms that also happen to be
words. You'll still need manual review.
- This has the potentially beneficial side effect of making typos stand out.


-- 
Mark Thomas[EMAIL PROTECTED] 
Internet Systems Architect DigitalNet, Inc. 

___
Perl-Win32-Users mailing list
[EMAIL PROTECTED]
To unsubscribe: http://listserv.ActiveState.com/mailman/mysubs


RE: Binary characters in my URL

2004-07-22 Thread Thomas, Mark - BLS CTR
> >>>If the HTML document contains something like this (without line
> >>>breaks):
> >>>
> >>>   http://etext.lib.virginia.edu/etcbin/toccer-
> >>>   new2?id=RsvGene.sgm&images=images/modeng&data=/texts/
> >>>   english/modeng/parsed&tag=public&part=all">
> >>>
> >>>then it's wrong. It should be written as
> >>>
> >>>   http://etext.lib.virginia.edu/etcbin/toccer-
> >>>   new2?id=RsvGene.sgm&images=images/modeng&data=
> >>>   /texts/english/modeng/parsed&tag=public&part=all">
> >>>
> >>>See http://www.htmlhelp.com/faq/html/links.html#link-msie-only
> >>>(among other places).
> >>
> >>Both forms should work from an HREF.  &part should not be
> >>interpreted as an HTML entity since there is no trailing ;.
> > 
> > 
> > Yes, but only the latter is valid HTML, see 
> > http://www.w3.org/TR/html401/appendix/notes.html#h-B.2.2
> 
> Sorry, but I don't get the same conclusion as you do.  Both
> are valid and both work.

What I'm talking about specifically is the use of a URI in an HREF
attribute. Literal ampersands must be represented as '&' or the
attribute is not valid. Both the spec and the validator output you quoted
agree on this matter.

-- 
Mark Thomas[EMAIL PROTECTED] 
Internet Systems Architect DigitalNet, Inc. 

$_=q;KvtuyboopuifeyQQfeemyibdlfee;; y.e.s. ;y+B-x+A-w+s; ;y;y; ;;print;; 
  

___
Perl-Win32-Users mailing list
[EMAIL PROTECTED]
To unsubscribe: http://listserv.ActiveState.com/mailman/mysubs


RE: Binary characters in my URL

2004-07-21 Thread Thomas, Mark - BLS CTR
> > If the HTML document contains something like this (without line
> > breaks):
> > 
> >http://etext.lib.virginia.edu/etcbin/toccer-
> >new2?id=RsvGene.sgm&images=images/modeng&data=/texts/
> >english/modeng/parsed&tag=public&part=all">
> > 
> > then it's wrong. It should be written as
> > 
> >http://etext.lib.virginia.edu/etcbin/toccer-
> >new2?id=RsvGene.sgm&images=images/modeng&data=
> >/texts/english/modeng/parsed&tag=public&part=all">
> > 
> > See http://www.htmlhelp.com/faq/html/links.html#link-msie-only
> > (among other places).
> 
> Both forms should work from an HREF.  &part should not be 
> interpreted as an HTML entity since there is no trailing ;.

Yes, but only the latter is valid HTML, see
http://www.w3.org/TR/html401/appendix/notes.html#h-B.2.2

-- 
Mark Thomas[EMAIL PROTECTED] 
Internet Systems Architect DigitalNet, Inc. 

$_=q;KvtuyboopuifeyQQfeemyibdlfee;; y.e.s. ;y+B-x+A-w+s; ;y;y; ;;print;; 
  

___
Perl-Win32-Users mailing list
[EMAIL PROTECTED]
To unsubscribe: http://listserv.ActiveState.com/mailman/mysubs


  1   2   >