Re: Help with unpack function - C struct to Perl

2005-12-01 Thread John W. Krahn
James Turnbull wrote:
> Hi

Hello,

> I have a C data structure being outputted to a Unix socket that I need
> to convert into a form Perl can use.  I am using IO::Socket to connect
> to the socket and I can receive the data fine.
> 
> I am using the Perl unpack function to convert the data.  I've read the
> documentation and all the examples and now I just need some help mapping
> data types between C and Perl.  My C data structure looks like:
> 
> u_int8_t alert
> u_int32_t var1
> u_int32_t var2
> u_int32_t var3
> u_int32_t var4
> u_int8_t var5
> u_int32_t var6
> bpf_u_int32 var7
> bpf_u_int32 var8
> 
> My template looks like:
> 
> $template = "C L4 C L ? ?"
> 
> Unfortunately the data unpacked does not match the expected data.  Have
> I got the right data type conversations taking place?
> 
> BTW ignore the ?'s they indicate the bpf_u_int32 data type as I don't
> know what Perl data type to put here.  I have been excluding these for
> now. Anyone know what data type to use?
> 
> Can anyone provide any hints about how I should do this?

The C programming language has four basic integer types: char, short, int and
long so your integer types are probably defined in a header file somewhere.
Although the numbers in the types probably determine how many bits each
integer contains.

Structures in C are usually padded so that integers that are smaller then the
native CPU integer size occupy the same space as the native integer size in
the structure and of course some compilers allow you to turn off padding.  So
the type u_int8_t may actually occupy 32 bits in the structure.

Different CPUs store the octets of integers in different order.  For example,
Intel compatible CPUs use a little-endian format while some IBM and Motorola
CPUs use a big-endian format.

So to determine the correct unpack() format you first have to determine the
endianess of the sending computer and whether the structure is padded or not
and if so how much padding is used.



John
-- 
use Perl;
program
fulfillment

-- 
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
 




Re: Reading xls file

2005-12-01 Thread Colm Gallagher
For a slightly different approach (output only)

I create an XML file with the data I want and then XSLT transform to an
excel sheet

here is a short script I wrote to convert an excel-html file to an xslt
http://www14.brinkster.com/colm/perl/perl-excel-xsl.html

This approach has the benefit that a non-excel user can read the sheet in
their web browser

--
Colm

On 12/2/05, Alfred Vahau <[EMAIL PROTECTED]> wrote:
>
> http://www-128.ibm.com/developerworks/library/l-pexcel/
>
> Alfred,
>
> Timothy Johnson wrote:
>
> >If you are on a Windows system, the Win32::OLE module will work
> >beautifully for this.  As a matter of fact, the documentation for the
> >Win32::OLE module uses Excel as an example.
> >
> >
> >-Original Message-
> >From: Pant, Hridyesh [mailto:[EMAIL PROTECTED]
> >Sent: Wednesday, November 30, 2005 8:22 PM
> >To: beginners@perl.org
> >Subject: Reading xls file
> >
> >Hi,
> >I want to store column data of xls file in array.
> >E.g. $array[0]=1st column of xls sheet.
> >$array[1]=2st column of xls sheet.
> >$array[2]=3st column of xls sheet.
> >
> >
> >
> >
>
> --
> To unsubscribe, e-mail: [EMAIL PROTECTED]
> For additional commands, e-mail: [EMAIL PROTECTED]
>  
>
>
>


--
Colm


config files

2005-12-01 Thread M. Lewis
I'm trying to move the configuration variables out of three perl scripts 
and put them in a config file. Fine, no problem so far.


The way this works is an email message with a given subject is processed 
by procmail then passed off to the first perl script. The first script 
sets up the second. The second sets up the third script.


If at the command line I do './script1.pl < my_email_message.eml 
everything works fine. The three scripts fire off as they should and do 
their tasks.


However, if allowed to be processed as normal (started via an incoming 
email message), then it does not work.


The root of the problem is I read the configuration file in script2.pl 
thusly:


do './mcr.conf';

The only way I have found thus far to make this work via the 'normal 
route' of an incoming email message is to change the above line to:


do '/absolute/path/to/mcr.conf';

Which defeats my purpose of getting the configuration items out of the 
scripts themselves. I don't want the users to have to edit the three 
scripts, only the mcr.conf file.


Is there a way around this?

Thanks,
Mike


--

 Netnews is like yelling, "Anyone want to buy a used car?" in a crowded 
theater.

  00:15:01 up 4 days, 19:05,  8 users,  load average: 1.10, 1.10, 1.09

 Linux Registered User #241685  http://counter.li.org

--
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
 




Help with unpack function - C struct to Perl

2005-12-01 Thread James Turnbull

Hi

I have a C data structure being outputted to a Unix socket that I need 
to convert into a form Perl can use.  I am using IO::Socket to connect 
to the socket and I can receive the data fine.


I am using the Perl unpack function to convert the data.  I've read the 
documentation and all the examples and now I just need some help 
mapping data types between C and Perl.  My C data structure looks like:


u_int8_t alert
u_int32_t var1
u_int32_t var2
u_int32_t var3
u_int32_t var4
u_int8_t var5
u_int32_t var6
bpf_u_int32 var7
bpf_u_int32 var8

My template looks like:

$template = "C L4 C L ? ?"

Unfortunately the data unpacked does not match the expected data.  Have 
I got the right data type conversations taking place?


BTW ignore the ?'s they indicate the bpf_u_int32 data type as I don't 
know what Perl data type to put here.  I have been excluding these for 
now. Anyone know what data type to use?


Can anyone provide any hints about how I should do this?

Thanks in advance

James Turnbull

--
James Turnbull <[EMAIL PROTECTED]>
---
Author of Hardening Linux from Apress
(http://www.amazon.com/exec/obidos/tg/detail/-/159059/)
---
PGP Key (http://pgp.mit.edu:11371/pks/lookup?op=get&search=0x0C42DF40)


This message was sent using IMP, the Internet Messaging Program.


--
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
 




RE: Moving Folder Access denied

2005-12-01 Thread Pant, Hridyesh
Why are you sending same mail to individual, while you are able to send mail to 
the beginners@perl.org

Regards
Hridyesh

-Original Message-
From: Manoj Thakkar, Noida [mailto:[EMAIL PROTECTED] 
Sent: 01 December 2005 20:42
To: beginners@perl.org
Subject: FW: Moving Folder Access denied


Hi Chris,
 
Need a favor, Can you please forward the message below to perl mailing list. As 
i dont have access to outside mails here in office so I subscribed mailing list 
to my gmail account and have put an auto forward there to my office email 
account to access it.
But i can not send mails to the group that way :(
 
Ohh forgot to mention please see if you can help me resolve the issue mentioned 
in mail below. That will be great.
 
Thanks & Best Regards
Manoj 



From: Manoj Thakkar, Noida
Sent: Thu 12/1/2005 10:37 AM
To: beginners@perl.org
Subject: Moving Folder Access denied


Hi,
 
I am trying to move some file form one folder to other . I am able to move the 
file if i do it from the dos prompt but it gives me access denied when i try it 
using Perl.
 
It seem to me a problem in reading the variable value.
 
Her is my code
 
Please suggest ..
 
use Win32API::File qw ( :ALL );
use strict;
open file, "remove_view_list.txt" or die $!;
while ()
{
# print $_;
my @reg_exp=split(/ /,$_);
#print @reg_exp;
my $view_name=$reg_exp[0];
my $view_date-$reg_exp[1];
my $view_path=$reg_exp[2];
print "view name: $view_name\n";
print "view date: $view_date\n";
print "view path: $view_path\n";  // value of view_path is printed as 
E:\cme_views\view_name1\abc.vws
 
qx(move $view_path,E:\\cme_views.old);
}
 
Best Regards
Manoj



From: Chris Devers [mailto:[EMAIL PROTECTED]
Sent: Thu 12/1/2005 9:57 AM
To: Pant, Hridyesh
Cc: beginners@perl.org
Subject: Re: Reading xls file



On Wed, 30 Nov 2005, Pant, Hridyesh wrote:

> I want to store column data of xls file in array.
> E.g. $array[0]=1st column of xls sheet.
> $array[1]=2st column of xls sheet.
> $array[2]=3st column of xls sheet.
> ...
> etc
>
> Can anybody help me...

Probably, I'm sure someone could.

What did your search for Excel-related modules on CPAN turn up?

When you found Spreadsheet::WriteExcel, as I have no doubt that you did,
did you read the documentation for it, and the sample code provided?

When you tried using the module, what happened? Where is your code?

This STILL isn't the "please do my homework for me" list :-)


--
Chris Devers

eD¯!î×/.Z$



--
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
 




Re: Interpolating variables in a string from a file

2005-12-01 Thread Andrew Brosnan
On 12/1/05 at 9:07 PM, [EMAIL PROTECTED] (Jeff 'japhy' Pinyan) wrote:

> On Dec 1, Andrew Brosnan said:
> 
> > my $var = 'world';
> > my $data = ;
> >
> > __DATA__
> > hello $var
> 
> Read 'perldoc -q expand'.

$data =~ s/(\$\w+)/$1/eeg;

Interesting, matching and substituting interpolates, so by substituting
the variables for themselves, you get interpolation...is that the idea?

Seems like there would be a more elegant way, but it works. Thanks!

Andrew

--
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
 




RE: Interpolating variables in a string from a file

2005-12-01 Thread Andrew Brosnan
Ahh, but you changed the data in the file...that's against the rules.
i.e. I don't have that luxury :-)


On 12/1/05 at 6:07 PM, [EMAIL PROTECTED] (Timothy Johnson) wrote:

> 
> You were probably pretty close when you tried, but don't forget that
> when you eval a string, eval will take it literally, so you need to
> put double-quotes around it in order for it to be interpolated.
> 
> 
> ###
> 
> use warnings;
> use strict;
>  
> my $var = 'world';
> undef $/;
> my $data = ;
>  
> $data = eval "$data";
> print $data;
>  
> __DATA__
> "hello $var"
> 
> ###
> 
> 
> 
> -Original Message-
> From: Andrew Brosnan [mailto:[EMAIL PROTECTED] 
> Sent: Thursday, December 01, 2005 5:20 PM
> To: Timothy Johnson
> Cc: beginners@perl.org
> Subject: RE: Interpolating variables in a string from a file
> 
> On 12/1/05 at 5:10 PM, [EMAIL PROTECTED] (Timothy Johnson) wrote:
> 
> > perldoc -f eval
> 
> Yes, I've read that. I can't seem to make it work though. Perhaps you
> could show me since you know how :-)
> 
> 
> > -Original Message-
> > From: Andrew Brosnan [mailto:[EMAIL PROTECTED] 
> > Sent: Thursday, December 01, 2005 5:06 PM
> > To: beginners@perl.org
> > Subject: Interpolating variables in a string from a file
> > 
> > How can I make this do what I mean?
> > 
> > 
> > #!/usr/bin/perl
> > use warnings;
> > use strict;
> > 
> > my $var = 'world';
> > 
> > undef $/;
> > my $data = ;
> > 
> > print $data; #oops
> > 
> > __DATA__
> > hello $var
> > 
> 
> 

--
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
 




RE: Interpolating variables in a string from a file

2005-12-01 Thread Timothy Johnson

You were probably pretty close when you tried, but don't forget that
when you eval a string, eval will take it literally, so you need to put
double-quotes around it in order for it to be interpolated.


###

use warnings;
use strict;
 
my $var = 'world';
undef $/;
my $data = ;
 
$data = eval "$data";
print $data;
 
__DATA__
"hello $var"

###



-Original Message-
From: Andrew Brosnan [mailto:[EMAIL PROTECTED] 
Sent: Thursday, December 01, 2005 5:20 PM
To: Timothy Johnson
Cc: beginners@perl.org
Subject: RE: Interpolating variables in a string from a file

On 12/1/05 at 5:10 PM, [EMAIL PROTECTED] (Timothy Johnson) wrote:

> perldoc -f eval

Yes, I've read that. I can't seem to make it work though. Perhaps you
could show me since you know how :-)


> -Original Message-
> From: Andrew Brosnan [mailto:[EMAIL PROTECTED] 
> Sent: Thursday, December 01, 2005 5:06 PM
> To: beginners@perl.org
> Subject: Interpolating variables in a string from a file
> 
> How can I make this do what I mean?
> 
> 
> #!/usr/bin/perl
> use warnings;
> use strict;
> 
> my $var = 'world';
> 
> undef $/;
> my $data = ;
> 
> print $data; #oops
> 
> __DATA__
> hello $var
> 


--
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
 




Re: Interpolating variables in a string from a file

2005-12-01 Thread Jeff 'japhy' Pinyan

On Dec 1, Andrew Brosnan said:


my $var = 'world';
my $data = ;

__DATA__
hello $var


Read 'perldoc -q expand'.

--
Jeff "japhy" Pinyan%  How can we ever be the sold short or
RPI Acacia Brother #734%  the cheated, we who for every service
http://www.perlmonks.org/  %  have long ago been overpaid?
http://princeton.pm.org/   %-- Meister Eckhart

--
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
 




RE: Interpolating variables in a string from a file

2005-12-01 Thread Andrew Brosnan
On 12/1/05 at 5:10 PM, [EMAIL PROTECTED] (Timothy Johnson) wrote:

> perldoc -f eval

Yes, I've read that. I can't seem to make it work though. Perhaps you
could show me since you know how :-)


> -Original Message-
> From: Andrew Brosnan [mailto:[EMAIL PROTECTED] 
> Sent: Thursday, December 01, 2005 5:06 PM
> To: beginners@perl.org
> Subject: Interpolating variables in a string from a file
> 
> How can I make this do what I mean?
> 
> 
> #!/usr/bin/perl
> use warnings;
> use strict;
> 
> my $var = 'world';
> 
> undef $/;
> my $data = ;
> 
> print $data; #oops
> 
> __DATA__
> hello $var
> 

--
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
 




RE: Interpolating variables in a string from a file

2005-12-01 Thread Timothy Johnson

perldoc -f eval

-Original Message-
From: Andrew Brosnan [mailto:[EMAIL PROTECTED] 
Sent: Thursday, December 01, 2005 5:06 PM
To: beginners@perl.org
Subject: Interpolating variables in a string from a file

How can I make this do what I mean?


#!/usr/bin/perl
use warnings;
use strict;

my $var = 'world';

undef $/;
my $data = ;

print $data; #oops

__DATA__
hello $var

-- 
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
 




--
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
 




Interpolating variables in a string from a file

2005-12-01 Thread Andrew Brosnan
How can I make this do what I mean?


#!/usr/bin/perl
use warnings;
use strict;

my $var = 'world';

undef $/;
my $data = ;

print $data; #oops

__DATA__
hello $var

--
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
 




Re: Reading xls file

2005-12-01 Thread Alfred Vahau

http://www-128.ibm.com/developerworks/library/l-pexcel/

Alfred,

Timothy Johnson wrote:


If you are on a Windows system, the Win32::OLE module will work
beautifully for this.  As a matter of fact, the documentation for the
Win32::OLE module uses Excel as an example.


-Original Message-
From: Pant, Hridyesh [mailto:[EMAIL PROTECTED] 
Sent: Wednesday, November 30, 2005 8:22 PM

To: beginners@perl.org
Subject: Reading xls file

Hi,
I want to store column data of xls file in array.
E.g. $array[0]=1st column of xls sheet.
$array[1]=2st column of xls sheet.
$array[2]=3st column of xls sheet.


 



--
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
 




RE: Reading xls file

2005-12-01 Thread Timothy Johnson

If you are on a Windows system, the Win32::OLE module will work
beautifully for this.  As a matter of fact, the documentation for the
Win32::OLE module uses Excel as an example.


-Original Message-
From: Pant, Hridyesh [mailto:[EMAIL PROTECTED] 
Sent: Wednesday, November 30, 2005 8:22 PM
To: beginners@perl.org
Subject: Reading xls file

Hi,
I want to store column data of xls file in array.
E.g. $array[0]=1st column of xls sheet.
$array[1]=2st column of xls sheet.
$array[2]=3st column of xls sheet.


--
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
 




Re: Count number of times matched

2005-12-01 Thread Dr.Ruud
SG Edwards:

> I want to count the number of times that a match occurs

  perldoc -q count

-- 
Affijn, Ruud

"Gewoon is een tijger."


-- 
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
 




FW: Moving Folder Access denied

2005-12-01 Thread Manoj Thakkar, Noida
Hi Chris,
 
Need a favor, Can you please forward the message below to perl mailing list. As 
i dont have access to outside mails here in office so I subscribed mailing list 
to my gmail account and have put an auto forward there to my office email 
account to access it.
But i can not send mails to the group that way :(
 
Ohh forgot to mention please see if you can help me resolve the issue mentioned 
in mail below. That will be great.
 
Thanks & Best Regards
Manoj 



From: Manoj Thakkar, Noida
Sent: Thu 12/1/2005 10:37 AM
To: beginners@perl.org
Subject: Moving Folder Access denied


Hi,
 
I am trying to move some file form one folder to other . I am able to move the 
file if i do it from the dos prompt but it gives me access denied when i try it 
using Perl.
 
It seem to me a problem in reading the variable value.
 
Her is my code
 
Please suggest ..
 
use Win32API::File qw ( :ALL );
use strict;
open file, "remove_view_list.txt" or die $!;
while ()
{
# print $_;
my @reg_exp=split(/ /,$_);
#print @reg_exp;
my $view_name=$reg_exp[0];
my $view_date-$reg_exp[1];
my $view_path=$reg_exp[2];
print "view name: $view_name\n";
print "view date: $view_date\n";
print "view path: $view_path\n";  // value of view_path is printed as 
E:\cme_views\view_name1\abc.vws
 
qx(move $view_path,E:\\cme_views.old);
}
 
Best Regards
Manoj



From: Chris Devers [mailto:[EMAIL PROTECTED]
Sent: Thu 12/1/2005 9:57 AM
To: Pant, Hridyesh
Cc: beginners@perl.org
Subject: Re: Reading xls file



On Wed, 30 Nov 2005, Pant, Hridyesh wrote:

> I want to store column data of xls file in array.
> E.g. $array[0]=1st column of xls sheet.
> $array[1]=2st column of xls sheet.
> $array[2]=3st column of xls sheet.
> ...
> etc
>
> Can anybody help me...

Probably, I'm sure someone could.

What did your search for Excel-related modules on CPAN turn up?

When you found Spreadsheet::WriteExcel, as I have no doubt that you did,
did you read the documentation for it, and the sample code provided?

When you tried using the module, what happened? Where is your code?

This STILL isn't the "please do my homework for me" list :-)


--
Chris Devers

eD¯!î×/.Z$




Re: Reading xls file

2005-12-01 Thread Chris Devers
On Thu, 1 Dec 2005, Rob Coops wrote:

> Then again Chris here is asking for a way to read XLS files not a way 
> to write them...

Doh! Of course, I meant Spreadsheet::ParseExcel :-)


-- 
Chris Devers

xô©l71Æþ;
-- 
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
 


Re: Count number of times matched

2005-12-01 Thread Xavier Noria

On Dec 1, 2005, at 15:13, SG Edwards wrote:


Hi folks,

If I want to count the number of times that a match occurs in a  
line is there a way of doing this, if there is I have not found it!


e.g.
$line="This is a sentence about matching sentences.\n";

$line=~/sentence/ig;


If you just want to count occurrences you can use a counter:

my $c = 0;
++$c while $line =~ /sentence/g;

There's a shorter idiom that takes advantage of the way list  
assignments work in scalar context that involves something known as  
the "goatse operator" (that's jargon it's not a real operator):


my $c =()= $line =~ /sentence/g;

but you have to choose which one is more easy to understand for you.

Is there a way to automatically capture each individual match (e.g.  
using a special array character?)


I don't know whether this is what you ask for, but m//g in list  
context returns the captures in one shot:


my @tags = $html =~ /<(\w+)/g;

That is documented in perlop.

-- fxn


--
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
 




Re: Count number of times matched

2005-12-01 Thread Jeff 'japhy' Pinyan

On Dec 1, SG Edwards said:

If I want to count the number of times that a match occurs in a line is there 
a way of doing this, if there is I have not found it!



$line="This is a sentence about matching sentences.\n";
$line=~/sentence/ig;

So I will have matched "sentence" twice and I want to record this.


No, you haven't.  A pattern match in scalar context only matches ONCE. 
What you want to do is:


  my @matches = $line =~ /($pattern)/ig;

Assigning the return value of the pattern match to an array means that the 
pattern match is executed in LIST context (instead of scalar context), so 
it will match as many times as it can (due to the /g modifier).


--
Jeff "japhy" Pinyan%  How can we ever be the sold short or
RPI Acacia Brother #734%  the cheated, we who for every service
http://www.perlmonks.org/  %  have long ago been overpaid?
http://princeton.pm.org/   %-- Meister Eckhart

--
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
 




Urgent: Searching for a Config file parser

2005-12-01 Thread Madhur Kashyap
Hi,

I know there are tonnes of config file parser listed at CPAN but I am
looking for something different. Also, after searching for a long
time, I could not find one which suits my needs. I am looking for a
config file parser to which I can specify

1.) variables whose values are required to be parsed and stored in hash
2.) variables which are necessary and incase if they don't have a
value or are absent in the config file then, the application should
quit after printing an error to a file, preferably STDOUT.
3.) variables which are not necessary and a default value can be passed to them.
4.) if parser encounters an unknown variable it should spit out a
warning to the user in a file, preferably STDOUT, but keep executing
the rest of the application.

In other words, I am looking for a configure parser which then
configures the configfile. The module need not be oops based. These
features are similar to some commandline argument parsing modules like
Getopt::Easy etc. Also, tcl/tk supports this kind of feature for
arguments of any procedure !!!.

--
Regards
Madhur Kashyap

--
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
 




Re: Count number of times matched

2005-12-01 Thread Shawn Corey

SG Edwards wrote:
If I want to count the number of times that a match occurs in a line is 
there a way of doing this, if there is I have not found it!


e.g.
$line="This is a sentence about matching sentences.\n";

$line=~/sentence/ig;

So I will have matched "sentence" twice and I want to record this.

I can do it like this:

$line=~/sentence/ig;

# count the number of instances of this in the sentence
@split=split(/sentence/,$line);
[EMAIL PROTECTED];
$length--;


This code works fine, but if I need to keep each matched term (as I have 
wild-cards to capture spelling variants).


i.e. output would be:
sentence
sentece

Is there a way to automatically capture each individual match (e.g. 
using a special array character?)


Is this close to what you want?

#!/usr/bin/perl

use strict;
use warnings;

my $line = "This is a sentence about matching sentences.\n";

my $count = 0;
while( $line =~ /(sentence\w*)/ig ){
  my $lexical = $1;
  $count ++;
  print "$count. $lexical\n";
}
print "\ttotal: $count\n";

__END__


--

Just my 0.0002 million dollars worth,
   --- Shawn

"Probability is now one. Any problems that are left are your own."
   SS Heart of Gold, _The Hitchhiker's Guide to the Galaxy_

--
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
 




Count number of times matched

2005-12-01 Thread SG Edwards

Hi folks,

If I want to count the number of times that a match occurs in a line is 
there a way of doing this, if there is I have not found it!


e.g.
$line="This is a sentence about matching sentences.\n";

$line=~/sentence/ig;

So I will have matched "sentence" twice and I want to record this.

I can do it like this:

$line=~/sentence/ig;

# count the number of instances of this in the sentence
@split=split(/sentence/,$line);
[EMAIL PROTECTED];
$length--;


This code works fine, but if I need to keep each matched term (as I 
have wild-cards to capture spelling variants).


i.e. output would be:
sentence
sentece

Is there a way to automatically capture each individual match (e.g. 
using a special array character?)


Sorry for the long-winded question, any help appreciated!




--
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
 




Re: PHP help to execute to .pl

2005-12-01 Thread JupiterHost.Net



Brent Clark wrote:

Hi all


Howdy,

Sorry for posting this here 


No need to be sorry just post PHP questions to a PHP list.

> (no to anger anyone, could you please reply

back off line)
I am in need of simulating the post like a web client

The html would look like this:


GREENc




This is what I have so far:



Thats the first mistake :)

Don't use PHP use Perl, specifically the LWP modules (search.cpan.org)

If it absolutely must be PHP for some weird and gun-to-your-head reason 
then itd be best to ask a PHP list.


Besides that, I;m not sure there is any problem you mention only that 
you want to do what it looks like a bunch of code you specified does... 
(IE the value is not passed, theri is a psecific error, etc etc ???)


--
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
 




Re: Useless use of lc

2005-12-01 Thread Beast

Xavier Noria wrote:

On Dec 1, 2005, at 12:48, Beast wrote:



How do I avoid this kind of warning?

Useless use of lc in void context at ./myscript.pl line 87.


Tried to use :

lc $string if $string;

but still gives warning.



I can count with my fingers the times a warning was not triggered by  
something that was actually a bug in my code. One has to understand  
what's happening and take an informed decision before disabling or  
writing some blind workaround to avoid it.


In that case the use of lc() is suspicious because lc() does not  modify 
$string in place, you probably want:


$string = lc $string;



Right, thanks!

--

--beast


--
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
 




Re: Useless use of lc

2005-12-01 Thread Xavier Noria

On Dec 1, 2005, at 12:48, Beast wrote:



How do I avoid this kind of warning?

Useless use of lc in void context at ./myscript.pl line 87.


Tried to use :

lc $string if $string;

but still gives warning.


I can count with my fingers the times a warning was not triggered by  
something that was actually a bug in my code. One has to understand  
what's happening and take an informed decision before disabling or  
writing some blind workaround to avoid it.


In that case the use of lc() is suspicious because lc() does not  
modify $string in place, you probably want:


$string = lc $string;

-- fxn

--
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
 




Useless use of lc

2005-12-01 Thread Beast


How do I avoid this kind of warning?

Useless use of lc in void context at ./myscript.pl line 87.


Tried to use :

lc $string if $string;

but still gives warning.

--

--beast


--
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
 




PHP help to execute to .pl

2005-12-01 Thread Brent Clark

Hi all

Sorry for posting this here (no to anger anyone, could you please reply back 
off line)
I am in need of simulating the post like a web client

The html would look like this:


GREENc




This is what I have so far:

\n";
} else {
   $out = "POST /$path HTTP/1.1\r\n";
   $out .= "Host: $host\r\n";
   $out .= "Content-type: application/x-www-form- urlencoded\r\n";
   $out .= "Content-length: " . strlen($path) . "\r\n";
   $out .= "Connection: Close\r\n\r\n";
   $pos = "$path?msg=GREEN";

   fwrite($fp, $out);
   while (!feof($fp)) {
   echo fgets($fp, 128);
   }
   print $pos;
   fclose($fp);
}
?>

Im trying to have my PHP fire the value to the perl script.

If anyome has any tips or advise, I would be most grateful.

Kind Regards and thanks in advance.

Brent Clark


--
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
 




Moving Folder Access denied

2005-12-01 Thread Manoj Thakkar, Noida
Hi,
 
I am trying to move some file form one folder to other . I am able to move the 
file if i do it from the dos prompt but it gives me access denied when i try it 
using Perl.
 
It seem to me a problem in reading the variable value.
 
Her is my code
 
Please suggest ..
 
use Win32API::File qw ( :ALL );
use strict;
open file, "remove_view_list.txt" or die $!;
while ()
{
# print $_;
my @reg_exp=split(/ /,$_);
#print @reg_exp;
my $view_name=$reg_exp[0];
my $view_date-$reg_exp[1];
my $view_path=$reg_exp[2];
print "view name: $view_name\n";
print "view date: $view_date\n";
print "view path: $view_path\n";  // value of view_path is printed as 
E:\cme_views\view_name1\abc.vws
 
qx(move $view_path,E:\\cme_views.old);
}
 
Best Regards
Manoj



From: Chris Devers [mailto:[EMAIL PROTECTED]
Sent: Thu 12/1/2005 9:57 AM
To: Pant, Hridyesh
Cc: beginners@perl.org
Subject: Re: Reading xls file



On Wed, 30 Nov 2005, Pant, Hridyesh wrote:

> I want to store column data of xls file in array.
> E.g. $array[0]=1st column of xls sheet.
> $array[1]=2st column of xls sheet.
> $array[2]=3st column of xls sheet.
> ...
> etc
>
> Can anybody help me...

Probably, I'm sure someone could.

What did your search for Excel-related modules on CPAN turn up?

When you found Spreadsheet::WriteExcel, as I have no doubt that you did,
did you read the documentation for it, and the sample code provided?

When you tried using the module, what happened? Where is your code?

This STILL isn't the "please do my homework for me" list :-)


--
Chris Devers

eD¯!î×/.Z$



-- 
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
 


Moving Folder Access denied

2005-12-01 Thread Pant, Hridyesh
Hi,
 
I am trying to move some file form one folder to other . I am able to
move the file if i do it from the dos prompt but it gives me access
denied when i try it using Perl.
 
It seem to me a problem in reading the variable value.
 
Her is my code
 
Please suggest ..
 
use Win32API::File qw ( :ALL );
use strict;
open file, "remove_view_list.txt" or die $!;
while ()
{
# print $_;
my @reg_exp=split(/ /,$_);
#print @reg_exp;
my $view_name=$reg_exp[0];
my $view_date-$reg_exp[1];
my $view_path=$reg_exp[2];
print "view name: $view_name\n";
print "view date: $view_date\n";
print "view path: $view_path\n";  // value of view_path is printed as
E:\cme_views\view_name1\abc.vws
 
qx(move $view_path,E:\\cme_views.old);
}

Thanks...

--
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
 




Re: Validating Decimal Values

2005-12-01 Thread John W. Krahn
Joel Divekar wrote:
> Hi

Hello,

> I am having a small program which parses data file.
> The data file contains decimal values and I am not
> able to validate the decimal number.
> 
> For eg. the decimal number will be as follows
> 
> Max Size : 9.99
> valid values : 3.00 or 745.15 or 21576.00
> invalid values : 3.001 or 745.1555 or 215766.00
> also 3..00 should be marked invalid.
> 
> I am not good with RE but I tried following code, but
> I am not sure if I am in right direction. Can anybody
> help or guide me ? 

perldoc -q "How do I determine whether a scalar is a number"


John
-- 
use Perl;
program
fulfillment

-- 
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
 




Re: Reading xls file

2005-12-01 Thread Rob Coops
Then again Chris here is asking for a way to read XLS files not a way to
write them...

So maybe the: 
*DBD::Excel*would
be more helpful in this case, but you are right most of us are not in
the habit of writting other people's homework, yet having been a perl
beginner my self at some point I do feel the need to mention that there is a
a chance that not all beginners know about the wonders that can be found at:
http://search.cpan.org

On 12/1/05, Chris Devers <[EMAIL PROTECTED]> wrote:
>
> On Wed, 30 Nov 2005, Pant, Hridyesh wrote:
>
> > I want to store column data of xls file in array.
> > E.g. $array[0]=1st column of xls sheet.
> > $array[1]=2st column of xls sheet.
> > $array[2]=3st column of xls sheet.
> > ...
> > etc
> >
> > Can anybody help me...
>
> Probably, I'm sure someone could.
>
> What did your search for Excel-related modules on CPAN turn up?
>
> When you found Spreadsheet::WriteExcel, as I have no doubt that you did,
> did you read the documentation for it, and the sample code provided?
>
> When you tried using the module, what happened? Where is your code?
>
> This STILL isn't the "please do my homework for me" list :-)
>
>
> --
> Chris Devers
>
> eD¯!î×/.Z$
>
>
> --
> To unsubscribe, e-mail: [EMAIL PROTECTED]
> For additional commands, e-mail: [EMAIL PROTECTED]
>  
>
>
>