Re: removing characters

2006-09-15 Thread jeffhua
 Hi,
You can do it like:
 
$var =~ s/\[|\]//g;
 
or
 
$var =~ s/[\[\]]//g;
 
 
-Original Message-
From: [EMAIL PROTECTED]
To: beginners@perl.org
Sent: Fri, 15 Sep 2006 1:54 PM
Subject: removing characters


Hi, 
 
I have a certain variables of emplyee number which comes in the format of 
[a000] or [u000] {whereby 000 is some serial numbers}. 
 
I would like to remove the enclosed [  ] see if it is belong to class a or 
u , i can do it as follow 
 
$var = /\[//; $var = /\]//; 
if ($var =~ '^a) { 
  print $var is class A; 
} elsfi ($var =~ '^u) { 
  print '$var is class U; 
} 
$var = /a//; $var = /u//; 
 
How can i remove the chars all in a single line? and write the code in a 
more perl manner ? 
 
regards 
rexo 

Check out the new AOL.  Most comprehensive set of free safety and security 
tools, free access to millions of high-quality videos from across the web, free 
AOL Mail and more.


Re: removing characters

2006-09-15 Thread John W. Krahn
ubergoonz wrote:
 Hi,

Hello,

 I have a certain variables of emplyee number which comes in the format of
 [a000]  or [u000] {whereby 000 is some serial numbers}.
 
 I would like to remove the enclosed [  ]  see if it is belong to class
 a or
 u , i can do it as follow
 
 $var = /\[//; $var = /\]//;
 if ($var =~ '^a) {
   print $var is class A;
 } elsfi ($var =~ '^u) {
   print '$var is class U;
 }
 $var = /a//; $var = /u//;
 
 How can i remove the chars all in a single line? and write the code in a
 more perl manner ?

You could do something like:

my ( $class, $ser_no ) = $var =~ /\[([au])(\d+)]/;

print $ser_no is class \u$class\n;




John
-- 
use Perl;
program
fulfillment

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




Problem with GD::Graph

2006-09-15 Thread john
Hi all

 

I have installed the GD::Graph module and I tried to run the example using
this code

 

 

#!/usr/bin/perl -w

 

use GD::Graph;

 

@data = (

[1st,2nd,3rd,4th,5th,6th,7th, 8th, 9th],

[1,2,5,6,3,  1.5,1, 3, 4],

[ sort { $a = $b } (1, 2, 5, 6, 3, 1.5, 1, 3, 4) ]

  );

 

my $graph = GD::Graph::chart-new(400, 300);

 

 

 

$graph-set(

  x_label   = 'X Label',

  y_label   = 'Y label',

  title = 'Some simple graph',

  y_max_value   = 8,

  y_tick_number = 8,

  y_label_skip  = 2

  ) or die $graph-error;

 

my $gd = $graph-plot([EMAIL PROTECTED]) or die $graph-error;

 

open(IMG, 'file.png') or die $!;

  binmode IMG;

  print IMG $gd-png;

 

 

 

But the error that I receive is the following

 

Can't locate object method new via package GD::Graph::chart (perhaps you
forgot to load GD::Graph::chart?) at test2.pl line 11

 

I copied that example from the link
http://search.cpan.org/~bwarfield/GDGraph-1.4308/Graph.pm

 

Does anyone know what is going on?



Re: extracting several text from logs using regex

2006-09-15 Thread Mumia W.

On 09/14/2006 11:04 PM, Michael Alipio wrote:

Hi,

A log file contains several of these lines:

session.blablahbla
blablabla proto:6 blablabla srcip:90.0.0.1 blablabla
blablabla srcport:3243 blablabla dstport:23 blablabla

session.blablahbla
blablabla proto:6 blablabla srcip:90.0.0.1 blablabla
blablabla srcport:3243 blablabla dstport:23 blablabla

session.blablahbla
blablabla proto:6 blablabla srcip:90.0.0.1 blablabla
blablabla srcport:3243 blablabla dstport:23 blablabla

basically, for each session, I need to obtain:
srcip, srcport, dstip, dstport, then do something with
it, say put it in a table;

So far here's what I got: :-)


my $sessionlog = shift @ARGV;
my $sessioncounter = '0';
my $start;
my $srcip;
my $srcport;
my $dstip;
my $dstport;

open SESSIONLOGS, $sessionlog or die $!;
while (SESSIONLOGS){
  if (/^session/){
 $start = true;
 ++$sessioncounter;
  }

}
[...]


This is how I might do it; however, the dstip's are not in the 
 data you posted:


use strict;
use warnings;
use IO::Scalar;
my $data = q{
session.blabfirst
blablabla proto:6 blablabla srcip:90.0.0.1 blablabla
blablabla srcport:3243 blablabla dstport:23 blablabla

session.blabsecond
blablabla proto:6 blablabla srcip:90.0.0.2 blablabla
blablabla srcport:3244 blablabla dstport:23 blablabla

session.blabthird
blablabla proto:6 blablabla srcip:90.0.0.3 blablabla
blablabla srcport:3245 blablabla dstport:23 blablabla
};

local $/ = '';
my $fh = new IO::Scalar \$data;
while (my $record = $fh) {
my %extr;
for (qw(srcip srcport dstport dstip)) {
$extr{$_} = '';
$extr{$_} = $1 if $record =~ /$_:([\d.]+)/;
}
print $extr{srcip}|$extr{srcport}|$extr{dstip}|.
$extr{dstport}\n;
}
$fh-close;

--end program---

Notice that I set $/ to '' so that entire records would be 
grabbed at once.



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




Re: removing characters

2006-09-15 Thread Mumia W.

On 09/15/2006 12:54 AM, ubergoonz wrote:

Hi,

I have a certain variables of emplyee number which comes in the format of
[a000]  or [u000] {whereby 000 is some serial numbers}.

I would like to remove the enclosed [  ]  see if it is belong to class 
a or

u , i can do it as follow

$var = /\[//; $var = /\]//;
if ($var =~ '^a) {
  print $var is class A;
} elsfi ($var =~ '^u) {
  print '$var is class U;
}
$var = /a//; $var = /u//;

How can i remove the chars all in a single line? and write the code in a
more perl manner ?


regards
rexo



I can think of two good ways of doing this:

use strict;
use warnings;
use Data::Dumper;
my $string = '[a000] [u000]';

# Method 1:
my $str = $string;
$str =~ s/[][]//g;
print $str, \n;

# Method 2:
my @data = grep length, split /[][ ]/, $string;
print Dumper([EMAIL PROTECTED]);

I can't remember from where I got the [][] syntax. Perhaps it 
was from FMTEYEWTK for the perl faqs. Thank you whoever you are.







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




Re: Problem with GD::Graph

2006-09-15 Thread Owen Cook


-- 

On Fri, 15 Sep 2006, john wrote:

 Hi all
 
  
 
 I have installed the GD::Graph module and I tried to run the example using
 this code
 
  
 
  
 
 #!/usr/bin/perl -w
 
  
 
 use GD::Graph;
 
  
 
 @data = (
 
 [1st,2nd,3rd,4th,5th,6th,7th, 8th, 9th],
 
 [1,2,5,6,3,  1.5,1, 3, 4],
 
 [ sort { $a = $b } (1, 2, 5, 6, 3, 1.5, 1, 3, 4) ]
 
   );
 
  
 
 my $graph = GD::Graph::chart-new(400, 300);
 
  
 
  
 
  
 
 $graph-set(
 
   x_label   = 'X Label',
 
   y_label   = 'Y label',
 
   title = 'Some simple graph',
 
   y_max_value   = 8,
 
   y_tick_number = 8,
 
   y_label_skip  = 2
 
   ) or die $graph-error;
 
  
 
 my $gd = $graph-plot([EMAIL PROTECTED]) or die $graph-error;
 
  
 
 open(IMG, 'file.png') or die $!;
 
   binmode IMG;
 
   print IMG $gd-png;
 
  
 
  
 
  
 
 But the error that I receive is the following
 
  
 
 Can't locate object method new via package GD::Graph::chart (perhaps you
 forgot to load GD::Graph::chart?) at test2.pl line 11
 
  
 
 I copied that example from the link
 http://search.cpan.org/~bwarfield/GDGraph-1.4308/Graph.pm
 
  
 
 Does anyone know what is going on?
 




You need to replace chart with the type of chart, pie, points etc

Read perldoc GD::graph




Owen


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




RE: Problem with GD::Graph

2006-09-15 Thread john
I replace the crusial line with the one below

my $graph = GD::Graph::area-new(400, 300);

and I received the error

Can't locate object method new via package GD::Graph::area (perhaps you
forgot to load GD::Graph::area?) at test2.pl line 11

I think that all these type of plotting are included in the GD::Graph
module.






-Original Message-
From: Owen Cook [mailto:[EMAIL PROTECTED] 
Sent: Friday, September 15, 2006 10:45 AM
To: john
Cc: beginners@perl.org
Subject: Re: Problem with GD::Graph



-- 

On Fri, 15 Sep 2006, john wrote:

 Hi all
 
  
 
 I have installed the GD::Graph module and I tried to run the example using
 this code
 
  
 
  
 
 #!/usr/bin/perl -w
 
  
 
 use GD::Graph;
 
  
 
 @data = (
 
 [1st,2nd,3rd,4th,5th,6th,7th, 8th, 9th],
 
 [1,2,5,6,3,  1.5,1, 3, 4],
 
 [ sort { $a = $b } (1, 2, 5, 6, 3, 1.5, 1, 3, 4) ]
 
   );
 
  
 
 my $graph = GD::Graph::chart-new(400, 300);
 
  
 
  
 
  
 
 $graph-set(
 
   x_label   = 'X Label',
 
   y_label   = 'Y label',
 
   title = 'Some simple graph',
 
   y_max_value   = 8,
 
   y_tick_number = 8,
 
   y_label_skip  = 2
 
   ) or die $graph-error;
 
  
 
 my $gd = $graph-plot([EMAIL PROTECTED]) or die $graph-error;
 
  
 
 open(IMG, 'file.png') or die $!;
 
   binmode IMG;
 
   print IMG $gd-png;
 
  
 
  
 
  
 
 But the error that I receive is the following
 
  
 
 Can't locate object method new via package GD::Graph::chart (perhaps
you
 forgot to load GD::Graph::chart?) at test2.pl line 11
 
  
 
 I copied that example from the link
 http://search.cpan.org/~bwarfield/GDGraph-1.4308/Graph.pm
 
  
 
 Does anyone know what is going on?
 




You need to replace chart with the type of chart, pie, points etc

Read perldoc GD::graph




Owen


-- 
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: Problem with GD::Graph

2006-09-15 Thread Owen Cook


On Fri, 15 Sep 2006, john wrote:

 I replace the crusial line with the one below
 
 my $graph = GD::Graph::area-new(400, 300);
 
 and I received the error
 
 Can't locate object method new via package GD::Graph::area (perhaps you
 forgot to load GD::Graph::area?) at test2.pl line 11
 
 I think that all these type of plotting are included in the GD::Graph
 module.


Please read the documentation, you must say

use GD::Graph::moduleName;



Owen


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




Re: Problem with GD::Graph

2006-09-15 Thread Mumia W.

On 09/15/2006 02:24 AM, john wrote:

Hi all

 

I have installed the GD::Graph module and I tried to run the example using 
this code

[...]
my $graph = GD::Graph::chart-new(400, 300);
[...]


I haven't installed GD::Graph yet, but the description 
provided by 'aptitude' doesn't describe a GD::Graph::chart 
class, so there might not be a chart class. Try one of 
lines, bars, points, linespoints, mixed or pie.





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




Re: any traction on JPL?

2006-09-15 Thread Paul Johnson
On Thu, Sep 14, 2006 at 03:47:48PM -0700, Alan Campbell wrote:

   anything I can find on this mail list  googling shows only JPL
   references  3 years old. Is there any active work on making
   Java-Perl work together?

JPL has recently been removed from the development version of Perl.  You
probably want to be looking at Inline::Java.  There is a mailing list
for Inline on lists.perl.org.

-- 
Paul Johnson - [EMAIL PROTECTED]
http://www.pjcj.net

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




RE: Re[2]: Problem with GD::Graph

2006-09-15 Thread john
Well, I did that

Putting the use GD::Graph::area in the beginning
and now the error is

perl: relocation error:
/usr/lib/perl5/site_perl/5.8.0/i486-linux/auto/GD/GD.so: undefined symbol:
gdFontGetLarge





-Original Message-
From: Alexandru Maximciuc [mailto:[EMAIL PROTECTED] 
Sent: Friday, September 15, 2006 11:28 AM
To: john
Subject: Re[2]: Problem with GD::Graph

Hello john,

Friday, September 15, 2006, 11:09:10 AM, you wrote:

 I replace the crusial line with the one below

 my $graph = GD::Graph::area-new(400, 300);

 and I received the error

 Can't locate object method new via package GD::Graph::area (perhaps
you
 forgot to load GD::Graph::area?) at test2.pl line 11

 I think that all these type of plotting are included in the GD::Graph
 module.




did you put at the beginning of your script
  use GD::Graph::area;
???

-- 
Best regards,
 Alexandrumailto:[EMAIL PROTECTED]


--
This message was scanned for viruses by BitDefender for Linux Mail Servers.
For more information please visit http://www.bitdefender.com/



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




running through regexp matches ($1-$n)

2006-09-15 Thread Michael Alipio
Hi,

A log file contains several of these lines:

session.blablahbla
blablabla proto:6 blablabla srcip:90.0.0.1 blablabla
blablabla srcport:3243 blablabla dstport:23 blablabla

session.blablahbla
blablabla proto:6 blablabla srcip:90.0.0.1 blablabla
blablabla srcport:3243 blablabla dstport:23 blablabla

session.blablahbla
blablabla proto:6 blablabla srcip:90.0.0.1 blablabla
blablabla srcport:3243 blablabla dstport:23 blablabla

basically, for each session, I need to obtain:
srcip, srcport, dstip, dstport, then do something with
it, say put it in a table;

So far here's what I got: :-)


my $sessionlog = shift @ARGV;
my $sessioncounter = '0';
my $start;
my $srcip;
my $srcport;
my $dstip;
my $dstport;

open SESSIONLOGS, $sessionlog or die $!;
while (SESSIONLOGS){
  if (/^session/){
 $start = true;
 ++$sessioncounter;
  }

}

#the logic I am thinking of here is to:
#for every line, if it sees the word session and until
it sees a new one, then mark it as a beggining of a
session with $start. process the following lines, only
until it sees another session keyword. then store
all the corresponding regex it see into:
my $srcip;
my $srcport;
my $dstip;
my $dstport;

the problem is... I'm not sure how to do it. :-)
can you help we with just some few tips?
pleaaase...:-)

Thank you very much
-jay

__
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: Re[2]: Problem with GD::Graph

2006-09-15 Thread john
Well , tried to recompile the GD-2.35 and the tests failed. It cannot
recongised those functions.

I have installed all the required modules.




-Original Message-
From: Owen Cook [mailto:[EMAIL PROTECTED] 
Sent: Friday, September 15, 2006 12:47 PM
To: john
Cc: beginners@perl.org
Subject: RE: Re[2]: Problem with GD::Graph


On Fri, 15 Sep 2006, john wrote:

 Well, I did that
 
 Putting the use GD::Graph::area in the beginning
 and now the error is
 
 perl: relocation error:
 /usr/lib/perl5/site_perl/5.8.0/i486-linux/auto/GD/GD.so: undefined symbol:
 gdFontGetLarge



Well it would seem to be an build type problem and you are going to have
to sspecify what you got. Perl 5.8.0 seems a bit old as does the i486 type
build.

Have you tried rebuilding GD::Graph from source, that is probably the best
option.

How was the original GD:Graph installed, via a rpm? Un-rpm it and see if
you can build from source. Watch for errors and see where it is failing


 
Owen


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




Modules to extract calendar info from Exchange

2006-09-15 Thread William Paulsen \(W\)

Hi,

Is there a perl module(s) that can extract calendar infrom from an MS
Exchange server.  I need to extract appmnts, meetings, etc such that I
can SMS these message to a person(s) cellphone.   Which modules are
available, and how easy is it?

William


~~
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: bizarre fractional exponents math

2006-09-15 Thread Dr.Ruud
Bryan R Harris schreef:

 Can someone explain this behavior?

 % perl -e 'print -12.17**0.2, \n'
 -1.64838295714428
 % perl -e 'print (-12.17)**(0.2), \n'
 -12.17% perl -e 'print ((-12.17)**(0.2)), \n'
 nan%

Use perl -we ..., or perl -Mwarnings -e 

-- 
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: extracting several text from logs using regex

2006-09-15 Thread John W. Krahn
Michael Alipio wrote:
 Hi,

Hello,

 A log file contains several of these lines:
 
 session.blablahbla
 blablabla proto:6 blablabla srcip:90.0.0.1 blablabla
 blablabla srcport:3243 blablabla dstport:23 blablabla
 
 session.blablahbla
 blablabla proto:6 blablabla srcip:90.0.0.1 blablabla
 blablabla srcport:3243 blablabla dstport:23 blablabla
 
 session.blablahbla
 blablabla proto:6 blablabla srcip:90.0.0.1 blablabla
 blablabla srcport:3243 blablabla dstport:23 blablabla
 
 basically, for each session, I need to obtain:
 srcip, srcport, dstip, dstport, then do something with
 it, say put it in a table;

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

my $sessionlog = shift or die usage: $0 logfile\n;

open SESSIONLOGS, '', $sessionlog or die Cannot open '$sessionlog' $!;

$/ = '';  # Set paragraph mode

while ( SESSIONLOGS ) {
/   ^  session
(?= .*? srcip: (\S+) )
(?= .*? srcport: (\S+) )
(?= .*? dstip: (\S+) )
(?= .*? dstport: (\S+) )
/sx  printf %-15s %5s %-15s %5s\n, $1, $2, $3, $4;
}

__END__



John
-- 
use Perl;
program
fulfillment

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




RE: Re[2]: Problem with GD::Graph

2006-09-15 Thread john
Where could I find the installed DG version since it's no visible in the GD
man page.




-Original Message-
From: Owen Cook [mailto:[EMAIL PROTECTED] 
Sent: Friday, September 15, 2006 1:15 PM
To: john
Cc: beginners@perl.org
Subject: RE: Re[2]: Problem with GD::Graph


On Fri, 15 Sep 2006, john wrote:

 Well , tried to recompile the GD-2.35 and the tests failed. It cannot
 recongised those functions.
 
 I have installed all the required modules.
 
 
 
 
 -Original Message-
 From: Owen Cook [mailto:[EMAIL PROTECTED] 
 Sent: Friday, September 15, 2006 12:47 PM
 To: john
 Cc: beginners@perl.org
 Subject: RE: Re[2]: Problem with GD::Graph
 
 
 On Fri, 15 Sep 2006, john wrote:
 
  Well, I did that
  
  Putting the use GD::Graph::area in the beginning
  and now the error is
  
  perl: relocation error:
  /usr/lib/perl5/site_perl/5.8.0/i486-linux/auto/GD/GD.so: undefined
symbol:
  gdFontGetLarge
 
 
 
 Well it would seem to be an build type problem and you are going to have
 to sspecify what you got. Perl 5.8.0 seems a bit old as does the i486 type
 build.
 
 Have you tried rebuilding GD::Graph from source, that is probably the best
 option.
 
 How was the original GD:Graph installed, via a rpm? Un-rpm it and see if
 you can build from source. Watch for errors and see where it is failing
 
 
  
 Owen
 
 




Well I'd only be guessing, and it seems you may have some outdated
libraries. Like what version of GD do you have?

Have a look at http://www.boutell.com/gd/

Got a spare partition? you might be better installing the latest ubuntu
and getting all the GD stuff that way. At least it will be all compatible


Good luck


Owen



-- 
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: extracting several text from logs using regex

2006-09-15 Thread Dr.Ruud
Michael Alipio schreef:

 A log file contains several of these lines:

 session.blablahbla
 blablabla proto:6 blablabla srcip:90.0.0.1 blablabla
 blablabla srcport:3243 blablabla dstport:23 blablabla

 session.blablahbla
 blablabla proto:6 blablabla srcip:90.0.0.1 blablabla
 blablabla srcport:3243 blablabla dstport:23 blablabla

 session.blablahbla
 blablabla proto:6 blablabla srcip:90.0.0.1 blablabla
 blablabla srcport:3243 blablabla dstport:23 blablabla

How exact does this represent your logfile? What is on a single line,
are there blank lines in between?

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




Modules to extract calendar info from Exchange

2006-09-15 Thread William Paulsen \(W\)

Hi,

Is there a perl module(s) that can extract calendar infrom from an MS
Exchange server.  I need to extract appmnts, meetings, etc such that I
can SMS these message to a person(s) cellphone.   Which modules are
available, and how easy is it?

William


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

How to create XML files from simple plain text files?

2006-09-15 Thread sfantar
Hello All!

I would like to know how possible it is to create XML files from plain text 
files.
I have a huge number of text files I want to convert into XML format.
Is there any Perl modules for this purpose?

Thanks in advance for your help.

Accédez au courrier électronique de La Poste
sur www.laposte.net ou sur 3615 LAPOSTENET (0,34€ TTC /mn)
1 Giga de stockage gratuit – Antispam et antivirus intégrés




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




Access elements of a array of hases

2006-09-15 Thread Geetha Weerasooriya
Hi ,
 
I have an Array of Hashes   as follows:
 
@array = (
 { 'A'=1, 'B' =2, 'C'=3, 'D'=4}
{ 'A'=5, 'B' =6, 'C'=7, 'D'=8}
{ 'A'=9, 'B' =10, 'C'=11, 'D'=12}
{ 'A'=13, 'B' =14, 'C'=15, 'D'=16}
{ 'A'=17, 'B' =18, 'C'=19, 'D'=20}
{ 'A'=21, 'B' =22, 'C'=23, 'D'=24}
)
 
I have given a reference to this array in my script.
 
I want to do some calculation with only one key of each hash. For
example, I want to subtract from the value of key 'B' of last hash all
the other values of the same key into a one column like follows 
 
22-2  20   
22-6  16
22-10 12
22-14  8
22-18  4
22-22  0
 
Can you please tell me how to do this ? 
 
Kind regards,
 
Geetha
 


RANSAC method code for perl?

2006-09-15 Thread Saurabh Singhvi

Hi all,

I am in need of a module which implements

http://en.wikipedia.org/wiki/RANSAC

I searched on cpan but couldn't find any. Where
I can find it??

regards
Saurabh


Re: RANSAC method code for perl?

2006-09-15 Thread Saurabh Singhvi

Hi Lee,

Thanks for the reply. I searched around on span and google
but I couldn't find any of the pages of PDL having anything
on RANSAC. So if you could please specify where exactly
to look for, it'd be great.

thanks
Saurabh

On 9/15/06, Lee Goddard [EMAIL PROTECTED] wrote:


 Hi all,

 I am in need of a module which implements

 http://en.wikipedia.org/wiki/RANSAC

 I searched on cpan but couldn't find any. Where I can find it??

Saurabh

Try the PDL list: Perl Data Languae.

Lee
--

http://www.bbc.co.uk/
This e-mail (and any attachments) is confidential and may contain personal
views which are not the views of the BBC unless specifically stated.
If you have received it in error, please delete it from your system.
Do not use, copy or disclose the information in any way nor act in
reliance on it and notify the sender immediately.
Please note that the BBC monitors e-mails sent or received.
Further communication will signify your consent to this.




Re: bizarre fractional exponents math

2006-09-15 Thread Bryan R Harris


Thank you, everyone!

Note, it appears that the fifth root of -12.17 is not complex, try this:

% perl -wle '$_=(-1.648382957144284)**5; print'

... but I don't blame perl for not finding it.

Thanks for the tips on -wle, and for the info on print.  I'm not sure how
I'll do it, but I really need to remember those things.  This list is
awesome.

- Bryan





 Bryan R Harris wrote:
 
 Can someone explain this behavior?
 
 % perl -e 'print -12.17**0.2, \n'
 -1.64838295714428
 
 This means
 
   print(-(12.17 ** 0.2), \n)
 
 because exponentiation has a higher priority than unary minus. (See the table
 of
 priorities in perldoc perlop).
 
 % perl -e 'print (-12.17)**(0.2), \n'
 -12.17
 
 This means
 
   (print(-12.17)) ** 0.2, \n
 
 because list operators have a highrt priority than exponentiation.
 
 What this does is to print -12.17, and then evaluate the fifth root of the
 result of the call to print() which should be 1, and immediately discard this
 value. The newline string after the comma operator is simply thrown away, as
 if
 you'd written
 
   (print(-12.17)) ** 0.2;
   \n;
 
 % perl -e 'print ((-12.17)**(0.2)), \n'
 nan%
 
 This means
 
   print((-12.17) ** 0.2), \n
 
 and Perl prints 'nan' since the fifth root of -12.17 is a complex number. The
 newline is just thrown away as before..
 
 Yes, the \n isn't getting printed for some reason on the 2nd two examples.
 
 Because they're not within the print's parameter list.
 
 
 Bottom line:
 
 -12.17**0.2  == -1.65
 (-12.17)**(0.2) == -12.17
 ((-12.17)**(0.2)) == nan
 
 I have absolutely zero idea what could be going on here...  Please help!
 
 HTH,
 
 Rob



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




Re: Access elements of a array of hases

2006-09-15 Thread Rob Dixon

Geetha Weerasooriya wrote:


I have an Array of Hashes   as follows:

@array = (
 { 'A'=1, 'B' =2, 'C'=3, 'D'=4}
{ 'A'=5, 'B' =6, 'C'=7, 'D'=8}
{ 'A'=9, 'B' =10, 'C'=11, 'D'=12}
{ 'A'=13, 'B' =14, 'C'=15, 'D'=16}
{ 'A'=17, 'B' =18, 'C'=19, 'D'=20}
{ 'A'=21, 'B' =22, 'C'=23, 'D'=24}
)

I have given a reference to this array in my script.

I want to do some calculation with only one key of each hash. For
example, I want to subtract from the value of key 'B' of last hash all
the other values of the same key into a one column like follows

22-2  20
22-6  16
22-10 12
22-14  8
22-18  4
22-22  0

Can you please tell me how to do this ?


Hi Geetha

I'm not sure exactly how you want to handle these values, so I've written some
code that pulls the values you need out into an array @b and reproduces from it
the output you describe. Hopefully you can use this to do what it is you want.

Rob



use strict;
use warnings;

my @array = (
 { 'A'=1,  'B' =2,  'C'=3,  'D'=4  },
 { 'A'=5,  'B' =6,  'C'=7,  'D'=8  },
 { 'A'=9,  'B' =10, 'C'=11, 'D'=12 },
 { 'A'=13, 'B' =14, 'C'=15, 'D'=16 },
 { 'A'=17, 'B' =18, 'C'=19, 'D'=20 },
 { 'A'=21, 'B' =22, 'C'=23, 'D'=24 },
);

my @b = map $_-{B}, @array;

foreach (@b) {
 printf %-10s%2d\n, $b[-1]-$_, $b[-1] - $_;
}

**OUTPUT**

22-2  20
22-6  16
22-10 12
22-14  8
22-18  4
22-22  0

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




Re: Modules to extract calendar info from Exchange

2006-09-15 Thread Tom Phoenix

On 9/15/06, William Paulsen (W) [EMAIL PROTECTED] wrote:


Is there a perl module(s) that can extract calendar infrom from an MS
Exchange server.  I need to extract appmnts, meetings, etc such that I
can SMS these message to a person(s) cellphone.   Which modules are
available, and how easy is it?


Have you checked CPAN yet?

   http://search.cpan.org

Cheers!

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




Re: How to create XML files from simple plain text files?

2006-09-15 Thread Tom Phoenix

On 9/15/06, sfantar [EMAIL PROTECTED] wrote:


I would like to know how possible it is to create XML files from plain text
files. I have a huge number of text files I want to convert into XML format.
Is there any Perl modules for this purpose?


Have you checked CPAN yet?

   http://search.cpan.org/

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




Re: How to create XML files from simple plain text files?

2006-09-15 Thread SFantar

Tom Phoenix a écrit :

On 9/15/06, sfantar [EMAIL PROTECTED] wrote:

I would like to know how possible it is to create XML files from 
plain text
files. I have a huge number of text files I want to convert into XML 
format.

Is there any Perl modules for this purpose?


Have you checked CPAN yet?

   http://search.cpan.org/



Yes, I have already checked the CPAN but I haven't found yet what I am 
looking for.
Do you have to write my own script from scratch to convert plain text 
files into XML files?

Or Is there any module that does the job, even half-way?
Thanks for your help.

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




Re: How to create XML files from simple plain text files?

2006-09-15 Thread lawrence
 
 Yes, I have already checked the CPAN but I haven't found yet what I am 
 looking for.
 Do you have to write my own script from scratch to convert plain text 
 files into XML files?

Your question makes no sense.  XML matching what doctype?  What kind
of plain text?



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




Re: Access elements of a array of hases

2006-09-15 Thread John W. Krahn
Geetha Weerasooriya wrote:
 Hi ,

Hello,

 I have an Array of Hashes   as follows:
  
 @array = (
  { 'A'=1, 'B' =2, 'C'=3, 'D'=4}
 { 'A'=5, 'B' =6, 'C'=7, 'D'=8}
 { 'A'=9, 'B' =10, 'C'=11, 'D'=12}
 { 'A'=13, 'B' =14, 'C'=15, 'D'=16}
 { 'A'=17, 'B' =18, 'C'=19, 'D'=20}
 { 'A'=21, 'B' =22, 'C'=23, 'D'=24}
 )
  
 I have given a reference to this array in my script.
  
 I want to do some calculation with only one key of each hash. For
 example, I want to subtract from the value of key 'B' of last hash all
 the other values of the same key into a one column like follows 
  
 22-2  20   
 22-6  16
 22-10 12
 22-14  8
 22-18  4
 22-22  0
  
 Can you please tell me how to do this ? 


$ perl -le'
my @array = (
{ A =  1, B =  2, C =  3, D =  4 },
{ A =  5, B =  6, C =  7, D =  8 },
{ A =  9, B = 10, C = 11, D = 12 },
{ A = 13, B = 14, C = 15, D = 16 },
{ A = 17, B = 18, C = 19, D = 20 },
{ A = 21, B = 22, C = 23, D = 24 },
);
my $ref = [EMAIL PROTECTED];

for my $hash ( @$ref ) {
print $ref-[ -1 ]{ B } - $hash-{ B };
}
'
20
16
12
8
4
0




John
-- 
use Perl;
program
fulfillment

-- 
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 XML files from simple plain text files?

2006-09-15 Thread Mumia W.

On 09/15/2006 07:12 AM, sfantar wrote:

Hello All!

I would like to know how possible it is to create XML files from plain text 
files.
I have a huge number of text files I want to convert into XML format.
Is there any Perl modules for this purpose?
[...]


XML::Simple can do it.



--
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 XML files from simple plain text files?

2006-09-15 Thread Johnson, Reginald \(GTI\)
Mumia,
A good book that covers a lot of the basic stuff that you want to know
is XML and Perl by Mark Riehl and Llya Sterin. I am reading it know.
Within the first two chapters itcovers the question you are asking
about.


-Original Message-
From: Mumia W. [mailto:[EMAIL PROTECTED] 
Sent: Friday, September 15, 2006 2:13 PM
To: Beginners List
Subject: Re: How to create XML files from simple plain text files?


On 09/15/2006 07:12 AM, sfantar wrote:
 Hello All!
 
 I would like to know how possible it is to create XML files from plain
text files.
 I have a huge number of text files I want to convert into XML format.
 Is there any Perl modules for this purpose?
 [...]

XML::Simple can do it.



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


If you are not an intended recipient of this e-mail, please notify the sender, 
delete it and do not read, act upon, print, disclose, copy, retain or 
redistribute it. Click here for important additional terms relating to this 
e-mail. http://www.ml.com/email_terms/


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




Re: running through regexp matches ($1-$n)

2006-09-15 Thread D. Bolliger
Michael Alipio am Freitag, 15. September 2006 09:30:
 Hi,

 A log file contains several of these lines:

As formatted below? One log entry consists of three lines, followed by an 
empty line?

 session.blablahbla
 blablabla proto:6 blablabla srcip:90.0.0.1 blablabla
 blablabla srcport:3243 blablabla dstport:23 blablabla

 session.blablahbla
 blablabla proto:6 blablabla srcip:90.0.0.1 blablabla
 blablabla srcport:3243 blablabla dstport:23 blablabla

 session.blablahbla
 blablabla proto:6 blablabla srcip:90.0.0.1 blablabla
 blablabla srcport:3243 blablabla dstport:23 blablabla

 basically, for each session, I need to obtain:
 srcip, srcport, dstip, dstport, then do something with
 it, say put it in a table;

 So far here's what I got: :-)

Some remarks to what you already have (hint to your actual problem at the end 
of this post)

 my $sessionlog = shift @ARGV;

# with error msg:
my $sessionlog = shift @ARGV or die argument (log file name) missing!;

perldoc -f open

 my $sessioncounter = '0';

# an integer, not a string:
my $sessioncounter = 0;

 my $start;
 my $srcip;
 my $srcport;
 my $dstip;
 my $dstport;

# shorter alternative:
my ($start, $srcip, $srcport, $dstip, $dstport);

# btw, $start has a too wide lexical scoping considered its use (with not much 
sense) below.

perldoc -f my

 open SESSIONLOGS, $sessionlog or die $!;

# no need to put a single var in double quotes;
# more verbose dying; more explicit file open for reading:
open SESSIONLOGS, '', $sessionlog or die can't open log file: $!;

 while (SESSIONLOGS){
   if (/^session/){
  $start = true;
  ++$sessioncounter;
   }
 }

This has not much sense except to count the number of (multi line) log 
entries. $start is set, overwritten on every first entry line, and never used 
(in the presented code excerpt). After the while loop, it will simply be 
false, if the log is not empty and its format correct.

 #the logic I am thinking of here is to:
 #for every line, if it sees the word session and until
 it sees a new one, then mark it as a beggining of a
 session with $start. process the following lines, only
 until it sees another session keyword. then store
 all the corresponding regex it see into:
 my $srcip;
 my $srcport;
 my $dstip;
 my $dstport;

 the problem is... I'm not sure how to do it. :-)
 can you help we with just some few tips?
 pleaaase...:-)

The key idea is to redefine the meaning of a line. You can read a file 
in paragraph mode (read three lines at a time), see

perldoc -q 'How can I read in a file by paragraphs?'
perldoc perlvar

and then use one regex to catch all of the required data (per entry).

perldoc perlre 
and others 

Hope this helps

Dani

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




Re: compiling PERL programs

2006-09-15 Thread hOURS
Hi everyone,
  I posed a question about compiling  a while ago and got this response 
(below).   It occurred to me that some of the text looked like things one might 
 type into the window (a DOS window I believe it's called) that I run PERL  
programs from.  When I typed in perldoc  perlcompile I got a ton of 
information.   The most interesting part was this:
  
To turn a Perl program into executable byte code, you can use 'perlcc' with the 
'-b' switch:
  
  perlcc –b myperlprogram.pl
  Very exciting - that's exactly what  I want!  So I whipped up a silly 
little  2 line program to try as a test of this called bytecodetry.pl.  I typed 
in perlcc -b bytecodetry.pl and got  the following results:
  1) I saw this in the DOS window:
  -
  Compiling bytecodetry.pl
  -
  Making Bytecode (bytecodetry.plc)  for bytecodetry.pl!
  C:\Perl\bin\Perl.exe -IC:/Perl/lib -IC:/Perl/site/lib -I. -MB::Stash -c   
bytecodetry.pl
  2) Despite a blinking cursor on the  next line, the computer became 
almost entirely non-functional.  A window called MS-DOS prompt appeared,  which 
said:
  This program has performed an  illegal operation and will be terminated.  
 Quit all programs, and then restart your computer.
  If the program consistently  encounters problems, click the Start button, 
then select Help, Troubleshooting,  and 'If you have trouble running MS-DOS 
programs'.
  I could respond with OK or get  Details.  The details were:
  The program encountered a general  protection exception
  Fault location: 0028:0003
  Interrupts in service: None
  3) The computer made a file called  bytecodetry.plc.  That file had 
one  line:
  #!C:\Perl\bin\Perl.exe_use  ByteLoader 0.03;_
  (Only the underscores weren't  underscores, they were solid blocks, which 
seem to represent returns, because  that's what they became when I cut and 
pasted it.)  Despite a couple zeroes near the end there, that doesn't look  
very binary to me.  What's that all  about?
  Any help would be appreciated.  Why is this illegal?  Did I get byte 
code?  If so where is it?
  
  Fred Kittelmann
hOURS wrote:
 Hi all,

Hello,

 I'd be interested in compiling programs I write in PERL.  This is
 possible, right?  I see occasional mention of such here and there
 but can't seem to find information on how it might be done.  I
 assume one would need appropriate software, right, a compiler?
 Is such available open source?

perl *is* a compiler.   :-)

perldoc perlcompile

perldoc -q How can I compile my Perl program into byte code or C



John
-- 
use Perl;
program
fulfillment

-- 
  


Fred Kittelmann
hOURS
215-551-1490
www.hoursystem.net

-
Do you Yahoo!?
 Get on board. You're invited to try the new Yahoo! Mail.

Re: Access elements of a array of hases

2006-09-15 Thread D. Bolliger
Geetha Weerasooriya am Freitag, 15. September 2006 15:52:
 Hi ,

 I have an Array of Hashes   as follows:

 @array = (
  { 'A'=1, 'B' =2, 'C'=3, 'D'=4}
 { 'A'=5, 'B' =6, 'C'=7, 'D'=8}
 { 'A'=9, 'B' =10, 'C'=11, 'D'=12}
 { 'A'=13, 'B' =14, 'C'=15, 'D'=16}
 { 'A'=17, 'B' =18, 'C'=19, 'D'=20}
 { 'A'=21, 'B' =22, 'C'=23, 'D'=24}
 )

 I have given a reference to this array in my script.

 I want to do some calculation with only one key of each hash. For
 example, I want to subtract from the value of key 'B' of last hash all
 the other values of the same key into a one column like follows

 22-2  20
 22-6  16
 22-10 12
 22-14  8
 22-18  4
 22-22  0

 Can you please tell me how to do this ?

Hi Geetha (again :-)

Here's a slightly shorter version of J.W.Krahn's:

#!/usr/bin/perl

use strict;
use warnings;

my @array = (
{ A =  1, B =  2, C =  3, D =  4 },
{ A =  5, B =  6, C =  7, D =  8 },
{ A =  9, B = 10, C = 11, D = 12 },
{ A = 13, B = 14, C = 15, D = 16 },
{ A = 17, B = 18, C = 19, D = 20 },
{ A = 21, B = 22, C = 23, D = 24 },
);

# avoids multiple recalculation of the same value:
#
my $the_main_value=$array[ -1 ]-{ B };


for my $hash ( @array ) {
print $the_main_value - $hash-{ B }, \n;
}

__END__


Suppose you want to use this principle for several arrays, you can make a 
procedure:

#!/usr/bin/perl

use strict;
use warnings;

my @array = (
#...
   );


sub my_calculation {
  my $array_ref=shift;

  my $the_one_value=$array_ref-[ -1 ]-{ B };

  for my $hash ( @$array_ref ) {
  print $the_one_value - $hash-{ B }, \n;
  }
}

my_calculation ([EMAIL PROTECTED]);

__END__

maybe you want to generalize the sub a bit:

# ...
sub my_calculation {
  my ($array_ref, $keyname)[EMAIL PROTECTED];

  my $the_one_value=$array_ref-[ -1 ]-{ $keyname };

  for my $hash ( @$array_ref ) {
  print $the_one_value - $hash-{ $keyname }, \n;
  }
}
# ...
my_calculation ([EMAIL PROTECTED], 'B');

__END__

greets

Dani

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




Re: Modules to extract calendar info from Exchange

2006-09-15 Thread D. Bolliger
William Paulsen (W) am Freitag, 15. September 2006 13:36:
 Hi,

Hi

 Is there a perl module(s) that can extract calendar infrom from an MS
 Exchange server.  I need to extract appmnts, meetings, etc such that I
 can SMS these message to a person(s) cellphone.   Which modules are
 available, and how easy is it?

No idea (and no other answers), but you could search on http://search.cpan.org 
with one of the keywords you're interested in. Maybe somethings shows up...

Hope this helps

Dani

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




Re: Modules to extract calendar info from Exchange

2006-09-15 Thread D. Bolliger
Sorry:

  Is there a perl module(s) that can extract calendar infrom from an MS
  Exchange server.  I need to extract appmnts, meetings, etc such that I
  can SMS these message to a person(s) cellphone.   Which modules are
  available, and how easy is it?

 No idea (and no other answers)
[...]
... to your *second* post

Dani

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




RE: Modules to extract calendar info from Exchange

2006-09-15 Thread Wagner, David --- Senior Programmer Analyst --- WGO
 
Can't answer the first, but on the second:

I send text messages to my ATT cingular phone using sendmail to
send the text. This gives me heads up when I have problems. Now I am
also starting sending to another phone number using cingular, but it is
a blackberry. This user receives the text, but it is messed up. I never
got around to correcting. For cinuglar node in my location, it is
@mmode.net and the other cingular is in Colorado and has a completely
different node ( @mobile.mycingular.com ).

It can be done and I have been running in this mode for 5 or
more years at least.

  If you have any problems or questions, please let me know.

 Thanks.

  Wags ;)
David R Wagner
Senior Programmer Analyst
FedEx Freight
1.408.323.4225x2224 TEL
1.408.323.4449   FAX
http://fedex.com/us 

-Original Message-
From: D. Bolliger [mailto:[EMAIL PROTECTED] 
Sent: Friday, September 15, 2006 13:26
To: beginners@perl.org
Subject: Re: Modules to extract calendar info from Exchange

Sorry:

  Is there a perl module(s) that can extract calendar infrom from an 
  MS Exchange server.  I need to extract appmnts, meetings, etc such
that I
  can SMS these message to a person(s) cellphone.   Which modules are
  available, and how easy is it?

 No idea (and no other answers)
[...]
... to your *second* post

Dani

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



**
This message contains information that is confidential and proprietary to FedEx 
Freight or its affiliates.  It is intended only for the recipient named and for 
the express  purpose(s) described therein.  Any other use is prohibited.
**


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




Re: Access elements of a array of hases

2006-09-15 Thread Xavier Mas i Ramón
A Divendres 15 Setembre 2006 22:21, D. Bolliger va escriure:
 Geetha Weerasooriya am Freitag, 15. September 2006 15:52:
  Hi ,
 
  I have an Array of Hashes   as follows:
 
  @array = (
   { 'A'=1, 'B' =2, 'C'=3, 'D'=4}
  { 'A'=5, 'B' =6, 'C'=7, 'D'=8}
  { 'A'=9, 'B' =10, 'C'=11, 'D'=12}
  { 'A'=13, 'B' =14, 'C'=15, 'D'=16}
  { 'A'=17, 'B' =18, 'C'=19, 'D'=20}
  { 'A'=21, 'B' =22, 'C'=23, 'D'=24}
  )
 
  I have given a reference to this array in my script.
 
  I want to do some calculation with only one key of each hash. For
  example, I want to subtract from the value of key 'B' of last hash all
  the other values of the same key into a one column like follows
 
  22-2  20
  22-6  16
  22-10 12
  22-14  8
  22-18  4
  22-22  0
 
  Can you please tell me how to do this ?

 Hi Geetha (again :-)

 Here's a slightly shorter version of J.W.Krahn's:

 #!/usr/bin/perl

 use strict;
 use warnings;

 my @array = (
 { A =  1, B =  2, C =  3, D =  4 },
 { A =  5, B =  6, C =  7, D =  8 },
 { A =  9, B = 10, C = 11, D = 12 },
 { A = 13, B = 14, C = 15, D = 16 },
 { A = 17, B = 18, C = 19, D = 20 },
 { A = 21, B = 22, C = 23, D = 24 },
 );

 # avoids multiple recalculation of the same value:
 #
 my $the_main_value=$array[ -1 ]-{ B };


 for my $hash ( @array ) {
 print $the_main_value - $hash-{ B }, \n;
 }

 __END__


 Suppose you want to use this principle for several arrays, you can make a
 procedure:

 #!/usr/bin/perl

 use strict;
 use warnings;

 my @array = (
 #...
);


 sub my_calculation {
   my $array_ref=shift;

   my $the_one_value=$array_ref-[ -1 ]-{ B };

   for my $hash ( @$array_ref ) {
   print $the_one_value - $hash-{ B }, \n;
   }
 }

 my_calculation ([EMAIL PROTECTED]);

 __END__

 maybe you want to generalize the sub a bit:

 # ...
 sub my_calculation {
   my ($array_ref, $keyname)[EMAIL PROTECTED];

   my $the_one_value=$array_ref-[ -1 ]-{ $keyname };

   for my $hash ( @$array_ref ) {
   print $the_one_value - $hash-{ $keyname }, \n;
   }
 }
 # ...
 my_calculation ([EMAIL PROTECTED], 'B');

 __END__

 greets

 Dani

To access an elements of an array of hashes, do like: 
print $array[4]{A},\n;#is value 17.

-- 
Xavier Mas

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




RE: Re[2]: Problem with GD::Graph

2006-09-15 Thread Owen Cook


-- 

On Fri, 15 Sep 2006, john wrote:

 Where could I find the installed DG version since it's no visible in the GD
 man page.
 



/usr/bin/gdlib-config --version

but you might want to read

/usr/bin/gdlib-config --help




Owen


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




Re: compiling PERL programs

2006-09-15 Thread Jack Faley ( The Tao of Jack )

On 9/15/06, hOURS [EMAIL PROTECTED] wrote:


Hi everyone,
  I posed a question about compiling  a while ago and got this
response (below).   It occurred to me that some of the text looked like
things one might  type into the window (a DOS window I believe it's called)
that I run PERL  programs from.  When I typed in perldoc  perlcompile I
got a ton of information.   The most interesting part was this:

To turn a Perl program into executable byte code, you can use 'perlcc'
with the '-b' switch:

  perlcc –b myperlprogram.pl
  Very exciting - that's exactly what  I want!  So I whipped up a
silly little  2 line program to try as a test of this called
bytecodetry.pl.  I typed in perlcc -b bytecodetry.pl and got  the
following results:
  1) I saw this in the DOS window:
  -
  Compiling bytecodetry.pl
  -
  Making Bytecode (bytecodetry.plc)  for bytecodetry.pl!
  C:\Perl\bin\Perl.exe -IC:/Perl/lib -IC:/Perl/site/lib -I. -MB::Stash
-c   bytecodetry.pl
  2) Despite a blinking cursor on the  next line, the computer
became almost entirely non-functional.  A window called MS-DOS prompt
appeared,  which said:
  This program has performed an  illegal operation and will be
terminated.   Quit all programs, and then restart your computer.
  If the program consistently  encounters problems, click the Start
button, then select Help, Troubleshooting,  and 'If you have trouble running
MS-DOS programs'.
  I could respond with OK or get  Details.  The details were:
  The program encountered a general  protection exception
  Fault location: 0028:0003
  Interrupts in service: None
  3) The computer made a file called  bytecodetry.plc.  That file
had one  line:
  #!C:\Perl\bin\Perl.exe_use  ByteLoader 0.03;_
  (Only the underscores weren't  underscores, they were solid blocks,
which seem to represent returns, because  that's what they became when I cut
and pasted it.)  Despite a couple zeroes near the end there, that doesn't
look  very binary to me.  What's that all  about?
  Any help would be appreciated.  Why is this illegal?  Did I get
byte code?  If so where is it?

  Fred Kittelmann
hOURS wrote:
 Hi all,

Hello,

 I'd be interested in compiling programs I write in PERL.  This is
 possible, right?  I see occasional mention of such here and there
 but can't seem to find information on how it might be done.  I
 assume one would need appropriate software, right, a compiler?
 Is such available open source?

perl *is* a compiler.   :-)

perldoc perlcompile

perldoc -q How can I compile my Perl program into byte code or C



John
--
use Perl;
program
fulfillment

--



Fred Kittelmann
hOURS
215-551-1490
www.hoursystem.net

-
Do you Yahoo!?
Get on board. You're invited to try the new Yahoo! Mail.





I assume you want this to execute this perl code and run independent of Perl
being installed, not just obfuscate your code so people cant read the
source? Did you try google?

PAR may solve your probem, though I don't explicitly know what you need or
why:
http://par.wikia.com/wiki/Main_Page
(wiki with links to CPAN)

It looks like sourceforge has an open-source project for it named perlbin.
http://perlbin.sourceforge.net/perlbin-0.01.html

It also looks like people have had lots of trouble trying to get perlcc to
work.
Depending on how many times you will actually need to do this it may not be
worth figuring out all your flags for perlcc. You might want to try what
this person did:
http://www.vdomck.org/blog/2005/09/23/perl-scripts-for-perl-less-people/

I know Ive seen commercial utilities to do this and that always puzzled me.
Now I see why , the perlcc -B  failed to compile my perl scripts as well.
Researching it, indicates its experimental and was probably started as a
path to turn the perl source into C. The few people I saw that had finally
gotten it to work used a lot of flags.There are dependencies.
ActiveState's Dev Kit has the ability to do this and a 21 day trial:
http://www.activestate.com/Products/Perl_Dev_Kit/

perl2exe is the first one I think I ever saw ( commercial )
http://www.indigostar.com/perl2exe.htm

HTH