Re: Storing filehandles(for writing) in hashes doesn't work (Re: whilereach my $variable (FILEHANDLE) )

2007-01-16 Thread Mumia W.

On 01/15/2007 11:21 PM, Michael Alipio wrote:

Hi,

Ok, seems like a pet logs is not a good example.:-)

Let me revise my story:

I have a logfile which contains different clients firewall's logs.

Let's say the log file is: firewall.log

Now each line in the logfile has a $deviceid string that identifies where or which client it came from. 
What I did was to list down all of these clients in a file named deviceid.conf. 
Let's say it  contains: ('client_name'  dash  'device_id')


client1 - 293u0sdfj
client2 - 8325kjsdf
client3 - kjldas8282
.
clientn - sdkfj28350


Having said that, my goals are:

1. read the firewall.log line by line.
if it see a particular device_id in $_, and it knows that that deviceid is for this 
particular client (using the information found at deviceid.conf) it will 
write that line into /client1/$date.log or /client2/$date.log etc.

By the way, our logs are being rotated  such that it contains logs from 6:26 yesterday, to 6:25 
today, so $date on the above was obtained by let's say getting the /date=(\S+)/ on the first line 
entry of the log, let's say it reads 2007-01-10, so our $date will be 2007-01-10_11, so 
the logfile for a particular client will be /client1/2007-01-10_11.log


Here is an example of a line in the logfile:

Jan 10 06:26:17 210.23.194.86 date=2007-01-10 
time=06:30:14,devname=sccp_firewall,device_id=FWF60A1234566,log_id=00210100
01,type=traffic,subtype=allowed,pri=notice,vd=root;SN=14435461,duration=139,user=N/A,group=N/A,policyid=11,proto=6,service=7
500/tcp,status=accept,src=192.169.1.70,srcname=192.168.1.3,dst=192.169.1.17,dstname=192.169.1.17,src_int=internal,dst_int
=wan2,sent=144,rcvd=0,sent_pkt=3,rcvd_pkt=0,src_port=2354,dst_port=7500,vpn=N/A,tran_ip=0.0.0.0,tran_port=0,dir_disp=org,tra
n_disp=noop



The device_id in this log entry does not appear in the device id file 
you showed above.





So far, I've been trying to use the code that was given to me but I'm still far 
from my goal:


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

my $logfile='firewall.log';
my $devices='deviceid.conf';
our %log;


##
# 1ST PART
open DEVICES, '', $devices or die Can't open $devices $!;

while ( my $device = DEVICES){
  chomp $device;
  ($device) = $device =~ /(\S+)$/;
  open( my $fh, '', $device.log) or die Can't open $device.log: $!;
  $log{$device} = $fh;
}
close DEVICES;
#

So far I can understand that in the first part, the code will read the 
deviceid.conf and create a file handle for writing for each device id, and 
store these filehandles inside %log. But that is what I wanted to do, I want 
to, as I wanted to write my logs into /clientN/date.log instead of 
client's_deviceid.log. So I'm still trying to figure out this one.


/(\S+)$/ only matches the device-id; the client-id is thrown away. Don't 
throw it away. Create a regular expression that captures the client id 
and use the client-id to create the log file name.





Next:



# 2nd PART

my $re = '^\S+\s+(' . join( '|', keys %log ). ')';

open( IN, '', $logfile ) or die Can't open $logfile: $!;

while( my $line = IN ){
  if( $line =~ m/$re/ ){
print $log{$1} $line;
  }
}


###


The second part is what confuses me, especially the line with my $re, and also the 
if($line =~ m/$re/)

As far as I can understand, the $re will contain a regexp with ('device_id1 | 
device_id2 | device_id3 | device_idN'), so that whenever it sees any pattern 
that match either of those device_ids, it will print it to say $log{device_idN} 
which points to the file handle that writes to device_idN.log.

But this is not the case.
The line print $log{$1} $line; doesn't even work as if it cannot decode the 
$log{$1}



You are correct, my $re creates a regular expression with all of the 
device ids, and you are also correct that print $log{$1} $line does 
not work. You must use print { $log{$1} } $line.




Useless use of a constant in void context at extractdevice.pl line 30.
Scalar found where operator expected at extractdevice.pl line 35, near } $line
(Missing operator before  $line?)
syntax error at extractdevice.pl line 35, near } $line

If I comment those codes inside the while in that second part, the program will 
successfully create emtpy device_id1.log, device_id2.log, etc. etc.)

Any idea what's wrong with this one?




My comments are above.

I wrote the program a completely different way. I think you should read 
'deviceid.conf' and place the device-ids and client-ids into a hash 
($clientids). Then open and start reading the logfile. Whenever you are 
able to capture a device-id that is in the %clientids hash, construct a 
filename to the desired output log file and append the input logfile 
line to that output log file.




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




Re: Storing filehandles(for writing) in hashes doesn't work (Re: whilereach my $variable (FILEHANDLE) )

2007-01-16 Thread Michael Alipio
Hi,


Ok, here's my code:


my $logfile='firewalllog';
my $devicefile='deviceid';

our %log;

open DEVICES, '', $devicefile or die Can't open $devicefile $!;

while (my $device DEVICES){
  ($device) = $device =~ /(\S+)$/;
  open (my $fh, '', $device..log) or die Can't write to $device..log: $!;
  $log{device} = $fh;
}
close DEVICES;

So I should be able to print to at least {$log{any_device_id}} right??

But using this:

print {$log{FWF60A1234566}} testing;


gives me:

Use of uninitialized value in ref-to-glob cast at extractdevice.pl line 20.
Can't use string () as a symbol ref while strict refs in use at 
extractdevice.pl line 20.

Any idea what does the above means? 




- Original Message 
From: Mumia W. [EMAIL PROTECTED]
To: Beginners List beginners@perl.org
Sent: Tuesday, January 16, 2007 3:13:38 PM
Subject: Re: Storing filehandles(for writing) in hashes doesn't work (Re: 
whilereach my $variable (FILEHANDLE) )

On 01/15/2007 11:21 PM, Michael Alipio wrote:
 Hi,
 
 Ok, seems like a pet logs is not a good example.:-)
 
 Let me revise my story:
 
 I have a logfile which contains different clients firewall's logs.
 
 Let's say the log file is: firewall.log
 
 Now each line in the logfile has a $deviceid string that identifies where or 
 which client it came from. 
 What I did was to list down all of these clients in a file named 
 deviceid.conf. 
 Let's say it  contains: ('client_name'  dash  'device_id')
 
 client1 - 293u0sdfj
 client2 - 8325kjsdf
 client3 - kjldas8282
 .
 clientn - sdkfj28350
 
 
 Having said that, my goals are:
 
 1. read the firewall.log line by line.
 if it see a particular device_id in $_, and it knows that that deviceid 
 is for this particular client (using the information found at 
 deviceid.conf) it will write that line into /client1/$date.log or 
 /client2/$date.log etc.
 
 By the way, our logs are being rotated  such that it contains logs from 6:26 
 yesterday, to 6:25 today, so $date on the above was obtained by let's say 
 getting the /date=(\S+)/ on the first line entry of the log, let's say it 
 reads 2007-01-10, so our $date will be 2007-01-10_11, so the logfile for a 
 particular client will be /client1/2007-01-10_11.log
 
 
 Here is an example of a line in the logfile:
 
 Jan 10 06:26:17 210.23.194.86 date=2007-01-10 
 time=06:30:14,devname=sccp_firewall,device_id=FWF60A1234566,log_id=00210100
 01,type=traffic,subtype=allowed,pri=notice,vd=root;SN=14435461,duration=139,user=N/A,group=N/A,policyid=11,proto=6,service=7
 500/tcp,status=accept,src=192.169.1.70,srcname=192.168.1.3,dst=192.169.1.17,dstname=192.169.1.17,src_int=internal,dst_int
 =wan2,sent=144,rcvd=0,sent_pkt=3,rcvd_pkt=0,src_port=2354,dst_port=7500,vpn=N/A,tran_ip=0.0.0.0,tran_port=0,dir_disp=org,tra
 n_disp=noop
 

The device_id in this log entry does not appear in the device id file 
you showed above.


 
 So far, I've been trying to use the code that was given to me but I'm still 
 far from my goal:
 
 
 #!/usr/bin/perl
 use warnings;
 use strict;
 
 my $logfile='firewall.log';
 my $devices='deviceid.conf';
 our %log;
 
 
 ##
 # 1ST PART
 open DEVICES, '', $devices or die Can't open $devices $!;
 
 while ( my $device = DEVICES){
   chomp $device;
   ($device) = $device =~ /(\S+)$/;
   open( my $fh, '', $device.log) or die Can't open $device.log: $!;
   $log{$device} = $fh;
 }
 close DEVICES;
 #
 
 So far I can understand that in the first part, the code will read the 
 deviceid.conf and create a file handle for writing for each device id, and 
 store these filehandles inside %log. But that is what I wanted to do, I want 
 to, as I wanted to write my logs into /clientN/date.log instead of 
 client's_deviceid.log. So I'm still trying to figure out this one.

/(\S+)$/ only matches the device-id; the client-id is thrown away. Don't 
throw it away. Create a regular expression that captures the client id 
and use the client-id to create the log file name.


 
 Next:
 
 
 
 # 2nd PART
 
 my $re = '^\S+\s+(' . join( '|', keys %log ). ')';
 
 open( IN, '', $logfile ) or die Can't open $logfile: $!;
 
 while( my $line = IN ){
   if( $line =~ m/$re/ ){
 print $log{$1} $line;
   }
 }
 
 
 ###
 
 
 The second part is what confuses me, especially the line with my $re, and 
 also the if($line =~ m/$re/)
 
 As far as I can understand, the $re will contain a regexp with ('device_id1 | 
 device_id2 | device_id3 | device_idN'), so that whenever it sees any pattern 
 that match either of those device_ids, it will print it to say 
 $log{device_idN} which points to the file handle that writes to 
 device_idN.log.
 
 But this is not the case.
 The line print $log{$1} $line; doesn't even work as if it cannot decode the 
 $log{$1}
 

You are correct, my $re creates a regular expression with all of the 
device ids, and you are also correct that print $log{$1} $line does 
not work. You must use print { $log{$1} } $line.


 Useless use of a constant in void 

InterOperate between a cluster and a web server

2007-01-16 Thread I BioKid

Dear All,

Currently we are developing an Integrated Web Server with a dedicated
cluster to support the server.

I need help to set up a web application that can manage the web server and
our cluster.
For example  if the user is submitting a huge set  of data to do some
processing , the program should take care of
the process and pass it on to the cluster and display the status of the job
(que and other details).
I know this is possible and people are doing it.

It will be great, If any of the Linux/perl/ techies around can help me out
with some help :))

We are using Ganglia as the server management tool. Web  Server is apache
running on  CentOS4 .

Thanks in Advance and Happy New Year to all...
--
S Khadar


Re: Storing filehandles(for writing) in hashes doesn't work (Re: whilereach my $variable (FILEHANDLE) )

2007-01-16 Thread Mumia W.

On 01/16/2007 04:02 AM, Michael Alipio wrote:

- Original Message 
From: Mumia W. [EMAIL PROTECTED]
To: Beginners List beginners@perl.org
Sent: Tuesday, January 16, 2007 3:13:38 PM
Subject: Re: Storing filehandles(for writing) in hashes doesn't work (Re: whilereach 
my $variable (FILEHANDLE) )

On 01/15/2007 11:21 PM, Michael Alipio wrote:

Hi,

Ok, seems like a pet logs is not a good example.:-)

Let me revise my story:

I have a logfile which contains different clients firewall's logs.

Let's say the log file is: firewall.log

Now each line in the logfile has a $deviceid string that identifies where or which client it came from. 
What I did was to list down all of these clients in a file named deviceid.conf. 
Let's say it  contains: ('client_name'  dash  'device_id')


client1 - 293u0sdfj
client2 - 8325kjsdf
client3 - kjldas8282
.
clientn - sdkfj28350


Having said that, my goals are:

1. read the firewall.log line by line.
if it see a particular device_id in $_, and it knows that that deviceid is for this 
particular client (using the information found at deviceid.conf) it will 
write that line into /client1/$date.log or /client2/$date.log etc.

By the way, our logs are being rotated  such that it contains logs from 6:26 yesterday, to 6:25 
today, so $date on the above was obtained by let's say getting the /date=(\S+)/ on the first line 
entry of the log, let's say it reads 2007-01-10, so our $date will be 2007-01-10_11, so 
the logfile for a particular client will be /client1/2007-01-10_11.log


Here is an example of a line in the logfile:

Jan 10 06:26:17 210.23.194.86 date=2007-01-10 
time=06:30:14,devname=sccp_firewall,device_id=FWF60A1234566,log_id=00210100
01,type=traffic,subtype=allowed,pri=notice,vd=root;SN=14435461,duration=139,user=N/A,group=N/A,policyid=11,proto=6,service=7
500/tcp,status=accept,src=192.169.1.70,srcname=192.168.1.3,dst=192.169.1.17,dstname=192.169.1.17,src_int=internal,dst_int
=wan2,sent=144,rcvd=0,sent_pkt=3,rcvd_pkt=0,src_port=2354,dst_port=7500,vpn=N/A,tran_ip=0.0.0.0,tran_port=0,dir_disp=org,tra
n_disp=noop



The device_id in this log entry does not appear in the device id file 
you showed above.




So far, I've been trying to use the code that was given to me but I'm still far 
from my goal:


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

my $logfile='firewall.log';
my $devices='deviceid.conf';
our %log;


##
# 1ST PART
open DEVICES, '', $devices or die Can't open $devices $!;

while ( my $device = DEVICES){
  chomp $device;
  ($device) = $device =~ /(\S+)$/;
  open( my $fh, '', $device.log) or die Can't open $device.log: $!;
  $log{$device} = $fh;
}
close DEVICES;
#

So far I can understand that in the first part, the code will read the 
deviceid.conf and create a file handle for writing for each device id, and 
store these filehandles inside %log. But that is what I wanted to do, I want 
to, as I wanted to write my logs into /clientN/date.log instead of 
client's_deviceid.log. So I'm still trying to figure out this one.


/(\S+)$/ only matches the device-id; the client-id is thrown away. Don't 
throw it away. Create a regular expression that captures the client id 
and use the client-id to create the log file name.




Next:



# 2nd PART

my $re = '^\S+\s+(' . join( '|', keys %log ). ')';

open( IN, '', $logfile ) or die Can't open $logfile: $!;

while( my $line = IN ){
  if( $line =~ m/$re/ ){
print $log{$1} $line;
  }
}


###


The second part is what confuses me, especially the line with my $re, and also the 
if($line =~ m/$re/)

As far as I can understand, the $re will contain a regexp with ('device_id1 | 
device_id2 | device_id3 | device_idN'), so that whenever it sees any pattern 
that match either of those device_ids, it will print it to say $log{device_idN} 
which points to the file handle that writes to device_idN.log.

But this is not the case.
The line print $log{$1} $line; doesn't even work as if it cannot decode the 
$log{$1}



You are correct, my $re creates a regular expression with all of the 
device ids, and you are also correct that print $log{$1} $line does 
not work. You must use print { $log{$1} } $line.




Useless use of a constant in void context at extractdevice.pl line 30.
Scalar found where operator expected at extractdevice.pl line 35, near } $line
(Missing operator before  $line?)
syntax error at extractdevice.pl line 35, near } $line

If I comment those codes inside the while in that second part, the program will 
successfully create emtpy device_id1.log, device_id2.log, etc. etc.)

Any idea what's wrong with this one?




My comments are above.

I wrote the program a completely different way. I think you should read 
'deviceid.conf' and place the device-ids and client-ids into a hash 
($clientids). Then open and start reading the logfile. Whenever you are 
able to capture a device-id that is in the %clientids hash, construct a 
filename to the desired output 

Mail Attachment

2007-01-16 Thread Anish Kumar K.

Hi

I am trying you to use this piece of code to send mail frm the HTML 
form. But I am not getting any mail as well as no error message. I am 
using sendmail to send the attachement. Any help is nice


my $picture=PATH OBTAINED FROM THE HTML FORM for example;  c:/a.jpg
my $sendmailpath=/usr/sbin/sendmail;

open (SENDMAIL, | $sendmailpath -t);
print SENDMAIL To: $to_address\n;
print SENDMAIL From: $from_address\n;
print SENDMAIL Subject: $subject\n\n;
print SENDMAIL $message_body;
print SENDMAIL \n\n;

open(FILE, uuencode $picture $picture|);
while(FILE) { print SENDMAIL; };
close(FILE);
close(SENDMAIL);

Thanks
Anish

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




Re: Mail Attachment

2007-01-16 Thread Lawrence Statton XE2/N1GAK

First -- your porgram is nowhere NEAR complete ... I see nowhere that
$to_address, $from_address, etc are populated.  Read the posting
guidelines and try again.

That being said, there are some glaring deficiencies that can be
pointed out even without the complete program.

 
 my $picture=PATH OBTAINED FROM THE HTML FORM for example;  c:/a.jpg
 my $sendmailpath=/usr/sbin/sendmail;
 
 open (SENDMAIL, | $sendmailpath -t);
 print SENDMAIL To: $to_address\n;
 print SENDMAIL From: $from_address\n;
 print SENDMAIL Subject: $subject\n\n;
 print SENDMAIL $message_body;
 print SENDMAIL \n\n;

Don't pipe to sendmail -- use one of the myriad convenient Perl
modules for sending email, with attachments etc.

MIME::Lite ismy favorite, there are many others just as good.  Try a
few and pick the one that fits your needs.

If $picture is a path obtained from a web form, it is probably a path
on the users computer, not your webserver (i.e. I find it near
impossible to imagine a computer whose sendmail is in /usr/sbin yet has
a directory in Apache's server_root named 'c:' and in this directory
is a file named a.jpg ).  

If you're not already (see that thing above about 'complete program')
using CGI.pm you should be, and you should go read the perldoc for the
file upload section a dozen times until you understand completely --
it is complicated and you'll get it wrong the first few times.

 open(FILE, uuencode $picture $picture|);

Should you fall in love with MIME::Lite you won't need to fork out to
uuencode.  IF you insist on uuencoding (uuencode?  did I fall into a
timewarp to 1992?) yourself, it would be a good idea to include the
complete path, or at least show us that you explicitly set the path.

ALWAYS CHECK RETURN STATUS ON OPEN AND CLOSE.  A lot of people ignore
close() errors on files more often than they should, even me - it's a
common venial sin, but whenever reading from or writing to pipes
... well, just do it.  You'd have surely noticed that uuencode failed
catostrophically because it couldn't find a file with the bizarrely
formed filename c:/a.jpg in the current working directory.

 
 Thanks
 Anish
 
 -- 
 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/




Get summery of a jpeg file

2007-01-16 Thread Gallagher, Tim F \(NE\)
 
A friend asked me to write a program for a WIN32 OS.  When this person's
camera takes a picture it populates the file summery with information
(right click on the file, go to the summary tab).  One field that I need
to get is called Date Picture Taken.  I then need to rename the
pictures with something incremented by 1 and this field.  Is there a
cpan module that can do this?

Thanks 
-T

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




Re: Get summery of a jpeg file

2007-01-16 Thread Lawrence Statton XE2/N1GAK
  
 A friend asked me to write a program for a WIN32 OS.  When this person's
 camera takes a picture it populates the file summery with information
 (right click on the file, go to the summary tab).  One field that I need
 to get is called Date Picture Taken.  I then need to rename the
 pictures with something incremented by 1 and this field.  Is there a
 cpan module that can do this?
 

Before you asked us, you CERTAINLY did a search of CPAN for JPEG and
Info, right?  How did Image::MetaData::JPEG fail to meet your needs?

It's huge, it's complicated, and the documentation is hard to read,
but Image Magick (which comes with perl bindings) can do anything with
an image that can be done, including getting the info block out of a
JPEG.

-- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --
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/




Re: Get summery of a jpeg file

2007-01-16 Thread Ovid
--- Gallagher, Tim F (NE) [EMAIL PROTECTED] wrote:
  
 A friend asked me to write a program for a WIN32 OS.  When this
 person's
 camera takes a picture it populates the file summery with information
 (right click on the file, go to the summary tab).  One field that I
 need
 to get is called Date Picture Taken.  I then need to rename the
 pictures with something incremented by 1 and this field.  Is there a
 cpan module that can do this?

 http://search.cpan.org/~bettelli/Image-MetaData-JPEG-0.15/

That's the first hit off search.cpan.org for 'jpeg'.  There are many
more available.

Cheers,
Ovid

--

Buy the book -- http://www.oreilly.com/catalog/perlhks/
Perl and CGI -- http://users.easystreet.com/ovid/cgi_course/

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




Hash variable is not imported?? (Re: Storing File Handles for writing)

2007-01-16 Thread Michael Alipio
Hi Mumia,

I think this one is closer to my goal.

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

my $logfile='fortilog';
my $devicefile='deviceid';
our %clientdevice;

open DEVICES, '', $devicefile or die Can't open $devicefile $!;

while (DEVICES){
  (my $client) = $_ =~ /^(\S+\s+)/;
  (my $device) = $_ =~ /(\S+)$/;
  $clientdevice{$device} = $client;
}
close DEVICES;


open( LOGFILE, '', $logfile ) or die Can't open $logfile: $!;
 while(my $log = LOGFILE ){
  (my $deviceid) = $log =~ /device_id=(\S+?),/;
  if (exists $clientdevice{$deviceid}){
 open FH, '', $clientdevice($deviceid) or die $!;
 print FH $log;
 close FH;
   }
}

The if exist line keeps on complaining:

Variable $clientdevice is not imported at extractdevice.pl line 23.
Global symbol $clientdevice requires explicit package name at 
extractdevice.pl line 23.
syntax error at extractdevice.pl line 23, near $clientdevice(


Do you know what does this tell?

For those unaware about my goal:
I have a logfile that contains each of our client's firewall logs:
A sample line looks like this.

Jan 10 06:26:17 210.23.194.86 date=2007-01-10 
time=06:30:14,devname=sccp_firewall,device_id=FWF60A123456,log_id=002101000
1,type=traffic,subtype=allowed,pri=notice,vd=root;SN=14435461,duration=139,user=N/A,group=N/A,policyid=11,proto=6,service=750
0/tcp,status=accept,src=192.168.16.23,srcname=192..168.23.5,dst=192.168.1.17,dstname=192.168.1.17,src_int=internal,dst_int=wa
n2,sent=144,rcvd=0,sent_pkt=3,rcvd_pkt=0,src_port=2354,dst_port=7500,vpn=N/A,tran_ip=0.0.0.0,tran_port=0,dir_disp=org,tran_di
sp=noop

Then I made a deviceid file which contains:

client1 - FWF60A123456
client2 - FG200A123456
client3 - FS300A123456

The goal is to read the logfile line by line, and if it sees that device_id 
exists in the hash that was created after reading deviceid file, then it will 
write that particular log entry in, let's say client1.log.





 

Finding fabulous fares is fun.  
Let Yahoo! FareChase search your favorite travel sites to find flight and hotel 
bargains.
http://farechase.yahoo.com/promo-generic-14795097

Re: Mail Attachment

2007-01-16 Thread JupiterHost.Net



Lawrence Statton XE2/N1GAK wrote:

First -- your porgram is nowhere NEAR complete ... I see nowhere that
$to_address, $from_address, etc are populated.  Read the posting
guidelines and try again.

That being said, there are some glaring deficiencies that can be
pointed out even without the complete program.


In addition to Lawrence's excellent points, I might suggest using

 Mail::Sender::Easy

You can simply do

 email(\%hash_that_describes_the_email) or die $@;

where \%hash_that_describes_the_email lets you structure it however you 
need, including attachments of any sort in any disposition etc...


It will make your life mch easier...

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




Re: Hash variable is not imported?? (Re: Storing File Handles for writing)

2007-01-16 Thread John W. Krahn
Michael Alipio wrote:
 Hi Mumia,

It's John but hello anyway.

 I think this one is closer to my goal.
 
 #!/usr/local/bin/perl
 use warnings;
 use strict;
 
 my $logfile='fortilog';
 my $devicefile='deviceid';
 our %clientdevice;
 
 open DEVICES, '', $devicefile or die Can't open $devicefile $!;
 
 while (DEVICES){
   (my $client) = $_ =~ /^(\S+\s+)/;
   (my $device) = $_ =~ /(\S+)$/;
   $clientdevice{$device} = $client;
 }
 close DEVICES;
 
 
 open( LOGFILE, '', $logfile ) or die Can't open $logfile: $!;
  while(my $log = LOGFILE ){
   (my $deviceid) = $log =~ /device_id=(\S+?),/;
   if (exists $clientdevice{$deviceid}){
  open FH, '', $clientdevice($deviceid) or die $!;

Change the parentheses () to braces {} there:

  open FH, '', $clientdevice{$deviceid} or die $!;

  print FH $log;
  close FH;
}
 }
 
 The if exist line keeps on complaining:

It is actually the line after that one that has the problem.

 Variable $clientdevice is not imported at extractdevice.pl line 23.
 Global symbol $clientdevice requires explicit package name at 
 extractdevice.pl line 23.
 syntax error at extractdevice.pl line 23, near $clientdevice(

Line 23 is:

  open FH, '', $clientdevice($deviceid) or die $!;



John
-- 
Perl isn't a toolbox, but a small machine shop where you can special-order
certain sorts of tools at low cost and in short order.   -- Larry Wall

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




Re: Hash variable is not imported?? (Re: Storing File Handles for writing)

2007-01-16 Thread Tom Phoenix

On 1/16/07, Michael Alipio [EMAIL PROTECTED] wrote:


Variable $clientdevice is not imported at extractdevice.pl line 23.


Since you were good enough to use strict (thank you!) Perl is
pointing out that you never declared any $clientdevice variable before
using it:


 open FH, '', $clientdevice($deviceid) or die $!;


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/




$[ (was: Re: Converting to capital only one word in a line)

2007-01-16 Thread Dr.Ruud
Jay Savage schreef:

 There are, however,
 modules that modify all sorts of internal variables and symbol tables
 to enhance efficiency and work magic, and there is always a slight
 chance that someone, somewhere has messed with $[ and not told you
 about it. If they have, you'll end with unexplained and nearly
 impossible to diagnose fencepost errors in your code if you expect
 that $#array and @array -1 will always return the same value, and
 $array[$#array] and [EMAIL PROTECTED] -1] will always refer to the same
 item.


But As of release 5 of Perl, assignment to $[ is treated as a com-
piler directive, and cannot influence the behavior of any other
file.. So it only influences the current file, onwards from where
it is set.

$ perl -Mstrict -MData::Dumper -wle'
  my @x; $[ = -1;
  $x[0] = abc; $[ =  1;
  $x[1] = cde;
  print Dumper [EMAIL PROTECTED]
'
$VAR1 = [
  'cde',
  'abc'
];

-- 
Affijn, Ruud

Gewoon is een tijger.


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




Re: CPAN installs

2007-01-16 Thread Kevin Viel

Wiggins d'Anconia wrote:

Kevin Viel wrote:

I am attempting to install modules on a Solaris v10 computer for which 
I do not have root privileges.  I see in MyConfig.pm that the build 
directory is local:


'build_dir' = q[/home/kviel/.cpan/build]

Where does it install the (built) module?

Thank you,

Kevin




The build_dir doesn't mean a lot in this case, assuming you are asking 
what I think you are asking. Instead you want to specify an install 
location in the makepl_arg and or mbuildpl_arg settings. For instance,


makepl_arg = LIB=~/local/lib PREFIX=~/local/lib
mbuildpl_arg = --install_base /home/user/local/lib

Check perldoc CPAN for information about 'o conf'. HTH,

http://danconia.org


Thanks Wiggins.

I attempted to use o conf scalar option value, but did not seem to 
have success.  In particular, I was unsure of how to use:


o conf list option [unshift|push|splice] list

It seems I'd need to use this since I had LIB and PREFIX.  Could someone 
provide an example?


So, I used o conf init and I have the following in my MyConfig.pm:

  'make_arg' = q[LIB=~/local/lib PREFIX=~/local/lib],
  'make_install_arg' = q[--install_base /home/kviel/local/lib],
  'makepl_arg' = q[LIB=~/local/lib PREFIX=~/local/lib],


but still obtain an apparent failure:

Failed Test  Stat Wstat Total Fail  Failed  List of Failed
---
base/message.t 952   2.11%  86 89
html/form-param.t   2   51224   48 200.00%  1-24
html/form.t 2   512   122  244 200.00%  1-122
local/autoload-get.t11 100.00%  1
local/autoload.t11 100.00%  1
local/get.t 2   512 24 200.00%  1-2
local/http-get.t   206  30.00%  1-2 5-7 20
local/http.t   186  33.33%  1-2 5-7 18
robot/ua-get.t  82  25.00%  3 5
robot/ua.t  72  28.57%  3 5
Failed 10/30 test scripts, 66.67% okay. 168/799 subtests failed, 78.97% 
okay.

make: *** [test] Error 29
  /usr/local/bin/make test -- NOT OK
Running make install
  make test had returned bad status, won't install without force



I used:

cpan install LWP::Simple

Thanks for any help or advice.

Kevin

--
Kevin Viel
Department of Genetics   [EMAIL PROTECTED]
Southwest Foundation for Biomedical Research phone:  (210)258-9884
P.O. Box 760549  fax:(210)258-9444
San Antonio, TX 78245-0549

Kevin Viel
PhD Candidate
Department of Epidemiology
Rollins School of Public Health
Emory University
Atlanta, GA 30322

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




Re: Get summery of a jpeg file

2007-01-16 Thread Omega -1911

 Before you asked us, you CERTAINLY did a search of CPAN for JPEG and


Info, right?  How did Image::MetaData::JPEG fail to meet your needs?

It's huge, it's complicated, and the documentation is hard to read,
but Image Magick (which comes with perl bindings) can do anything with
an image that can be done, including getting the info block out of a
JPEG.

-- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --
Lawrence Statton - [EMAIL PROTECTED] s/aba/c/g




Did YOU assume that the OP knew about CPAN. I know when I had my first
interest in Perl, I had NO IDEA of who or what CPAN was, let alone that it
existed

Shame on you for flaming on a *BEGINNER* mailing list. (Not that there have
been some exceptions...)


Re: Hash variable is not imported?? (Re: Storing File Handles for writing)

2007-01-16 Thread Michael Alipio
Hi John! 

- Original Message 
 From: John W. Krahn [EMAIL PROTECTED]
 To: Perl Beginners beginners@perl.org
 Sent: Tuesday, January 16, 2007 8:15:36 AM
 Subject: Re: Hash variable is not imported?? (Re: Storing File Handles for 
 writing)

  
  open( LOGFILE, '', $logfile ) or die Can't open $logfile: $!;
   while(my $log = LOGFILE ){
(my $deviceid) = $log =~ /device_id=(\S+?),/;
if (exists $clientdevice{$deviceid}){
   open FH, '', $clientdevice($deviceid) or die $!;

 Change the parentheses () to braces {} there:

Holly cow! Sorry about this one. I shouldn't have done this on a putty 
terminal, my mistake, can't spot the difference between () and {}.

Thank you very much John!
You're a certified perl guru! :-)

   open FH, '', $clientdevice{$deviceid} or die $!;

   print FH $log;
   close FH;
 }
  }
  
  The if exist line keeps on complaining:

 It is actually the line after that one that has the problem.

  Variable $clientdevice is not imported at extractdevice.pl line 23.
  Global symbol $clientdevice requires explicit package name at 
  extractdevice.pl line 23.
  syntax error at extractdevice.pl line 23, near $clientdevice(

 Line 23 is:

   open FH, '', $clientdevice($deviceid) or die $!;



John
-- 
Perl isn't a toolbox, but a small machine shop where you can special-order
certain sorts of tools at low cost and in short order.   -- Larry Wall

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









 

Sucker-punch spam with award-winning protection. 
Try the free Yahoo! Mail Beta.
http://advision.webevents.yahoo.com/mailbeta/features_spam.html

any way to redirect output from a .pl script to a log file

2007-01-16 Thread Janeen

Hello All:

Is there a way to re-direct the output of a perl script to a log file, 
from within the perl script?  I'm looking for the perl equivalent of the 
following:


{
   command 1
   command 2
   command 3
} 2 ${LOG} 12

which would redirect anything written to STDOUT and STDERR, by commands 
1,2,  3,  to the logfile  in a unix shell script.


Janeen

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




Re: any way to redirect output from a .pl script to a log file

2007-01-16 Thread Jason Roth

Hi Janeen,

To redirect STDOUT and STDERR, simply open them for writing with
whatever file name you want to log to.  For example

#!/usr/bin/perl
print I'm written to the consonle\n;
open STDOUT, '', 'log.txt';
print I'm written to a log file\n;

Hope that helps.

-Jason

On 1/16/07, Janeen [EMAIL PROTECTED] wrote:

Hello All:

Is there a way to re-direct the output of a perl script to a log file,
from within the perl script?  I'm looking for the perl equivalent of the
following:

{
command 1
command 2
command 3
} 2 ${LOG} 12

which would redirect anything written to STDOUT and STDERR, by commands
1,2,  3,  to the logfile  in a unix shell script.

Janeen

--
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: Get summery of a jpeg file

2007-01-16 Thread Lawrence Statton XE2/N1GAK

Omega 1911 wrote in part:
Did YOU assume that the OP knew about CPAN. I know when I had my first
interest in Perl, I had NO IDEA of who or what CPAN was, let alone that it
existed

Since the OPs question included, Is there a cpan module that can do
this? I think it is not unfair to assume that he knew about the
existance of cpan.  Furthermore, the posting guidelines are included
here frequently enough that ignorance is of feeble excuse...


Had OPs request even been phrased as I searched CPAN for JPEG and
Info and there were dozens of modules, and I'm lost as to which is the
best for my seemingly simple needs -- does anyone here have a favorite
and why?, it would have been far superior.

-- 
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
place them into the correct order.





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




Re: Get summery of a jpeg file

2007-01-16 Thread Mumia W.

On 01/16/2007 10:18 PM, Lawrence Statton XE2/N1GAK wrote:

Omega 1911 wrote in part:

Did YOU assume that the OP knew about CPAN. I know when I had my first
interest in Perl, I had NO IDEA of who or what CPAN was, let alone that it
existed


Since the OPs question included, Is there a cpan module that can do
this? I think it is not unfair to assume that he knew about the
existance of cpan.  Furthermore, the posting guidelines are included
here frequently enough that ignorance is of feeble excuse...
[...]


Where are the posting guidelines for this mailing list, [EMAIL PROTECTED]




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