RE: Assistance with Spreadsheet::WriteExcel Formula

2007-02-12 Thread Nichols, Ron
Thanks for your feedback.  I was hoping that there was a way around the
issue of the formula not being evaluated when the spreadsheet was
opened.

I have created spreadsheets with both Spreadsheet::WriteExcel and
Win32::OLE.  I chose to use Spreadsheet::WriteExcel because it creates
the spreadsheets much more quickly than Win32::OLE. In parallel with
requesting assistance from the this  support group, I wrote a Win32::OLE
routine to open the spreadsheet files created by
Spreadsheet::WriteExcel, read the '=SUMIF()' statements and write them
back to the spreadsheet.  This fix appears to work and should correct
the formula evaluation process.  

I was hoping to avoid using this approach because I have some other
plans for spreadsheets that would be created on a *NIX box and did not
want to have to go through a WIN32 platform to correct any spreadsheets
that were generated.

Again, Thanks for the feedback.

Ron Nichols


Ronald G. Nichols
Director of Information Technology
Knouse Foods Cooperative
717 677-7111 Ext. 3470
[EMAIL PROTECTED]

-Original Message-
From: Lyndon Rickards [mailto:[EMAIL PROTECTED] 
Sent: Saturday, February 10, 2007 1:33 PM
To: Nichols, Ron
Cc: Perl-Win32-Users@listserv.ActiveState.com
Subject: Re: Assistance with Spreadsheet::WriteExcel Formula

Nichols, Ron wrote:
> I am generating a spreadsheet using Spreadsheet::WriteExcel.
Everything 
> is working fine except a formula containing =SUMIF(A5:A10,
C15,C5:C10).  
> The formula gets generated correctly in the spreadsheet but in order
to 
> get the resulting value to be displayed in the cell, you have to edit 
> the cell (i.e., click in the edit bar, hit enter).  After performing
an 
> edit (without changing anything), the formula is evaluated correctly
and 
> displays the value.
> 
> Is there any way to get the formula to evaluate without having to edit

> the cell?  The spreadsheets that I am creating are locked so the user 
> cannot make changes to the formulas.  The script that creates the 
> spreadsheet will create hundreds of spreadsheets each time it is run.
> 
> I have attempted to force a recalculation of the spreadsheet from
within 
> Excel but that does not solve the issue.
> 
> The version of the module as shown from PPM query is:  
> Spreadsheet-WriteExcel-Simple [0.03] A simple single-sheet Excel
document
> 
> Your assistance is appreciated.
> 
> *//**//**/Ronald G. Nichols/*
> 
> */Director of Information Technology/*
> 
> */Knouse Foods Cooperative/*
> 
> */717 677-7111 Ext. 3470/*
> 
> */[EMAIL PROTECTED]/*
> 
> *//**//*
> 

Spreadsheet::WriteExcel is an excellent module especially if you need
to create sn excel file on a *nix box, but AFAIK you have hit a 
limitation of the module.

Suggest you consider switching to Win32::OLE which, as it is directly 
driving Excel, will provide what you need.

The syntax isn't so very different to convert from your 
Spreadsheet::WriteExcel script so far - I have made the conversion many 
times myself. Short example -

#!perl -w
use strict;
use Win32::OLE::Const 'Microsoft Excel';
use Win32::OLE qw(in with);

$Win32::OLE::Warn = 1;
my $Excel = Win32::OLE->new('Excel.Application'); #, 'Quit');
$Excel->{'Visible'} = 1;

my $xlFile = "e:/testing2/book.xls";
unlink($xlFile) if(-e $xlFile);
$Excel->{SheetsInNewWorkbook} = 1;
my $workbook = $Excel->Workbooks->Add();
print "$xlFile\n";


my $sheet = $workbook->Worksheets(1);
$sheet->{Name} = "My_Sheet";

my $col = "A";
my $row = 1;

foreach('Col1', 'Col2', 'Total' ) {
 $sheet->Range($col . $row)->{Font}->{Bold} = 1;
 $sheet->Range($col . $row)->{Value} = $_;
 $col++;
 }

$row += 1;

for(my $x = 10, my $y = 15; $y < 100; $x++, $y+= 3) {
  $sheet->Range("A". $row)->{Value} = $x;
  $sheet->Range("B". $row)->{Value} = $y;
  $sheet->Range("C". $row)->{Value} = "=SUM(A" .$row ."+B" .$row .
")";
 $row++;
 }
$Excel->ActiveWorkbook->SaveAs({Filename => $xlFile});

HTH - Lynn.


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


Assistance with Spreadsheet::WriteExcel Formula

2007-02-09 Thread Nichols, Ron
I am generating a spreadsheet using Spreadsheet::WriteExcel.  Everything
is working fine except a formula containing =SUMIF(A5:A10, C15,C5:C10).
The formula gets generated correctly in the spreadsheet but in order to
get the resulting value to be displayed in the cell, you have to edit
the cell (i.e., click in the edit bar, hit enter).  After performing an
edit (without changing anything), the formula is evaluated correctly and
displays the value.

Is there any way to get the formula to evaluate without having to edit
the cell?  The spreadsheets that I am creating are locked so the user
cannot make changes to the formulas.  The script that creates the
spreadsheet will create hundreds of spreadsheets each time it is run.

I have attempted to force a recalculation of the spreadsheet from within
Excel but that does not solve the issue.

The version of the module as shown from PPM query is:
Spreadsheet-WriteExcel-Simple [0.03] A simple single-sheet Excel
document

Your assistance is appreciated.


Ronald G. Nichols
Director of Information Technology
Knouse Foods Cooperative
717 677-7111 Ext. 3470
[EMAIL PROTECTED]


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


RE: Printing to Network Printer

2006-07-28 Thread Nichols, Ron
 
I shared my default printer and opened the printer as
\\computer_Name\Printer_name.  Creating the share solved the problem...

Thanks for you assistance.

Ronald G. Nichols
Director of Information Technology
Knouse Foods Cooperative, Inc.
[EMAIL PROTECTED]
(717) 677-8181 Ext. 3470
 

-Original Message-
From: [EMAIL PROTECTED]
[mailto:[EMAIL PROTECTED] On Behalf Of
Ken Cornetet
Sent: Friday, July 28, 2006 12:38 PM
To: Perl-Win32-Users@listserv.ActiveState.com
Subject: RE: Printing to Network Printer

Open the printer share name. For example, if the computer that the
printer is set up on is called "chworktap", and the printer share name
is "wagstaff", then your open should look like this:

Open FILE, "chworktap\\wagstaff"

Your post mentions an IP address and port 9100 (typically used by
network print servers for raw data). If you want to send data directly
to the printer over the network, you'd have to open a socket to the
destination IP address and port and dump the data which will
transparently be sent to the printer. That's the theory - I've never
tried it. 

If you really want to send data directly to the printer, and if the
print server will handle the LPR protocol, your best bet would probably
be Net::LPR.


-Original Message-
From: [EMAIL PROTECTED]
[mailto:[EMAIL PROTECTED] On Behalf Of
Nichols, Ron
Sent: Friday, July 28, 2006 8:22 AM
To: Perl-Win32-Users@listserv.ActiveState.com
Subject: Printing to Network Printer

I have a PERL script that prints to a network printer on a Windows XP
Professional OS.  The script will be used on a variety of XP systems
with varying network printers as the default printer.  When I run the
code shown below:
 
#! perl -w
use strict;
 
my $port='9100';
my $default_printer='10.1.5.211';
 
open(OUTPUT_PRINTER,">$default_printer\\$port") || die "Unable to
open printer: $!\n"; print OUTPUT_PRINTER "This is a test Line\n";

 
I get the message:  Unable to open printer: Permission denied
 
I have turned off the firewall to see if that was causing the error but
get the same response.  I am hoping that someone has some ideas on how
to accomplish printing to the default printer.  

Your assistance is appreciated.
 
Ronald G. Nichols
Director of Information Technology
Knouse Foods Cooperative, Inc.
[EMAIL PROTECTED] <mailto:[EMAIL PROTECTED]>
(717) 677-8181 Ext. 3470
 
___
Perl-Win32-Users mailing list
Perl-Win32-Users@listserv.ActiveState.com
To unsubscribe: http://listserv.ActiveState.com/mailman/mysubs
___
Perl-Win32-Users mailing list
Perl-Win32-Users@listserv.ActiveState.com
To unsubscribe: http://listserv.ActiveState.com/mailman/mysubs

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


RE: Printing to Network Printer

2006-07-28 Thread Nichols, Ron
The selected printer is the default printer for my system.  I can print
from any other windows based application to the default printer.  I am
also set up as the local administrator on the system. 


Ronald G. Nichols
Director of Information Technology
Knouse Foods Cooperative, Inc.
[EMAIL PROTECTED]
(717) 677-8181 Ext. 3470
 

-Original Message-
From: [EMAIL PROTECTED]
[mailto:[EMAIL PROTECTED] On Behalf Of
Chris Wagner
Sent: Friday, July 28, 2006 9:33 AM
To: Perl-Win32-Users@listserv.ActiveState.com
Subject: Re: Printing to Network Printer

That sounds like the account the script is running as doesn't have print
permission on the print server.  Can u print a normal document?  Check
the permissions on the print share on the print server.





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

0100

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

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


Printing to Network Printer

2006-07-28 Thread Nichols, Ron
I have a PERL script that prints to a network printer on a Windows XP
Professional OS.  The script will be used on a variety of XP systems
with varying network printers as the default printer.  When I run the
code shown below:
 
#! perl -w
use strict;
 
my $port='9100';
my $default_printer='10.1.5.211';
 
open(OUTPUT_PRINTER,">$default_printer\\$port") || die "Unable to
open printer: $!\n";
print OUTPUT_PRINTER "This is a test Line\n";

 
I get the message:  Unable to open printer: Permission denied
 
I have turned off the firewall to see if that was causing the error but
get the same response.  I am hoping that someone has some ideas on how
to accomplish printing to the default printer.  

Your assistance is appreciated.
 
Ronald G. Nichols
Director of Information Technology
Knouse Foods Cooperative, Inc.
[EMAIL PROTECTED]  
(717) 677-8181 Ext. 3470
 
___
Perl-Win32-Users mailing list
Perl-Win32-Users@listserv.ActiveState.com
To unsubscribe: http://listserv.ActiveState.com/mailman/mysubs


Re: Tk

2006-04-13 Thread Ron Hartikka
use strict;use Tk;my $mw=MainWindow->new;$mw->title("TextArea");my $textBox=$mw->Scrolled("Text")->pack();$mw->Button(-text, "Store it", -background, "yellow", -foreground, "purple",
-command, sub{\&enterIt();})->pack();MainLoop;sub enterIt()   {my $enteredThis = $textBox->get("1.0", "end");   print "$enteredThis";   sleep(1);
   exit;   }On 4/13/06, Jerry Kassebaum <[EMAIL PROTECTED]> wrote:
Friends,I am attempting to enter some text in a Tk text area and send it to my(Windows ME) DOS window.
Below are two programs, the first with the text area, which doesn't work,and the second with a single-line text entry, which does work.#use strict;use Tk;my $mw=MainWindow->new;$mw->title("TextArea");
my $textBox=$mw->Scrolled("Text")->pack();my $enteredThis = $textBox->get("1.0", "end");$mw->Button(-text, "Store it", -background, "yellow", -foreground, "purple",
-command, sub{\&enterIt();})->pack();MainLoop;sub enterIt()   {print "$enteredThis";sleep(1);exit;}#The following works with a single-ine text-entry, but I can't seem to make
the leap to a text area:#use Tk;my $mw=MainWindow->new;$mw->title("Text Entry");$mw->Button(-text, "Enter", -foreground, "blue", -command, sub{print
"$author";})->pack(-side, "bottom", -expand, 1, -fill, 'none');$author=$mw->Entry(-width, 60, -textvariable, \$author)->pack;$author="";MainLoop;#
___Perl-Win32-Users mailing listPerl-Win32-Users@listserv.ActiveState.comTo unsubscribe: 
http://listserv.ActiveState.com/mailman/mysubs-- Ron Hartikka[EMAIL PROTECTED]
___
Perl-Win32-Users mailing list
Perl-Win32-Users@listserv.ActiveState.com
To unsubscribe: http://listserv.ActiveState.com/mailman/mysubs


Re: Error with $Response->Flush()

2002-09-26 Thread Ron Grabowski

> >And as you mentioned the 256 bytes most definetely need to be sent before
> >anything will flush.
> 
> It is actually Internet Explorer that needs to receive 256 bytes before
> displaying anything.  If you test your page with a different browser (like
> Mozilla), you'll see that the Flush() works with less data too.

How did you know that? Are quirks of IE and other Microsoft products
documented anywhere? I wouldn't know where to start in the MSDN.
___
Perl-Win32-Users mailing list
[EMAIL PROTECTED]
To unsubscribe: http://listserv.ActiveState.com/mailman/mysubs



Re: HTML::Parser question

2002-09-26 Thread Ron Grabowski

> use strict;
> use HTML::Parser 3.00 ();

Thank you for posting some HTML::Parser code. For as long as I've been
doing Perl I've only seen "real" HTML::Parser code a handful of times.
People are quick to say "just use HTML::Parser". If most people are
anything like me, I just end up using some regexs and a few substr()s to
hack out what I want. Its good to see people actually using such a
talked about module.
___
Perl-Win32-Users mailing list
[EMAIL PROTECTED]
To unsubscribe: http://listserv.ActiveState.com/mailman/mysubs



Re: perl module for 'clicking' links??

2002-09-04 Thread Ron Grabowski

T&C Winquist wrote:
> 
> I searched CPAN for a module that would emulate clicking a link on a web
> page.  Let's say I know that I want to click the link " href=r/fo>Photos" on yahoo's index page.  I would like a script that
> would emulate that click and load the resulting page into the web browser
> that calls the script.  It would load the actual page and not just a string
> version of the page.  This may be a bad example, but for some of my web
> automation applications, it is necessary.  Anyone ever seen such a module or
> script??  Thanks in advance!

Have you looking into creating an "InternetExplorer" ActiveX object and
using its Navigate() method?
___
Perl-Win32-Users mailing list
[EMAIL PROTECTED]
To unsubscribe: http://listserv.ActiveState.com/mailman/mysubs



Re: HTTP::Daemon -->Send client autoproxy?

2002-08-26 Thread Ron Grabowski

> How do I get the details of "HTTP::Headers=HASH(0x1c5d150)"?

What does Data::Dumper say?

 use Data::Dumper;
 print Dumper $r->headers;

Or just look at the keys:

 foreach my $key ( keys %{$r->headers} ) {
  print "$key => ", $r->headers->{$key}, "\n";
 }
___
Perl-Win32-Users mailing list
[EMAIL PROTECTED]
To unsubscribe: http://listserv.ActiveState.com/mailman/mysubs



Re: easy user input interface into Perl

2002-08-26 Thread Ron Grabowski

> > the "real/regular" program will then use for input. It asks the user
> > only two short text questions. Of course any of us would be quite happy

> 
> You could check out Win32::GUI (see HTML under .../html/lib/win32) or maybe
> use Tk as an alternative GUI interface - except it may not be installed
> on your target system.
> 

That's a lot of work for only two questions. Why not prompt the user
using STDIN:

 print 'Enter server: ';
 chomp(my $server = );
 print 'Enter login: ';
 chomp(my $login = );
___
Perl-Win32-Users mailing list
[EMAIL PROTECTED]
To unsubscribe: http://listserv.ActiveState.com/mailman/mysubs



Re: LWP and ASP Pages

2002-08-26 Thread Ron Grabowski

[EMAIL PROTECTED] wrote:
> 
> I'm trying to test to make sure my web site is up by connecting to the
> admin web page of my application.  The admin web page is an ASP page and
> whenever I set it up using:
> 
> use HTTP::Request;
> use LWP::UserAgent;
> 
> $filename  = D:\\temp\\msi.html";
> 
> $ua = LWP::UserAgent->new;
> $url = "http://webserver/admin.asp";;
> $req = new HTTP::Request (GET => $url);
> $res = $ua->request($req, $filename);
> if ($res->is_success) {
> print "Got response back from web page\n";
> } else {
> print "No response from web page.\n";
> exit;
> }
> 
> It always fails.  I can take the URL and plug it into a browser and it
> comes up just fine.  Any ideas???

What about adding this:

 use LWP::Debug qw(+);

to the top of the script. What lwp-request say from the command line?

 C:\>lwp-request http://webserver/admin.asp

According to this ( perldoc lwp::useragent ):

  The filename variant requires a scalar containing a filename as the
  second argument to request() and is suitable for large WWW objects
which
  need to be written directly to the file without requiring large
amounts
  of memory. In this case the response object returned from request()
will
  have an empty content attribute. If the request fails, then the
content
  might not be empty, and the file will be untouched.

You could check to make sure $res->content is empty for success and if
its not empty, report contents() as the error message:

 $res = $ua->request($req,$filename);
 if ($res->content) {
  print 'Error: ', $res->content;
 } else {
  print 'OK';
 }

I don't know why is_sucess() isn't working though.
___
Perl-Win32-Users mailing list
[EMAIL PROTECTED]
To unsubscribe: http://listserv.ActiveState.com/mailman/mysubs



Re: trying to understand how regex works

2002-08-12 Thread Ron Grabowski

> open FOUT, ">>/some/path/outputfile.txt";
> open FILE ">/some/path/outputfile.txt") or
 die("Error: $!");

open(FILE " while{
> p="N";
> next if (/.*?\|value_garbage1\|.*?/ ||
> /.*?\|value_garbage2\|.*?/ ||
> /.*?\|value_garbage3\|.*?/);

 my $regex = join '|', 'value_garbage1',
   'value_garbage2',
   'value_garbage3';

 next if /$regex/;

> if(/(.*?)\|(.*?)\|30 times/){
> $p="Y";
> do something to $1; #change field 1
> do something to $3; #change filed 3
> $fld1=$newfld1;
> $fld2=$2;
> $fld3=$newfld3;
> $fld4=$4;and so on
> }
> print FOUT "$fld1|$fld2|...|$fld30|\n" if ($p="Y");

If you put the print inside of the if(), you don't need $p. Look into
the join() function:

 print FOUT join '|', $fld1, $fld2, $fld3;
 print FOUT join '|', @array;
___
Perl-Win32-Users mailing list
[EMAIL PROTECTED]
To unsubscribe: http://listserv.ActiveState.com/mailman/mysubs



Re: How to do CDDB lookup via Win32 Perl?

2002-08-12 Thread Ron Grabowski

> I'm having the same problem as described in the following post.  Did anyone
> ever find a solution to this?

Read this post again:

 http://aspn.activestate.com/ASPN/Mail/Message/1312188

Download this file:

 http://www.freedb.org/software/cddbidgen.zip

Run this Perl code:

---
use strict;
use warnings;
use CDDB;

my $cddbp = new CDDB( Host  => 'freedb.freedb.org', # default
  Port  => 8880,# default
  Login => 'win32user',
# Debug => 1
) or die $!;

my $strTOC = getTOCinfo('G:');
   # getTOCinfo('E:');
   # getTOCinfo('1:0:0');
   # getTOCinfo('2:0:0');

if ( $strTOC ) {

  my(@array,$cddbp_id,$total_seconds,@track_offsets,@discs);
  @array = split ' ', $strTOC;
  $cddbp_id = $array[2];
  $total_seconds = $array[-1];
  push @track_offsets, $array[$_] for ( 4 .. $#array-1 );
  ## @track_offsets is not getting populated ???
  ## my($cddbp_id, $total_seconds, @track_offsets) =
  ## (split ' ',$strTOC)[2,-1,4..-2];
  @discs = $cddbp->get_discs($cddbp_id,\@track_offsets,$total_seconds);
  foreach my $disc (@discs) {
   ppDisc($cddbp,$disc);
  }

}

#===
sub ppDisc {
#===
  my($cddbp,$disc) = @_;
  my($genre,$cddbp_id,$title) = @$disc;
  my $disc_info = $cddbp->get_disc_details($genre,$cddbp_id);
  my @track_titles = @{$disc_info->{ttitles}};
  print $title, "\n", "=" x length($title), "\n";
  printf("%02d - %s\n", $_, $track_titles[$_]) for ( 1 ..
@track_titles-1 );
} # end sub

#===
sub getTOCinfo {
#===
  my($device) = @_;
  my($buf,$result);
  unless ( $device =~ /\w:|\d:\d:\d/ ) {
print STDERR 'Error: misformed drive letter or device';
return undef;
  }
  $buf = `cddbidgen.exe`;
  ($result) = ($buf =~ /^.*".*?$device.*?".*?(cddb
query.*?)\s+?[A-Z]/s);
  if ( $result ) {
$result =~ s/\n//; # ???
  } else {
print STDERR "Error: could not produce cddb query string for
[$device]";
  }
  return $result;
} # end sub
---

It successfully produced output for two test cds ( one of them being a
CD-EXTRA disc ):

Counting Crows / Hard Candy
===
01 - American Girls
02 - Good Time
03 - If I Could Give All My Love -or- Richard Manuel Is Dead
04 - Goodnight L.A.
05 - Butterfly In Reverese
06 - Miami
07 - New Frontier
08 - Carriage
09 - Black And Blue
10 - Why Should You Come When I Call?
11 - Up All Night (Frankie Miller Goes To Hollywood)
12 - Holiday In Spain

Counting Crows / Across A Wire - Live In NYC (From The Ten Spot)(CD 2)
==
01 - Angels Of The Silences
02 - Rain King
03 - Sullivan Street
04 - Children In Bloom
05 - Have You Seen Me Lately?
06 - Raining In Baltimore
07 - Round Here
08 - I'm Not Sleeping
09 - A Murder Of One
10 - A Long December
11 - Walkaways

Note that you can use a drive letter or a device name. You'll need to
press "any key" to continue after cddbidgen.exe gets the TOC
information. I tried using IPC::Open2 to read/write to the program but I
couldn't get it to work. Anyone know how to read input from an external
program then press a key to make it exit? The source code for
cddbidgen.exe is available so I'd just as well comment out that line and
recompile.

I couldn't figure out why this was failing:

 my($cddbp_id, $total_seconds, @track_offsets) = 
   (split ' ',$strTOC)[2,-1,4..-2];

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



Re: problem with djgpp/perl

2002-07-26 Thread Ron Grabowski

> 1. I downloaded perl542b.zip and csdpmi5b.zip

"This is a MSDOS/DJGPP port of perl 5.004_02.". The file dates to 1997.
There have been many major revisions to Perl in the last 5+ years.

> Can't locate Socket.pm in @INC (@INC contains: C:\PERL\LIB\PERL5

Socket.pm has been a core ( i.e. it comes installed with every version
of Perl ) for quite some time. I suggest going to:

 http://www.activestate.com

and installing ActivePerl.

> Do you have any idea why?

Why are you wanting to use such an outdated version of Perl in the first
place?
___
Perl-Win32-Users mailing list
[EMAIL PROTECTED]
To unsubscribe: http://listserv.ActiveState.com/mailman/mysubs



Re: Split function

2002-07-15 Thread Ron Grabowski

> Would it be only semantic to escape the semicolon, or could it cause a
> problem not to do so? I'm not asking to be picky, I really don't know. :)

The semi-colon is not special unless you do something like this:

 m;foo|bar|\;;
___
Perl-Win32-Users mailing list
[EMAIL PROTECTED]
To unsubscribe: http://listserv.ActiveState.com/mailman/mysubs



Re: Split function

2002-07-15 Thread Ron Grabowski

> I would like to split on either a double dash or a semi colon with one
> split using ( | ).

$_ = 'Hello-world;how--are--you;today';

print join "\n", split /--|;/;
___
Perl-Win32-Users mailing list
[EMAIL PROTECTED]
To unsubscribe: http://listserv.ActiveState.com/mailman/mysubs



Re: Reading from a form

2002-07-09 Thread Ron Grabowski

> my $q = new CGI;
> ##
> # Get the input
> read(STDIN, $buffer, $ENV{'CONTENT_LENGTH'});
> 
> # Split the name-value pairs
> @pairs = split(/&/, $buffer);
> 
> foreach $pair (@pairs) {
>($name, $value) = split(/=/, $pair);
> 
>$value =~ tr/+/ /;
>$value =~ s/%([a-fA-F0-9][a-fA-F0-9])/pack("C", hex($1))/eg;
>$value =~ s/<([^>]|\n)*>//g;
>$value =~ s/$value =~ s/>//g;
>$FORM{$name} = $value; #line 21
> }
>  $url = $FORM{'url'};   #line 23

Are you comfortable enough with Perl to know what all of those lines do?
Since you are already using the CGI module, why not let that do all the
work for you in these two lines:

 use CGI qw/:standard/;
 my $url = param('url');

> #THIS OPENS THE HTML FILE
> 
> use LWP;
> my $pagecontent;
> 
> my $ua = LWP::UserAgent->new;
> my $request = HTTP::Request->new('GET', $url);
> my $response = $ua->request($request);
> 
> if ( $response->is_success()){
>   $pagecontent = $response->content() ;
> }else {
>   my $rc = $response->code();
>   die "Error Occured with response code $rc";
> }

LWP::Simple might make things easier too.

What happens when someone submits the form with the form variable 'url'
set to:

 file://c:/password.txt
 file://d:/network_drive/secret.txt
___
Perl-Win32-Users mailing list
[EMAIL PROTECTED]
To unsubscribe: http://listserv.ActiveState.com/mailman/mysubs



Re: Is there a LPR Module

2002-07-05 Thread Ron Grabowski

> PS I would settle for a free command line as well.

 http://www.weihenstephan.de/~syring/win32/UnxUtils.html
___
Perl-Win32-Users mailing list
[EMAIL PROTECTED]
To unsubscribe: http://listserv.ActiveState.com/mailman/mysubs



Re: If..else scope problem?

2002-06-13 Thread Ron Grabowski

> Here's a revised version of your code.  It puts the data into a hash, whence
> you can retrieve it in any order you like (the output line at the end is
> just an example of one way).

I just put everything into the hash and dealt with it later:

---
use strict;
use warnings;
use vars qw(%H);

while (  ) {
  chomp;
  if ( m## .. m## ) {
   s#]*)>##g or next;
   $H{$1} = $_;
  }
}

$H{DatumValute} =~ s/()(..)(..)/$3.$2.$1/;
$H{Iznos} = ($H{Oznaka} eq 'D' ? '-' : '+') . $H{Iznos};

printf("%-16s%-16s%-24s%-s",
  @H{qw|DatumValute Naziv Svrha Iznos|});

__DATA__

0102017910001874
20020409
20020409
MEDICOM D.O.O.
2484008
1100342506
00
PLACANJE FAKTURE

00
17-020305


99



P
2712,06


---

09.04.2002  MEDICOM D.O.O.  PLACANJE FAKTURE+2712,06

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



Re: Autocompletion in Perl ( Win 32 )

2002-06-11 Thread Ron Pero

For a different approach to this (if I understand what you are after), in
the archives of this list, see the thread, "Not so silly DOS question"
which started August 24, 2001.
It is about how to make the tab key do autocompletes in a command line window.

At 09:15 AM 06/07/02 +0530, [EMAIL PROTECTED] wrote:
>Dear Carl,
>I can do this in UNIX ( using Perl). But now i want the
Windows eqvt perl  module.
>Please see the following code ( that i used for UNIX ).
>
>
>UNIX - Perl CODE:
>
>
>use Term::Complete ;
>@completion_list = ("Pons","arunram");
>$input = Complete('prompt_string', \@completion_list);
>print "$input \n";
>
>
>Expecting  your wishes,
>Pons.
>
>Ponnambalam. M.A.
>Philips Medical Systems,
>Philips Innovation Campus,
>#1,Murphy Road, Ulsoor.
>Bangalore - 560008. INDIA
>Phone : +91- 080 - 557 9000 Extn: 1013
>E-mail: [EMAIL PROTECTED]
>
>
>
>
   
>  Carl Jolley <[EMAIL PROTECTED]>
   
>  Sent by: To:
 "Dirk Bremer (NISC)" <[EMAIL PROTECTED]>
>  [EMAIL PROTECTED] cc:
 "'Perl Win32 Users Mailing List'" 
>  veState.com
<[EMAIL PROTECTED]>  
>
(bcc: Ponnam Balam/BTC/MS/PHILIPS)
>
Subject:   Re: How can we implement escape sequences in Perl ( Win 32 )
   
>  06/07/02 02:09 AM
   
>
Classification:
   
>
   
>
   
>
>
>
>
>On Thu, 6 Jun 2002, Dirk Bremer (NISC) wrote:
>
>> I am surpassed that no one has told you that this is not a Perl-related
>> question. But I won't tell you that, I will tell you to go to
>> www.microsoft.com and search the knowledge base for article Q244407. There
>> are also several utilities that can do this for you, including TweakUI,
also
>> on the Microsoft site. How's the weather in Bangalore?
>>
>
>It's only "not perl-related" if it can't be done with perl. (:-D)
>
> [EMAIL PROTECTED] 
> All opinions are my own and not necessarily those of my employer 
>k
>
>___
>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
>
___
Perl-Win32-Users mailing list
[EMAIL PROTECTED]
To unsubscribe: http://listserv.ActiveState.com/mailman/mysubs



Re: Win32::IPROC or some other 'ps'

2002-06-10 Thread Ron Grabowski

> I've looked in the 'usual' spot (http://www.generation.net/~aminer/Perl/)

There doesn't appear to be anything on that website.

> Otherwise, can any suggest the best way to get a process listing on a
> Win2000 box via perl?

I have a better script someplace but maybe this will do for the time
being:

 http://www.roth.net/perl/scripts/scripts.asp?ProcList.pl

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



Re: HTML in E-mail

2002-06-05 Thread Ron Grabowski

> that somebody would actually get annoyed by the format of an e-mail.

Sometimes when people use a client like Outlook, I'm unable to quote
their message in my response. I don't think changing the font color to a
pretty shade of blue or a non-standard Times New Roman font really adds
anything. It gets annoying when people start sending you mail in green,
red, blue, etc. colored text all with different fonts that may or may
not render correctly.
___
Perl-Win32-Users mailing list
[EMAIL PROTECTED]
To unsubscribe: http://listserv.ActiveState.com/mailman/mysubs



Re: How can we implement escape sequences in Perl ( Win 32 )

2002-06-05 Thread Ron Grabowski

>   I would like to implement the escape sequences like ( if the value 
>is "Perl",  

I'm not sure what you are asking.

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



Re: Using both 'Benchmark' and 'strict'

2002-06-03 Thread Ron Grabowski

> Is there a simpler way ?

---
use strict;
use Benchmark;

timethese (-1, {
one => 'my @one = (1..10);
my @two = (11..20);
scalar(@one);',
two => 'my @one = (1..10);
my @two = (11..20);
scalar(@two), "\n";'
});
---

Benchmark: running one, two, each for at least 1 CPU seconds...
   one:  1 wallclock secs ( 1.05 usr +  0.00 sys =  1.05 CPU) @
191443.39/s
(n=201207)
   two:  1 wallclock secs ( 1.06 usr +  0.00 sys =  1.06 CPU) @
190574.39/s
(n=202390)
___
Perl-Win32-Users mailing list
[EMAIL PROTECTED]
To unsubscribe: http://listserv.ActiveState.com/mailman/mysubs



Re: Text::CSV and empty fields ???

2002-06-01 Thread Ron Grabowski

"Michael D. Schleif" wrote:
> 
> When I do this:
> 
> if ($csv->parse($_)) {
> @array = $csv->fields;
> }
> print scalar @array, "\n";
> 
> I get various values, because some fields in the CSV file are empty.
> 
> What I want to do is get an array with empty fields, as required.

Doesn't the module do that already?

---
use strict;
use warnings;
use Text::CSV;
use Data::Dumper;

my $csv = Text::CSV->new();

my $line = 'hello,world,how,,are,you,,today';

if  ( $csv->parse($line) ) {
  print Dumper [ $csv->fields() ];
}
---

$VAR1 = [
  'hello',
  'world',
  'how',
  '',
  'are',
  'you',
  '',
  'today'
];
___
Perl-Win32-Users mailing list
[EMAIL PROTECTED]
To unsubscribe: http://listserv.ActiveState.com/mailman/mysubs



Re: comparing two arrays

2002-05-30 Thread Ron Grabowski

[EMAIL PROTECTED] wrote:
> 
> I have two string arrays (say ar1 and ar2) and I would like to compare
> them
> to find out all the strings in ar1 that do not exist in ar2. What's
> the fastest and
> most efficient way to do that? I know I can use a couple of
> for/foreach
> but I am hoping that there is a more efficient way to do that.

What's wrong with the for() loops? At some point you're going to have to
look at the elements to see if they are equal or not.

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



Re: Generating random numbers?

2002-05-28 Thread Ron Grabowski

> I have seen a few ok random number generator snippets but none really look
> like they work too well. Take the two below arrays.

 http://search.cpan.org/search?mode=module&query=random

Some modules that may be of interest:

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



Re: Set::Object

2002-05-27 Thread Ron Grabowski

> I think it's just a matter of:
> my $s = Set::Object->new(['a','b']);

That did it. Thank you.

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



Re: IE/OLE - properties & methods questions

2002-05-24 Thread Ron Grabowski

> 3) Instead of using Navigate to get a URL or file, can I use HTML
> that's stored in a scalar in my source code? Can you set the Document
> to an html string?
> 
> my $ie = WIn32::OLE->new('InternetExplorer.Application') or die 'Can't
> create instance of IE';
> 
> my $html =
> 'TestTest';
> # Now can I do something like (both of which don't work)
> $ie->Document = $html;
> #or
> $ie->Document->{body} = $html;

Try navigating to 'about':

 # untested
 $ie->Navigate("about:hello%20world");

Be careful because you can only send so much HTML that way. Longer pages
will have to be sent loaded via file://
___
Perl-Win32-Users mailing list
[EMAIL PROTECTED]
To unsubscribe: http://listserv.ActiveState.com/mailman/mysubs



Re: Problem with win32::OLE - please check this out

2002-05-24 Thread Ron Grabowski

I like to add this to Chuck's response:

I recall reading someplace that many of the larger MS applications (
i.e. Word, Excel ) are not suitable to act as OLE servers in a
production environment such as a webserver. I don't know if this applies
to Outlook. I'll try to look on Google for where I read about that.

> eval {$OL= Win32::OLE->GetActiveObject('Outlook.Application')};

One of the benefits of using eval() comes from being able to check $@
for errors:

 eval {$OL= Win32::OLE->GetActiveObject('Outlook.Application')}; 
 warn $@ if $@;

I think seeing this would be more common:

 $OL = Win32::OLE->GetActiveObject('Outlook.Application')
   || Win32::OLE->new('Outlook.Application', 'Quit') unless $OL;
___
Perl-Win32-Users mailing list
[EMAIL PROTECTED]
To unsubscribe: http://listserv.ActiveState.com/mailman/mysubs



Re: Regex matching pairs?

2002-05-23 Thread Ron Grabowski

---
use strict;
use Text::Balanced qw(extract_bracketed);
my $text = '{\f2\fs20 Da biste }{\cs6\f1\cf6\lang
\{#}RES_ID{\cs6\f1\cf6\lang #\}} odaberite';
my($extracted, $remainder) = extract_bracketed($text,'{}');
print "$extracted\n$remainder\n";
print(($extracted =~ /^{.*?\s(.*)\s}$/));
---

{\f2\fs20 Da biste }
{\cs6\f1\cf6\lang \{#}RES_ID{\cs6\f1\cf6\lang #\}} odaberite
Da biste

If there are multiple \fs2 things on a line, you should be able to loop
through either $extracted or $remainder to find then and extract the
string.

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



Re: FAQ

2002-05-22 Thread Ron Grabowski

> Yup - a decent faq and a reminder work rather well for most FAQ's  assuming
> the users read some emails before posting and didn't subscribe just to ask a
> question. An auto-responder would be unpopular and put new users off, as

I don't think there is a need for Yet-Another-FAQ. I think people need
to put a little bit of effort into looking for answers to their
questions before posting. My favorite is when people ( who presumedly
haven't been using Perl for more than a few weeks ) declare they might
have found a bug in some common function that people have been using
since 1987(so says -v). I am referring to the popular "$mon from
localtime is off by one month, is this a bug in Perl?". I think if
people would:

 read a few chapters in any Perl book
 search perldoc -f
 search perldoc -q
 search CPAN
 search google
 search list archives

instead of doing nothing not only will the need for a FAQ might be
diminished, but people might find answers quicker. For example if I
wanted to do something with dates, a good place to look might be to look
on CPAN in the Date:: catagory. Most answers to questions can found by
appending the world 'perl' to the subject line and searching that string
on Google.
___
Perl-Win32-Users mailing list
[EMAIL PROTECTED]
To unsubscribe: http://listserv.ActiveState.com/mailman/mysubs



Re: HOWTO: break up a directory path name into components ...

2002-05-16 Thread Ron Grabowski

> I have a subroutine "splitFilename" that I wrote that does this for
> me.  It's been enhanced over time to include support for UNC, but this
> is the meat of that subroutine that handles directory/path/filename
> strings:

Not to be a wet blanket, but isn't File::Basename part of the core? I
looked in Basename.pm and file/directory name parsing has been somewhat
standardized in Perl since 1996.

> ($file_d, $file_p_tl, $file_p, $file_f, $file_e) = m#^[\\/][\\/]#
> ? m#^([\\/][\\/][^\\/]+[\\/]) (([\\/][^\\/]+)*[\\/]) (.*?)
> ((\.[^.]+)*)$#x
> : m#^([a-z]:) (([\\/][^\\/]+)*[\\/]) (.*?) ((\.[^.]+)*)$#ix;

Not having looked at that in too much detail, Basename.pm basically
gives this for Win32 systems:

 ($dirpath,$basename) = (/^(.*[:>\]])?(.*)/s)
___
Perl-Win32-Users mailing list
[EMAIL PROTECTED]
To unsubscribe: http://listserv.ActiveState.com/mailman/mysubs



Re: connecting via perl to mysql on another windows 2000 box -

2002-05-16 Thread Ron Grabowski

> Here is the situation.  I have to connect to Mysql running on another
> windows 2000 box.  I have never done this before. Do I set this up in the
> tables as another
> host and use the -h parm in command shell and the host parm in my perl
> scripts? or is there another way to do it?

What happens when you simple tell the script the machine name of where
the mysql server resides as per the DBI documentation:

---
  DBI Class Methods

The following methods are provided by the DBI class:

"connect"
  $dbh = DBI->connect($data_source, $username, $password)
or die $DBI::errstr;
  $dbh = DBI->connect($data_source, $username, $password,
\%attr)
or die $DBI::errstr;

[snip]

Examples of "$data_source" values are:

  dbi:DriverName:database_name
  dbi:DriverName:database_name@hostname:port
  dbi:DriverName:database=database_name;host=hostname;port=port
---
___
Perl-Win32-Users mailing list
[EMAIL PROTECTED]
To unsubscribe: http://listserv.ActiveState.com/mailman/mysubs



Re: More or Pager function is Perl

2002-05-16 Thread Ron Grabowski

> This is what I use in a program that mimics the Unix head command:

 http://www.perl.com/language/ppt/src/head/
___
Perl-Win32-Users mailing list
[EMAIL PROTECTED]
To unsubscribe: http://listserv.ActiveState.com/mailman/mysubs



RE: initializing an array of 'records'

2002-03-18 Thread Ron Hartikka

If you...

@the_data = ();

... then @the_data will be empty.

Is that what you want?

(When you say, "...clear everything out - reinitialize it so it is
'fresh'.", you have failed to say what you want in 3 different ways.)

Ron


> -Original Message-
> From: [EMAIL PROTECTED]
> [mailto:[EMAIL PROTECTED]]On Behalf Of
> Andrew Wax
> Sent: Monday, March 18, 2002 8:51 AM
> To: [EMAIL PROTECTED]
> Subject: initializing an array of 'records'
>
>
> Good Morning -
>
> I think this is (one of) the last question(s) - I have the following
> structure -
> $the_data[$datapointcnt] =
> {
> x => $maturity_range_counter,
> y =>
> $maturity[$maturity_range_counter][$maturity_detail_counter] -> {oas},
> rating =>
> $maturity[$maturity_range_counter][$maturity_detail_counter] -> {rating},
> }
>
> I use this structure for several different (sequential and mutually
> exclusive) iterations - between each use (iteration) I would like
> to
> Reason being -
> I sort the information and it works perfectly (almost).  When Iteration
> 'n+1' has fewer elements than iteration 'n' the old information from nth
> iteration shows up in the output - which leads me to believe the
> information
> is still hidden in the array.
>
> (if I do not sort it - I know how many elements I have placed -and can
> control the output when I dump the data  and know the data that I
> am placing
> is good)
>
> Any ideas how to purge the old information would be appreciated.
>
> Andrew
>
> ___
> 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: Q: How to sort Array of Hashes

2002-01-29 Thread Ron Hartikka

For these...

> : sub schwartz{
> : @ordered = ();
> : return @ordered = map { $_->[2] }
> :sort { $b->[0] <=> $a->[0] || $a->[1] cmp $b->[1]}
> :map { [$_->{'SIZE'}, $_->{'NAME'}, $_] }
> :@A_of_H;
> : }
> :
> : sub no_schwartz{
> : @ordered = ();
> : return @ordered = sort {
>   $b->{'SIZE'} <=> $a->{'SIZE'} ||
>   $a->{'NAME'} cmp $b->{'NAME'}
>   } @A_of_H;
> : }


...well, files are rarely the same size, so second comparison rarely
executed due to short circuit...

Benchmark: timing 1000 iterations of no_schwartz, schwartz...
no_schwartz:  7 wallclock secs ( 7.33 usr +  0.00 sys =  7.33 CPU) @
136.43/s (n=1000)
  schwartz: 10 wallclock secs ( 9.68 usr +  0.00 sys =  9.68 CPU) @ 103.26/s
(n=1000)


doing C:\WINNT\SYSTEM32 which has 2003 files

Benchmark: timing 1000 iterations of no_schwartz, schwartz...
no_schwartz: 56 wallclock secs (55.52 usr +  0.00 sys = 55.52 CPU) @ 18.01/s
(n=1000)
  schwartz: 66 wallclock secs (65.42 usr +  0.00 sys = 65.42 CPU) @ 15.28/s
(n=1000)

...I did this, though...

sub schwartz{
@ordered = ();
return @ordered = map { $_->[1] }
   sort { ($a->[0] + $a->[0] ) <=> ($b->[0] + $b->[0] ) }
   map { [$_->{'SIZE'}, $_] }
   @A_of_H;
}

sub no_schwartz{
@ordered = ();
return @ordered = sort { ($b->{'SIZE'} + $b->{'SIZE'}  )  <=> (
$a->{'SIZE'} + $a->{'SIZE'}  ) } @A_of_H;

}

...and got this...

doing C:\data\perl\programexamples which has 479 files

Benchmark: timing 1000 iterations of no_schwartz, schwartz...
no_schwartz: 12 wallclock secs (11.90 usr +  0.00 sys = 11.90 CPU) @ 84.05/s
(n=1000)
  schwartz: 12 wallclock secs (11.98 usr +  0.00 sys = 11.98 CPU) @ 83.49/s
(n=1000)


doing C:\WINNT\SYSTEM32 which has 2003 files

Benchmark: timing 1000 iterations of no_schwartz, schwartz...
no_schwartz: 75 wallclock secs (74.38 usr +  0.00 sys = 74.38 CPU) @ 13.45/s
(n=1000)
  schwartz: 68 wallclock secs (68.17 usr +  0.00 sys = 68.17 CPU) @ 14.67/s
(n=1000)

... ST pulls ahead when the comparision is more expensive.


> -----Original Message-
> From: [EMAIL PROTECTED]
> [mailto:[EMAIL PROTECTED]]On Behalf Of
> Joseph P. Discenza
> Sent: Tuesday, January 29, 2002 2:54 PM
> To: Ron Hartikka; [EMAIL PROTECTED]
> Subject: RE: Q: How to sort Array of Hashes
>
>
> Ron Hartikka wrote, on Tuesday, January 29, 2002 2:40 PM
> : Unless I've been unfair, for small dirs, no_shwartz wins; for big dirs
> : (~3000 files?), schwartz wins.
> : Looks like you want to reserve schwartz for where calculating
> the value to
> : sort by is more expensive than a hash lookup or where you have more than
> : ~3000 elements elements.
> :
> : Maybe somebody could make a dir with 3000 files an verify?
>
> Ron, you da man! As long as I'm wasting your workday, Tom actually
> suggested adding a 'NAME' comparand to discriminate between files of
> identical size.
>
> Want to try it with
>
> : sub schwartz{
> : @ordered = ();
> : return @ordered = map { $_->[2] }
> :sort { $b->[0] <=> $a->[0] || $a->[1] cmp $b->[1]}
> :map { [$_->{'SIZE'}, $_->{'NAME'}, $_] }
> :@A_of_H;
> : }
> :
> : sub no_schwartz{
> : @ordered = ();
> : return @ordered = sort {
>   $b->{'SIZE'} <=> $a->{'SIZE'} ||
>   $a->{'NAME'} cmp $b->{'NAME'}
>   } @A_of_H;
> : }
>
> and see what happens? I think adding comparands will decrease the
> difference between the two methods.
>
> Joe
>
> ==
>   Joseph P. Discenza, Sr. Programmer/Analyst
>mailto:[EMAIL PROTECTED]
>
>   Carleton Inc.   http://www.carletoninc.com
>   219.243.6040 ext. 300fax: 219.243.6060
>
> Providing Financial Solutions and Compliance for over 30 Years
>
>
> ___
> Perl-Win32-Users mailing list
> [EMAIL PROTECTED]
> To unsubscribe:
http://listserv.ActiveState.com/mailman/listinfo/perl-win32-users



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



RE: Q: How to sort Array of Hashes

2002-01-29 Thread Ron Hartikka

Unless I've been unfair, for small dirs, no_shwartz wins; for big dirs
(~3000 files?), schwartz wins.
Looks like you want to reserve schwartz for where calculating the value to
sort by is more expensive than a hash lookup or where you have more than
~3000 elements elements.

Maybe somebody could make a dir with 3000 files an verify?

I didn't find a dir big enough to prove it but you can see the trend:

123.58 / 150.85 = 0.819 # schwartz is 82% as fast on 475 files
21.88  /  23.20 = 0.943 # schwartz is 94% as fast on 2003 files

** output

doing C:\data\perl\programexamples which has 475 files

Benchmark: timing 1000 iterations of no_schwartz, schwartz...
no_schwartz:  7 wallclock secs ( 6.63 usr +  0.00 sys =  6.63 CPU) @
150.85/s (n=1000)
  schwartz:  8 wallclock secs ( 8.09 usr +  0.00 sys =  8.09 CPU) @ 123.58/s
(n=1000)


doing C:\WINNT\SYSTEM32 which has 2003 files

Benchmark: timing 1000 iterations of no_schwartz, schwartz...
no_schwartz: 44 wallclock secs (43.10 usr +  0.00 sys = 43.10 CPU) @ 23.20/s
(n=1000)
  schwartz: 45 wallclock secs (45.71 usr +  0.00 sys = 45.71 CPU) @ 21.88/s
(n=1000)

*** code

use strict;
use Benchmark;

$|=1;

our @ordered;
our @A_of_H;
our $i;
our @files;

for my $dir ('C:\data\perl\programexamples', 'C:\WINNT\SYSTEM32'){

@files = ();
opendir(DIR, $dir) || die "can’t opendir $dir: $!";
(@files = readdir(DIR))  || die "can't readdir: $!";
closedir DIR;
print "\n\ndoing $dir which has $#files files \n\n";

$i = 0;
@A_of_H = ();

for my $file (@files){
#next unless defined $size;
my
($dev,$ino,$mode,$nlink,$uid,$gid,$rdev,$size,$atime,$mtime,$ctime,$blksize,
$blocks)= stat("$dir\\$file");
$A_of_H[$i]{'FILE'} = $file;
$A_of_H[$i]{'SIZE'} = $size;
$A_of_H[$i]{'DATE'} = $ctime;
$i++;
}

timethese(1000, {
'schwartz' => sub{schwartz()},
'no_schwartz' => sub{no_schwartz()}
}
);

}



sub schwartz{
@ordered = ();
return @ordered = map { $_->[1] }
   sort { $a->[0] <=> $b->[0] }
   map { [$_->{'SIZE'}, $_] }
   @A_of_H;
}

sub no_schwartz{
@ordered = ();
return @ordered = sort {$b->{'SIZE'} <=> $a->{'SIZE'}} @A_of_H;

}

> -Original Message-
> From: [EMAIL PROTECTED]
> [mailto:[EMAIL PROTECTED]]On Behalf Of
> Morse, Richard E.
> Sent: Tuesday, January 29, 2002 2:14 PM
> To: 'Thomas R Wyant_III'; [EMAIL PROTECTED]
> Subject: RE: Q: How to sort Array of Hashes
>
>
> Okay, I'll bite.
>
> Orcish manouver?
>
> Ricky
>
> -Original Message-
> From: Thomas R Wyant_III [mailto:[EMAIL PROTECTED]]
> Sent: Tuesday 29 January 2002 2:07 PM
> To: [EMAIL PROTECTED]
> Subject: RE: Q: How to sort Array of Hashes
>
>
>
> <[EMAIL PROTECTED]> wrote
>
>
>
> 
>
> > Do you think we can impose upon our Original Poster to run some
> > benchmarking on his live data?
>
> Honestly, no. We could try, but since we're just mailing addresses to each
> other, I doubt we have anything to impose _with_. But if he
> wishes to do it
> and publish, I for one would welcome the information.
>
> My personal approach to just about any code is to do it the dumb
> way first,
> and tweak it if it isn't up to snuff. There are people who, no matter how
> many cycles they have at their disposal, grudge every one. But I figure
> that these days wetware cycles are generally more expensive than hardware
> cycles. Some benchmark data would tell us where spending a few wetware
> cycles is worthwhile.
>
> I have yet to use the Schwartzian transform, I merely pulled it in for
> completeness in my answer. The REALLY short answer to the
> Original Poster's
> question was "RTFM". But I wanted to couch this in the more
> humane terms of
> "Here's how you get started, and here's where you go for more
> information",
> and the Schwartzian transform was my hook for the second half.
>
> If only I could have found a way to bring in the Orcish maneuver, which I
> _do_ use, and which has a _much_ cooler name.
>
> Tom Wyant
>
> ___
> Perl-Win32-Users mailing list
> [EMAIL PROTECTED]
> To unsubscribe:
> http://listserv.ActiveState.com/mailman/listinfo/perl-win32-users
> ___
> Perl-Win32-Users mailing list
> [EMAIL PROTECTED]
> To unsubscribe:
> http://listserv.ActiveState.com/mailman/listinfo/perl-win32-users
>
>


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



RE: How to sort Array of Hashes

2002-01-29 Thread Ron Hartikka

This is tested. Perl Cookbook Recipe 4.15. Sorting a List by Computable
Field
The date from stat is probably not what you want.
-

my $dir = 'C:\data\perl\programexamples';   change to your
dir
$|=1;
opendir(DIR, $dir) || die "can’t opendir $dir: $!";
my @files = readdir(DIR);
closedir DIR;

my @A_of_H;
my $i = 0;

for my $file (@files){
my
($dev,$ino,$mode,$nlink,$uid,$gid,$rdev,$size,$atime,$mtime,$ctime,$blksize,
$blocks)= stat($file);
$A_of_H[$i]{'FILE'} = $file;
$A_of_H[$i]{'SIZE'}  = $size;
$A_of_H[$i]{'DATE'} = $ctime;
$i++;
}

@ordered = map { $_->[1] }
   sort { $a->[0] <=> $b->[0] }
   map { [compute($_), $_] }
   @A_of_H;

for (@ordered){
print "$_->{'SIZE'}:\t $_->{'FILE'}\t$_->{'DATE'}\n";

}

sub  compute{
my $hash_ref = shift;
my $size = $hash_ref->{'SIZE'};
return $size;

}
> -Original Message-
> From: [EMAIL PROTECTED]
> [mailto:[EMAIL PROTECTED]]On Behalf Of
> John Draper
> Sent: Tuesday, January 29, 2002 9:23 AM
> To: [EMAIL PROTECTED]
> Subject: Q: How to sort Array of Hashes
>
>
> Hi,
>
> I would like to know how to sort an array of hashes based on one of the
> values from one of it's keys.
>
> Specifially, I have a structure like this:
>
> my @A_of_H;
> my $i = 0;
>
> some looping mechanism starts here which populates $file, $size and $date:
>$A_of_H[$i]{'FILE'} = $file;
>$A_of_H[$i]{'SIZE'} = $size;;
>$A_of_H[$i]{'DATE'} = $date;
>$i++;
> end of loop..
>
> I would like to sort @A_of_H based on 'SIZE', i.e.,
> A_of_H[$i]{'SIZE'} from
> largest to smallest.
>
> How does one do this in Perl. I know how to do it for 'pure' arrays or
> hashes, but not an array of hashes. Any help would be appreciated.
>
> Thanks,
>
> John
>
> ___
> Perl-Win32-Users mailing list
> [EMAIL PROTECTED]
> To unsubscribe:
http://listserv.ActiveState.com/mailman/listinfo/perl-win32-users



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



RE: (no subject)

2002-01-21 Thread Ron Hartikka



try 
$counter->update;
after
$counter->configure(-text=>$i);
 
My guess is 
you are going to want to look at Tk's 'after' method.
 

  -Original Message-From: 
  [EMAIL PROTECTED] 
  [mailto:[EMAIL PROTECTED]]On Behalf Of 
  robozSent: Monday, January 21, 2002 11:01 AMTo: 
  [EMAIL PROTECTED]; [EMAIL PROTECTED]; 
  [EMAIL PROTECTED]; 
  [EMAIL PROTECTED]; 
  [EMAIL PROTECTED]; perl-win32-web@listserv. 
  ActiveState. com EE-mail"; 
  [EMAIL PROTECTED]Subject: (no 
  subject)
  Hi All,
   
      Please help me! 
  Why doesn't the counter label count in real time in my Tcl/tk Perl 
  script, though I configure the '$counter' label at all changes 
  of  the "$i" variable.
   
  Thanks: R. 
  Beci   
   
  
  
  
  #!/usr/bin/perl -w
   
  use strict;use Tk;$|=1;
   
  # Create main windowmy $main = 
  MainWindow->new;
   
  # Add a Label and a Button to main 
  window$main->Button( -text => 'Start', -command 
  => sub {progress()} )->pack;
   
  my 
  $counter=$main->Label( -text=>"0" )->pack();
   
  # Spin the message loopMainLoop;
   
  sub progress { for my $i (0..15) 
  {  sleep(1);  $counter->configure(-text=>$i); }}
  
  
  


RE: problem with eval

2002-01-15 Thread Ron Hartikka



No, I don't think 
do('file.pl') is called for, because the op states he only wants only some 
of the lines from the file.
 
Of course, he could _put_ 
these lines in another file and do('_that_'). Might even solve his 
problem. It would really help to see the code and know what is allowed in all 
such code.
 
From perlfaq8,  
"What‘s the difference between require and use?":
 
do $file is like eval ‘cat $file‘, except the 
former:
    
1.1: searches @INC and updates %INC.
    
1.2: bequeaths an *unrelated* lexical scope on the eval’ed 
code.
 
Please. Post in 
plain text. Ugh.

  -Original Message-From: 
  [EMAIL PROTECTED] 
  [mailto:[EMAIL PROTECTED]]On Behalf Of 
  Venkataramana MokkapatiSent: Tuesday, January 15, 2002 9:16 
  AMTo: Ron Hartikka; thiyag; perl-win32-users Mailing 
  ListSubject: Re: problem with eval
  do('file.pl')
   
  
    - Original Message -
From: Ron 
Hartikka
Sent: Tuesday, January 15, 2002 5:50 
AM
To: thiyag; perl-win32-users Mailing 
List
Subject: RE: problem with eval
 

Seems like a 
hard way to program! But, maybe it's right for your 
situation.
 
Please post 
more if you can.
What do you 
mean by "it didn't work"?
Try printing 
the values returned by eval() - undefined value message indicates bad 
code.
 
 

  -Original Message-From: 
  [EMAIL PROTECTED] 
  [mailto:[EMAIL PROTECTED]]On Behalf Of 
  thiyagSent: Tuesday, January 15, 2002 5:41 AMTo: 
  perl-win32-users Mailing ListSubject: problem with 
  eval
  i have a file with perl statments,I want them to be access few 
  lines(depends dynamically) in my programe ,
  can anyone suggest me how to go about with it...! i tried reading the 
  file line by line extracting the  needed line's into an array and 
  then executing each element with eval ( )...but it did't work .
  
  Get Your Private, Free E-mail from Indiatimes at 
  http://email.indiatimes.comBuy Music, Video, 
  CD-ROM, Audio-Books and Music Accessories from http://www.planetm.co.in 
  
  
  Get more from the Web. FREE MSN Explorer download : http://explorer.msn.com
  


RE: problem with eval

2002-01-15 Thread Ron Hartikka



Seems like a 
hard way to program! But, maybe it's right for your 
situation.
 
Please post 
more if you can.
What do you 
mean by "it didn't work"?
Try printing 
the values returned by eval() - undefined value message indicates bad 
code.
 
 

  -Original Message-From: 
  [EMAIL PROTECTED] 
  [mailto:[EMAIL PROTECTED]]On Behalf Of 
  thiyagSent: Tuesday, January 15, 2002 5:41 AMTo: 
  perl-win32-users Mailing ListSubject: problem with 
  eval
  i have a file with perl statments,I want them to be access few 
  lines(depends dynamically) in my programe ,
  can anyone suggest me how to go about with it...! i tried reading the file 
  line by line extracting the  needed line's into an array and then 
  executing each element with eval ( )...but it did't work .
  
  Get Your Private, Free E-mail from Indiatimes at 
  http://email.indiatimes.comBuy Music, Video, CD-ROM, 
  Audio-Books and Music Accessories from http://www.planetm.co.in 



RE: Regex Help Please!

2002-01-10 Thread Ron Hartikka

Works but not if you have more or fewer than 2 values in a row.
Do you?


> -Original Message-
> From: [EMAIL PROTECTED]
> [mailto:[EMAIL PROTECTED]]On Behalf Of
> Wagner-David
> Sent: Thursday, January 10, 2002 1:31 PM
> To: 'Gordon Brandt'; [EMAIL PROTECTED]
> Subject: RE: Regex Help Please!
>
>
>   Here is a simplistic approach. May want more edits, but is
> a starting place.
>
>   Placing the data for testing under DATA:
>
> while (  ) {
>chomp;
>next if ( /^\s*$/ );   # bypass blank lines
>if ( /^  (.+) <\/v>
> (.+) <\/v><\/row>/ ) {
>   printf "%-s, %-s, %-s, %-s\n", $1, $2, $3, $4;
> }else {
>   printf "No hit on data:\n%-s\n", $_;
> }
>
>  }
> __DATA__
> 
>  NaN  NaN 
> 
>  6.00e+001  6.90e+001 
> ^--- Script ends here
> Output:
>
> 2002-01-08 09:35:00 Eastern Standard Time, 1010500500, NaN, NaN
> 2002-01-08 09:40:00 Eastern Standard Time, 1010500800,
> 6.00e+001, 6.90e+001
>
>   Wags ;)
>
> -Original Message-
> From: Gordon Brandt [mailto:[EMAIL PROTECTED]]
> Sent: Thursday, January 10, 2002 10:17
> To: [EMAIL PROTECTED]
> Subject: Regex Help Please!
>
>
> I am trying to come up with a script to convert this output from
> RRDTool DUMP to a format which lends itself to import into Excel
> 97.  Unfortunately, I am just getting started with Perl and do
> not have a clear enough grasp of how to configure this so that it
> strips out the unwanted parts and formats
> it correctly.  I would like to be able to feed a file into this
> script, and then receive a comma delimited formatted file as output.
>
> Can anyone point me in the right direction?  I have the O'reilly
> camel book, but when I read the section on Regex, I feel like an idiot! :(
>
> Input file:
> |
>
> (misc header information I want to delete)
>
> #This is how the data I want to pull out is formatted
> 
>  NaN  NaN 
> 
>  6.00e+001  6.90e+001 
>
> |---
>
> Output wanted is:
> 2002-01-08 09:35:00 Eastern Standard Time, 1010500500, NaN, NaN
> 2002-01-08 09:40:00 Eastern Standard Time, 1010500800,
> 6.00e+001, 6.90e+001
>
> |--
>
> Thanks in advance.
>
> Gordon
> --
>
> ___
> 1 cent a minute calls anywhere in the U.S.!
>
> http://www.getpennytalk.com/cgi-bin/adforward.cgi?p_key=RG9853KJ&u
rl=http://www.getpennytalk.com



___
Perl-Win32-Users mailing list
[EMAIL PROTECTED]
http://listserv.ActiveState.com/mailman/listinfo/perl-win32-users
___
Perl-Win32-Users mailing list
[EMAIL PROTECTED]
http://listserv.ActiveState.com/mailman/listinfo/perl-win32-users



___
Perl-Win32-Users mailing list
[EMAIL PROTECTED]
http://listserv.ActiveState.com/mailman/listinfo/perl-win32-users



RE: Disable DisplayAlerts in Excel

2001-12-24 Thread Ron Rohrssen

I had this same problem a few months ago.

I went through some old emails and this is how I resolved the issue at that
time.

$Excel->{DisplayAlerts} = 0;

Ron

-Original Message-
From: [EMAIL PROTECTED]
[mailto:[EMAIL PROTECTED]]On Behalf Of
Brian Shade
Sent: Monday, December 24, 2001 7:44 AM
To: [EMAIL PROTECTED]
Subject: Disable DisplayAlerts in Excel


Hi everyone. I thought I had this figured out, but after testing my code,
it turns out I didn't. My script runs on a server and converts various
documents to text, with one of them being Excel spreadsheets. I can't be
at the server all the time, so I need a way to disable to dialogue boxes
that might pop up. For instance, one spreadsheet wanted to know if I
wanted to update it with another spreadsheet. Here is part of my code:

$excel = Win32::OLE->new('Excel.Application', 'Quit');
$excel->{DisplayAlerts} ="False";

I thought that would disable the alerts, but I was wrong. I even tried
setting the alerts to 0 and to False without the quotes as people have
suggested in the mailing list archives. I am running the script on Windows
2000 with Office 2000 as well. Does anyone know how I can disable the
alerts successfully or what I did wrong? Thanks in advance.

Brian

___
Perl-Win32-Users mailing list
[EMAIL PROTECTED]
http://listserv.ActiveState.com/mailman/listinfo/perl-win32-users

___
Perl-Win32-Users mailing list
[EMAIL PROTECTED]
http://listserv.ActiveState.com/mailman/listinfo/perl-win32-users



RE: lwp memory leak

2001-12-09 Thread Ron Hartikka

As far as I know, perl does not free memory (back to the system); you can
never shrink.

You can avoid getting too big in the first place.
You can restart (exec) yourself if you get to big.

> -Original Message-
> From: [EMAIL PROTECTED]
> [mailto:[EMAIL PROTECTED]]On Behalf Of
> sunil matte
> Sent: Thursday, December 06, 2001 11:34 PM
> To: [EMAIL PROTECTED]
> Subject: lwp memory leak
>
>
> hi all
>  i am running a perl process as a windows 2000
> service. it makes socket connections periodically.i am
> fetching about 40-50 pages each time. everything works
> fine except that the background process is occupying
> about 10 MB or so.it does not free the memory at
> all.did any one of you guys faced a similar
> problem.how do i flush the memory in perl.can some one
> help out in this.
>
> awaiting your suggestions
> sunil matte..
>
> __
> Do You Yahoo!?
> Send your FREE holiday greetings online!
> http://greetings.yahoo.com
> ___
> Perl-Win32-Users mailing list
> [EMAIL PROTECTED]
> http://listserv.ActiveState.com/mailman/listinfo/perl-win32-users
>
>


___
Perl-Win32-Users mailing list
[EMAIL PROTECTED]
http://listserv.ActiveState.com/mailman/listinfo/perl-win32-users



RE: dynamic variable evaluation

2001-12-05 Thread Ron Hartikka

I don't know what you mean by '"rereferenced" (not a perl reference).

I don't know what you are trying to do from your explanation.

But, I see this...

$hashfmt{'1'} = "abc, 123, \$hash{\$x}{$y}{'value'}, xyz, 345,
\$hash{\$x}{\$y}{'value2'}" ;

... which you later split into an array. It's as if as if you wrote...

$values[2] = "\$hash{\$x}{\$y}{'value'}"; # contents is a string, not a ref
to a hash

What you plan to do with the string "\$hash{\$x}{\$y}{'value'}"?

> -Original Message-
> From: Ed DeBus [mailto:[EMAIL PROTECTED]]
> Sent: Tuesday, December 04, 2001 12:31 PM
> To: Ron Hartikka; [EMAIL PROTECTED]
> Subject: RE: dynamic variable evaluation
>
>
>
> Thanks all for the responses.  I think I may need to explain the code
> further.
>
> First, and most important, let's call the reference hash a
> "formatting" hash
> insteadthis hash and it's values has nothing to do with perl
> references.
>
> I think the problem I'm having is that the formatting hash is defined
> immediately when the scripts starts, and it's format never
> changes, however,
> the variables (hash values) represented by the formatting hash constantly
> change.  If the variables represented in the formatting hash
> exist prior to
> the hashes keys/values being definded, then of course this works fine.
> However once on of the variables "refererneced" (not a perl reference) in
> the format hash change, that does not force the value of that variable in
> the format hash to change.
>
> Yes, I could refer to the variables I want directly when I need them.  The
> purpose for this is to be able to build a template that creates the
> formatted message I need when I need it (there are several
> hundred potential
> unique messageshence the desire to build them dynamically from a
> template).
>
> Thanks!
>
>
> Ed DeBus
>
> -Original Message-
> From: [EMAIL PROTECTED]
> [mailto:[EMAIL PROTECTED]]On Behalf Of Ron
> Hartikka
> Sent: Tuesday, December 04, 2001 8:29 AM
> To: Ed DeBus; [EMAIL PROTECTED]
> Subject: RE: dynamic variable evaluation
>
>
> You took some extra references; I removed some backslashes: seem
> method 'a'
> below.
>
> (If you really had to convert the substring \$hash{\$x}{$y}{'value'} to a
> reference, you'd need to use eval()'.
>
> But, I think you ought to look at method 'b' below ...
>
> $x = 'xval'; $y = 'yval';
>
> $hash{$x}{$y}{'value'} = 'worked';
> $hash{$x}{$y}{'value2'} = 'not worked';
>
> # method a
>
> $hashfmt{'1'} = "abc, 123, $hash{$x}{$y}{'value'}, xyz, 345,
> $hash{$x}{$y}{'value2'}" ;
> @values = split(/, |,/ ,$hashfmt{'1'}) ; # note I switch alternatives
>
> print "a: $values[2], $values[5]\n";
>
> # method b
>
> @values = ('abc', 123, $hash{$x}{$y}{'value'}, 'xyz', 345,
> $hash{$x}{$y}{'value2'});
> print "b: $values[2], $values[5]";
>
> ... prints
>
> a: worked, not worked
> b: worked, not worked
>
>
> > -Original Message-
> > From: [EMAIL PROTECTED]
> > [mailto:[EMAIL PROTECTED]]On Behalf Of Ed
> > DeBus
> > Sent: Tuesday, December 04, 2001 2:27 AM
> > To: [EMAIL PROTECTED]
> > Subject: dynamic variable evaluation
> >
> >
> >
> > Given the following scenario, is there a clean way to perform variable
> > substitution
> >
> > First, we have a 3 dimensional hash:
> >
> > $hash{$x}{$y}{'value'} = "it worked" ;
> > $hash{$x}{$y}{'value2'} = "didn't work" ;
> >
> >
> > And another "reference" hash (nothing to do with perl ref's, but
> > rather for
> > building an array dynamically)
> >

> >
> >
> > Now build an array dynamically using format defined by the
> > "reference" hash.
> >
> > @values = split(/,|, / ,$hashfmt{'1'}) ;
> >
> > $count=1 ;
> > foreach $item (@values) {
> > ?< do what here> if ($count % 3 == 0) ;
> > print "Item = [$item]\n" :
> > $count++ ;
> > }
> >
> >
> > The problem I have is getting every 3ed item in the array
> (array position
> > 2,5, etc.) to evaluate and return a value of "it worked" or
> "didn't work".
> > The reference hash format(s) are configured when the script starts and
> > remain static from that point forward.  It's probably obvious,
> but keys to
> > the 1st and 2nd dimensions of the "reference" hash are passed
> as variables
> > from a calling subroutine.  Probably important to also mention that the
> > values for the 1st and 2nd keys of the 3 dimensional hash can/do change
> > frequently.
> >
> > Any help/idea's appreciated
> >
> > Ed
> >
> > ___
> > Perl-Win32-Users mailing list
> > [EMAIL PROTECTED]
> > http://listserv.ActiveState.com/mailman/listinfo/perl-win32-users
> >
> >
>
>
> ___
> Perl-Win32-Users mailing list
> [EMAIL PROTECTED]
> http://listserv.ActiveState.com/mailman/listinfo/perl-win32-users
>
>
>


___
Perl-Win32-Users mailing list
[EMAIL PROTECTED]
http://listserv.ActiveState.com/mailman/listinfo/perl-win32-users



RE: dynamic variable evaluation

2001-12-04 Thread Ron Hartikka

You took some extra references; I removed some backslashes: seem method 'a'
below.

(If you really had to convert the substring \$hash{\$x}{$y}{'value'} to a
reference, you'd need to use eval()'.

But, I think you ought to look at method 'b' below ...

$x = 'xval'; $y = 'yval';

$hash{$x}{$y}{'value'} = 'worked';
$hash{$x}{$y}{'value2'} = 'not worked';

# method a

$hashfmt{'1'} = "abc, 123, $hash{$x}{$y}{'value'}, xyz, 345,
$hash{$x}{$y}{'value2'}" ;
@values = split(/, |,/ ,$hashfmt{'1'}) ; # note I switch alternatives

print "a: $values[2], $values[5]\n";

# method b

@values = ('abc', 123, $hash{$x}{$y}{'value'}, 'xyz', 345,
$hash{$x}{$y}{'value2'});
print "b: $values[2], $values[5]";

... prints

a: worked, not worked
b: worked, not worked


> -Original Message-
> From: [EMAIL PROTECTED]
> [mailto:[EMAIL PROTECTED]]On Behalf Of Ed
> DeBus
> Sent: Tuesday, December 04, 2001 2:27 AM
> To: [EMAIL PROTECTED]
> Subject: dynamic variable evaluation
>
>
>
> Given the following scenario, is there a clean way to perform variable
> substitution
>
> First, we have a 3 dimensional hash:
>
>   $hash{$x}{$y}{'value'} = "it worked" ;
>   $hash{$x}{$y}{'value2'} = "didn't work" ;
>
>
> And another "reference" hash (nothing to do with perl ref's, but
> rather for
> building an array dynamically)
>
>   $hashfmt{'1'} = "abc, 123, \$hash{\$x}{$y}{'value'}, xyz, 345,
> \$hash{\$x}{\$y}{'value2'}" ;
>
>
> Now build an array dynamically using format defined by the
> "reference" hash.
>
>   @values = split(/,|, / ,$hashfmt{'1'}) ;
>
>   $count=1 ;
>   foreach $item (@values) {
>   ?< do what here> if ($count % 3 == 0) ;
>   print "Item = [$item]\n" :
>   $count++ ;
>   }
>
>
> The problem I have is getting every 3ed item in the array (array position
> 2,5, etc.) to evaluate and return a value of "it worked" or "didn't work".
> The reference hash format(s) are configured when the script starts and
> remain static from that point forward.  It's probably obvious, but keys to
> the 1st and 2nd dimensions of the "reference" hash are passed as variables
> from a calling subroutine.  Probably important to also mention that the
> values for the 1st and 2nd keys of the 3 dimensional hash can/do change
> frequently.
>
> Any help/idea's appreciated
>
> Ed
>
> ___
> Perl-Win32-Users mailing list
> [EMAIL PROTECTED]
> http://listserv.ActiveState.com/mailman/listinfo/perl-win32-users
>
>


___
Perl-Win32-Users mailing list
[EMAIL PROTECTED]
http://listserv.ActiveState.com/mailman/listinfo/perl-win32-users



RE: Regular expression help

2001-11-29 Thread Ron Hartikka

for $number (1006326869812, 563296853235993 , 35968322963568389){
print "$1-$2-$3\n" if ($number =~ /(\d*)(\d{4})(\d{5})/);

}

> -Original Message-
> From: [EMAIL PROTECTED]
> [mailto:[EMAIL PROTECTED]]On Behalf Of
> [EMAIL PROTECTED]
> Sent: Thursday, November 29, 2001 3:32 PM
> To: [EMAIL PROTECTED]
> Subject: Regular expression help
> 
> 
> I need help creating a regular expression to do the following.
> 
> I have the following numbers:
> 
> 1006326869812
> 563296853235993
> 35968322963568389
> 
> and it needs to be broken up like this
> 
> 1006-3268-69812
> 563296-8532-35993
> 35968322-9635-68389
> 
> Notice the second group of numbers is always 4 places and the 
> last group is
> always 5 places.
> 
> I'm stumped and not to good with RE's. Any pointers would be great.
> 
> Rob
> ___
> Perl-Win32-Users mailing list
> [EMAIL PROTECTED]
> http://listserv.ActiveState.com/mailman/listinfo/perl-win32-users
> 
> 

___
Perl-Win32-Users mailing list
[EMAIL PROTECTED]
http://listserv.ActiveState.com/mailman/listinfo/perl-win32-users



RE: Minimize Window

2001-11-28 Thread Ron Hartikka

I started task mgr manually. This worked. w2k.


use Win32::GuiTest qw(FindWindowLike GetWindowText SetForegroundWindow
SendKeys);

$Win32::GuiTest::debug = 0; # Set to "1" to enable verbose mode

my @windows = FindWindowLike(undef, "Windows Task Manager", ".");

#print join "\n", @windows;


for (@windows) {
# print "$_>\t'", GetWindowText($_), "'\n";
 SetForegroundWindow($_);
 SendKeys("%{space}n");

}

> -Original Message-
> From: [EMAIL PROTECTED]
> [mailto:[EMAIL PROTECTED]]On Behalf Of
> Dirk Bremer
> Sent: Wednesday, November 28, 2001 4:05 PM
> To: perl-win32-users
> Subject: Minimize Window
>
>
> I have started an instance of the Winnt Task Manager using
> Win32::Process, and once it has started, I would like to minimize it. How
> may I accomplish this in Perl?
>
> Dirk Bremer - Systems Programmer II - AMS Department - NISC
> 636-922-9158 ext. 652 fax 636-447-4471
>
> 
>
>
> ___
> Perl-Win32-Users mailing list
> [EMAIL PROTECTED]
> http://listserv.ActiveState.com/mailman/listinfo/perl-win32-users
>
>


___
Perl-Win32-Users mailing list
[EMAIL PROTECTED]
http://listserv.ActiveState.com/mailman/listinfo/perl-win32-users



RE: unlink(file)

2001-11-28 Thread Ron Hartikka

Do you have the file open?

You cannot delete an open file according to Bill.

open (JUNK, '>junkyfile.txt');
print JUNK "STUFF IN junkyfile.txt\n";
close JUNK;
print `type junkyfile.txt`;
unlink 'junkyfile.txt';
print `type junkyfile.txt`;

... prints...

STUFF IN junkyfile.txt
The system cannot find the file specified.

... or ...

STUFF IN junkyfile.txt
STUFF IN junkyfile.txt

... depending on whether the close is there or not.

> -Original Message-
> From: [EMAIL PROTECTED]
> [mailto:[EMAIL PROTECTED]]On Behalf Of
> Edward G. Orton
> Sent: Wednesday, November 28, 2001 3:04 PM
> To: Perl-Win32-Users Mailing List
> Subject: unlink(file)
> 
> 
> I seem to have a problem with deleting files from Perl. I use
> unlink('filename') to delete the file, but it does not actually
> get deleted until the perl program exits. This is a problem
> since I am using a perl program to clean up old files, and put
> new ones on a removeable drive. If the drive is full, I remove
> the oldest files until there is enough data deleted to add in
> the new files. The problem is, until the script exits, the
> deleted files aren't deleted.
> 
> Any suggestions?
> ActivePerl 628 on Windows 2000 server.
> 
> ego
> Edward G. Orton, GWN Consultants Inc.
> Phone: 613-764-3186, Fax: 613-764-1721
> email: [EMAIL PROTECTED]
> 
> ___
> Perl-Win32-Users mailing list
> [EMAIL PROTECTED]
> http://listserv.ActiveState.com/mailman/listinfo/perl-win32-users
> 
> 

___
Perl-Win32-Users mailing list
[EMAIL PROTECTED]
http://listserv.ActiveState.com/mailman/listinfo/perl-win32-users



RE: How to omit lines from execution in a perl program

2001-11-12 Thread Ron Hartikka

Just remove the debug statements once and put them in a second script to be
exec'd based on command line parameter.

> -Original Message-
> From: [EMAIL PROTECTED]
> [mailto:[EMAIL PROTECTED]]On Behalf Of
> Nick Djurovich
> Sent: Monday, November 12, 2001 12:45 PM
> To: PERLMAILINGLIST
> Subject: How to omit lines from execution in a perl program
>
>
> Hi,
>
> I have a perl script with lots of debug statements. I want
> to be able to run the script without the debug statements.
> Is there a way to do this in runtime ?
>
> I can currently set a debug variable that prevents output, but
> I would rather the debug statements were never executed for
> optimum speed.
>
> I have thought of a way, in which at the start, if specified
> by a command line parameter, it slurps itself up into a large
> string, removing the debug statements and then evaluating
> the string, and then exits. Yuck.
>
> Regards
>
> Nick Djurovich
> 
> Software Development Manager
> mediaMailGroup
> Colchester
> UK
> ___
> Perl-Win32-Users mailing list
> [EMAIL PROTECTED]
> http://listserv.ActiveState.com/mailman/listinfo/perl-win32-users
>
>


___
Perl-Win32-Users mailing list
[EMAIL PROTECTED]
http://listserv.ActiveState.com/mailman/listinfo/perl-win32-users



outlook distribution list from recipient list?

2001-10-15 Thread Ron Hartikka

I have:

[EMAIL PROTECTED]; [EMAIL PROTECTED]; [EMAIL PROTECTED]; [EMAIL PROTECTED];

I want an Outlook distribution list with these addresses.

Outlook makes me do them one at a time.

Can you do this in perl? If so how?

Thanks.

___
Perl-Win32-Users mailing list
[EMAIL PROTECTED]
http://listserv.ActiveState.com/mailman/listinfo/perl-win32-users



Re: Include statement..Boy am I a newbie

2001-07-03 Thread Ron Grabowski

> In linux it automatically looks in the current directory. However, with
> windows, it looks to C:/Perl/lib or C:/Perl/site/lib .

All versions of Perl look in the global array @INC to see which directories
to look for files:

perl -v

Characteristics of this binary (from libperl):
  Locally applied patches:
ActivePerl Build 522
  Built under MSWin32
  Compiled at Nov  2 1999 09:52:28
  @INC:
C:/Perl/lib
C:/Perl/site/lib

> I tried putting the pl file into those directories, and I tried changing

It should work by just putting it in the current directory too. If not you
can always add another directory to @INC or use the 'lib' pragma.

___
Perl-Win32-Users mailing list
[EMAIL PROTECTED]
http://listserv.ActiveState.com/mailman/listinfo/perl-win32-users



Re: scalar context question

2001-07-03 Thread Ron Grabowski

> > I don't think it would force a scalar context. => is just a shorthand
for comma in a list. In other words, $b in the following three code segments
would get the same results:

A comma that adds single quotes the value to its left.


___
Perl-Win32-Users mailing list
[EMAIL PROTECTED]
http://listserv.ActiveState.com/mailman/listinfo/perl-win32-users



Re: Regular expression

2001-07-03 Thread Ron Grabowski

>   print "$1 \n" if $text =~ /\/(.+):/;
>   print "$1 \n" if $text =~ /\/([^\/]+):/;

Or you could do it in one line:

(split/:\s/)[2] =~ m|.*/(.*)$|;

___
Perl-Win32-Users mailing list
[EMAIL PROTECTED]
http://listserv.ActiveState.com/mailman/listinfo/perl-win32-users



Re: external program and stdin

2001-07-03 Thread Ron Grabowski

> I have an external program that I access with the back
> tick operator (`program.exe`) -it works fine, but I do
> not know how to send it certain parameters through
> stdin after it executes. For example what I really
> want to do is to execute the program, and then send it
> some data through stdin.

perldoc -f open talks about using the pipe symbol on a file handler to write
input to a program.

___
Perl-Win32-Users mailing list
[EMAIL PROTECTED]
http://listserv.ActiveState.com/mailman/listinfo/perl-win32-users



Re: MSComm and Win32::API

2001-06-30 Thread Ron Grabowski

> serial port communications?

Why not use this instead:

 http://search.cpan.org/search?dist=Win32-SerialPort
___
Perl-Win32-Users mailing list
[EMAIL PROTECTED]
http://listserv.ActiveState.com/mailman/listinfo/perl-win32-users



Re: format+Tk

2001-06-28 Thread Ron Grabowski

> My PROBLEM:
>  I want to insert a formatted test , I mean the resulting of the "format"
> command . if I use write every line will go on the STDOUT
> but I want to get all the columns well formatted inside the
> "$TextMessage".

perlform lead me to this:

---
use Carp;
sub swrite {
  croak "usage: swrite PICTURE ARGS" unless @_;
  my $format = shift;
  $^A = "";
  formline($format,@_);
  return $^A;
}

$string = swrite(<<'END', $str, $%, "\$$num");
Test: @ @| @>
END

print $string;
---

___
Perl-Win32-Users mailing list
[EMAIL PROTECTED]
http://listserv.ActiveState.com/mailman/listinfo/perl-win32-users



Re: format+Tk

2001-06-28 Thread Ron Grabowski

> My PROBLEM:
>  I want to insert a formatted test , I mean the resulting of the "format"
> command . if I use write every line will go on the STDOUT
> but I want to get all the columns well formatted inside the
> "$TextMessage".
> I know it is not clearbut if you manage to understand what I am trying
> to say..please support me.

Is the font in the window a fixed font? Something like Arial or Times New
Roman will not line up correctly because every character does not take up
the same amount of space. Ignoring that, it sounds like you want a
filehandler to really be a variable in which case you'd need the IO::Scalar
module:

---
use IO::Scalar;

tie *STDOUT, 'IO::Scalar', \$TextMessage;

write(STDOUT);
---

___
Perl-Win32-Users mailing list
[EMAIL PROTECTED]
http://listserv.ActiveState.com/mailman/listinfo/perl-win32-users



Removing ACE's from Member Servers they are local member server groups

2001-06-24 Thread Ron LEVER

Help

I have posted this problem to Admin list and on Roths perms news no one has
been able to help yet.

Ron

The error code that I get is,

126 The specified module could not be found. ERROR_MOD_NOT_FOUND
When the program tries to remove the second ACE.

Does this help anyone, help me?

Help

I am getting a little desperate, if anyone can help please.

Using NT 4 SP 5

Below is the code. What I am trying to do is remove selected group
permissions
on a particular path. The path and the groups (local groups) are on a
member server.

I have Dave Roth's new book and checked through all the examples he
never uses $perm->Get
and he does not give an example of removing a series of ACE's. In the
examples he uses
$perm->Remove(-1) to remove all the permissions. When I try this it
removes them all OK but
I can not put any back. I would prefer not to use this method anyway.

The program will find and remove the first ACE that matches the group
name. If there is more
than just the one ACE then it will fail. Even though I set then close
then undef the perm
and finally recreate the perm it will not remove the other ACE's of the
same name.

However if I close the program down and then rerun it, it will delete
the next ACE.

So the bottom line is I have to run the program as many times as I have
ACE's, not very
practical. Does anyone know why??


use strict;
use Win32::Perms;
use Win32;
use Win32::Lanman;

my ( $_perm, $_index, $_server, $_path, @_lines, @_list,
  $_group, $_script, $_elements, $_line, $_found, $i, $j );

if( not scalar @ARGV )
{
 my ( $_script ) = ( $0 =~ /([^\\]*?)$/);

 print << "EOT";

 Syntax

  Perl $_script   

 Example:

  perl $_script c:\\ansto Tagua project_admins

EOT

 exit();
}

$_path = "c:\\" unless ( $_path = $ARGV[0] );

$_server = Win32::NodeName() unless ( $_server = $ARGV[1] );

$_line =
"___
__";

$_group = 'ansto_dm';

$_found = 1;

while( $_found )
{
 $_index = $_found = 0;

 $_perm = new Win32::Perms( "dir:".$_path ) || exit "Can not obtain
permissions on $_path\n";

 $_perm->Dump( \@_list );

 $_elements = @_list;

 printOutput( "Server Name: \"$_server\" Path: \"$_path\" Delete Group:
\"$_group\"\n" );

 printOutput( "\nNumber of Elements $_elements\n");

 printList( @_list );

 $_found = removeGroupPermissions( $_perm, $_group, @_list );

 $_perm->Set();

 $_perm->Close();

 undef $_perm;
}

writeFile( "RemoveGroups", "v:\\ansto\\Output" );

#---


sub showName
{
 my( $sid ) = @_;

 my( $binSid, $accountName, $domain, $SDT );

 $binSid = Win32::Lanman::StringToSid( $sid );
 Win32::LookupAccountSID( $_server, $binSid, $accountName, $domain, $SDT
);

 return $accountName;
}

sub printList
{
 my( @list ) = @_;

 my( $account, $accountName, $index, $line );

 $index = 0;

 foreach $account ( @list )
   {
  ( $accountName ) = showName( $account->{SID} );

  printOutput( "Index: $index, Account: $accountName Details are: \n" );


  printAccountDetails( $account );

  printOutput( "\n$_line\n" );

  $index++;
 }
}

sub printAccountDetails
{
 my( $account ) = @_;

 printOutput( "\nAccount->{ObjectName}  : \"$account->{ObjectName}\"" );

 printOutput( "Account->{ObjectType}  : \"$account->{ObjectType}\""  );
 printOutput( "Account->{Access}  : \"$account->{Access}\""  );
 printOutput( "Account->{Account} : \"$account->{Account}\"" );
 printOutput( "Account->{Domain}  : \"$account->{Domain}\"" );
 printOutput( "Account->{Mask}: \"$account->{Mask}\"" );
 printOutput( "Account->{Type}: \"$account->{Type}\"" );
 printOutput( "Account->{Flag}: \"$account->{Flag}\"" );
 printOutput( "Account->{SID} : \"$account->{SID}\"\n" );
}

sub printOutput
{
 my( $line ) = @_;

 print "$line\n";

 # Remove white space from the end on the line
 #$line =~ s/\s+$//;
 push( @_lines, $line );
}

sub writeFile
{
 my( $file, $dir ) = @_;

 my( $filename, $line );

 $filename = "$dir\\$file".".dbug";

 open( F_OUT, ">$filename" ) || warn "Can not open $filename: $!";

 print "In writeFile $filename\n\n";

 foreach $line ( @_lines )
 {
  $line = "$line\n";
  print F_OUT $line;
 }
 close( F_OUT );
}

sub removeGroupPermissions
{
 my( $perm, $group, @list ) = @_;

 my( $account, $accountName, $index, $found );

 $index = $found = 0;

 foreach $account ( @list )
 {
  unless( $accountName = $account->{ A

Re: Smartarse Unix Beardy Types...

2001-06-22 Thread Ron Grabowski

> perl -e "while (1){rand>0.5 ? print'\\' : print'/'}" 

perl -e "print rand > 0.5 ? q/\\/ : q\/\ while 1"

___
Perl-Win32-Users mailing list
[EMAIL PROTECTED]
http://listserv.ActiveState.com/mailman/listinfo/perl-win32-users



Re: Question

2001-06-20 Thread Ron Grabowski
Title: Network Blitz




  HTML mail ==> *yuck*
   
  Did you download and install the LDAP.pm 
  module on your computer?
   
   
  Can't locate Net/LDAP.pm in @INC 
  (@INC contains: C:/Perl/lib C:/Perl/site/lib .) at PerlLDAPquery.plx 
  line 4.BEGIN failed--compilation aborted at PerlLDAPquery.plx line 
  4.
   
  


RE: computations with backreferences

2001-06-18 Thread Ron Hartikka

Could you clarify the question.

Example: If I get the input line

___

I want this output line 

___.

-Original Message-
From: [EMAIL PROTECTED]
[mailto:[EMAIL PROTECTED]]On Behalf Of Dan
Jablonsky
Sent: Monday, June 18, 2001 2:32 PM
To: [EMAIL PROTECTED]
Subject: computations with backreferences


Hi all,
I have a regex, it's isolating some numbers in each
line of a text file and I want to add some computation
with those numbers on the same line. I know you can
basically stick any function in a regex but I don't
know how. Hence, the code below won't work:

$_=~s/^[A-Z]\t(\d{1,2})\t.*\t(\d{2})\t.*/$1\t$2\t($1+$2)/2/;

The forward slash that would terminate wrongly the
regex is actually a "divide by".
What is the correct way to do it?
Thanks,
Dan

__
Do You Yahoo!?
Spot the hottest trends in music, movies, and more.
http://buzz.yahoo.com/
___
Perl-Win32-Users mailing list
[EMAIL PROTECTED]
http://listserv.ActiveState.com/mailman/listinfo/perl-win32-users

___
Perl-Win32-Users mailing list
[EMAIL PROTECTED]
http://listserv.ActiveState.com/mailman/listinfo/perl-win32-users



Re: @$_ works, so why doesn't %$_ ?

2001-06-14 Thread Ron

@list = (\%hash_one, \%hash_two, \%hash_three);

Look at Making References and Using references in perlref.


- Original Message -
From: "Peter Eisengrein" <[EMAIL PROTECTED]>
To: "'Carl Jolley'" <[EMAIL PROTECTED]>
Cc: "Perl-Win32-Users Mailing List (E-mail)"
<[EMAIL PROTECTED]>
Sent: Thursday, June 14, 2001 4:32 PM
Subject: RE: @$_ works, so why doesn't %$_ ?


> Like this?
> @list = ([%hash_one],[%hash_two],[%hash_three]);
>
>
>
> > -Original Message-
> > From: Carl Jolley [mailto:[EMAIL PROTECTED]]
> > Sent: Thursday, June 14, 2001 4:24 PM
> > To: Peter Eisengrein
> > Cc: Perl-Win32-Users Mailing List (E-mail)
> > Subject: Re: @$_ works, so why doesn't %$_ ?
> >
> >
> > On Thu, 14 Jun 2001, Peter Eisengrein wrote:
> >
> > > Aaargggh. This is making me nutty! I have several
> > hashes that I want to
> > > process identically, so I put their names in an array and
> > want to call those
> > > names iteratively from the array. But I just can't get it
> > to work. Please
> > > help!
> > >
> > >
> > > ### here's what I am trying to do:
> > > my @list = ("hash_one","hash_two","hash_three");
> > > foreach (@list)
> > > {
> > > ### now process %$_ which I want to be
> > > ### %hash_one
> > > ### then %hash_two
> > > ### then %hash_three
> > > }
> > >
> > >
> > >
> > > I've used @$_ before, so why doesn't %$_ work? I've tried...
> > > %$_
> > > %{$_}
> > > %${_}
> > > %{${_}}
> > > %\$_
> > > %(eval($_))
> > > ... and every other combination I can think of. I'll just
> > be here banging my
> > > head on my desk
> >
> > To avoid being evil, I suggest instead of putting the names in the
> > list that you put a reference to each hash in the list.
> >
> >  [EMAIL PROTECTED] 
> >  All opinions are my own and not necessarily those of my
> > employer 
> > k
> >
> ___
> Perl-Win32-Users mailing list
> [EMAIL PROTECTED]
> http://listserv.ActiveState.com/mailman/listinfo/perl-win32-users
>

___
Perl-Win32-Users mailing list
[EMAIL PROTECTED]
http://listserv.ActiveState.com/mailman/listinfo/perl-win32-users



RE: @$_ works, so why doesn't %$_ ?

2001-06-14 Thread Ron Hartikka

Same with scalars...

our $s1 = "a";
my  %s2 = "b";
our $s3 = "c";

for my $it (qw(s1 s2 s3)){
print "$it: $$it\n";

}

... prints...

Name "main::s1" used only once: possible typo at scalersymref.pl line 2.
Name "main::s3" used only once: possible typo at scalersymref.pl line 4.
Use of uninitialized value in concatenation (.) at scalersymref.pl line 8.
s1: a
s2: # was a my
s3: c

...Locals work...

$s2 = "s";

{
our $s1 = "a";
local  $s2 = "b";
our $s3 = "c";


for my $it (qw(s1 s2 s3)){
print "$it: $$it\n";

}
}

... prints...

Name "main::s1" used only once: possible typo at scalersymref.pl line 4.
Name "main::s3" used only once: possible typo at scalersymref.pl line 6.
s1: a
s2: b ### not "s"
s3: c

See perlref 'Symbolic References' or Camel 2 section 4.4, on 'Symbolic
References':


-Original Message-
From: [EMAIL PROTECTED]
[mailto:[EMAIL PROTECTED]]On Behalf Of
Peter Eisengrein
Sent: Thursday, June 14, 2001 1:44 PM
To: Perl-Win32-Users Mailing List (E-mail)
Subject: @$_ works, so why doesn't %$_ ?


Aaargggh. This is making me nutty! I have several hashes that I want to
process identically, so I put their names in an array and want to call those
names iteratively from the array. But I just can't get it to work. Please
help!


### here's what I am trying to do:
my @list = ("hash_one","hash_two","hash_three");
foreach (@list)
{
### now process %$_ which I want to be
### %hash_one
### then %hash_two
### then %hash_three
}



I've used @$_ before, so why doesn't %$_ work? I've tried...
%$_
%{$_}
%${_}
%{${_}}
%\$_
%(eval($_))
... and every other combination I can think of. I'll just be here banging my
head on my desk

Thanks group.

___
Perl-Win32-Users mailing list
[EMAIL PROTECTED]
http://listserv.ActiveState.com/mailman/listinfo/perl-win32-users

___
Perl-Win32-Users mailing list
[EMAIL PROTECTED]
http://listserv.ActiveState.com/mailman/listinfo/perl-win32-users



RE: @$_ works, so why doesn't %$_ ?

2001-06-14 Thread Ron Hartikka

Maybe you didn't say your hashes were 'my' variables?


our %h1 = qw(a A b B c c);
our %h2 = qw(x X y Y z Z);
my %h3 = qw(r R s S t T);


for my $it (qw(h1 h2 h3)){
@$it = %$it;
print join " ",  $it, ": ", @$it, "\n";

}

...prints

Name "main::h1" used only once: possible typo at symrefhash.pl line 2.
Name "main::h2" used only once: possible typo at symrefhash.pl line 3.
h1 :  a A b B c c
h2 :  x X y Y z Z
h3 :

(Ignore the -w's about 'only once'.)

-Original Message-
From: [EMAIL PROTECTED]
[mailto:[EMAIL PROTECTED]]On Behalf Of
Peter Eisengrein
Sent: Thursday, June 14, 2001 1:44 PM
To: Perl-Win32-Users Mailing List (E-mail)
Subject: @$_ works, so why doesn't %$_ ?


Aaargggh. This is making me nutty! I have several hashes that I want to
process identically, so I put their names in an array and want to call those
names iteratively from the array. But I just can't get it to work. Please
help!


### here's what I am trying to do:
my @list = ("hash_one","hash_two","hash_three");
foreach (@list)
{
### now process %$_ which I want to be
### %hash_one
### then %hash_two
### then %hash_three
}



I've used @$_ before, so why doesn't %$_ work? I've tried...
%$_
%{$_}
%${_}
%{${_}}
%\$_
%(eval($_))
... and every other combination I can think of. I'll just be here banging my
head on my desk

Thanks group.

___
Perl-Win32-Users mailing list
[EMAIL PROTECTED]
http://listserv.ActiveState.com/mailman/listinfo/perl-win32-users

___
Perl-Win32-Users mailing list
[EMAIL PROTECTED]
http://listserv.ActiveState.com/mailman/listinfo/perl-win32-users



Re: 'Reversing an array'

2001-06-11 Thread Ron Grabowski

> I have an array with value of 1-10.
>
> What is the fastest way to 'reverse' the values to 10-1 (ie. 10 9 8 7 6
...)

@array = reverse(@array);

perldoc -f reverse

http://www.google.com/search?q=how+do+i+reverse+an+array+in+perl

___
Perl-Win32-Users mailing list
[EMAIL PROTECTED]
http://listserv.ActiveState.com/mailman/listinfo/perl-win32-users



Re: FTP Connections

2001-06-11 Thread Ron Grabowski

> to the server if the connection is severed, currently I use WS_FTP (those
> who use this know what I mean).

SmartFTP is a full-featured freeware FTP client that has its own scripting
language:

 http://www.smartftp.com



___
Perl-Win32-Users mailing list
[EMAIL PROTECTED]
http://listserv.ActiveState.com/mailman/listinfo/perl-win32-users



Re: Pass To Module

2001-06-11 Thread Ron Grabowski

> As I am learning how to try and use modules today, I ran into a strange

Eventually this entire list is going to be PerlEx experts thanks to Scott's
posts
:-) I know how frustrating it to do simply tasks with unfamiliar software.

>  MY MAIN CALLING SCRIPT IN WHICH I WANT TO PASS HOST AND PORT TO MY
> MODULE
> use vars qw($q $host $port);
> use CGI;
> use CGI::Carp (fatalsToBrowser);
>
> $host = '208.238.162.204';
> $port = '8000';
> $q = CGI->new;
> use My::HT qw($q $host $port);
> My::HT::printmyheader();
> print "MOM";

Can you just make it into an object?

use vars qw($q $host $post $objHT);
use CGI;
use CGI::Carp (fatalsToBrowser);
use My::HT;

$q = CGI->new;

$objHT = new My::HT ($q,$host,$port);

$objHT->printmyheader();

___
Perl-Win32-Users mailing list
[EMAIL PROTECTED]
http://listserv.ActiveState.com/mailman/listinfo/perl-win32-users



Re: Hex bytecount??

2001-06-11 Thread Ron Grabowski

> > # here I need to get contents of $ray[0x209] in DECIMAL so I can know
how
> > many following bytes are relevant.
> >
> > Thoughts... options??
>
> How many bytes long is the length word ?

It sounds like he just wants

$ray[ hex(0x209) ]

but unpack does seem to make more sense that splitting each line into an
array first. Maybe if we had some sort of sample input and desired output we
could just write the darn thing.

___
Perl-Win32-Users mailing list
[EMAIL PROTECTED]
http://listserv.ActiveState.com/mailman/listinfo/perl-win32-users



Re: A few uncivil remarks..........

2001-06-11 Thread Ron Grabowski

> Just curious... since this was not a response but rather a new thread, was
> there a particular offense that got your underwear in a bunch, or did you
> just wake up a bit cranky?

The problem is that some people refuse to look for information on their own.
I can't tell you how many times this list has answered 'How Do I send email
in perl'. Not only does the answer to this question come with every
installation of Perl but guess what phrase you enter into Google to get the
answer http://www.google.com/search?q=how+do+i+send+mail+with+perl Its basic
skills like that that these people are lacking.


___
Perl-Win32-Users mailing list
[EMAIL PROTECTED]
http://listserv.ActiveState.com/mailman/listinfo/perl-win32-users



Re: A few uncivil remarks..........

2001-06-11 Thread Ron Grabowski

> Lee Goddard wrote:
> >
> > I reckon PLEASE READ THE FAQ and a url should appear at the top
> > of every AS post, not just a URL a the bottom
>
> No, not at the TOP! I don't need another thing to scroll down through
> before I get to something meaningful.

Instead of just giving code, I like to refer people to the appropriate man
page or a simple Google query where they can find the answer for themselves.

___
Perl-Win32-Users mailing list
[EMAIL PROTECTED]
http://listserv.ActiveState.com/mailman/listinfo/perl-win32-users



Re: Assistance use Strict

2001-06-08 Thread Ron

I take back the last bit of my last post.

I think you could say...
> my @lines = split /\n/, @{$rawDataRef}[ $#{ $rawDataRef }];

... based on accessing and printing of Arrays of Arrays in camel 3. pg 271

- Original Message -
From: "Ron" <[EMAIL PROTECTED]>
To: "Purcell, Scott" <[EMAIL PROTECTED]>
Cc: "perl win32 users" <[EMAIL PROTECTED]>
Sent: Friday, June 08, 2001 6:17 PM
Subject: Re: Assistance use Strict


> You can't get $#rawDataRef because @rawDataRef is undefined.
>
> You have $rawDataRef, a scalar, containing a ref to array, not
@rawDataRef.
>
> You could do this...
>
> my @junk = @{$rawDataRef};
>
> my @lines = split /\n/, @{$rawDataRef}[$#junk];
>
> ...I think you could even say...
>
> my @lines = split /\n/, @{$rawDataRef}[ $#{ @{$rawDataRef} }];
>
> ...but I haven't tried that.
>
> - Original Message -
> From: "Purcell, Scott" <[EMAIL PROTECTED]>
> To: "'[EMAIL PROTECTED]'"
> <[EMAIL PROTECTED]>
> Sent: Friday, June 08, 2001 4:52 PM
> Subject: Assistance use Strict
>
>
> > Hello, I am using strict and I am getting an error on the second line
> below.
> >
> > Line one, is a query that brings back a "REFERENCE TO AN ARRAY".
> > In line 2, I am trying to grab only the LAST array element, and split it
> up
> > on the newline and put that result into lines.
> > But strict is telling me I can' do that.?
> >
> > I have tried two other ways, but they also give me errors.? I know I
could
> > rewrite the &refQuery, but I use it constantly, and this is the only
place
> > where I grab the last array item, so I hate to do that.
> >
> >
> >
> >
> > my $rawDataRef = &refQuery("USER_NAME=\"$group
> >
>
\'","ISSUP\nRES15\nPGROUP","$mediabankdir/sysdbase/dbuser.dbf",'SYSTEM','1')
> > ;
> > my @lines = split /\n/, @{$rawDataRef}[$#rawDataRef]; # gives me
error
> >
> > other
> > my @lines = split /\n/, $rawDataRef->[#$rawDataRef]; # gives me
> > error
> >
> >
> >
> > Scott Purcell
> >
> > ___
> > Perl-Win32-Users mailing list
> > [EMAIL PROTECTED]
> > http://listserv.ActiveState.com/mailman/listinfo/perl-win32-users
> >
>
> ___
> Perl-Win32-Users mailing list
> [EMAIL PROTECTED]
> http://listserv.ActiveState.com/mailman/listinfo/perl-win32-users
>

___
Perl-Win32-Users mailing list
[EMAIL PROTECTED]
http://listserv.ActiveState.com/mailman/listinfo/perl-win32-users



Re: Getting text from HTML pages

2001-06-08 Thread Ron Grabowski

> my ($text)=$htmlstring=~/\(.*)/i;

I think he wanted everything in the file. The Cookbook says:

% perl -pe 's/<[^>]*>//g' file


___
Perl-Win32-Users mailing list
[EMAIL PROTECTED]
http://listserv.ActiveState.com/mailman/listinfo/perl-win32-users



Re: Wildcard matching of hash keys

2001-06-08 Thread Ron Pero

At times I've thought it would be worthwhile to have a function called
"regexists", that would look like this:

if ( regexists('cart','^302v') ) {
print "hello\n";
}

Better yet, like the "exists" function:
if ( regexists $cart{/^302v/} ) {

grep works just fine for this
if (grep {/^305v/} keys %cart) {
print "hello, $_\n";
}
--
if ( regexists('cart','^302v') ) {
print "hello\n";
}
sub regexists {
my ($hash_name, $regex) = @_;
foreach (keys %{$hash_name}) {
if ($_ =~ m~$regex~) {
return 1;
}
}
return 0;
}

Ron

At 03:14 PM 06/08/01 +0100, Martin Moss wrote:
>All,
>
>Has anybody done any work with wildcard matching of hash keys?
>
>along the lines of 
>
>my $pattern="*red*";
>if (exists($hash{$pattern}))   #I 
>{
>   print "Key exists\n";
>}
>
>Is the only solution to sort through each key and do a pattern match?
>
>Regards
>
>Marty
>___
>Perl-Win32-Users mailing list
>[EMAIL PROTECTED]
>http://listserv.ActiveState.com/mailman/listinfo/perl-win32-users
>
___
Perl-Win32-Users mailing list
[EMAIL PROTECTED]
http://listserv.ActiveState.com/mailman/listinfo/perl-win32-users



RE: RegEx: Finding and replacing all characters between ( and ) ?

2001-06-07 Thread Ron Hartikka

Ok

while (){

print;
print "becomes\n";
s/\([^\(\)]+\)|\(\(\)\)/()/g;
print;
print "\n";

}
__DATA__
asdf(asdf)asdf
asdf((asdf))asdf
asdf(as(asdf)df)asdf

prints--

asdf(asdf)asdf
becomes
asdf()asdf

asdf((asdf))asdf
becomes
asdf(())asdf

asdf(as(asdf)df)asdf
becomes
asdf(as()df)asdf

- so, while what? -



-Original Message-
From: Joseph P. Discenza [mailto:[EMAIL PROTECTED]]
Sent: Thursday, June 07, 2001 8:53 AM
To: Ron Hartikka; perl win32 users
Subject: RE: RegEx: Finding and replacing all characters between ( and )
?


Ron Hartikka wrote, on Thursday, June 07, 2001 8:33 AM
: Can the () in your data be nested?
:
: If so, you can't use an re. (See: How do I find matching/nesting anything?
: in perlfaq 4.) For example,
:
: while (){
:
:   print;
:   print "becomes\n";
:   s/\([^\)]+\)/()/g; # as Bill suggests

What if you make it
s/\([^\(\)]+\)|\(\(\)\)/()/g;
? You could also stick that in a while, print it at each iteration,
and watch the innermost parenthetical expressions disappear.

Joe

==
  Joseph P. Discenza, Sr. Programmer/Analyst
   mailto:[EMAIL PROTECTED]

  Carleton Inc.   http://www.carletoninc.com
  219.243.6040 ext. 300fax: 219.243.6060

Providing Financial Solutions and Compliance for over 30 Years



___
Perl-Win32-Users mailing list
[EMAIL PROTECTED]
http://listserv.ActiveState.com/mailman/listinfo/perl-win32-users



RE: RegEx: Finding and replacing all characters between ( and ) ?

2001-06-07 Thread Ron Hartikka

Charles,

Can the () in your data be nested?

If so, you can't use an re. (See: How do I find matching/nesting anything?
in perlfaq 4.) For example,

while (){

print;
print "becomes\n";
s/\([^\)]+\)/()/g; # as Bill suggests
print;
print "\n";

}
__DATA__
asdf(asdf)asdf
asdf((asdf))asdf

has the output...

asdf(asdf)asdf
becomes
asdf()asdf

asdf((asdf))asdf
becomes
asdf())asdf

I think you can use an re if you hard code a limit to the number of nests.

If you know there are no nested () you can use the re above.
If you know there is a limit to the nest depth, post the limit.
If you want to do unlimited nesting, you have to write a parser.


-Original Message-
From: [EMAIL PROTECTED]
[mailto:[EMAIL PROTECTED]]On Behalf Of
$Bill Luebkert
Sent: Thursday, June 07, 2001 12:35 AM
To: Charles Wilson (h)
Cc: [EMAIL PROTECTED]
Subject: Re: RegEx: Finding and replacing all characters between ( and )
?


"Charles Wilson (h)" wrote:
>
> I have been studying how to use Regular Expressions within my text editor
(Allaire's Coldfusion
> Studio- AKA Homesite).
>
> Specifically, I would like to find a left parenthese '(' then find a right
parenthese ')' in a file,
> and then delete out any amount of characters between the parentheses.  I'm
sure that using a Regular
> Expression to match the characters would be best, but I have tried all
different types of
> expressions such as:
>
> ((**))
> or
> ((*.*.*.*.*.*.))
>
> but it doesen't seem to work.
>
> Does anyone have any ideas?

Untested:

s/\([^\)]+\)/()/g;  # replace (...) with () multiple times (g)


--
  ,-/-  __  _  _ $Bill Luebkert   ICQ=14439852
 (_/   /  )// //   DBE Collectibles   http://www.todbe.com/
  / ) /--<  o // //  Mailto:[EMAIL PROTECTED] http://dbecoll.webjump.com/
-/-' /___/_<_http://www.freeyellow.com/members/dbecoll/
___
Perl-Win32-Users mailing list
[EMAIL PROTECTED]
http://listserv.ActiveState.com/mailman/listinfo/perl-win32-users

___
Perl-Win32-Users mailing list
[EMAIL PROTECTED]
http://listserv.ActiveState.com/mailman/listinfo/perl-win32-users



Re: Hash-of-hashes problem testing whether keys have values

2001-06-02 Thread Ron

Defined/Exists is NOT the issue here.

To paraphrase 'exists' entry in Camel 3 (but not Camel 2 or online docs):

When you say...

if(defined (((or exists $Hash{'Key1'}->{'Key2'} {'Key3'}){...

... Perl autovivifies the hash references $Hash{'Key1'} and
$Hash{'Key1'}->{'Key2'}.

You need to say this:

if ( exists $Hash{'Key1'}   and
 exists $Hash{'Key1'}{'Key2'} and
 exists $Hash{'Key1'}{'Key2'}{'Key3'} ) {...}

>From the docs:

"This surprising autovivification in what does not at first--or even
second--glance appear to be an lvalue context may be fixed in a future
release."




- Original Message -
From: "Ian Taite" <[EMAIL PROTECTED]>
To: <[EMAIL PROTECTED]>
Sent: Friday, June 01, 2001 5:09 AM
Subject: Hash-of-hashes problem testing whether keys have values


> After writing a system admin script that creates a hash-of-hashes data
> structure and then writes it to a series of files, I have encountered the
> following problem.
>
> With a simple hash, if I want to test whether a hash element has a value,
> I've used the following test:
>
> if ( defined $Hash{'Key'} )
> {
> # 'Key' has a value
> }
>
> However, if I try this on a hash-of-hashes, the test seems to create hash
> elements as shown by the following example:
>
> my %Hash;
> use Data::Dumper;
> print "Before\n";
> print Dumper %Hash;
> if(defined $Hash{'Key1'}->{'Key2'}->{'Key3'}){
> print "Defined.\n";
> }else{
> print "Not Defined.\n";
> };
> print "After\n";
> print Dumper %Hash;
>
>
> D:\>perl.exe hashtest.pl
> Before
> Not Defined.
> After
> $VAR1 = 'Key1';
> $VAR2 = {
>   'Key2' => {}
> };
>
> Maybe this behaviour is "by design" however, I still need to test whether
> certain data structure elements exist and the exhibited behavior is
> definitely not what I want.
>
> Any ideas how I can test whether the 'Key3' has a value without creating
> it's parent keys in the process?
>
> Regards, Ian.
>
>
>
>
>

> Note
>

>
> The information in this Email message, and any files transmitted with it,
> are confidential and intended only for use of the individual or entity
named
> as recipient. If the reader of this message is not the intended recipient
> you are hereby notified that any dissemination, processing, distribution
or
> copy of this material is strictly prohibited. If you have received this
> Email in error, please immediately notify our network manager on the
> telephone number below and delete the message. Your co-operation is
> appreciated.
>
> Any personal opinions expressed in this message are those of the sender
and
> should not be taken as representing the views of ITIS Holdings.
>
>

> Contact Details
>
>  ITIS Holdings
>  The Warrant House
>  1 The High Street
>  Altrincham
>  WA14 1PZ
>
>  Telephone - (44) 161 929 5788
>
> ___
> Perl-Win32-Users mailing list
> [EMAIL PROTECTED]
> http://listserv.ActiveState.com/mailman/listinfo/perl-win32-users
>


___
Perl-Win32-Users mailing list
[EMAIL PROTECTED]
http://listserv.ActiveState.com/mailman/listinfo/perl-win32-users



Re: regular expression question

2001-05-31 Thread Ron

No regex in answer here but...

Is this what you want?


use File::Basename;
$OK = "c:\\temp\\test\\test1\\test2";
$OK1 = dirname($OK);
print "dir of

$OK 

is 

$OK1\n";



- Original Message - 
From: <[EMAIL PROTECTED]>
To: <[EMAIL PROTECTED]>
Sent: Thursday, May 31, 2001 5:17 PM
Subject: regular expression question


> Dear all,
> I have a question about a regular expression, for example
> $OK = "c:\\temp\\test\\test1\\test2";
> How can I do to make me get
> $OK1 = "c:\\temp\\test\\test1";
> That means I do not want the last part of the directory.
> Thanks in advance!
> 
> Lixin
> ___
> Perl-Win32-Users mailing list
> [EMAIL PROTECTED]
> http://listserv.ActiveState.com/mailman/listinfo/perl-win32-users
> 


___
Perl-Win32-Users mailing list
[EMAIL PROTECTED]
http://listserv.ActiveState.com/mailman/listinfo/perl-win32-users



Re: Interacting with COM+ w/ Perl?

2001-05-30 Thread Ron Grabowski

> ' We have the database so lets set the properties that we want.
> CompObject.Value("ConstructionEnabled") = True
> CompObject.Value("ConstructorString") = Chr(34) +
> "Provider=SQLOLEDB;Driver={SQL Server};User
> ID=momma;Password=;DATABASE=BigDog;SERVER=" & strServer & ";" + Chr(34)
> 
> Anyone heard of interacting directly with the MS COM+ API's via Perl or some
> Perl Module?  I struck out searching www.perl.com

use OLE;

$CompObject = OLE CreateObject("CompObject.Foo"); # I forget the
syntax...
$CompObject->{ConstructionEnabled} = 1;
$CompObject->{ConstructorString} = char(34) .
"Provider=SQLOLEDB;Driver={SQL
Server};UserID=momma;Password=;DATABASE=BigDog;SERVER=$strServer;" .
chr(34);


What do you mean by 'interacting directly with the COM+ API'? Do you
want to make raw calls to the DLL with Win32::API as opposed to using
the COM interface?
___
Perl-Win32-Users mailing list
[EMAIL PROTECTED]
http://listserv.ActiveState.com/mailman/listinfo/perl-win32-users



Re: directory

2001-05-29 Thread Ron

Tanya,

next if($file =~ /^.+$/);# from Tushar

and...

next if $file eq '.' or file eq '..'; # from me

... do the same thing.

Unless you have a file called '...' or '...'  :)

Ron

- Original Message -
From: "Kulkarni, Tushar (GEL, MSX)" <[EMAIL PROTECTED]>
To: "'Tanya Graham'" <[EMAIL PROTECTED]>; "'Ron'" <[EMAIL PROTECTED]>; "perl
win32 users" <[EMAIL PROTECTED]>
Sent: Tuesday, May 29, 2001 7:16 PM
Subject: RE: directory


> Just put,
>
> at the start of your while loop. "." and ".." directories are
> special directories which refers to current directory and parent
directory.
> U need to skip this.
> Hope this solves ur problem
>
> Tushar
>
> -Original Message-
> From: Tanya Graham [mailto:[EMAIL PROTECTED]]
> Sent: Tuesday, May 29, 2001 7:03 PM
> To: 'Ron'; perl win32 users
> Subject: RE: directory
>
>
> ok, for some reason if i hardcode it, it is fine. it won't work if i try
and
> get it from STDIN.  anyway, here is my program:
> #!/usr/bin/perl
>
> $dirname = 'C:/PerlExp';
> opendir (DIR, $dirname) or die "can't open directory
> $dirname: $!";
>
> while ( defined ($file = readdir (DIR))){
> open (SOURCE, ">>$file") or die "can't open file $file for
> appending";
> seek (SOURCE, 0, 0) or die "can't point to beginning";
> print  SOURCE "copyright info yada yada yada" ;
> close (SOURCE);
> }
> closedir(DIR);
>
> i get the error "can't open file . for appending at C:|append.pl line 7"
> is it trying to open something called "."?  the files in that folder are
all
> like "tester.txt" "tester2.txt", etc
> any ideas?
> tanya
>
> -Original Message-
> From: Ron [mailto:[EMAIL PROTECTED]]
> Sent: Tuesday, May 29, 2001 4:12 PM
> To: perl win32 users
> Subject: Re: directory
>
>
> >From perlport document:
>
> =
> "System calls accept either / or \ as the path separator.
>
> However, many command?line utilities of DOS vintage treat / as the option
> prefix,
> so they may get confused by filenames containing /.
> Aside from calling any external programs, / will work just fine, and
> probably better,
> as it is more consistent with popular usage,
> and avoids the problem of remembering what to backwhack and what not to."
> =
>
> "System calls" includes opendir().
>
> By the way, I tested with both / and \ as file separators in the program I
> posted.
>
> - Original Message -
> From: "Tanya Graham" <[EMAIL PROTECTED]>
> To: <[EMAIL PROTECTED]>;
> <[EMAIL PROTECTED]>
> Sent: Tuesday, May 29, 2001 6:31 PM
> Subject: RE: directory
>
>
> > it still doesn't work...it says there is no such file or directory...why
> > does it use back slashes, but when i specify the path i'm supposed to
use
> > forward slashes?
> > tanya
> >
> > -Original Message-
> > From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED]]
> > Sent: Tuesday, May 29, 2001 3:35 PM
> > To: [EMAIL PROTECTED]
> > Subject: Re: directory
> >
> >
> >
> > >Hi,
> > >I am trying to open a directory, but I don't know how to specify it
> > exactly.
> > >I just need to open something in the C drive, under a folder named
> > PerlExp.
> > >I know this is a dumb question, but does anyone want to help me?
> > >thanks
> > >tanya graham
> >
> > Tanya,
> >
> > You can open directories in a mannor very similar to opening and reading
a
> > file.
> >
> > #--
> >
> > my $perlexp_dir = "C:/PerlExp";
> > opendir( DIRHNDLE, $perlexp_dir ) or die "Failed to open $perlexp_dir!";
> >
> > # if opendir works you now have a handle into the directory
> > # stored in DIRHNDLE. There are many ways to "work" with it
> >
> > # one way
> > my @file_list = readdir DIRHNDLE;
> > # now operate on the file_list array
> >
> > # another way
> > while ( defined( my $file = readdir DIRHNDLE ) ) {
> >  # operate on $file
> > }
> >
> > # another way
> > for my $file ( readdir DIRHNDLE ) {
> >  # operate on $file
> > }
> >
> > closedir( DIRHNDLE ) or die "Failed to close $perlexp_dir!";
>

RE: directory

2001-05-29 Thread Wantock, Ron L.

The file names that you are retrieving with the readdir command do not have
the full path on them.  To open them you need to append the path onto the
front.

open (SOURCE, ">>$dirname/$file");


wantor


> -Original Message-
> From: Tanya Graham [mailto:[EMAIL PROTECTED]]
> Sent: Tuesday, May 29, 2001 6:03 PM
> To: 'Ron'; perl win32 users
> Subject: RE: directory
> 
> 
> ok, for some reason if i hardcode it, it is fine. it won't 
> work if i try and
> get it from STDIN.  anyway, here is my program:
> #!/usr/bin/perl
> 
> $dirname = 'C:/PerlExp';
> opendir (DIR, $dirname)   or die "can't 
> open directory
> $dirname: $!";
> 
>   while ( defined ($file = readdir (DIR))){
>   open (SOURCE, ">>$file")or die "can't open file 
> $file for
> appending";
>   seek (SOURCE, 0, 0) or die "can't point to 
> beginning";
>   print  SOURCE "copyright info yada yada yada" ;
>   close (SOURCE);
> }
> closedir(DIR);
> 
> i get the error "can't open file . for appending at 
> C:|append.pl line 7"
> is it trying to open something called "."?  the files in that 
> folder are all
> like "tester.txt" "tester2.txt", etc
> any ideas?
> tanya
> 
> -Original Message-
> From: Ron [mailto:[EMAIL PROTECTED]]
> Sent: Tuesday, May 29, 2001 4:12 PM
> To: perl win32 users
> Subject: Re: directory
> 
> 
> From perlport document:
> 
> =
> "System calls accept either / or \ as the path separator.
> 
> However, many command?line utilities of DOS vintage treat / 
> as the option
> prefix,
> so they may get confused by filenames containing /.
> Aside from calling any external programs, / will work just fine, and
> probably better,
> as it is more consistent with popular usage,
> and avoids the problem of remembering what to backwhack and 
> what not to."
> =
> 
> "System calls" includes opendir().
> 
> By the way, I tested with both / and \ as file separators in 
> the program I
> posted.
> 
> - Original Message -
> From: "Tanya Graham" <[EMAIL PROTECTED]>
> To: <[EMAIL PROTECTED]>;
> <[EMAIL PROTECTED]>
> Sent: Tuesday, May 29, 2001 6:31 PM
> Subject: RE: directory
> 
> 
> > it still doesn't work...it says there is no such file or 
> directory...why
> > does it use back slashes, but when i specify the path i'm 
> supposed to use
> > forward slashes?
> > tanya
> >
> > -Original Message-
> > From: [EMAIL PROTECTED] 
> [mailto:[EMAIL PROTECTED]]
> > Sent: Tuesday, May 29, 2001 3:35 PM
> > To: [EMAIL PROTECTED]
> > Subject: Re: directory
> >
> >
> >
> > >Hi,
> > >I am trying to open a directory, but I don't know how to specify it
> > exactly.
> > >I just need to open something in the C drive, under a folder named
> > PerlExp.
> > >I know this is a dumb question, but does anyone want to help me?
> > >thanks
> > >tanya graham
> >
> > Tanya,
> >
> > You can open directories in a mannor very similar to 
> opening and reading a
> > file.
> >
> > #--
> >
> > my $perlexp_dir = "C:/PerlExp";
> > opendir( DIRHNDLE, $perlexp_dir ) or die "Failed to open 
> $perlexp_dir!";
> >
> > # if opendir works you now have a handle into the directory
> > # stored in DIRHNDLE. There are many ways to "work" with it
> >
> > # one way
> > my @file_list = readdir DIRHNDLE;
> > # now operate on the file_list array
> >
> > # another way
> > while ( defined( my $file = readdir DIRHNDLE ) ) {
> >  # operate on $file
> > }
> >
> > # another way
> > for my $file ( readdir DIRHNDLE ) {
> >  # operate on $file
> > }
> >
> > closedir( DIRHNDLE ) or die "Failed to close $perlexp_dir!";
> >
> > #--
> >
> > Remember pick ONE of the methods above as once you've "used 
> up" the handle
> > you need to close and re-open it to reset the cursor 
> position back to the
> > top!  The first method is best if you're going to need to 
> make more than
> > one pass (for the reason just stated) through the data.  
> Ope

Re: directory

2001-05-29 Thread Ron

'.' is the current directory and '..' is the parent of  '.'

The are in your list from readdir just as they are if you type 'dir' in a
DOS window.

Try this: (I added line tested elsewhere: next if $file eq '.' or file eq
'..';)

#!/usr/bin/perl

$dirname = 'C:/PerlExp';
opendir (DIR, $dirname) or die "can't open directory
$dirname: $!";

while ( defined ($file = readdir (DIR))){
next if $file eq '.' or file eq '..';
open (SOURCE, ">>$file") or die "can't open file $file for
appending";
seek (SOURCE, 0, 0) or die "can't point to beginning";
print  SOURCE "copyright info yada yada yada" ;
close (SOURCE);
}
closedir(DIR);


opendir(DIR, $some_dir) || die "canft opendir $some_dir: $!";
@dots = grep { /^\./ && -f "$some_dir/$_" } readdir(DIR);
closedir DIR;

- Original Message -
From: "Tanya Graham" <[EMAIL PROTECTED]>
To: "'Ron'" <[EMAIL PROTECTED]>; "perl win32 users"
<[EMAIL PROTECTED]>
Sent: Tuesday, May 29, 2001 7:03 PM
Subject: RE: directory


> ok, for some reason if i hardcode it, it is fine. it won't work if i try
and
> get it from STDIN.  anyway, here is my program:
> #!/usr/bin/perl
>
> $dirname = 'C:/PerlExp';
> opendir (DIR, $dirname) or die "can't open directory
> $dirname: $!";
>
> while ( defined ($file = readdir (DIR))){
> open (SOURCE, ">>$file") or die "can't open file $file for
> appending";
> seek (SOURCE, 0, 0) or die "can't point to beginning";
> print  SOURCE "copyright info yada yada yada" ;
> close (SOURCE);
> }
> closedir(DIR);
>
> i get the error "can't open file . for appending at C:|append.pl line 7"
> is it trying to open something called "."?  the files in that folder are
all
> like "tester.txt" "tester2.txt", etc
> any ideas?
> tanya
>
> -Original Message-
> From: Ron [mailto:[EMAIL PROTECTED]]
> Sent: Tuesday, May 29, 2001 4:12 PM
> To: perl win32 users
> Subject: Re: directory
>
>
> >From perlport document:
>
> =
> "System calls accept either / or \ as the path separator.
>
> However, many command?line utilities of DOS vintage treat / as the option
> prefix,
> so they may get confused by filenames containing /.
> Aside from calling any external programs, / will work just fine, and
> probably better,
> as it is more consistent with popular usage,
> and avoids the problem of remembering what to backwhack and what not to."
> =
>
> "System calls" includes opendir().
>
> By the way, I tested with both / and \ as file separators in the program I
> posted.
>
> - Original Message -
> From: "Tanya Graham" <[EMAIL PROTECTED]>
> To: <[EMAIL PROTECTED]>;
> <[EMAIL PROTECTED]>
> Sent: Tuesday, May 29, 2001 6:31 PM
> Subject: RE: directory
>
>
> > it still doesn't work...it says there is no such file or directory...why
> > does it use back slashes, but when i specify the path i'm supposed to
use
> > forward slashes?
> > tanya
> >
> > -Original Message-
> > From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED]]
> > Sent: Tuesday, May 29, 2001 3:35 PM
> > To: [EMAIL PROTECTED]
> > Subject: Re: directory
> >
> >
> >
> > >Hi,
> > >I am trying to open a directory, but I don't know how to specify it
> > exactly.
> > >I just need to open something in the C drive, under a folder named
> > PerlExp.
> > >I know this is a dumb question, but does anyone want to help me?
> > >thanks
> > >tanya graham
> >
> > Tanya,
> >
> > You can open directories in a mannor very similar to opening and reading
a
> > file.
> >
> > #--
> >
> > my $perlexp_dir = "C:/PerlExp";
> > opendir( DIRHNDLE, $perlexp_dir ) or die "Failed to open $perlexp_dir!";
> >
> > # if opendir works you now have a handle into the directory
> > # stored in DIRHNDLE. There are many ways to "work" with it
> >
> > # one way
> > my @file_list = readdir DIRHNDLE;
> > # now operate on the file_list array
> >
> > # another way
> > while ( defined( my $file = readdir DIRHNDLE ) ) {
> >  # operate on $file
> > }
> >
> > # another way
> > for 

Re: directory

2001-05-29 Thread Ron

You can use / inside single or double quotes.

You can use \ inside single quotes.

You can use \\ inside double quotes.

You can't use \ inside single quotes. (Not for a dir separator, anyway: Perl
assumes you are starting an escape sequence)

- Original Message -
From: <[EMAIL PROTECTED]>
To: <[EMAIL PROTECTED]>
Sent: Tuesday, May 29, 2001 6:56 PM
Subject: RE: directory


>
> >it still doesn't work...it says there is no such file or directory...why
> >does it use back slashes, but when i specify the path i'm supposed to use
> >forward slashes?
> >tanya
>
> See Response below...
>
>
> >>Hi,
> >>I am trying to open a directory, but I don't know how to specify it
> >>exactly.
> >>I just need to open something in the C drive, under a folder named
> >>PerlExp.
> >>I know this is a dumb question, but does anyone want to help me?
> >>thanks
> >>tanya graham
> >>
> >>>Tanya,
> >>>
> >>>
> >>>You can open directories in a mannor very similar to opening and
reading
> a
> >>>file.
> >>>
> >>>#--
> >>>
> >>>my $perlexp_dir = "C:/PerlExp";
> >>>opendir( DIRHNDLE, $perlexp_dir ) or die "Failed to open
$perlexp_dir!";
> >>>
> >>># if opendir works you now have a handle into the directory
> >>># stored in DIRHNDLE. There are many ways to "work" with it
> >>>
> >>># one way
> >>>my @file_list = readdir DIRHNDLE;
> >>># now operate on the file_list array
> >>>
> >>># another way
> >>>while ( defined( my $file = readdir DIRHNDLE ) ) {
> >>> # operate on $file
> >>>}
> >>>
> >>># another way
> >>>for my $file ( readdir DIRHNDLE ) {
> >>> # operate on $file
> >>>}
> >>>
> >>>closedir( DIRHNDLE ) or die "Failed to close $perlexp_dir!";
> >>>
> >>>#--
> >>>
> >>>Remember pick ONE of the methods above as once you've "used up" the
> handle
> >>>you need to close and re-open it to reset the cursor position back to
> the
> >>>top!  The first method is best if you're going to need to make more
than
> >>>one pass (for the reason just stated) through the data.  Open the
> handle,
> >>>read it into an array, and then you can close it immediately. Now you
> can
> >>>rip through the array as many times as needed without having to pay any
> IO
> >>>penalties. The while and for examples are handy for when you know you
> only
> >>>need to make a single pass through the file listing.
> >>>
> >>>HTH,
> >>>
> >>>Chuck
>
> forward slashes are just a way to save having to "escape" backslashes.
> Under Win32 you can specify paths 2 ways:
> my $dir = "C:\\winnt\\system32";
> or
> my $dir = "C:/winnt/system32";
>
> both are valid, perl makes the forward slashes backslashes before it does
> it's business.
>
> the reasons I'd suggest using forward slashes is #1 it helps avoid typos.
> I can't tell you how many times I see people having problems like yours
> where they forgot to escape a backslash - D:\winnt\\system32 won't work!
> #2 is portability, which may or may not concern you in any way, but
forward
> slashes are more "portable" should you ever need to write something that
> has to run on multiple platforms.
>
> I'm not sure why it's not working, could you maybe post some sample code?
> Are POSITIVE you are using a valid path?  have you read the docs for
> opendir/readdir?  (perldoc -f opendir, perldoc -f readdir)  Posting a code
> sample is often the quickest way to get questions resolved.
>
> Chuck
>
>
>
> ___
> Perl-Win32-Users mailing list
> [EMAIL PROTECTED]
> http://listserv.ActiveState.com/mailman/listinfo/perl-win32-users
>

___
Perl-Win32-Users mailing list
[EMAIL PROTECTED]
http://listserv.ActiveState.com/mailman/listinfo/perl-win32-users



Re: directory

2001-05-29 Thread Ron

>From perlport document:

=
"System calls accept either / or \ as the path separator.

However, many command?line utilities of DOS vintage treat / as the option
prefix,
so they may get confused by filenames containing /.
Aside from calling any external programs, / will work just fine, and
probably better,
as it is more consistent with popular usage,
and avoids the problem of remembering what to backwhack and what not to."
=

"System calls" includes opendir().

By the way, I tested with both / and \ as file separators in the program I
posted.

- Original Message -
From: "Tanya Graham" <[EMAIL PROTECTED]>
To: <[EMAIL PROTECTED]>;
<[EMAIL PROTECTED]>
Sent: Tuesday, May 29, 2001 6:31 PM
Subject: RE: directory


> it still doesn't work...it says there is no such file or directory...why
> does it use back slashes, but when i specify the path i'm supposed to use
> forward slashes?
> tanya
>
> -Original Message-
> From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED]]
> Sent: Tuesday, May 29, 2001 3:35 PM
> To: [EMAIL PROTECTED]
> Subject: Re: directory
>
>
>
> >Hi,
> >I am trying to open a directory, but I don't know how to specify it
> exactly.
> >I just need to open something in the C drive, under a folder named
> PerlExp.
> >I know this is a dumb question, but does anyone want to help me?
> >thanks
> >tanya graham
>
> Tanya,
>
> You can open directories in a mannor very similar to opening and reading a
> file.
>
> #--
>
> my $perlexp_dir = "C:/PerlExp";
> opendir( DIRHNDLE, $perlexp_dir ) or die "Failed to open $perlexp_dir!";
>
> # if opendir works you now have a handle into the directory
> # stored in DIRHNDLE. There are many ways to "work" with it
>
> # one way
> my @file_list = readdir DIRHNDLE;
> # now operate on the file_list array
>
> # another way
> while ( defined( my $file = readdir DIRHNDLE ) ) {
>  # operate on $file
> }
>
> # another way
> for my $file ( readdir DIRHNDLE ) {
>  # operate on $file
> }
>
> closedir( DIRHNDLE ) or die "Failed to close $perlexp_dir!";
>
> #--
>
> Remember pick ONE of the methods above as once you've "used up" the handle
> you need to close and re-open it to reset the cursor position back to the
> top!  The first method is best if you're going to need to make more than
> one pass (for the reason just stated) through the data.  Open the handle,
> read it into an array, and then you can close it immediately. Now you can
> rip through the array as many times as needed without having to pay any IO
> penalties. The while and for examples are handy for when you know you only
> need to make a single pass through the file listing.
>
> HTH,
>
> Chuck
>
>
> ___
> Perl-Win32-Users mailing list
> [EMAIL PROTECTED]
> http://listserv.ActiveState.com/mailman/listinfo/perl-win32-users
> ___
> Perl-Win32-Users mailing list
> [EMAIL PROTECTED]
> http://listserv.ActiveState.com/mailman/listinfo/perl-win32-users
>


___
Perl-Win32-Users mailing list
[EMAIL PROTECTED]
http://listserv.ActiveState.com/mailman/listinfo/perl-win32-users



Re: directory

2001-05-29 Thread Ron

use strict;
# change this to a dir on your system
my $some_dir = 'C:\My Documents\My Pictures\PowerPics';

# create dir handle DIR first
opendir(DIR, $some_dir) || die "can't opendir $some_dir: $!";

# array of file names from DIR
my @files =  readdir(DIR);

# do something with your data
print join "\n", @files; # print it, one per line

# clean up
closedir DIR;

# on my machine, this prints  (note that you get a line for 'dot' and 'dot
dot'):
.
..
AA001063.JPG
AA002716.JPG
AB000746.JPG
BU001686.JPG

-
Look at documenation for the functions:
perldoc -f opendir
perldoc -f readdir
perldoc -f closedir

- Original Message -
From: "Tanya Graham" <[EMAIL PROTECTED]>
To: <[EMAIL PROTECTED]>
Sent: Tuesday, May 29, 2001 6:09 PM
Subject: directory


> Hi,
> I am trying to open a directory, but I don't know how to specify it
exactly.
> I just need to open something in the C drive, under a folder named
PerlExp.
> I know this is a dumb question, but does anyone want to help me?
> thanks
> tanya graham
>
> -Original Message-
> From: Purcell, Scott [mailto:[EMAIL PROTECTED]]
> Sent: Tuesday, May 29, 2001 2:20 PM
> To: 'Dan Jablonsky'; [EMAIL PROTECTED]
> Subject: RE: remove duplicate lines
>
>
> I am not an expert here, but why compare each line. Read each line into a
> hash, whereas each line becomes a key, and set the value to something like
a
> 1, and your dups would be gone, quickly and I believe pretty efficiently.
>
> eg.
> my %textHash = ();
> open (SOMEDATAFILE, "<$pathToFile/theFile") or die("Can't open. $!")
> while () {
> next if ($_ =~ /^\s+$/); # possibly skip blank lines and any ohter
> stuff in yoiur files.
> chomp; # remove newline
> $texthash{$_} = 1;
> }
>
> Just a thought,
> Scott
>
>
>
> -Original Message-
> From: Dan Jablonsky [mailto:[EMAIL PROTECTED]]
> Sent: Tuesday, May 29, 2001 4:09 PM
> To: [EMAIL PROTECTED]
> Subject: remove duplicate lines
>
>
> Hi all,
> I need to remove duplicate lines from a whole bunch of
> files, I already have a script that does this but it's
> brute force (compare first line with the others one by
> one; if no match write it to another file), hence very
> inefficient. Somehow I believe there must be a nicer
> approach. Does anybody have a script that does that in
> an elegant/efficient manner?
> Thanks a lot,
> Dan
>
> __
> Do You Yahoo!?
> Yahoo! Auctions - buy the things you want at great prices
> http://auctions.yahoo.com/
> ___
> Perl-Win32-Users mailing list
> [EMAIL PROTECTED]
> http://listserv.ActiveState.com/mailman/listinfo/perl-win32-users
> ___
> Perl-Win32-Users mailing list
> [EMAIL PROTECTED]
> http://listserv.ActiveState.com/mailman/listinfo/perl-win32-users
> ___
> Perl-Win32-Users mailing list
> [EMAIL PROTECTED]
> http://listserv.ActiveState.com/mailman/listinfo/perl-win32-users
>

___
Perl-Win32-Users mailing list
[EMAIL PROTECTED]
http://listserv.ActiveState.com/mailman/listinfo/perl-win32-users



Re: Converting Word / Excel to PDF

2001-05-10 Thread Ron Grabowski

> > Anyone know of a why to do this in Perl?  I want to create a web
interface
> > where you upload a Word/Excel document and downloaded a PDF version.
>
> Adobe provides a service that does exactly this, for a nominal fee.  See
> (http://cpdf.adobe.com).  They handle Word, Excel, and a few other formats
> directly, and their technique for handling other formats is for you to
print to
> a Postscript file and send them that.  As for doing this yourself, I know
there
> are Perl packages for writing PDF, but I'm not sure about reading PS.
Word and
> Excel are Microsoft proprietary formats so I doubt you'll find any way to
read
> that reliably in Perl.

If you have an Acrobat PDF Printer ddriver installed, you could change the
printer on the program and print to that via the PDF Printer. There's been
discussion on the list over the past few days about printer related things
so that might be of help too.

- Ron

___
Perl-Win32-Users mailing list
[EMAIL PROTECTED]
http://listserv.ActiveState.com/mailman/listinfo/perl-win32-users



Re: Dictionary object problem with PerlScript ASP

2001-05-10 Thread Ron Grabowski

> Here's the VBScript version of some code I am trying to write in
PerlScript.
> (I don't want to use VBScript full-time)

VBScript is a lot faster than Perlscript when it comes to ASP.

> $Response->Redirect($dGatewayConfig->Item("foo"));

use Data::Dumper;
$Response->Write("" . Dumper( $dGatewayConfig ) . ");

See what that does. You might have to explicitly call ->Item('foo')->Value
or something. If the VBScript is working, I'd just use that.

- Ron



___
Perl-Win32-Users mailing list
[EMAIL PROTECTED]
http://listserv.ActiveState.com/mailman/listinfo/perl-win32-users



RE: Numbers in perl

2001-05-09 Thread Ron Hartikka

Well, printf is displaying a rounded version of the number - the number is
not disturbed.

Displaying the rounded version hides the fact that you are dealing with an
approximation - until it is too big to hide.

Often, that is long enough.

-Original Message-
From: [EMAIL PROTECTED]
[mailto:[EMAIL PROTECTED]]On Behalf Of
Peter Eisengrein
Sent: Tuesday, May 08, 2001 12:05 PM
To: 'Perl_Users'
Subject: RE: Numbers in perl


But isn't sprintf %1.1f just rounding the numbers anyway, thus continuing
the approximation? Why wouldn't perl (or the OS for that matter) multiply
the decimal to make it a whole number, do the arithmatic, then divide it by
the same value? For instance...

0.1 x 10 = 1. Add by increments of 1, then divide by 10. But I guess it
would still have to approximate the value in the final division, wouldn't
it?



-Original Message-
From: Philip Newton [mailto:[EMAIL PROTECTED]]
Sent: Tuesday, May 08, 2001 8:21 AM
To: '[EMAIL PROTECTED]'; 'Perl_Users'
Subject: Re: Numbers in perl


Geoff Ellis wrote:
> I don't understand why you have to format the number though...
> If someonce could point that out for us.. :o)

Read `perldoc -q decimal`.

Basically, it's because 0.1 is not representable exactly in binary, so the
value used is slightly different. Then when you add that inexact value
repeatedly, the rounding error starts to add up.

By using a printf format, you're rounding the number to a certain number of
decimal places and so it looks correct again, since the first 'n' decimal
places are still being computed correctly.

Cheers,
Philip
--
Philip Newton <[EMAIL PROTECTED]>
All opinions are my own, not my employer's.
If you're not part of the solution, you're part of the precipitate.
___
Perl-Win32-Users mailing list
[EMAIL PROTECTED]
http://listserv.ActiveState.com/mailman/listinfo/perl-win32-users
___
Perl-Win32-Users mailing list
[EMAIL PROTECTED]
http://listserv.ActiveState.com/mailman/listinfo/perl-win32-users

___
Perl-Win32-Users mailing list
[EMAIL PROTECTED]
http://listserv.ActiveState.com/mailman/listinfo/perl-win32-users



RE: re-evaluate as a scalar

2001-05-03 Thread Ron Hartikka

When I say, "But, it's not pretty to embed the function call in a print
statement", I mean you can't put a function call in a scalar. You can put it
in the list to print.

I haven't tried it, but I think you can put a tied scalar in a scalar and
get the tied behavior, which is what you want.

-Original Message-
From: [EMAIL PROTECTED]
[mailto:[EMAIL PROTECTED]]On Behalf Of Rob
Sent: Thursday, May 03, 2001 5:24 AM
To: Perl
Subject: re-evaluate as a scalar


Hi all!

I want to have scalar that includes another scalar:

use strict;
my $one = "";
$two = "Isn't this a nice $one!";

I want to assign a particular value to $one whenever I need and then output
$two so it will contain a 'dynamic' value of $one.

My problem is that perl interpolates into $two whatever value of $one it has
when the scalars are declared and then forgets it was ever a variable..

So how do I declare $two in such a way that perl will remember the embedded
$one is a scalar and re-evaluate it when I output $two?

Thanks!
Rob

___
Perl-Win32-Users mailing list
[EMAIL PROTECTED]
http://listserv.ActiveState.com/mailman/listinfo/perl-win32-users

___
Perl-Win32-Users mailing list
[EMAIL PROTECTED]
http://listserv.ActiveState.com/mailman/listinfo/perl-win32-users



RE: re-evaluate as a scalar

2001-05-03 Thread Ron Hartikka

You could use &two, a function, instead of $two a scalar...

for $one qw(a b c d){
print two();
}

sub two{"isn't this a nice $one!\n"}

prints...

isn't this a nice a!
isn't this a nice b!
isn't this a nice c!
isn't this a nice d!

But, it's not pretty to embed the function call in a print statement.

Or, you could 'tie' $two to a class defined to do the interpolation when
$two was on the right hand side. This, I think, will work in a print
statement. But, it's more work.

If you post what you are trying to do, you might get different answers.

-Original Message-
From: [EMAIL PROTECTED]
[mailto:[EMAIL PROTECTED]]On Behalf Of Rob
Sent: Thursday, May 03, 2001 5:24 AM
To: Perl
Subject: re-evaluate as a scalar


Hi all!

I want to have scalar that includes another scalar:

use strict;
my $one = "";
$two = "Isn't this a nice $one!";

I want to assign a particular value to $one whenever I need and then output
$two so it will contain a 'dynamic' value of $one.

My problem is that perl interpolates into $two whatever value of $one it has
when the scalars are declared and then forgets it was ever a variable..

So how do I declare $two in such a way that perl will remember the embedded
$one is a scalar and re-evaluate it when I output $two?

Thanks!
Rob

___
Perl-Win32-Users mailing list
[EMAIL PROTECTED]
http://listserv.ActiveState.com/mailman/listinfo/perl-win32-users

___
Perl-Win32-Users mailing list
[EMAIL PROTECTED]
http://listserv.ActiveState.com/mailman/listinfo/perl-win32-users



Re: CSV sorting

2001-04-25 Thread Ron

You may want to read about the Schawartzian Transform.

You can find this in many Perl resrources: Perl Cookbook, etc.

Here's a free example: http://www.effectiveperl.com/recipes/sorting.html


- Original Message -
From: "Walsh, Keith" <[EMAIL PROTECTED]>
To: <[EMAIL PROTECTED]>
Sent: Wednesday, April 25, 2001 6:42 PM
Subject: CSV sorting


> Hello all:
>
> I have what I hope is a very simple question.  In the script that I
> am writing I create a csv file that includes certain information I take
out
> of some logfiles.  The first column is the date, the second the time and
the
> third an NT user account.  My question is this, is there anyway that after
I
> create this file to sort by column a, then b, then c in a descending
order?
> There must be some way right?  Any help would be greatly appreciated.
>
> Thank you.
>
> ***
> Keith Walsh
> IT Security Technology
> 281.681.6605
>
>
>
>
> **
> This email and any files transmitted with it are confidential and
> intended solely for the use of the individual or entity to whom they
> are addressed. If you have received this email in error please notify
> the system manager.
>
>
> www.mimesweeper.com
> **
> ___
> Perl-Win32-Users mailing list
> [EMAIL PROTECTED]
> http://listserv.ActiveState.com/mailman/listinfo/perl-win32-users
>

___
Perl-Win32-Users mailing list
[EMAIL PROTECTED]
http://listserv.ActiveState.com/mailman/listinfo/perl-win32-users



RE: [OLE] Preventing the IE splash screen

2001-04-20 Thread ron . wantock

Outstanding!  M$ really hid that one didn't they.

One correction for anyone following this thread.  The key "Internet Explorer
needs to be two words, as in 

HKEY_LOCAL_MACHINE\SOFTWARE\Policies\Microsoft\Internet
Explorer\Infodelivery\Restrictions


Thanks Chuck,

wantor


> -Original Message-
> From: [EMAIL PROTECTED] 
> [mailto:[EMAIL PROTECTED]]
> Sent: Friday, April 20, 2001 4:38 PM
> To: [EMAIL PROTECTED]
> Subject: Re: [OLE] Preventing the IE splash screen
> 
> 
> 
> >Is there any way to prevent the Internet Explorer splash screen from
> >appearing when you create a non visible instance of an IE OLE object?
> >
> >
> >wantor
> 
> Found it.  This is for IE 5.0+ (I believe) and it is a 
> registry hack (found
> this in some of the IEAK docs we had around here)
> 
> open regedit and add do the following:
> 
> under:
> HKEY_LOCAL_MACHINE\SOFTWARE\Policies\Microsoft\InternetExplore
> r\Infodelivery\Restrictions
> 
> Add a DWORD value called NoSplash and set the value to 1
> 
> I hope that does it for ya,
> 
> Chuck
> 
> 
> 
> ___
> Perl-Win32-Users mailing list
> [EMAIL PROTECTED]
> http://listserv.ActiveState.com/mailman/listinfo/perl-win32-users
> 
___
Perl-Win32-Users mailing list
[EMAIL PROTECTED]
http://listserv.ActiveState.com/mailman/listinfo/perl-win32-users



[OLE] Preventing the IE splash screen

2001-04-20 Thread ron . wantock

Is there any way to prevent the Internet Explorer splash screen from
appearing when you create a non visible instance of an IE OLE object?


wantor
___
Perl-Win32-Users mailing list
[EMAIL PROTECTED]
http://listserv.ActiveState.com/mailman/listinfo/perl-win32-users



RE: [OLE] Printing from IE

2001-04-18 Thread ron . wantock

Yes, I did try printing the page manually.  When I print it manually, it
does not print the blank page.  I went through all the printer settings and
didn't see anything that would cause a form feed, but I will double check
them.  


wantor

> -Original Message-
> From: Jan Dubois [mailto:[EMAIL PROTECTED]]
> Sent: Wednesday, April 18, 2001 9:57 AM
> To: [EMAIL PROTECTED]
> Cc: [EMAIL PROTECTED]
> Subject: Re: [OLE] Printing from IE
> 
> 
> On Tue, 17 Apr 2001 18:42:06 -0500, [EMAIL PROTECTED] wrote:
> 
> >I'm working on an IE OLE app that navigates to multiple web 
> pages and prints
> >them.  I've come up with the code below.  The code works 
> great on NT, but
> >when I run it on 98, an extra (blank) page gets printed 
> along with each
> >content page.
> 
> Did you try printing manually on that 98 box?  Does it also print the
> extra page?  I would rather expect this to be a printer 
> driver / printer
> queue setting than an OLE automation problem.  Go through all 
> the printer
> properties and see if it uses a FF to separate print jobs etc.
> 
> -Jan
> 
___
Perl-Win32-Users mailing list
[EMAIL PROTECTED]
http://listserv.ActiveState.com/mailman/listinfo/perl-win32-users



Re: Reading a file from point A to B

2001-04-16 Thread Ron Grabowski

> my( $var );
> while( <> ) {
> $var = $_  if ( m!! .. m!! ) == 2;
> # Other line-by-line processing, if any, goes here.
> }

For those who are boggled by that, its explained in the Cookbook:

while (<>) {
if (/BEGIN PATTERN/ .. /END PATTERN/) {
# line falls between BEGIN and END in the
# text, inclusive.
}
}

while (<>) {
if ($FIRST_LINE_NUM .. $LAST_LINE_NUM) {
# operate only between first and last line, inclusive.
}
}

The ... operator doesn't test both conditions at once if the first one
is true.

while (<>) {
if (/BEGIN PATTERN/ ... /END PATTERN/) {
# line is between BEGIN and END on different lines
}
}

while (<>) {
if ($FIRST_LINE_NUM ... $LAST_LINE_NUM) {
# operate only between first and last line, but not same
}
}

Discussion

The range operators, .. and ..., are probably the least understood of
Perl's myriad operators. They were designed to allow easy extraction of
ranges of lines without forcing
the programmer to retain explicit state information. When used in a
scalar sense, such as in the test of if and while statements, these
operators return a true or false value that's
partially dependent on what they last returned. The expression
left_operand .. right_operand returns false until left_operand is true,
but once that test has been met, it
stops evaluating left_operand and keeps returning true until
right_operand becomes true, after which it restarts the cycle. To put it
another way, the first operand turns on
the construct as soon as it returns a true value, whereas the second one
turns it off as soon as it returns true.

These conditions are absolutely arbitrary. In fact, you could write
mytestfunc1() .. mytestfunc2(), although in practice this is seldom
done. Instead, the range operators
are usually used either with line numbers as operands (the first
example), patterns as operands (the second example), or both.

# command-line to print lines 15 through 17 inclusive (see below)
perl -ne 'print if 15 .. 17' datafile

# print out all  ..  displays from HTML doc
while (<>) {
print if m##i .. m##i;
}
___
Perl-Win32-Users mailing list
[EMAIL PROTECTED]
http://listserv.ActiveState.com/mailman/listinfo/perl-win32-users



Re: Having Problem with zero's dropping on left side of decimal placeHELP!

2001-04-12 Thread Ron Grabowski

> $RECNUM = 0;
> $RECCOUNT = 0;
> while(! $RS->EOF) {
> 
> for ( $i = 0; $i < $Count; $i++ )
> {
> $tmp = $RS->Fields($i)->value;
> $tmp =~ s/\s+$//;   # trim trailing white space
> $amt = $tmp;
> 
> # No datachecking here!  To turn this off, set the next line
> to "OFF";
> # This formats the SECOND field in the array (gotten from
> the database) to a
> # currency format.
> I think this is where my problem is:
> $DO_THIS_THING = "ON";
> if( $i == 1 && $DO_THIS_THING eq 'ON' )
> {
> $amt = sprintf( "%.2f", $tmp );
> }

for my $i ( 0 .. $Count ) {

 $amt = sprintf("%.2f", $RS->Fields($i)->Value ) if $i == 1;
 print OUT $amt, $FDELIM;

}

I wasn't able to reproduce any of the problems you were having.

 printf("%.2f","250.00");

Came out as expected: '250.00'

Could we have some reproducable sample code?
___
Perl-Win32-Users mailing list
[EMAIL PROTECTED]
http://listserv.ActiveState.com/mailman/listinfo/perl-win32-users



Re: net::telnet

2001-04-11 Thread Ron Grabowski




  > $telnet->cmd("su");
   
  su should require a password so normal users cannot 
  arbitrarly become root.
   


Re: The Perl Journal - Dead for good?

2001-04-10 Thread Ron Grabowski

> Does anyone know if TPJ is officially "dead" ?

When this discussion popped up on Slashdot I hurried up and ordered some
back issues and recieved them a few weeks ( well more than a few ) later.

As far as I know there aren't going to be any new issues published. Which is
a real shame, that was the only computing magazine I read.

___
Perl-Win32-Users mailing list
[EMAIL PROTECTED]
http://listserv.ActiveState.com/mailman/listinfo/perl-win32-users



  1   2   >