Re: monitor for a filename

2004-05-07 Thread John W. Krahn
Charles Farinella wrote:
> 
> I need to look at a directory for about 90 seconds, and if a certain
> file shows up, do something with it.  A pointer to a man page or any
> reference would be appreciated.

If you know the file name in advance then use one of the file test
operators like -e or maybe -s:

perldoc -f -X

Or you could use stat or open which will return undef and report an
error through $! if the file does not exist.

perldoc -f stat
perldoc -f open

If you only know part of the file name you could use glob or
opendir/readdir.

perldoc -f glob
perldoc -f opendir
perldoc -f readdir



John
-- 
use Perl;
program
fulfillment

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




Re: Array in a regexp

2004-05-07 Thread John W. Krahn
Jason Dusek wrote:
> 
> Hi List,

Hello,

> Let's say I want to know if anything in @ARGV has one of a certain list
> of suffixes in it. So I write:
> 
>foreach (@ARGV) {
>  print if (/\.(fish|foul)$/);
>}
> 
> But if I have a long list of suffixes, then I would like to store the
> suffixes in an array, and then evaluate the array in my regular
> expression. What does this? I've tried:
> 
>@SUFF = (fish,foul);
>foreach (@ARGV) {
>  print if (/\.(@SUFFIXES)$/);
>}
> 
> and also:
> 
>@SUFF = (fish,foul);
>foreach (@ARGV) {
>  print if (/\.(@[EMAIL PROTECTED])$/);
>}
> 
> but I can't get it to work.


To make sure that it works correctly you have to join each suffix with a
'|' character between them and ensure that any special regular
expression characters are escaped.  Also, using qr// to pre-compile the
regexp may help.

my @SUFF = qw( fish foul );
my $match = join '|', map "\Q$_", @SUFF;
foreach ( @ARGV ) {
  print if /\.(?:$match)$/;
}

Or better:

my @SUFF = qw( fish foul );
my $match = qr/\.(?:@{[ join '|', map "\Q$_", @SUFF ]})$/;
foreach ( @ARGV ) {
  print if /$match/;
}



John
-- 
use Perl;
program
fulfillment

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




RE: process signals

2004-05-07 Thread Bob Showalter
[EMAIL PROTECTED] wrote:
> If you dont understand my question then I assume you do not know unix
> or tail -f ?

You're right, those are both new to me.

>  I want to after a sleep of 5-8 seconds, send a kill
> signal to the previous command then increment the counter.  thank
> you!

Sorry, I think I understand the question now. If you want to run something
like tail -f that never exits and then kill it after a while, you'll need
the PID number. So you can't run it via system() or backticks, since those
don't return until the subprocess exits.

Something along these lines should work inside your loop:

 my $pid = open(PIPE, "tail -f /etc/passwd |") or die $!;
 local $SIG{ALRM} = sub { kill 'TERM', $pid };
 alarm 5;
 print while();
 alarm 0;
 close PIPE;

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




RE: process signals

2004-05-07 Thread Jayakumar Rajagopal
Bottom posted:

On Friday 07 May 2004 11:00 am, [EMAIL PROTECTED] wrote:
> yeah ok whatever  I want to use perl not ksh...as simple as that.
>
> Derek B. Smith
> OhioHealth IT
> UNIX / TSM / EDM Teams
>
>
>
>
>
>
> "Jayakumar Rajagopal" <[EMAIL PROTECTED]>
> 05/07/2004 01:16 PM
>
>
> To: <[EMAIL PROTECTED]>, "Bob Showalter"
> <[EMAIL PROTECTED]> cc: "Beginners Perl"
> <[EMAIL PROTECTED]>
> Subject:RE: process signals
>
>
> Mr Smith,
> I saw your elementary question at about 8:50 AM. I did not 
answer
> it, since it was not clear to me too. I have seen Bob ( who I have never
> spoken with or by no means friend of me) answering good, difficult
> questions very legibly. If you think you have know better unix, then you
> may kindly let us know :
>   1) why were you not able to use unix system("kill..") command, 
than
> waiting for perl group to answer?
>   2) how you can print "\n" while 'command' has already been writing
> the log file. (in case 'command was in background')
>   3) don't you think you contradict either in (2) or in trying to
> signal the process that is already over before print "\n" (in case not 
in
> background)
>
> If you want to send singal hangup the process use : kill HUP => $PID
>
> with regards,
> Jay
> -Original Message-
> From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED]
> Sent: Friday, May 07, 2004 12:36 PM
> To: Bob Showalter
> Cc: Beginners Perl
> Subject: RE: process signals
>
>
> If you dont understand my question then I assume you do not know unix or
> tail -f ?  I want to after a sleep of 5-8 seconds, send a kill signal to
> the previous command then increment the counter.  thank you!
>
>
>
> Derek B. Smith
> OhioHealth IT
> UNIX / TSM / EDM Teams
>
>
>
>
>
>
> Bob Showalter <[EMAIL PROTECTED]>
> 05/07/2004 10:57 AM
>
>
> To: "'[EMAIL PROTECTED]'" <[EMAIL PROTECTED]>,
> Beginners Perl
> <[EMAIL PROTECTED]>
> cc:
> Subject:RE: process signals
>
> [EMAIL PROTECTED] wrote:
> > I have an application system command that is like tail -f in UNIX and
> > I want to say
> >
> > x=1
> > while x < 10
> > do
> > 'command'  append to log
> > print "\n" append to log
> > issue HANGUP or KILL SIGNAL
> > x+=1
> > done
> >
> > How do I issue a hangup signal to this process using perl?
>
> I'm not sure I understand your problem, but the perl way to send a 
signal
> is
> with the kill() function. The way to catch a signal is by installing a
> handler using the %SIG hash.
>
> perldoc -f kill
> perldoc perlipc

Hi Mr.Smith,
   If you are more comfortable with shell scripting, and need to solve it urgently 
, you may write small sh script like this and call it from perl script:
 
command &
sleep 6
kill -HUP $!
  echo "\n" >> log

with regards,
Jay


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




Re: process signals

2004-05-07 Thread DBSMITH
thank you!  This was all I wanted as I am teaching myself perl and am 
still new.

Derek B. Smith
OhioHealth IT
UNIX / TSM / EDM Teams






Phil Schaechter <[EMAIL PROTECTED]>
05/07/2004 02:08 PM

 
To: [EMAIL PROTECTED]
cc: 
Subject:Re: process signals


They explained it to you.  Use the kill() function in perl.

-Phil

On Friday 07 May 2004 11:00 am, [EMAIL PROTECTED] wrote:
> yeah ok whatever  I want to use perl not ksh...as simple as that.
>
> Derek B. Smith
> OhioHealth IT
> UNIX / TSM / EDM Teams
>
>
>
>
>
>
> "Jayakumar Rajagopal" <[EMAIL PROTECTED]>
> 05/07/2004 01:16 PM
>
>
> To: <[EMAIL PROTECTED]>, "Bob Showalter"
> <[EMAIL PROTECTED]> cc: "Beginners Perl"
> <[EMAIL PROTECTED]>
> Subject:RE: process signals
>
>
> Mr Smith,
> I saw your elementary question at about 8:50 AM. I did not 
answer
> it, since it was not clear to me too. I have seen Bob ( who I have never
> spoken with or by no means friend of me) answering good, difficult
> questions very legibly. If you think you have know better unix, then you
> may kindly let us know :
>   1) why were you not able to use unix system("kill..") command, 
than
> waiting for perl group to answer?
>   2) how you can print "\n" while 'command' has already been writing
> the log file. (in case 'command was in background')
>   3) don't you think you contradict either in (2) or in trying to
> signal the process that is already over before print "\n" (in case not 
in
> background)
>
> If you want to send singal hangup the process use : kill HUP => $PID
>
> with regards,
> Jay
> -Original Message-
> From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED]
> Sent: Friday, May 07, 2004 12:36 PM
> To: Bob Showalter
> Cc: Beginners Perl
> Subject: RE: process signals
>
>
> If you dont understand my question then I assume you do not know unix or
> tail -f ?  I want to after a sleep of 5-8 seconds, send a kill signal to
> the previous command then increment the counter.  thank you!
>
>
>
> Derek B. Smith
> OhioHealth IT
> UNIX / TSM / EDM Teams
>
>
>
>
>
>
> Bob Showalter <[EMAIL PROTECTED]>
> 05/07/2004 10:57 AM
>
>
> To: "'[EMAIL PROTECTED]'" <[EMAIL PROTECTED]>,
> Beginners Perl
> <[EMAIL PROTECTED]>
> cc:
> Subject:RE: process signals
>
> [EMAIL PROTECTED] wrote:
> > I have an application system command that is like tail -f in UNIX and
> > I want to say
> >
> > x=1
> > while x < 10
> > do
> > 'command'  append to log
> > print "\n" append to log
> > issue HANGUP or KILL SIGNAL
> > x+=1
> > done
> >
> > How do I issue a hangup signal to this process using perl?
>
> I'm not sure I understand your problem, but the perl way to send a 
signal
> is
> with the kill() function. The way to catch a signal is by installing a
> handler using the %SIG hash.
>
> perldoc -f kill
> perldoc perlipc





RE: process signals

2004-05-07 Thread DBSMITH
yeah ok whatever  I want to use perl not ksh...as simple as that.

Derek B. Smith
OhioHealth IT
UNIX / TSM / EDM Teams






"Jayakumar Rajagopal" <[EMAIL PROTECTED]>
05/07/2004 01:16 PM

 
To: <[EMAIL PROTECTED]>, "Bob Showalter" <[EMAIL PROTECTED]>
cc: "Beginners Perl" <[EMAIL PROTECTED]>
Subject:RE: process signals


Mr Smith,
I saw your elementary question at about 8:50 AM. I did not answer 
it, since it was not clear to me too. I have seen Bob ( who I have never 
spoken with or by no means friend of me) answering good, difficult 
questions very legibly. If you think you have know better unix, then you 
may kindly let us know : 
  1) why were you not able to use unix system("kill..") command, than 
waiting for perl group to answer?
  2) how you can print "\n" while 'command' has already been writing 
the log file. (in case 'command was in background')
  3) don't you think you contradict either in (2) or in trying to 
signal the process that is already over before print "\n" (in case not in 
background)
 
If you want to send singal hangup the process use : kill HUP => $PID

with regards,
Jay
-Original Message-
From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED]
Sent: Friday, May 07, 2004 12:36 PM
To: Bob Showalter
Cc: Beginners Perl
Subject: RE: process signals


If you dont understand my question then I assume you do not know unix or 
tail -f ?  I want to after a sleep of 5-8 seconds, send a kill signal to 
the previous command then increment the counter.  thank you! 

 
 
Derek B. Smith
OhioHealth IT
UNIX / TSM / EDM Teams






Bob Showalter <[EMAIL PROTECTED]>
05/07/2004 10:57 AM

 
To: "'[EMAIL PROTECTED]'" <[EMAIL PROTECTED]>, 
Beginners Perl 
<[EMAIL PROTECTED]>
cc: 
Subject:RE: process signals


[EMAIL PROTECTED] wrote:
> I have an application system command that is like tail -f in UNIX and
> I want to say
> 
> x=1
> while x < 10
> do
> 'command'  append to log
> print "\n" append to log
> issue HANGUP or KILL SIGNAL
> x+=1
> done
> 
> How do I issue a hangup signal to this process using perl?

I'm not sure I understand your problem, but the perl way to send a signal 
is
with the kill() function. The way to catch a signal is by installing a
handler using the %SIG hash.

perldoc -f kill
perldoc perlipc







Re: Using variables in a regex

2004-05-07 Thread KEVIN ZEMBOWER
John, just wanted to thank you for your help. I've also pasted in the file, a sample 
data file and the output to this message, in case anyone's following along in the 
archives.

You're suggestions to improve time were amazing. I went from analyzing an 84,000 line 
log file in 30 minutes to just seconds.

Thank you again for all your help.

-Kevin Zembower
=
[EMAIL PROTECTED]:/opt/analog/logdata/db$ cat listqueries3.pl
#!/usr/bin/perl

use warnings;
use strict;

my $debug = 1;

while (<>) {
   next if /^#/; #Skip it if it's one of the comments at the beginning of the file.
   my ($date, $time, $source, undef, undef, $host, $FQDN, $method, $file, $query, 
undef) = split;
   next unless $file =~ /dbtwpcgi\.exe/ and $query =~ /&TN=popline&/i and $query =~ 
/QF0/;
   my $type = $query =~ /QI2/? 'A': 'B';
 
   my %hash = (abstract =>'', author =>'', engtitle =>'', docno =>'', keywordsmajor 
=>'', journaltitle =>'', languages =>'', popreporttopic =>'', refereed =>'', year 
=>'');
   #This is the more elaborate version, suggested by John Krahn
   $hash{ lc $2 } = $3 while $query =~ 
/QF(\d+)=\b(abstract|author|engtitle|docno|keywordsmajor|journaltitle|languages|popreporttopic|refereed|year)\b(?=.*?&QI\1=([^&]*))/ig;

   my $outstring = join("\t", $type, $date, $time, @hash{ qw( abstract author engtitle 
docno keywordsmajor journaltitle languages popreporttopic refereed year)}) . "\n";
   print translate($outstring);
}# while there are more lines in the input file   

sub translate() {
   $_ = $_[0];
   s/%22/\"/g;
   s/%2C/,/g;
   s/%20/ /g;
   s#%2F#/#g;
   s/%3D/=/g;
   s/%3B/;/g;
   s/%26/&/g;
   s/%0D//g;
   s/%0A//g;
   s/\+/ /g;
   s/%29/)/g;
   s/%28/(/g;
   s/%27/'/g;
   s/%2b/+/g;
   s/%7C/|/g;
   s/%3A/:/g;
   #Debbie request all boolean logical words and sumbols be replaced with '|'
   s/\band\b/|/ig;
   s/\bor\b/|/ig;
   tr!&/!|!;
   $_;
   }
[EMAIL PROTECTED]:/opt/analog/logdata/db$ cat x
2004-03-28 00:38:31 d7.facsmf.utexas.edu - W3SVC1 DB db.jhuccp.org GET 
/dbtw-wpd/exec/dbtwpcgi.exe 
XC=%2Fdbtw-wpd%2Fexec%2Fdbtwpcgi.exe&BU=http%3A%2F%2Fdb.jhuccp.org%2Fpopinform%2Fbasic.html&QB0=AND&QF0=Abstract+%7C+KeywordsMajor+%7C+KeywordsMinor+%7C+Notes+%7C+EngTitle+%7C+TT+%7C+FREAb+%7C+SPAAb&QI0=China%0D%0A&QB1=AND&QF1=Author+%7C+CN&QI1=&MR=10&TN=popline&RF=ShortRecordDisplay&DF=LongRecordDisplay&DL=1&RL=1&NP=0&AC=QBE_QUERY&x=37&y=4
 200 0 21248 814 19391 80 HTTP/1.1 
Mozilla/4.0+(compatible;+MSIE+6.0;+Windows+NT+5.1;+.NET+CLR+1.0.3705) - 
http://db.jhuccp.org/popinform/basic.html
2004-03-28 00:38:31 d7.facsmf.utexas.edu - W3SVC1 DB db.jhuccp.org GET 
/dbtw-wpd/jscript/dbtw-r-main.js - 200 0 6256 647 172 80 HTTP/1.1 
Mozilla/4.0+(compatible;+MSIE+6.0;+Windows+NT+5.1;+.NET+CLR+1.0.3705) - 
http://db.jhuccp.org/dbtw-wpd/exec/dbtwpcgi.exe?XC=%2Fdbtw-wpd%2Fexec%2Fdbtwpcgi.exe&BU=http%3A%2F%2Fdb.jhuccp.org%2Fpopinform%2Fbasic.html&QB0=AND&QF0=Abstract+%7C+KeywordsMajor+%7C+KeywordsMinor+%7C+Notes+%7C+EngTitle+%7C+TT+%7C+FREAb+%7C+SPAAb&QI0=China%0D%0A&QB1=AND&QF1=Author+%7C+CN&QI1=&MR=10&TN=popline&RF=ShortRecordDisplay&DF=LongRecordDisplay&DL=1&RL=1&NP=0&AC=QBE_QUERY&x=37&y=4
2004-03-28 00:38:31 d7.facsmf.utexas.edu - W3SVC1 DB db.jhuccp.org GET 
/popinform/res-style.css - 200 0 2212 639 63 80 HTTP/1.1 
Mozilla/4.0+(compatible;+MSIE+6.0;+Windows+NT+5.1;+.NET+CLR+1.0.3705) - 
http://db.jhuccp.org/dbtw-wpd/exec/dbtwpcgi.exe?XC=%2Fdbtw-wpd%2Fexec%2Fdbtwpcgi.exe&BU=http%3A%2F%2Fdb.jhuccp.org%2Fpopinform%2Fbasic.html&QB0=AND&QF0=Abstract+%7C+KeywordsMajor+%7C+KeywordsMinor+%7C+Notes+%7C+EngTitle+%7C+TT+%7C+FREAb+%7C+SPAAb&QI0=China%0D%0A&QB1=AND&QF1=Author+%7C+CN&QI1=&MR=10&TN=popline&RF=ShortRecordDisplay&DF=LongRecordDisplay&DL=1&RL=1&NP=0&AC=QBE_QUERY&x=37&y=4
2004-03-30 14:59:24 218.11.80.208 - W3SVC1 DB db.jhuccp.org GET 
/dbtw-wpd/jscript/dbtw-r-main.js - 200 0 6256 444 2078 80 HTTP/1.1 
Mozilla/4.0+(compatible;+MSIE+5.01;+Windows+NT+5.0) - 
http://db.jhuccp.org/dbtw-wpd/exec/dbtwpcgi.exe?BU=http%3A%2F%2Fdb.jhuccp.org%2Fdbtw-wpd%2Fexec%2Fdbtwpcgi.exe&QF0=Country&QI0=China&TN=Condoms&AC=QBE_QUERY&MR=30&RF=ShortRecordDisplay&NP=3&DF=results_long
2004-03-30 14:59:24 218.11.80.208 - W3SVC1 DB db.jhuccp.org GET 
/dbtw-wpd/exec/dbtwpcgi.exe 
BU=http%3A%2F%2Fdb.jhuccp.org%2Fdbtw-wpd%2Fexec%2Fdbtwpcgi.exe&QF0=Country&QI0=China&TN=Condoms&AC=QBE_QUERY&MR=30&RF=ShortRecordDisplay&NP=3&DF=results_long
 200 0 33987 588 5109 80 HTTP/1.1 Mozilla/4.0+(compatible;+MSIE+5.01;+Windows+NT+5.0) 
- http://condoms.jhuccp.org/asia.html
2004-03-31 13:28:05 proxy.unam.na - W3SVC1 DB db.jhuccp.org GET 
/dbtw-wpd/exec/dbtwpcgi.exe 
XC=%2Fdbtw-wpd%2Fexec%2Fdbtwpcgi.exe&BU=http%3A%2F%2Fdb.jhuccp.org%2Fpopinform%2Fbasic.html&QB0=AND&QF0=Abstract+%7C+KeywordsMajor+%7C+KeywordsMinor+%7C+Notes+%7C+EngTitle+%7C+TT+%7C+FREAb+%7C+SPAAb&QI0=child+labour+AND++literacy+NOT+China+&QB1=AND&QF1=Author+%7C+CN&QI1=&MR=10&TN=popline&RF=ShortRecordDisplay&DF=LongRecordDisplay&DL=1&RL=1&NP=0&AC=QBE_QUERY&x

Re: Array in a regexp

2004-05-07 Thread Jenda Krynicky
From: Alok Bhatt <[EMAIL PROTECTED]>
> --- Jason Dusek <[EMAIL PROTECTED]> wrote:
> > Hi List,
> > But if I have a long list of suffixes, then I would
> > like to store the 
> > suffixes in an array, and then evaluate the array in
> > my regular 
> > expression. What does this? I've tried:
> > 
> >@SUFF = (fish,foul);
> >foreach (@ARGV) {
> >  print if (/\.(@SUFFIXES)$/);
> >}
> > 
> > and also:
> > 
> >@SUFF = (fish,foul);
> >foreach (@ARGV) {
> >  print if (/\.(@[EMAIL PROTECTED])$/);
> >}
> Hi, 
> try this
> my @suffix=(txt, jpg, tif);
> my $pattern= join "|", @suffix;
> 
> foreach (@ARGV) {
>   print if /\.$pattern$/;
> }

This would match even   foo.notatif, you have to add braces into the 
regexp.

print if /\.(?:$pattern)$/;

(The ?: makes the braces non-capturing. See perldoc perlre)

You will also either want to use the /o option to compile the regexp 
just once or use the qr// operator:

my $pattern= join "|", @suffix;
foreach (@ARGV) {
print if /\.$pattern$/o;
}

or

my $pattern = join "|", @suffix;
$pattern = qr/\.$pattern$/; # compile the regexp
foreach (@ARGV) {
print if $_ =~ $pattern;
}

HTH, 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: process signals

2004-05-07 Thread Jayakumar Rajagopal
Mr Smith,
I saw your elementary question at about 8:50 AM. I did not answer it, since it 
was not clear to me too. I have seen Bob ( who I have never spoken with or by no means 
friend of me) answering good, difficult questions very legibly. If you think you have 
know better unix, then you may kindly let us know : 
  1) why were you not able to use unix system("kill..") command, than waiting for 
perl group to answer?
  2) how you can print "\n" while 'command' has already been writing the log file. 
(in case 'command was in background')
  3) don't you think you contradict either in (2) or in trying to signal the 
process that is already over before print "\n" (in case not in background)
  
If you want to send singal hangup the process use : kill HUP => $PID

with regards,
Jay
-Original Message-
From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED]
Sent: Friday, May 07, 2004 12:36 PM
To: Bob Showalter
Cc: Beginners Perl
Subject: RE: process signals


If you dont understand my question then I assume you do not know unix or 
tail -f ?  I want to after a sleep of 5-8 seconds, send a kill signal to 
the previous command then increment the counter.  thank you! 

 
 
Derek B. Smith
OhioHealth IT
UNIX / TSM / EDM Teams






Bob Showalter <[EMAIL PROTECTED]>
05/07/2004 10:57 AM

 
To: "'[EMAIL PROTECTED]'" <[EMAIL PROTECTED]>, Beginners Perl 
<[EMAIL PROTECTED]>
cc: 
Subject:RE: process signals


[EMAIL PROTECTED] wrote:
> I have an application system command that is like tail -f in UNIX and
> I want to say
> 
> x=1
> while x < 10
> do
> 'command'  append to log
> print "\n" append to log
> issue HANGUP or KILL SIGNAL
> x+=1
> done
> 
> How do I issue a hangup signal to this process using perl?

I'm not sure I understand your problem, but the perl way to send a signal 
is
with the kill() function. The way to catch a signal is by installing a
handler using the %SIG hash.

perldoc -f kill
perldoc perlipc




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




Re: monitor for a filename

2004-05-07 Thread Wiggins d Anconia
> I need to look at a directory for about 90 seconds, and if a certain
> file shows up, do something with it.  A pointer to a man page or any
> reference would be appreciated.
> 

perldoc -f opendir
perldoc -f readdir

A simple way to do this is to open the directory, loop over its contents
with readdir looking for your file. Then sleep for a second or some
interval, then read the contents again.  Set a counter for the number of
iterations and then kill the while when it hits 90 (aka 90 seconds). 
There are lots of ways this could be changed/improved, but it gets the
job done at least as well as the specification provided...

--pseudo code--

opendir or die
counter = 0
while counter < 90
  list = readdir
  if list contains file
 process file
 last
   
   counter+1
   sleep 1

close dir

http://danconia.org

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




RE: process signals

2004-05-07 Thread Wiggins d Anconia
Please bottom post

> 
> If you dont understand my question then I assume you do not know unix or 
> tail -f ?  

That would be a shocker.  Trust me, Bob knows about unix and tail...

I want to after a sleep of 5-8 seconds, send a kill signal to 
> the previous command then increment the counter.  thank you! 
> 
>  

More than likely he meant that running a single command will block until
the process has finished, which means your signal will never get passed
to a command that is still running, since to get to that point it would
have had to have finished.  

You should probably go back and read the second doc he mentioned, so
that you understand better what can be done on Unix.  The basic problem
with your code is that you would not issue a command like 'tail -f'
inside of the while loop. You would issue it first, then while you read
from the command do something, when you are done close the command, so
your pseudo-code doesn't work the way you think it will.

http://danconia.org

>  
> Derek B. Smith
> OhioHealth IT
> UNIX / TSM / EDM Teams
> 
> 
> 
> 
> 
> 
> Bob Showalter <[EMAIL PROTECTED]>
> 05/07/2004 10:57 AM
> 
>  
> To: "'[EMAIL PROTECTED]'" <[EMAIL PROTECTED]>,
Beginners Perl 
> <[EMAIL PROTECTED]>
> cc: 
> Subject:RE: process signals
> 
> 
> [EMAIL PROTECTED] wrote:
> > I have an application system command that is like tail -f in UNIX and
> > I want to say
> > 
> > x=1
> > while x < 10
> > do
> > 'command'  append to log
> > print "\n" append to log
> > issue HANGUP or KILL SIGNAL
> > x+=1
> > done
> > 
> > How do I issue a hangup signal to this process using perl?
> 
> I'm not sure I understand your problem, but the perl way to send a signal 
> is
> with the kill() function. The way to catch a signal is by installing a
> handler using the %SIG hash.
> 
> perldoc -f kill
> perldoc perlipc
> 
> 
> 
> 
> 



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




monitor for a filename

2004-05-07 Thread Charles Farinella
I need to look at a directory for about 90 seconds, and if a certain
file shows up, do something with it.  A pointer to a man page or any
reference would be appreciated.

--charlie

-- 
Charles Farinella
Appropriate Solutions, Inc.
603-924-6079


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




RE: process signals

2004-05-07 Thread DBSMITH
If you dont understand my question then I assume you do not know unix or 
tail -f ?  I want to after a sleep of 5-8 seconds, send a kill signal to 
the previous command then increment the counter.  thank you! 

 
 
Derek B. Smith
OhioHealth IT
UNIX / TSM / EDM Teams






Bob Showalter <[EMAIL PROTECTED]>
05/07/2004 10:57 AM

 
To: "'[EMAIL PROTECTED]'" <[EMAIL PROTECTED]>, Beginners Perl 
<[EMAIL PROTECTED]>
cc: 
Subject:RE: process signals


[EMAIL PROTECTED] wrote:
> I have an application system command that is like tail -f in UNIX and
> I want to say
> 
> x=1
> while x < 10
> do
> 'command'  append to log
> print "\n" append to log
> issue HANGUP or KILL SIGNAL
> x+=1
> done
> 
> How do I issue a hangup signal to this process using perl?

I'm not sure I understand your problem, but the perl way to send a signal 
is
with the kill() function. The way to catch a signal is by installing a
handler using the %SIG hash.

perldoc -f kill
perldoc perlipc





Re: Best way to Send Hash to a Socket

2004-05-07 Thread JupiterHost.Net


Wiggins d Anconia wrote:

On Wed, 05 May 2004 11:38:33 -0500, [EMAIL PROTECTED]
(Jupiterhost.Net) wrote:

Hello list,

To day I am trying to figure out the best way to send a hash to a socket 
and have the receiver be able to use it as a hash.

The best way I've done so far is to Data::Dumper the hash into a string 
and send the string, then parse the string back into a hash on the other 
end.
If you are willing to use the Net::EasyTCP module, it uses hashes to
communicate. I find it one of it's best features.


Storable is another commonly used module for this purpose. 

And naturally I couldn't pass up this opportunity to mention POE,
specifically POE::Filter::Reference, which is one of the few parts of
POE that is standalone, aka you don't need a POE kernel running to use
it. The interface is incredibly simple, and I have used it extensively.
Of course since you are working with sockets, then POE would be great
Thanks! looks like I'm going to take a trip to cpan today :)

for that too ;-)

http://danconia.org


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



Re: Best way to Send Hash to a Socket

2004-05-07 Thread JupiterHost.Net


zentara wrote:
On Wed, 05 May 2004 11:38:33 -0500, [EMAIL PROTECTED]
(Jupiterhost.Net) wrote:

Hello list,

To day I am trying to figure out the best way to send a hash to a socket 
and have the receiver be able to use it as a hash.

The best way I've done so far is to Data::Dumper the hash into a string 
and send the string, then parse the string back into a hash on the other 
end.


If you are willing to use the Net::EasyTCP module, it uses hashes to
communicate. I find it one of it's best features.
I'll take a look thanks for the info! :)

Lee.M - JupiterHost.Net

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



installing perl 5.6.1

2004-05-07 Thread Johnson, Shaunn
Howdy:

I'm trying to install 5.6.1 on RHEL version 3
from source.  After looking at google for some problems
related to the  and command errors, I get to
the point where I need to make / make test.

At the end, I get the following error:

[snip]
DB_File.xs: In function `ParseOpenInfo':
DB_File.xs:1339: warning: passing arg 2 of pointer to function 
 from incompatible pointer type
DB_File.xs:1339: incompatible type for argument 4 of indirect function call
DB_File.xs:1339: too few arguments to function
make[2]: *** [DB_File.o] Error 1
make[2]: Leaving directory `/var/tools/perl_mkdir/perl-5.6.1/ext/DB_File'
make[1]: *** [lib/auto/DB_File/DB_File.so] Error 2
make[1]: Leaving directory `/var/tools/perl_mkdir/perl-5.6.1'
make: *** [install] Error 2
[/snip]

Previously, I installed DBI with the current version of
Perl (5.8.0 - comes with the OS), but that's about all 
I've had before this.

Can someone tell me what this error is about and how to
correct it?

Thanks!

-X


Re: perl code

2004-05-07 Thread Lino Iozzo
I don't understand when you say:
 
"Really without more info there is not much more I can help with."
 
I am willing to provide as much info as you need.
 
what you have said already is helpful and is inline with my thinking.
 
I wish to look in a direcory and display to the user all of the files in the directory 
to stdout
 
so it would look something like this:
 
The files in the "x" directory are:  (lino.txt iozzo.txt lino.csv)
 
then the user would type on the next line one of the file names returnd above and hit 
enter.
 
the code would then open and parse the file requested and resave as another filename.
 
Where do i put the directory/path to look in.
 
I hope this is provides you with more information.
 
Thanks,
 
Lino
 


"Paul D. Kraus" <[EMAIL PROTECTED]> wrote:
On Fri, May 07, 2004 at 05:38:38AM -0700, Lino Iozzo wrote:
> please excuse my inability to understand this code.
> 
> but what is: while ( <*> )
> 
> and where is the piece of code that tells what directory/path to look in?
> 
> where does it go?

I may be saying this wrong but the <*> globs the current directory. Meaning it 
iterates through all files. you could als do *.txt for all text files.

This code does not contain dircetory / path so its what ever director the script is 
run it that it globs.

Really without more info there is not much more I can help with.

Paul

Re: NNTP Server responses from a perl script?

2004-05-07 Thread Wiggins d Anconia
> Hi all!  I'm working on my second ever perl script for a school assignment
> and running into a quirk that I can't seem to figure out.
> 
> If I telnet to an nntp server that requires authentication and issue a
> command without authenticating first, I get an error message "480
> Authentication Required"
> 
> However, in Perl, when I open a socket connection to a news server that
> requires authentication, issue a command, and wait for a response,
> everything hangs.  It seems rather odd that it would hang when telnet
> doesn't.  Is there any way around this (without using the NNTP module
- I'm
> not allowed to)?
>

Show us some code, there are lots of possible reasons
 
> Thanks,
> Rick
> remove **NOSPAM** from e-mail address to respond
> 

Not gonna happen.

http://danconia.org


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




RE: process signals

2004-05-07 Thread Bob Showalter
[EMAIL PROTECTED] wrote:
> I have an application system command that is like tail -f in UNIX and
> I want to say
> 
> x=1
> while x < 10
> do
> 'command'  append to log
> print "\n" append to log
> issue HANGUP or KILL SIGNAL
> x+=1
> done
> 
> How do I issue a hangup signal to this process using perl?

I'm not sure I understand your problem, but the perl way to send a signal is
with the kill() function. The way to catch a signal is by installing a
handler using the %SIG hash.

perldoc -f kill
perldoc perlipc


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




RE: Oracle:DBD and perl 5.8.0 - SV

2004-05-07 Thread Johnson, Shaunn
--belay that last transmission - i
--*have* to roll back to perl 5.6.x.
--sorry to jump the gun.

-X

--original post--
Is there a version of Oracle:DBD that will compile
with 5.8.0 or do I have to rollback to 5.6.1?


Re: Array in a regexp

2004-05-07 Thread Jeff 'japhy' Pinyan
On May 7, Jason Dusek said:

>But if I have a long list of suffixes, then I would like to store the
>suffixes in an array, and then evaluate the array in my regular
>expression. What does this? I've tried:
>
>   @SUFF = (fish,foul);

I think you mean @SUFFIXES.  That's the array you use below...

>   foreach (@ARGV) {
> print if (/\.(@SUFFIXES)$/);
>   }

The problem is that @SUFFIXES expands to "fish foul" inside a string or a
regex, and you need it to be "fish|foul".  There are a couple ways to
accomplish what you want:

  my $pat = join "|", @SUFFIXES;
  foreach (@ARGV) {
print if /\.($pat)$/;
  }

Or:

  foreach (@ARGV) {
local $" = "|";
print if /\.(@SUFFIXES)$/;
  }

And both of those regexes can have the /o modifier put on the end of them,
if you're sure @SUFFIXES won't change during the execution of your
program.

  foreach (@ARGV) {
local $" = "|";
print if /\.(@SUFFIXES)$/o;
  }

-- 
Jeff "japhy" Pinyan  [EMAIL PROTECTED]  http://www.pobox.com/~japhy/
RPI Acacia brother #734   http://www.perlmonks.org/   http://www.cpan.org/
CPAN ID: PINYAN[Need a programmer?  If you like my work, let me know.]
 what does y/// stand for?   why, yansliterate of course.


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




Re: Perl Scripts examples

2004-05-07 Thread James Edward Gray II
On May 7, 2004, at 4:23 AM, anish mehta wrote:

Hi all!

I am new to perl. Can somebody tell me about some link on internet 
from where i can find some scripts to begin with so that i can start 
getting style of writing code in perl. I have gone through o'reilly 
book and is looking for some practical exercises.

Any suggestions will be highly appriciated.
The archives of this list would contain MANY examples, as long as you 
remember that some will be less than perfect.  Still, usually when 
someone posts less than ideal code, others post corrections and that 
could be very helpful to see.

Also, while not the code that you asked for, you did mention that you 
were looking for style information and you can find that in:

perldoc perlstyle

Hope that helps.

James

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



RE: Line number variable....

2004-05-07 Thread Shaw, Matthew

> -Original Message-
> >there a variable containing the actual
> > source-line number during execution?
> >
> 
> Yes, the $.

This is incorrect, $. actually contains the 'current line number' from
the last accessed file handle. It will be undef if no filehandles have
been accessed. 

The __LINE__ constant contains the current line number (IE: it will
return the line that __LINE__ is called from) from the source file.

Hope that helps.


Regards,
Matt


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




Oracle:DBD and perl 5.8.0

2004-05-07 Thread Johnson, Shaunn
Howdy:

I have been trying to install Oracle:DBD 1.14 or 1.15 
with perl 5.8.0 and after adding different paths to
compensate for the missing Config.pm, et al, it
finally said, '... this isn't 5.6.0' and the process
stopped.

Is there a version of Oracle:DBD that will compile
with 5.8.0 or do I have to rollback to 5.6.1?

Thanks!

-X


Re: Array in a regexp

2004-05-07 Thread Alok Bhatt

--- Alok Bhatt <[EMAIL PROTECTED]> wrote:
> 
> --- Jason Dusek <[EMAIL PROTECTED]> wrote:
> > Hi List,
> > But if I have a long list of suffixes, then I
> would
> > like to store the 
> > suffixes in an array, and then evaluate the array
> in
> > my regular 
> > expression. What does this? I've tried:
> > 
> >@SUFF = (fish,foul);
> >foreach (@ARGV) {
> >  print if (/\.(@SUFFIXES)$/);
> >}
> > 
> > and also:
> > 
> >@SUFF = (fish,foul);
> >foreach (@ARGV) {
> >  print if (/\.(@[EMAIL PROTECTED])$/);
> >}
> Hi, 
> try this
> my @suffix=(txt, jpg, tif);
> my $pattern= join "|", @suffix;
> 
> foreach (@ARGV) {
>   print if /\.$pattern$/;

Forgot to add
you should use /o option

print if /\.$pattern$/o;

so that it runs fater
> }
>  
> HTH,
> Alok
> (BTW- Nice sig.)
> 
> > but I can't get it to work.
> > -- 
> > -- Jason Dusek  ("`-''-/").___..--''"`-._
> > -- | `6_ 6  )   `-.  (
> > ).`-.__.`)
> > -- | (_Y_.)'  ._   )  `._ `.
> ``-..-'
> > -- |   _..`--'_..-_/  /--'_.' ,'
> > -- |  (il),-''  (li),'  ((!.-'
> > --
> > 
> > -- 
> > To unsubscribe, e-mail:
> > [EMAIL PROTECTED]
> > For additional commands, e-mail:
> > [EMAIL PROTECTED]
> > 
> > 
> > 
> > 
> 
> 
> 
>   
>   
> __
> Do you Yahoo!?
> Win a $20,000 Career Makeover at Yahoo! HotJobs  
> http://hotjobs.sweepstakes.yahoo.com/careermakeover 
> 
> -- 
> To unsubscribe, e-mail:
> [EMAIL PROTECTED]
> For additional commands, e-mail:
> [EMAIL PROTECTED]
> 
> 
> 
> 





__
Do you Yahoo!?
Win a $20,000 Career Makeover at Yahoo! HotJobs  
http://hotjobs.sweepstakes.yahoo.com/careermakeover 

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




Pal ( Replacement for Cal ) Parse Sort Term Width

2004-05-07 Thread Paul D. Kraus
I just started using the program Pal its a unix terminal emulator. I wanted to wrap it 
with a perl script so that I could sort events based on A1 codes. So A1 A2 A3 C3 D4 C2 
would get sorted in order of priority. So i wrote a quick little perl script to pipe 
the output of pal to have it resort it and then display it. I have cron email me and 
print a copy 3 times a day. To help keep me on track. Its easy in IT to get stuck on 
the web or in email all day :)

At any rate the wrapper works great but it seems that depeneding on the size of the 
terminal window that pal is actually inserting line breaks rather then letting the 
line wrap. This makes my wrapper not work for print jobs and for smaller terminal 
windows. Granted I could just keep my pal files at a certain width and avoid the 
problem but that wouldn't be very perlish. Below is my code. Below that is the output. 
Now this is hard to show because when I redirect output to a file it doesn't break it 
up. So below the redirected out put is just a copy paste of the terminal window.

TIA,

Paul D. Kraus
~=~=~=~=~=~=~=~=~=~=~=~=~
~ Network Administrator ~
~ PEL Supply Company~
~ 216.267.5775 Voice~
~ 216.267.6176 Fax  ~
~=~=~=~=~=~=~=~=~=~=~=~=~
~   www.pelsupply.com   ~
~=~=~=~=~=~=~=~=~=~=~=~=~


Code
-
#!/usr/bin/perl
use strict;

my ( @cal, %events );
getdata ( [EMAIL PROTECTED], \%events );
printcal ( [EMAIL PROTECTED] );
printevents ( \%events );


sub getdata { # Capture Data
  my ( $cal, $events ) = ( shift, shift );
  my $key;
  my %weekname = ( "Mon" => 1, "Tue" => 2, "Wed" => 3,
   "Thu" => 4, "Fri" => 5, "Sat" => 6,
   "Sun" => 7 );
  while ( <> ) {
chomp;
unless ( ( /Mon|Tue|Wed|Thu|Fri|Sat|Sun|\*/ ) or ( $key ) )  {
  next unless ( $_ );
  push ( @$cal, $_ );
} else {
  $key = $weekname{ $1 } if ( /\e\[1m(Mon)/ );
  $key = $weekname{ $1 } if ( /\e\[1m(Tue)/ );
  $key = $weekname{ $1 } if ( /\e\[1m(Wed)/ );
  $key = $weekname{ $1 } if ( /\e\[1m(Thu)/ );
  $key = $weekname{ $1 } if ( /\e\[1m(Fri)/ );
  $key = $weekname{ $1 } if ( /\e\[1m(Sat)/ );
  $key = $weekname{ $1 } if ( /\e\[1m(Sun)/ );
  push ( @{$$events{$key}}, $_ );
}
  }
}

sub printcal { # Print Calendars
  my $cal = shift;
  print "$_\n" foreach ( @{ $cal } ) ;
  print "\n";
}

sub printevents { # Print Events
  my $events = shift;
  my %weeknum  = ( 1 => "Mon", 2 => "Tue", 3 => "Wed",
   4 => "Thu", 5 => "Fri", 6 => "Sat",
   7 => "Sun" );
  foreach my $key ( sort keys %{ $events } ) {
next unless ( $key );
print "$$events{$key}[0]";
foreach my $event (sort @{ $$events{ $key} } [EMAIL PROTECTED]) {
  print "$event\n";
}
print "\n";
  }
}



Output of pal
-
 Su   Mo   Tu   We   Th   Fr   Sa | Su   Mo   Tu  
 We   Th   Fr   Sa
May  25   26   27   28   29   30   01 |Jun 
C30C U31S  01   02   03   04   05 
 02   03   04  P05E  06  [1;[EMAIL PROTECTED];[EMAIL 
PROTECTED]  08 |C06C  07   08   09  
C10C  11   12 
U09S  10  P11E  12  
P13E  14  U15S| 13  
U14S  15   16   17   18   19 
C16C  17   18   19  C20C  21   22 
|U20S  21   22   23   24   25   26 
 23   24   25   26   27   28   29 |Jul  27   28   29   30   
01   02   03 

Fri  7 May 2004 - Today
* PK Events: Meeting - Record Retention ( 9:00AM ) Seminar Room
* History: Germany surrenders after WWII, 1945
* PK ToDoList: D1: Advertising - Pel E-Gram Sales Analysis (Waiting Kelly & 
Ronelle)
* PK ToDoList: D1: Kelly Luiere - Who is not buying liners (Waiting Kelly)
* PK ToDoList: D1: Viv Walsh - Add Credit Card Banner to Pick Tickets 
(Waiting Viv)
* PK ToDoList: D1: Paulette Vaughn - Copier will not work  (Waiting parts)
* PK ToDoList: D1: Add Attention Field to PEL E-Gram Fax's (Waiting PAV)
* PK ToDoList: C4: Bev - Give Money to Bev for Danniele - House Warming Gift
* PK ToDoList: A1: Paulette Vaughn - Add Children Customers to new Cust 
Class Code
* PK ToDoList: A1: Bob Boff - Buy Laptop

Sat  8 May 2004 - Tomorrow
* History: US institutes mining of Haiphong Harbor, 1972

Sun  9 May 2004 - 2 days away
* USA: Mother's Day
* History: 94 degrees, New York, 1979

Mon 10 May 2004 - 3 days away
* History: Germany invades Low Countries, 1940
* History: Nazi bookburning, 1933




Output (Cust Paste Term Window pip

Re: Array in a regexp

2004-05-07 Thread Alok Bhatt

--- Jason Dusek <[EMAIL PROTECTED]> wrote:
> Hi List,
> But if I have a long list of suffixes, then I would
> like to store the 
> suffixes in an array, and then evaluate the array in
> my regular 
> expression. What does this? I've tried:
> 
>@SUFF = (fish,foul);
>foreach (@ARGV) {
>  print if (/\.(@SUFFIXES)$/);
>}
> 
> and also:
> 
>@SUFF = (fish,foul);
>foreach (@ARGV) {
>  print if (/\.(@[EMAIL PROTECTED])$/);
>}
Hi, 
try this
my @suffix=(txt, jpg, tif);
my $pattern= join "|", @suffix;

foreach (@ARGV) {
  print if /\.$pattern$/;
}
 
HTH,
Alok
(BTW- Nice sig.)

> but I can't get it to work.
> -- 
> -- Jason Dusek  ("`-''-/").___..--''"`-._
> -- | `6_ 6  )   `-.  (
> ).`-.__.`)
> -- | (_Y_.)'  ._   )  `._ `. ``-..-'
> -- |   _..`--'_..-_/  /--'_.' ,'
> -- |  (il),-''  (li),'  ((!.-'
> --
> 
> -- 
> To unsubscribe, e-mail:
> [EMAIL PROTECTED]
> For additional commands, e-mail:
> [EMAIL PROTECTED]
> 
> 
> 
> 





__
Do you Yahoo!?
Win a $20,000 Career Makeover at Yahoo! HotJobs  
http://hotjobs.sweepstakes.yahoo.com/careermakeover 

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




RE: Perl Scripts examples

2004-05-07 Thread Charles K. Clarkson
anish mehta [mailto:[EMAIL PROTECTED] 
: 
: I am new to perl. Can somebody tell me about some link
: on internet from where i can find some scripts to begin
: with so that i can start getting style of writing code
: in perl. I have gone through o'reilly book and is 
: looking for some practical exercises.
: 
: Any suggestions will be highly appriciated.

 Take a look at the Code Catacombs at PerlMonks:

 http://www.perlmonks.com/index.pl?node=Code%20Catacombs


Not all of this fine code. Read the comments as well
as the code. Try re-writing some of the code. Look for
ways to reduce size, add white space, reduce number of
variables used, add sub routines, etc.

Perlmonks has a lot of code on site. You'll probably
find something interesting.


HTH,

Charles K. Clarkson
-- 
Mobile Homes Specialist
254 968-8328


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




Re: perl code

2004-05-07 Thread Lino Iozzo
please excuse my inability to understand this code.
 
but what is: while ( <*> )
 
and where is the piece of code that tells what directory/path to look in?
 
where does it go?
 
Thanks,
 
Lino 

"Paul D. Kraus" <[EMAIL PROTECTED]> wrote:
On Thu, May 06, 2004 at 03:28:51PM -0700, Lino Iozzo wrote:
> Here is an example:
> 
> I have a file and save it to a directory whether it is one file or multiple files 
> then i go to my perl script and type retrievelist.pl this should look into the 
> specified directory in the code and display everything in this directory.
> 
> Then retrieve list should prompt the user to select one of the files it returned and 
> then this would invoke another perl command called parselist.pl.
> 
> this should all take place in the retrieve list for now until i build a menu 
> system...and i don't know when this will happen.
> 

Well without still more info such as what you want to do with the list this script 
will read the current directory and store all the file names into an array. You could 
use a hash or even process each file one at a time. Code is untested. 

HTH,
Paul Kraus


Code
-=-=-=

use strict;
use warnings;

my @files;
while ( <*> ) {
next if ( /\.|\../ ); # skip the '.' and '..' directory
my $filename = $_;
push ( @files, $filename );
 or you could process each file as it is found ...
open ( IN, "<$filename" ) or die (" could not open file $!\n" );
while ( ){
###Parse file here
}
}



foreach my $ file ( @files ) {
open ( IN, "<$file" ) or die (" could not open file $!\n" );
while ( ){
###Parse file here
}
}


Re: Perl Scripts examples

2004-05-07 Thread Alok Bhatt
> I am new to perl. Can somebody tell me about some
> link on internet from 
> where i can find some scripts to begin with so that
> i can start getting 
> style of writing code in perl. I have gone through
> o'reilly book and is 
> looking for some practical exercises.

Hi,
the examples from Learning perl are available at:
http://examples.oreilly.com/lperl3/llamasamp.zip

the examples from Programming perl are available at:
http://examples.oreilly.com/pperl3/examples.zip

This info is also given on oreilly books.

Alok




__
Do you Yahoo!?
Win a $20,000 Career Makeover at Yahoo! HotJobs  
http://hotjobs.sweepstakes.yahoo.com/careermakeover 

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




process signals

2004-05-07 Thread DBSMITH
I have an application system command that is like tail -f in UNIX and I 
want to say

x=1
while x < 10
do
'command'  append to log
print "\n" append to log
issue HANGUP or KILL SIGNAL
x+=1
done

How do I issue a hangup signal to this process using perl?


Derek B. Smith
OhioHealth IT
UNIX Support


Array in a regexp

2004-05-07 Thread Jason Dusek
Hi List,

Let's say I want to know if anything in @ARGV has one of a certain list 
of suffixes in it. So I write:

  foreach (@ARGV) {
print if (/\.(fish|foul)$/);
  }
But if I have a long list of suffixes, then I would like to store the 
suffixes in an array, and then evaluate the array in my regular 
expression. What does this? I've tried:

  @SUFF = (fish,foul);
  foreach (@ARGV) {
print if (/\.(@SUFFIXES)$/);
  }
and also:

  @SUFF = (fish,foul);
  foreach (@ARGV) {
print if (/\.(@[EMAIL PROTECTED])$/);
  }
but I can't get it to work.
--
-- Jason Dusek  ("`-''-/").___..--''"`-._
-- | `6_ 6  )   `-.  ( ).`-.__.`)
-- | (_Y_.)'  ._   )  `._ `. ``-..-'
-- |   _..`--'_..-_/  /--'_.' ,'
-- |  (il),-''  (li),'  ((!.-'
--
--
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
 



Re: perl code

2004-05-07 Thread Paul D. Kraus
On Thu, May 06, 2004 at 03:28:51PM -0700, Lino Iozzo wrote:
> Here is an example:
>  
> I have a file and save it to a directory whether it is one file or multiple files 
> then i go to my perl script and type retrievelist.pl this should look into the 
> specified directory in the code and display everything in this directory.
>  
> Then retrieve list should prompt the user to select one of the files it returned and 
> then this would invoke another perl command called parselist.pl.
>  
> this should all take place in the retrieve list for now until i build a menu 
> system...and i don't know when this will happen.
>  

Well without still more info such as what you want to do with the list this script 
will read the current directory and store all the file names into an array. You could 
use a hash or even process each file one at a time. Code is untested. 

HTH,
Paul Kraus


Code
-=-=-=

use strict;
use warnings;

my @files;
while ( <*> ) {
next if ( /\.|\../ ); # skip the '.' and '..' directory
my $filename = $_;
push ( @files, $filename );
 or you could process each file as it is found ...
open ( IN, "<$filename" ) or die (" could not open file $!\n" );
while (  ){
###Parse file here
}
}



foreach my $ file ( @files ) {
open ( IN, "<$file" ) or die (" could not open file $!\n" );
while (  ){
###Parse file here
}
}


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




RE: Line number variable....

2004-05-07 Thread NYIMI Jose (BMB)

> -Original Message-
> From: Paul Johnson [mailto:[EMAIL PROTECTED] On Behalf Of Paul Johnson
> Sent: Friday, May 07, 2004 1:20 PM
> To: NYIMI Jose (BMB)
> Cc: Gabor Urban; [EMAIL PROTECTED]
> Subject: Re: Line number variable
> 
> 
> On Fri, May 07, 2004 at 01:01:01PM +0200, NYIMI Jose (BMB) wrote:
> 
> > > -Original Message-
> > > From: Gabor Urban [mailto:[EMAIL PROTECTED]
> > > 
> > > I was going through the manuals some times, but could not
> > > find it. Is there a variable containing the actual 
> > > source-line number during execution? 
> > 
> > Yes, the $.
> 
> Sounds more like __LINE__ to me, though this is a token 
> rather than a variable.

Sorry, you right ...
Ignore my previous post.

José.


 DISCLAIMER 

"This e-mail and any attachment thereto may contain information which is confidential 
and/or protected by intellectual property rights and are intended for the sole use of 
the recipient(s) named above. 
Any use of the information contained herein (including, but not limited to, total or 
partial reproduction, communication or distribution in any form) by other persons than 
the designated recipient(s) is prohibited. 
If you have received this e-mail in error, please notify the sender either by 
telephone or by e-mail and delete the material from any computer".

Thank you for your cooperation.

For further information about Proximus mobile phone services please see our website at 
http://www.proximus.be or refer to any Proximus agent.


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




Re: Line number variable....

2004-05-07 Thread Paul Johnson
On Fri, May 07, 2004 at 01:01:01PM +0200, NYIMI Jose (BMB) wrote:

> > -Original Message-
> > From: Gabor Urban [mailto:[EMAIL PROTECTED] 
> > 
> > I was going through the manuals some times, but could not 
> > find it. Is there a variable containing the actual 
> > source-line number during execution? 
> 
> Yes, the $.

Sounds more like __LINE__ to me, though this is a token rather than a
variable.

perldoc perldata

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

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




RE: Line number variable....

2004-05-07 Thread NYIMI Jose (BMB)
> -Original Message-
> From: Gabor Urban [mailto:[EMAIL PROTECTED] 
> Sent: Friday, May 07, 2004 12:57 PM
> To: [EMAIL PROTECTED]
> Subject: Line number variable
> 
> 
> Hi,
> 
> I was going through the manuals some times, but could not 
> find it. Is there a variable containing the actual 
> source-line number during execution? 
> 

Yes, the $.

José.



 DISCLAIMER 

"This e-mail and any attachment thereto may contain information which is confidential 
and/or protected by intellectual property rights and are intended for the sole use of 
the recipient(s) named above. 
Any use of the information contained herein (including, but not limited to, total or 
partial reproduction, communication or distribution in any form) by other persons than 
the designated recipient(s) is prohibited. 
If you have received this e-mail in error, please notify the sender either by 
telephone or by e-mail and delete the material from any computer".

Thank you for your cooperation.

For further information about Proximus mobile phone services please see our website at 
http://www.proximus.be or refer to any Proximus agent.


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




Line number variable....

2004-05-07 Thread Gabor Urban
Hi,

I was going through the manuals some times, but could not find it. Is
there a variable containing the actual source-line number during
execution? 

Gabaux
Linux is like a wigwam: no gates, no windows, and an apache
inside!

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




RE: How to write a Perl module

2004-05-07 Thread NYIMI Jose (BMB)
> -Original Message-
> From: Jenda Krynicky [mailto:[EMAIL PROTECTED] 
> Sent: Friday, May 07, 2004 12:32 PM
> To: [EMAIL PROTECTED]
> Subject: Re: How to write a Perl module
> 
> 
> From: Owen <[EMAIL PROTECTED]>
> > As an exercise in making an LDP How-To as well as confirming my own 
> > limited knowledge of making a Perl module I wrote.
> > 
> >  http://www.pcug.org.au/~rcook/PerlModule_HOWTO.html
> > 
> > It is for beginners, just "do this" and it should work without any 
> > explanation.
> 
> Abstract:
>   s/should be place in a module/should be placed in a module/
> 
> Section 5.1
>   s/#user perl Makefile.PL/user# perl Makefile.PL/
> 
> The intro is almost longer than the real stuff. Is all this 
> legalistic chatter really necessary in such a short document?
> 
> Also you should include pointers to Perl manual pages explaining the 
> details

Yes, as you did at http://jenda.krynicky.cz/perl/CPAN&ppm.html ;)

José.


 DISCLAIMER 

"This e-mail and any attachment thereto may contain information which is confidential 
and/or protected by intellectual property rights and are intended for the sole use of 
the recipient(s) named above. 
Any use of the information contained herein (including, but not limited to, total or 
partial reproduction, communication or distribution in any form) by other persons than 
the designated recipient(s) is prohibited. 
If you have received this e-mail in error, please notify the sender either by 
telephone or by e-mail and delete the material from any computer".

Thank you for your cooperation.

For further information about Proximus mobile phone services please see our website at 
http://www.proximus.be or refer to any Proximus agent.


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




Re: NNTP Server responses from a perl script?

2004-05-07 Thread Jenda Krynicky
From: "Rick Wilson" <[EMAIL PROTECTED]>
> Hi all!  I'm working on my second ever perl script for a school
> assignment and running into a quirk that I can't seem to figure out.
> 
> If I telnet to an nntp server that requires authentication and issue a
> command without authenticating first, I get an error message "480
> Authentication Required"
> 
> However, in Perl, when I open a socket connection to a news server
> that requires authentication, issue a command, and wait for a
> response, everything hangs.  It seems rather odd that it would hang
> when telnet doesn't.  Is there any way around this (without using the
> NNTP module - I'm not allowed to)?

How are you issuing the command? Using Net::Telnet? Or Net::Cmd? Or 
raw socket()s?
Are you sure you have the autoflush turned on for the socket?
(see perldoc -q flush)

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: How to write a Perl module

2004-05-07 Thread Jenda Krynicky
From: Owen <[EMAIL PROTECTED]>
> As an exercise in making an LDP How-To as well as confirming my own
> limited knowledge of making a Perl module I wrote.
> 
>  http://www.pcug.org.au/~rcook/PerlModule_HOWTO.html
> 
> It is for beginners, just "do this" and it should work without any
> explanation.

Abstract:
s/should be place in a module/should be placed in a module/

Section 5.1
s/#user perl Makefile.PL/user# perl Makefile.PL/

The intro is almost longer than the real stuff. Is all this 
legalistic chatter really necessary in such a short document?

Also you should include pointers to Perl manual pages explaining the 
details
perlmod
perlmodlib
perlsub
Exporter

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: Variable "$some_var" will not stay shared

2004-05-07 Thread Perrin Harkins
On Thu, 2004-05-06 at 17:19, Beau E. Cox wrote:
> But maybe I could explain the overall picture. I am trying to embed
> 'any' script (whthout modification) in perl; I use a perl package
> (which is run via a c program) to maintain 'persistence' of the script
> which is read from disk. This must be done in the mod_perl registry
> for cgi scripts, but my search of the mod_perl source so far has
> been fruitless.

The code is in Apache::Registry, or ModPerl::RegistryCooker for mp2. 
It's pure perl and pretty easy to read.  It has the same problem as
yours though, i.e. subs that refer to lexicals declared outside of them
generate this error.  Normally, that sub would just be a closure, but
once you nest it you get an actual leak.

Workarounds are described in the mod_perl docs here:
http://perl.apache.org/docs/general/perl_reference/perl_reference.html#my___Scoped_Variable_in_Nested_Subroutines

I don't think you can solve this nicely without limiting the sort of
code that you allow.

- Perrin


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




NNTP Server responses from a perl script?

2004-05-07 Thread Rick Wilson
Hi all!  I'm working on my second ever perl script for a school assignment
and running into a quirk that I can't seem to figure out.

If I telnet to an nntp server that requires authentication and issue a
command without authenticating first, I get an error message "480
Authentication Required"

However, in Perl, when I open a socket connection to a news server that
requires authentication, issue a command, and wait for a response,
everything hangs.  It seems rather odd that it would hang when telnet
doesn't.  Is there any way around this (without using the NNTP module - I'm
not allowed to)?

Thanks,
Rick
remove **NOSPAM** from e-mail address to respond



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




Perl Scripts examples

2004-05-07 Thread anish mehta
Hi all!

I am new to perl. Can somebody tell me about some link on internet from 
where i can find some scripts to begin with so that i can start getting 
style of writing code in perl. I have gone through o'reilly book and is 
looking for some practical exercises.

Any suggestions will be highly appriciated.

Thanks in advance.

Regards,

Anish

_
Post Classifieds on MSN classifieds. http://go.msnserver.com/IN/44045.asp 
Buy and Sell on MSN Classifieds.

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



RE: How to write a Perl module

2004-05-07 Thread NYIMI Jose (BMB)
> -Original Message-
> From: Owen [mailto:[EMAIL PROTECTED] 
> Sent: Friday, May 07, 2004 5:40 AM
> To: [EMAIL PROTECTED]
> Subject: How to write a Perl module
> 
> 
> 
> As an exercise in making an LDP How-To as well as confirming 
> my own limited knowledge of making a Perl module I wrote.
> 
>  http://www.pcug.org.au/~rcook/PerlModule_HOWTO.html
> 

Your doc has a nice presentation (look) , congratulations! ;)
It's seems that you have used "DocBook" to produce it. Is that true ?
Could you share some doc ressources/links about DocBook.
The ones I know is:
http://docbook.sourceforge.net/

José.


 DISCLAIMER 

"This e-mail and any attachment thereto may contain information which is confidential 
and/or protected by intellectual property rights and are intended for the sole use of 
the recipient(s) named above. 
Any use of the information contained herein (including, but not limited to, total or 
partial reproduction, communication or distribution in any form) by other persons than 
the designated recipient(s) is prohibited. 
If you have received this e-mail in error, please notify the sender either by 
telephone or by e-mail and delete the material from any computer".

Thank you for your cooperation.

For further information about Proximus mobile phone services please see our website at 
http://www.proximus.be or refer to any Proximus agent.


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