Re: regex...

2006-01-10 Thread Tom Phoenix
On 1/9/06, Tom Allison <[EMAIL PROTECTED]> wrote:
> I'm trying to capture the base URL and "everything after that"

You probably want to use the URI module, or another module.

http://search.cpan.org/~gaas/URI-1.35/URI.pm

Hope this helps!

--Tom Phoenix
Stonehenge Perl Training

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




Re: regex...

2006-01-10 Thread Tom Phoenix
On 1/9/06, Tom Allison <[EMAIL PROTECTED]> wrote:
> Tom Allison wrote:

> $string =~ /(?:(A|B))/   WORKS
> $string =~ m|(?:(A|B))|  DOES NOT WORK
> $string =~ m%(?:http://)%;  ALSO WORKS

The m// operator is a quoting construct. The general rule is that,
after the initial m, you may use any punctuation mark for the start
and end of your pattern match. If you use a left-mark to start, the
end is the corresponding right-mark; if the mark isn't one of these
four < ( [ { then the end is the same as the start. If you wish to use
the end mark inside the quoted section, you must backslash it.

Or, better yet, choose a delimiter which won't cause you troubles. One
of my favorites is #, because it uses a lot of ink (so it's easy for
the eye to pick out in the line) and because I hardly ever need it in
my patterns. Another good choice is one of the paired ones. Because
parentheses, square brackets, and curly braces are generally paired
inside patterns, the can be good choices for the outer delimiters as
well. (Perl's parser keeps count of the nested delimiters.)

That's why your second example above fails: The parser sees the
internal | character as the end of the pattern, even though the
parentheses aren't balanced there. Human-brain parsers tend to get
this parsing wrong. :-)

Hope this helps!

--Tom Phoenix
Stonehenge Perl Training

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




GD Graph

2006-01-10 Thread Aditi Gupta
Hello Everybody,

Is there a way to plot each point separately on a 2D plot using GD::Graph
instead of passing the two dimensional array? I want to color differently
certain data points in the plot but I couln't find a way to do that.

Thanks in advance,
Best Wishes
Aditi


Obtaining complete Unix command line that evoked script as string

2006-01-10 Thread Grant Jacobs

Item: Obtaining complete Unix command line that evoked script as a string

If there is a more appropriate list for this, let me know; the other 
perl lists I've seen seem to specialised for this.


I'm trying to get the complete command line that invoked a script as 
a string, that is the output of 'history 1'. Note this is not just 
the arguments of the call to the script, but everything including 
pipes and redirects, etc., e.g.


  echo -n "Starting..." ; more some-stuff | \
doStuff.pl - 3 > save-here.out ; echo "done."

Ideally the perl interpreter would grab the complete command line as 
its evoked and I'd access this via a variable. As this seem 
problematic, more realistically, ideally the shell should maintain a 
"current command" variable in the same fashion as the CWD variable, 
which can then be exported and read. AFAIK this does exist... (I see 
at the bottom of the bash FAQ that better environment variable 
support of perl is on hopeful feature to be added... one day; I'd 
very much like to see this.)


So... any ideas on something that does work, or am I just plain stuck?

I'm using the bash shell for what its worth. This may appear to be a 
bash question, but I'm hoping for a perlish solution if possible!



You can achieve this in an ugly unreliable fashion by having the 
caller set up an environment variable and read this in within the 
scripts, e.g.


  THISCMD=`history 1` ; doStuff.pl first-time

(and have doStuff read in $THISCMD)

But if the caller doesn't set up the environment variable on any 
given command line, the previous value is used which is plain wrong. 
Basically its untrustworthy, defeating my purpose for this, and there 
doesn't seem to be any particularly easy way to make it trustworthy. 
In any event, its also plain ugly!
Using bash's PROMPT_COMMAND to clear the value doesn't help, as this 
doesn't apply if the command lines are within a non-interactive 
script.



Grant

--
---
Grant Jacobs Ph.D. BioinfoTools
ph. +64 3 478 0095  (office, after 10am)   PO Box 6129,
or  +64 27 601 5917 (mobile)   Dunedin,
[EMAIL PROTECTED]   NEW ZEALAND.
   Bioinformatics tools: deriving knowledge from biological data
Bioinformatics tools - software development - consulting - training
 15 years experience in bioinformatics ready to solve your problem
Check out the website for more details: http://www.bioinfotools.com

The information contained in this mail message is  confidential and
may be legally privileged.  Readers of this message who are not the
intended recipient are hereby notified that any use, dissemination,
distribution or reproduction of this message is prohibited.  If you
have received this message in error please notify the sender immed-
iately and destroy the original message.  This applies also to  any
attached documents.

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




how to change working directory

2006-01-10 Thread Mayank Ahuja
Hi Could you please let me know how to change the working directory without going under through setting the path variable process.I am using the following code.use warnings;use strict;use Cwd;chdir ('/user/bin') or die can not change the directory.if there is only one way then let me know how do we set the variable $ENV{HOME}.With warm regardsMayank

Byte array

2006-01-10 Thread jeffrey . ramsey
I'm new to Perl and am trying to set a variable length byte array that is
passed to a socket as a string for output. I have the following which works,
but the commented out code doesn't.  What am I doing wrong?  Thanks.
use IO::Socket;
use Time::HiRes qw(usleep ualarm gettimeofday tv_interval);
my $sock = new IO::Socket::INET( PeerAddr => '10.10.2.141', PeerPort =>
'5', Proto => 'udp' );
die "no socket\n" unless $sock;
$totalNumPkts = 1;
$pktSize = 512;
$dataVal = 'U';
$iPkt = "1";
for ( $i = 1; $i < $pktSize; $i++ )
{
$iPkt += "1";
}
$startTime = Time::HiRes::time;
for ( $i = 1; $i <= $totalNumPkts; $i++ )
{
print "sending msg ..";
$sock->print( "Hello\n" );
#$sock->print( $iPkt );
}
$endTime = Time::HiRes::time;
$totalTime = $endTime - $startTime;
printf( " st %f end %f total time=%f time/pkt=%f\n", $startTime, $endTime,
$totalTime, $totalTime / 
$totalNumPkts );
printf("done\n");
close( $sock );



RE: GD Graph

2006-01-10 Thread Ryan Frantz


> -Original Message-
> From: Aditi Gupta [mailto:[EMAIL PROTECTED]
> Sent: Tuesday, January 10, 2006 4:16 AM
> To: Perl Beginners
> Subject: GD Graph
> 
> Hello Everybody,

Howdy,

> 
> Is there a way to plot each point separately on a 2D plot using
GD::Graph
> instead of passing the two dimensional array? I want to color
differently
> certain data points in the plot but I couln't find a way to do that.
> 
> Thanks in advance,
> Best Wishes
> Aditi

Read the GD::Graph documentation at search.cpan.org and you'll find
this:

*from http://search.cpan.org/~bwarfield/GDGraph-1.4305/Graph.pm*

dclrs (short for datacolours)

This controls the colours for the bars, lines, markers, or pie
slices. This should be a reference to an array of colour names as
defined in GD::Graph::colour (perldoc GD::Graph::colour for the names
available).

$graph->set( dclrs => [ qw(green pink blue cyan) ] );

The first (fifth, ninth) data set will be green, the next pink, etc.

A colour can be undef, in which case the data set will not be drawn.
This can be useful for cumulative bar sets where you want certain data
series (often the first one) not to show up, which can be used to
emulate error bars (see examples 1-7 and 6-3 in the distribution).

Default: [ qw(lred lgreen lblue lyellow lpurple cyan lorange) ]

ry

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




Re: how to change working directory

2006-01-10 Thread Leif Ericksen
If you are running your script as a given user the script should
'inherit' the environment of the user that is is being run as.  IF You
run as a daemon it should 'inherit' the environment of the user that
started the script.  If your script issues a chroot command all bets are
off since.

To set the environment as I found, I think it was in the Perl Cook Book
as I am working on a few scripts both for pleasure and work I found
this:   $ENV{PATH} = '/bin:/sbin:/usr/bin:/usr/sbin';

IMHO:  It is always a good idea to set your scripts with a path that you
want them to have rather than trusting an 'inheritance' factor.
Also if your script is to be run by many, and possibly have a net
connection it would be a good idea to further restrict with chroot.

--
Leif Ericksen
On Wed, 2006-01-11 at 04:21 +0630, Mayank Ahuja wrote:
> 
> Hi 
> 
> Could you please let me know how to change the working directory
> withoutgoing under through settingthe path variable process.
> 
> I am using the following code.
> 
> use warnings;
> 
> use strict;
> 
> use Cwd;
> 
> chdir ('/user/bin') or die can not change the directory.
> 
> if there is only one way then let me know how do we set the variable
> $ENV{HOME}.
> 
> With warm regards
> 
> Mayank
> 
-- 
Leif Ericksen <[EMAIL PROTECTED]>


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




Re: Byte array

2006-01-10 Thread Shawn Corey

[EMAIL PROTECTED] wrote:

I'm new to Perl and am trying to set a variable length byte array that is
passed to a socket as a string for output. I have the following which works,
but the commented out code doesn't.  What am I doing wrong?  Thanks.
use IO::Socket;
use Time::HiRes qw(usleep ualarm gettimeofday tv_interval);
my $sock = new IO::Socket::INET( PeerAddr => '10.10.2.141', PeerPort =>
'5', Proto => 'udp' );
die "no socket\n" unless $sock;
$totalNumPkts = 1;
$pktSize = 512;
$dataVal = 'U';
$iPkt = "1";
for ( $i = 1; $i < $pktSize; $i++ )
{
$iPkt += "1";
}


This loop can be replaced with: $iPkt = 513;
Or do you want a string of 512 ones? $iPkt = '1' x 512;
You should print out $iPkt to make sure it contains what you think it 
does: printf "%5d %s\n", length($iPkt), $iPkt;



$startTime = Time::HiRes::time;
for ( $i = 1; $i <= $totalNumPkts; $i++ )
{
print "sending msg ..";
$sock->print( "Hello\n" );
#$sock->print( $iPkt );
}
$endTime = Time::HiRes::time;
$totalTime = $endTime - $startTime;
printf( " st %f end %f total time=%f time/pkt=%f\n", $startTime, $endTime,
$totalTime, $totalTime / 
$totalNumPkts );

printf("done\n");
close( $sock );




--

Just my 0.0002 million dollars worth,
   --- Shawn

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

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

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




Re: how to change working directory

2006-01-10 Thread JupiterHost.Net



Mayank Ahuja wrote:


Hi

Could you please let me know how to change the working directory 
without going under through setting the path variable process.


Not sure what "going under through setting the path variable process" 
means and/or what it has to do with chdir???


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




Re: Byte array

2006-01-10 Thread John Doe
[EMAIL PROTECTED] am Dienstag, 10. Januar 2006 14.08:
> I'm new to Perl and am trying to set a variable length byte array that is
> passed to a socket as a string for output. I have the following which
> works, but the commented out code doesn't.  What am I doing wrong?  Thanks.

Don't forget to put

use warnings;
use strict;

> use IO::Socket;
> use Time::HiRes qw(usleep ualarm gettimeofday tv_interval);
> my $sock = new IO::Socket::INET( PeerAddr => '10.10.2.141', PeerPort =>
> '5', Proto => 'udp' );
> die "no socket\n" unless $sock;
> $totalNumPkts = 1;
> $pktSize = 512;
> $dataVal = 'U';

$dataVal is never used.


If you want a string consisting of 1's, you can't use the + operator. In perl, 
strings are concatanated with the . operator, see

perldoc perlop

In your case, there is even a simpler way to produce a string of char $c of 
lenght $x:

> $iPkt = "1";
> for ( $i = 1; $i < $pktSize; $i++ )
> { $iPkt += "1"; }

$iPkt = '1' x $pktSize;

> $startTime = Time::HiRes::time;

> for ( $i = 1; $i <= $totalNumPkts; $i++ )

or:

  for (1..$totalNumPkts)

since you don't use $i in the loop.

> {
> print "sending msg ..";
> $sock->print( "Hello\n" );
> #$sock->print( $iPkt );
> }
> $endTime = Time::HiRes::time;
> $totalTime = $endTime - $startTime;
> printf( " st %f end %f total time=%f time/pkt=%f\n", $startTime, $endTime,
> $totalTime, $totalTime /
> $totalNumPkts );
> printf("done\n");
> close( $sock );

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




Re: Obtaining complete Unix command line that evoked script as string

2006-01-10 Thread JupiterHost.Net



Grant Jacobs wrote:


Item: Obtaining complete Unix command line that evoked script as a string


use Unix::PID;

my $pid = Unix::PID->new();
print 'The kernel says I am: ' . $pid->get_command($$);

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




Re: Byte array

2006-01-10 Thread Dr.Ruud
[EMAIL PROTECTED] schreef:


What the others wrote, and:

> my $sock = new IO::Socket::INET( PeerAddr => '10.10.2.141', PeerPort
> => '5', Proto => 'udp' );
> die "no socket\n" unless $sock;

my $sock = new IO::Socket::INET( PeerAddr => '10.10.2.141'
   , PeerPort => '5'
   , Proto=> 'udp' )
or die "no socket $!";


> $sock->print( "Hello\n" );

$sock->print("Hello\n")
or die "no Hello $!";


> printf("done\n");
> close( $sock );

close($sock)
or die "no close $!";

printf("done\n");

-- 
Affijn, Ruud

"Gewoon is een tijger."


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




Re: Byte array

2006-01-10 Thread John Doe
John Doe am Dienstag, 10. Januar 2006 15.06:
> [EMAIL PROTECTED] am Dienstag, 10. Januar 2006 14.08:
> > I'm new to Perl and am trying to set a variable length byte array that is
> > passed to a socket as a string for output. I have the following which
> > works, but the commented out code doesn't.  What am I doing wrong? 
> > Thanks.
>
> Don't forget to put
>
>   use warnings;
>   use strict;
>
[...]

> > John:
> > 
> > Thanks very much.  That did the trick, except I get tons of errors when I
> > include "use strict" like:
> > 
> > Global symbol "$totalNumPkts" requires explicit package name at
> > sibtest1.pl 
> > line 9.

yes, that is because of the usage of undeclared variables. Simply define your 
variables with my, see

perldoc -f my

and, related, the other ways of declaring variables:

perldoc -f our
perldoc vars

The usage of 'use strict' and declaring variables may look as "too much work", 
but it will help *a lot* in finding errors, even subtle ones. Not to speak 
from bigger projects :-)

Best thing to do it always, even in 10 line scripts :-)

> > But, it now sends the message size I wanted.  I have been using O'Reilly's
> > "Learning Perl" but it seems not to address everything.  Do you have
> > another reference that you think is better?  Thanks again.

"Learning Perl" is a good book, but it's intention is to teach the basics; the 
example are as short as possible to demonstrate something - nearly everything 
needed *in practice* is omittet, input sanitizing as an example.

Good sources are f.e:

- this list, or perlmonks.org, or any other place where realistic examples are 
discussed
- the source code of standard perl modules
- further perl code on cpan.org
- ...

With the time, you will know the people that are known to write good (open 
source) code.

greetings, joe

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




Re: ^M

2006-01-10 Thread Patricio Bruna V.
dos2unix :)
> open in VIM
>
> nd write
>
> %s/^m//
>
> it will remove all the ^m in vim
>
> Cheers
> Manoj
>
> 
>
> From: swayam panda [mailto:[EMAIL PROTECTED]
> Sent: Mon 1/9/2006 5:22 PM
> To: [EMAIL PROTECTED]; beginners@perl.org
> Subject: Re: ^M
>
>
>
> Hi.
>
>If u will open the file in VIM u will get the new line character as
> ^m.
> Correct me if i am wrong
> - Original Message -
> From: <[EMAIL PROTECTED]>
> To: 
> Sent: Monday, January 09, 2006 3:50 PM
> Subject: ^M
>
>
> Hallo,
>
>
>
> I have to process some files with more than 10 lines. At the end of
> each line is the sign ^M. How could I remove it.
>
>
>
>
>
> Mit freundlichen Grüssen /with best regards
>
> Matthias Hämmerle
>
> T-Systems Business Services GmbH
>
> TCO IT CC IT BP-Competence Center OSS Development
>
> Reporting Solutions (InfoVista)
>
> Address: Fasanenweg 9, D-70771 Leinfelden-Echterdingen
>
> Phone: +49 (711) 972-49833
>
> Fax: +49 (711) 120303-014889
>
> Mobile: +49 (171) 4064266
>
> E-Mail:  
> mailto:[EMAIL PROTECTED]
>
> Internet:   http://www.t-systems.com
>
>
>
>
>
> Hinweis: Diese Nachricht oder deren Anlagen können vertraulichen Inhalts,
> oder auf eine andere Weise schutzwürdig sein. Sollten Sie nicht der
> beabsichtigte Empfänger der Nachricht sein, oder diese Nachricht
> versehentlich erhalten haben, sind Sie nicht berechtigt, den Inhalt der
> Nachricht weiterzuleiten, zu kopieren oder den Inhalt auf eine andere Art
> zu verbreiten. Wenn Sie diese Nachricht versehentlich erhalten haben,
> benachrichtigen Sie bitte den Absender und löschen Sie die Nachricht
> mitsamt den Anlagen. Vielen Dank.
>
> Notice: This message and any attachments may be of a confidential nature or
> may require protection for other reasons. Should you not be the intended
> recipient of this message or should you have received this message by
> mistake, you are not allowed to forward, copy or disseminate the content of
> the message in any form. Should you have received this message by mistake,
> please inform the sender and delete the message along with the enclosures.
> Thank you.
>
>
>
>
>
>
>
> --
> To unsubscribe, e-mail: [EMAIL PROTECTED]
> For additional commands, e-mail: [EMAIL PROTECTED]
>  

-- 
Patricio Bruna V.
Jefe de Proyectos y Operaciones de Capacitación

Linux Center Latin América
http://www.linuxcenterla.com


Edificio Birmann 24
Mariano Sanchez Fontecilla 310
Las Condes, Santiago - Chile

Central : 56-2-483.4000
Directo : 56-2-483.4042
Fax : 56-2-483.4050 

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




compiling DateTime module on SCO OSR5

2006-01-10 Thread Scott Taylor

Hello all,

I'm trying to compile DateTime module for Perl in SCO OSR5.07 and failing
miserably.

I have no idea what these errors mean.  Can anyone tell me what I need, or
what I'm doing wrong?

All tests in the "make test" are failing with messages like this one:

PERL_DL_NONLAZY=1 /usr/bin/perl "-MExtUtils::Command::MM" "-e"
"test_har
ness(0, 'blib/lib', 'blib/arch')" t/*.t
t/00load
# Failed test (t/00load.t at line 6)
# Tried to use 'DateTime'.
# Error:  Can't locate loadable object for module DateTime in @INC
(@INC con
tains: /u1/mis01/Perl/DateTime-0.30/blib/lib
/u1/mis01/Perl/DateTime-0.30/blib/a
rch /usr/lib/perl5/5.8/i586-pc-sco3.2v5.0 /usr/lib/perl5/5.8
/usr/lib/perl5/site
_perl/5.8/i586-pc-sco3.2v5.0 /usr/lib/perl5/site_perl/5.8
/usr/lib/perl5/site_pe
rl/5.8 /usr/lib/perl5/sco_perl/5.8/i586-pc-sco3.2v5.0
/usr/lib/perl5/sco_perl/5.
8 /usr/lib/perl5/sco_perl/5.8 .) at
/usr/lib/perl5/5.8/i586-pc-sco3.2v5.0/XSLoad
er.pm line 44
# BEGIN failed--compilation aborted at t/00load.t line 6.
# Compilation failed in require at (eval 3) line 2.
# BEGIN failed--compilation aborted at (eval 3) line 2.
# Looks like you failed 1 test of 1.
dubious
Test returned status 1 (wstat 256, 0x100)
DIED. FAILED test 1
Failed 1/1 tests, 0.00% okay
t/01sanity..Can't locate loadable object for module DateTime
in @INC
 (@INC contains: /u1/mis01/Perl/DateTime-0.30/blib/lib
/u1/mis01/Perl/DateTime-0
.30/blib/arch /usr/lib/perl5/5.8/i586-pc-sco3.2v5.0 /usr/lib/perl5/5.8
/usr/lib/
perl5/site_perl/5.8/i586-pc-sco3.2v5.0 /usr/lib/perl5/site_perl/5.8
/usr/lib/per
l5/site_perl/5.8 /usr/lib/perl5/sco_perl/5.8/i586-pc-sco3.2v5.0
/usr/lib/perl5/s
co_perl/5.8 /usr/lib/perl5/sco_perl/5.8 .) at
/usr/lib/perl5/5.8/i586-pc-sco3.2v
5.0/XSLoader.pm line 44
BEGIN failed--compilation aborted at
/u1/mis01/Perl/DateTime-0.30/blib/lib/DateT
ime.pm line 44.
Compilation failed in require at t/01sanity.t line 7.
BEGIN failed--compilation aborted at t/01sanity.t line 7.
# Looks like your test died before it could output anything.
dubious
Test returned status 255 (wstat 65280, 0xff00)
DIED. FAILED tests 1-16
Failed 16/16 tests, 0.00% okay



--
Scott


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




Re: compiling DateTime module on SCO OSR5

2006-01-10 Thread Scott Taylor

BTW, I originally tried installing it through perl -MCPAN -e shell

always running installs as root.

Scott Taylor said:
>
> Hello all,
>
> I'm trying to compile DateTime module for Perl in SCO OSR5.07 and failing
> miserably.
>
> I have no idea what these errors mean.  Can anyone tell me what I need, or
> what I'm doing wrong?
>
> All tests in the "make test" are failing with messages like this one:
>
> PERL_DL_NONLAZY=1 /usr/bin/perl "-MExtUtils::Command::MM" "-e"
> "test_har
> ness(0, 'blib/lib', 'blib/arch')" t/*.t
> t/00load
> # Failed test (t/00load.t at line 6)
> # Tried to use 'DateTime'.
> # Error:  Can't locate loadable object for module DateTime in @INC
> (@INC con
> tains: /u1/mis01/Perl/DateTime-0.30/blib/lib
> /u1/mis01/Perl/DateTime-0.30/blib/a
> rch /usr/lib/perl5/5.8/i586-pc-sco3.2v5.0 /usr/lib/perl5/5.8
> /usr/lib/perl5/site
> _perl/5.8/i586-pc-sco3.2v5.0 /usr/lib/perl5/site_perl/5.8
> /usr/lib/perl5/site_pe
> rl/5.8 /usr/lib/perl5/sco_perl/5.8/i586-pc-sco3.2v5.0
> /usr/lib/perl5/sco_perl/5.
> 8 /usr/lib/perl5/sco_perl/5.8 .) at
> /usr/lib/perl5/5.8/i586-pc-sco3.2v5.0/XSLoad
> er.pm line 44
> # BEGIN failed--compilation aborted at t/00load.t line 6.
> # Compilation failed in require at (eval 3) line 2.
> # BEGIN failed--compilation aborted at (eval 3) line 2.
> # Looks like you failed 1 test of 1.
> dubious
> Test returned status 1 (wstat 256, 0x100)
> DIED. FAILED test 1
> Failed 1/1 tests, 0.00% okay
> t/01sanity..Can't locate loadable object for module DateTime
> in @INC
>  (@INC contains: /u1/mis01/Perl/DateTime-0.30/blib/lib
> /u1/mis01/Perl/DateTime-0
> .30/blib/arch /usr/lib/perl5/5.8/i586-pc-sco3.2v5.0 /usr/lib/perl5/5.8
> /usr/lib/
> perl5/site_perl/5.8/i586-pc-sco3.2v5.0 /usr/lib/perl5/site_perl/5.8
> /usr/lib/per
> l5/site_perl/5.8 /usr/lib/perl5/sco_perl/5.8/i586-pc-sco3.2v5.0
> /usr/lib/perl5/s
> co_perl/5.8 /usr/lib/perl5/sco_perl/5.8 .) at
> /usr/lib/perl5/5.8/i586-pc-sco3.2v
> 5.0/XSLoader.pm line 44
> BEGIN failed--compilation aborted at
> /u1/mis01/Perl/DateTime-0.30/blib/lib/DateT
> ime.pm line 44.
> Compilation failed in require at t/01sanity.t line 7.
> BEGIN failed--compilation aborted at t/01sanity.t line 7.
> # Looks like your test died before it could output anything.
> dubious
> Test returned status 255 (wstat 65280, 0xff00)
> DIED. FAILED tests 1-16
> Failed 16/16 tests, 0.00% okay
>
>
>
> --
> Scott
>
>
> --
> To unsubscribe, e-mail: [EMAIL PROTECTED]
> For additional commands, e-mail: [EMAIL PROTECTED]
>  
>
>


--
Scott


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




Help with my thought process...parsing a log

2006-01-10 Thread Robert Hicks
I have an application log that shows the "time", "id" and "type" for a user
logging in. A short except looks like this:

19/12/2005 07:28:37  User (guest) logging in from (LIMS-CIT) - Assigned
Userno (7045)
19/12/2005 07:32:06  User (guest) logging in from (LIMS-CIT) - Assigned
Userno (1959)
19/12/2005 07:51:38  User (guest) logging in from (LIMS-CIT) - Assigned
Userno (7601)
19/12/2005 07:54:10  User (guest) logging off - Userno (7601)

I need to get the difference in the time from when 7601 logged into the
system and logged out of the system. The caveat is that 7601 could log in
and log out multiple times. I am having a hard time thinking about how to do
that.

Should I find the first login and look for the logout, get the diff and
reset some counter. Do I use a hash for this?

Just a little push (not off the cliff please)...is all I need.

Robert



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




Understanding Benchmark results

2006-01-10 Thread Steve Bertrand
Hi all,

I've a project on the go, where I must compare a single field of more
than 3 million database records, then sort them largest to smallest. The
field will contain up to a 6 digit integer.

Just to ensure the most efficient possible run, I've been doing tests
with benchmark.

I'll post the relevant code, then the results. What I want to know is
the cmpthese() results. I *think* that 'b' is much more efficient than
'a'. My assumption is that 'b' can perform 79531 operations per second,
where 'b' is only doing 20666. Am I looking at this right? Is the
Schwartzian Transform really about 300% better than just plain sort?

 code snip (and yes -w and strict are in effect :) 

if ($benchTest) {

my $r1 = sub {
my @unsorted = qw(3 4 9 88 24 1034 28);

my @sorted = sort {$a <=> $b} @unsorted;
};

my $r2 = sub {
my @unsorted = qw(3 4 9 88 24 1034 28);

my @sorted =
map $_->[0],
sort { $a->[1] <=> $b->[1] }
map [ $_, $_ ],
@unsorted;
};

my $href = { 'a' => $r1, 'b' => $r2, };
my $result = timethese(-10, $href);
cmpthese($result);

}

- results ---

Benchmark: running a, b, each for at least 10 CPU seconds...
 a: 11 wallclock secs (10.59 usr +  0.01 sys = 10.60 CPU) @
79531.20/s (n=843155)
 b: 11 wallclock secs (10.44 usr +  0.02 sys = 10.45 CPU) @
20665.69/s (n=216021)

 Rateba
b 20666/s   -- -74%
a 79531/s 285%   --



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




Re: compiling DateTime module on SCO OSR5

2006-01-10 Thread Scott Taylor


Tom Phoenix said:
> On 1/10/06, Scott Taylor <[EMAIL PROTECTED]> wrote:
>
>> I'm trying to compile DateTime module for Perl in SCO OSR5.07 and failing
>> miserably.
>
>> # Error:  Can't locate loadable object for module DateTime in @INC
>
> It looks as if something failed long before this point, during the build
process. I recommend that you re-do the installation from the beginning,
watching for any error messages along the way.

You lost me.  Perl 5.8 comes with the OS and is built and maintained be
SCO.  I'm guessing DateTime needs something in order to compile, but what?
 Why would it say it can't locate an object in the modules that I'm trying
to install?

That was the beginning.  Those are the first error messages.

> Have you been able to install similar modules before? If you didn't
build perl on the same machine that's running it, something may not be
configured correctly for building modules there.

I have installed many other modules, like email stuff and WriteExcel, but
nothing with Date and Time functions like this one.

--
Scott



--
Scott


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




global variables

2006-01-10 Thread David Gama Rodrí­guez

Hello everyone !!

I'm really a newbie developing perl modules. I have and issue

I made a module that loads when Apache starts, in my module I declare a 
hash  as a global in order to be accesed in any place in my module,


my $hash;


sub x{
$foo = shift;
..
..
$hash->{x} = $foo;
}


sub y{


print $hash->{x};
}


in a webapageX I call the x sub and another webpageY I call y sub, I 
access webpageX once to put some value to the $hash so the trouble 
starts when I'm access the webpageY  from diferent locations and $hash 
lost its value declare in webpageX


I suppose that when I initialice the module when Apache starts it will 
hold that $hash variable available for every page that calls that 
module, is that right ? or ervrytime that it calls webpageY is a new 
instance of the module???


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




Re: compiling DateTime module on SCO OSR5

2006-01-10 Thread Tom Phoenix
On 1/10/06, Scott Taylor <[EMAIL PROTECTED]> wrote:

> I'm trying to compile DateTime module for Perl in SCO OSR5.07 and failing
> miserably.

> # Error:  Can't locate loadable object for module DateTime in @INC

It looks as if something failed long before this point, during the
build process. I recommend that you re-do the installation from the
beginning, watching for any error messages along the way.

Have you been able to install similar modules before? If you didn't
build perl on the same machine that's running it, something may not be
configured correctly for building modules there.

Hope this helps!

--Tom Phoenix
Stonehenge Perl Training

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




Add comment to a pattern matched file line

2006-01-10 Thread Vincent Li

Hi List:

I have two files like this:

file1:
score CN_SUBJ_PROMOTE3.100 # [0.000..3.100]
score CN_SUBJ_PROMOTION  3.600 # [0.000..3.600]
score CN_SUBJ_PROVIDE3.000 # [0.000..3.000]

file2:
CN_SUBJ_PROMOTE
CN_SUBJ_PROMOTION

If string CN_SUBJ_PROMOTE exist in file2 and file1, add comment (#) to 
file1 like:


#score CN_SUBJ_PROMOTE3.100 # [0.000..3.100]
#score CN_SUBJ_PROMOTION  3.600 #[0.000..3.600]

I came  up with this script:

#!/usr/bin/perl
use strict;
use warnings;
use Tie::File;

tie my @array1, ,'Tie::File',  "file1" or die "Could not tie file1!";
tie my @array2, ,'Tie::File',  "file2" or die "Could not tie file2!";

for (@array2) {
   my $string = $_;
  for (@array1) {
  if (/$string/) {
   s/$_/#$_/;
   }
   }
}

It did not work as I wish, any thoughts or other method to do this?

Thanks in Advance!


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




Re: global variables

2006-01-10 Thread vmalik
I think that a fresh new copy of the module is loaded into memory everytime it
is called. That's why your module loses its value. If I want to do something
like that, I'd consider storing the value on the hard drive somewhere.

Vishal


Quoting David Gama Rodrí­guez <[EMAIL PROTECTED]>:

> Hello everyone !!
> 
> I'm really a newbie developing perl modules. I have and issue
> 
> I made a module that loads when Apache starts, in my module I declare a 
> hash  as a global in order to be accesed in any place in my module,
> 
> my $hash;
> 
> 
> sub x{
>  $foo = shift;
> ..
> ..
>  $hash->{x} = $foo;
> }
> 
> 
> sub y{
> 
> 
> print $hash->{x};
> }
> 
> 
> in a webapageX I call the x sub and another webpageY I call y sub, I 
> access webpageX once to put some value to the $hash so the trouble 
> starts when I'm access the webpageY  from diferent locations and $hash 
> lost its value declare in webpageX
> 
> I suppose that when I initialice the module when Apache starts it will 
> hold that $hash variable available for every page that calls that 
> module, is that right ? or ervrytime that it calls webpageY is a new 
> instance of the module???
> 
> -- 
> To unsubscribe, e-mail: [EMAIL PROTECTED]
> For additional commands, e-mail: [EMAIL PROTECTED]
>  
> 
> 





This mail sent through www.mywaterloo.ca

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




Re: compiling DateTime module on SCO OSR5

2006-01-10 Thread Scott Taylor

Tom Phoenix said:
> On 1/10/06, Scott Taylor <[EMAIL PROTECTED]> wrote:
>
>> I'm trying to compile DateTime module for Perl in SCO OSR5.07 and
>> failing
>> miserably.
>
>> # Error:  Can't locate loadable object for module DateTime in @INC
>
> It looks as if something failed long before this point, during the
> build process. I recommend that you re-do the installation from the
> beginning, watching for any error messages along the way.
>
> Have you been able to install similar modules before? If you didn't
> build perl on the same machine that's running it, something may not be
> configured correctly for building modules there.

Thanks Tom,

Taking a closer look, now looks like SCO's C compiling system is FUBAR. 
Really nice.

--
Scott


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




string interpolation when reading from a file

2006-01-10 Thread Dan Huston

Greetings --

I am reading text sql commands) from a file, chopping it into sections 
and then writing each section out to a different file. Within the text 
are perl variables that I had expected to be interpolated as they were 
written out to the new file but they are not.


Here is a sample line:

REVOKE SELECT ON $TABLE_NAME FROM PUBLIC;

$TABLE_NAME for example might be 'STUDENTS'. 

Is there a reason that the text is not being interpolated when before it 
is written out to the new file (either when it is read in or when it is 
printed out)?


Here is a piece of my code:


##CODE SNIPPET   #

for $k ( @these_lines ) {

   # for debugging
   print "$TABLE_NAME\n";
   print "K\t=>\t$k\n";

### SQL_OUT is the filehandle that I am writing to
   print SQL_OUT "$k\n";

} ### CLOSE-FOR-K


produces this output in STDOUT:

TABLE_NAME  =>  STUDENTS
K   =>   REVOKE SELECT ON $TABLE_NAME FROM PUBLIC;

where I want to have :

K   =>   REVOKE SELECT ON STUDENTS FROM PUBLIC;


##CODE SNIPPET   #


Thanks
Dan


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




interpolation

2006-01-10 Thread The Ghost

I want to pull some text from a database:

RxNumber in (select RxNumber FROM restoreReports WHERE Status in  
$Status)


then I want perl to use this string and interpolate the variables  
($Status).


so:

my $Status= "('New','Old')";
my $sql=get_SQL_String(); #will get 'RxNumber in (select RxNumber  
FROM restoreReports WHERE Status in $Status)'



something.
print $sql;

# should print:

RxNumber in (select RxNumber FROM restoreReports WHERE Status in  
('New','Old'))



What can I do?

Splitting file

2006-01-10 Thread Raoul Ripmeester
Hello all,

I am a newbe so please bare with me :

I am trying to split lines of a file into variables so I can do some
sorting and other stuff with this. Now my script is working but the
split is giving me problems. I am splitting on the space character, but
the line(s) can contain multiple spaces. Underneath a few sample lines
that I am trying to split.



 7-NOV-2005 09:24:00.56 PRIVILEGE  PRVAUD_SUCCESS   SMC8   SMCMAN
02DF TXA4:
 7-NOV-2005 09:24:24.36 PRIVILEGE  PRVAUD_SUCCESS   SMC8   SMCMAN
02DF TXA4:
 7-NOV-2005 09:25:16.44 PRIVILEGE  PRVAUD_SUCCESS   SMC8   SMCMAN
02DF TXA4:
 7-NOV-2005 09:25:42.22 PRIVILEGE  PRVAUD_SUCCESS   SMC8   SMCMAN
02DF TXA4:
 7-NOV-2005 09:27:53.48 PRIVILEGE  PRVAUD_SUCCESS   SMC8   SMCMAN
02DF TXA4:
 7-NOV-2005 09:29:51.32 LOGOUT LOCALSMC8   SMCMAN
02DF _TXA4:
 7-NOV-2005 09:46:13.94 LOGIN  LOCALSMC8   SMCMAN
02E0 _TXA4:


And here is a part of the code I am using ( the print statements are
just to test the splitting ) :



open (FILE, $file ) || die  ("open of $file failed $! \n") ;
while (){
  ($date,$time,$type,$subtype,$node,$username,$ID, $term) =
split(/ /,$_) ;
  print "date = $date \t time = $time \t type = $type \n" ;
  print "subtype = $subtype \t node = $ node \t username =
$username \n " ;
  print "ID = $ID \t term = $term \n " ;
  }



How can I make the split to work with one or multiple space. I tried to
split on / .*/  But that will put the whole line in the first variable,
so what am I missing. 

Thanks and best regards,

Raoul. 

-- 
Censorship cannot eliminate evil, it can only kill freedom.


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




RE: Splitting file

2006-01-10 Thread Ryan Frantz


> -Original Message-
> From: Raoul Ripmeester [mailto:[EMAIL PROTECTED]
> Sent: Tuesday, January 10, 2006 4:48 PM
> To: beginners@perl.org
> Subject: Splitting file
> 
> Hello all,

Hello,


> 
> I am a newbe so please bare with me :
> 
> I am trying to split lines of a file into variables so I can do some
> sorting and other stuff with this. Now my script is working but the
> split is giving me problems. I am splitting on the space character,
but
> the line(s) can contain multiple spaces. Underneath a few sample lines
> that I am trying to split.
> 
> 
> 
>  7-NOV-2005 09:24:00.56 PRIVILEGE  PRVAUD_SUCCESS   SMC8   SMCMAN
> 02DF TXA4:
>  7-NOV-2005 09:24:24.36 PRIVILEGE  PRVAUD_SUCCESS   SMC8   SMCMAN
> 02DF TXA4:
>  7-NOV-2005 09:25:16.44 PRIVILEGE  PRVAUD_SUCCESS   SMC8   SMCMAN
> 02DF TXA4:
>  7-NOV-2005 09:25:42.22 PRIVILEGE  PRVAUD_SUCCESS   SMC8   SMCMAN
> 02DF TXA4:
>  7-NOV-2005 09:27:53.48 PRIVILEGE  PRVAUD_SUCCESS   SMC8   SMCMAN
> 02DF TXA4:
>  7-NOV-2005 09:29:51.32 LOGOUT LOCALSMC8   SMCMAN
> 02DF _TXA4:
>  7-NOV-2005 09:46:13.94 LOGIN  LOCALSMC8   SMCMAN
> 02E0 _TXA4:
> 
> 
> And here is a part of the code I am using ( the print statements are
> just to test the splitting ) :
> 
> 
> 
> open (FILE, $file ) || die  ("open of $file failed $! \n") ;
>   while (){

To match one or more spaces, your regex should be:

/\s+/

This:
>   ($date,$time,$type,$subtype,$node,$username,$ID, $term)
=
> split(/ /,$_) ;

becomes:
($date,$time,$type,$subtype,$node,$username,$ID, $term) =
split(/\s+/,$_) ;

ry

>   print "date = $date \t time = $time \t type = $type \n"
;
>   print "subtype = $subtype \t node = $ node \t username =
> $username \n " ;
>   print "ID = $ID \t term = $term \n " ;
>   }
> 
> 
> 
> How can I make the split to work with one or multiple space. I tried
to
> split on / .*/  But that will put the whole line in the first
variable,
> so what am I missing.
> 
> Thanks and best regards,
> 
> Raoul.
> 
> --
> Censorship cannot eliminate evil, it can only kill freedom.
> 
> 
> --
> To unsubscribe, e-mail: [EMAIL PROTECTED]
> For additional commands, e-mail: [EMAIL PROTECTED]
>  
> 


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




Re: Splitting file

2006-01-10 Thread Casey Cichon
On Tue, Jan 10, 2006 at 10:47:50PM +0100 or thereabouts, Raoul Ripmeester wrote:
> Hello all,
> 
> I am a newbe so please bare with me :
> 
> I am trying to split lines of a file into variables so I can do some
> sorting and other stuff with this. Now my script is working but the
> split is giving me problems. I am splitting on the space character, but
> the line(s) can contain multiple spaces. Underneath a few sample lines
> that I am trying to split.
> 
> 
> 
>  7-NOV-2005 09:24:00.56 PRIVILEGE  PRVAUD_SUCCESS   SMC8   SMCMAN
> 02DF TXA4:
>  7-NOV-2005 09:24:24.36 PRIVILEGE  PRVAUD_SUCCESS   SMC8   SMCMAN
> 02DF TXA4:
>  7-NOV-2005 09:25:16.44 PRIVILEGE  PRVAUD_SUCCESS   SMC8   SMCMAN
> 02DF TXA4:
>  7-NOV-2005 09:25:42.22 PRIVILEGE  PRVAUD_SUCCESS   SMC8   SMCMAN
> 02DF TXA4:
>  7-NOV-2005 09:27:53.48 PRIVILEGE  PRVAUD_SUCCESS   SMC8   SMCMAN
> 02DF TXA4:
>  7-NOV-2005 09:29:51.32 LOGOUT LOCALSMC8   SMCMAN
> 02DF _TXA4:
>  7-NOV-2005 09:46:13.94 LOGIN  LOCALSMC8   SMCMAN
> 02E0 _TXA4:
> 
> 

This looks like fixed width data to me.

> And here is a part of the code I am using ( the print statements are
> just to test the splitting ) :
> 
> 
> 
> open (FILE, $file ) || die  ("open of $file failed $! \n") ;
>   while (){
>   ($date,$time,$type,$subtype,$node,$username,$ID, $term) =
> split(/ /,$_) ;
>   print "date = $date \t time = $time \t type = $type \n" ;
>   print "subtype = $subtype \t node = $ node \t username =
> $username \n " ;
>   print "ID = $ID \t term = $term \n " ;
>   }
> 
> 
> 
> How can I make the split to work with one or multiple space. I tried to
> split on / .*/  But that will put the whole line in the first variable,
> so what am I missing. 
> 

I had to do something like this a while back ... had the same problem.  A
friend of mine introduced me to a different function --> unpack.

Unfortuneately . I don't remember the exact syntax.

> Thanks and best regards,
> 
> Raoul. 
> 
> -- 
> Censorship cannot eliminate evil, it can only kill freedom.
> 
> 
> -- 
> To unsubscribe, e-mail: [EMAIL PROTECTED]
> For additional commands, e-mail: [EMAIL PROTECTED]
>  
> 

-- 
Casey Cichon
[EMAIL PROTECTED]

Never ascribe to malice that which could merely be incompetence.


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




RE: Splitting file

2006-01-10 Thread Raoul Ripmeester
Ryan,

Yes thank you that works and did the trick.

Kind regards,

Raoul. 

On Tue, 2006-01-10 at 16:48 -0500, Ryan Frantz wrote:
> 
> > -Original Message-
> > From: Raoul Ripmeester [mailto:[EMAIL PROTECTED]
> > Sent: Tuesday, January 10, 2006 4:48 PM
> > To: beginners@perl.org
> > Subject: Splitting file
> > 
> > Hello all,
> 
> Hello,
> 
> 
> > 
> > I am a newbe so please bare with me :
> > 
> > I am trying to split lines of a file into variables so I can do some
> > sorting and other stuff with this. Now my script is working but the
> > split is giving me problems. I am splitting on the space character,
> but
> > the line(s) can contain multiple spaces. Underneath a few sample lines
> > that I am trying to split.
> > 
> > 
> > 
> >  7-NOV-2005 09:24:00.56 PRIVILEGE  PRVAUD_SUCCESS   SMC8   SMCMAN
> > 02DF TXA4:
> >  7-NOV-2005 09:24:24.36 PRIVILEGE  PRVAUD_SUCCESS   SMC8   SMCMAN
> > 02DF TXA4:
> >  7-NOV-2005 09:25:16.44 PRIVILEGE  PRVAUD_SUCCESS   SMC8   SMCMAN
> > 02DF TXA4:
> >  7-NOV-2005 09:25:42.22 PRIVILEGE  PRVAUD_SUCCESS   SMC8   SMCMAN
> > 02DF TXA4:
> >  7-NOV-2005 09:27:53.48 PRIVILEGE  PRVAUD_SUCCESS   SMC8   SMCMAN
> > 02DF TXA4:
> >  7-NOV-2005 09:29:51.32 LOGOUT LOCALSMC8   SMCMAN
> > 02DF _TXA4:
> >  7-NOV-2005 09:46:13.94 LOGIN  LOCALSMC8   SMCMAN
> > 02E0 _TXA4:
> > 
> > 
> > And here is a part of the code I am using ( the print statements are
> > just to test the splitting ) :
> > 
> > 
> > 
> > open (FILE, $file ) || die  ("open of $file failed $! \n") ;
> > while (){
> 
> To match one or more spaces, your regex should be:
> 
> /\s+/
> 
> This:
> >   ($date,$time,$type,$subtype,$node,$username,$ID, $term)
> =
> > split(/ /,$_) ;
> 
> becomes:
> ($date,$time,$type,$subtype,$node,$username,$ID, $term) =
> split(/\s+/,$_) ;
> 
> ry
> 
> >   print "date = $date \t time = $time \t type = $type \n"
> ;
> >   print "subtype = $subtype \t node = $ node \t username =
> > $username \n " ;
> >   print "ID = $ID \t term = $term \n " ;
> >   }
> > 
> > 
> > 
> > How can I make the split to work with one or multiple space. I tried
> to
> > split on / .*/  But that will put the whole line in the first
> variable,
> > so what am I missing.
> > 
> > Thanks and best regards,
> > 
> > Raoul.
> > 
> > --
> > Censorship cannot eliminate evil, it can only kill freedom.
> > 
> > 
> > --
> > To unsubscribe, e-mail: [EMAIL PROTECTED]
> > For additional commands, e-mail: [EMAIL PROTECTED]
> >  
> > 
> 
> 
-- 
Censorship cannot eliminate evil, it can only kill freedom.


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




Module Installation - Solaris

2006-01-10 Thread Gerald Wheeler
Running Perl 5.6.1 on Solaris 9 (Unix) SPARC

Trying to install a (actually any ) module e.g., CPAN (upgrade), MD5,
XML::XSLT, etc..  using: perl -MCPAN -e shell

I do not have access to a "C" compiler, etc...

The errors shown below occurred for every module I attempt to install..
 (below is just a small fraction of the errors)

Anyone have an idea as to the solution...ability to install modules
using: " perl -MCPAN -e shell "

Thanks

Jerry

***
 CPAN.pm: Going to build P/PM/PMQS/Compress-Zlib-1.41.tar.gz

Parsing config.in...
Building Zlib enabled
Looks Good.
Up/Downgrade complete.
Checking if your kit is complete...
Looks good
Writing Makefile for Compress::Zlib
-- NOT OK
Running make test
  Can't test without successful make
Running make install
  make had returned bad status, install seems impossible
Running install for module Archive::Tar
Running make for K/KA/KANE/Archive-Tar-1.26.tar.gz
Issuing "/usr/bin/ftp -n"
Local directory now /.cpan/sources/authors/id/K/KA/KANE

 CPAN.pm: Going to build I/IN/INGY/YAML-0.50.tar.gz

Checking if your kit is complete...
Looks good
Warning: prerequisite Spiffy failed to load: Can't locate Spiffy.pm in
@INC (@INC contains: inc /usr/perl5/5.6.1/lib/sun4-solaris-64int
/usr/perl5/5.6.1/lib /usr/perl5/site_perl/5.6.1/sun4-solaris-64int
/usr/perl5/site_perl/5.6.1 /usr/perl5/site_perl
/usr/perl5/vendor_perl/5.6.1/sun4-solaris-64int
/usr/perl5/vendor_perl/5.6.1 /usr/perl5/vendor_perl .) at (eval 13) line
3.
Warning: prerequisite Test::Base failed to load: Can't locate
Test/Base.pm in @INC (@INC contains: inc
/usr/perl5/5.6.1/lib/sun4-solaris-64int /usr/perl5/5.6.1/lib
/usr/perl5/site_perl/5.6.1/sun4-solaris-64int /usr/perl5/site_perl/5.6.1
/usr/perl5/site_perl /usr/perl5/vendor_perl/5.6.1/sun4-solaris-64int
/usr/perl5/vendor_perl/5.6.1 /usr/perl5/vendor_perl .) at (eval 14) line
3.
Warning: prerequisite Test::More failed to load: Can't locate
Test/More.pm in @INC (@INC contains: inc
/usr/perl5/5.6.1/lib/sun4-solaris-64int /usr/perl5/5.6.1/lib
/usr/perl5/site_perl/5.6.1/sun4-solaris-64int /usr/perl5/site_perl/5.6.1
/usr/perl5/site_perl /usr/perl5/vendor_perl/5.6.1/sun4-solaris-64int
/usr/perl5/vendor_perl/5.6.1 /usr/perl5/vendor_perl .) at (eval 15) line
3.
Writing Makefile for YAML
 Unsatisfied dependencies detected during
[I/IN/INGY/YAML-0.50.tar.gz] -
Spiffy
Test::Base
Test::More

Writing Makefile for YAML
 Unsatisfied dependencies detected during
[I/IN/INGY/YAML-0.50.tar.gz] -
Spiffy
Test::Base
Test::More
Shall I follow them and prepend them to the queue
of modules we are processing right now? [yes] 
Running make test
  Delayed until after prerequisites
Running make install
  Delayed until after prerequisites
Running install for module Text::Glob
Running make for R/RC/RCLAMP/Text-Glob-0.06.tar.gz
Issuing "/usr/bin/ftp -n"
Local directory now /.cpan/sources/authors/id/R/RC/RCLAMP

Not connected.
Not connected.
Not connected.
Not connected.
Not connected.
Not connected.
Not connected.
Not connected.
Not connected.
Bad luck... Still failed!
Can't access URL
ftp://ftp.perl.org/pub/CPAN/authors/id/R/RC/RCLAMP/Text-Glob-0.06.tar.gz.

LWP not available
Please check, if the URLs I found in your configuration file () are
valid.
The urllist can be edited. E.g. with 'o conf urllist push ftp://myurl/'


Could not fetch authors/id/R/RC/RCLAMP/Text-Glob-0.06.tar.gz
Giving up on
'/.cpan/sources/authors/id/R/RC/RCLAMP/Text-Glob-0.06.tar.gz'
Note: Current database in memory was generated on Tue, 10 Jan 2006
11:10:21 GMT

cpan> cpan> 

etc., etc.




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




Re: Help with my thought process...parsing a log

2006-01-10 Thread John Doe
Robert Hicks am Dienstag, 10. Januar 2006 18.16:
> I have an application log that shows the "time", "id" and "type" for a user
> logging in. A short except looks like this:
>
> 19/12/2005 07:28:37  User (guest) logging in from (LIMS-CIT) - Assigned
> Userno (7045)
> 19/12/2005 07:32:06  User (guest) logging in from (LIMS-CIT) - Assigned
> Userno (1959)
> 19/12/2005 07:51:38  User (guest) logging in from (LIMS-CIT) - Assigned
> Userno (7601)
> 19/12/2005 07:54:10  User (guest) logging off - Userno (7601)
>
> I need to get the difference in the time from when 7601 logged into the
> system and logged out of the system. The caveat is that 7601 could log in
> and log out multiple times. I am having a hard time thinking about how to
> do that.
>
> Should I find the first login and look for the logout, get the diff and
> reset some counter. Do I use a hash for this?
>
> Just a little push (not off the cliff please)...is all I need.

Are you interested in one specific Userno only, or do you want the login times 
for all Usernos?

What do you mean by "could log in and log out multiple times"? In parallel, or 
sequential? If parallel: Are different Usernos assigned for the same user 
logged in multiple times?

A hash (or hash of hashes / hash of arrays) could be useful to lookup Usernos 
or login times.

Have you some code to post, f.e. the part extracting the wanted info from the 
lines?

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




Re: interpolation

2006-01-10 Thread Mike Blezien

Try changing your $Status variable to this:

my $Status  = '(' . '"' . join('","','New','Old') . '"' . ')';

that should give the results desired

hope it helps.

The Ghost wrote:

I want to pull some text from a database:

RxNumber in (select RxNumber FROM restoreReports WHERE Status in  $Status)

then I want perl to use this string and interpolate the variables  
($Status).


so:

my $Status= "('New','Old')";
my $sql=get_SQL_String(); #will get 'RxNumber in (select RxNumber  FROM 
restoreReports WHERE Status in $Status)'



something.
print $sql;

# should print:

RxNumber in (select RxNumber FROM restoreReports WHERE Status in  
('New','Old'))



What can I do?



--
Mike(mickalo)Blezien
=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
Thunder Rain Internet Publishing
Providing Internet Solutions that work!
http://thunder-rain.com/
=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=


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




Re: Understanding Benchmark results

2006-01-10 Thread John Doe
Steve Bertrand am Dienstag, 10. Januar 2006 18.24:
> Hi all,

Hi Steve

> I've a project on the go, where I must compare a single field of more
> than 3 million database records, then sort them largest to smallest. The
> field will contain up to a 6 digit integer.

(I think you must have a reason not to sort the values while retrieving them 
from the database - or is it not a SQL db?)

> Just to ensure the most efficient possible run, I've been doing tests
> with benchmark.
>
> I'll post the relevant code, then the results. What I want to know is
> the cmpthese() results. I *think* that 'b' is much more efficient than
> 'a'. My assumption is that 'b' 

you mean: 'a'

> can perform 79531 operations per second, 
> where 'b' is only doing 20666. Am I looking at this right? Is the
> Schwartzian Transform really about 300% better than just plain sort?

No, about 300% more _slowly_, since 'a' is doing more per second than 'b'.

This seems also plausible from the fact that the schwarzian transformation in 
'b' does a comparison like 'a' does, but does additional work.

>  code snip (and yes -w and strict are in effect :) 
>
> if ($benchTest) {
>
> my $r1 = sub {
> my @unsorted = qw(3 4 9 88 24 1034 28);
>
> my @sorted = sort {$a <=> $b} @unsorted;
> };
>
> my $r2 = sub {
> my @unsorted = qw(3 4 9 88 24 1034 28);
>
> my @sorted =
> map $_->[0],
> sort { $a->[1] <=> $b->[1] }
> map [ $_, $_ ],
> @unsorted;
> };
>
> my $href = { 'a' => $r1, 'b' => $r2, };
> my $result = timethese(-10, $href);
> cmpthese($result);
>
> }
>
> - results ---
>
> Benchmark: running a, b, each for at least 10 CPU seconds...
>  a: 11 wallclock secs (10.59 usr +  0.01 sys = 10.60 CPU) @
> 79531.20/s (n=843155)
>  b: 11 wallclock secs (10.44 usr +  0.02 sys = 10.45 CPU) @
> 20665.69/s (n=216021)
>
>  Rateba
> b 20666/s   -- -74%

read: b performs 74% compared with a.

> a 79531/s 285%   --

hth, 
joe

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




Re: Splitting file

2006-01-10 Thread Dr.Ruud
Raoul Ripmeester schreef:

> How can I make the split to work with one or multiple space.

What you aim for, is already the default behaviour of split.

  perldoc -f split

"If PATTERN is also omitted, splits on whitespace (after 
skipping any leading whitespace). [...]
As a special case, specifying a PATTERN of space (' ') will
split on white space just as "split" with no arguments does."

So change your 

  split(/ /,$_)

into 

  split ' '

or even into just

  split

-- 
Affijn, Ruud

"Gewoon is een tijger."


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




Re: Add comment to a pattern matched file line

2006-01-10 Thread John Doe
Vincent Li am Dienstag, 10. Januar 2006 19.59:
> Hi List:

Hi Vincent

> I have two files like this:
>
> file1:
> score CN_SUBJ_PROMOTE3.100 # [0.000..3.100]
> score CN_SUBJ_PROMOTION  3.600 # [0.000..3.600]
> score CN_SUBJ_PROVIDE3.000 # [0.000..3.000]
>
> file2:
> CN_SUBJ_PROMOTE
> CN_SUBJ_PROMOTION
>
> If string CN_SUBJ_PROMOTE exist in file2 and file1, add comment (#) to
> file1 like:
>
> #score CN_SUBJ_PROMOTE3.100 # [0.000..3.100]
> #score CN_SUBJ_PROMOTION  3.600 #[0.000..3.600]
>
> I came  up with this script:

Which is not easy to test, so I didn't :-)

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

Great two lines!

> use Tie::File;
>
> tie my @array1, ,'Tie::File',  "file1" or die "Could not tie file1!";
> tie my @array2, ,'Tie::File',  "file2" or die "Could not tie file2!";
>
> for (@array2) {
> my $string = $_;

shorter: for my $string (@array2) {

>for (@array1) {
>if (/$string/) {
> s/$_/#$_/;

Eventually it is faster just to handle the beginning of the line 
with s/^./#./

> }
> }
> }
>
> It did not work as I wish, any thoughts or other method to do this?

How did it not work as expected?

You pass through the whole @array1 for every value in @array2, this is much 
work. If the lines in file1 are unique and not very numerous, you could use a 
hash (line_content=>line_number) instead of @array1, modify it and write it 
back to file at the end. In this case, a substitution would not be necessary,  
'#' could simply be prepended (i _think_ this is faster than a subst).

There may also be a useful module on search.cpan.org.

hth, 
joe

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




Re: Help with my thought process...parsing a log

2006-01-10 Thread Dr.Ruud
Robert Hicks:

> I have an application log that shows the "time", "id" and "type" for
> a user logging in. A short except looks like this:
>
> 19/12/2005 07:28:37  User (guest) logging in from (LIMS-CIT) -
> Assigned Userno (7045)
> 19/12/2005 07:32:06  User (guest) logging in from (LIMS-CIT) -
> Assigned Userno (1959)
> 19/12/2005 07:51:38  User (guest) logging in from (LIMS-CIT) -
> Assigned Userno (7601)
> 19/12/2005 07:54:10  User (guest) logging off - Userno (7601)
>
> I need to get the difference in the time from when 7601 logged into
> the system and logged out of the system. The caveat is that 7601
> could log in and log out multiple times. I am having a hard time
> thinking about how to do that.
>
> Should I find the first login and look for the logout, get the diff
> and reset some counter. Do I use a hash for this?
>
> Just a little push (not off the cliff please)...is all I need.

  perldoc -q nesting

  CPAN, search for 'parse'

Maybe adjust Parse::Syslog.

For the order, don't rely on the Date + Time but also store a
linenumber.

-- 
Affijn, Ruud

"Gewoon is een tijger."



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




Re: Add comment to a pattern matched file line

2006-01-10 Thread Dr.Ruud
John Doe:
> Vincent Li:

>>if (/$string/) {
>> s/$_/#$_/;
> 
> Eventually it is faster just to handle the beginning of the line
> with s/^./#./

ITYM: s/^/#/

-- 
Affijn, Ruud

"Gewoon is een tijger."


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




Re: string interpolation when reading from a file

2006-01-10 Thread John Doe
Dan Huston am Dienstag, 10. Januar 2006 21.40:
> Greetings --
>
> I am reading text sql commands) from a file, chopping it into sections
> and then writing each section out to a different file. Within the text
> are perl variables that I had expected to be interpolated as they were
> written out to the new file but they are not.
>
> Here is a sample line:
>
> REVOKE SELECT ON $TABLE_NAME FROM PUBLIC;
>
> $TABLE_NAME for example might be 'STUDENTS'.
>
> Is there a reason that the text is not being interpolated when before it
> is written out to the new file (either when it is read in or when it is
> printed out)?
>
> Here is a piece of my code:
>
>
> ##CODE SNIPPET   #
>
> for $k ( @these_lines ) {
>
> # for debugging
> print "$TABLE_NAME\n";
> print "K\t=>\t$k\n";
>
> ### SQL_OUT is the filehandle that I am writing to
> print SQL_OUT "$k\n";

$k _itself_ is interpolated into the double quoted string: $k contains a 
string with content looking like perl vars, $k is replaced by this string. 

But there is - luckily! - no second level interpolation included (the 
variable names _in_ the string _in_ variable $k).

You would have to make the second level interpolation explicit

   my $var='hi!';
   print eval "q(He said $var and disappeared)";
=>He said hi! and disappeared

but this is DANGEROUS since the text could contain code instead of simple 
variable names.

There may be a useful templating module on search.cpan.org.

Or you could reinvent the wheel and parse for the variable names and replace 
them with values. Something along the lines

use strict; 
use warnings;
my %vars=(TABLE_NAME=>'STUDENTS');
my @these_lines=('REVOKE SELECT ON $TABLE_NAME FROM PUBLIC $UNKNOWN;');
for (@these_lines) {
s/\$([_a-zA-Z]\w*)/$vars{$1} || '$'.$1/eg;
}
print @these_lines;

>
> } ### CLOSE-FOR-K
>
>
> produces this output in STDOUT:
>
> TABLE_NAME  =>  STUDENTS
> K   =>   REVOKE SELECT ON $TABLE_NAME FROM PUBLIC;
>
> where I want to have :
>
> K   =>   REVOKE SELECT ON STUDENTS FROM PUBLIC;
>
>
> ##CODE SNIPPET   #
>
>
> Thanks
> Dan

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




Re: interpolation

2006-01-10 Thread John Doe
The Ghost am Dienstag, 10. Januar 2006 21.57:
> I want to pull some text from a database:
>
> RxNumber in (select RxNumber FROM restoreReports WHERE Status in
> $Status)
>
> then I want perl to use this string and interpolate the variables
> ($Status).
>
> so:
>
> my $Status= "('New','Old')";
> my $sql=get_SQL_String(); #will get 'RxNumber in (select RxNumber
> FROM restoreReports WHERE Status in $Status)'

$sql=~s/\$Status/$Status/;

(first time as literal string, second time as perl variable defined in the 
surrounding context)

see

perldoc perlre

> print $sql;
>
> # should print:
>
> RxNumber in (select RxNumber FROM restoreReports WHERE Status in
> ('New','Old'))
>
>
> What can I do?

hth,
joe

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




Unix solaris Scripting

2006-01-10 Thread Roman Hanousek
 

 

Hi All

 

I am trying to come up with a way of automating Soraris packages through my
perl script. 

 

The problem I am having is that in the middle off the package install I get
asked to overwrite a bunch of files. What I am not sure of is how to capture
the response and then send an answer.

 

 

Here is the way I am installing the package:

 

@output = `/usr/sbin/pkgadd -n -d /var/tmp/SomePackage.pkg -R /data/jboss
jboss-services`;



 

If I run the command myself, this is what happens.

 

--

 

## Processing package information.

## Processing system information.

   1 package pathname is already properly installed.

## Verifying disk space requirements.

## Checking for conflicts with packages already installed.

 

The following files are already installed on the system and are being

used by another package:

  /data/jboss/blah1.xml

  /data/jboss/blah2.jar

  /data/jboss/dist/balh4.jar

* - conflict with a file which does not belong to any package.

 

Do you want to install these conflicting files [y,n,?,q]

 

__

 

 

 

Is there a way I can capture this "Do you want to install these conflicting
files [y,n,?,q]" and send it a response some how ? 

 

 

 

Perl =  v5.8.5 built for sun4-solaris

Solaris 9 

 

Cheers Roman

 

 

 



Re: Understanding Benchmark results

2006-01-10 Thread Tom Phoenix
On 1/10/06, Steve Bertrand <[EMAIL PROTECTED]> wrote:

> Just to ensure the most efficient possible run, I've been doing tests
> with benchmark.

Hey, this is no place for empirical evidence! :-)

> Benchmark: running a, b, each for at least 10 CPU seconds...
>  a: 11 wallclock secs (10.59 usr +  0.01 sys = 10.60 CPU) @
> 79531.20/s (n=843155)
>  b: 11 wallclock secs (10.44 usr +  0.02 sys = 10.45 CPU) @
> 20665.69/s (n=216021)

Those values of n are the number of times the code could run during 10
CPU seconds. Algorithm a is accomplishing four times as much as
algorithm b in the same time. That means that b, the do-nothing
Schwartzian Transform, is 1/4 the speed of the simpler way of doing a
numeric sort. (The latter, I suspect, is internally optimized, too, so
the results aren't surprising. The S.T. would do better if it weren't
competing against that optimization, but it would, I'm sure, still
lose.) Needless to say, this result is heavily dependent upon the data
set and data size, so don't count on this four-to-one ratio in
general.

There's no reason to expect a do-nothing S.T. to speed general numeric
sorting, any more than you should expect to speed up your daily dental
ritual by trying to use 32 toothbrushes in parallel. The S.T. is
useful when a sort is expensive, but can be transformed into one
that's less expensive. That's why the word "Transform" is in there, in
fact. When you don't need to transform anything, you shouldn't.

Hope this helps!

--Tom Phoenix
Stonehenge Perl Training

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




Re: global variables

2006-01-10 Thread Tom Phoenix
On 1/10/06, David Gama Rodrí­guez <[EMAIL PROTECTED]> wrote:
> I made a module that loads when Apache starts, in my module I declare a
> hash  as a global in order to be accesed in any place in my module,
>
> my $hash;

Not to be picky about terminology, but a "my" variable is a lexical
variable, not a global variable. I think what you're talking about
here is a file-scoped lexical variable: It's accessible by name from
the rest of its file, but not from code in any other files.

But because Apache will fork many separate server processes,
persistent variables, whether global or not, may show surprising
behavior. Here's some documentation that may help, or you can search
other mod_perl resources:

http://modperlbook.org/html/ch06_04.html#pmodperl-CHP-6-SECT-4.3

Good luck with it!

--Tom Phoenix
Stonehenge Perl Training

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




perl Input from GUI - form

2006-01-10 Thread manoj thakur
Hi All,

My question is what is the best way to have the input to my perl script
through a GUi like a form or a window.
I know may be CGI any input to point me in the right direction is highly
appreciated.

The idea is not to give the command line arguments as input to perl rather
filling them from a GUI interface.

Thanks & Regards
Manoj


Re: perl Input from GUI - form

2006-01-10 Thread Chris Devers
On Wed, 11 Jan 2006, manoj thakur wrote:

> My question is what is the best way to have the input to my perl script
> through a GUi like a form or a window.
> I know may be CGI any input to point me in the right direction is highly
> appreciated.

Read the documentation for CGI.pm, then write a program using it.

Have you tried either of these yet?

If you've read the documentation, cite it and explain to us how it 
didn't make sense to you. If you've written a program, show it to us and 
explain how it isn't doing what you want it to do.
 


-- 
Chris Devers
DO NOT LEAVE IT IS NOT REAL

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




loop Question

2006-01-10 Thread Ron McKeever
I wanted to print if it matches my range of IP's. I thought I could use the
(#..#) and it would work, but it didn't:

#!/usr/bin/perl -nlw

# Print if Ip's are in 
# 111.9.1-18.### or 
# 111.9.20-100.###
# range
#
my $a="1-18";
my $b="20-100";

while (<>)
{  
chomp $_;
next if ($_ eq "");

my ( $number,$ip,$host ) = split(/,/,$_);
  if ( $ip =~ /111.9.\b(1..18)\b.\d/){
 print "$ip";
}
}
exit;


Thanks for any input.

rob



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




Re: perl Input from GUI - form

2006-01-10 Thread manoj thakur
My bad I didn't frame my question well.
My idea is to accept users input for a perl script i have from GUI like a
window or frame ...

I understand both CGI & TK can help me do that. Please see if you can help
me understand which is easy & best way to do it

also any pointers to some examles for CGI & Tk stating the same is highly
appreciated

Thanks & Regards
Manoj

On 1/11/06, Chris Devers <[EMAIL PROTECTED]> wrote:
>
> On Wed, 11 Jan 2006, manoj thakur wrote:
>
> > My question is what is the best way to have the input to my perl script
> > through a GUi like a form or a window.
> > I know may be CGI any input to point me in the right direction is highly
> > appreciated.
>
> Read the documentation for CGI.pm, then write a program using it.
>
> Have you tried either of these yet?
>
> If you've read the documentation, cite it and explain to us how it
> didn't make sense to you. If you've written a program, show it to us and
> explain how it isn't doing what you want it to do.
>
>
>
> --
> Chris Devers
> DO NOT LEAVE IT IS NOT REAL
>


loop Question

2006-01-10 Thread jcht_mck
I wanted to print if it matches my range of IP's. I thought I could use the
(#..#) and it would work, but it didn't:

#!/usr/bin/perl -nlw

# Print if Ip's are in 
# 111.9.1-18.### or 
# 111.9.20-100.###
# range
#
my $a="1-18";
my $b="20-100";

while (<>)
{  
chomp $_;
next if ($_ eq "");

my ( $number,$ip,$host ) = split(/,/,$_);
  if ( $ip =~ /111.9.\b(1..18)\b.\d/){
 print "$ip";
}
}
exit;


Thanks for any input.

rob



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




Re: Module Installation - Solaris

2006-01-10 Thread Tom Phoenix
On 1/10/06, Gerald Wheeler <[EMAIL PROTECTED]> wrote:
> Running Perl 5.6.1 on Solaris 9 (Unix) SPARC
>
> Trying to install a (actually any ) module e.g., CPAN (upgrade), MD5,
> XML::XSLT, etc..  using: perl -MCPAN -e shell
>
> I do not have access to a "C" compiler, etc...

You should be able to install modules that don't use C without a C
compiler. But you'll almost certainly find that installing gcc is
worth the trouble. In fact, building perl from the source, before
trying to build modules, will probably be worth the trouble, even when
you have to install gcc first. Good luck with it!

--Tom Phoenix
Stonehenge Perl Training

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




Re: loop Question

2006-01-10 Thread Owen Cook

On Tue, 10 Jan 2006, jcht_mck wrote:

> I wanted to print if it matches my range of IP's. I thought I could use the
> (#..#) and it would work, but it didn't:
> 
> #!/usr/bin/perl -nlw
> 
> # Print if Ip's are in 
> # 111.9.1-18.### or 
> # 111.9.20-100.###
> # range
> #
> my $a="1-18";
> my $b="20-100";
> 
> while (<>)
> {  
> chomp $_;
> next if ($_ eq "");
> 
> my ( $number,$ip,$host ) = split(/,/,$_);
>   if ( $ip =~ /111.9.\b(1..18)\b.\d/){
>  print "$ip";
> }
> }
> exit;


Maybe you want to try something like this. It's a bit of a sledge hammer
approach but I think it does the job


#!/usr/bin/perl -w

# Print if Ip's are in
# 111.9.1-18.### or
# 111.9.20-100.###

use strict;
while ()
{

next if /^(\s)*$/;
my $line = $_;
my ( $number,$ip,$host ) = split/,/,$line;

if ($ip=~/(\d+\.)(\d+\.)(\d+\.)(\d+)/) {unless (($1 == 111 )and ($2 ==
9)){next}
if ((($3 > 0) and ($3 < 19))or(($3 > 19) and ($3 < 101))){
print " in range $3 "}}
print "$ip\n"}


__DATA__
number,111.9.1.10,blah
number,111.9.5.55,blah
number,111.9.16.256,blah
number,111.9.20.10,blah
number,111.9.20.256,blah
number,111.9.6.66,blah
number,111.9.22.22,blah
number,111.10.1.33,blah
number,111.9.111.10,blah


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