online favorites project

2003-09-22 Thread Todd W.
xposted to: perl.beginners, perl.beginners.cgi

I've wrote a web based program to store favorites online. I work on quite a
few computers each week between home, work, and school and its something
I've wanted for awhile. The program is account based so others can use it.
It is free to use. The home page is at:

http://waveright.homeip.net/products/FavoritesAnywhere.html

It works on IE 6 and NN 7.1. It should work on any Gecko 1.4 based browser.
Technically, it should work on anything that supports DOM Level 2, cookies,
and JavaScript. If you find it useful, please tell your friends about it.
You can get support at the link below.

It is free software. I have a stack of features I want to add to it. I would
like to invite other developers to work on it with me. The server side logic
is written in mod_perl. The pages are generated with Template::Toolkit. The
menu is generated with XSLT. The DHTML does alot of DOM work, and the menu
options talk to the server using RPC. The server uses RPC::XML, and the
client uses jsolait.

The idea is simple, so even beginners could contribute. User and developer
questions/suggestions can be posted at:

http://waveright.homeip.net/tools/phpBB2/index.php?c=5

Thanks eveyone,

Todd W.





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



Re: CGI.pm 2.98 breaks CGI::Carp?

2003-09-22 Thread Randal L. Schwartz
 Db == Db  [EMAIL PROTECTED] writes:

Db I'm working on a large web application with a friend of mine and we
Db thought it would be a good idea to update the modules we were using.
Db Using CPAN.pm we updated CGI, CGI::Session, and several others.  It
Db upgraded CGI.pm from 2.93 to 3.00.  After the upgrade we noticed that
Db CGI::Carp was not sending correct headers to the browser on
Db fatalsToBrowser and explicit 'die's.  It'd just send the error message
Db without any Content type.  I just downgraded to 2.98 and everything
Db works again.  2.99 exhibits the same behavior as 3.00.

Just a sidenote, but I sincerely hope that you were removing CGI::Carp
before deploying your code in production, and therefore must already have
some other error trapping mechanism for production *anyway*.  Might as
well develop with your final release until you can figure out what is
wrong with CGI::Carp.

-- 
Randal L. Schwartz - Stonehenge Consulting Services, Inc. - +1 503 777 0095
[EMAIL PROTECTED] URL:http://www.stonehenge.com/merlyn/
Perl/Unix/security consulting, Technical writing, Comedy, etc. etc.
See PerlTraining.Stonehenge.com for onsite and open-enrollment Perl training!

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



RE: Cookies

2003-09-22 Thread Alejandro Chavarria - CyPage
Thanks.  I will try that.

Alex

-Original Message-
From: Wiggins d'Anconia [mailto:[EMAIL PROTECTED]
Sent: Saturday, September 20, 2003 7:24 AM
To: [EMAIL PROTECTED]; [EMAIL PROTECTED]
Subject: Re: Cookies


Alejandro Chavarria - CyPage wrote:
 Thanks for your reply Wiggins d'Anconia.  I understand the part about just
 setting the cookie to an empty value, but I don't understand the part
about
 the secret key and a check failing.  Could you explain further?  When
would
 this happen: initially setting the cookie's value, or everytime you check
 the cookie to see if the username and password are correct?


Remember to group reply so everyone can help and be helped.  Essentially
you would take the username and password once, at that time you create a
hashed value of some user information such as an id # or the username if
you want, etc. and any other information you want, IP and expiration
time, plus a secret key, basically any phrase that your site knows
that no one else does. (insert rant about how that is not secure because
anyone with access to the code can see it, blah blah blah...) and you
hash the values together (check out Digest::MD5 or Digest:SHA1 for two
good hashing modules, I prefer the second for other reasons). Then each
time you want to verify the user is who they say they are you take the
information they provide (aka their username or id as mentioned above)
and the hash you generated above which can be stored in teh same cookie
and then you create the hash in the same manner as before and check to
see that the hashes match.  (There is a much better explanation on this
with code samples in the O'Reilly Apache Modules with Perl and C book.)

It is *very difficult* (nothing is completely secure) for the user to
create a hash that will be authentic based only on the knowledge they
have, aka what the cookie looks like and what their user id is. They
could guess that you are using a hash of something fairly easily, and
that if their user id is 245 that there is probably user ids 1-244 but
they can't guess your secret passphrase so to recreate a hash is nearly
impossible.

This also prevents the need to be passing the username/password around
other than on initial login, and is much better than simply setting a
single cookie and checking for its existence for obvious reasons.

Examples:

#
#  Method to generate authentication cookie
#
use Digest::SHA1;
sub authentication_string {
 my $self = shift;


 my $uid = $self-id;
 my $time = time;
 my $expires = 2592000;


 my $data = join(':', CONFIG_AUTH_KEY, $time, $expires, $uid);
 my $hash = Digest::SHA1::sha1_hex($data);


 return uid=$uid time=$time expires=$expires hash=$hash;
}


The above code assumes a 'User' object with an instance method of 'id'
that returns the user's id, and a constant CONFIG_AUTH_KEY that contains
the site's secret key.

I leave the method for validating the authentication to the reader
(mostly because mine has lots of non-standard error checking in it).

Thoughts/comments from any of the gurus?

http://danconia.org



 -Original Message-
 From: Wiggins d'Anconia [mailto:[EMAIL PROTECTED]
 Sent: Thursday, September 18, 2003 6:17 AM
 To: [EMAIL PROTECTED]; [EMAIL PROTECTED]
 Subject: RE: Cookies



 
 On Wed, 17 Sep 2003 20:33:00 -0800, Alejandro Chavarria - CyPage
 [EMAIL PROTECTED] wrote:


Hey,

I have a script and I want to allow an administrator log on to it.  Once
logged in they can change things... etc.  Basically stuff I don't want

 other

people to be able to do.  I have decided that cookies is the best way to

 go.

I've been looking and looking on the internet for a way to add a logout
button in the script that will delete the cookie that has the username and
password so they are essentially logged out.  I have read that you can

 fill

in the expires field in with 1. a date in the past (ie. -1d) or 2. the
word now.  I have heard about problems with both these methods.

What do you suggest?



 In general I would reset the cookie to the empty string with no expiration
 date, and then on the other end your check should be that the cookie
exists
 *and* has a correct value.  Then make the correct value very hard
(because
 nothing is 100% secure) to figure out how to generate. In other words hash
 it with a secret key or some such that only the server has.  So the cookie
 exists but the check fails, and as soon as the session ends the cookie is
no
 longer stored.

 http://danconia.org





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



Re: Perl Vs ...

2003-09-22 Thread Tassilo von Parseval
On Sun, Sep 21, 2003 at 09:28:21PM -0400 Paul Kraus wrote:

 Perl was pretty much my first language. Not counting Business Basic and same
 old Pascal from high school. The more I learn the more I see that perl can
 handle just about anything I want to do. How do you go about deciding if you
 should use another tool such as C++ over perl? I am thinking about learning
 another language and trying to decide what language would be best to learn.
 To expand my skill set. Suggestions, Ideas, Book Recommendations?

I was always of the opinion that knowing C is one of the essential
things. Too many vital stuff is nowadays hidden away from the user in
more recent languages (such as portability issues and memory management
for instance).

C also has the advantage that it integrates tightly into perl. You can
write Perl modules as C extensions which is fun and will teach you a lot
about perl and how interpreters in general work.

However, C's learning curve is rather steep (but shorter than Perl's).

Tassilo
-- 
$_=q#,}])!JAPH!qq(tsuJ[{@tnirp}3..0}_$;//::niam/s~=)]3[))_$-3(rellac(=_$({
pam{rekcahbus})(rekcah{lrePbus})(lreP{rehtonabus})!JAPH!qq(rehtona{tsuJbus#;
$_=reverse,s+(?=sub).+q#q!'qq.\t$.'!#+sexisexiixesixeseg;y~\n~~;eval


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



Re: Perl Vs ...

2003-09-22 Thread Marc Adler
* Tassilo von Parseval [EMAIL PROTECTED] [2003-09-21 20:27]:
 On Sun, Sep 21, 2003 at 09:28:21PM -0400 Paul Kraus wrote:
 
  Perl was pretty much my first language. Not counting Business Basic and same
  old Pascal from high school. The more I learn the more I see that perl can
  handle just about anything I want to do. How do you go about deciding if you
  should use another tool such as C++ over perl? I am thinking about learning
  another language and trying to decide what language would be best to learn.
  To expand my skill set. Suggestions, Ideas, Book Recommendations?
 
 I was always of the opinion that knowing C is one of the essential
 things. Too many vital stuff is nowadays hidden away from the user in
 more recent languages (such as portability issues and memory management
 for instance).
 
 C also has the advantage that it integrates tightly into perl. You can
 write Perl modules as C extensions which is fun and will teach you a lot
 about perl and how interpreters in general work.
 
 However, C's learning curve is rather steep (but shorter than Perl's).

Would learning C++ do just as well? On many of the C/C++-related
websites/newsgroups they say that there's no point in learning C because
you'll have to unlearn a bunch of bad habits when you learn C++ (I
don't know either language, so I don't know what those habits might be).

Also, how commonly is perl learned as a first language?

 $_=q#,}])!JAPH!qq(tsuJ[{@tnirp}3..0}_$;//::niam/s~=)]3[))_$-3(rellac(=_$({
 pam{rekcahbus})(rekcah{lrePbus})(lreP{rehtonabus})!JAPH!qq(rehtona{tsuJbus#;
 $_=reverse,s+(?=sub).+q#q!'qq.\t$.'!#+sexisexiixesixeseg;y~\n~~;eval

What's all that?

-- 
Sun, 21 Sep 2003 21:12:00 -1000
Linux 2.4.20-20.9
Mutt 1.4.1i (2003-03-19)


Fear not the earl lest I had conquered him and peopled else this isle
with Calibans.
-- the surreal compliment generator

Marc Adler

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



Re: using foreach on an array

2003-09-22 Thread Marius Roets
Wow, I didn't know that, and I have been using Perl for some time. Never
too old to learn.


The answer is in 'perldoc perlsyn':

   The foreach loop iterates over a normal list value and sets the
vari- 
   able VAR to be each element of the list in turn.  If the variable is

   preceded with the keyword my, then it is lexically scoped, and is

   therefore visible only within the loop.  Otherwise, the variable is

   implicitly local to the loop and regains its former value upon
exiting 
   the loop.  If the variable was previously declared with my, it
uses 
   that variable instead of the global one, but it's still localized to

   the loop.

The last sentence is important here: Even though $t is a lexical
variable in your program, it's value is nonetheless localized inside
the
loop and regains its previous value when leaving it.

Tassilo
-- 
$_=q#,}])!JAPH!qq(tsuJ[{@tnirp}3..0}_$;//::niam/s~=)]3[))_$-3(rellac(=_$({
pam{rekcahbus})(rekcah{lrePbus})(lreP{rehtonabus})!JAPH!qq(rehtona{tsuJbus#;
$_=reverse,s+(?=sub).+q#q!'qq.\t$.'!#+sexisexiixesixeseg;y~\n~~;eval


-- 
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: Perl Vs ...

2003-09-22 Thread Tassilo von Parseval
On Sun, Sep 21, 2003 at 09:17:38PM -1000 Marc Adler wrote:

 * Tassilo von Parseval [EMAIL PROTECTED] [2003-09-21 20:27]:

  I was always of the opinion that knowing C is one of the essential
  things. Too many vital stuff is nowadays hidden away from the user in
  more recent languages (such as portability issues and memory management
  for instance).
  
  C also has the advantage that it integrates tightly into perl. You can
  write Perl modules as C extensions which is fun and will teach you a lot
  about perl and how interpreters in general work.
  
  However, C's learning curve is rather steep (but shorter than Perl's).
 
 Would learning C++ do just as well? On many of the C/C++-related
 websites/newsgroups they say that there's no point in learning C because
 you'll have to unlearn a bunch of bad habits when you learn C++ (I
 don't know either language, so I don't know what those habits might be).

Well, the same is probably true the other way round. C and C++ are not
the same languages. If that would really matter, you could always only
learn one of them.

If one plans on learning both of them, C should come before, I think. C
is a minimal language whose concepts you should know when doing C++.
There are subtle differences between seemingly similar things though. A
good C++ introduction should mention them.

 Also, how commonly is perl learned as a first language?

I don't know. For me it was de-facto the first language. I learnt
Modula-3 before that but I'd rather not want to talk about that. Knowing
Perl made it pretty easy (in my perception) to learn other languages. In
my case this was mainly Java (unsuitable as first language because it
disallows too many things) and after that C (though: no matter which
language you learnt first, learning C will sooner or later make you send
curses towards heaven; so many things don't work in the beginning).

  $_=q#,}])!JAPH!qq(tsuJ[{@tnirp}3..0}_$;//::niam/s~=)]3[))_$-3(rellac(=_$({
  pam{rekcahbus})(rekcah{lrePbus})(lreP{rehtonabus})!JAPH!qq(rehtona{tsuJbus#;
  $_=reverse,s+(?=sub).+q#q!'qq.\t$.'!#+sexisexiixesixeseg;y~\n~~;eval
 
 What's all that?

It's a JAPH. See 'perldoc -q JAPH'. If you preserve the whitespacing of
the above, you can run it as Perl code.

Tassilo
-- 
$_=q#,}])!JAPH!qq(tsuJ[{@tnirp}3..0}_$;//::niam/s~=)]3[))_$-3(rellac(=_$({
pam{rekcahbus})(rekcah{lrePbus})(lreP{rehtonabus})!JAPH!qq(rehtona{tsuJbus#;
$_=reverse,s+(?=sub).+q#q!'qq.\t$.'!#+sexisexiixesixeseg;y~\n~~;eval


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



RE: Split based on length

2003-09-22 Thread NYIMI Jose (BMB)
I don't know which version of perl are you using but
I have just tried again the script i sent to you
And the ones with your modifications , both work well and do not
Die as you explained : fatal error x outside of string
Below is my perl -v output :
C:\perl -v

This is perl, v5.6.1 built for MSWin32-x86-multi-thread
(with 1 registered patch, see perl -V for more detail)

Copyright 1987-2001, Larry Wall

Binary build 631 provided by ActiveState Tool Corp. http://www.ActiveState.com
Built 17:16:22 Jan  2 2002


Perl may be copied only under the terms of either the Artistic License or the
GNU General Public License, which may be found in the Perl 5 source kit.

Complete documentation for Perl, including FAQ lists, should be found on
this system using `man perl' or `perldoc perl'.  If you have access to the
Internet, point your browser at http://www.perl.com/, the Perl Home Page.

José.

-Original Message-
From: zsdc [mailto:[EMAIL PROTECTED] 
Sent: Saturday, September 20, 2003 10:06 AM
To: NYIMI Jose (BMB)
Cc: [EMAIL PROTECTED]
Subject: Re: Split based on length


NYIMI Jose (BMB) wrote:

 I have an other request : code review :-)
 Below is my final code.
 I'm sure that you guys will find
 Some better style to write it ...

This code doesn't work with the input you sent me. It dies processing 
the third line of input (i.e. the first one which is not skipped) with 
fatal error x outside of string when get_fields calls unpack.

  sub get_fields{
my($str)[EMAIL PROTECTED];
my $format=$index_len $name_len $way_len;
$format.= $delim_len $meas_len x $nof_meas;
unpack($format,$str); # === it dies here
  }

 From perldiag manpage: 'x outside of string (F) You had a pack template 
that specified a relative position after the end of the string being 
unpacked. See pack in perlfunc.'

Unfortunately I cannot help you with the debugging right now, but I hope 
others who helped you with unpack might be more up to date with your 
code and data.

Still, as you asked about style, I made few mostly cosmetic changes to 
your code. The output is identical, it does exactly the same thing as 
your original code, even reproducing the fatal error, but might be 
somewhat cleaner to work with. I also demonstrated some magic with 
print. So here's my refactored version of your code:

#!/usr/bin/perl

use strict;
use warnings;

#--
# Global variables
#--

my $group_len =  64;
my $index_len = 'A1';
my $name_len  = 'A6';
my $way_len   = 'A3';
my $delim_len = 'x1';
my $meas_len  = 'A5';
my $nof_meas  =  9;

#-
# Subroutines
#-

sub split_len {
   my ($str, $len) = @_;
   $str =~ /.{1,$len}/g;
}

sub get_fields {
   my $str = shift || $_;
   my $format = $index_len $name_len $way_len;
   $format .=  $delim_len $meas_len x $nof_meas;
   unpack $format, $str; # - DIES HERE: x outside of string
}

#--
# Main
#--

($,, $\) = (\t, \n);

while () {
 next if $.  3;
 /(\d{2}-\d{2}-\d{4}:\d{3})\s+(\d{2})(.+)/ or die Bad input\n;
 my ($date, $dummy, $str) = ($1, $2, $3);
 for (split_len $str, $group_len) {
print $date, get_fields;
 }
}

__END__

I'm sure it's going to get much cleaner in a while, when other people 
change few other things. Ask if you're not sure how the print works here 
but you might first read about $, and $\ (the output field separator 
and the output record separator) in perldoc perlvar.

Note that this code still dies on unpack, just like yours, so you still 
have to debug it anyway. Speaking about the unpack, I wouldn't use it 
here. For simple things it's great but with your data the format gets 
quite complicated. Take a look at these CPAN modules:

Parse::FixedLength
Data::FixedFormat
Text::FixedLength
Text::FixedLength::Extra
AnyData
AnyData::Format::Fixed
DBD::AnyData

I'm not sure which one would be best for you, but they all help handle 
fixed-length records data, exactly what you are doing manually.

For example DBD::AnyData (which would probably be an overkill here, but 
is definitely worth knowing about) is a driver for DBI. You can use the 
data like it was a table in an SQL database. It uses SQL::Statement as 
SQL parsing and processing engine.

The AnyData module helps you manipulate data in many formats (fixed 
length, tab delimited, pipe delimited, passwd style, CSV, XML, HTML 
tables, vertical/paragraph text files, etc.). You can use the data like 
it was a %hash or manipulate it with SQL queries with DBI and 
DBD::AnyData. AnyData also makes converting between formats very easy.

Parse::FixedLength is very powerful. You define a parser object, which 
then can parse data. You can subclass Parse::FixedLength and make using 
it in your main program very easy by just calling new method on your 
parser class and feeding the new object with data.

Data::FixedFormat is easier to use and its count keyword would be 
probably ideal for your needs here to use instead of get_fields 
subroutine, when you 

Printing Arrays

2003-09-22 Thread Desmond Lim
I have 3 arrays @arr1, @arr2 and @arr3.

I need to print them into the same file and I'm doing this.

open FILE, file name;
print FILE @arr1\n;
print FILE @arr2\n;
print FILE @arr3\n;
close FILE;

I would like to shorten it to

for ($i=0;$i4;$i++) {
  print FILE @arr$i\n;
}

I know there is an error but is there a work around to this?

Thanks.

Desmond

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



online favorites project

2003-09-22 Thread Todd W.
xposted to: perl.beginners, perl.beginners.cgi

I've wrote a web based program to store favorites online. I work on quite a
few computers each week between home, work, and school and its something
I've wanted for awhile. The program is account based so others can use it.
It is free to use. The home page is at:

http://waveright.homeip.net/products/FavoritesAnywhere.html

It works on IE 6 and NN 7.1. It should work on any Gecko 1.4 based browser.
Technically, it should work on anything that supports DOM Level 2, cookies,
and JavaScript. If you find it useful, please tell your friends about it.
You can get support at the link below.

It is free software. I have a stack of features I want to add to it. I would
like to invite other developers to work on it with me. The server side logic
is written in mod_perl. The pages are generated with Template::Toolkit. The
menu is generated with XSLT. The DHTML does alot of DOM work, and the menu
options talk to the server using RPC. The server uses RPC::XML, and the
client uses jsolait.

The idea is simple, so even beginners could contribute. User and developer
questions/suggestions can be posted at:

http://waveright.homeip.net/tools/phpBB2/index.php?c=5

Thanks eveyone,

Todd W.





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



Re: Printing Arrays

2003-09-22 Thread Rob Dixon
Desmond Lim wrote:

 I have 3 arrays @arr1, @arr2 and @arr3.

 I need to print them into the same file and I'm doing this.

 open FILE, file name;
 print FILE @arr1\n;
 print FILE @arr2\n;
 print FILE @arr3\n;
 close FILE;

 I would like to shorten it to

 for ($i=0;$i4;$i++) {
   print FILE @arr$i\n;
 }

 I know there is an error but is there a work around to this?

There should be no 'errors' as such, because what you've written
is valid Perl, but there are several problems here.

- Your 'open' statement is is doing

   open FILE, glob ('file name');

which I don't think you meant.

- This form of the 'for' statement is taken from C, and is
rarely the best way to do things in Perl. Your loop also
starts at zero, when there isn't a @arr0 variable. Use

  for (1 .. 3) {
:
  }

- The 'print' statement is expanding variables @arr and $i
separately in the string. @arr doesn't exist, so you'll just
get $i in the output records.


The answer to your question is that you need to use

@{qq(arr$i)}\n

as your string but, if anybody catches you doing it, I didn't
tell you, OK?

It's important to

  use strict;   # always
  use warnings; # usually

and 'strict' will, quite rightly, prevent you from doing anything
like this. In this case it's only possible because you've used
meaningless names for your arrays. (It's hard to guess what, say,
@arr2 contains without asking you.)

Just what is wrong with

  print FILE @arr1\n;
  print FILE @arr2\n;
  print FILE @arr3\n;

anyway? It's a great deal clearer than

  for (1 .. 3) {
print FILE @{qq(arr$i)}\n;
  }

and fractionally faster.

If you insist on doing it with 'strict' enabled then

  for ([EMAIL PROTECTED], [EMAIL PROTECTED], [EMAIL PROTECTED]) {
print @$_\n;
  }

is the way.

Cheers,

Rob



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



RE: Printing Arrays

2003-09-22 Thread Charles K. Clarkson
Desmond Lim [EMAIL PROTECTED] wrote:
: 
: I have 3 arrays @arr1, @arr2 and @arr3.
: 
: I need to print them into the same file and I'm doing this.
: 
: open FILE, file name;
: print FILE @arr1\n;
: print FILE @arr2\n;
: print FILE @arr3\n;
: close FILE;
: 
: I would like to shorten it to
: 
: for ($i=0;$i4;$i++) {
:   print FILE @arr$i\n;
: }
How about:

use strict;
use warnings;

my $filename = 'blah';

# always check to see if open succeeded
open FH, $filename or die Cannot open $filename: $!;

print FH @[EMAIL PROTECTED]@arr3\n;

close FH;
__END__

HTH,

Charles K. Clarkson
-- 
Head Bottle Washer,
Clarkson Energy Homes, Inc.
Mobile Home Specialists
254 968-8328



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



Re: Problem with input record separator

2003-09-22 Thread Rob Dixon

John W. Krahn wrote:

 Daniel Liston wrote:
 
  Here is a tool I use to unfold long lines in LDAP outputs.
  It also works on mailboxes that have the Received: lines
  or Content-*: lines folded.

 There are two things in your code that may cause a problem.


  #!/usr/bin/perl
 
  #syntax:  unfold.pl filename  newfilename
 
  if ($ARGV[0]) {
 local $/ = '';
 open(FILE, $ARGV[0]) or die can't open $ARGV[0]: $!\n;
 @records = FILE;
 close(FILE);
  }
  foreach $record (@records) {
 $record =~ s/\n\s//g;
 print $record\n\n;
  }

 You are removing a newline and a single whitespace character.  If your
 input looks like this:

 one
  two
  three

 Your substitution will result in:

 onetwothree

 And if your input looks like this:

 one
  two
  three

 Your substitution will result in:

 onetwothree

 However if you change the substitution it will screw up the record
 separator.  You should chomp the records when you read from the file and
 substitute all whitespace after the newline with a single space.

 #!/usr/bin/perl

 #syntax:  unfold.pl filename  newfilename

 @ARGV or die usage: $0 filename\n;

 my @records = do {
local ( $/, *FILE ) = '';
open FILE, $ARGV[0] or die can't open $ARGV[0]: $!;
grep chomp, FILE;

This will drop the last line of the file if there is no
terminating separator.

  grep {chomp, 1} FILE;


 foreach my $record ( @records ) {
$record =~ s/\n\s+/ /g;
print $record\n\n;
 }



...and even then the original problem was that the input
file doesn't contain empty lines, just blank ones with
whitespace before the record separator. Setting $/ = ''
won't work in this case, and the record split has to be
coded explicitly. If only you could write

  $/ = qr/\n(\s*\n)+/

then all would be well.

Rob



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



Re: Printing Arrays

2003-09-22 Thread Jenda Krynicky
From: Desmond Lim [EMAIL PROTECTED]
 I have 3 arrays @arr1, @arr2 and @arr3.

Do not do that!

http://www.oreillynet.com/pub/a/network/2001/05/18/perl_redflags.html
 
Jenda
= [EMAIL PROTECTED] === http://Jenda.Krynicky.cz =
When it comes to wine, women and song, wizards are allowed 
to get drunk and croon as much as they like.
-- Terry Pratchett in Sourcery


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



Re: Printing Arrays

2003-09-22 Thread Rob Dixon

Jenda Krynicky wrote:

 Desmond Lim wrote:

  I have 3 arrays @arr1, @arr2 and @arr3.

 Do not do that!

Yeah. I guess that summarises it :)

Rob



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



May I know the perl version of following shellscript

2003-09-22 Thread Saifuddin_Bohra/HSS




Hi,
  I am new to Perl. I have a follpwing shell script

if [ -n `netstat -na|grep LISTEN |grep 1099` ];
then
exit 0
else
exit 1
fi

I need the perl script for the same job.
and how to use this in another perl program
Any pointer ??

saifuddin


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



OT: RE: Apache Question

2003-09-22 Thread Wiggins d'Anconia


On Sun, 21 Sep 2003 22:39:30 -0700 (PDT), Ebaad Ahmed [EMAIL PROTECTED] wrote:

 Hi,
 
 I want to configure apache to host my own website on a
 solaris box. Please let me know how can I do it, I
 have read the FM but could not be confident enough to
 make the move.
 

Start here: http://httpd.apache.org

This is a Perl group.

http://danconia.org

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



Re: May I know the perl version of following shellscript

2003-09-22 Thread Jeff Westman

--- Saifuddin_Bohra/[EMAIL PROTECTED] wrote:

 Hi,
   I am new to Perl. I have a follpwing shell script
 
 if [ -n `netstat -na|grep LISTEN |grep 1099` ];
 then
 exit 0
 else
 exit 1
 fi
 
 I need the perl script for the same job.
 and how to use this in another perl program
 Any pointer ??
 
 saifuddin

This should work .

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

if ( length(qx(netstat -na|grep LISTEN |grep 1099))  0 ) {
exit(0);
}
else {
exit(1);
}

(There are ways to shorten this, but this is the basic code I think you are
looking for)


-Jeff


__
Do you Yahoo!?
Yahoo! SiteBuilder - Free, easy-to-use web site design software
http://sitebuilder.yahoo.com

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



Re: Perl Vs ...

2003-09-22 Thread Shlomi Fish
On Sun, 21 Sep 2003, Paul Kraus wrote:

 Perl was pretty much my first language. Not counting Business Basic and same
 old Pascal from high school. The more I learn the more I see that perl can
 handle just about anything I want to do. How do you go about deciding if you
 should use another tool such as C++ over perl? I am thinking about learning
 another language and trying to decide what language would be best to learn.
 To expand my skill set. Suggestions, Ideas, Book Recommendations?


I would suggest learning several things:

1. C is a good language to know as it is very close to machine language
and gives you important insights about programming and computers
architecture. I can't really recommend a book because I first learned it
from the Turbo C++ 3.0 manual, but I heard KR's or A Book on C are
good.

2. The book Structure and Interpretation of Computer Programs is very
interesting and enlightening. It is available online here:

http://mitpress.mit.edu/sicp/

It teaches programming through Scheme, a dialect of LISP that is very
similar to Perl. I fully understood closures after reading this book.
I also suggest doing some of the exercises in the book, because they give
a whole new dimension to learning it.

3. After you tackled Scheme and lexical scoping, then Lambda Calculus is
an extra useful enlightenment. It's a very minimalistic language that is
actually quite usable. I learned LC from a book I found about it in the
library, but I wrote a lecture about it with detailed slides:

http://vipe.technion.ac.il/~shlomif/lecture/Lambda-Calculus/

4. I found learning Haskell to be quite enlightening and I still like to
experiment with it on occasions. I learned it from the so-called Gentle
Introduction to Haskell:

http://www.haskell.org/tutorial/

O'Caml is a similar language that is more usable, but less elegant.

5. Matlab is a very nice tool for making engineering calculations. If you
deal with these kind of things, it is useful to know. Perl has an
equivalent toolkit in PDL - the Perl data language.

6. Paul Graham's On Lisp book is also very nice.

http://www.paulgraham.com/onlisp.html

Available for free download online.

---

Regards,

Shlomi Fish





 Paul Kraus





--
Shlomi Fish[EMAIL PROTECTED]
Home Page: http://t2.technion.ac.il/~shlomif/

An apple a day will keep a doctor away. Two apples a day will keep two
doctors away.

Falk Fish

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



Re: Perl Vs ...

2003-09-22 Thread Dan Anderson
 How do you go about deciding if you
 should use another tool such as C++ over perl? 

You basically look at the advantages and disadvantages of different
languages and decide which will be best for the task.  For instance, if
you wanted to write a quick script to generate a Template file and fill
in some values (possibly by querying the user) it would be a nightmare
to implement in C++ compared with Perl.

At the same time, try programming a game making use of 3D graphics and
hardware acceleration in Perl...  It's probably not something you would
want to do.  You would want to use C or C++. 

So it all depends on what you are interested in and what you want to
do.  Do you want to do web development?  You could write a CGI program
in C++, but probably wouldn't want to (Perl or PHP would be a better
choice).  Do you want to create games and programs that a user can
interact with from a web page?  Better check out Java or .NET -- because
a CGI script is done executing when a web page is displayed.

The list goes on and on.  C++ is a bad choice to use if you want
portability without headache, Java would be a better choice (although
this is not entirely true, Java can have its own quirks as well).

So look and see what you want to do.  And find a language based on that

-Dan


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



Re: OT: RE: Apache Question

2003-09-22 Thread Ebaad Ahmed
I'm sorry to post a unrelated question on the list,
but I was hoping somebody will have some kind of
answer for me since most of the people on the list
have their own sites and email addresses.

Really sorry to ask a question like that.

Ebaad.

--- Wiggins d'Anconia [EMAIL PROTECTED] wrote:
 
 
 On Sun, 21 Sep 2003 22:39:30 -0700 (PDT), Ebaad
 Ahmed [EMAIL PROTECTED] wrote:
 
  Hi,
  
  I want to configure apache to host my own website
 on a
  solaris box. Please let me know how can I do it, I
  have read the FM but could not be confident enough
 to
  make the move.
  
 
 Start here: http://httpd.apache.org
 
 This is a Perl group.
 
 http://danconia.org


__
Do you Yahoo!?
Yahoo! SiteBuilder - Free, easy-to-use web site design software
http://sitebuilder.yahoo.com

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



RE: Perl Vs ...

2003-09-22 Thread Akens, Anthony
I first learned C, then C++, which was a good route for me.  It gave
me a solid background in programming and structure that lends itself
well to learning other languages.  I've begun to pick up perl in order
to aid in system administration, though I've been told that Python is
a great tool for that task, also.

As many have said, it depends a lot on what you want to accomplish.
Look at what you want to do, and it will often dictate the road to
take to get there.


Tony

-Original Message-
From: Dan Anderson [mailto:[EMAIL PROTECTED]
Sent: Monday, September 22, 2003 10:52 AM
To: Paul Kraus
Cc: 'perl beginners'
Subject: Re: Perl Vs ...


 How do you go about deciding if you
 should use another tool such as C++ over perl? 

You basically look at the advantages and disadvantages of different
languages and decide which will be best for the task.  For instance, if
you wanted to write a quick script to generate a Template file and fill
in some values (possibly by querying the user) it would be a nightmare
to implement in C++ compared with Perl.

At the same time, try programming a game making use of 3D graphics and
hardware acceleration in Perl...  It's probably not something you would
want to do.  You would want to use C or C++. 

So it all depends on what you are interested in and what you want to
do.  Do you want to do web development?  You could write a CGI program
in C++, but probably wouldn't want to (Perl or PHP would be a better
choice).  Do you want to create games and programs that a user can
interact with from a web page?  Better check out Java or .NET -- because
a CGI script is done executing when a web page is displayed.

The list goes on and on.  C++ is a bad choice to use if you want
portability without headache, Java would be a better choice (although
this is not entirely true, Java can have its own quirks as well).

So look and see what you want to do.  And find a language based on that

-Dan


-- 
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: Problem with input record separator

2003-09-22 Thread John W. Krahn
Rob Dixon wrote:
 
 John W. Krahn wrote:
 
  my @records = do {
 local ( $/, *FILE ) = '';
 open FILE, $ARGV[0] or die can't open $ARGV[0]: $!;
 grep chomp, FILE;
 
 This will drop the last line of the file if there is no
 terminating separator.
 
   grep {chomp, 1} FILE;

Or:

grep [ chomp ], FILE;



John
-- 
use Perl;
program
fulfillment

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



Re: May I know the perl version of following shellscript

2003-09-22 Thread John W. Krahn
Saifuddin Bohra/Hss wrote:
 
 Hi,

Hello,

   I am new to Perl. I have a follpwing shell script
 
 if [ -n `netstat -na|grep LISTEN |grep 1099` ];
 then
 exit 0
 else
 exit 1
 fi
 
 I need the perl script for the same job.
 and how to use this in another perl program
 Any pointer ??


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

open PIPE, 'netstat -na |' or die Cannot open pipe from netstat: $!;

while ( PIPE ) {
exit 0 if /LISTEN/ and /1099/;
}
exit 1;

__END__



John
-- 
use Perl;
program
fulfillment

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



stop/start

2003-09-22 Thread rmck
Hi

I'm trying to get this to work in perl. 

I want to start a unix process send it to a log file. Then at midnight kill it and 
restart it, with the date at the top.

I'm starting with the following but the intial start of the proccess is not working 
right:

#!/bin/perl
$date = `date | awk '{print $4}'`;
$snoop = /usr/sbin/snoop;
$filename = `date +%y%m%d%H%M`.sno;
$logfile = /opt/$filename;
$pid = `/bin/pgrep snp.pl`;
 
system(/usr/sbin/snoop -d ge0 -ta  $logfile );
  
 
until (1 eq 0){
if ($date == 00:00:00){
system(/bin/pkill -P $pid);
print === `date` ==\n  $logfile;
system(/usr/sbin/snoop -d ge0 -ta  $logfile );
}
  }


Any suggestions would be helpfull. 
thanks
rob

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



Re: nested anonymous reference syntax

2003-09-22 Thread david
[EMAIL PROTECTED] wrote:

 Hello,
 
 I'm having trouble grasping the syntax to perform foreach operation on an
 anonymous array within an anonymous hash reference.
 
 my $hashRef = { bah = humbug,
list = [ lions, tigers, bears, oh_my ],
woo = hoo };

here you have a hash ref named $hashRef

 
 How can I run a foreach on every item in that anonymous array reference
 that
 is a value of the key list in the hash reference?  I'm having great
 difficulties getting this to work.  Is it even possible without nested
 foreach
 structures?  I would think it would be something like:
 
 foreach my $listItem (@{$hashref{list}}) {
print $_list item is one item of the array!  Woo hoo!\n;
 }

here you are trying to access the 'list' slot of a hash named $hashref which 
on course is different than $hashRef you declared above. not to mention 
that you are not treating $hashref as hash reference, you are using it as a 
hash. which one is it? is $hashref really a hash reference or just a hash? 
is $hashRef the same as $hashref?

if $hashref is the same as $hashRef and it's really a hash reference, try:

for(@{$hashRef-{list}}){
print $_\n;
}

if $hashref is NOT the same as $hashRef and it's really just a hash, you 
have the right syntax:

for(@{$hashref{list}}){
print $_\n;
}

david
-- 
$_=q,015001450154015401570040016701570162015401440041,,*,=*|=*_,split+local$;
map{~$_1{$,=1,[EMAIL PROTECTED]||3])=~}}0..s~.~~g-1;*_=*#,

goto=print+eval

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



Re: perl(this) and perl(the)

2003-09-22 Thread Rob Dixon
Eric Rose wrote:

 This is the error message that I get when installing Mysql.

 #rpm -Uvh MySQL-client-4.0.15-0.i386.rpm
 error:  Failed dependencies:
 perl(the) is needed by MySQL-client-4.0.15-0.i386.rpm

I'm playing away here, as I know nothing about RPM other than
that it is a package manager and pro9bably specific to RedHat
Linux.

Having said that, it looks like you are trying to install a
module called MySQL::client, which I've never heard of and
isn't available on the definitive CPAN site.

Unless you have a reason to go along this route (when I think
you will need Linux-specific help) you should use the Database
Independent interface module 'DBI' together with the MySQL
driver module 'DBD::MySQL', with which most Perl database
programmers are familiar.

I hope this helps in some way.

Rob



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



Re: perl(this) and perl(the)

2003-09-22 Thread Rob Dixon
Rob Dixon wrote:
 .. you should use the Database Independent interface module
 'DBI' together with the MySQL driver module 'DBD::MySQL', with
 which most Perl database programmers are familiar.

Strictly, that should be 'DBD::mysql'.

/R



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



Help needed on Telnet.pm

2003-09-22 Thread Pandey Rajeev-A19514
Hi,

I need an urgent help and direction regarding capture of scrolling text using the 
Telnet.pm module.

Apart from the False Telnet servers(unusual ascii characters) described in the module, 
ther is one more scenario where the output on a telnet session shell does not get 
captured.  

Does Telnet.pm capture output from other than the STDOUT ?

I have a case where I telnet to a router through a console connection. All commands 
work well and returns the output. 
But, there is a special command that turns on the monitoring system of that machine. 
So some text keep on scrolling (text that appear even without issuing any user 
command). Such texts are not captured by telnet module. 

I am not doing any mistake in setting the prompt.

In expect language, I am able to capture the scrolling text but not in Telnet.pm.

I am in urgent need.

Please tell me if I am missing something.

Thanks in advance.
Rajeev


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



RE: Looking for a good OpenSSL/Perl library

2003-09-22 Thread Rajesh Dorairajan
Well, I looked at this library. But I'm afraid this won't serve the purpose
I've in mind. The specific needs I'm looking for are:

* Parse a certificate and return it's details (Such as DN, Issuer)
* Verify a certificate's integrity
* get a PEM encoded certificate from a DER-encoded and vice-versa
* Create Certificate request in PKCS10 format

All these are supported by OpenSSL currently. I just wanted to find a client
library of OpenSSL that performs these functions instead of calling OpenSSL
directly using an IPC call. But looks like I do not have much of a choice.
Thank you very much for your suggestion though.

Rajesh

-Original Message-
From: Wiggins d'Anconia [mailto:[EMAIL PROTECTED]
Sent: Saturday, September 20, 2003 10:05 AM
To: Rajesh Dorairajan
Cc: '[EMAIL PROTECTED]'
Subject: Re: Looking for a good OpenSSL/Perl library


Rajesh Dorairajan wrote:
 Does anyone know where I can find a good implementation of OpenSSL library
 on Perl. I tried Massimmilio Pala's OpenCA::OpenSSL and ran into some
issues
 there. Specifically, I am not able to generate a request. Whatever DN
string
 I pass does not seem to be acceptable to the underlying OpenSSL library. I
 went through the source and could not figure out where the problem lies. I
 searched CPAN and openssl sites and they do not seem to have a better
 implementation of OpenSSL. Anyone know  where I can find a more complete
 implementation of OpenSSL in Perl?
 

Will this work...?

http://search.cpan.org/author/BEHROOZI/IO-Socket-SSL-0.95/SSL.pm

http://danconia.org


Re: perl(this) and perl(the)

2003-09-22 Thread Daniel Staal
--On Monday, September 22, 2003 19:23 +0100 Rob Dixon 
[EMAIL PROTECTED] wrote:

I'm playing away here, as I know nothing about RPM other than
that it is a package manager and pro9bably specific to RedHat
Linux.
Having said that, it looks like you are trying to install a
module called MySQL::client, which I've never heard of and
isn't available on the definitive CPAN site.
Unless you have a reason to go along this route (when I think
you will need Linux-specific help) you should use the Database
Independent interface module 'DBI' together with the MySQL
driver module 'DBD::MySQL', with which most Perl database
programmers are familiar.
You've got Perl on the brain.  ;-)  An RPM doesn't have to be a Perl 
module.  What he's trying to do is install a database client (like 
you would write using the DBI) program (MySQL-client-4.0.15-0) that 
happens to depend on Perl.  (Presumably it is partially written in 
Perl, maybe using the DBI.)  The install is complaining that Perl is 
not installed.

I missed the original question, but I would echo the advice to use 
your distro's help resources to fix this, assuming you are sure Perl 
is installed.

Daniel T. Staal

---
This email copyright the author.  Unless otherwise noted, you
are expressly allowed to retransmit, quote, or otherwise use
the contents for non-commercial purposes.  This copyright will
expire 5 years after the author's death, or in 30 years,
whichever is longer, unless such a period is in excess of
local copyright law.
---
--
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]


Re: Help needed on Telnet.pm

2003-09-22 Thread Daniel Staal


--On Tuesday, September 23, 2003 0:02 +0530 Pandey Rajeev-A19514 
[EMAIL PROTECTED] wrote:

Does Telnet.pm capture output from other than the STDOUT ?

I have a case where I telnet to a router through a console
connection. All commands work well and returns the output.  But,
there is a special command that turns on the monitoring system of
that machine. So some text keep on scrolling (text that appear even
without issuing any user command). Such texts are not captured by
telnet module.
I am not doing any mistake in setting the prompt.

In expect language, I am able to capture the scrolling text but not
in Telnet.pm.
Sounds like Telnet.pm only captures from STDOUT.  You are turning on 
error messages, and they are getting written to STDERR.  You'll have 
to combine them.  If the router you are connecting to is Unix-like 
you should be able to add '21' to the end of the prompt and have 
STDERR written to STDOUT.

Daniel T. Staal

---
This email copyright the author.  Unless otherwise noted, you
are expressly allowed to retransmit, quote, or otherwise use
the contents for non-commercial purposes.  This copyright will
expire 5 years after the author's death, or in 30 years,
whichever is longer, unless such a period is in excess of
local copyright law.
---
--
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]


Re: Problem with input record separator

2003-09-22 Thread Daniel Liston
Daniel Liston wrote:

Here is a tool I use to unfold long lines in LDAP outputs. It
also works on mailboxes that have the Received: lines or
Content-*: lines folded.


There are two things in your code that may cause a problem.



#!/usr/bin/perl

#syntax:  unfold.pl filename  newfilename

if ($ARGV[0]) { local $/ = ''; open(FILE, $ARGV[0]) or die
can't open $ARGV[0]: $!\n; @records = FILE; close(FILE); } 
foreach $record (@records) { $record =~ s/\n\s//g; print
$record\n\n; }


You are removing a newline and a single whitespace character.  If
your input looks like this:
one two three
In the case of (Received|Content-.*): headers, I simply
replace my substitution with s/\n\s/ /g, as folding is
accomplished between words and prefixing continuation
lines with a tab character.
Your substitution will result in:

onetwothree

And if your input looks like this:

one two three

Your substitution will result in:

onetwothree
In LDAP extracts, long lines are not split at the end of a
word, so this is actually what I want to do here.  I have
to be able to reconnect words without putting a space back
in.
However if you change the substitution it will screw up the record 
separator.  You should chomp the records when you read from the file
and substitute all whitespace after the newline with a single space.

#!/usr/bin/perl

#syntax:  unfold.pl filename  newfilename

@ARGV or die usage: $0 filename\n;

my @records = do { local ( $/, *FILE ) = ''; open FILE, $ARGV[0] or
die can't open $ARGV[0]: $!; grep chomp, FILE; } foreach my
$record ( @records ) { $record =~ s/\n\s+/ /g; print $record\n\n; }


Or you could pare that down a bit.  :-)

#!/usr/bin/perl

#syntax:  unfold.pl filename  newfilename

@ARGV or die usage: $0 filename\n;

$/ = ''; print for grep [ chomp, s/\n\s+/ /g, s/\z/\n\n/ ], ;
I like that line.  I will have to experiment with it.




[snip]

The second paragraph could be modified to fit your needs rather
simply.
$count = 0; foreach $record (@records) { @recordnumber$count =
$record;
^^^
Thanks.  I should have tried that before posting

The intent was to make hashes (named on the fly)
of the lines in each record.
Example,
@recordnumber0 = \nAA\nAAA
@recordnumber1 = \nBB\nBBB
@recordnumber2 = \nCC\nCCC
$ perl -le'$record = 234; @recordnumber$count = $record;' Scalar
found where operator expected at -e line 1, near 
@recordnumber$count (Missing operator before $count?) syntax error
at -e line 1, near @recordnumber$count  Execution of -e aborted due
to compilation errors.

$ perl -le '$record = AAA\nAAA\nAAA; @recordnumber{$count}= $record;'

Wrapping $count in {} braces gets past the missing operator error.


$count++ }


John -- use Perl; program fulfillment


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


Re: stop/start

2003-09-22 Thread Stephen Hardisty
Hi,
you could write a handler for the signal alarm that starts a new process and
kills the current:
$SIG{ALRM} = {
`this-script`;
exit;
};

At the beginning of the script set the alarm to go off 24 hours later:
alarm(84600);

DISCLAIMER: haven't really thought it through and it's really hacky, so
don't have a go at me (but it is quick to do).

Cheers!



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



Re: stop/start

2003-09-22 Thread Stephen Hardisty
 $SIG{ALRM} = {
 `this-script`;
 exit;
 };

Sorry, didn't think it through (before anybody notices.). Remove the
thing that executes the script (the bit in backticks) and just have the
process start on a cron job.

Tired, apologies.


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



Re: Problem with input record separator

2003-09-22 Thread Rob Dixon
Daniel Liston wrote:

 John W. Krahn wrote:

  Or you could pare that down a bit.  :-)
 
  #!/usr/bin/perl
 
  #syntax:  unfold.pl filename  newfilename
 
  @ARGV or die usage: $0 filename\n;
 
  $/ = ''; print for grep [ chomp, s/\n\s+/ /g, s/\z/\n\n/ ], ;

 I like that line.  I will have to experiment with it.

Anything that John writes after a ':-)' should be taken
with a (large) pinch of salt.

:-)

/R



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



Re: perl(this) and perl(the)

2003-09-22 Thread Rob Dixon
Daniel Staal wrote:

 --On Monday, September 22, 2003 19:23 +0100 Rob Dixon
 [EMAIL PROTECTED] wrote:

  I'm playing away here, as I know nothing about RPM other than
  that it is a package manager and pro9bably specific to RedHat
  Linux.
 
  Having said that, it looks like you are trying to install a
  module called MySQL::client, which I've never heard of and
  isn't available on the definitive CPAN site.
 
  Unless you have a reason to go along this route (when I think
  you will need Linux-specific help) you should use the Database
  Independent interface module 'DBI' together with the MySQL
  driver module 'DBD::MySQL', with which most Perl database
  programmers are familiar.

 You've got Perl on the brain.  ;-)  An RPM doesn't have to be a Perl
 module.  What he's trying to do is install a database client (like
 you would write using the DBI) program (MySQL-client-4.0.15-0) that
 happens to depend on Perl.  (Presumably it is partially written in
 Perl, maybe using the DBI.)  The install is complaining that Perl is
 not installed.

Then I'm glad I qualified my answer. But please enlighten me: what
sort of beast is an RPM 'package'. The error message

Eric Rose wrote:
  #rpm -Uvh MySQL-client-4.0.15-0.i386.rpm
  error:  Failed dependencies:
  perl(the) is needed by MySQL-client-4.0.15-0.i386.rpm

looks like OO terminology but is nonsense in a Perl context. My first
guess would be that an RPM distribution of Perl must be installed, but
now I'm /way/ outside my remit. The bottom line is that this is an RPM
error message to be fought by an RPM gladiator.

 I missed the original question, but I would echo the advice to use
 your distro's help resources to fix this, assuming you are sure Perl
 is installed.

I don't think the original question was posted to the list at all. Tell
us Wiggins?

Cheers all,

Rob



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



Silly question

2003-09-22 Thread Gupta, Sharad

Hi ALL,

I know i am missing something somewhere:


perl -e '  
package Foo;   
use overload q() = sub {return shift-{bar}};   
$s = bless{bar=hello}, Foo;   
print $s\n 
 '

prints hello.


Whereas:

perl -e ' 
package Foo;   
use overload q() = sub {return shift-{bar}};   
$s = bless{bar=hello},Foo;   
$wilma = how r u;   
print $wilma\n  
 '

prints how r u.


Why is'nt it overloading   in the second case??. I was expecting it to again print 
hello.


Thanx for showing me light,
-Sharad


Re: grep with [ ] brackets ... ?

2003-09-22 Thread John W. Krahn
Luke Bakken wrote:
 
 I'd thought I'd seen everything with perl until I saw John Krahn give
 this code as a solution:
 
 #syntax:  unfold.pl filename  newfilename
 
 @ARGV or die usage: $0 filename\n;
 $/ = '';
 print for grep [ chomp, s/\n\s+/ /g, s/\z/\n\n/ ], ;

It's just a different way of writing:

print for map { chomp; s/\n\s+/ /g; s/\z/\n\n/; $_ } ;


Perhaps I shouldn't get too cute on the beginners list?  :-)


 I've never seen grep used with [ ] brackets before - it works the same
 with { }:
 
 print for grep { chomp, s/\n\s+/ /g, s/\z/\n\n/ } ;

This is not the same and does not do the same thing.

 How do the brackets fit into the grep EXPR, LIST form given in the
 docs?

grep has two forms:

grep { BLOCK } LIST

And:

grep EXRESSION, LIST


The first form allows multiple statements and lexically scoped variables
because it uses a code block.  The second form must have a single
expression.  grep evaluates the expression and if it is true passes the
current list element through to the left.  Putting [] around the
expression creates an anonymous array which in boolean context is always
true so that all elements of the list are passed through with the side
effect that they are modified by the expression in the anonymous array.


John
-- 
use Perl;
program
fulfillment

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