Insecure $ENV{PATH}

2006-06-08 Thread Lecca Paola


Trying to write the processes input of an hatml form via a cgi script I 
get this error message:


Software error:

Insecure $ENV{PATH} while running with -T switch at 
/usr/local/apache2/cgi-bin/post.cgi line 357.



It concerns the following lines of my cgi script

...

$ENV{PATH} = /usr/local/apache2/cgi-bin;

open(OUTF,execute.ml) or dienice(Can't open execute.ml for writing: 
$!);


...

What does this error mean and how can I solve it?

Thanks a lot in advance,
Paola.


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




Re: Insecure $ENV{PATH}

2006-06-08 Thread Paul Archer

From 'perldoc -q taint'

Found in /usr/lib/perl5/5.8.8/pod/perlfaq7.pod
   How can I tell if a variable is tainted?

   You can use the tainted() function of the Scalar::Util module, 
available from CPAN (or included with
   Perl since release 5.8.0).  See also Laundering and Detecting 
Tainted Data in perlsec.



That points to perlsec, so try
'perldoc perlsec'


Paul



2:59pm, Lecca Paola wrote:



Trying to write the processes input of an hatml form via a cgi script I get 
this error message:


Software error:

Insecure $ENV{PATH} while running with -T switch at 
/usr/local/apache2/cgi-bin/post.cgi line 357.



It concerns the following lines of my cgi script

...

$ENV{PATH} = /usr/local/apache2/cgi-bin;

open(OUTF,execute.ml) or dienice(Can't open execute.ml for writing: 
$!);


...

What does this error mean and how can I solve it?

Thanks a lot in advance,
Paola.


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






---
   Working with babies had its problems...
but then I tried working with chickens.
  Jim Henson, talking about making Labyrinth
---

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




sequence of function in Javascript

2006-06-08 Thread Lecca Paola


Thanks for your help. I solved the problem of the error message Insecure 
$ENV{...} 


Now, another question, In my html form after the insertion of data a cgi 
perl save them in a file and open a new html page, from which I want to 
have the possibility to go back to the form html page, but with all the 
field black.
In other terms, after the insertion of the data and the confirmation 
message displayed on a new html page, I wish to return from this page to 
my form an to insert new data. So I need a black form.


If I specify

INPUT type=button value=Insert new onClick=insertData()

where the function insertData() calls the form html page, I get the 
following error message like this


Unable to find insertion_form.html

The permission for the access to the directory of the htdocs are ok. 
Therefore, why this error?


To avoid this troble my idea was to compose the functions history.back() 
and Reset(), but I do not know in which way to do it. For example if I write


INPUT type=button value=Insert new onClick=history.back();Reset()

I do not obtain what I want.

Have you any idea about how to solve this problem?

Thanks a lot in advance,
Paola.

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




getting file from outer network with curl tool occurs errors

2006-06-08 Thread Joodhawk Lin








While I try to get file from a site by CURL tool, it
alters me this:

Curl: (6) Could not resolve host:
http://helloworld.com/; No data record of requested type



I am in an inner network, and I try to get file
through gateway (10.89.54.254) by http.

Did anybody get it; can you share it to me?

Or you can contact to me by email!



You can refer the attachment for the command that I
key in my command line on WIN2000.



Thank you!








c:\winnt\system32\cmd.exe /c E:\WWW\www_1\project2\taibei_server\tool\curl.exe  
http://helloworld.com/bmg_ce/FR.MT9  
E:\WWW\www_1\project2\taibei_server\receive\FR.MT9

errors:
curl: (6) Could not resolve host: shop.benq.com.tw; No data record of requested 
type-- 
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
http://learn.perl.org/ http://learn.perl.org/first-response


OO Perl question

2006-06-08 Thread Graeme McLaren
Hi all, this class that I have written lists the contents of a log table 
when the $log-view method is invoked.  There is some hardcoded SQL in this 
method and all I do is pass it a number which then looks up the relevant 
records.  This really isn't a reusable class as far as I understand it 
because it assumes that anyone else using it would have a log table with 
various fields of a certain name defined.  How can I make this completely 
reuseable, should it be documented saying that you need to create a log 
table with various fields before using it or should I code it so that the 
table name and fields have to be passed in and the script would then take 
care of it?



Your thoughts and comments are as always - appreciated.


Cheers,

G :)



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




Re: OO Perl question

2006-06-08 Thread Anthony Ettinger

On 6/8/06, Graeme McLaren [EMAIL PROTECTED] wrote:

Hi all, this class that I have written lists the contents of a log table
when the $log-view method is invoked.  There is some hardcoded SQL in this
method and all I do is pass it a number which then looks up the relevant
records.  This really isn't a reusable class as far as I understand it
because it assumes that anyone else using it would have a log table with
various fields of a certain name defined.  How can I make this completely
reuseable, should it be documented saying that you need to create a log
table with various fields before using it or should I code it so that the
table name and fields have to be passed in and the script would then take
care of it?


Your thoughts and comments are as always - appreciated.


Cheers,

G :)



Interesting. Reusable by who? Is it part of a package you're going to
distribute? is there an included mypkg.sql file they have to run?

Typically, package installs come with a config file where a user can
specify tablename_prefix. so it would be pretty seamless if all they
had to do was edit mypkg.conf and change:
table_prefix = mypkg_

so then log_table would become mypkg_log_table, while columns
would remain the same.
You could have your module simply read the config file inside the
implementation of $log-view();

The table structure(s) should stay the same, but give them a chance to
override the table names incase they collide with pre-existing tables.

I've found this to be the best way to ensure not dropping tables on
accident, especially if you load an sql file with drop table foo if
foo exists. I almost did that at work the other day on a table with 1
character diff in the name (i was lucky, and added dp_ to all my table
namespaces).



--
Anthony Ettinger
Signature: http://chovy.dyndns.org/hcard.html

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




Re: OO Perl question

2006-06-08 Thread Graeme McLaren
Hi Anthony, good idea about overriding the table names.  I had a feeling 
there would be a conf file somewhere.  As I am outputting the results of the 
SELECT to an HTML::Template I am already using a Conf file which is another 
class.  This leads me on to another question.  If I instantiate my class and 
create a Conf object within $log-view then the Conf file won't be loaded 
till this method is invoked.  I want to have all the Conf details available 
at the same time, I don't want to instantiate the Conf class several times 
and hold several copies of the Conf in memory when only one is required.  So 
how or where should I instantiate it?



Cheers,

G :)


From: Anthony Ettinger [EMAIL PROTECTED]
To: Graeme McLaren [EMAIL PROTECTED]
CC: beginners@perl.org
Subject: Re: OO Perl question
Date: Thu, 8 Jun 2006 00:50:07 -0700
MIME-Version: 1.0
Received: from lists.develooper.com ([63.251.223.186]) by 
bay0-mc4-f9.bay0.hotmail.com with Microsoft SMTPSVC(6.0.3790.1830); Thu, 8 
Jun 2006 00:50:55 -0700

Received: (qmail 30649 invoked by uid 514); 8 Jun 2006 07:50:32 -
Received: (qmail 30640 invoked from network); 8 Jun 2006 07:50:32 -
Received: from x1a.develooper.com (HELO x1.develooper.com) (216.52.237.111) 
 by lists.develooper.com with SMTP; 8 Jun 2006 07:50:32 -

Received: (qmail 22138 invoked by uid 225); 8 Jun 2006 07:50:32 -
Received: (qmail 22131 invoked by alias); 8 Jun 2006 07:50:31 -
Received: pass (x1.develooper.com: domain of [EMAIL PROTECTED] designates 
64.233.184.235 as permitted sender)
Received: from wr-out-0506.google.com (HELO wr-out-0506.google.com) 
(64.233.184.235)by la.mx.develooper.com (qpsmtpd/0.28) with ESMTP; Thu, 
08 Jun 2006 00:50:15 -0700
Received: by wr-out-0506.google.com with SMTP id i24so350408wrafor 
beginners@perl.org; Thu, 08 Jun 2006 00:50:07 -0700 (PDT)
Received: by 10.85.2.9 with SMTP id e9mr1043594aui;Thu, 08 Jun 2006 
00:50:07 -0700 (PDT)

Received: by 10.85.9.6 with HTTP; Thu, 8 Jun 2006 00:50:07 -0700 (PDT)
X-Message-Info: LsUYwwHHNt33w3Rs6VlmTi0/QtJPVei9e3LxwGYZQ3U=
Mailing-List: contact [EMAIL PROTECTED]; run by ezmlm
Precedence: bulk
List-Post: mailto:beginners@perl.org
List-Help: mailto:[EMAIL PROTECTED]
List-Unsubscribe: mailto:[EMAIL PROTECTED]
List-Subscribe: mailto:[EMAIL PROTECTED]
List-Id: beginners.perl.org
Delivered-To: mailing list beginners@perl.org
Delivered-To: beginners@perl.org
X-Spam-Status: No, hits=-2.6 
required=8.0tests=BAYES_00,DK_SIGNED,DK_VERIFIED,SPF_PASS

X-Spam-Check-By: la.mx.develooper.com
DomainKey-Signature: a=rsa-sha1; q=dns; c=nofws;s=beta; 
d=gmail.com;
h=received:message-id:date:from:sender:to:subject:cc:in-reply-to:mime-version:content-type:content-transfer-encoding:content-disposition:references:x-google-sender-auth; 
   
b=MWpGrVpwc5GSsI/9QwtAXq29UU6v9M/50xwMNviV4k/doYyXT+zT5tJLPgmP6oAPZipEEyHZjjeRrTsRnULP2Vd1zGUb7fIG8mhvVu6fvZqgDb/TTWKjPbG/u61Z566xW5C4j1kzLrf2ghHEJs2IVm8kXf2bf5x/b/mGFixB+ZE=

References: [EMAIL PROTECTED]
X-Google-Sender-Auth: 13b1a86a963908ff
Return-Path: [EMAIL PROTECTED]
X-OriginalArrivalTime: 08 Jun 2006 07:50:55.0355 (UTC) 
FILETIME=[45AEC4B0:01C68AD0]


On 6/8/06, Graeme McLaren [EMAIL PROTECTED] wrote:

Hi all, this class that I have written lists the contents of a log table
when the $log-view method is invoked.  There is some hardcoded SQL in 
this

method and all I do is pass it a number which then looks up the relevant
records.  This really isn't a reusable class as far as I understand it
because it assumes that anyone else using it would have a log table with
various fields of a certain name defined.  How can I make this completely
reuseable, should it be documented saying that you need to create a log
table with various fields before using it or should I code it so that the
table name and fields have to be passed in and the script would then take
care of it?


Your thoughts and comments are as always - appreciated.


Cheers,

G :)



Interesting. Reusable by who? Is it part of a package you're going to
distribute? is there an included mypkg.sql file they have to run?

Typically, package installs come with a config file where a user can
specify tablename_prefix. so it would be pretty seamless if all they
had to do was edit mypkg.conf and change:
table_prefix = mypkg_

so then log_table would become mypkg_log_table, while columns
would remain the same.
You could have your module simply read the config file inside the
implementation of $log-view();

The table structure(s) should stay the same, but give them a chance to
override the table names incase they collide with pre-existing tables.

I've found this to be the best way to ensure not dropping tables on
accident, especially if you load an sql file with drop table foo if
foo exists. I almost did that at work the other day on a table with 1
character diff in the name (i was lucky, and added dp_ to all my table
namespaces).



--
Anthony Ettinger
Signature: 

Re: OO Perl question

2006-06-08 Thread Anthony Ettinger

On 6/8/06, Graeme McLaren [EMAIL PROTECTED] wrote:

Hi Anthony, good idea about overriding the table names.  I had a feeling
there would be a conf file somewhere.  As I am outputting the results of the
SELECT to an HTML::Template I am already using a Conf file which is another
class.  This leads me on to another question.  If I instantiate my class and
create a Conf object within $log-view then the Conf file won't be loaded
till this method is invoked.  I want to have all the Conf details available
at the same time, I don't want to instantiate the Conf class several times
and hold several copies of the Conf in memory when only one is required.  So
how or where should I instantiate it?



If everything related to the app is encapsulated withing your Log
package, put it in the constructor

package Log;

sub new
{
//create object

$self-init();
}

sub init
{
  open(CONF, $conf) or die can't open config file: $!;
  while(CONF)
  {
next if (m/^#/); #skip comments
my ($option) = $_ =~ s/(.*?)#/; #skip inline comments

my ($key, $val) = split(/\s*=\s*/, $option);
$self-{$key} = $val;
  }
  close(CONF);

  return $self;
}

sub getTablePrefix
{
   my $self = shift;
   return $self-{'table_prefix'};
}


So now when you can print Dumper($self-{'table_prefix'}); and it
should have the value from the config file.

my $log = new Log;
print $log-getTablePrefix();




--
Anthony Ettinger
Signature: http://chovy.dyndns.org/hcard.html

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




Re: OO Perl question

2006-06-08 Thread Anthony Ettinger

my ($option) = $_ =~ s/(.*?)#/; #skip inline comments

should be

m//, not s//



On 6/8/06, Anthony Ettinger [EMAIL PROTECTED] wrote:

On 6/8/06, Graeme McLaren [EMAIL PROTECTED] wrote:
 Hi Anthony, good idea about overriding the table names.  I had a feeling
 there would be a conf file somewhere.  As I am outputting the results of the
 SELECT to an HTML::Template I am already using a Conf file which is another
 class.  This leads me on to another question.  If I instantiate my class and
 create a Conf object within $log-view then the Conf file won't be loaded
 till this method is invoked.  I want to have all the Conf details available
 at the same time, I don't want to instantiate the Conf class several times
 and hold several copies of the Conf in memory when only one is required.  So
 how or where should I instantiate it?


If everything related to the app is encapsulated withing your Log
package, put it in the constructor

package Log;

sub new
{
 //create object

 $self-init();
}

sub init
{
   open(CONF, $conf) or die can't open config file: $!;
   while(CONF)
   {
 next if (m/^#/); #skip comments
 my ($option) = $_ =~ s/(.*?)#/; #skip inline comments

 my ($key, $val) = split(/\s*=\s*/, $option);
 $self-{$key} = $val;
   }
   close(CONF);

   return $self;
}

sub getTablePrefix
{
my $self = shift;
return $self-{'table_prefix'};
}


So now when you can print Dumper($self-{'table_prefix'}); and it
should have the value from the config file.

my $log = new Log;
print $log-getTablePrefix();




--
Anthony Ettinger
Signature: http://chovy.dyndns.org/hcard.html




--
Anthony Ettinger
Signature: http://chovy.dyndns.org/hcard.html

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




Yet another OO question

2006-06-08 Thread Graeme McLaren
Hi all, I've just been reading a bit about accessor get/set methods.  I have 
a method:


sub even{
   my $self = shift;
   my $even   = shift;

   $self-{_even} = $even if defined($even);
   return $self-{_even};
}


This basically does what a get and set method would do.  So why would I need 
a set/get methods?  This value is passed to the object like so:


$object-even('even_value');


This is setting the value here, although I'm sure this isn't the recommended 
way of doing it.  Should objects only have values set when instatiating?


my $object = the_object-new('even_value');


Basically I think I need to clarifiy the difference between an accessor / 
mutator type method and get/set methods, can anyone explain this?



Cheers,

G :)



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




Re: regex to match a range of numbers

2006-06-08 Thread Flemming Greve Skovengaard

Joshua Colson wrote:

On Thu, 2006-06-08 at 00:55 +0200, Flemming Greve Skovengaard wrote:


If you are just going to print the day number and you have other dates in a
similar format why not just use:

print +(split /\s+/, $date)[2];


Well, in this particular instance, I am. However, there have been at
least a few times in the past that I've wanted to achieve the same thing
and it always ends up looking like comic book curse words. Also, I
prefer to validate the input. This example would match even if the third
column weren't digits (more specifically, digits in the range of 1 to
31).

Thanks.



OK, how about this.
This however does not check whether the month can have 31 days.

#!/usr/bin/perl

use strict;
use warnings;

my @dates = (
Wed Jun  7 14:27:38 2006,
Wed Jun 47 14:27:38 2006,
);

foreach my $date ( @dates ) {
my $day_number = ( split /\s+/, $date )[2];
if ( $day_number =~ m/
^(?:
[12]?[1-9]  |   # 1-9, 11-19, 21-29 or
[1-3]0  |   #  10,20,30 or
31  #  31
)$
/x ) {

print $day_number, \n;
# Or whatever you want to do with the day number
}
}


--
Flemming Greve Skovengaard   Just a few small tears between
a.k.a Greven, TuxPower   Someone happy and one sad
[EMAIL PROTECTED]  Just a thin line drawn between
4181.33 BogoMIPS Being a genius or insane


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




Re: Yet another OO question

2006-06-08 Thread Ricardo SIGNES
* Graeme McLaren [EMAIL PROTECTED] [2006-06-08T05:44:05]
 Hi all, I've just been reading a bit about accessor get/set methods.  I 
 have a method:
 
 sub even{
my $self = shift;
my $even   = shift;
 
$self-{_even} = $even if defined($even);
return $self-{_even};
 }
 
 
 This basically does what a get and set method would do.  So why would I 
 need a set/get methods?  This value is passed to the object like so:

It's a question of style, largely.  Some people prefer their code to be
very clear about whether your getting or setting.  Using explicit set and get
methods can also help prevent bugs; you won't accidentally make a read-only
value writeable, because you will avoid writing a set_ro_value method -- if you
only have a get-and-set ro_value method, you might forget to special-case it to
be get-only.

Also, you'd probably avoid bugs like the one you introduced above.  What
happens if I want to clear the even value?

  $obj-even(undef);

This does not affect the value; I can't undef even.

You probably wanted:

  sub even {
my $self = shift;

return $self-{even} unless @_;
return $self-{even} = shift @_;
  }

-- 
rjbs


signature.asc
Description: Digital signature


Two perl installation

2006-06-08 Thread Vijay Kumar Adhikari

Hello, I was running an earlier version of perl and upgraded to the
latest one. Now when I run perl from command line, I get an error like
this

[Thu Jun  8 18:57:18 2006] Importer_mysql.pl: install_driver(mysql)
failed: Can't load
'/usr/local/lib/perl5/site_perl/5.8.8/i686-linux/auto/DBD/mysql/mysql.so'
for module DBD::mysql:
/usr/local/lib/perl5/site_perl/5.8.8/i686-linux/auto/DBD/mysql/mysql.so:
undefined symbol: __builtin_delete at
/usr/local/lib/perl5/5.8.8/i686-linux/DynaLoader.pm line 230.
[Thu Jun  8 18:57:18 2006] Importer_mysql.pl:  at (eval 5) line 3
[Thu Jun  8 18:57:18 2006] Importer_mysql.pl: Compilation failed in
require at (eval 5) line 3.
[Thu Jun  8 18:57:18 2006] Importer_mysql.pl: Perhaps a required
shared library or dll isn't installed where expected
[Thu Jun  8 18:57:18 2006] Importer_mysql.pl:  at Test.pl line 50

How do I fix this problem?

But when I access the same from as a cgi program, it runs fine. I
suspect cgi and command line perl are not the same.

I know command line perl is /usr/local/bin/perl bu issuing this command
[EMAIL PROTECTED] ep]# which perl
/usr/local/bin/perl

Not sure how I check which perl cgi is using. Help.

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




Exec a script on one server that will exec other scripts on a different server..

2006-06-08 Thread William Paulsen \(W\)

Hi,

I'm trying to write a perl script that will run on one server but can
instruct either socker server deamon on another server to exec any one
of three applications on a different box.  The reason for this is the
password changes every month and the scripts that I'm currently using
fails because of that.  Is this possible in perl?

tks
William Paulsen
Guguletu



~~
This e-mail and its contents are subject to the Telkom SA Limited
e-mail legal notice available at
http://www.telkom.co.za/TelkomEMailLegalNotice.PDF
~~

RE: Exec a script on one server that will exec other scripts on a different server..

2006-06-08 Thread Jerry DuVal


-Original Message-
From: William Paulsen (W) [mailto:[EMAIL PROTECTED]
Sent: Thursday, June 08, 2006 8:54 AM
To: beginners@perl.org
Subject: Exec a script on one server that will exec other scripts on a
different server..


Hi,

I'm trying to write a perl script that will run on one server but can
instruct either socker server deamon on another server to exec any one
of three applications on a different box.  The reason for this is the
password changes every month and the scripts that I'm currently using
fails because of that.  Is this possible in perl?


Can you add public/private keys pairs then a password is not needed? 


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




RE: Exec a script on one server that will exec other scripts on a different server..

2006-06-08 Thread William Paulsen \(W\)

Adding it would be an advantage, however right now I just need setup a
client side script that'll tell the server side to exec/run one of
three scripts on the other server. 

tks
William
Gugulethu

-Original Message-
From: Jerry DuVal [mailto:[EMAIL PROTECTED]
Sent: 08 June 2006 03:09 PM
To: William Paulsen (W); beginners@perl.org
Subject: RE: Exec a script on one server that will exec other scripts
on a different server..



-Original Message-
From: William Paulsen (W) [mailto:[EMAIL PROTECTED]
Sent: Thursday, June 08, 2006 8:54 AM
To: beginners@perl.org
Subject: Exec a script on one server that will exec other scripts on
a
different server..


Hi,

I'm trying to write a perl script that will run on one server but can
instruct either socker server deamon on another server to exec any
one
of three applications on a different box.  The reason for this is the
password changes every month and the scripts that I'm currently using
fails because of that.  Is this possible in perl?


Can you add public/private keys pairs then a password is not needed?


~~
This e-mail and its contents are subject to the Telkom SA Limited
e-mail legal notice available at
http://www.telkom.co.za/TelkomEMailLegalNotice.PDF
~~

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




ldif to CSV

2006-06-08 Thread Mihir Kamdar

hi,

I am totally a beginner at perl. I have to write a perl script as following:

I am given a ldif(ldap interchange format) file which contains all the
information about all employees of my organization. I can use ldapsearch to
extract information about one particular employee. I am also given a CSV
file generated from MS Outlook which contains fields like first name,
last name,etc.
For example, In ldif file there is sn which corresponds to last name
in  CSV file.
I have to write a perl script that takes the fields that correspond to the
Outlook CSV file and discard others, map them to the corresponding fields in
the CSV file and direct the output to a CSV file which can be loaded to
Outlook.
Lets say the Outlook CSV file has the first and second field which does not
correspond to any fields in ldif file, then my output file should have those
two empty spaces seperated by comma or semicolon.

I actually have to seperate the fields with semi-colon as fields like
address already have commas which can clash with the comma-seperated values.

I shall be extremely grateful if anybody can suggest a solution to this.

Regards,
Mihir


Re: Two perl installation

2006-06-08 Thread sfantar

Vijay Kumar Adhikari a écrit :

Hello, I was running an earlier version of perl and upgraded to the
latest one. Now when I run perl from command line, I get an error like
this

[Thu Jun  8 18:57:18 2006] Importer_mysql.pl: install_driver(mysql)
failed: Can't load
'/usr/local/lib/perl5/site_perl/5.8.8/i686-linux/auto/DBD/mysql/mysql.so'
for module DBD::mysql:
/usr/local/lib/perl5/site_perl/5.8.8/i686-linux/auto/DBD/mysql/mysql.so:
undefined symbol: __builtin_delete at
/usr/local/lib/perl5/5.8.8/i686-linux/DynaLoader.pm line 230.
[Thu Jun  8 18:57:18 2006] Importer_mysql.pl:  at (eval 5) line 3
[Thu Jun  8 18:57:18 2006] Importer_mysql.pl: Compilation failed in
require at (eval 5) line 3.
[Thu Jun  8 18:57:18 2006] Importer_mysql.pl: Perhaps a required
shared library or dll isn't installed where expected
[Thu Jun  8 18:57:18 2006] Importer_mysql.pl:  at Test.pl line 50

How do I fix this problem?

But when I access the same from as a cgi program, it runs fine. I
suspect cgi and command line perl are not the same.

I know command line perl is /usr/local/bin/perl bu issuing this command
[EMAIL PROTECTED] ep]# which perl
/usr/local/bin/perl

Not sure how I check which perl cgi is using. Help.


Are you running Apache as well? I suppose yes. Which version?
You have to tell Apache where the new modules installed are.
Check this out :

http://perl.apache.org/docs/2.0/user/config/config.html#C_PerlRequire_

On this page, you will find how to tell Apache to load modules whose 
directories are not in the @INC.


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




Re: Two perl installation

2006-06-08 Thread Vijay Kumar Adhikari

Thanks, but I am not using mod_perl.

The problem is twofold. It works well when accessed from CGI. It
doesn't complain anything at all. When run in command line, it
generates that error.

My questions are: 1) How do I know which perl executable CGI is
running and 2) How do I fix that error with DBD::Mysql

On 6/8/06, sfantar [EMAIL PROTECTED] wrote:

Vijay Kumar Adhikari a écrit :
 Hello, I was running an earlier version of perl and upgraded to the
 latest one. Now when I run perl from command line, I get an error like
 this

 [Thu Jun  8 18:57:18 2006] Importer_mysql.pl: install_driver(mysql)
 failed: Can't load
 '/usr/local/lib/perl5/site_perl/5.8.8/i686-linux/auto/DBD/mysql/mysql.so'
 for module DBD::mysql:
 /usr/local/lib/perl5/site_perl/5.8.8/i686-linux/auto/DBD/mysql/mysql.so:
 undefined symbol: __builtin_delete at
 /usr/local/lib/perl5/5.8.8/i686-linux/DynaLoader.pm line 230.
 [Thu Jun  8 18:57:18 2006] Importer_mysql.pl:  at (eval 5) line 3
 [Thu Jun  8 18:57:18 2006] Importer_mysql.pl: Compilation failed in
 require at (eval 5) line 3.
 [Thu Jun  8 18:57:18 2006] Importer_mysql.pl: Perhaps a required
 shared library or dll isn't installed where expected
 [Thu Jun  8 18:57:18 2006] Importer_mysql.pl:  at Test.pl line 50

 How do I fix this problem?

 But when I access the same from as a cgi program, it runs fine. I
 suspect cgi and command line perl are not the same.

 I know command line perl is /usr/local/bin/perl bu issuing this command
 [EMAIL PROTECTED] ep]# which perl
 /usr/local/bin/perl

 Not sure how I check which perl cgi is using. Help.

Are you running Apache as well? I suppose yes. Which version?
You have to tell Apache where the new modules installed are.
Check this out :

http://perl.apache.org/docs/2.0/user/config/config.html#C_PerlRequire_

On this page, you will find how to tell Apache to load modules whose
directories are not in the @INC.

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






--
Vijay

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




RE: Exec a script on one server that will exec other scripts on a different server..

2006-06-08 Thread Jerry DuVal
Adding it would be an advantage, however right now I just need setup a
client side script that'll tell the server side to exec/run one of
three scripts on the other server.

We have a similar situation.  One thing we did on the boxes we could not add
the key pairs was add a cron that ran a script every 3 mins.  The client
script would contact the server via HTTP Get and it would get a XML doc of
commands it needed to run.  The client would run the command and HTTP Post
the results back to the server. This way we did not need any key pairs, user
names, or passwords.  

-Original Message-
From: William Paulsen (W) [mailto:[EMAIL PROTECTED]
Sent: Thursday, June 08, 2006 9:31 AM
To: Jerry DuVal; beginners@perl.org
Subject: RE: Exec a script on one server that will exec other scripts on a
different server..


Adding it would be an advantage, however right now I just need setup a
client side script that'll tell the server side to exec/run one of
three scripts on the other server.


tks
William
Gugulethu

-Original Message-
From: Jerry DuVal [mailto:[EMAIL PROTECTED]

Sent: 08 June 2006 03:09 PM
To: William Paulsen (W); beginners@perl.org
Subject: RE: Exec a script on one server that will exec other scripts
on a different server..



-Original Message-
From: William Paulsen (W) [mailto:[EMAIL PROTECTED]
Sent: Thursday, June 08, 2006 8:54 AM
To: beginners@perl.org
Subject: Exec a script on one server that will exec other scripts on
a
different server..


Hi,

I'm trying to write a perl script that will run on one server but can
instruct either socker server deamon on another server to exec any
one
of three applications on a different box.  The reason for this is the
password changes every month and the scripts that I'm currently using
fails because of that.  Is this possible in perl?


Can you add public/private keys pairs then a password is not needed?



~~
This e-mail and its contents are subject to the Telkom SA Limited
e-mail legal notice available at

http://www.telkom.co.za/TelkomEMailLegalNotice.PDF
~~

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



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




Re: Two perl installation

2006-06-08 Thread sfantar

Vijay Kumar Adhikari a écrit :

Thanks, but I am not using mod_perl.

The problem is twofold. It works well when accessed from CGI. It
doesn't complain anything at all. When run in command line, it
generates that error.

My questions are: 1) How do I know which perl executable CGI is
running and 2) How do I fix that error with DBD::Mysql

On 6/8/06, sfantar [EMAIL PROTECTED] wrote:

Vijay Kumar Adhikari a écrit :
 Hello, I was running an earlier version of perl and upgraded to the
 latest one. Now when I run perl from command line, I get an error like
 this

 [Thu Jun  8 18:57:18 2006] Importer_mysql.pl: install_driver(mysql)
 failed: Can't load
 
'/usr/local/lib/perl5/site_perl/5.8.8/i686-linux/auto/DBD/mysql/mysql.so'

 for module DBD::mysql:
 
/usr/local/lib/perl5/site_perl/5.8.8/i686-linux/auto/DBD/mysql/mysql.so:

 undefined symbol: __builtin_delete at
 /usr/local/lib/perl5/5.8.8/i686-linux/DynaLoader.pm line 230.
 [Thu Jun  8 18:57:18 2006] Importer_mysql.pl:  at (eval 5) line 3
 [Thu Jun  8 18:57:18 2006] Importer_mysql.pl: Compilation failed in
 require at (eval 5) line 3.
 [Thu Jun  8 18:57:18 2006] Importer_mysql.pl: Perhaps a required
 shared library or dll isn't installed where expected
 [Thu Jun  8 18:57:18 2006] Importer_mysql.pl:  at Test.pl line 50

 How do I fix this problem?

 But when I access the same from as a cgi program, it runs fine. I
 suspect cgi and command line perl are not the same.

 I know command line perl is /usr/local/bin/perl bu issuing this command
 [EMAIL PROTECTED] ep]# which perl
 /usr/local/bin/perl

 Not sure how I check which perl cgi is using. Help.

Are you running Apache as well? I suppose yes. Which version?
You have to tell Apache where the new modules installed are.
Check this out :

http://perl.apache.org/docs/2.0/user/config/config.html#C_PerlRequire_

On this page, you will find how to tell Apache to load modules whose
directories are not in the @INC.

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





Sorry I thought you were running mod_perl.
On which platform are you running Perl?
You can tell at the beginning of your perl script where your new 
installed perl libs are by using use lib where_your_lib_is






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




Re: Two perl installation

2006-06-08 Thread Vijay Kumar Adhikari

FC3

On 6/8/06, sfantar [EMAIL PROTECTED] wrote:

Vijay Kumar Adhikari a écrit :
 Thanks, but I am not using mod_perl.

 The problem is twofold. It works well when accessed from CGI. It
 doesn't complain anything at all. When run in command line, it
 generates that error.

 My questions are: 1) How do I know which perl executable CGI is
 running and 2) How do I fix that error with DBD::Mysql

 On 6/8/06, sfantar [EMAIL PROTECTED] wrote:
 Vijay Kumar Adhikari a écrit :
  Hello, I was running an earlier version of perl and upgraded to the
  latest one. Now when I run perl from command line, I get an error like
  this
 
  [Thu Jun  8 18:57:18 2006] Importer_mysql.pl: install_driver(mysql)
  failed: Can't load
 
 '/usr/local/lib/perl5/site_perl/5.8.8/i686-linux/auto/DBD/mysql/mysql.so'
  for module DBD::mysql:
 
 /usr/local/lib/perl5/site_perl/5.8.8/i686-linux/auto/DBD/mysql/mysql.so:
  undefined symbol: __builtin_delete at
  /usr/local/lib/perl5/5.8.8/i686-linux/DynaLoader.pm line 230.
  [Thu Jun  8 18:57:18 2006] Importer_mysql.pl:  at (eval 5) line 3
  [Thu Jun  8 18:57:18 2006] Importer_mysql.pl: Compilation failed in
  require at (eval 5) line 3.
  [Thu Jun  8 18:57:18 2006] Importer_mysql.pl: Perhaps a required
  shared library or dll isn't installed where expected
  [Thu Jun  8 18:57:18 2006] Importer_mysql.pl:  at Test.pl line 50
 
  How do I fix this problem?
 
  But when I access the same from as a cgi program, it runs fine. I
  suspect cgi and command line perl are not the same.
 
  I know command line perl is /usr/local/bin/perl bu issuing this command
  [EMAIL PROTECTED] ep]# which perl
  /usr/local/bin/perl
 
  Not sure how I check which perl cgi is using. Help.
 
 Are you running Apache as well? I suppose yes. Which version?
 You have to tell Apache where the new modules installed are.
 Check this out :

 http://perl.apache.org/docs/2.0/user/config/config.html#C_PerlRequire_

 On this page, you will find how to tell Apache to load modules whose
 directories are not in the @INC.

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




Sorry I thought you were running mod_perl.
On which platform are you running Perl?
You can tell at the beginning of your perl script where your new
installed perl libs are by using use lib where_your_lib_is





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






--
Vijay

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




parsing a CSV file with more fields than column names

2006-06-08 Thread RICHARD FERNANDEZ
Hello All,

I'm just trying to get some ideas for the best way to approach this...

I have a CSV file whose first line is a header. According to this header
there should be 17 values per line. Unfortunately this is not the case.
It seems that the first 16 header values match up with the first 16
values in each line, but for the 17th header item, there may be 1 or
more comma separated values associated with it! Here is a sample line
with header:

Num,Env Num,Envelope,Transaction,Lockbox,Date,Time,Batch,Batch
Item,Check,Check Amount,ABA/RT,Account Num,Check Num,Check
Image,Envelope Image,Page Images

1,1,G-999,G-999,SFC-99,2006/06/01,11:00,999,9,9,$.99,999
99,,99,9,9,23,24,25,26,27 


As you can see the 17th value is 23, but really there are 5 values
associated with Page Images, 23-27.

I've been playing with Tie::Handle::CSV, but I don't see a way to have
it pick up more that one value per hash key. What I need is a way to
specify all remaining values a la split, perhaps with an array ref.

Maybe Tie::Handle::CSV isn't the best choice? 

Any thoughts are appreciated.

TIA

richf

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




Re: How to create a new browser window using CGI

2006-06-08 Thread Prabu Ayyappan

On 6/8/06, chen li [EMAIL PROTECTED] wrote:


Dear all,

How can I add a line (lines) to the following script
so that I can show the results on a new browser window
after I press the submit button?

Thanks,

Li


#!c:/Perl/bin/perl.exe
use warnings;
use strict;
use CGI;

my $query_obj=CGI-new();

#creat webpage
print $query_obj-header;
print $query_obj-start_html('My First Webpage');

print $query_obj-start_form;
print $query_obj-p;

print What is your name
,$query_obj-textfield(-name='text_field',
-value='');

print $query_obj-p;
my @major=qw( English Biology Immunology );
print  What is your major
,$query_obj-popup_menu(-name='menu_name',-value=[EMAIL PROTECTED]);



print $query_obj-p,$query_obj-submit;
print $query_obj-end_form;

print $query_obj-end_html;
#capture the data

my $name=($query_obj-param('text_field') or '');
print $query_obj-p,This is your name $name,
\n\n;

print $query_obj-p;
my $major=($query_obj-param('menu_name') or '');
print This is your major $major ;

exit;



Hello ,

Hope this work.

#!c:/Perl/bin/perl.exe
use warnings;
use strict;
use CGI;

my $query_obj=CGI-new();

#creat webpage
print $query_obj-header;
print $query_obj-start_html('My First Webpage');
if (!$query_obj-param){
   print $query_obj-start_form(-target='_new');
   print $query_obj-p;
   print What is your name
,$query_obj-textfield(-name='text_field',-value='');
   print $query_obj-p;
   my @major=qw( English Biology Immunology );
   print  What is your major
,$query_obj-popup_menu(-name='menu_name',-value=[EMAIL PROTECTED]);
   print $query_obj-p,$query_obj-submit;
   print $query_obj-end_form;
}
else{
my $name=($query_obj-param('text_field') or '');
print $query_obj-p,This is your name $name,\n\n;

print $query_obj-p;
my $major=($query_obj-param('menu_name') or '');
print This is your major $major ;
}
print $query_obj-end_html;

exit;


--
Prabu M A


Re: Two perl installation

2006-06-08 Thread Tom Phoenix

On 6/8/06, Vijay Kumar Adhikari [EMAIL PROTECTED] wrote:


How do I know which perl executable CGI is
running


If your sysadmin won't tell you, upgrade your sysadmin. :-)

But you can use Inside to tell you about your CGI configuration,
including which perl binary runs it:

   http://search.cpan.org/~phoenix/Inside-1.01/

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/ http://learn.perl.org/first-response




How to match a directory path?

2006-06-08 Thread sfantar

Hello everybody

As the path to a directory under Linux is like /file/file/file where 
file can be a word containing either - or _ .

Which regexp can match this in the best way?
I tried (/\w[-]?\w/)+ but it doesn't work well.

Thanks in advance.

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




Pattern Matching

2006-06-08 Thread anu p
Hi,

I have the following code snippet in which I open two
files for read. 

For each line in file 1 (log.txt), I extract the test
name, which is of format dir/file which is my
pattern and search for the line with same pattern in
file 2 (rg_table.txt). Somehow it's not working.


open (TST_IN, rg_table.txt) || die Cannot open for
read $!\n;  

open (FIN, log.txt) || die Cannot open file for
read $!\n;  
while (FIN) {
   next if !(/Config/i);
   @log_row = split(/\s+/, $_);
   print([EMAIL PROTECTED] = @log_row\n);
   $test_case = $log_row[3];
   
   while (TST_IN) {
if (m{\Q($test_case)\E}) {  //once again,
the test_case if of form dir/file 
   $row = $_;
}
print(\$row = $row, \$test_case =
$test_case\n);
  }
  .

I see that $row variable is not being updated
properly.
I am not sure if it is because of nested file opens
and using $_ or bad pattern matching.

Thanks in advance for any input.

Anu.

__
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/ http://learn.perl.org/first-response




FW: Exec a script on one server that will exec other scripts on a different server..

2006-06-08 Thread William Paulsen \(W\)





From: William Paulsen (W)
Sent: Thu 2006-06-08 14:54
To: beginners@perl.org
Subject: Exec a script on one server that will exec other scripts on a
different server..



Hi,

I'm trying to write a perl script that will run on one server but can
instruct either socker server deamon on another server to exec any one
of three applications on a different box.  The reason for this is the
password changes every month and the scripts that I'm currently using
fails because of that.  Is this possible in perl?

tks

William Paulsen

Guguletu



~~
This e-mail and its contents are subject to the Telkom SA Limited
e-mail legal notice available at
http://www.telkom.co.za/TelkomEMailLegalNotice.PDF
~~

Re: How to match a directory path?

2006-06-08 Thread Dr.Ruud
sfantar schreef:

 As the path to a directory under Linux is like /file/file/file where
 file can be a word containing either - or _ .
 Which regexp can match this in the best way?
 I tried (/\w[-]?\w/)+ but it doesn't work well.

You have two slashes in there, as if you want to match

 /file//file//file

Further, almost any character can be part of a filename.

  m{ \A  # From start-of-buffer,
   (?:   # start a non-capturing group
  /  # that begins with a slash
  [^/]+  # which is followed by 1 or more
 #   non-slash characters.
   )+# Match 1 or more groups
 \z  # until end-of-buffer.
   }x


To capture the matched string in $1:

  m{ \A   # From start-of-buffer,
   (  # start-of-capturing
(?:   # start a non-capturing group
   /  # that begins with a slash
   [^/]+  # which is followed by 1 or more
  #   non-slash characters.
)+# Match 1 or more groups
   )  # end-of-capturing
 \z   # until end-of-buffer.
   }x


See also Regexp::Common.
http://search.cpan.org/search?module=Regexp::Common

-- 
Affijn, Ruud

Gewoon is een tijger.



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




Re: Exec a script on one server that will exec other scripts on a different server..

2006-06-08 Thread Chad Perrin
On Thu, Jun 08, 2006 at 02:54:06PM +0200, William Paulsen (W) wrote:
 
 I'm trying to write a perl script that will run on one server but can
 instruct either socker server deamon on another server to exec any one
 of three applications on a different box.  The reason for this is the
 password changes every month and the scripts that I'm currently using
 fails because of that.  Is this possible in perl?

Yes, it's possible.  I'm sure it's also possible in Haskell, OCaml, 
Java, VB.NET, and Logo.  What exactly is it that you're having trouble 
doing?  Is it the client script that you're having trouble writing or 
the server that accepts commands from the client?  If the server, is it
accepting input from the client or executing applications that is the 
problem?  If the client, is it network connectivity or interfacing with
the server?  Is it more than one of the above?  Is it something else 
entirely?

I'm afraid your question isn't very clear.  I don't even know if I have
the information you actually want -- unless the yes answer to your 
yes or no question above is the answer you want.

-- 
CCD CopyWrite Chad Perrin [ http://ccd.apotheon.org ]
Real ugliness is not harsh-looking syntax, but having to
build programs out of the wrong concepts. - Paul Graham

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




Re: How to match a directory path?

2006-06-08 Thread sfantar

sfantar a écrit :

Hello everybody

As the path to a directory under Linux is like /file/file/file where 
file can be a word containing either - or _ .

Which regexp can match this in the best way?
I tried (/\w[-]?\w/)+ but it doesn't work well.

Thanks in advance.


Could this be a solution : http://www.perlmonks.org/?node_id=511069 ?
In this example, it is told that if a path contains a \x00, then under 
Linux the path is no correct.

Is that enough to check the spelling of a path?

Thanks in advance.

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




Re: Yet another OO question

2006-06-08 Thread Anthony Ettinger

On 6/8/06, Ricardo SIGNES [EMAIL PROTECTED] wrote:

* Graeme McLaren [EMAIL PROTECTED] [2006-06-08T05:44:05]
 Hi all, I've just been reading a bit about accessor get/set methods.  I
 have a method:

 sub even{
my $self = shift;
my $even   = shift;

$self-{_even} = $even if defined($even);
return $self-{_even};
 }


 This basically does what a get and set method would do.  So why would I
 need a set/get methods?  This value is passed to the object like so:

It's a question of style, largely.  Some people prefer their code to be
very clear about whether your getting or setting.  Using explicit set and get
methods can also help prevent bugs; you won't accidentally make a read-only
value writeable, because you will avoid writing a set_ro_value method -- if you
only have a get-and-set ro_value method, you might forget to special-case it to
be get-only.

Also, you'd probably avoid bugs like the one you introduced above.  What
happens if I want to clear the even value?

  $obj-even(undef);

This does not affect the value; I can't undef even.

You probably wanted:

  sub even {
my $self = shift;

return $self-{even} unless @_;
return $self-{even} = shift @_;
  }

--
rjbs


-BEGIN PGP SIGNATURE-
Version: GnuPG v1.4.2 (GNU/Linux)

iD8DBQFEiBrL5IEwYcR13KMRAnUiAJ9jORCdmqcxxvJSLnzfg2B0BXJdMACZAU3v
H8WkVST4w7lrACbWr2hdtLY=
=7rTT
-END PGP SIGNATURE-





i prefer the return once method:

sub foo
{
   my $self = shift;
   if (@_ == 1) { $self-{'foo'} = shift; }

   return $self-{'foo'};
}

--
Anthony Ettinger
Signature: http://chovy.dyndns.org/hcard.html

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




Re: Pattern Matching

2006-06-08 Thread anu p
Hi,

  Sorry, it was working, found out the problem was due
to something else.

Thanks,
Anu.

  
--- anu p [EMAIL PROTECTED] wrote:

 Hi,
 
 I have the following code snippet in which I open
 two
 files for read. 
 
 For each line in file 1 (log.txt), I extract the
 test
 name, which is of format dir/file which is my
 pattern and search for the line with same pattern in
 file 2 (rg_table.txt). Somehow it's not working.
 
 
 open (TST_IN, rg_table.txt) || die Cannot open
 for
 read $!\n;  
 
 open (FIN, log.txt) || die Cannot open file for
 read $!\n;  
 while (FIN) {
next if !(/Config/i);
@log_row = split(/\s+/, $_);
print([EMAIL PROTECTED] = @log_row\n);
$test_case = $log_row[3];

while (TST_IN) {
 if (m{\Q($test_case)\E}) {  //once
 again,
 the test_case if of form dir/file 
$row = $_;
 }
 print(\$row = $row, \$test_case =
 $test_case\n);
   }
   .
 
 I see that $row variable is not being updated
 properly.
 I am not sure if it is because of nested file opens
 and using $_ or bad pattern matching.
 
 Thanks in advance for any input.
 
 Anu.
 
 __
 Do You Yahoo!?
 Tired of spam?  Yahoo! Mail has the best spam
 protection around 
 http://mail.yahoo.com 
 


__
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/ http://learn.perl.org/first-response




Re: Yet another OO question

2006-06-08 Thread Mr. Shawn H. Corey
On Thu, 2006-08-06 at 10:56 -0700, Anthony Ettinger wrote:
 i prefer the return once method:
 
 sub foo
 {
 my $self = shift;
 if (@_ == 1) { $self-{'foo'} = shift; }
 
 return $self-{'foo'};
 }

I would prefer it to return the old value:

sub foo {
  my $self = shift;
  my $old_foo = $self-{'foo'};
  $self-{'foo'} = shift if @_  0;
  return $old_foo;
}


-- 
__END__

Just my 0.0002 million dollars worth,
   --- Shawn

For the things we have to learn before we can do them, we learn by doing them.
  Aristotle

* Perl tutorials at http://perlmonks.org/?node=Tutorials
* A searchable perldoc is at http://perldoc.perl.org/



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




Re: parsing a CSV file with more fields than column names

2006-06-08 Thread Chris Charley


- Original Message - 
From: RICHARD FERNANDEZ [EMAIL PROTECTED]

Newsgroups: perl.beginners
To: beginners@perl.org
Sent: Thursday, June 08, 2006 11:17 AM
Subject: parsing a CSV file with more fields than column names


Hello All,

I'm just trying to get some ideas for the best way to approach this...

I have a CSV file whose first line is a header. According to this header
there should be 17 values per line. Unfortunately this is not the case.
It seems that the first 16 header values match up with the first 16
values in each line, but for the 17th header item, there may be 1 or
more comma separated values associated with it! Here is a sample line
with header:

Num,Env Num,Envelope,Transaction,Lockbox,Date,Time,Batch,Batch
Item,Check,Check Amount,ABA/RT,Account Num,Check Num,Check
Image,Envelope Image,Page Images

1,1,G-999,G-999,SFC-99,2006/06/01,11:00,999,9,9,$.99,999
99,,99,9,9,23,24,25,26,27 



As you can see the 17th value is 23, but really there are 5 values
associated with Page Images, 23-27.

I've been playing with Tie::Handle::CSV, but I don't see a way to have
it pick up more that one value per hash key. What I need is a way to
specify all remaining values a la split, perhaps with an array ref.

Maybe Tie::Handle::CSV isn't the best choice? 


Any thoughts are appreciated.

TIA

richf

Hello Rich

See docs for perlfunc, specifically split.

Especially, the form for split
   'split /PATTERN/,EXPR,LIMIT'

By setting the limit, you will be able to solve the problem.

Chris


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




Re: Yet another OO question

2006-06-08 Thread Anthony Ettinger

On 6/8/06, Mr. Shawn H. Corey [EMAIL PROTECTED] wrote:

On Thu, 2006-08-06 at 10:56 -0700, Anthony Ettinger wrote:
 i prefer the return once method:

 sub foo
 {
 my $self = shift;
 if (@_ == 1) { $self-{'foo'} = shift; }

 return $self-{'foo'};
 }

I would prefer it to return the old value:

sub foo {
  my $self = shift;
  my $old_foo = $self-{'foo'};
  $self-{'foo'} = shift if @_  0;
  return $old_foo;
}


--
__END__

Just my 0.0002 million dollars worth,
   --- Shawn



If you set a new value, why would you want your client to still be
using the old value?



--
Anthony Ettinger
Signature: http://chovy.dyndns.org/hcard.html

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




modifying @INC permanently

2006-06-08 Thread Anthony Ettinger

Is there a way to modify @INC for the perl installation as a whole?

All my scripts have logic to push the same directory to @INC. It's
rather repetative.

I know I can export PERL_LIB environment variable, but I need
something for all system users (including win32).



--
Anthony Ettinger
Signature: http://chovy.dyndns.org/hcard.html

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




RE: parsing a CSV file with more fields than column names

2006-06-08 Thread Timothy Johnson

As long as you're sure that there aren't any commas in your data, you
could always do this:

my @records = split(/,/,$line,17);

This will limit your total records to 17, and will dump the rest into
the 17th record.  Then you can split the last record again if you want.

If you have some commas in your data then you might have to adjust your
logic to include records that look like this:

1,1,G-999,G-999,SFC-99,2006/06/01,11:00,999,9,9,$.99,9
99
99,999,999,999,999,99,9,9,23,24,25,26,27


-Original Message-
From: RICHARD FERNANDEZ [mailto:[EMAIL PROTECTED] 
Sent: Thursday, June 08, 2006 8:18 AM
To: beginners@perl.org
Subject: parsing a CSV file with more fields than column names

Hello All,

I'm just trying to get some ideas for the best way to approach this...

I have a CSV file whose first line is a header. According to this header
there should be 17 values per line. Unfortunately this is not the case.
It seems that the first 16 header values match up with the first 16
values in each line, but for the 17th header item, there may be 1 or
more comma separated values associated with it! Here is a sample line
with header:

Num,Env Num,Envelope,Transaction,Lockbox,Date,Time,Batch,Batch
Item,Check,Check Amount,ABA/RT,Account Num,Check Num,Check
Image,Envelope Image,Page Images

1,1,G-999,G-999,SFC-99,2006/06/01,11:00,999,9,9,$.99,999
99,,99,9,9,23,24,25,26,27 


As you can see the 17th value is 23, but really there are 5 values
associated with Page Images, 23-27.

I've been playing with Tie::Handle::CSV, but I don't see a way to have
it pick up more that one value per hash key. What I need is a way to
specify all remaining values a la split, perhaps with an array ref.

Maybe Tie::Handle::CSV isn't the best choice? 

Any thoughts are appreciated.

TIA

richf

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




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




Re: How to create a new browser window using CGI

2006-06-08 Thread chen li

 Hello ,
 
 Hope this work.
 
 #!c:/Perl/bin/perl.exe
 use warnings;
 use strict;
 use CGI;
 
 my $query_obj=CGI-new();
 
 #creat webpage
 print $query_obj-header;
 print $query_obj-start_html('My First Webpage');
 if (!$query_obj-param){
 print
 $query_obj-start_form(-target='_new');
 print $query_obj-p;
 print What is your name

,$query_obj-textfield(-name='text_field',-value='');
 print $query_obj-p;
 my @major=qw( English Biology Immunology );
 print  What is your major

,$query_obj-popup_menu(-name='menu_name',-value=[EMAIL PROTECTED]);
 print $query_obj-p,$query_obj-submit;
 print $query_obj-end_form;
 }
 else{
 my $name=($query_obj-param('text_field') or '');
 print $query_obj-p,This is your name
 $name,\n\n;
 
 print $query_obj-p;
 my $major=($query_obj-param('menu_name') or '');
 print This is your major $major ;
 }
 print $query_obj-end_html;
 
 exit;
 
 
 --
 Prabu M A
 


Thanks Prabu. But I am just curious how to find out
the parameters that start_form method and others  will
take. When I read the CGI.pm discription I see nowhere
in the POD talking about the details of parameters
that each method will take(just a little bit). Can you
point out how you get this kind of information?


Once again thank you very much,

Li

__
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/ http://learn.perl.org/first-response




RE: modifying @INC permanently

2006-06-08 Thread Timothy Johnson

Win32 changes to the environment from within your script won't be
permanent, so that won't work unless you do the system call that sets
the environment variable permanently (and also the local one, because it
won't reflect the changes to the system call until it is invoked again).

Do you have the ability to install modules on your clients?  The
SetEnvVar function from Win32::AdminMisc will do what you want.

http://www.roth.net/perl/adminmisc/#SetEnvVar

You can install it via PPM from the repository
http://www.roth.net/perl/packages.


Really, though, I think I remember that it's better to 'use lib' than
change @INC.  Someone here might be better able to explain why.



-Original Message-
From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED] On Behalf Of
Anthony Ettinger
Sent: Thursday, June 08, 2006 1:40 PM
To: Perl Beginners
Subject: modifying @INC permanently

Is there a way to modify @INC for the perl installation as a whole?

All my scripts have logic to push the same directory to @INC. It's
rather repetative.

I know I can export PERL_LIB environment variable, but I need
something for all system users (including win32).



-- 
Anthony Ettinger
Signature: http://chovy.dyndns.org/hcard.html

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




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




Re: Yet another OO question

2006-06-08 Thread Lawrence Statton
  I would prefer it to return the old value:
 
  sub foo {
my $self = shift;
my $old_foo = $self-{'foo'};
$self-{'foo'} = shift if @_  0;
return $old_foo;
  }
 
 
 
 If you set a new value, why would you want your client to still be
 using the old value?

Because you may need to put the old value back.  It's more of a
philosophical question.  What should the mutator return? 

The Object Purist says, Nothing -- it should be declared void.

Another school says, It should return the value you just set it to.
I think is useless -- it's a tautology.  You KNOW what value you just
set it to.

Yet another thought is The previous value -- that is at least
something you didn't know going INTO the call - so it does increase
the total knowledge of your program.

My hitherto prefered answer is It should return the object.  Only
because I (used to) like to chain method calls.  I've since lost this
bad habit.

$fruit-name('apple')-color('red')-texture('crunchy');

So, I am now wavering between the 'previous value' and 'nothing'
options.  

-- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- 
Lawrence Statton - [EMAIL PROTECTED] s/aba/c/g
Computer  software  consists of  only  two  components: ones  and
zeros, in roughly equal proportions.   All that is required is to
sort them into the correct order.



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




Re: modifying @INC permanently

2006-06-08 Thread Lawrence Statton
 Is there a way to modify @INC for the perl installation as a whole?

Yes.  Recompile Perl setting the appropriate compile-time flags.  More
importantly, though: Why?  It is just easier to install your modules
in the standardly defined place for site-specific modules.

 
 All my scripts have logic to push the same directory to @INC. It's
 rather repetative.
 

You do not need logic to do that.  It would seem better to use:

  use lib '/path/to/my/misplaced/perl-modules'; 

-- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- 
Lawrence Statton - [EMAIL PROTECTED] s/aba/c/g
Computer  software  consists of  only  two  components: ones  and
zeros, in roughly equal proportions.   All that is required is to
sort them into the correct order.

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




RE: parsing a CSV file with more fields than column names

2006-06-08 Thread RICHARD FERNANDEZ
 Hello Rich

Hi, Chris, thanks for your response


 
 See docs for perlfunc, specifically split.
 
 Especially, the form for split
 'split /PATTERN/,EXPR,LIMIT'
 
 By setting the limit, you will be able to solve the problem.
 
 Chris
 

The thing is I can't be sure that there will never be embedded commas in
the data (well maybe I can with this particular set of data, not sure),
so split (as discussed in the Cookbook) isn't the way to go. This is why
I was looking to use a specialized module for the job. Also, I need to
be able to address several of the fields specifically, to change their
values, so I like the idea of using a hash which is done for me with
something like Tie::Handle::CSV.

What I've come up with is this:

code
#!/usr/bin/perl -w
use strict;
use Tie::Handle::CSV;

my $file = shift or die You forgot to provide the name of a CSV
file\n;
my $csv_fh = Tie::Handle::CSV-new(file = $file, header = 0);

my %csv_headers = (
   0 = 'Num',
   1 = 'Env Num',
   2 = 'Envelope', 
   3 = 'Transaction',
   4 = 'Lockbox',
   5 = 'Date',
   6 = 'Time', 
   7 = 'Batch',
   8 = 'Batch Item',
   9 = 'Check',
   10 = 'Check Amount', 
   11 = 'ABA/RT',
   12 = 'Account Num',
   13 = 'Check Num',
   14 = 'Check Image', 
   15 = 'Envelope Image',
   16 = 'Page Images'  
);   


my %csv_hash;
while (my $csv_line = $csv_fh) {
   next if ($.  4 );

   for my $index (0..15) {
  $csv_hash{ $csv_headers{$index} } = $csv_line - [$index];
   }

   # The values that remain in @{$csv_line} are all associated with
Page Images, so
   # we need to build an array to pass as a hash value...
   $csv_hash{'Page Images'} = [];
   for my $index (16..$#{$csv_line}) {
  push @{ $csv_hash{'Page Images'} }, $csv_line - [$index];
   }

   for (sort keys %csv_hash) {
  if ( !ref $csv_hash{$_}  ) { # If the value is not a (array) ref
 print $_,  = , $csv_hash{$_}, \n;
  } else {
 print $_,  = \n;

 for ( @{ $csv_hash{$_} } ) {
print \n\t, $_;
 }
 print \n\n;
  }
   }
   print \n\n\n;
   print '*' x 20, \n;
}

/code

Which does what I want, but it seems like there should be an easier
way...

richf


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




RE: parsing a CSV file with more fields than column names

2006-06-08 Thread Timothy Johnson


-Original Message-
From: RICHARD FERNANDEZ [mailto:[EMAIL PROTECTED] 
Sent: Thursday, June 08, 2006 2:04 PM
To: beginners@perl.org
Subject: RE: parsing a CSV file with more fields than column names

  Hello Rich

 Hi, Chris, thanks for your response


 
 See docs for perlfunc, specifically split.
 
 Especially, the form for split
 'split /PATTERN/,EXPR,LIMIT'
 
 By setting the limit, you will be able to solve the problem.
 
 Chris
 

 The thing is I can't be sure that there will never be embedded commas
in
 the data (well maybe I can with this particular set of data, not
sure),
 so split (as discussed in the Cookbook) isn't the way to go. This is
why
 I was looking to use a specialized module for the job. Also, I need to
 be able to address several of the fields specifically, to change their
 values, so I like the idea of using a hash which is done for me with
 something like Tie::Handle::CSV.

 snip

If the data is as you showed, with no quotations around fields that
contain commas, then you're screwed, unless you're talking about the
last field only, in which case the split will work.  If there may be
commas inside of a comma-delimited output line then you will need some
way to differentiate between a field that has a comma and one that
doesn't.  Are you SURE that there might be commas in the other fields?
I would hope that whoever made this file you're parsing would have
thought of this if they ever intended to later use the data.


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




Re: modifying @INC permanently

2006-06-08 Thread Chad Perrin
On Thu, Jun 08, 2006 at 01:59:46PM -0700, Lawrence Statton wrote:
  Is there a way to modify @INC for the perl installation as a whole?
 
 Yes.  Recompile Perl setting the appropriate compile-time flags.  More
 importantly, though: Why?  It is just easier to install your modules
 in the standardly defined place for site-specific modules.

Why:  I find that often remote servers (such as webhosting account
servers) that are not under one's sole control lack modules the
programmer wants, and cannot have them added in the standard path for
@INC.  This can cause problems when someone wants to use something
written by someone else, or write something that makes use of a given
module.

That's probably why.  It's certainly the reason that comes to mind for
me.

-- 
CCD CopyWrite Chad Perrin [ http://ccd.apotheon.org ]
Real ugliness is not harsh-looking syntax, but having to
build programs out of the wrong concepts. - Paul Graham

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




Re: modifying @INC permanently

2006-06-08 Thread Anthony Ettinger

You do not need logic to do that.  It would seem better to use:

  use lib '/path/to/my/misplaced/perl-modules';


The point is to not have to specify a local path at all:

use lib qw(/path);
push(@inc, '/path');

Each script tests for OS: linux/sunos, and win32, and pushes the path
to @INC accordingly, based on path names. I tried File::Spec, but use
lib won't take a variable as it's evaluated before runtime, so that
left me with push.




--
Anthony Ettinger
Signature: http://chovy.dyndns.org/hcard.html

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




Re: modifying @INC permanently

2006-06-08 Thread Anthony Ettinger

On 6/8/06, Chad Perrin [EMAIL PROTECTED] wrote:


 Yes.  Recompile Perl setting the appropriate compile-time flags.  More
 importantly, though: Why?  It is just easier to install your modules
 in the standardly defined place for site-specific modules.


By install do you mean cp myMod.pm to /my/path/ ??



--
Anthony Ettinger
Signature: http://chovy.dyndns.org/hcard.html

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




RE: parsing a CSV file with more fields than column names

2006-06-08 Thread RICHARD FERNANDEZ
 Are you SURE that there might be commas in the other fields?
 I would hope that whoever made this file you're parsing would 
 have thought of this if they ever intended to later use the data.

Good point. But I have no way of verifying that.

These CSV files are provided to me by an outside source. I don't know if
I'll be able to pin anyone down on the comma issue. And I've already
gotten bad answers to other technical questions...

My thinking was to code for the worse case, which is where the data
might contain embedded commas. This way, I don't have to worry about it.

My concern is with field #17 (the last item in the header). But the
detail lines may contain 17 items. Assuming that there are never
embedded commas in the data, everything in the detail from field 17 on
should be considered as one group. But again, I can't make that
assumption. One embedded comma earlier in the data will throw off the
logic.

richf

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




RE: parsing a CSV file with more fields than column names

2006-06-08 Thread Timothy Johnson


-Original Message-
From: RICHARD FERNANDEZ [mailto:[EMAIL PROTECTED] 
Sent: Thursday, June 08, 2006 2:37 PM
To: beginners@perl.org
Subject: RE: parsing a CSV file with more fields than column names

 Are you SURE that there might be commas in the other fields?
 I would hope that whoever made this file you're parsing would 
 have thought of this if they ever intended to later use the data.

 Good point. But I have no way of verifying that.

 These CSV files are provided to me by an outside source. I don't know
if
 I'll be able to pin anyone down on the comma issue. And I've already
 gotten bad answers to other technical questions...

 snip


Your next best bet, then, might be to check each field and see if they
follow a close enough pattern that you can create a regex that will help
validate that field.  Even if you can only narrow down a few fields,
you will be able to tell if the commas are off.  That doesn't
automatically fix the problem, but it does let you know if your input
data is dirty and can let you know where to check for problems.




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




Re: Yet another OO question

2006-06-08 Thread Anthony Ettinger

On 6/8/06, Lawrence Statton [EMAIL PROTECTED] wrote:

  I would prefer it to return the old value:
 
  sub foo {


I see...I i've been more or less looking at the current state

$curr = $foo-bar();
$old = $curr;

$curr = $foo-bar('new value');



--
Anthony Ettinger
Signature: http://chovy.dyndns.org/hcard.html

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




Help with line length in script

2006-06-08 Thread Chris
I use a script that generates stats for clamav. It generates both txt and 
html output.  The problem is that the line length in the txt and html 
output differ. For instance in the txt output it shows this: (the numbers 
differ because the files were generated at different times)

Email.ScamS.Gen005.Sa           6   9.09%

While in the html file its shows this:

Email.ScamS.Gen005.Sanesecurity.060411007   9.46%

I 'think' this is where this comes from, but knowing very, very little about 
perl I may be wrong.

### VIRUS COUNTS

$TXT .= keys ( %{$stats{virus}} ) .  Virus Types Detected\n if $text;
$TXT .= --\n if $text;

if ($html) {
print table border=0trTh COLSPAN=4 bgcolor=\#99font 
color=\#FF size=4 . keys ( %{$stats{virus}} ) .  Virus Types 
Detected/font/thTH align=center;
}

foreach my $rec ( sort {$stats{virus}{$b}=$stats{virus}{$a}}  keys 
%{$stats{virus}} ) {
my $percent = sprintf (%.2f, (($stats{virus}-{$rec} / 
$stats{count}) * 
100));
1 while $stats{virus}-{$rec} =~ s/(.*\d)(\d\d\d)/$1,$2/;
$TXT .= swrite(@  @ @,$rec, 
$stats{virus}-{$rec}, $percent).%\n if $text;

if ($html) {
print trtd align=left bgcolor=\#FF;
print $rec/td;
print td align=right bgcolor=\#DCDCEE;
print $stats{virus}-{$rec} . /tdtd/tdtd 
ALIGN=RIGHT 
bgcolor=\#FF$percent. %;
print /td/tr\n;
}

}
print /TABLE/td if $html;

If the whole script is needed let me know and I'll upload it somewhere.

Thanks for any advice

-- 
Chris
Registered Linux User 283774 http://counter.li.org
19:51:46 up 25 days, 7:52, 1 user, load average: 0.18, 0.50, 0.45
Mandriva Linux 10.1 Official, kernel 2.6.8.1-12mdk



pgpxOzIqQgzs5.pgp
Description: PGP signature


RE: Help with line length in script

2006-06-08 Thread Timothy Johnson
Here's the offending line:

###
$TXT .= swrite(@  @ @,$rec, 
$stats{virus}-{$rec}, $percent).%\n if $text;
###

The @ part is telling format to print up to 21 characters 
of $rec and truncate the rest, left justifying it.  If you want to make the 
printout of $rec longer, add more of these: '' to that field.


-Original Message-
From: Chris [mailto:[EMAIL PROTECTED] 
Sent: Thursday, June 08, 2006 6:05 PM
To: beginners@perl.org
Subject: Help with line length in script

I use a script that generates stats for clamav. It generates both txt and 
html output.  The problem is that the line length in the txt and html 
output differ. For instance in the txt output it shows this: (the numbers 
differ because the files were generated at different times)

Email.ScamS.Gen005.Sa           6   9.09%

While in the html file its shows this:

Email.ScamS.Gen005.Sanesecurity.060411007   9.46%

I 'think' this is where this comes from, but knowing very, very little about 
perl I may be wrong.

### VIRUS COUNTS

$TXT .= keys ( %{$stats{virus}} ) .  Virus Types Detected\n if $text;
$TXT .= --\n if $text;

if ($html) {
print table border=0trTh COLSPAN=4 bgcolor=\#99font 
color=\#FF size=4 . keys ( %{$stats{virus}} ) .  Virus Types 
Detected/font/thTH align=center;
}

foreach my $rec ( sort {$stats{virus}{$b}=$stats{virus}{$a}}  keys 
%{$stats{virus}} ) {
my $percent = sprintf (%.2f, (($stats{virus}-{$rec} / 
$stats{count}) * 
100));
1 while $stats{virus}-{$rec} =~ s/(.*\d)(\d\d\d)/$1,$2/;
$TXT .= swrite(@  @ @,$rec, 
$stats{virus}-{$rec}, $percent).%\n if $text;

if ($html) {
print trtd align=left bgcolor=\#FF;
print $rec/td;
print td align=right bgcolor=\#DCDCEE;
print $stats{virus}-{$rec} . /tdtd/tdtd 
ALIGN=RIGHT 
bgcolor=\#FF$percent. %;
print /td/tr\n;
}

}
print /TABLE/td if $html;

If the whole script is needed let me know and I'll upload it somewhere.

Thanks for any advice

-- 
Chris
Registered Linux User 283774 http://counter.li.org
19:51:46 up 25 days, 7:52, 1 user, load average: 0.18, 0.50, 0.45
Mandriva Linux 10.1 Official, kernel 2.6.8.1-12mdk



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




Re: Help with line length in script

2006-06-08 Thread Chris
On Thursday 08 June 2006 8:11 pm, Timothy Johnson wrote:
 Here's the offending line:

 ###
 $TXT .= swrite(@  @ @,$rec,
 $stats{virus}-{$rec}, $percent).%\n if $text; ###

 The @ part is telling format to print up to 21
 characters of $rec and truncate the rest, left justifying it.  If you
 want to make the printout of $rec longer, add more of these: '' to that
 field.


I thought that was it and I'm sure I'd made changes to that line earlier, 
but guess I didn't.  

Thanks for the help, lines look much better now.

-- 
Chris
Registered Linux User 283774 http://counter.li.org
20:24:25 up 25 days, 8:24, 1 user, load average: 0.23, 0.26, 0.22
Mandriva Linux 10.1 Official, kernel 2.6.8.1-12mdk



pgpXSme7Kt2PV.pgp
Description: PGP signature