RE: Win32:OLE Excel last row question.

2004-02-13 Thread Charbeneau, Chuck

> From: Beckett Richard-qswi266 [mailto:[EMAIL PROTECTED] 
> Subject: Win32:OLE Excel last row question.

> This line successfully gives me the last used row in a populated
> spreadsheet:
> 
> my $LastRow = $sheet->UsedRange->Find({What=>"*",
> SearchDirection=>xlPrevious, SearchOrder=>xlByRows})->{Row};

my $LastRow = $sheet->UsedRange->Find({What=>"*",
SearchDirection=>xlPrevious, SearchOrder=>xlByRows})->{Row}
if $sheet->UsedRange->{Count}>1;

**
** LEGAL DISCLAIMER **
**

This E-mail message and any attachments may contain 
legally privileged, confidential or proprietary 
information. If you are not the intended recipient(s),
or the employee or agent responsible for delivery of 
this message to the intended recipient(s), you are 
hereby notified that any dissemination, distribution 
or copying of this E-mail message is strictly 
prohibited. If you have received this message in 
error, please immediately notify the sender and 
delete this E-mail message from your computer.
___
Perl-Win32-Users mailing list
[EMAIL PROTECTED]
To unsubscribe: http://listserv.ActiveState.com/mailman/mysubs


RE: List excel sheets

2004-01-23 Thread Charbeneau, Chuck

> From: Gianvittorio Negri [mailto:[EMAIL PROTECTED] 
> Subject: List excel sheets 

> I'm trying to list all the sheet contained in a single excel 
> file, in order build a script for 
> split a single excel multi-sheet in more single sheet excel 
> files using sheet name as file name. 
> The sheet number and sheet name are always different.
> I can't find anything regarding sheet in perl documentation.

http://perlmonks.org/index.pl?node_id=153486

Bottom of the page.  I list two different ways:

Range Example:

my $sheetcnt = $Book->Worksheets->Count();
foreach (1..$sheetcnt)
{
   print "\t" .$Book->Worksheets($_)->{Name} ."\n";
} 


'IN' Example

foreach my $Sheet(in $Book->{Worksheets})
{
   print "\t" .$Sheet->{Name} ."\n";
}


I suggest reading the entire tutorial.

C-.

**
** LEGAL DISCLAIMER **
**

This E-mail message and any attachments may contain 
legally privileged, confidential or proprietary 
information. If you are not the intended recipient(s),
or the employee or agent responsible for delivery of 
this message to the intended recipient(s), you are 
hereby notified that any dissemination, distribution 
or copying of this E-mail message is strictly 
prohibited. If you have received this message in 
error, please immediately notify the sender and 
delete this E-mail message from your computer.
___
Perl-Win32-Users mailing list
[EMAIL PROTECTED]
To unsubscribe: http://listserv.ActiveState.com/mailman/mysubs


RE: Reading Mail from Exchange Folder

2004-01-14 Thread Charbeneau, Chuck

> -Original Message-
> From: Richard DeWath [mailto:[EMAIL PROTECTED] 
> Subject: Reading Mail from Exchange Folder

> I am just learning about this and need some pointers
> on how I can write a Perl script that lets me read my
> new mail on an Exchange server [assume the Inbox],
> find mail with a fixed subject I am looking for, then
> process the data, move the mail to a "read" folder. 
> Any good examples, pointers or books that will let me
> do this using Activestate Perl for Windows?

Assuming you have outlook, this should get you started:


use strict;
use Win32::OLE qw(in with);
use Win32::OLE::Const 'Microsoft Outlook';

$Win32::OLE::Warn = 2; # Throw Errors, I'll catch them
my $outfile = 'c:\perl\projects\improvdb\nahatemailssorted.txt';
my $OL = Win32::OLE->GetActiveObject('Outlook.Application')  or die
Win32::OLE->LastError();

my $NameSpace = $OL->GetNameSpace("MAPI");
my $Folder = $NameSpace->GetDefaultFolder(olFolderInbox);

   foreach my $msg (in $Folder->{Items}){
   if ($msg->{Subject} =~ m//i)
   {
   #Here, there be move code
   }
   }


Also, I wrote a tutorial on using Excel and Win32::OLE on perlmonks, but the
beginning portion is applicable to all Win32::OLE use, and is worth the
read.

http://perlmonks.org/index.pl?node_id=153486

Otherwise, using Win32::MAPI would also be a choice.

Chuck Charbeneau
Lear Corporation
Lead Software Applications Engineer
ccharbeneau at lear dot com

**
** LEGAL DISCLAIMER **
**

This E-mail message and any attachments may contain 
legally privileged, confidential or proprietary 
information. If you are not the intended recipient(s),
or the employee or agent responsible for delivery of 
this message to the intended recipient(s), you are 
hereby notified that any dissemination, distribution 
or copying of this E-mail message is strictly 
prohibited. If you have received this message in 
error, please immediately notify the sender and 
delete this E-mail message from your computer.
___
Perl-Win32-Users mailing list
[EMAIL PROTECTED]
To unsubscribe: http://listserv.ActiveState.com/mailman/mysubs


RE: OLE again

2003-10-01 Thread Charbeneau, Chuck

> From: Michael D. Smith [mailto:[EMAIL PROTECTED] 
> Subject: Re: OLE again
> 

> In these examples from recent mailings to the list
> my $IE = Win32::OLE->GetActiveObject( 'WebBrowser.Application' );
> my $Excel = Win32::OLE->GetActiveObject('Excel.Application')


> The point in these example above was to start the 
> application.

No, actually, the point of those two code snippets is to get an 'Active
Object' of said type.  That is, if there is already an instance running,
connect to it instead of instantiating a new OLE server.

To START a new OLE server, you would use:


my $Excel = Win32::OLE->new('Excel.Application', 'Quit'); 


I usually do something like this (to cover all bases):



my $Excel = Win32::OLE->GetActiveObject('Excel.Application')
|| Win32::OLE->new('Excel.Application', 'Quit'); 



Which says "If there is already an instance running, use it, otherwise,
start me a new one."

I hope that helps,

Chuck Charbeneau
Lear Corporation
Lead Software Applications Engineer
ccharbeneau at lear dot com


**
** LEGAL DISCLAIMER **
**

This E-mail message and any attachments may contain 
legally privileged, confidential or proprietary 
information. If you are not the intended recipient(s),
or the employee or agent responsible for delivery of 
this message to the intended recipient(s), you are 
hereby notified that any dissemination, distribution 
or copying of this E-mail message is strictly 
prohibited. If you have received this message in 
error, please immediately notify the sender and 
delete this E-mail message from your computer.
___
Perl-Win32-Users mailing list
[EMAIL PROTECTED]
To unsubscribe: http://listserv.ActiveState.com/mailman/mysubs


RE: moving Excel Sheets via OLE

2003-08-14 Thread Charbeneau, Chuck

> From: [EMAIL PROTECTED] 
> Subject: moving Excel Sheets via OLE

I'm in a bit of a hurry right now, or I'd type out the code, but:

http://perlmonks.org/index.pl?node_id=153486

Bottom of my tutorial, Add and Move work the same.

YMMV, some restrictions may apply.

Chuck Charbeneau
Lear Corporation
Lead Software Applications Engineer
ccharbeneau at lear dot com

**
** LEGAL DISCLAIMER **
**

This E-mail message and any attachments may contain 
legally privileged, confidential or proprietary 
information. If you are not the intended recipient(s),
or the employee or agent responsible for delivery of 
this message to the intended recipient(s), you are 
hereby notified that any dissemination, distribution 
or copying of this E-mail message is strictly 
prohibited. If you have received this message in 
error, please immediately notify the sender and 
delete this E-mail message from your computer.
___
Perl-Win32-Users mailing list
[EMAIL PROTECTED]
To unsubscribe: http://listserv.ActiveState.com/mailman/mysubs


RE: Win32-OLE excel cell reference.

2003-08-10 Thread Charbeneau, Chuck

> From: Beckett Richard-qswi266 [mailto:[EMAIL PROTECTED] 
> Subject: Win32-OLE excel cell reference.


> It seems that the Range command likes data like (A14), or 
> (A14:B26), and I am happy with this.
> 
> My problem occurrs when I only have numeric data to work 
> with, because of incremented counters, or Count commands.
> 
> I have had success with Cells(1,14), but I cannot for the 
> life of me work out how to reference an area of cells like this...
> 
> Cells(1,14:5,28)


You have to use the range and cells object together, like so:



$Sheet1->Range($Sheet1->Cells(1,14), $Sheet1->Cells(5,28))->Select();



Chuck Charbeneau
Lear Corporation
Lead Software Applications Engineer
ccharbeneau at lear dot com

**
** LEGAL DISCLAIMER **
**

This E-mail message and any attachments may contain 
legally privileged, confidential or proprietary 
information. If you are not the intended recipient(s),
or the employee or agent responsible for delivery of 
this message to the intended recipient(s), you are 
hereby notified that any dissemination, distribution 
or copying of this E-mail message is strictly 
prohibited. If you have received this message in 
error, please immediately notify the sender and 
delete this E-mail message from your computer.
___
Perl-Win32-Users mailing list
[EMAIL PROTECTED]
To unsubscribe: http://listserv.ActiveState.com/mailman/mysubs


RE: Win32-OLE excel cell reference.

2003-08-10 Thread Charbeneau, Chuck

> From: Ross Matt-QMR000 [mailto:[EMAIL PROTECTED] 
> Subject: RE: Win32-OLE excel cell reference.

> by no means did mean anything negative about what you 
> wrote in reply. You have ALWAYS been very helpful to me and 
> others with your posts. 


No worries.  I didn't take any offense, just offering a little more info to
the mix regarding using Cell and Range.  If the user could only use ints,
then Cell is the only way he could go.  Personally, I would have just
converted to letters and used a multiple entry range

$Sheet->Range("a1:c3, r5, c5:t3")->

 but be that as it may.

I have pretty thick skin and will usually throw the bozo bit before I get
too rankled anyway.

Keep up the good work,

Chuck Charbeneau
Lear Corporation
Lead Software Applications Engineer
ccharbeneau at lear dot com

**
** LEGAL DISCLAIMER **
**

This E-mail message and any attachments may contain 
legally privileged, confidential or proprietary 
information. If you are not the intended recipient(s),
or the employee or agent responsible for delivery of 
this message to the intended recipient(s), you are 
hereby notified that any dissemination, distribution 
or copying of this E-mail message is strictly 
prohibited. If you have received this message in 
error, please immediately notify the sender and 
delete this E-mail message from your computer.
___
Perl-Win32-Users mailing list
[EMAIL PROTECTED]
To unsubscribe: http://listserv.ActiveState.com/mailman/mysubs


RE: How to recurse through a directory and do something with each file

2003-08-04 Thread Charbeneau, Chuck

> From: Subrahmanyam Vadlamani [mailto:[EMAIL PROTECTED] 
> Subject: How to recurse through a directory and do something 
> with each file


> I would like to recurse through a directory and do
> something with the files in the directory (and all sub-directories).
> 
> What is the most efficient way of doing this?  What
> are some modules that I could use?

search.cpan.org

http://search.cpan.org/search?query=File+Directory+recursive&mode=all

top entry (File::Recurse)

or File::Find would probably also help, though these search first and ask
questions (process) later in their example usages.

I'm sure there are others out there, and that they will be mentioned, but
what have you tried thus far?

Chuck Charbeneau
Lear Corporation
Lead Software Applications Engineer
ccharbeneau at lear dot com

**
** LEGAL DISCLAIMER **
**

This E-mail message and any attachments may contain 
legally privileged, confidential or proprietary 
information. If you are not the intended recipient(s),
or the employee or agent responsible for delivery of 
this message to the intended recipient(s), you are 
hereby notified that any dissemination, distribution 
or copying of this E-mail message is strictly 
prohibited. If you have received this message in 
error, please immediately notify the sender and 
delete this E-mail message from your computer.
___
Perl-Win32-Users mailing list
[EMAIL PROTECTED]
To unsubscribe: http://listserv.ActiveState.com/mailman/mysubs


RE: dynamic reports

2003-07-30 Thread Charbeneau, Chuck

> From: steve silvers [mailto:[EMAIL PROTECTED] 
> Subject: Re: dynamic reports

> Crystal Reports..

> >"Does anyone have a idea as to the best way to do this?
> >Perl ?
> >XML ?
> >C and postgres ?


All of the above an accomplish what you are looking for.

Crystal offers you controls that dynamically create your queries offering
you a "smoother" interface (I never really liked crystal because of some
scaling issues) but in most cases, you are going to have to include those
controls in code (take your pick of languages).

Perl (or any pure language approach) is more of a brute force approach,
meaning that you are going to have to handle all of the db connections,
rendering techniques, data sets, etc.

XML is nice, as you could retrieve a large amount of data to a data island
and work XSL against it as the queries change.

Honestly, for most small and medium applications, if you were to go with a
code approach (Perl, C, .NET, whatever) I would say use a combination of
Data sets and XML/XSLT.  For applications of any real size, however, you
might want to start looking at an off the shelf package.  We use Actuate
(but there are others out there), and have had pretty decent ROI given the
number of reports we run (1000s a day), etc.

Chuck Charbeneau
Lear Corporation
Lead Software Applications Engineer
ccharbeneau at lear dot com

**
** LEGAL DISCLAIMER **
**

This E-mail message and any attachments may contain 
legally privileged, confidential or proprietary 
information. If you are not the intended recipient(s),
or the employee or agent responsible for delivery of 
this message to the intended recipient(s), you are 
hereby notified that any dissemination, distribution 
or copying of this E-mail message is strictly 
prohibited. If you have received this message in 
error, please immediately notify the sender and 
delete this E-mail message from your computer.
___
Perl-Win32-Users mailing list
[EMAIL PROTECTED]
To unsubscribe: http://listserv.ActiveState.com/mailman/mysubs


RE: Cpan colors

2003-07-23 Thread Charbeneau, Chuck

Forgot to send this to everyone: 

Or he could go to: 
 
http://search.cpan.org
 
click on the link which reads:
 
"Why is this site Orange?" 
 
and leads here:
 
http://search.cpan.org/orange.html

And read how he can get it back.

C-.

**
** LEGAL DISCLAIMER **
**

This E-mail message and any attachments may contain 
legally privileged, confidential or proprietary 
information. If you are not the intended recipient(s),
or the employee or agent responsible for delivery of 
this message to the intended recipient(s), you are 
hereby notified that any dissemination, distribution 
or copying of this E-mail message is strictly 
prohibited. If you have received this message in 
error, please immediately notify the sender and 
delete this E-mail message from your computer.
___
Perl-Win32-Users mailing list
[EMAIL PROTECTED]
To unsubscribe: http://listserv.ActiveState.com/mailman/mysubs


RE: Using Outlook in Win32::OLE

2003-06-17 Thread Charbeneau, Chuck

> From: Bautista, Rodel D.(Digitel-GSM) 
> Subject: FW: Using Outlook in Win32::OLE

> I'm entirely at a loss here. I'm in dire need of help with my 
> problem below. I've tried searching for a perl script that 
> automatically connect/log me to an outlook application and 
> send a mail with an attachment but all I found was a script 
> that asks me for a profile and logon info before actually 
> sending the mail.


Maybe I'm missing the point, but why would you want the overhead of using
Outlook, when you could just connect to the Exchange server as an SMTP
server and send a MIME encoded email that way?  The code would be platform
independent, smaller, and not require Outlook be installed on any machine
that wants to use it?

Chuck Charbeneau
Lear Corporation
Lead Software Applications Engineer
ccharbeneau at lear dot com

**
** LEGAL DISCLAIMER **
**

This E-mail message and any attachments may contain 
legally privileged, confidential or proprietary 
information. If you are not the intended recipient(s),
or the employee or agent responsible for delivery of 
this message to the intended recipient(s), you are 
hereby notified that any dissemination, distribution 
or copying of this E-mail message is strictly 
prohibited. If you have received this message in 
error, please immediately notify the sender and 
delete this E-mail message from your computer.
___
Perl-Win32-Users mailing list
[EMAIL PROTECTED]
To unsubscribe: http://listserv.ActiveState.com/mailman/mysubs


RE: Outlook 2000/XP

2003-04-01 Thread Charbeneau, Chuck

> From: Christopher Moss [mailto:[EMAIL PROTECTED] 
> Subject: RE: Outlook 2000/XP

> Thanks for the suggestion Chuck I did manager to get there 
> with Mime-Lite, once I'd managed to work how it talked to the 
> SMTP server! The main issue being the send->("smtp", 
> [Hostname])line which slightly confused me! A case of RTFM I suppose!!

And knowing is half the battle.

Null perspiration,

C-.

**
** LEGAL DISCLAIMER **
**

This E-mail message and any attachments may contain 
legally privileged, confidential or proprietary 
information. If you are not the intended recipient(s),
or the employee or agent responsible for delivery of 
this message to the intended recipient(s), you are 
hereby notified that any dissemination, distribution 
or copying of this E-mail message is strictly 
prohibited. If you have received this message in 
error, please immediately notify the sender and 
delete this E-mail message from your computer.
___
Perl-Win32-Users mailing list
[EMAIL PROTECTED]
To unsubscribe: http://listserv.ActiveState.com/mailman/mysubs


RE: Outlook 2000/XP

2003-03-28 Thread Charbeneau, Chuck

> From: Christopher Moss [mailto:[EMAIL PROTECTED] 
> Subject: Outlook 2000/XP


> I'm trying to test sending emails from Perl using OLE on MS Outlook 
> (2000 or XP). I have written the following simple script (mainly based 
> on previous postings):

Seems like a lot of overhead to send an email.

Why not use NET::SMTP or MIME::Lite?  Unless your exchange server (or other
mail server) won't accept an SMTP connection or there is something else you
are trying to accomplish that you didn't share, Outlook is a big ole axe
when all you need are a pair of nail clippers.

C-.

"Watch your Toes"

**
** LEGAL DISCLAIMER **
**

This E-mail message and any attachments may contain 
legally privileged, confidential or proprietary 
information. If you are not the intended recipient(s),
or the employee or agent responsible for delivery of 
this message to the intended recipient(s), you are 
hereby notified that any dissemination, distribution 
or copying of this E-mail message is strictly 
prohibited. If you have received this message in 
error, please immediately notify the sender and 
delete this E-mail message from your computer.
___
Perl-Win32-Users mailing list
[EMAIL PROTECTED]
To unsubscribe: http://listserv.ActiveState.com/mailman/mysubs


RE: Excel question

2003-02-03 Thread Charbeneau, Chuck

> From: Rivera, Oscar [mailto:[EMAIL PROTECTED]]
> Subject: Excel question
> 
> 
> Hello,
> I want to copy a range of cells (A2-F300) from a "export.csv"
> file and append it to "myfile.xls" and save the file. can 
> some  one help?


a CSV file really doesn't contain the row, column information, as it is only
text, but it will map into excel correctly.

What have you tried so far?

I usually suggest that if you're new to using excel, read this:

http://perlmonks.org/index.pl?node_id=153486

What you could do is open one instance of Excel, open both files as separate
objects, activate the CSV file, Select your given range, activate the Excel
file, find the last row and column, and then paste the Applications current
selection starting at the range of the last row and column.  This will work
if the data areas are the same shape.  

If you have to iterate through the CSV data and put it in different rows and
columns, just open the CSV file as a txt file directly in perl, iterate
through the file and insert the data one cell or row (line of CSV data) at a
time into the excel file, saving when you are complete.

Chuck Charbeneau

**
** LEGAL DISCLAIMER **
**

This E-mail message and any attachments may contain 
legally privileged, confidential or proprietary 
information. If you are not the intended recipient(s),
or the employee or agent responsible for delivery of 
this message to the intended recipient(s), you are 
hereby notified that any dissemination, distribution 
or copying of this E-mail message is strictly 
prohibited. If you have received this message in 
error, please immediately notify the sender and 
delete this E-mail message from your computer.
___
Perl-Win32-Users mailing list
[EMAIL PROTECTED]
To unsubscribe: http://listserv.ActiveState.com/mailman/mysubs



RE: Making a line graph

2002-12-04 Thread Charbeneau, Chuck
> From: Ian Robertson [mailto:[EMAIL PROTECTED]] 
> Subject: Making a line graph


> I need to write a script to produce a line graph 
> (quick and dirty to prove a point)!
 
>Can anybody recommend the best module to use?

The Chart module offers a quick interface.

C-.



use strict;
use Chart::Lines; 
my $outfile = '\graphoutput.png';

my @LEGENDS = qw (SetOne SetTwo SetThree SetFour) ;
my @plotdata = (
["First", "Second", "Third", "Fourth", "Fifth", "Sixth"],
[12, 9, 2, 23, 9, -2],
[1, 3, 5, 7, 9, 11],
[3, 17, 7, 9, 11, 13],
[0, 12, 0, 12, 0, 12],
);
my $graph = Chart::Lines->new (640,480) or die $!;;
   $graph->set(
grid_lines => 'true',
title => 'Title of my Graph',
dclrs => [qw(
lred lorange lyellow lgreen lblue lpurple
dred  orange dyellow dgreen dblue dpurple
)],
   );
$graph->set ('legend_labels' => \@LEGENDS);
$graph->png($outfile, \@plotdata);


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



RE: Excel, OLE, and Activestae PERL 5.6.1 rel 633 on Windows 2K.

2002-10-30 Thread Charbeneau, Chuck
> From: Daniel Needles [mailto:daniel.needles@;Callisma.com] 
> Subject: Excel, OLE, and Activate PERL 5.6.1 rel 633 on Windows 2K.

> The following program:
[SNIP]
> 
> C:\Documents and Settings\dln1\AANC>perl test.pl
> 
>   Win32::OLE(0.1502) error 0x80070005: "Access is denied" in 
> PROPERTYPUT "Visible" at test.pl line 6
>   Win32::OLE(0.1502) error 0x80070005: "Access is denied" in 
> METHOD/PROPERTYGET "" at test.pl line 7
>   Can't call method "Open" on an undefined value at test.pl line 7.


I'll ask the same questions I asked on Perl Monks to this:

Do you have Excel Installed on this Machine?
What happens when you put error checking in?


use strict;
use Win32::OLE qw(in with);
use Win32::OLE::Const 'Microsoft Excel';

$Win32::OLE::Warn = 3; # Die on Errors.

my $excelfile = 'book1.xls';

my $Excel = Win32::OLE->GetActiveObject('Excel.Application')
|| Win32::OLE->new('Excel.Application', 'Quit')
|| die Win32::OLE->LastError(); 

   $Excel->{DisplayAlerts}=0;   

my $Book = $Excel->Workbooks->Open($excelfile) or die
Win32::OLE->LastError();

print Win32::OLE->LastError();


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



RE: manipulating Excel

2002-09-11 Thread Charbeneau, Chuck

> From: Beckett Richard-qswi266 [mailto:[EMAIL PROTECTED]] 
> Subject: RE: manipulating Excel


> I have two (silly) questions, already...

Nothing is silly if in the pursuit of knowledge.

> I have an excel file in the directory that the script is 
> running from, called results.xls, however I can't open it with:
> 
> my $Book = $Excel->Workbooks->Open("results.xls");
> 
> I have to use :
> 
> my $Book = $Excel->Workbooks->Open("d:\\perl\\my 
> scripts\\results.xls");
> 
> Is there a way around this, as when I ship my completed 
> script, the files will all be in the same dir, but that dir 
> is likely to vary, depending on where the user puts it?

If this is working as web script on IIS (I can't speak for others), then the
cwd will end up being the WEB SERVERS working directory.  I would suggest
including some code to apply the users environment info to the script,
either through an ini or settings text, command line, etc.



> Secondly, when the script exits, save and replace-file 
> dialogue boxes pop up. I have tried to disable these with:
> 
> $Excel->{DisplayAlerts}=0;
> 
> but the script does not make any changes to the spreadsheet. 
> It gives no warnings or errors, either. I tried replacing the 
> {} with (), but this gave an error.


hmm, try this instead:  

#my $vttrue =  Variant(VT_BOOL, 1);

my $vtfalse =  Variant(VT_BOOL, 0);
   $Excel->{DisplayAlerts}=$vtfalse;

HTH,

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



RE: manipulating Excel

2002-09-11 Thread Charbeneau, Chuck

> From: Jacobson, Karl [mailto:[EMAIL PROTECTED]] 
> Subject: manipulating Excel
> 
> 
> I would like to change formats and the like in Excel.   Is 
> that possible
> (within my Perl scripts of course) and where would I find 
> information on this?


I wrote a tutorial on Perlmonks on just this topic, feel free to give it a
read:

http://perlmonks.org/index.pl?node_id=153486

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



RE: Displaying time in PERL

2002-08-09 Thread Charbeneau, Chuck

> From: Bellenger, Bruno (Paris) [mailto:[EMAIL PROTECTED]]
> Subject: RE: Displaying time in PERL

> Shortest one so far. And not even bad on the obfuscation criteria. 
> Well done. 

> > printf ("%02d:%02d:%02d",(localtime(time))[2,1,0]);


I can't take credit for it, I saw someone else use a slice under a similar
circumstance, and just applied it in this situation.  But thank you.

I found it to be so useful that I macro'd it in my IDE like so:

printf ("%02d:%02d:%02d - MESSAGE\n",(localtime(time))[2,1,0]);


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



RE: Displaying time in PERL

2002-08-09 Thread Charbeneau, Chuck

> From: Charbeneau, Chuck [mailto:[EMAIL PROTECTED]]
> Subject: RE: Displaying time in PERL
> 
> 
> printf ("%02d:%02d:%02d",(localtime(time))[2,1,0]);
> 
> Chuch Charbeneau
  ^
  |  
But how can you trust the code from a man who can't spell his own name?

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



RE: Displaying time in PERL

2002-08-09 Thread Charbeneau, Chuck

printf ("%02d:%02d:%02d",(localtime(time))[2,1,0]);

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



RE: Newton Raphson's or Bisection Interpolation in perl

2002-06-07 Thread Charbeneau, Chuck

> From: parvez [mailto:[EMAIL PROTECTED]]
> Subject: Newton Raphson's or Bisection Interpolation in perl

> Does anybody know of a module that helps in interpolation using
> Newton Raphson's method or Bisection method in Perl.


Wolf book, Chapter 16, pgs. 638 - 640.

You can probably get the code from the example at the O'Reilly site in the
examples

http://examples.oreilly.com/maperl/

look in the ch16 dir, the file "root"

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



RE: Problem Converting a Timestamp in Excel

2002-05-20 Thread Charbeneau, Chuck

-Original Message-
From: Arul, Rex [mailto:[EMAIL PROTECTED]]
Subject: Problem Converting a Timestamp in Excel


> Hello Friends, 
> In the Excel spreadsheet, I am trying to cull out data, there 
> is a column with values of this format: 22:15 (10:15:00 PM)
> However, while trying to get the data, I am getting decimal 
> values of this format(for the same 10:15:00 PM): 0.9270833 
> I am sure the Perl code is seeing it not as an object of OLE::Variant 
> or any other Excel object type, as my code is returning nothing when 
> I use the ref function for all the cells of the particular column. If 
> it did, then I could have used the Value() function of OLE::Variant class.
> Please help. 
> Thanks, 
> Rex 

I would say that it IS seing it as a variant type

Try forcing the type like so:


use strict;

use Win32::OLE qw(in with);
use Win32::OLE::Const 'Microsoft Excel';
use Win32::OLE::Variant;
use Win32::OLE::NLS qw(:LOCALE :DATE :TIME);

my $Excel = Win32::OLE->GetActiveObject('Excel.Application');

   $Excel->{DisplayAlerts}=0;  
   
   my $Book = $Excel->{ActiveWorkbook};
   my $Sheet = $Book->Worksheets("Sheet1");
   $Sheet->Activate();
   
   my $dt = Variant(VT_DATE, $Sheet->Range("a2")->{Value});

  ## A2 has your decimal value, You can also input a time value, 
  ## (10:22:54 pm) and it will work
  
print $dt->Time, "\n";
print $dt->Time(TIME_FORCE24HOURFORMAT|TIME_NOTIMEMARKER), "\n";
print $dt->Time("hh.mm.ss tt"), "\n";



The following is directly from the ::Variant docs

.-=.-=.-=.-=.-=.-=.-=.-=.-=.-=.-=.-=.-=.-=.-=.-=.-=.-=.-=.-=.-=.-=.-=.-=

Converts the VARIANT into a formatted time string.  FORMAT can be either
one of the following integer constants or a format string:

LOCALE_NOUSEROVERRIDE   system default time format for this locale
TIME_NOMINUTESORSECONDS don't use minutes or seconds
TIME_NOSECONDS  don't use seconds
TIME_NOTIMEMARKER   don't use a time marker
TIME_FORCE24HOURFORMAT  always use a 24-hour time format

The constants are available from the Win32::OLE::NLS module:

use Win32::OLE::NLS qw(:LOCALE :TIME);

The following elements can be used to construct a time format string.
Characters must be specified exactly as given below (e.g. "dd" B "DD").
Spaces can be inserted anywhere between formating codes, other verbatim
text should be included in single quotes.

h   hours; 12-hour clock
hh  hours with leading zero for single-digit hours; 12-hour
clock
H   hours; 24-hour clock
HH  hours with leading zero for single-digit hours; 24-hour
clock
m   minutes
mm  minutes with leading zero for single-digit minutes
s   seconds
ss  seconds with leading zero for single-digit seconds
t   one character time marker string, such as A or P
tt  multicharacter time marker string, such as AM or PM

.-=.-=.-=.-=.-=.-=.-=.-=.-=.-=.-=.-=.-=.-=.-=.-=.-=.-=.-=.-=.-=.-=.-=.-=

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



RE: Distance between 2 latitudes and longitudes

2002-03-06 Thread Charbeneau, Chuck

This time, I'll post it to the list:

> From: Lee Goddard [mailto:[EMAIL PROTECTED]]
> Subject: Re: Distance between 2 latitudes and longitudes

> At 10:14 06/03/2002 -0600, MOTTER, JEFFREY D. wrote:
> >Does any know where I can find a script to calculate the 
> distance between 2
> >seperate latitudes and longitudes?


I must have missed the original post.  There are actually a couple of
different methods for determining the distance between 2 long/lat pairs and
you need to be aware of the accuracy of each. The Great Circle method is the
least accurate IIRC, but is the most accessible, as it is a part of
Math::Trig.  

I wrote some code to do this using the various methods. Actually, it finds
the distances between two zip codes for which the long/lat pairs are known,
but I'll remove the database stuff for you and just give the pertinent code.

You should also read:

http://www.chilidog.com/zip/zipnotes.html
http://mathforum.org/dr.math/problems/neff.04.21.99.html

and my favorite:

http://op.gfz-potsdam.de/GMT-Help/Archive/msg00143.html



use Math::Trig qw(deg2rad pi great_circle_distance asin acos);

  
my ($lat1, $long1);
my ($lat2, $long2);

print "Haversine   : ". &Haversine($lat1, $long1, $lat2, $long2) ."\n";
print "Law Cosines : ". &LawCosines($lat1, $long1, $lat2, $long2)."\n";
print "Flat-Earth  : ". &FlatEarth($lat1, $long1, $lat2, $long2) ."\n";
print "Great Circle: ". &GreatCircle($lat1, $long1, $lat2, $long2)."\n";
   

sub LawCosines {
my ($lat1, $long1, $lat2, $long2) = @_;
my $r=3956;

my $dist = acos(sin(deg2rad($lat1))*
sin(deg2rad($lat2))+
cos(deg2rad($lat1))*
cos(deg2rad($lat2))*
cos(deg2rad($long2)- deg2rad($long1))) * $r;
return $dist;

}

sub FlatEarth {
my ($lat1, $long1, $lat2, $long2) = @_;
my $r=3956;

my $a = (pi/2)- deg2rad($lat1);   
my $b = (pi/2)- deg2rad($lat2);
my $c = sqrt($a**2 + $b**2 - 2 * $a *$b
*cos(deg2rad($long2)-deg2rad($long1)));
my $dist = $c * $r;

return $dist;

}

sub Haversine {
my ($lat1, $long1, $lat2, $long2) = @_;
my $r=3956;

   
$dlong = deg2rad($long1) - deg2rad($long2);
$dlat  = deg2rad($lat1) - deg2rad($lat2);

$a = sin($dlat/2)**2 +cos(deg2rad($lat1)) 
* cos(deg2rad($lat2))
* sin($dlong/2)**2;
$c = 2 * (asin(sqrt($a)));
$dist = $r * $c;   


return $dist;

}

sub GreatCircle {
my ($lat1, $long1, $lat2, $long2) = @_;
my $r=3956;
my @zip1 = (deg2rad($long1), deg2rad(90-$lat1));
my @zip2 = (deg2rad($long2), deg2rad(90-$lat2));
my $dist = great_circle_distance(@zip1, @zip2,$r);
 

return $dist;

}



Hope that helps.

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



RE: disk quota

2001-11-12 Thread Charbeneau, Chuck

> From: lonh SENG [mailto:[EMAIL PROTECTED]]
> Subject: disk quota


> Can you help me?

Yes, we can.  

> I want to write a script to create disk quota for all home 
> directories of all users.  Their sizes are the same.

As a matter of fact, I wrote exactly that for the ME department at Michigan
Tech.  But what have you tried already?  Many of us here would hardly want
to do either your job or your homework for you without first seeing what you
have already tried.  But we would be more than willing to help you along the
way to enlightenment.

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



RE: Editing word documents

2001-10-10 Thread Charbeneau, Chuck

> From: Christopher Hahn [mailto:[EMAIL PROTECTED]]
> Subject: RE: Editing word documents

> I wanted to ask again whether anyone had found a useful
> *book* that deals with OLE from perl.  MS's MSDN site seems
> designed so as to spread the info out to such an extent that
> I do not see the big picture when browsing there.


"Windows NT WIN32 Perl Programming: The Standard Extensions" by Dave Roth 
ISBN: 1578700671

More info on Dave and what he does and has written:  http://www.roth.net/

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



RE: OLE Resource

2001-07-05 Thread Charbeneau, Chuck

Typo - Should have been: "WIN32 Perl Scripting: The Administrator's
Handbook".  

Sorry.

Chuck.

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



RE: OLE Resource

2001-07-05 Thread Charbeneau, Chuck

> From: Wells, Doug [mailto:[EMAIL PROTECTED]]
> Subject: OLE Resource

> What are some good books/resources for learning more about 
> Perl/OLE scripting? 


Also, Dave Roth's books have been an INCREDIBLE resource for me.  Look for
"WIN32 Perl Programming: The Standard Extensions" and "WIN32 Scripting: The
Administrator's Handbook".  

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



RE: Perl-Editor

2000-10-31 Thread Charbeneau, Chuck


> From: Ralf Lister [mailto:[EMAIL PROTECTED]]
> can someone point me to a free Perl-Editor?


In a message from 3 days ago, I responded to this VERY question with the
following:

Straight from the http://mailarchive.activestate.com/ to you:

This has been hashed out so many times, someone actually compiled a list.
It can be found at:

http://www.perl.com/reference/query.cgi?editors

(I personally use the editor from DZSoft.)



Chuck Charbeneau
-- The best selling Children's Author of
"Where are the archives and where can I read them"
___
Perl-Win32-Users mailing list
[EMAIL PROTECTED]
http://listserv.ActiveState.com/mailman/listinfo/perl-win32-users