Possible Perl/CGI Application

2007-10-23 Thread les...@gmail.com
I'm an engineer and I need to build a web based application for a
customer to view results of my analysis. To simplify the problem say I
have a duct with a length, width, and height. I have 'avi' files
showing the fluid behavior in that duct for various combinations of
these dimensions. The analysis package I use generates movies with the
naming convention:

length_width_height.avi

I want to allow the customer to specify the length, width, and height
and view the appropriate video file. Ideally using some combination of
radio buttons, drop downs, etc.

I am experienced in Perl and have have worked with simple HTML. I was
told CGI might be the way to go in developing such an application. My
question is, does that seem reasonable? I don't want to throw myself
into learning CGI if I'm going to reach a point a few weeks down the
road when I realize I should have taken a different approach.

Thaks.

Less


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




Re: Possible Perl/CGI Application

2007-10-23 Thread Gunnar Hjalmarsson

[EMAIL PROTECTED] wrote:

I'm an engineer and I need to build a web based application for a
customer to view results of my analysis. To simplify the problem say I
have a duct with a length, width, and height. I have 'avi' files
showing the fluid behavior in that duct for various combinations of
these dimensions. The analysis package I use generates movies with the
naming convention:

length_width_height.avi

I want to allow the customer to specify the length, width, and height
and view the appropriate video file. Ideally using some combination of
radio buttons, drop downs, etc.

I am experienced in Perl and have have worked with simple HTML. I was
told CGI might be the way to go in developing such an application. My
question is, does that seem reasonable?


Absolutely. Please study the CGI.pm docs to get started.

perldoc CGI

--
Gunnar Hjalmarsson
Email: http://www.gunnar.cc/cgi-bin/contact.pl

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




Re: Possible Perl/CGI Application

2007-10-23 Thread David Moreno Garza
On Tue, 2007-10-23 at 02:04 +, [EMAIL PROTECTED] wrote:
 I am experienced in Perl and have have worked with simple HTML. I was
 told CGI might be the way to go in developing such an application. My
 question is, does that seem reasonable? I don't want to throw myself
 into learning CGI if I'm going to reach a point a few weeks down the
 road when I realize I should have taken a different approach. 

Sure, why not.

--
David Moreno Garza [EMAIL PROTECTED] | http://www.damog.net/
 Ahora buscas chamba por la Marquesa.



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




Re: Possible Perl/CGI Application

2007-10-23 Thread Greg Jetter
On Monday October 22 2007 6:04 pm, [EMAIL PROTECTED] wrote:
 I'm an engineer and I need to build a web based application for a
 customer to view results of my analysis. To simplify the problem say I
 have a duct with a length, width, and height. I have 'avi' files
 showing the fluid behavior in that duct for various combinations of
 these dimensions. The analysis package I use generates movies with the
 naming convention:

 length_width_height.avi

 I want to allow the customer to specify the length, width, and height
 and view the appropriate video file. Ideally using some combination of
 radio buttons, drop downs, etc.

 I am experienced in Perl and have have worked with simple HTML. I was
 told CGI might be the way to go in developing such an application. My
 question is, does that seem reasonable? I don't want to throw myself
 into learning CGI if I'm going to reach a point a few weeks down the
 road when I realize I should have taken a different approach.

 Thaks.

 Less

The main  reason you want to use CGI.pm is  the  OO way of  decoding  passed 
parameters from your HTML forms.

I assume your going to let  the client page  select  or build a combination of  
length , width , and height. Then send it to your Perl script to  run your 
application via a system call and  produce your output  AVI file . Then  you  
can again use  functions in the CGI.pm module to  push back  the resulting 
page. , you could do the  same thing without  CGI.pm but why would you want 
to re invent the wheel ?

instead of  decoding  a URL produced by your form manually , you  can  create 
a new CGI object and  then extract  the data like so

example:

use CGI;
use strict;

my $q = new CGI;

 # assuming  length is a  input field  of  some type on the form
my $length = $q-param('length');

then after you built the reply .
open the  file and print it to the browser ,  you  will need the correct mime 
type in your header..

take a look at the docs , it's  pretty common usage of  CGI.

that should get you going

good luck

Greg Jetter 
Alaska Internet Solutions






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




pattren maching and mail sending please help !

2007-10-23 Thread [EMAIL PROTECTED]
Hi,

My name is juan. Im very new to Perl so please give me a hand here, Im
working on this script lot of time and without sucess.

I need a script which will read  and send mail each time a message
with the word IDS is generated  under /var/log/messages.

this is the script, which I know have lots of errors:

#!/usr/local/bin/perl
#
# Program to check /var/log/messeges for alerts contining the word IDS
and send mails
# in case the word is found- including the line

use strict;
use warnings;
use Mail::Mailer;

open (INFO, /var/log/messages);   # Open the file

while
 { $message = INFO / IDS/g # Read it into an array
 $message = $

$mailer = Mail::Mailer-new(smtp, 10.83.27.71);
$mailer-open( 'From'= 'Syslog  [EMAIL PROTECTED]',
   'To'  = 'gabriela [EMAIL PROTECTED]',
   'Subject' = 'PiX Detected Attack ' );
print $mailer $message;
close($mailer)  or die can't close mailer: $!;

when I execute the script I got this:

[EMAIL PROTECTED] perl]# perl ./logcheck
Scalar found where operator expected at ./logcheck line 16, near $

$mailer
(Missing semicolon on previous line?)
Use of bare  to mean  is deprecated at ./logcheck line 20.
Scalar found where operator expected at ./logcheck line 22, near
$message
  (Might be a runaway multi-line  string starting on line 20)
(Missing operator before $message?)
syntax error at ./logcheck line 13, near {
Global symbol $message requires explicit package name at ./logcheck
line 13.
Global symbol $message requires explicit package name at ./logcheck
line 14.
Global symbol $mailer requires explicit package name at ./logcheck
line 16.
Global symbol $mailer requires explicit package name at ./logcheck
line 17.
Global symbol $mailer requires explicit package name at ./logcheck
line 20.
Global symbol $mailer requires explicit package name at ./logcheck
line 20.
syntax error at ./logcheck line 22, near $message
Global symbol $message requires explicit package name at ./logcheck
line 22.
Execution of ./logcheck aborted due to compilation errors.


can someone please help me a bit? I dont know how to fix all of
this !!

thanks a lot !!

Juan


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




Re: Absolute noobie question regarding opening files on Windows platform

2007-10-23 Thread Ayesha
On Oct 22, 9:32 pm, [EMAIL PROTECTED] (Rob Dixon) wrote:
 Ayesha wrote:
  Hi all

  I wrote this code to read a file (in the same directory as the script)
  on Win XP
  ***­
  #!/usr/local/bin/perl
  use strict;
  use warnings;

  open(READFILE1,./Sample_text_file.txt) or die (Cannot open the
  given file);
  my $record;
   while ($record = READFILE1) {
print $record;
 }

  close READFILE1;

  #print Is this even working? \n
  ***­*
  It is gives me output that Cannot open the given file. However, the
  same program is working on linux/mac platforms, i.e. can open files
  and read them. To check that I have perl correctly installed I added a
  print statement at the end. When I block everything regarding opening
  the file and just have the print statement in the script, the script
  works OK, implying Perl is installed correctly. Can anyone tell me
  what is wrong. Can anyone tell me what am I doing wrong here? It seems
  some Windows specific thing.

 Change your open call to:

   open READFILE1, 'Sample_text_file.txt' or die Cannot open the file: $!;

 and you will see additional information as to why the file couldn't be opened.

 Rob- Hide quoted text -

 - Show quoted text -

I was not in the right directory, but I learnt about forward and
backward slashed also. Thanks to all who replied

Ayesha


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




Perl module

2007-10-23 Thread Sayed, Irfan (Irfan)
Hi All,
 
How to refer Perl module in Perl script which is not there in the @INC
path. I don't have permission to add this module in the @INC path
 
I need to use the SendMail.pm module , but that is not there in the
default @INC path.
 
Can I refer the path of this module in my actual Perl script?? If yes
how to do that 
 
Please help
 
Regards
Irfan.
 
 

Irfan Sayed |SCM Engineer RDPS SCM Services - GCS Avaya India Pvt. Ltd.|
Wing 'A', Level -2, Tower-1, Cybercity, Magarpatta City, Hadapsar |
Pune, 411028|India

Voice +91 20 3041 2588 | Fax +91 20 3041 2970|Email - [EMAIL PROTECTED]
mailto:[EMAIL PROTECTED] 

For all support requests, please visit http://itss.avaya.com
http://itss.avaya.com/  Submit a request for IT assistance -
Applications-Themis Suite and select the appropriate sub-section to
open tickets, 

*   
For example:
*   
Build Factory: Build and release Management
*   
Workitem: Defect Management
*   
Source control: Source Code Control Management (Clearcase)

 


Re: Perl module

2007-10-23 Thread Rob Coops
I found the following a very easy way to include libs not on the default
path.

# Set the lib path for our own libs
use FindBin;
use lib $FindBin::Bin/lib;

This way if you want to have for instance: Net::Sendmail as a module all you
need to do is create a directory: Net in the lib directory and put the
module Sendmail.pm in that Net directory ending you up with something like
this.

/yourScript.pl
/lib/Net/Sendmail.pm

Then in your script you do as you always do to include a module.
use Net::Sendmail;

This also helps for portability, your script will pick the
Sendmail.pmmodule that it finds on the path first, so if you are not
sure when moving
your application from one machine to the next if the required module is
already installed this is a handy trick to use.

Regards,

Rob


On 10/23/07, Sayed, Irfan (Irfan) [EMAIL PROTECTED] wrote:

 Hi All,

 How to refer Perl module in Perl script which is not there in the @INC
 path. I don't have permission to add this module in the @INC path

 I need to use the SendMail.pm module , but that is not there in the
 default @INC path.

 Can I refer the path of this module in my actual Perl script?? If yes
 how to do that

 Please help

 Regards
 Irfan.



 Irfan Sayed |SCM Engineer RDPS SCM Services - GCS Avaya India Pvt. Ltd.|
 Wing 'A', Level -2, Tower-1, Cybercity, Magarpatta City, Hadapsar |
 Pune, 411028|India

 Voice +91 20 3041 2588 | Fax +91 20 3041 2970|Email - [EMAIL PROTECTED]
 mailto:[EMAIL PROTECTED]

 For all support requests, please visit http://itss.avaya.com
 http://itss.avaya.com/  Submit a request for IT assistance -
 Applications-Themis Suite and select the appropriate sub-section to
 open tickets,

 *
For example:
 *
Build Factory: Build and release Management
 *
Workitem: Defect Management
 *
Source control: Source Code Control Management (Clearcase)





How do I properly use global variables?

2007-10-23 Thread monk
I'm having problems accessing a variable outside its subroutine.
I've tried several combinations too long to write here. Maybe I just
can't see the forest for the trees.  But I'm lost.  I need your
wisdom.

I'd like my program below to change $status to zero to exit the loop.

meaning...$ perl test.pl --start
it prints out indefinitely hello world

But if  $ perl test.pl --stop
it gets out of the loop exiting the program.



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

snip

our $status;

sub start{
$status = 1;
while ($status == 1){
  print hello world!\n;
}
print out of loop. Will exit now;
exit;
}


sub stop {
 $status = 0;

}


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




Re: How do I properly use global variables?

2007-10-23 Thread Rob Coops
 You might want to try the following call your script twice with the start
argument, then look at the processes running (just send the output of the
script to /dev/null or something like that for ease of use)

You will see the script running twice, this is because you started the Perl
interpreter twice. If you want to be able to do this you will have to look
into something called signaling. With this you can send your script a signal
to stop, this signal you can then process in anyway you like.

I hope this will help yo a bit, regards,

Rob



On 10/23/07, monk [EMAIL PROTECTED] wrote:

 I'm having problems accessing a variable outside its subroutine.
 I've tried several combinations too long to write here. Maybe I just
 can't see the forest for the trees.  But I'm lost.  I need your
 wisdom.

 I'd like my program below to change $status to zero to exit the loop.

 meaning...$ perl test.pl --start
 it prints out indefinitely hello world

 But if  $ perl test.pl --stop
 it gets out of the loop exiting the program.



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

 snip

 our $status;

 sub start{
$status = 1;
while ($status == 1){
  print hello world!\n;
}
 print out of loop. Will exit now;
 exit;
 }


 sub stop {
 $status = 0;

 }


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





Re: How do I properly use global variables?

2007-10-23 Thread Jeff Pang
On 10/23/07, monk [EMAIL PROTECTED] wrote:
 I'm having problems accessing a variable outside its subroutine.
 I've tried several combinations too long to write here. Maybe I just
 can't see the forest for the trees.  But I'm lost.  I need your
 wisdom.

 I'd like my program below to change $status to zero to exit the loop.

 meaning...$ perl test.pl --start
 it prints out indefinitely hello world

 But if  $ perl test.pl --stop
 it gets out of the loop exiting the program.



Hi,

When script is running,how can you re-run it with another argument to
make it stop?
The general way to let a running program stop is to send a signal.
Let me modify your code to,

use strict;
use warnings;

our $status = 1;
$SIG{TERM} = $SIG{INT} = sub {$status = 0};

start();

sub start {
   while ($status){
 print hello world!\n;
 sleep 1;
   }

   print out of loop. Will exit now\n;
   exit 0;
}

__END__


When you run it,you can send SIGINT or SIGTERM to let it exit gracefully.
Given the process id is 1234,under unix you can say,

$ kill -s 2  1234

The script would print out of loop. Will exit now and exit.
(-s 2 means sending SIGINT,see `man 7 signal` for details).

The most important change for the code above is that we re-defined
singal handlers:
$SIG{TERM} = $SIG{INT} = sub {$status = 0};

When the script receive SIGTERM or SIGINT,it set the global $status to
0,so the loop condition become false,the program exit.

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




Re: Perl module

2007-10-23 Thread Jeff Pang
On 10/23/07, Sayed, Irfan (Irfan) [EMAIL PROTECTED] wrote:
 Hi All,

 How to refer Perl module in Perl script which is not there in the @INC
 path. I don't have permission to add this module in the @INC path

 I need to use the SendMail.pm module , but that is not there in the
 default @INC path.

 Can I refer the path of this module in my actual Perl script?? If yes
 how to do that


Yes. First find the lib's path in your system,then `use lib` it.

use lib qw(/my/lib/path);

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




Re: pattren maching and mail sending please help !

2007-10-23 Thread Gunnar Hjalmarsson

[EMAIL PROTECTED] wrote:

I need a script which will read  and send mail each time a message
with the word IDS is generated  under /var/log/messages.

this is the script, which I know have lots of errors:

#!/usr/local/bin/perl
#
# Program to check /var/log/messeges for alerts contining the word IDS
and send mails
# in case the word is found- including the line

use strict;
use warnings;


Good start. :)


use Mail::Mailer;

open (INFO, /var/log/messages);   # Open the file


You should make it a habit to check the return value when using open().

open (INFO, /var/log/messages) or die Couldn't open file: $!;


while
 { $message = INFO / IDS/g # Read it into an array
 $message = $

$mailer = Mail::Mailer-new(smtp, 10.83.27.71);


I would guess that you want something like this:

while ( my $message = INFO ) {
next unless $message =~ /\bIDS\b/;

my $mailer = Mail::Mailer-new(smtp, 10.83.27.71);

You should be able to take it from here.

--
Gunnar Hjalmarsson
Email: http://www.gunnar.cc/cgi-bin/contact.pl

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




RE: Perl module

2007-10-23 Thread Sayed, Irfan (Irfan)
 

This is the error which I am getting

Can't locate SendMail.pm in @INC (@INC contains:
/opt/rational/common/lib/perl5/5.8.6/sun4-solaris-multi
/opt/rational/common/lib/perl5/5.8.6
/opt/rational/common/lib/perl5/site_perl/5.8.6/sun4-solaris-multi
/opt/rational/common/lib/perl5/site_perl/5.8.6
/opt/rational/common/lib/perl5/site_perl/5.6.1
/opt/rational/common/lib/perl5/site_perl .) at
/usr/add-on/puccase_admin/viewtools/unixbin/del_complete.pl line 5.
BEGIN failed--compilation aborted at
/usr/add-on/puccase_admin/viewtools/unixbin/del_complete.pl line 5.

And the first few lines of actual perl script is

use strict;
use warnings;
use SendMail 2.09;
use lib qw(/home/ccvob01/irf/lib/SendMail.pm);
my $CT=/usr/atria/bin/cleartool;

I have also created the lib dir. in above path and copied the
SendMail.pm.

Please guide.

Regards
Irfan.






-Original Message-
From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED] On Behalf Of Jeff Pang
Sent: Tuesday, October 23, 2007 1:38 PM
To: Sayed, Irfan (Irfan)
Cc: beginners@perl.org
Subject: Re: Perl module

On 10/23/07, Sayed, Irfan (Irfan) [EMAIL PROTECTED] wrote:
 Hi All,

 How to refer Perl module in Perl script which is not there in the @INC

 path. I don't have permission to add this module in the @INC path

 I need to use the SendMail.pm module , but that is not there in the 
 default @INC path.

 Can I refer the path of this module in my actual Perl script?? If yes 
 how to do that


Yes. First find the lib's path in your system,then `use lib` it.

use lib qw(/my/lib/path);

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

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




Re: Perl module

2007-10-23 Thread Jeff Pang
this line is not correct:
use lib qw(/home/ccvob01/irf/lib/SendMail.pm);

you should do,
use lib qw(/home/ccvob01/irf/lib);

the .pm file is not included.

On 10/23/07, Sayed, Irfan (Irfan) [EMAIL PROTECTED] wrote:


 This is the error which I am getting

 Can't locate SendMail.pm in @INC (@INC contains:
 /opt/rational/common/lib/perl5/5.8.6/sun4-solaris-multi
 /opt/rational/common/lib/perl5/5.8.6
 /opt/rational/common/lib/perl5/site_perl/5.8.6/sun4-solaris-multi
 /opt/rational/common/lib/perl5/site_perl/5.8.6
 /opt/rational/common/lib/perl5/site_perl/5.6.1
 /opt/rational/common/lib/perl5/site_perl .) at
 /usr/add-on/puccase_admin/viewtools/unixbin/del_complete.pl line 5.
 BEGIN failed--compilation aborted at
 /usr/add-on/puccase_admin/viewtools/unixbin/del_complete.pl line 5.

 And the first few lines of actual perl script is

 use strict;
 use warnings;
 use SendMail 2.09;
 use lib qw(/home/ccvob01/irf/lib/SendMail.pm);
 my $CT=/usr/atria/bin/cleartool;

 I have also created the lib dir. in above path and copied the
 SendMail.pm.

 Please guide.

 Regards
 Irfan.






 -Original Message-
 From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED] On Behalf Of Jeff Pang
 Sent: Tuesday, October 23, 2007 1:38 PM
 To: Sayed, Irfan (Irfan)
 Cc: beginners@perl.org
 Subject: Re: Perl module

 On 10/23/07, Sayed, Irfan (Irfan) [EMAIL PROTECTED] wrote:
  Hi All,
 
  How to refer Perl module in Perl script which is not there in the @INC

  path. I don't have permission to add this module in the @INC path
 
  I need to use the SendMail.pm module , but that is not there in the
  default @INC path.
 
  Can I refer the path of this module in my actual Perl script?? If yes
  how to do that
 

 Yes. First find the lib's path in your system,then `use lib` it.

 use lib qw(/my/lib/path);

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

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




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




RE: Perl module

2007-10-23 Thread Sayed, Irfan (Irfan)
 
Still the error is same.

Please find the attached Perl script for reference.

Please guide.

Regards
Irfan.



-Original Message-
From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED] On Behalf Of Jeff Pang
Sent: Tuesday, October 23, 2007 2:18 PM
To: Sayed, Irfan (Irfan)
Cc: beginners@perl.org
Subject: Re: Perl module

this line is not correct:
use lib qw(/home/ccvob01/irf/lib/SendMail.pm);

you should do,
use lib qw(/home/ccvob01/irf/lib);

the .pm file is not included.

On 10/23/07, Sayed, Irfan (Irfan) [EMAIL PROTECTED] wrote:


 This is the error which I am getting

 Can't locate SendMail.pm in @INC (@INC contains:
 /opt/rational/common/lib/perl5/5.8.6/sun4-solaris-multi
 /opt/rational/common/lib/perl5/5.8.6
 /opt/rational/common/lib/perl5/site_perl/5.8.6/sun4-solaris-multi
 /opt/rational/common/lib/perl5/site_perl/5.8.6
 /opt/rational/common/lib/perl5/site_perl/5.6.1
 /opt/rational/common/lib/perl5/site_perl .) at 
 /usr/add-on/puccase_admin/viewtools/unixbin/del_complete.pl line 5.
 BEGIN failed--compilation aborted at
 /usr/add-on/puccase_admin/viewtools/unixbin/del_complete.pl line 5.

 And the first few lines of actual perl script is

 use strict;
 use warnings;
 use SendMail 2.09;
 use lib qw(/home/ccvob01/irf/lib/SendMail.pm);
 my $CT=/usr/atria/bin/cleartool;

 I have also created the lib dir. in above path and copied the 
 SendMail.pm.

 Please guide.

 Regards
 Irfan.






 -Original Message-
 From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED] On Behalf Of Jeff 
 Pang
 Sent: Tuesday, October 23, 2007 1:38 PM
 To: Sayed, Irfan (Irfan)
 Cc: beginners@perl.org
 Subject: Re: Perl module

 On 10/23/07, Sayed, Irfan (Irfan) [EMAIL PROTECTED] wrote:
  Hi All,
 
  How to refer Perl module in Perl script which is not there in the 
  @INC

  path. I don't have permission to add this module in the @INC path
 
  I need to use the SendMail.pm module , but that is not there in the 
  default @INC path.
 
  Can I refer the path of this module in my actual Perl script?? If 
  yes how to do that
 

 Yes. First find the lib's path in your system,then `use lib` it.

 use lib qw(/my/lib/path);

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

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





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


Re: Perl module

2007-10-23 Thread Jeff Pang
use lib qw(/home/ccvob01/irf/lib);
this line should be put *before* any modules you want to import from
the specified path.


On 10/23/07, Sayed, Irfan (Irfan) [EMAIL PROTECTED] wrote:

 Still the error is same.

 Please find the attached Perl script for reference.

 Please guide.

 Regards
 Irfan.



 -Original Message-
 From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED] On Behalf Of Jeff Pang
 Sent: Tuesday, October 23, 2007 2:18 PM
 To: Sayed, Irfan (Irfan)
 Cc: beginners@perl.org
 Subject: Re: Perl module

 this line is not correct:
 use lib qw(/home/ccvob01/irf/lib/SendMail.pm);

 you should do,
 use lib qw(/home/ccvob01/irf/lib);

 the .pm file is not included.

 On 10/23/07, Sayed, Irfan (Irfan) [EMAIL PROTECTED] wrote:
 
 
  This is the error which I am getting
 
  Can't locate SendMail.pm in @INC (@INC contains:
  /opt/rational/common/lib/perl5/5.8.6/sun4-solaris-multi
  /opt/rational/common/lib/perl5/5.8.6
  /opt/rational/common/lib/perl5/site_perl/5.8.6/sun4-solaris-multi
  /opt/rational/common/lib/perl5/site_perl/5.8.6
  /opt/rational/common/lib/perl5/site_perl/5.6.1
  /opt/rational/common/lib/perl5/site_perl .) at
  /usr/add-on/puccase_admin/viewtools/unixbin/del_complete.pl line 5.
  BEGIN failed--compilation aborted at
  /usr/add-on/puccase_admin/viewtools/unixbin/del_complete.pl line 5.
 
  And the first few lines of actual perl script is
 
  use strict;
  use warnings;
  use SendMail 2.09;
  use lib qw(/home/ccvob01/irf/lib/SendMail.pm);
  my $CT=/usr/atria/bin/cleartool;
 
  I have also created the lib dir. in above path and copied the
  SendMail.pm.
 
  Please guide.
 
  Regards
  Irfan.
 
 
 
 
 
 
  -Original Message-
  From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED] On Behalf Of Jeff
  Pang
  Sent: Tuesday, October 23, 2007 1:38 PM
  To: Sayed, Irfan (Irfan)
  Cc: beginners@perl.org
  Subject: Re: Perl module
 
  On 10/23/07, Sayed, Irfan (Irfan) [EMAIL PROTECTED] wrote:
   Hi All,
  
   How to refer Perl module in Perl script which is not there in the
   @INC
 
   path. I don't have permission to add this module in the @INC path
  
   I need to use the SendMail.pm module , but that is not there in the
   default @INC path.
  
   Can I refer the path of this module in my actual Perl script?? If
   yes how to do that
  
 
  Yes. First find the lib's path in your system,then `use lib` it.
 
  use lib qw(/my/lib/path);
 
  --
  To unsubscribe, e-mail: [EMAIL PROTECTED] For additional
  commands, e-mail: [EMAIL PROTECTED] http://learn.perl.org/
 
  --
  To unsubscribe, e-mail: [EMAIL PROTECTED] For additional
  commands, e-mail: [EMAIL PROTECTED] http://learn.perl.org/
 
 
 

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




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




PHP parsing

2007-10-23 Thread Siva Prasad
 

Hi Gurus,

 

I have a PHP page I need to click on the links that are there on the php
which will navigate me to another PHP page and I need to parse data on them

 

Is there any Perl modules that will server my purpose.

 

Thanks in Advance.

PP

image001.gif

Date addition-reg

2007-10-23 Thread neelike

Hi

Thaks for ur valuable info..

my code is

my $total_nights=3;
$total_nights = 0.$total_nights if ((!($total_nights =~ 
/^0/))  ($total_nights  10));

my $start_date=2008-03-24;
my ($year,$mon,$day) = split/-/,$start_date;
   $day=($day+$total_nights);
   my @data =($year,$mon,$day);
my $departure_date= join(-,@data);

but it makes issues on Feb and end of the 
monthsAny comments???


Thanks,
Boniface

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




Re: PHP parsing

2007-10-23 Thread Jeff Pang
PHP finally generate a html page,is it?
so you can take a look at HTML::Parser module:
http://search.cpan.org/~gaas/HTML-Parser-3.56/Parser.pm

On 10/23/07, Siva Prasad [EMAIL PROTECTED] wrote:




 Hi Gurus,



 I have a PHP page I need to click on the links that are there on the php 
 which will navigate me to another PHP page and I need to parse data on them



 Is there any Perl modules that will server my purpose.



 Thanks in Advance.

 PP

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




Re: Any clues to access Chinese folder name on Win32 ?

2007-10-23 Thread Panda-X
Hi Phoenix,

Thanks for the reply. But seems I have no luck with that !
Please see attached screen capture and here's my code.
My basic code is simply like this :

use Tk;
my $mw = MainWindow - new();
my $x = $mw - getOpenFile ;
$mw - Label ( -text=$x ) - pack();
open F , $x or $mw - Label ( -text= $! --- $x  ) - pack();
$mw - MainLoop;

So is there any clues to open file in such case ??
Thank you very much,

Panda-X


2007/10/18, Tom Phoenix [EMAIL PROTECTED]:

 On 10/17/07, Panda-X [EMAIL PROTECTED] wrote:

  I have tried to use utf8, and I can print the file name in right
 string,
  but when I try to open the file and read. It happens No such file or
  directory.

 Sometimes, two different strings can seem identical on-screen. Can you
 use readdir or glob to find out the real name of files and
 directories? The values you get back should (should) work when you
 need to open a file.

 Good luck with it!

 --Tom Phoenix
 Stonehenge Perl Training

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


Re: Date addition-reg

2007-10-23 Thread Jeff Pang
Please don't open a new topic when you repeat the same question.

$day=($day+$total_nights);

I've said clearly,you can't do date oprations by this way.
See my before message that answered your question fully.

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




Help generating XML output

2007-10-23 Thread Beginner
Hi,

I have been trying to output XML that looks like this:

users
username id=10dermot/username
username id=17joe/username
...
/users

I have tried XML::Simple and XML::Generator but keep hitting the same 
problem when it comes to separating the id attribute and the value 
from my hash reference.

$VAR1 = {
   'dermot' = '10',
   'joe' = '17',
   'rose' = '11',
   'phil' = '13',
   'brian' = '20',
   'andy' = '15',
 };

If I use this loop to generate the output with XML::Generator I only 
get the last user in the XML

my $xml;
my $gen = XML::Generator-new(':pretty');
foreach my $k (keys %{$ref}) {
   $xml = $gen-users(
  $gen-username({ id = $ref-{$k}},$k),
   );
   }
print $xml;

username id=15andy/username

With XML::Simple I considered using this:
 
my $xml = XMLout($ref, RootName = 'users', ValueAttr = { '??' = 
'??'}

But I can't determine how to use ValueAttr to suit my needs as the 
keys/values are not know.

I think XML::Generator would suit me best but I can't see can append 
data to $xml. Can anyone offer any advice?

TIA,
Dp.




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




Re: Help generating XML output

2007-10-23 Thread Rob Coops
foreach my $k (keys %{$ref}) {
  $xml = $gen-users( # $xml gets over written with every new
key So instead of doing that I would try $xml .= (appending)
 $gen-username({ id = $ref-{$k}},$k),
  );
  }


On 10/23/07, Beginner [EMAIL PROTECTED] wrote:

 Hi,

 I have been trying to output XML that looks like this:

 users
username id=10dermot/username
username id=17joe/username
 ...
 /users

 I have tried XML::Simple and XML::Generator but keep hitting the same
 problem when it comes to separating the id attribute and the value
 from my hash reference.

 $VAR1 = {
   'dermot' = '10',
   'joe' = '17',
   'rose' = '11',
   'phil' = '13',
   'brian' = '20',
   'andy' = '15',
 };

 If I use this loop to generate the output with XML::Generator I only
 get the last user in the XML

 my $xml;
 my $gen = XML::Generator-new(':pretty');
 foreach my $k (keys %{$ref}) {
   $xml = $gen-users(
  $gen-username({ id = $ref-{$k}},$k),
   );
   }
 print $xml;

 username id=15andy/username

 With XML::Simple I considered using this:

 my $xml = XMLout($ref, RootName = 'users', ValueAttr = { '??' =
 '??'}

 But I can't determine how to use ValueAttr to suit my needs as the
 keys/values are not know.

 I think XML::Generator would suit me best but I can't see can append
 data to $xml. Can anyone offer any advice?

 TIA,
 Dp.




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





Re: Help generating XML output

2007-10-23 Thread Beginner
On 23 Oct 2007 at 12:12, Rob Coops wrote:

 foreach my $k (keys %{$ref}) {
   $xml = $gen-users( # $xml gets over written with every new
 key So instead of doing that I would try $xml .= (appending)
  $gen-username({ id = $ref-{$k}},$k),
   );
   }
 

Perhaps I should have mentioned that I had tried that and the result 
is empty XML like this


my $gen = XML::Generator-new(':pretty');
my $xml;
foreach my $k (keys %{$ref}) {
 $xml .= $gen-users(
$gen-username({ id = $ref-{$k}},$k),
);
 }

/usersusers


This seems to work but my browser is complaining about the output:
XML Parsing Error: junk after document element
The source looks out but there is no root level element.

my $xml;
foreach my $k (keys %{$ref}) {
 $xml .= $gen-username({ id = $ref-{$k}},$k);
  }
print $xml;


So it's close but not quite there.
Dp.


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




how to insert rows into database from array/hash using DBI

2007-10-23 Thread petelink1
I'm trying to grab data from an MS-Access log file and put it into a
fast, read-only database. (I'm thinking SQL Lite at this point.)

The code below is working.  Now I need to put the identical data and
structure into an SQL Lite table.  Any suggestions on where to look
for examples?  (or if you want to write one, that's fine too.)

I own the book Programming the Perl DBI, but I haven't found
anything that addresses this.

use warnings;
use strict;

use DBI;
use DBD::ODBC;
use DBD::SQLite;

my $DSN = 'driver=Microsoft Access Driver (*.mdb);dbq=C:\temp
\adt2_in.mdb';
my $dbh1 = DBI-connect(dbi:ODBC:$DSN,,) or die $DBI::errstr\n;

$dbh1-{LongReadLen} = 2000;
$dbh1-{LongTruncOk} = 1;

my $sth1 = $dbh1-prepare(select message_index, message_no,
message_event, time_stamp, data from log);

$sth1-execute();

my @stash;

while (my $hash_ref = $sth1-fetchrow_hashref()) {
push @stash, { %$hash_ref };
}

$dbh1-disconnect();

my $itemp = 1;
foreach my $hash_ref (@stash) {
print  Details of row $itemp: ;
print \n\n;

foreach my $key (keys %{$hash_ref}) {
   print ($key \t $hash_ref-{$key} \n);
}
   $itemp++;
}

Thanks.


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




Re: Getting error message while installing Crypt-DSA module

2007-10-23 Thread sisyphus
On Oct 23, 1:15 am, [EMAIL PROTECTED] (Kilaru Rajeev) wrote:
 Hi All,

 I am getting the following error in the *make test* part while istalling the
 *Crypt::DSA* module. Please give me an advice how to procede.

 t/03-keygen.*Math::BigInt: couldn't load specified math lib(s), fallback
 to Math::BigInt::Calc* at /tmp/Crypt-DSA-0.14/blib/lib/Crypt/DSA/KeyChain.pm
 line 6
 *Math::BigInt: couldn't load specified math lib(s), fallback to
 Math::BigInt::Calc* at /tmp/Crypt-DSA-0.14/blib/lib/Crypt/DSA/Key.pm line 6
 *Math::BigInt: couldn't load specified math lib(s), fallback to
 Math::BigInt::Calc* at /tmp/Crypt-DSA-0.14/blib/lib/Crypt/DSA/Util.pm line 6


I don't believe it's an error - it's merely telling you that you don't
have Math::BigInt::GMP installed, so (the slower, pure perl)
Math::BigInt::Calc is being used instead.

The line of code that's producing the warning in all 3 instances is:

use Math::BigInt lib = 'GMP';

If you had Math::BigInt::GMP installed you would find that the tests
run more quickly. (To install Math::BigInt::GMP, you'll first need to
install the GMP library. See http://gmplib.org/ )

Cheers,
Rob


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




Insecure dependency in open while running setuid at

2007-10-23 Thread anders
I have a program witch calls a test program i PERL
The testa prorgam gets a filname and parameters in
Ans supose to just write data to a output file
But i get an error saying
Insecure dependency in open while running setuid at

Any ide, i'dont like to have rewrite the program i eg. C..
mutch easy with PERL..

// Anders


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




Re: How to use Perl for email

2007-10-23 Thread johnnyp
On Oct 22, 6:52 am, [EMAIL PROTECTED] (Jeff Pang) wrote:
 There're lots of modules for sending mail on CPAN.like:

 Mail::Sender
 Email::Send
 MIME::Lite
 Net::SMTP
 ...

 which method do you use and what error message did you get?

 On 10/22/07, johnnyp [EMAIL PROTECTED] wrote:



  All,
  Perl newbie here. I am looking for help on how to send emails form
  a Windows XP platform using Perl 5.8.8. I have tried different codes
  and must be doing something wrong. Any thoughts or help would be
  appreciated.

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

 - Show quoted text -

Yes including code and errors would have been more helpful on my
part.  I am attempting to use Mail::SendMail with the following code:

#!C:\Perl\lib\mail

use strict;
use warnings;
use Mail::SendMail;


  my%mail = ( To  = '[EMAIL PROTECTED]',
   From= '[EMAIL PROTECTED]',
  Message = test mail
   );

sendmail(%mail) or die $Mail::Sendmail::error;

  print OK. Log says:\n, $Mail::Sendmail::log;

__END__

The error I am getting is:
'undefined subroutine main::sendmail called at C:perl\lib\mail
\mail.pl line 13.

As best I can tell this error is actually popping up from the
sendmail.pm subroutine sub sendmail. But I could be mistaken.


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




RE: Perl module

2007-10-23 Thread Sayed, Irfan (Irfan)
 

Thanks Jeff. It's working now.

Regards
Irfan.



-Original Message-
From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED] On Behalf Of Jeff Pang
Sent: Tuesday, October 23, 2007 2:30 PM
To: Sayed, Irfan (Irfan)
Cc: beginners@perl.org
Subject: Re: Perl module

use lib qw(/home/ccvob01/irf/lib);
this line should be put *before* any modules you want to import from the
specified path.


On 10/23/07, Sayed, Irfan (Irfan) [EMAIL PROTECTED] wrote:

 Still the error is same.

 Please find the attached Perl script for reference.

 Please guide.

 Regards
 Irfan.



 -Original Message-
 From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED] On Behalf Of Jeff 
 Pang
 Sent: Tuesday, October 23, 2007 2:18 PM
 To: Sayed, Irfan (Irfan)
 Cc: beginners@perl.org
 Subject: Re: Perl module

 this line is not correct:
 use lib qw(/home/ccvob01/irf/lib/SendMail.pm);

 you should do,
 use lib qw(/home/ccvob01/irf/lib);

 the .pm file is not included.

 On 10/23/07, Sayed, Irfan (Irfan) [EMAIL PROTECTED] wrote:
 
 
  This is the error which I am getting
 
  Can't locate SendMail.pm in @INC (@INC contains:
  /opt/rational/common/lib/perl5/5.8.6/sun4-solaris-multi
  /opt/rational/common/lib/perl5/5.8.6
  /opt/rational/common/lib/perl5/site_perl/5.8.6/sun4-solaris-multi
  /opt/rational/common/lib/perl5/site_perl/5.8.6
  /opt/rational/common/lib/perl5/site_perl/5.6.1
  /opt/rational/common/lib/perl5/site_perl .) at 
  /usr/add-on/puccase_admin/viewtools/unixbin/del_complete.pl line 5.
  BEGIN failed--compilation aborted at 
  /usr/add-on/puccase_admin/viewtools/unixbin/del_complete.pl line 5.
 
  And the first few lines of actual perl script is
 
  use strict;
  use warnings;
  use SendMail 2.09;
  use lib qw(/home/ccvob01/irf/lib/SendMail.pm);
  my $CT=/usr/atria/bin/cleartool;
 
  I have also created the lib dir. in above path and copied the 
  SendMail.pm.
 
  Please guide.
 
  Regards
  Irfan.
 
 
 
 
 
 
  -Original Message-
  From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED] On Behalf Of Jeff 
  Pang
  Sent: Tuesday, October 23, 2007 1:38 PM
  To: Sayed, Irfan (Irfan)
  Cc: beginners@perl.org
  Subject: Re: Perl module
 
  On 10/23/07, Sayed, Irfan (Irfan) [EMAIL PROTECTED] wrote:
   Hi All,
  
   How to refer Perl module in Perl script which is not there in the 
   @INC
 
   path. I don't have permission to add this module in the @INC path
  
   I need to use the SendMail.pm module , but that is not there in 
   the default @INC path.
  
   Can I refer the path of this module in my actual Perl script?? If 
   yes how to do that
  
 
  Yes. First find the lib's path in your system,then `use lib` it.
 
  use lib qw(/my/lib/path);
 
  --
  To unsubscribe, e-mail: [EMAIL PROTECTED] For 
  additional commands, e-mail: [EMAIL PROTECTED] 
  http://learn.perl.org/
 
  --
  To unsubscribe, e-mail: [EMAIL PROTECTED] For 
  additional commands, e-mail: [EMAIL PROTECTED] 
  http://learn.perl.org/
 
 
 

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




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




Re: How to use Perl for email

2007-10-23 Thread Gunnar Hjalmarsson

johnnyp wrote:

I am attempting to use Mail::SendMail with the following code:

#!C:\Perl\lib\mail

use strict;
use warnings;
use Mail::SendMail;

^
Case matters, even if you are on Windows.


  my%mail = ( To  = '[EMAIL PROTECTED]',
   From= '[EMAIL PROTECTED]',
  Message = test mail
   );

sendmail(%mail) or die $Mail::Sendmail::error;

  print OK. Log says:\n, $Mail::Sendmail::log;

__END__

The error I am getting is:
'undefined subroutine main::sendmail called at C:perl\lib\mail
\mail.pl line 13.

As best I can tell this error is actually popping up from the
sendmail.pm subroutine sub sendmail. But I could be mistaken.


You are; see my remark above.

--
Gunnar Hjalmarsson
Email: http://www.gunnar.cc/cgi-bin/contact.pl

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




Re: How to use Perl for email

2007-10-23 Thread Jenda Krynicky
From: johnnyp [EMAIL PROTECTED]
 Yes including code and errors would have been more helpful on my
 part.  I am attempting to use Mail::SendMail with the following code:
 
 #!C:\Perl\lib\mail
 
 use strict;
 use warnings;
 use Mail::SendMail;
 
 
   my%mail = ( To  = '[EMAIL PROTECTED]',
From= '[EMAIL PROTECTED]',
   Message = test mail
);
 
   sendmail(%mail) or die $Mail::Sendmail::error;
 
   print OK. Log says:\n, $Mail::Sendmail::log;
 
 __END__
 
 The error I am getting is:
 'undefined subroutine main::sendmail called at C:perl\lib\mail
 \mail.pl line 13.

The module is named Mail::Sendmail ! Notice the lowercase m in the 
middle of Sendmail. Perl is case sensitive even if the underlying 
filesystem is not. (I do wish Perl emited a warning in such cases.)

Perl is able to find and load the ...\Mail\SendMail.pm (because the 
Windows filesystem doesn't care whether you ask it for Sendmail.pm, 
SendMail.pm or SENDMAIL.PM), but fails to initialize it properly ... 
it tries to initialize module Mail::SendMail, but there is only 
Mail::Sendmail in the file.

Jenda
= [EMAIL PROTECTED] === http://Jenda.Krynicky.cz =
When it comes to wine, women and song, wizards are allowed 
to get drunk and croon as much as they like.
-- Terry Pratchett in Sourcery


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




Insecure dependency in open while running setuid at

2007-10-23 Thread anders
I have a program witch calls a test program i PERL
The testa prorgam gets a filname and parameters in
Ans supose to just write data to a output file
But i get an error saying
Insecure dependency in open while running setuid at

Any ide, i'dont like to have rewrite the program i eg. C..
mutch easy with PERL..

// Anders


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




Re: how to insert rows into database from array/hash using DBI

2007-10-23 Thread Gunnar Hjalmarsson

[EMAIL PROTECTED] wrote:

I'm trying to grab data from an MS-Access log file and put it into a
fast, read-only database. (I'm thinking SQL Lite at this point.)

The code below is working.  Now I need to put the identical data and
structure into an SQL Lite table.  Any suggestions on where to look
for examples?


The documentation for the DBD::SQLite module, perhaps?

It may be as simple as just modifying the DBI-connect statement.

--
Gunnar Hjalmarsson
Email: http://www.gunnar.cc/cgi-bin/contact.pl

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




Re: Help generating XML output

2007-10-23 Thread Rob Dixon

Beginner wrote:


I have been trying to output XML that looks like this:

users
username id=10dermot/username
username id=17joe/username
...
/users

I have tried XML::Simple and XML::Generator but keep hitting the same 
problem when it comes to separating the id attribute and the value 
from my hash reference.


$VAR1 = {
   'dermot' = '10',
   'joe' = '17',
   'rose' = '11',
   'phil' = '13',
   'brian' = '20',
   'andy' = '15',
 };

If I use this loop to generate the output with XML::Generator I only 
get the last user in the XML


my $xml;
my $gen = XML::Generator-new(':pretty');
foreach my $k (keys %{$ref}) {
   $xml = $gen-users(
  $gen-username({ id = $ref-{$k}},$k),
   );
   }
print $xml;

username id=15andy/username

With XML::Simple I considered using this:
 
my $xml = XMLout($ref, RootName = 'users', ValueAttr = { '??' = 
'??'}


But I can't determine how to use ValueAttr to suit my needs as the 
keys/values are not know.


I think XML::Generator would suit me best but I can't see can append 
data to $xml. Can anyone offer any advice?


I am unfamiliar with XML::Generator, but have experimented with it for
the purposes of your question and it seems to be essentially a translator
that will convert a Perl fragment into an XML fragment, and I can see no
way to modify existing XML. Because of this it seems extremely limited in
its application, as you would have to write

 my $xml = $gen-users(
   $gen-user({id = 10}, 'dermot'),
   $gen-user({id = 17}, 'joe'),
 :
 );

to create your desired output, which simply moves your problem to one of
how to generate the Perl from your data in the first place. If someone
on the list is familiar with XML::Generator then please correct me if I
am wrong.

Depending on how complex your real data is, you should be using XML::LibXML,
XML::Twig, or XML::Element (in decreasing order of desirability) to get
a proper API for building XML data. But if you really have something as
simple as you describe then you should look at XML::Writer, which does little
except check that your XML syntax is correct as you write it (you have to
balance your own start/end tags). The code below represents a solution using
this module.

HTH,

Rob


use strict;
use warnings;

use XML::Writer;

chomp (my @data = DATA);

my $writer = XML::Writer-new(DATA_MODE = 1, DATA_INDENT = 1);

$writer-startTag('users');

foreach (@data) {

 my ($name, $id) = split;
 $writer-startTag('user', id = $id);
 $writer-characters($name);
 $writer-endTag('user', id = $id);
}

$writer-endTag('users');

$writer-end;

__DATA__
dermot 10
joe 17
rose 11
phil 13
brian 20
andy 15


**OUTPUT**

users
user id=10dermot/user
user id=17joe/user
user id=11rose/user
user id=13phil/user
user id=20brian/user
user id=15andy/user
/users


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




Re: Help generating XML output

2007-10-23 Thread Jenda Krynicky
From: Rob Dixon [EMAIL PROTECTED]
 I am unfamiliar with XML::Generator, but have experimented with it for
 the purposes of your question and it seems to be essentially a translator
 that will convert a Perl fragment into an XML fragment, and I can see no
 way to modify existing XML. Because of this it seems extremely limited in
 its application, as you would have to write
 
   my $xml = $gen-users(
 $gen-user({id = 10}, 'dermot'),
 $gen-user({id = 17}, 'joe'),
   :
   );
 
 to create your desired output, which simply moves your problem to one of
 how to generate the Perl from your data in the first place. If someone
 on the list is familiar with XML::Generator then please correct me if I
 am wrong.

It's just a matter of one map():

#!perl
use XML::Generator;

$ref = {
'dermot' = '10',
'joe' = '17',
'rose' = '11',
'phil' = '13',
'brian' = '20',
'andy' = '15',
};

my $gen = XML::Generator-new(':pretty');
my $xml = $gen-users(
 map { $gen-user({id = $ref-{$_}}, $_) } keys %{$ref}
);

print $xml;
__END__

Jenda
= [EMAIL PROTECTED] === http://Jenda.Krynicky.cz =
When it comes to wine, women and song, wizards are allowed 
to get drunk and croon as much as they like.
-- Terry Pratchett in Sourcery


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




Re: PHP parsing

2007-10-23 Thread Jenda Krynicky
From: Siva Prasad [EMAIL PROTECTED]
 I have a PHP page I need to click on the links that are there on the php
 which will navigate me to another PHP page and I need to parse data on them
 
 Is there any Perl modules that will server my purpose.

It's irrelevant that it's PHP on the server side.

Have a look at WWW::Mechanize and HTML::Parser.

Jenda
= [EMAIL PROTECTED] === http://Jenda.Krynicky.cz =
When it comes to wine, women and song, wizards are allowed 
to get drunk and croon as much as they like.
-- Terry Pratchett in Sourcery


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




Re: Date addition-reg

2007-10-23 Thread jeevs
On Oct 23, 2:19 pm, [EMAIL PROTECTED] wrote:
 Hi

 Thaks for ur valuable info..

 my code is

 my $total_nights=3;
 $total_nights = 0.$total_nights if ((!($total_nights =~
 /^0/))  ($total_nights  10));
 my $start_date=2008-03-24;
 my ($year,$mon,$day) = split/-/,$start_date;
$day=($day+$total_nights);
my @data =($year,$mon,$day);
 my $departure_date= join(-,@data);

 but it makes issues on Feb and end of the
 monthsAny comments???

 Thanks,
 Boniface

Date is one complex thing to handle on itself, when you want to
manipulate it ... There are modules to make it simple
I would suggest you Date::Calc module

##
use strict;
use warnings;
use Date::Calc qw(Add_Delta_Days);

my ($y,$m,$d) = (2007,7,12);
$total_nights = 3;
($y,$m,$d) = Add_Delta_Days($y,$m,$d,$total_nights);

##

From whatever I have read to be you requirement this would work fine
for you





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




Re: Help generating XML output

2007-10-23 Thread Beginner
On 23 Oct 2007 at 14:21, Jenda Krynicky wrote:

 From: Rob Dixon [EMAIL PROTECTED]
  I am unfamiliar with XML::Generator, but have experimented with it
 for
  the purposes of your question and it seems to be essentially a
 translator
  that will convert a Perl fragment into an XML fragment, and I can
 see no
  way to modify existing XML. Because of this it seems extremely
 limited in
  its application, as you would have to write
  
my $xml = $gen-users(
  $gen-user({id = 10}, 'dermot'),
  $gen-user({id = 17}, 'joe'),
:
);
  
  to create your desired output, which simply moves your problem to
 one of
  how to generate the Perl from your data in the first place. If
 someone
  on the list is familiar with XML::Generator then please correct me
 if I
  am wrong.
 
 It's just a matter of one map():
 
 #!perl
 use XML::Generator;
 
 $ref = {
   'dermot' = '10',
   'joe' = '17',
   'rose' = '11',
   'phil' = '13',
   'brian' = '20',
   'andy' = '15',
 };
 
 my $gen = XML::Generator-new(':pretty');
 my $xml = $gen-users(
  map { $gen-user({id = $ref-{$_}}, $_) } keys %{$ref}
 );
 
 print $xml;
 __END__

Well that certainly does it. I could almost kick myself for not 
seeing it.

On a more general point I haven't found it easy to find modules that 
output XML or perhaps I should say, I didn't find the ones I did look 
at to be well documented in terms of examples or show the variety of 
different ways data structures can be represented in XML.

Excuse my whinge. Thanx to you both your help.
Dp.


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




Re: How do I properly use global variables?

2007-10-23 Thread Matthew Whipple
Jeff Pang wrote:
 On 10/23/07, monk [EMAIL PROTECTED] wrote:
   
 I'm having problems accessing a variable outside its subroutine.
 I've tried several combinations too long to write here. Maybe I just
 can't see the forest for the trees.  But I'm lost.  I need your
 wisdom.

 I'd like my program below to change $status to zero to exit the loop.

 meaning...$ perl test.pl --start
 it prints out indefinitely hello world

 But if  $ perl test.pl --stop
 it gets out of the loop exiting the program.


 
And if you want to keep the notation similar to that above you'd need
the second instance of the script (with the --stop), to send the signal
to the process of the first instance (generally by storing the pid in a
file and then sending the signal as below if the pid is still running).

 Hi,

 When script is running,how can you re-run it with another argument to
 make it stop?
 The general way to let a running program stop is to send a signal.
 Let me modify your code to,

 use strict;
 use warnings;

 our $status = 1;
 $SIG{TERM} = $SIG{INT} = sub {$status = 0};

 start();

 sub start {
while ($status){
  print hello world!\n;
  sleep 1;
}

print out of loop. Will exit now\n;
exit 0;
 }

 __END__


 When you run it,you can send SIGINT or SIGTERM to let it exit gracefully.
 Given the process id is 1234,under unix you can say,

 $ kill -s 2  1234

 The script would print out of loop. Will exit now and exit.
 (-s 2 means sending SIGINT,see `man 7 signal` for details).

 The most important change for the code above is that we re-defined
 singal handlers:
 $SIG{TERM} = $SIG{INT} = sub {$status = 0};

 When the script receive SIGTERM or SIGINT,it set the global $status to
 0,so the loop condition become false,the program exit.

   


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




Re: Absolute noobie question regarding opening files on Windows platform

2007-10-23 Thread Paul Lalli
On Oct 22, 7:49 pm, [EMAIL PROTECTED] (Yitzle) wrote:
 The '/' is used on Unix, but not on Windows.
 Try replacing it with a '\'
 open(READFILE1,.\Sample_text_file.txt) or die (Cannot open the given 
 file);
 Or maybe just drop the './' entirely.

To the OP, please ignore this post completely.  It is very wrong, and
will lead you to more complicated errors.

Yitzle, I'm sure you mean well, but taking random guesses at what
might be wrong, and worse, at what a solution might be, are far worse
than giving no advice at all.

Paul Lalli


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




Re: Absolute noobie question regarding opening files on Windows platform

2007-10-23 Thread Paul Lalli
On Oct 22, 3:27 pm, [EMAIL PROTECTED] (Ayesha) wrote:
 Hi all

 I wrote this code to read a file (in the same directory as the script)
 on Win XP
 ***­
 #!/usr/local/bin/perl
 use strict;
 use warnings;

 open(READFILE1,./Sample_text_file.txt) or die (Cannot open the
 given file);
 my $record;
  while ($record = READFILE1) {
   print $record;
}

 close READFILE1;

 #print Is this even working? \n
 ***­*
 It is gives me output that Cannot open the given file. However, the
 same program is working on linux/mac platforms, i.e. can open files
 and read them. To check that I have perl correctly installed I added a
 print statement at the end. When I block everything regarding opening
 the file and just have the print statement in the script, the script
 works OK, implying Perl is installed correctly. Can anyone tell me
 what is wrong. Can anyone tell me what am I doing wrong here? It seems
 some Windows specific thing.

You are asking *us* why Perl can't open the file, before you ask
*Perl* why it can't open the file.  That is most illogical...

Your die() message should include the $! variable, which contains the
last operating system error.  It will tell you why the file could not
be opened.  Change your die() to:

die Cannot open the given file: $!;

Not relevant to the problem at hand, but you should also be using
lexical filehandles instead of global barewords, and get into the
habbit of using the three-argument form of open:

open my $READFILE1, '', './Sample_text_file.txt' or
   die Cannot open the given file: $!;

Paul Lalli


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




problem runing code | strange Error

2007-10-23 Thread Juan B

-Hi,

Im trying to run this code: (im getting this error
message):

Can't use string (From) as a HASH ref while strict
refs in use at
/usr/lib/perl5/site_perl/5.8.8/Mail/Mailer.pm line
320.

The code:

use strict;
use warnings;
use Mail::Mailer;

my @lines = ();
open (INFO, /var/log/messages) or die $!;
while (my $line = INFO) {
   if ($line =~ /IDS/) {
  push @lines,$line;
   }
}
close INFO;
if (@lines) {
   my $mailer = Mail::Mailer-new(smtp,
10.83.27.71);
   $mailer-open( 'From' = 'Syslog
[EMAIL PROTECTED]',
  'To' = 'gabriela pinado
[EMAIL PROTECTED]',
  'Subject' = 'PiX Detected Attack '
);
   print $mailer @lines;
   $mailer-close or die can't close mailer: $!;
}

Any ideas where is the problem?

thanks a lot !

Juan


__
Do You Yahoo!?
Tired of spam?  Yahoo! Mail has the best spam protection around 
http://mail.yahoo.com 

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




Re: Absolute noobie question regarding opening files on Windows platform

2007-10-23 Thread Paul Lalli
On Oct 23, 12:27 am, [EMAIL PROTECTED] (Ayesha) wrote:

 I was not in the right directory, but I learnt about forward and
 backward slashed also. Thanks to all who replied

Arg.  This is exactly what I was afraid of.  The post about forward vs
backwards slashes was wrong.  Do not follow it.  You should ALWAYS use
front slashes, regardless of Windows vs Unix.   The only thing in
Windows that requires backslashes is the cmd.exe or command.com
shells.  You are not using these shells when you write a Perl program.

Paul Lalli


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




Re: problem runing code | strange Error

2007-10-23 Thread Paul Lalli
On Oct 23, 9:57 am, [EMAIL PROTECTED] (Juan B) wrote:
 -Hi,

 Im trying to run this code: (im getting this error
 message):

 Can't use string (From) as a HASH ref while strict
 refs in use at
 /usr/lib/perl5/site_perl/5.8.8/Mail/Mailer.pm line
 320.

 The code:

 use strict;
 use warnings;
 use Mail::Mailer;

 my @lines = ();
 open (INFO, /var/log/messages) or die $!;
 while (my $line = INFO) {
if ($line =~ /IDS/) {
   push @lines,$line;
}}

 close INFO;
 if (@lines) {
my $mailer = Mail::Mailer-new(smtp,
 10.83.27.71);
$mailer-open( 'From' = 'Syslog
 [EMAIL PROTECTED]',
   'To' = 'gabriela pinado
 [EMAIL PROTECTED]',
   'Subject' = 'PiX Detected Attack '
 );

Mail::Mailer::open takes a hash reference.  You have passed it a list
of key/value pairs.

Stick a { before 'From' and a } after 'Attack' to create your hash
reference.

Paul Lalli


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




Re: problem runing code | strange Error

2007-10-23 Thread Juan B
Hi,

I did it and know I get another error:

syntax error at logcheck line 25, near 'PiX Detected
Attack } ' )
Missing right curly or square bracket at logcheck line
28, at end of line
Execution of logcheck aborted due to compilation
errors.

This is the code:

use strict;
use warnings;
use Mail::Mailer;

my @lines = ();
open (INFO, /var/log/messages) or die $!;
while (my $line = INFO) {
   if ($line =~ /IDS/) {
  push @lines,$line;
   }
}
close INFO;
if (@lines) {
   my $mailer = Mail::Mailer-new(smtp,
10.83.27.71);
  $mailer-open( {'From' = 'Syslog
[EMAIL PROTECTED]',
  'To' = 'gabriela pinado
[EMAIL PROTECTED]',
  'Subject' = 'PiX Detected Attack }
' );
   print $mailer @lines;
   $mailer-close or die can't close mailer: $!;


thanks a lot !

Juan


__
Do You Yahoo!?
Tired of spam?  Yahoo! Mail has the best spam protection around 
http://mail.yahoo.com 

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




Re: Absolute noobie question regarding opening files on Windows platform

2007-10-23 Thread Jenda Krynicky
From: Paul Lalli [EMAIL PROTECTED]
 You are asking *us* why Perl can't open the file, before you ask
 *Perl* why it can't open the file.  That is most illogical...
 
 Your die() message should include the $! variable, which contains the
 last operating system error.  It will tell you why the file could not
 be opened.  Change your die() to:
 
 die Cannot open the given file: $!;

You might want to use $^E instead, under some OSes (VMS, OS/2, 
Windows) it contains more details than $!, on other's it's equal to 
$!.

Jenda
= [EMAIL PROTECTED] === http://Jenda.Krynicky.cz =
When it comes to wine, women and song, wizards are allowed 
to get drunk and croon as much as they like.
-- Terry Pratchett in Sourcery


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




Re: Help generating XML output

2007-10-23 Thread Jenda Krynicky
From: Beginner [EMAIL PROTECTED]
 On a more general point I haven't found it easy to find modules that 
 output XML or perhaps I should say, I didn't find the ones I did look 
 at to be well documented in terms of examples or show the variety of 
 different ways data structures can be represented in XML.

Well, as the author of one of the modules you may have looked at I am 
to blame. There are virtualy no examples in XML::Rules. For your 
example the code using XML::Rules would look like this:


use XML::Rules;

$ref = {
  'dermot' = '10',
  'joe' = '17',
  'rose' = '11',
  'phil' = '13',
  'brian' = '20',
  'andy' = '15',
};

my $parser = XML::Rules-new(
  rules = [],
);

print $parser-ToXML(
 users = {
  user = [
   map { {id = $ref-{$_}, _content = $_} } keys %{$ref}
  ]
 }, 0, '  '
);


Jenda
= [EMAIL PROTECTED] === http://Jenda.Krynicky.cz =
When it comes to wine, women and song, wizards are allowed 
to get drunk and croon as much as they like.
-- Terry Pratchett in Sourcery


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




Re: Insecure dependency in open while running setuid at

2007-10-23 Thread Tom Phoenix
On 10/23/07, anders [EMAIL PROTECTED] wrote:

 I have a program witch calls a test program i PERL
 The testa prorgam gets a filname and parameters in
 Ans supose to just write data to a output file
 But i get an error saying
 Insecure dependency in open while running setuid at

I'm not sure what you're trying to say. If you don't speak English
well, please feel free to ask your question in a language that you're
fluent in.

Have you seen what the perldiag manpage has to say about that message?
It means that the open() function was given data from a
possibly-insecure source. That's probably a filename. If you're
getting the filename from the user, you'll need to extract it from a
pattern match, maybe something like this:

  chomp(my $filename = STDIN);
  if ($filename =~ /^(\w+)\z/) {
$filename = $1;  # extracted data is considered safe
  } else {
die Disallowed characters in filename: '$filename';
  }
  open FILE, $filename or die Can't open '$filename': $!;

Good luck with it!

--Tom Phoenix
Stonehenge Perl Training

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




Re: problem runing code | strange Error

2007-10-23 Thread Jenda Krynicky
From: Juan B [EMAIL PROTECTED]
 use Mail::Mailer;
 
 snipped

my $mailer = Mail::Mailer-new(smtp,
 10.83.27.71);
$mailer-open( 'From' = 'Syslog
 [EMAIL PROTECTED]',
   'To' = 'gabriela pinado
 [EMAIL PROTECTED]',
   'Subject' = 'PiX Detected Attack '
 );

The open() expects a single parameter, a reference to a hash. Not a 
list of parameters, the odd ones being names and the even ones the 
values.

Use

  $mailer-open({
   'From' = 'Syslog [EMAIL PROTECTED]',
   'To' = 'gabriela pinado [EMAIL PROTECTED]',
   'Subject' = 'PiX Detected Attack'
 });

HTH, Jenda
= [EMAIL PROTECTED] === http://Jenda.Krynicky.cz =
When it comes to wine, women and song, wizards are allowed 
to get drunk and croon as much as they like.
-- Terry Pratchett in Sourcery


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




Re: Any clues to access Chinese folder name on Win32 ?

2007-10-23 Thread Tom Phoenix
On 10/23/07, Panda-X [EMAIL PROTECTED] wrote:

 Thanks for the reply. But seems I have no luck with that !

Did you try readdir() or glob(), as I suggested? I can't see them in your code.

--Tom Phoenix
Stonehenge Perl Training

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




Re: Help generating XML output

2007-10-23 Thread Beginner
On 23 Oct 2007 at 16:46, Jenda Krynicky wrote:

 From: Beginner [EMAIL PROTECTED]
  On a more general point I haven't found it easy to find modules
 that 
  output XML or perhaps I should say, I didn't find the ones I did
 look 
  at to be well documented in terms of examples or show the variety
 of 
  different ways data structures can be represented in XML.
 
 Well, as the author of one of the modules you may have looked at I
 am 
 to blame. 

Opps. The words foot and mouth spring to mind. No offence 
intended, honest.
Dp.


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




Re: problem runing code | strange Error

2007-10-23 Thread Juan B
Ok I did it and know I get another error :-(
here goes the error:
 Died at /usr/lib/perl5/site_perl/5.8.8/Mail/Mailer.pm
line 284.



this is the code:
use strict;
use warnings;
use Mail::Mailer;

my @lines = ();
open (INFO, /var/log/messages) or die $!;
while (my $line = INFO) {
   if ($line =~ /IDS/) {
  push @lines,$line;
   }
}
close INFO;
if (@lines) {
   my $mailer = Mail::Mailer-new(smtp,
10.83.27.71);
  $mailer-open({
'From' = 'Syslog [EMAIL PROTECTED]',
'To' = 'gabriela pinado
[EMAIL PROTECTED]',
'Subject' = 'PiX Detected Attack'
});
   print $mailer @lines;
   $mailer-close or die can't close mailer: $!;
}
~

please assist!

thanks very much !

Juan


__
Do You Yahoo!?
Tired of spam?  Yahoo! Mail has the best spam protection around 
http://mail.yahoo.com 

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




Re: problem runing code | strange Error

2007-10-23 Thread Jenda Krynicky
From:   Juan B [EMAIL PROTECTED]
 Ok I did it and know I get another error :-(
 here goes the error:
  Died at /usr/lib/perl5/site_perl/5.8.8/Mail/Mailer.pm
 line 284.

That's not a very informative error message. anyway maybe it's time 
to go read the Mail::Mailer's docs. Search for smtp and look at the 
example.

 this is the code:
 use strict;
 use warnings;
 use Mail::Mailer;
 
 my @lines = ();
 open (INFO, /var/log/messages) or die $!;
 while (my $line = INFO) {
if ($line =~ /IDS/) {
   push @lines,$line;
}
 }
 close INFO;
 if (@lines) {
my $mailer = Mail::Mailer-new(smtp,
 10.83.27.71);

jenda
= [EMAIL PROTECTED] === http://Jenda.Krynicky.cz =
When it comes to wine, women and song, wizards are allowed 
to get drunk and croon as much as they like.
-- Terry Pratchett in Sourcery


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




Re: Getting error message while installing Crypt-DSA module

2007-10-23 Thread kilaru rajeev
Hi All,

Thanks for your quick responce.

I found following message while installing the Net::SSH module.

t/03-packet..Can't load
'/crdv8/shared/perl/lib/site_perl/5.8.3/sun4-solaris/auto/Math/GMP/GMP.so'
for module Math::GMP: ld.so.1: perl5.8.3: fatal: relocation error: file
/crdv8/shared/perl/lib/site_perl/5.8.3/sun4-solaris/auto/Math/GMP/GMP.so:
symbol __gmpz_init_set_str: referenced symbol not found at
/crdv8/shared/perl/lib/5.8.3/sun4-solaris/DynaLoader.pm line 229.

Please advice me know what it really meant.

Thanks,
Rajeev Kilaru

On 23 Oct 2007 01:06:42 -0700, sisyphus [EMAIL PROTECTED] wrote:

 On Oct 23, 1:15 am, [EMAIL PROTECTED] (Kilaru Rajeev) wrote:
  Hi All,
 
  I am getting the following error in the *make test* part while istalling
 the
  *Crypt::DSA* module. Please give me an advice how to procede.
 
  t/03-keygen.*Math::BigInt: couldn't load specified math lib(s),
 fallback
  to Math::BigInt::Calc* at /tmp/Crypt-DSA-0.14
 /blib/lib/Crypt/DSA/KeyChain.pm
  line 6
  *Math::BigInt: couldn't load specified math lib(s), fallback to
  Math::BigInt::Calc* at /tmp/Crypt-DSA-0.14/blib/lib/Crypt/DSA/Key.pm
 line 6
  *Math::BigInt: couldn't load specified math lib(s), fallback to
  Math::BigInt::Calc* at /tmp/Crypt-DSA-0.14/blib/lib/Crypt/DSA/Util.pm
 line 6
 

 I don't believe it's an error - it's merely telling you that you don't
 have Math::BigInt::GMP installed, so (the slower, pure perl)
 Math::BigInt::Calc is being used instead.

 The line of code that's producing the warning in all 3 instances is:

 use Math::BigInt lib = 'GMP';

 If you had Math::BigInt::GMP installed you would find that the tests
 run more quickly. (To install Math::BigInt::GMP, you'll first need to
 install the GMP library. See http://gmplib.org/ )

 Cheers,
 Rob


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





Re: Help generating XML output

2007-10-23 Thread Rob Dixon

Jenda Krynicky wrote:

From: Rob Dixon [EMAIL PROTECTED]

I am unfamiliar with XML::Generator, but have experimented with it for
the purposes of your question and it seems to be essentially a translator
that will convert a Perl fragment into an XML fragment, and I can see no
way to modify existing XML. Because of this it seems extremely limited in
its application, as you would have to write

  my $xml = $gen-users(
$gen-user({id = 10}, 'dermot'),
$gen-user({id = 17}, 'joe'),
  :
  );

to create your desired output, which simply moves your problem to one of
how to generate the Perl from your data in the first place. If someone
on the list is familiar with XML::Generator then please correct me if I
am wrong.


It's just a matter of one map():

#!perl
use XML::Generator;

$ref = {
'dermot' = '10',
'joe' = '17',
'rose' = '11',
'phil' = '13',
'brian' = '20',
'andy' = '15',
};

my $gen = XML::Generator-new(':pretty');
my $xml = $gen-users(
 map { $gen-user({id = $ref-{$_}}, $_) } keys %{$ref}
);

print $xml;
__END__


Well yes, of course that's possible. But you're advocating abandoning
strictures and writing unintelligible code by proposing it.

Rob

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




String processing

2007-10-23 Thread Mark Wagner
I'm working on a program to process Wikipedia pages.  Wikipedia pages
can contain templates of the form:

{{template name
|key = value
|key2 = value2
|...
}}

Any value may in turn be a template, with essentially no limit to the
level of nesting.  Given a key = value pair, how would I go about
retrieving the entire template from the page?

In C, I'd use strstr() to find the key = value pair, walk my way
back up the string until I found an unmatched {{ as the beginning of
the template, and walk down the string until I found an unmatched }}
as the end.  How would I do this in Perl?

-- 
Mark

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




Re: String processing

2007-10-23 Thread yitzle
Recursion is the way I'd solve something like this.
Start processing the data, line by line, and when you hit a 'begin
template' ({{), recursively process it.

An example of a nested template and a sample of what you are trying to
generate might make it easier to be specific about the solution

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




Re: String processing

2007-10-23 Thread Matthew Whipple
Mark Wagner wrote:
 I'm working on a program to process Wikipedia pages.  Wikipedia pages
 can contain templates of the form:

 {{template name
 |key = value
 |key2 = value2
 |...
 }}

 Any value may in turn be a template, with essentially no limit to the
 level of nesting.  Given a key = value pair, how would I go about
 retrieving the entire template from the page?

 In C, I'd use strstr() to find the key = value pair, walk my way
 back up the string until I found an unmatched {{ as the beginning of
 the template, and walk down the string until I found an unmatched }}
 as the end.  How would I do this in Perl?

   
Are you looking for the way to implement the outlined algorithm in Perl,
or suggestions on other ways to process the data?
By processing the data as far as the question goes, you're looking to
create a hash for each template?

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




Re: String processing

2007-10-23 Thread Dr.Ruud
Mark Wagner schreef:

 I'm working on a program to process Wikipedia pages.  Wikipedia pages
 can contain templates of the form:

 {{template name
 |key = value
 |key2 = value2
 | ...
 }}

 Any value may in turn be a template, with essentially no limit to the
 level of nesting.  Given a key = value pair, how would I go about
 retrieving the entire template from the page?

 In C, I'd use strstr() to find the key = value pair, walk my way
 back up the string until I found an unmatched {{ as the beginning of
 the template, and walk down the string until I found an unmatched }}
 as the end.  How would I do this in Perl?

Look for a proper module first, like Parse::RecDescent
http://search.cpan.org/~tbone/Parse-RecDescent-FAQ/FAQ.pm

-- 
Affijn, Ruud

Gewoon is een tijger.


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




Re: Help generating XML output

2007-10-23 Thread Jenda Krynicky
From:   Rob Dixon [EMAIL PROTECTED]
 Jenda Krynicky wrote:
  It's just a matter of one map():
  
  #!perl
  use XML::Generator;
  
  $ref = {
  'dermot' = '10',
  'joe' = '17',
  'rose' = '11',
  'phil' = '13',
  'brian' = '20',
  'andy' = '15',
  };
  
  my $gen = XML::Generator-new(':pretty');
  my $xml = $gen-users(
   map { $gen-user({id = $ref-{$_}}, $_) } keys %{$ref}
  );
  
  print $xml;
  __END__
 
 Well yes, of course that's possible. But you're advocating abandoning
 strictures and writing unintelligible code by proposing it.

Beg your pardon? use strict doesn't have any problems with that code. 
And if you find map{} uninteligible it's your problem, not the 
code's. If you insist on not using map{} you could of course write 
the code like this:

#!perl
use strict;
use warnings;
use XML::Generator;

my $ref = {
  'dermot' = '10',
  'joe' = '17',
  'rose' = '11',
  'phil' = '13',
  'brian' = '20',
  'andy' = '15',
};

my $gen = XML::Generator-new(':pretty');
my @users;
foreach (keys %{$ref}) {
  push @users, $gen-user({id = $ref-{$_}}, $_)
}

my $xml = $gen-users(
 @users
);

print $xml;
__END__

but I do not find it any easier to read. Just the opposite.

map{} just transforms a list, what's so hard about it?

Jenda
= [EMAIL PROTECTED] === http://Jenda.Krynicky.cz =
When it comes to wine, women and song, wizards are allowed 
to get drunk and croon as much as they like.
-- Terry Pratchett in Sourcery


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




Re: how to insert rows into database from array/hash using DBI

2007-10-23 Thread Matthew Whipple
[EMAIL PROTECTED] wrote:
 I'm trying to grab data from an MS-Access log file and put it into a
 fast, read-only database. (I'm thinking SQL Lite at this point.)
   
Make sure that's it's only read-only after it's written to.  Depending
on what you're doing with the data it may be easiest and fastest to use
a format that Access can work with and then dump directly to that file
with something like a SELECT...INTO... statement and a linked table in
Access.
 The code below is working.  Now I need to put the identical data and
 structure into an SQL Lite table.  Any suggestions on where to look
 for examples?  (or if you want to write one, that's fine too.)

 I own the book Programming the Perl DBI, but I haven't found
 anything that addresses this.

 use warnings;
 use strict;

 use DBI;
 use DBD::ODBC;
 use DBD::SQLite;

 my $DSN = 'driver=Microsoft Access Driver (*.mdb);dbq=C:\temp
 \adt2_in.mdb';
 my $dbh1 = DBI-connect(dbi:ODBC:$DSN,,) or die $DBI::errstr\n;

 $dbh1-{LongReadLen} = 2000;
 $dbh1-{LongTruncOk} = 1;

 my $sth1 = $dbh1-prepare(select message_index, message_no,
 message_event, time_stamp, data from log);

 $sth1-execute();

 my @stash;

 while (my $hash_ref = $sth1-fetchrow_hashref()) {
 push @stash, { %$hash_ref };
 }

 $dbh1-disconnect();

 my $itemp = 1;
 foreach my $hash_ref (@stash) {
 print  Details of row $itemp: ;
 print \n\n;

 foreach my $key (keys %{$hash_ref}) {
print ($key \t $hash_ref-{$key} \n);
 }
$itemp++;
 }

 Thanks.


   


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




Re: String processing

2007-10-23 Thread Mark Wagner
On 10/23/07, Matthew Whipple [EMAIL PROTECTED] wrote:
 Mark Wagner wrote:
  I'm working on a program to process Wikipedia pages.  Wikipedia pages
  can contain templates of the form:
 
  {{template name
  |key = value
  |key2 = value2
  |...
  }}
 
  Any value may in turn be a template, with essentially no limit to the
  level of nesting.  Given a key = value pair, how would I go about
  retrieving the entire template from the page?
 
  In C, I'd use strstr() to find the key = value pair, walk my way
  back up the string until I found an unmatched {{ as the beginning of
  the template, and walk down the string until I found an unmatched }}
  as the end.  How would I do this in Perl?
 
 
 Are you looking for the way to implement the outlined algorithm in Perl,
 or suggestions on other ways to process the data?
 By processing the data as far as the question goes, you're looking to
 create a hash for each template?

Basically, I can find the middle of a template.  From there, I want to
identify the entire template.  I don't much care how.

-- 
Mark

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




Re: Getting error message while installing Crypt-DSA module

2007-10-23 Thread Tom Phoenix
On 10/23/07, kilaru rajeev [EMAIL PROTECTED] wrote:

 I found following message while installing the Net::SSH module.

 Please advice me know what it really meant.

It really means that you've made a mistake at some earlier step, which
you should go back and re-do. It looks as if your C compiler settings,
your loader settings, or something similar, may not be correct. It may
help to re-install perl itself, so that you can use the same settings
for perl as for your modules.

Good luck with it!

--Tom Phoenix
Stonehenge Perl Training

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




problem runing code | strange Error

2007-10-23 Thread [EMAIL PROTECTED]
Hi,

Im trying to run this code: (im getting this error message):

Can't use string (From) as a HASH ref while strict refs in use at /
usr/lib/perl5/site_perl/5.8.8/Mail/Mailer.pm line 320.

The code:

use strict;
use warnings;
use Mail::Mailer;

my @lines = ();
open (INFO, /var/log/messages) or die $!;
while (my $line = INFO) {
   if ($line =~ /IDS/) {
  push @lines,$line;
   }
}
close INFO;
if (@lines) {
   my $mailer = Mail::Mailer-new(smtp, 10.83.27.71);
   $mailer-open( 'From' = 'Syslog [EMAIL PROTECTED]',
  'To' = 'gabriela pinado
[EMAIL PROTECTED]',
  'Subject' = 'PiX Detected Attack ' );
   print $mailer @lines;
   $mailer-close or die can't close mailer: $!;
}

Any ideas where is the problem?

thanks a lot !

Juan


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




Another noobie question about perl on Windows - perl running in background

2007-10-23 Thread Ayesha
Hi all

Thanks to all who replied to my question yesterday. I am using perl-
express IDE to write a small perl code. Sometimes the code runs for a
long time (infinite loop logical error), I close the editor but
realize that the computer is suddenly running slow. So I have to go to
task manager and close perl.exe (eating 99% of CPU at that time). I
wanted to know is there any break execution when using perl-express,
and on Unix (since I use both types of OS).

Thanks
Ayesha


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




Can't figure the regex

2007-10-23 Thread newBee
^([a-zA-Z0-9_\-\.]+)@([a-zA-Z0-9_\-\.]+)\.([a-zA-Z]{2,5})$

Its look like an email address... is it..? it will be a great help if
some one could give a breakdown on the this regex.

thanks in advance...


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




Re: problem runing code | strange Error

2007-10-23 Thread Gunnar Hjalmarsson

[EMAIL PROTECTED] wrote:

Im trying to run this code: (im getting this error message):

Can't use string (From) as a HASH ref while strict refs in use at /
usr/lib/perl5/site_perl/5.8.8/Mail/Mailer.pm line 320.

The code:

use strict;
use warnings;
use Mail::Mailer;

my @lines = ();
open (INFO, /var/log/messages) or die $!;
while (my $line = INFO) {
   if ($line =~ /IDS/) {
  push @lines,$line;
   }
}
close INFO;
if (@lines) {
   my $mailer = Mail::Mailer-new(smtp, 10.83.27.71);
   $mailer-open( 'From' = 'Syslog [EMAIL PROTECTED]',
  'To' = 'gabriela pinado
[EMAIL PROTECTED]',
  'Subject' = 'PiX Detected Attack ' );
   print $mailer @lines;
   $mailer-close or die can't close mailer: $!;
}

Any ideas where is the problem?


Yes. As stated in the docs for Mail::Mailer, the open() method expects a 
hash reference as its argument.


--
Gunnar Hjalmarsson
Email: http://www.gunnar.cc/cgi-bin/contact.pl

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




line-equation program gives wrong results

2007-10-23 Thread camotito
Hello!

I was just implementing this small program for calculating the line-
equation, given two points.
Just in case you don't remind this equation y = slope * x + b.
First I calculate the slope and then b:

$slope = ($ARGV[1] - $ARGV[3]) / ($ARGV[0] - $ARGV[2]);
$b = $ARGV[1] - ($ARGV[0] * $slope);
print \n$ARGV[1] = $slope * $ARGV[0] + $b\n;

For this input :

 perl my_program 16.81 16.57 0 0

It gives me this result :

 16.57 = 0.985722784057109 * 16.81 + 0

Clearly b can be 0 only if the slope is 1. I don't know the reason for
this result (I guess precission but that's the only thing I could
say), neither how to solve it.
Please what should I do to get the correct result?

Thank you

camotito


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




Re: line-equation program gives wrong results

2007-10-23 Thread Lawrence Statton


 
 $slope = ($ARGV[1] - $ARGV[3]) / ($ARGV[0] - $ARGV[2]);
 $b = $ARGV[1] - ($ARGV[0] * $slope);
 print \n$ARGV[1] = $slope * $ARGV[0] + $b\n;
 
 For this input :
 
  perl my_program 16.81 16.57 0 0
 
 It gives me this result :
 
  16.57 = 0.985722784057109 * 16.81 + 0
 
 Clearly b can be 0 only if the slope is 1. 

Not at all clear to me ... Since one of the given points is at the
origin, then the intercept *MUST* be zero.

 I don't know the reason for
 this result (I guess precission but that's the only thing I could
 say), neither how to solve it.
 Please what should I do to get the correct result?
 
 Thank you
 
 camotito
 
 
 -- 
 To unsubscribe, e-mail: [EMAIL PROTECTED]
 For additional commands, e-mail: [EMAIL PROTECTED]
 http://learn.perl.org/
 


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




Re: line-equation program gives wrong results

2007-10-23 Thread Tom Phoenix
On 10/23/07, camotito [EMAIL PROTECTED] wrote:

 I was just implementing this small program for calculating the line-
 equation, given two points.
 Just in case you don't remind this equation y = slope * x + b.
 First I calculate the slope and then b:

 $slope = ($ARGV[1] - $ARGV[3]) / ($ARGV[0] - $ARGV[2]);
 $b = $ARGV[1] - ($ARGV[0] * $slope);
 print \n$ARGV[1] = $slope * $ARGV[0] + $b\n;

It's easier to read, write, and maintain code that uses names instead
of indices. So I'd re-write your code so far like this:

  use strict;
  use warnings;
  # @ARGV holds two points (two xy pairs)
  my($x1, $y1, $x2, $y2) = @ARGV;
  my $slope = ($y1 - $y2) / ($x1 - $x2);
  my $b = $y1 - ($x1 * $slope);
  print \n;
  print $y1 = $slope * $x1 + $b\n;

 For this input :

  perl my_program 16.81 16.57 0 0

 It gives me this result :

  16.57 = 0.985722784057109 * 16.81 + 0

 Clearly b can be 0 only if the slope is 1.

One must pay special attention to those points a mathematician
describes as clear. :-)   You must have meant to say, clearly, b can
be 0 only if the line passes through the origin. But check that sort
of detail with your algebra teacher or in a mathematics forum; perl is
doing what you're asking of it.

Cheers!

--Tom Phoenix
Stonehenge Perl Training

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




Re: Can't figure the regex

2007-10-23 Thread Jeff Pang
Yes,this is a regex for email matching,but may be broken under some cases.

The username part can be all a-z,A-Z,0-9, -, . and _ characters.
The first tld part (before the .) take the same character range as username.
the last tld part (after the .) can be a-z and A-Z only,and the
length is from 2 to 5.

In fact this is not an exact regex for email address,b/c it also match
the cases below:

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

and even,
[EMAIL PROTECTED]
[EMAIL PROTECTED]
[EMAIL PROTECTED]


There is an article on internet How to Find or Validate an Email Address.
I didn't check it carefully,but just a reference for you.
http://www.regular-expressions.info/email.html


On 10/24/07, newBee [EMAIL PROTECTED] wrote:
 ^([a-zA-Z0-9_\-\.]+)@([a-zA-Z0-9_\-\.]+)\.([a-zA-Z]{2,5})$

 Its look like an email address... is it..? it will be a great help if
 some one could give a breakdown on the this regex.

 thanks in advance...


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




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




Re: Can't figure the regex

2007-10-23 Thread Tom Phoenix
On 10/23/07, newBee [EMAIL PROTECTED] wrote:

 ^([a-zA-Z0-9_\-\.]+)@([a-zA-Z0-9_\-\.]+)\.([a-zA-Z]{2,5})$

 Its look like an email address... is it..?

It might be somebody's attempt at matching an e-mail address. But it
fails to match many valid addresses, while not excluding all invalid
ones. In other words, it makes both false positive and false negative
errors. If, of course, that's what it's intended to do.

If you're working on the program, you could try to determine whether
there's a better way to verify an e-mail address (such as sending an
activation code to it, then waiting for the owner of the address to
use that code).

 it will be a great help if
 some one could give a breakdown on the this regex.

Have you seen YAPE::Regex::Explain?

http://search.cpan.org/dist/YAPE-Regex-Explain/

Hope this helps!

--Tom Phoenix
Stonehenge Perl Training

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




Re: Another noobie question about perl on Windows - perl running in background

2007-10-23 Thread Jeff Pang
If perl consume your system source large,it mostly has two reasons:

1) Your task is really hard,ie,to handle a huge file.
2) Wrong usage with perl code.

So you'd better to describe clearly what you are doing and how you do
it.Also posting some code piece here is better.

On 10/24/07, Ayesha [EMAIL PROTECTED] wrote:
 Hi all

 Thanks to all who replied to my question yesterday. I am using perl-
 express IDE to write a small perl code. Sometimes the code runs for a
 long time (infinite loop logical error), I close the editor but
 realize that the computer is suddenly running slow. So I have to go to
 task manager and close perl.exe (eating 99% of CPU at that time). I
 wanted to know is there any break execution when using perl-express,
 and on Unix (since I use both types of OS).

 Thanks
 Ayesha


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




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




Re: Any clues to access Chinese folder name on Win32 ?

2007-10-23 Thread Panda-X
2007/10/23, Tom Phoenix [EMAIL PROTECTED]:

 On 10/23/07, Panda-X [EMAIL PROTECTED] wrote:

  Thanks for the reply. But seems I have no luck with that !

 Did you try readdir() or glob(), as I suggested? I can't see them in your
 code.

 --Tom Phoenix
 Stonehenge Perl Training



Yes, I did. Here's more code :

use Tk;
my $mw = MainWindow - new();
$x = $mw - getOpenFile ;
$mw - Label ( -text=$x ) - pack();

print $x ;
## so I got Wide character in print at list.pl line 6.

# Not sure if that's meaningful, but it got the same error ( No such file or
directory )
$dir = $x; $dir =~ s/\/[^\/]+$//;
opendir D, $dir or $mw - Label ( -text= $! --- $dir  ) - pack();
closedir D;

print glob $dir ;
# This gives nothing

open F , $x or $mw - Label ( -text= $! --- $x  ) - pack();
$mw - MainLoop;

###

# This approach works! It shows all files, and I can open files.

my $hcode_path = C:/Documents and Settings/Exile_Local/桌面 ; # Just treat
as a 2bytes char
opendir D, $hcode_path or $mw - Label ( -text= $! --- $hcode_path  ) -
pack();
if  ( D  ) {
print readdir D ;
print $/$/;
open F, $hcode_path . /index.html or die $!;
 print while F ;
close F;
}
closedir D;

###

Since I got error wide char ... I guess that relates to utf8, and so I
wrote this in another script :

use Tk;
use utf8;

binmode(STDIN, ':encoding(big5)');
binmode(STDOUT, ':encoding(big5)');
binmode(STDERR, ':encoding(big5)');

my $mw = MainWindow - new();
$x = $mw - getOpenFile ;
$mw - Label ( -text=$x ) - pack();

print $x;
## This time, the path prints okay !

$dir = $x; $dir =~ s/\/[^\/]+$//;
opendir D, $dir or $mw - Label ( -text= $! --- $dir  ) - pack();
closedir D;

print glob $dir ;

open F , $x or $mw - Label ( -text= $! --- $x  ) - pack();
$mw - MainLoop;

Beside I still got the no such file or directory error when I try to open
it,
the weir thing I don't understand is the glob() gives me this :

\x{00e6} does not map to big5-eten at list.pl line 18.
\x{00a1} does not map to big5-eten at list.pl line 18.
\x{008c} does not map to big5-eten at list.pl line 18.
\x{00e9} does not map to big5-eten at list.pl line 18.
\x{009d} does not map to big5-eten at list.pl line 18.
\x{00a2} does not map to big5-eten at list.pl line 18.
C:/DocumentsandSettings/Exile_Local/\x{00e6}\x{00a1}\x{008c}\x{00e9}\x{009d}\x{00a2}

# I don't know why the spaces are sticked together, anyway.



Just a note, I didn't assume users will select file from Desktop (in
Chinese) all the times,
so that maybe C:\abc.exe, maybe
C:/Folders/In/Other/Chinese/Char/Name/file.doc.

Thank you very much for any help.
Panda-X


undefined symbol: Perl_sv_2iv_flags

2007-10-23 Thread sivasakthi
Hi All,

I have executed the cgi files , It throws the following error in error
log,

symbol lookup
error: /usr/lib/perl5/vendor_perl/5.8.8/i386-linux-thread-multi/auto/GD/GD.so: 
undefined symbol: Perl_sv_2iv_flags,referer: http://...

Perl version is: v5.8.8 
perl-Gd rpm is :  perl-GD-2.35-1.fc5

could you help me to solve the problem..


Thanks,
Siva



Re: undefined symbol: Perl_sv_2iv_flags

2007-10-23 Thread Tom Phoenix
On 10/23/07, sivasakthi [EMAIL PROTECTED] wrote:

 I have executed the cgi files , It throws the following error in error
 log,

Why do you say you found the message in the error log? Surely you
test your programs before you install them on a server, no? Does the
message not appear when you test your program offline?

 symbol lookup
 error: /usr/lib/perl5/vendor_perl/5.8.8/i386-linux-thread-multi/auto/GD/GD.so:
 undefined symbol: Perl_sv_2iv_flags,referer: http://...

Something is misconfigured or misinstalled. It seems likely that the
GD module wasn't compiled using the same settings as your perl binary,
or something like that. If you didn't build your perl binary from the
source, I'd recommend that you build both perl and the GD module (and
any other modules) from source.

Good luck with it!

--Tom Phoenix
Stonehenge Perl Training

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




PArsing tables of web page directly on the web.

2007-10-23 Thread Siva Prasad
 

Hi Gurus,

 

I wanted to parse a PHP page which is on web.

 

I don't have access to server where the PHP page is hosted.

 

So I wanted to get source of that particular page and then parse the source
file.

 

Here is the code:

 

---Code

use LWP::UserAgent ; 

$ua = new LWP::UserAgent ; 

$ua-agent(Mozilla/4.0) ; # Play with their minds 

$req = new HTTP::Request 'GET',
'http://www.jimmyr.com:80/free_education.php' ; 

$req-header('Accept' = 'text/html') ; 

$res = $ua-request($req) ; 

if($res-is_success){ 

print $res-content ; 

} else { 

print Error:  . $res-code . . $res-message ; 

} 

 

-Code

 

 

But When I run the above code I am getting the following error.

 

Error: 500 Can't connect to www.jimmyr.com:80 (connect: Unknown error).

 

 

Is there any alternate way that I can directly parse tables and contents of
the tables on the webpage directly?

 

 

Thanks in Advance,

Siva

image001.gif