Weird Regular expression.

2007-10-05 Thread ash
Hello fellow scripters!

I've come across weird regex like this: (.{4}).(.{21}).(.{3})..(.{3}).
(.{10}).(.{9}).
Has anyone any idea about the syntax of these regex? Thank you for
your help.


-- 
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
http://learn.perl.org/




Win32::OLE help for saving file.

2007-09-13 Thread ash
Hello fellow scripters!!

What stumps me is pretty straight forward. I need to save a Word file
using Win32::OLE, but I need to replace an existing file if there is
any.
What properties do I have to set before calling SaveAs() to do that?
Any help is appreciated. Thank you very much.


-- 
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
http://learn.perl.org/




Displaying html document.

2007-08-15 Thread ash
Hi!

What is good way to display html documents in GUI created by Perl
script?


-- 
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
http://learn.perl.org/




Component Object Model

2007-07-02 Thread ash
Hello!

Does Perl support COM? If yes can I have an example of creating an
object and using functions? Thank you in advance.


-- 
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
http://learn.perl.org/




Re: Removing decimal points

2007-06-14 Thread ash
Thank you all!

I used POSIX floor() and ceil(). Thanks for all the suggestion.


-- 
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
http://learn.perl.org/




Need help for writing attachment saver

2007-06-12 Thread ash
Hi!

I'm trying to write a code to read mail from POP3 server and then save
the attachment in specified folder. I checked the
Email::MIME::Attachment::Stripper which needs to be initialized with
Email::MIME object. I checked the Email::MIME module but I couldn't
understand how to read mail and create new Email::MIME object.

Basically I need code for reading mail with Mail::POP3Client module
then create Email::MIME object and then pass it to
Email::MIME::Attachment::Stripper. Or is there better way to receive
mail and save attachment?

Thank you all.


-- 
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
http://learn.perl.org/




Re: Writing data row at a time using OLE

2007-06-11 Thread ash
On Jun 11, 12:39 pm, [EMAIL PROTECTED] (Mumia W.)
wrote:
> On 06/11/2007 08:59 AM, ash wrote:
>
> > Hi everyone!
>
> > I am using Win32::OLE for writing data in existing Excel file. I would
> > like to know how to write data one row at a time. Writing one cell at
> > a time is too slow, it took 17mins to write 527KB file.
>
> > Thank you all very much for your help :).
>
> You might look into the Spreadsheet::WriteExcel module which has a
> "write_row" method.

Thanks for your feedback! But WrietExcel does not support writing to
existing excel file. I need to open existing excel file and write on
it.


-- 
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
http://learn.perl.org/




Writing data row at a time using OLE

2007-06-11 Thread ash
Hi everyone!

I am using Win32::OLE for writing data in existing Excel file. I would
like to know how to write data one row at a time. Writing one cell at
a time is too slow, it took 17mins to write 527KB file.

Thank you all very much for your help :).


-- 
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
http://learn.perl.org/




Removing decimal points

2007-06-08 Thread ash
Hello there!

I need to remove decimal points from numbers. For eg 1.23 or 1.77
would be just 1. Any suggestion is appreciated. Thank you.


-- 
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
http://learn.perl.org/




Creating an array of hashes from a database while preserving order

2006-07-20 Thread Derek Ash
I am creating a phone directory and would like to display the entire
contents of the database ordered by last name utilizing the
HTML:Template module.  I am not sure the code that I have so far will
work as I have planned as this is my first time ever using an array of
hashes.  How can I be sure, using the code that I have so far, that my
order by last name will preserved once displayed in the template??? 
Here's my code:

sub displayphone {

#Retrieve current state of the object
my $self = shift;

#Shortcut to return a reference to an array of hash elements  
my %attr = ( dbi_fetchall_arrayref_attr => {});

#Preparing the template and substitute the values
my $template = HTML::Template->new(filename =>
'displayphone.tmpl');
$template->param(ROWS => $dbh->selectall_arrayref("SELECT * FROM
directory ORDER BY lastname", \%attr, $value),);

   #Display results
return $template->output; 

}   

Thanks in advanceI am a Perl newbie,

derek 

Derek Ash
Application Programmer II
University of Illinois College of Medicine at Peoria
One Illini Drive, Box 1649
Peoria, Illinois 61656-1649


-- 
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
<http://learn.perl.org/> <http://learn.perl.org/first-response>




Re: sorting

2006-03-19 Thread Ash Varma
sorry for an incomplete question, but this is exactly what I was after..
:)

Thanks


On 3/20/06, Christer Ekholm <[EMAIL PROTECTED]> wrote:
>
> "Ash Varma" <[EMAIL PROTECTED]> writes:
>
> > Hi..
> >
> > I have:
> >
> > $code[0][0] = "AAA"
> > $code[0][1] = "19.5"
> > $code[1][0] = "AAD"
> > $code[1][1] = "20.0"
> > $code[2][0] = "ZZZ"
> > $code[2][1] = "10.7"
> > $code[3][0] = "XXA"
> > $code[3][1] = "5.9"
> > $code[4][0] = "YXA"
> > $code[4][1] = "27.1"
> > $code[5][0] = "AZX"
> > $code[5][1] = "1.9"
> >
> > What would be the best way to sort this?
>
> Guessing you want to sort the list @code by it's first elements
> alphabetically it's:
>
>   sort { $a->[0] cmp $b->[0] } @code;
>
> But you don't tell so that's just a guess.
>
> --
> Christer
>
>
> --
> To unsubscribe, e-mail: [EMAIL PROTECTED]
> For additional commands, e-mail: [EMAIL PROTECTED]
> <http://learn.perl.org/> <http://learn.perl.org/first-response>
>
>
>


--
Ash Varma
[EMAIL PROTECTED]
[EMAIL PROTECTED]

The browser you can trust! Get Firefox and rediscover the web!
http://www.getfirefox.com/


sorting

2006-03-19 Thread Ash Varma
Hi..

I have:

$code[0][0] = "AAA"
$code[0][1] = "19.5"
$code[1][0] = "AAD"
$code[1][1] = "20.0"
$code[2][0] = "ZZZ"
$code[2][1] = "10.7"
$code[3][0] = "XXA"
$code[3][1] = "5.9"
$code[4][0] = "YXA"
$code[4][1] = "27.1"
$code[5][0] = "AZX"
$code[5][1] = "1.9"

What would be the best way to sort this?



--
Ash Varma
[EMAIL PROTECTED]
[EMAIL PROTECTED]

The browser you can trust! Get Firefox and rediscover the web!
http://www.getfirefox.com/


Re: Adding ID numbers to names

2006-03-02 Thread Ash Varma
On 3/3/06, Ryan Gies <[EMAIL PROTECTED]> wrote:
>
> Ash Varma wrote:
> >
> > Any hint on the J Smith and J Smith Thomas ??
> >
>
> Hmm, good point.  I'm sure there are several methods, but the first
> which comes to mind is to do two replacements...
>
> a. sort you list by the length(), processing longer names first
> b. 1st replacement replaces the all names with their unique id
>
> ... J Smith ___ J Smithers ___ J Smith Thomas ...
>
> becomes
>
> ... {{0001}} ___ {{0002}} ___ {{0003}} ...
>
> c. 2nd replacement puts the names back in
>
> ... {{0001}} ___ {{0002}} ___ {{0003}} ...
>
> becomes
>
> ... J Smith 1 ___ J Smithers 0002 ___ J Smith Thomas 0003 ...
>
>
> For example:
>
>
> !/usr/bin/perl -w
>
> my @names = ( 'J Smith', 'J Smithers', 'J Smith Thomas' );
> my $text = "... J Smith ___ J Smithers ___ J Smith Thomas ...";
> my %id_to_name = ();
> my $idx = 0;
>
> foreach my $name ( sort { length($b) <=> length($a) } @names ) {
>
> my $playerid = sprintf "%04d", ++$idx;
> $id_to_name{$playerid} = $name;
> $text =~ s/\b$name\b/{{$playerid}}/g;
>
> }#foreach
>
> print "$text\n";
>
> foreach my $id ( keys %id_to_name ) {
>
> $text =~ s/\{\{$id\}\}/$id_to_name{$id} $id/g;
>
> }#foreach
>
> print "$text\n";



Brilliant !!!

I'll try this.. But this makes very good sense.. and should work quite well
for me :)

Thanks again

Ash





--
Ash Varma
[EMAIL PROTECTED]
[EMAIL PROTECTED]

The browser you can trust! Get Firefox and rediscover the web!
http://www.getfirefox.com/


Re: Adding ID numbers to names

2006-03-02 Thread Ash Varma
On 3/3/06, Ryan Gies <[EMAIL PROTECTED]> wrote:
>
> > for ($i=0;$i<=$#id;$i++) {
> > $randomtext =~ s/$name[$i]/$name[$i] $id[$i]/g
> > }
>
> Putting the word-break identifiers around your search text will prevent
> "J Smithers" from getting replaced when the $i for "J Smith" comes around.
>
> $randomtext =~ s/\b$name[$i]\b/$name[$i] $id[$i]/g
>

Thanks..

Any hint on the J Smith and J Smith Thomas ??

Ash


--
Ash Varma
[EMAIL PROTECTED]
[EMAIL PROTECTED]

The browser you can trust! Get Firefox and rediscover the web!
http://www.getfirefox.com/


Re: Adding ID numbers to names

2006-03-02 Thread Ash Varma
On 3/3/06, Wagner, David --- Senior Programmer Analyst --- WGO <
[EMAIL PROTECTED]> wrote:
>
> Ash Varma wrote:
> > Hi..
> >
> > I have 2 files of data..
> >
> > File 1 = id,name
> >
> > eg:
> >
> > 0001, J Smith
> > 0002, J Smithers
> > 0003 J Smith Thomas
> >
> >
> > File 2 = general text, with names recorded at different locations..
> >
> > eg.
> >
> > This is random text for with J Smith, J Smithers and J Smith Thomas
> >
>What does your general data look like? Depending on how one can
> break out the data, might give insight on how to do the changes.
> Wags ;)


 I am working with MLB boxscores as provided by Yahoo!
eg. http://sports.yahoo.com/mlb/boxscore?gid=250925115

Basically, I am trying to add ID numbers to player names, to enable my
analysis code to better track players..

Adding the IDs to the actual box info is easy..
Adding it to the scoring text is where I am stumped...

Hope this helps.. I can mail a sample of the cleaned text (with html, ads,
etc) if that would be better...

Ash


--
Ash Varma
[EMAIL PROTECTED]
[EMAIL PROTECTED]

The browser you can trust! Get Firefox and rediscover the web!
http://www.getfirefox.com/


Adding ID numbers to names

2006-03-02 Thread Ash Varma
Hi..

I have 2 files of data..

File 1 = id,name

eg:

0001, J Smith
0002, J Smithers
0003 J Smith Thomas


File 2 = general text, with names recorded at different locations..

eg.

This is random text for with J Smith, J Smithers and J Smith Thomas

I am trying to replace all J Smiths with J Smith 0001 and J Smithers with J
Smithers 0002, etc...

I cannot use:

for ($i=0;$i<=$#id;$i++) {
$randomtext =~ s/$name[$i]/$name[$i] $id[$i]/g
}

This does not give the desired result... Gives names with dual IDs, or
incorrect IDs..

Any hints on how I can solve this..

Thanks
Ash

--
Ash Varma
[EMAIL PROTECTED]
[EMAIL PROTECTED]

The browser you can trust! Get Firefox and rediscover the web!
http://www.getfirefox.com/


Re: Matching and general expressions

2004-01-18 Thread aSH
It works like charm Kenton!

Thank you very much! :)

aSH

On Sunday, January 18, 2004, at 06:14 PM, Kenton Brede wrote:

On Sun, Jan 18, 2004 at 05:22:46PM +0100, aSH 
([EMAIL PROTECTED]) wrote:
Hello,

I'm trying to learn and use the patterns. This is my first "serious"
try with perl.
I have a long list of words and phrases that I need to find.

Let's take this example. I want to find this patterns anywhere, no
matter if there are followed by other characters:
Central PendingCall object
PendingCall.getOutputParameter
PendingCall.getOutputParameterByName
PendingCall.getOutputParameters
I have been trying this:

pattern="m/Central PendingCall object/"
pattern="m/PendingCall.getOutputParameter/"
But the last one it shadows  PendingCall.getOutputParameterByName

So I tried this, but I'm not sure what this is doing:

pattern="m/\bPendingCall.getOutputParameter\b(?!B)/"

I want to find my patterns always, with repetitions.

I have been following this tutorial
http://www.perldoc.com/perl5.6.1/pod/perlretut.html
But now I need help with the code because I'm lost and I need to send
my code.
First let me say I'm a beginner myself so the following is not
necessarily best practice but it works.  I'm sure someone will give you
a better solution.  It would be easier to help if you would have posted
code but I've taken a stab at what you are trying to do.
#!/usr/bin/perl
use warnings;
use strict;
while () {
print "$1\n" if m/\b(Central PendingCall object)\b/;
print "$1\n" if m/\b(PendingCall.getOutputParameter)\b/;
}
__DATA__
Central PendingCall object what the
PendingCall.getOutputParameter add this
that is the truth PendingCall.getOutputParameterByName
Central PendingCall object the
PendingCall.getOutputParameters
Adding a line here
PendingCall.getOutputParameter
__END__
I think only one line really needs explanation here.

print "$1\n" if m/\b(Central PendingCall object)\b/;

"$1" contains the matched text in () "\b" defines a word boundary.

Hth,
Kent
--

--
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
<http://learn.perl.org/> <http://learn.perl.org/first-response>



--
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
<http://learn.perl.org/> <http://learn.perl.org/first-response>



Matching and general expressions

2004-01-18 Thread aSH
Hello,

I'm trying to learn and use the patterns. This is my first "serious" 
try with perl.

I have a long list of words and phrases that I need to find.

Let's take this example. I want to find this patterns anywhere, no 
matter if there are followed by other characters:

Central PendingCall object
PendingCall.getOutputParameter
PendingCall.getOutputParameterByName
PendingCall.getOutputParameters
I have been trying this:

pattern="m/Central PendingCall object/"
pattern="m/PendingCall.getOutputParameter/"
But the last one it shadows  PendingCall.getOutputParameterByName

So I tried this, but I'm not sure what this is doing:

pattern="m/\bPendingCall.getOutputParameter\b(?!B)/"

I want to find my patterns always, with repetitions.

I have been following this tutorial
http://www.perldoc.com/perl5.6.1/pod/perlretut.html
But now I need help with the code because I'm lost and I need to send 
my code.

Thanks in advance.

aSH

--
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
<http://learn.perl.org/> <http://learn.perl.org/first-response>