Re: Convert letter to phone keypad equivalent

2004-01-02 Thread Tom Kinzer
You could do it with a mathematical operation based on the ASCII value...course that's 
not a regex.


-Tom Kinzer


-Original Message-
From: Kevin Old <[EMAIL PROTECTED]>
Sent: Jan 2, 2004 8:26 AM
To: [EMAIL PROTECTED]
Subject: Convert letter to phone keypad equivalent

Hello everyone,

Here's a script I wrote to convert letters into their telephone keypad
equivalentsexampleA-B to 2, D-F to 3, etc.

#!/usr/bin/perl

use warnings;
use strict;

my $cnum = 'SM1550';

$cnum =~ s/[A-C]/2/g;
$cnum =~ s/[D-F]/3/g;
$cnum =~ s/[G-I]/4/g;
$cnum =~ s/[J-L]/5/g;
$cnum =~ s/[M-O]/6/g;
$cnum =~ s/[P-S]/7/g;
$cnum =~ s/[T-V]/8/g;
$cnum =~ s/[W-Y]/9/g;

print "$cnum\n"

This works like a charm, but I wondered if anyone knew of a way to
consolidate this into fewer regex's.  Like my post earlier this week,
I'm not trying to be lazy, just trying to learn other ways of
programming/consolidating regexes.

Any help is appreciated,
Kevin
-- 
Kevin Old <[EMAIL PROTECTED]>


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




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




RE: generating GIFs

2003-12-29 Thread Tom Kinzer
sounds like a new sourceforge project is hatched...?

-Original Message-
From: Armin [mailto:[EMAIL PROTECTED]
Sent: Monday, December 29, 2003 2:45 PM
To: [EMAIL PROTECTED]
Subject: Re: generating GIFs


Robert Brown wrote:
> Andrew Gaffney writes:
>  > zentara wrote:
>  > > Well, gifs were shunned by alot of the software writers because of
>  > > the old patent issues. So your best bet will be to make your image as
>  > > a jpg or png, then convert it to gif afterwards.
>  >
>  > Is PNG a good format for a 51x20 image with 4 or 5 colors?
>  >
>  > > If you want to make an animated gif, you can
>  > > use something like this:
>  > > system("gifsicle -lforever $graphical*.gif > $graphical.anim.gif")
>  >
>  > I've used gifsicle before to make animated GIFs. That was a nifty
little program.
>
> Is there any alternative to gifs to make animated images?  Flash is
> proprietary to macromedia, and gif to Unisys.  Is there such a thing
> as an animated png?  How about a free (in the GPL sense) open sourced
> alternative to Flash?
>

Well, it isn't impossible, though it is inconvenient, to make multiple
images and switch through them with JavaScript...

--
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: techniques for handling large text files

2003-12-28 Thread Tom Kinzer
Maybe try not checking the marker counter every single line.

Also, is the end of file check really necessary?  You could just let it drop
out naturally.

These are probably minor hits compared to a major I/O tweak someone may come
up with but is a suggestion.  I don't see anything jumping out at me for
I/O.

Have you tried benchmark on it?

-Tom Kinzer

-Original Message-
From: danl001 [mailto:[EMAIL PROTECTED]
Sent: Sunday, December 28, 2003 10:06 PM
To: [EMAIL PROTECTED]
Subject: techniques for handling large text files


Hi,

If this question would be better posted to another perl list, please let
me know.

I have a very large text files (~2 GB) and it's in the following format:

header line
header line
header line
marker 1
header line
header line
header line
marker 2
line type 1
line type 1
line type 1
...
line type 1
line type 2
line type 2
line type 2
...
line type 2
end of file marker line


My objective is to put all "line type 1" lines to file1.txt and all
"line type 2" lines to file2.txt. The "header line" and any of the
marker lines will not appear in either file1.txt or file2.txt. Note
there is no marker line between where line type 1 ends and where line
type 2 starts, but that can be determined by examining a field in the line.

So I have a script to do this. Essentially, it visits each line in the
file and decides which output file to write it to. The problem is it
takes a long time to run (roughly 45 min) (dual p4, 512 ram). I'd like
to cut this running time down as much as possible. What I'm looking is
either suggestions on a better way to do this in perl, or suggestions or
techniques I could use to speed up my current script. I have pasted the
relevant parts of the script below. I noticed I could shave a bit off
the runtime by reading the original file in a buffered manner instead of
  line by line. My outputs to file1.txt and file2.txt at this point take
place with prints to their respective file handles.

Any suggestions that will speed this up in any way will be greatly
appreciated! Thanks,

Dan

--- script ---

# open original file
open(INPUT, $filename) or die "error: $filename cannot be opened\n";
my $BUFFER_SIZE = 4096;
my $buffer = "";
my $sz_buffer = 0;

# open output file for line type 1
my $out1 = "$file1.txt";
open(OUT1, ">$out1") or die "error: $out1 cannot be opened for writing\n";

# open output file for line type 2
my $out2 = "$file2.txt";
open(OUT2, ">$out2") or die "error: $out2 cannot be opened for writing\n";

# counter for the markers we see
my $marker_count = 0;

my $regex_split_space='\s+';
my $regex_split_newline='\n';
my $regex_marker='^marker';
my $regex_eof='^end file';

while (my $rv = read(INPUT, $buffer, $BUFFER_SIZE)) {

 if ($rv >= $BUFFER_SIZE) {
 $buffer .= ;
 }

 #print "rv: $rv\n";
 my @lines = split(/$regex_split_newline/o, $buffer);
 # process each line in zone file
 foreach my $line (@lines) {

 #print "line: $line\n";
 if ( $marker_count != 2 ) {

 # if we haven't seen 2 marker lines, we
 # are still in the header section of the file
 if ( $line =~ m/$regex_marker/o ) {
$marker_count++;
}

 } elsif ( $line =~ m/$regex_eof/o ) {
 # end of the input file. close
 # our two output files and get out
 close(OUT1);
 close(OUT2);
 exit 0;

 } else {
 # a line we care about

 # split the line on a space character
my @fields = split(/$regex_split_space/o, $line);

 # check the second field in this line
 if ( $fields[1] eq "1" ) {

 print OUT1 "$line\n";

 } elsif ( $fields[1] eq "2" ) {

 print OUT2 "$line\n";

 } else {

print "@fields\n";
die "saw something other than a 1 or 2 line\n";

 }
 }
 }

 $buffer = "";
}


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



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




RE: How to count the size of files in a directory

2003-12-27 Thread Tom Kinzer
not sure if you meant except those that match...in that case, replace the if
with unless.

-Tom Kinzer

-Original Message-
From: danield [mailto:[EMAIL PROTECTED]
Sent: Saturday, December 27, 2003 10:15 PM
To: perl_beginer
Subject: How to count the size of files in a directory


Hello all,

I do have a beautiful script, that counts a size of specified files
("ABAA.txt", "ABAC.txt") in a directory test. I have got this script
from discussion board.

Here is the script:

my $dir='c:\\test';
my @files2check = ("ABAA.txt", "ABAC.txt");

my $totalSize= 0;
foreach (@files2check) {
   $totalSize += (-s "$dir\\$_") if /^AB/;
}

print $totalSize;

I would like to modify it that it will count the size of all files in the
directory, EXCEPT those in list or so it will count the size of files that
match first 2 characters "AB" (sort of AB*)
Can anybody advice?

Thank you for your time.

danield


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



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




RE: Array Representation

2003-12-23 Thread Tom Kinzer
that says assign elements 12 through 24 of that array these values.

element numbering in perl starts at zero, so 12 is the 13th element in the
array.

-Tom Kinzer

-Original Message-
From: Ursala Luttrell [mailto:[EMAIL PROTECTED]
Sent: Tuesday, December 23, 2003 10:41 AM
To: [EMAIL PROTECTED]
Subject: Array Representation


I need to modify an existing perl script.  Within the code the following
appears:

@unique_array[12..24]=
$first_total,$second_total,$third_total,$fourth_total,undef,$fifth_total,$si
xth_total,undef,1000);

I don't understand what the function of [12..24] is.  Thanks in advance for
an explanation.



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



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




RE: Align Text

2003-12-19 Thread Tom Kinzer
say wha?  show me, please.

-Original Message-
From: Bill Jastram [mailto:[EMAIL PROTECTED]
Sent: Friday, December 19, 2003 10:04 AM
To: Tom Kinzer
Cc: James Edward Gray II; Perl List
Subject: RE: Align Text


We're getting closer. But lets say the first name of the first field in the
first row is 'Bill'. And the first name of the first field in the second row
is 'Lanette'. This command will not compensate for the difference in the
length of the two first names. So, the alignment of the second fields in
each row will not be correct. And so on ...

Does this help you understand where I'm headed?

Bill
__

>yes, and if that won't work for you, check out the 'format' command,
>you can
>do lots of slick stuff with it, like centering.
>
>-Tom Kinzer
>
>-Original Message-
>From: James Edward Gray II [mailto:[EMAIL PROTECTED]
>Sent: Friday, December 19, 2003 9:16 AM
>To: Bill Jastram
>Cc: Perl List
>Subject: Re: Align Text
>
>
>On Dec 19, 2003, at 8:29 AM, Bill Jastram wrote:
>
>> James:
>>
>> A coupe of things.
>>
>> #1. Pardon my ignorance, but I'm not sure how to use the list
>where I
>> found the reply button to e-mail you directly. I could not find a
>way
>> to
>> add to the already existing 'thread'. Your help would be
>appreciated.
>
>The list is just another address you can send your messages too:
>
>[EMAIL PROTECTED]
>
>A lot of people just hit "Reply All" if their mail client has such a
>button.  In the case of this message, that would send your answer to
>me
>and the list.
>
>> #2. The challenge with the use of %20s is that in the next row of
>> records
>> the names will not be aligned (flush left) with the row above, if the
>> names are not the same length. This is my dilemma.
>
>Correct, but they will be aligned flush right.  For flush left, we just
>change the pattern a little:
>
> > perl -e 'printf "%-20s %-20s %-20s\n", "James", "Edward", "Gray"'
>JamesEdward   Gray
>
>Does that answer your question?
>
>James
>
>
>--
>To unsubscribe, e-mail: [EMAIL PROTECTED]
>For additional commands, e-mail: [EMAIL PROTECTED]
><http://learn.perl.org/> <http://learn.perl.org/first-response>
>
>

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



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




RE: Preventing Accidentally Fork Bombing My Box

2003-12-19 Thread Tom Kinzer
nope, looks like it's no safety net for CPU or anything, just
compartmentalized namespace and such.

-Tom Kinzer

-Original Message-
From: Tom Kinzer [mailto:[EMAIL PROTECTED]
Sent: Friday, December 19, 2003 9:27 AM
To: Dan Anderson; Perl Beginners
Subject: RE: Preventing Accidentally Fork Bombing My Box


use safe ?

just a guess if it will work for this problem.  check it out.

-Tom Kinzer

-Original Message-
From: Dan Anderson [mailto:[EMAIL PROTECTED]
Sent: Friday, December 19, 2003 8:56 AM
To: Perl Beginners
Subject: Preventing Accidentally Fork Bombing My Box


I'm creating an app that uses forks in a number of places to do things
quicker.  Unfortunately, I have a bad habit of accidentally fork bombing
my box.  Is there any way I can run a perl process (even if it's a Linux
command) so that it wont eat up all available resources if I screw up?
Or do I just need to learn to be more careful?

-Dan


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



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



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




RE: Preventing Accidentally Fork Bombing My Box

2003-12-19 Thread Tom Kinzer
use safe ?

just a guess if it will work for this problem.  check it out.

-Tom Kinzer

-Original Message-
From: Dan Anderson [mailto:[EMAIL PROTECTED]
Sent: Friday, December 19, 2003 8:56 AM
To: Perl Beginners
Subject: Preventing Accidentally Fork Bombing My Box


I'm creating an app that uses forks in a number of places to do things
quicker.  Unfortunately, I have a bad habit of accidentally fork bombing
my box.  Is there any way I can run a perl process (even if it's a Linux
command) so that it wont eat up all available resources if I screw up? 
Or do I just need to learn to be more careful?

-Dan


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



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




RE: Align Text

2003-12-19 Thread Tom Kinzer
yes, and if that won't work for you, check out the 'format' command, you can
do lots of slick stuff with it, like centering.

-Tom Kinzer

-Original Message-
From: James Edward Gray II [mailto:[EMAIL PROTECTED]
Sent: Friday, December 19, 2003 9:16 AM
To: Bill Jastram
Cc: Perl List
Subject: Re: Align Text


On Dec 19, 2003, at 8:29 AM, Bill Jastram wrote:

> James:
>
> A coupe of things.
>
> #1. Pardon my ignorance, but I'm not sure how to use the list where I
> found the reply button to e-mail you directly. I could not find a way
> to
> add to the already existing 'thread'. Your help would be appreciated.

The list is just another address you can send your messages too:

[EMAIL PROTECTED]

A lot of people just hit "Reply All" if their mail client has such a
button.  In the case of this message, that would send your answer to me
and the list.

> #2. The challenge with the use of %20s is that in the next row of
> records
> the names will not be aligned (flush left) with the row above, if the
> names are not the same length. This is my dilemma.

Correct, but they will be aligned flush right.  For flush left, we just
change the pattern a little:

 > perl -e 'printf "%-20s %-20s %-20s\n", "James", "Edward", "Gray"'
JamesEdward   Gray

Does that answer your question?

James


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



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




RE: how to remove a ^M charaters from a variable

2003-12-19 Thread Tom Kinzer
Also to address the root cause, the OP said it was on the end of every line.
I would check the whole system - depending on the journeys and gyrations the
CSV file goes through before you get it.  An intelligent use of ASCII ftp
(binary bad) and/or chomp will usually take care of any of the
cross-platform weirdness on the end of your lines.

-Tom Kinzer

-Original Message-
From: agftech lists [mailto:[EMAIL PROTECTED]
Sent: Friday, December 19, 2003 9:00 AM
To: [EMAIL PROTECTED]
Subject: Re: how to remove a ^M charaters from a variable


I'd found this here
http://www.unixblog.com/quick_unix_tips/remove_m_with_vi.php

You can try this on multiple files
perl -pi -e 's/\015//g' files





On Sat, 2003-12-20 at 07:21, David Inglis wrote:
> I am reading in a csv file and it has a control character ^M at the end
> of each line how can I remove these charaters, I have tried the following
> and had no success.
>
> $a=~s/\^M//;
> $a=~s/^M//;
>
>
> Any help appreciated thanks.
>
>
> --
> Regards
>
>
>
> David Inglis
> 0408502342


__
Aman Raheja
AGF Technologies
http://www.agftech.com
__


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



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




RE: how to remove a ^M charaters from a variable

2003-12-19 Thread Tom Kinzer
right - my bad.   what i mean, not what i say!

thanks rob.

-Tom Kinzer

-Original Message-
From: Rob Dixon [mailto:[EMAIL PROTECTED]
Sent: Friday, December 19, 2003 3:07 AM
To: [EMAIL PROTECTED]
Subject: Re: how to remove a ^M charaters from a variable


Tom Kinzer wrote:
>
> tr/015//;

This will do nothing to the string. It will just return the
number of zero, one and five characters it finds.

Control-M is

  "\cM"
or
  "\x0D"
or
  "\015"
or
  "\r"

To get 'tr' to delete the characters it finds you need the /d
modifier.

  tr/\015//d

will do the trick.

Cheers,

Rob



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



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




RE: how to remove a ^M charaters from a variable

2003-12-19 Thread Tom Kinzer
tr/015//;

-Tom Kinzer

-Original Message-
From: Randy W. Sims [mailto:[EMAIL PROTECTED]
Sent: Thursday, December 18, 2003 8:05 PM
To: David Inglis
Cc: [EMAIL PROTECTED]
Subject: Re: how to remove a ^M charaters from a variable


On 12/20/2003 8:21 AM, David Inglis wrote:

> I am reading in a csv file and it has a control character ^M at the end
> of each line how can I remove these charaters, I have tried the following
> and had no success.
> 
> $a=~s/\^M//;
> $a=~s/^M//;
> 
> 
> Any help appreciated thanks.
> 
> 

^M is the carriage return. Try s/\x0D//;

Regards,
Randy.


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



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




RE: script for passwd file

2003-12-16 Thread Tom Kinzer
we'll be curious to see what you come up with for a solution, rob.

*and help if you get stuck*

-Tom Kinzer

-Original Message-
From: rmck [mailto:[EMAIL PROTECTED]
Sent: Tuesday, December 16, 2003 5:01 PM
To: [EMAIL PROTECTED]
Subject: script for passwd file


Hi,


I'm stuck and that I would ask if anyone has a script to check for empty
passwords /etc/passwd/ /etc/shadow and then lock them Thanks

Rob

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



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




RE: Recommended simple Perl IDE/Editors ?

2003-12-15 Thread Tom Kinzer
I use the IDE OptiPerl and like it quite a bit.  Vim is the best editor,
IMHO.  The Optiperl boys have added Vim OLE support to their list of
enhancements.


http://www.xarka.com/optiperl/index.html

-Tom Kinzer


-Original Message-
From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED]
Sent: Monday, December 15, 2003 10:24 AM
To: [EMAIL PROTECTED]
Subject: Recommended simple Perl IDE/Editors ?


Hi all:

Just wondering what IDE/editor folks use for their Perl work ?

I'm looking for something for a W2K system that is easy to use (without
customization) and that has the basics (syntax highlighting, visual
debugging, something that shows variable values, the values in whitespace,
etc) without a lot of bell & whistles.

I plan to look at:

ActiveState Komodo 2.5
PerlEdit
OpenPerl IDE

Any recommendation, or feedback on the above IDE's would be appreciated.

Thanks.



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




RE: Recommended simple Perl IDE/Editors ?

2003-12-15 Thread Tom Kinzer
OptiPerl rocks.

http://www.xarka.com/optiperl/index.html


-Tom Kinzer


-Original Message-
From: Randy W. Sims [mailto:[EMAIL PROTECTED]
Sent: Monday, December 15, 2003 2:22 PM
To: Wiggins d Anconia
Cc: Chuck Fox; [EMAIL PROTECTED]; [EMAIL PROTECTED]
Subject: Re: Recommended simple Perl IDE/Editors ?


On 12/15/2003 3:29 PM, Wiggins d Anconia wrote:

> 
>>[EMAIL PROTECTED] wrote:
>>
>>
>>>>Just wondering what IDE/editor folks use for their Perl work ?
>>>
>>>I am on OS X but I use a Java-based editor called jedit, which is 
>>>available on W32 as well, I guess.
>>>http://www.jedit.org/
>>>
>>>It supports syntax highlightning, plus it's Freeware and there are 
>>>lots of nice add-ons!
>>>
>>>Stephan
>>>
>>
>>FWIW, I am a big fan of emacs and vim, both do syntax highlighting.  
>>Emacs is a little more arcane, but if you are comfortable with vi, then 
>>vim makes a good choice.  www.vim.org, its a winner for a simple editor 
>>that doesn't get in your way and is available on windows, mac, and *nix.
>>
>>HTH,
>>
>>Chuck
>>
> 
> 
> I thought it was illegal to be a fan of both Vim and emacs?  Personally
> I am a Vim user though have known a couple of nice emacs users,
> though they looked kinda funny ;-)... 

Hey, I resemble that remark.



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



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




RE: Parentheses

2003-12-12 Thread Tom Kinzer
as a matter of style, i think always having them is nice for
maintenance/readability.

-Tom Kinzer

-Original Message-
From: Rob Dixon [mailto:[EMAIL PROTECTED]
Sent: Friday, December 12, 2003 8:08 AM
To: [EMAIL PROTECTED]
Subject: Re: Parentheses


Paul Kraus wrote:
>
> Ok another question on perl then. When do you have to use () on a
> function or sub call? Or in the new construct of an object.
> I use then on everything since I don't better. Figure its safer to leave
> them on then take them off.

Very simply, if you've previously declared a subroutine either
explicitly or by importing from a module then it becomes a list
operator. It will be passed everything listed in the call and you
don't need parentheses.

If you're calling an undeclared subroutine, or the call is ambiguous
without them then you need parentheses.

Built-in functions and prototyped subroutines behave exactly how
you say they should. But forget about prototyping subroutines:
it almost never the way to go.

Take a look at the program below.

I hope this helps.

Rob


sub subA;  # Predeclare just subA

  subA 1, 2, 3, 4;
  subA (1), 2, 3, 4;

# subB 1, 2, 3, 4; # Syntax error
  subB (1, 2, 3, 4);
  subB (1), 2, 3, 4;


sub subA { print "SubA: ", scalar @_, " parameters\n" };
sub subB { print "SubB: ", scalar @_, " parameters\n" };






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



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




RE: Question for this Group ... dont flame me :)

2003-12-12 Thread Tom Kinzer
btw Jeff, good post.

I think this will stimulate a good conversation.  This is a common problem
with lots of different workarounds.

Thanks.

-Original Message-
From: Jeff Westman [mailto:[EMAIL PROTECTED]
Sent: Friday, December 12, 2003 7:26 AM
To: perl_help
Subject: Question for this Group ... dont flame me :)


Question for this group.  And please don't flame me for asking this.

Often times one writes in, asking how to do something fairly trivial,
such as a date conversion from a non-standard format, or doing something
else not require too much overhead.  When asked for advice, nine times
out of ten, the responded will refer the originator to such-and-such
module at CPAN to download and install.  I'm all for not re-inventing
the wheel -- don't get me wrong.  But if any of you are like me, you
don't have access to install modules that run in a production environment.
In my case, we have a couple of test servers and several hundred satellite
servers that run 'production code'.  So, installing a module is out-of-
the-question.  In my case, I am basically "stuck" with the perl [5.8]
default libraries and modules.

So, why is it that most of the solutions represented in this group tend
to point to a CPAN module when the code for it isn't that hard (usually)
to write?  I'm not sure if using modules is a matter of "convenience"
or "necessity".  While the solutions shown here will most often work,
they aren't practical for Joe Programmer working in the corporate world
(don't flame me! LOL) who doesn't have access to install as root or install
on many many servers.

My point being, it might be helpful to provide a solution such as

 See xxx::yyy at CPAN or my solution below

I tend to believe that most people part this list distribution do coding
for a living, while others just tinker with it on the side or are
students.

I suppose one way to point to a CPAN module and not have to install
as root would be to install the module in the application library path.

Thoughts?


-Jeff


__
Do you Yahoo!?
New Yahoo! Photos - easier uploading and sharing.
http://photos.yahoo.com/

--
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: Question for this Group ... dont flame me :)

2003-12-12 Thread Tom Kinzer
Well, I'm a professional Perl developer.  I have also been in your position
before Jeff.

I can say that it is just a "best practice" to always use a module.  It's
just smart to reuse modular code.

1) it saves building work
2) it's already tested
3) it's already documented
4) in many cases it's supported by the author(s)
5) it's more maintainable because it usually will have a somewhat standard
interface and/or at least you may have a chance that another team member or
contractor will already know how to use the module somewhere out there.

So, I'd say, if it's in any way feasible to do so, a module makes sense.  If
it's just out of the question, I suppose the poster should state that
constraint.

In any case I don't think it's because people aren't using Perl as a serious
production tool.

As to how to get around it:  You can always install your own version of
perl.  You then have a few perl path issues to deal with, but you can put
whatever modules you want in without mussing any of the "system" perl tools.

-Tom Kinzer

-Original Message-
From: Jeff Westman [mailto:[EMAIL PROTECTED]
Sent: Friday, December 12, 2003 7:26 AM
To: perl_help
Subject: Question for this Group ... dont flame me :)


Question for this group.  And please don't flame me for asking this.

Often times one writes in, asking how to do something fairly trivial,
such as a date conversion from a non-standard format, or doing something
else not require too much overhead.  When asked for advice, nine times
out of ten, the responded will refer the originator to such-and-such
module at CPAN to download and install.  I'm all for not re-inventing
the wheel -- don't get me wrong.  But if any of you are like me, you
don't have access to install modules that run in a production environment.
In my case, we have a couple of test servers and several hundred satellite
servers that run 'production code'.  So, installing a module is out-of-
the-question.  In my case, I am basically "stuck" with the perl [5.8]
default libraries and modules.

So, why is it that most of the solutions represented in this group tend
to point to a CPAN module when the code for it isn't that hard (usually)
to write?  I'm not sure if using modules is a matter of "convenience"
or "necessity".  While the solutions shown here will most often work,
they aren't practical for Joe Programmer working in the corporate world
(don't flame me! LOL) who doesn't have access to install as root or install
on many many servers.

My point being, it might be helpful to provide a solution such as

 See xxx::yyy at CPAN or my solution below

I tend to believe that most people part this list distribution do coding
for a living, while others just tinker with it on the side or are
students.

I suppose one way to point to a CPAN module and not have to install
as root would be to install the module in the application library path.

Thoughts?


-Jeff


__
Do you Yahoo!?
New Yahoo! Photos - easier uploading and sharing.
http://photos.yahoo.com/

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



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




RE: Move a file

2003-12-12 Thread Tom Kinzer
A variation of Wiggins' approach is to pre or append the PID to the file
name.  This can potentially allow multiple processes of the same type to run
simultaneously without stomping on each other while they are running and can
aid in tracking down those production problems - assuming you are logging
your PID, or just figuring out which zombie process owns which file...

it's a little more work to ignore, or you can use both ideas at the same
time and ignore files starting with dot.

-Tom Kinzer

-Original Message-
From: Wiggins d Anconia [mailto:[EMAIL PROTECTED]
Sent: Friday, December 12, 2003 6:37 AM
To: [EMAIL PROTECTED]
Subject: Re: Move a file




> Neill Taylor wrote:
> >
> > I am writing a script which will poll a directory and then move  any
files
> > in the directory to a new directory dependant upon its name.
> >
> > The problem I think I might have is that the script may try to pick
a file
> > that is still being copied into the directory whilst the application is
> > still trying to write the file.
> >
> > What is the best method in Perl to prevent errors.
>
> Hi Neill.
>
> If your application is well-behaved then it may lock the file
> for writing. If your Perl program asks for an exclusive lock
> then it will be granted if it no longer being accessed.
> Take a look at
>
>   perldoc -f flock
>
> Another way is to check the size of file. A file will often
> show a size of zero until it is closed by the writing
> application.
>
> Finally, if only one file at a time is being written then
> just sort the them in order of creation date and move all
> but the latest one.
>
> What works you will find only by experimentation.
>

Depending on what is writing the files, aka another controllable
program? I have had good luck with writing the file to a temporary
location, usually with a dot on the front, then executing a move from
that temp location to the real name. A move is usually a single action
(at least that's my understanding) and for most filesystems is merely a
single inode update.  Then just have the directory watcher skip dot
files... Though the lock would probably be better...

http://danconia.org

--
Boycott the Sugar Bowl! You couldn't pay me to watch that game.

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



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




RE: adding path to $PATH

2003-12-10 Thread Tom Kinzer
in korn it would be:

export PATH=$(add_path):$PATH


-Original Message-
From: Robert Brown [mailto:[EMAIL PROTECTED]
Sent: Wednesday, December 10, 2003 3:20 PM
To: drieux
Cc: Perl Perl
Subject: Re: adding path to $PATH


drieux writes:
 > 
 > On Dec 9, 2003, at 10:09 PM, Pablo Cusnir wrote:
 > 
 > > Is there a way using Perl to add to the environment
 > > variable PATH a new path, and that addition will be
 > > valid after the script is ran and not only for the script's scope.
 > > I'm working in cshell in Solaris 5.8
 > 
 > let me see IF I get your idea.
 > 
 > I have a command say "add_path"  so that
 > you could do something like
 > 
 >  vladimir: 70:] echo $PATH
 >  /usr/local/bin:/usr/X/bin:/usr/bin
 >  vladimir: 71:] add_path
 >  vladimir: 72:] echo $PATH
 >  /happy/place/here:/usr/local/bin:/usr/X/bin:/usr/bin
 >  vladimir: 73:]
 > 
 > that's not really going to happen, since you want to
 > change the environment of the currently running process
 > by having a sub-process 'signal it'...


I am not a c-shell guy, but in then Bourne shell, or in bash, you
could accomplish what you want in a similar fashion thus:

# instead of "add_path" being called directly, you can do this:
export PATH=`add_path`:$PATH

The back-quotes perform what lispers call a "splice macro".  The value 
that is returned on add_path's stdout replaces the text or `add_path`
so that it does what you want.  So add_path might look something like
this: 

#!/bin/bash

# add_path -- return a path to add to PATH

echo /some/unusual/path:/another/one:/and/so/forth

I know there is a similar construct in csh, but I do not remember what 
it is.

I hope this is at least some help.


-- 
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: -e with single quotes

2003-12-10 Thread Tom Kinzer
Guessing here but maybe you don't want to use *Perl's* escape, but instead
use your *shell's* escape.

Whatchu running from?

-Tom Kinzer

-Original Message-
From: Dan Muey [mailto:[EMAIL PROTECTED]
Sent: Wednesday, December 10, 2003 3:05 PM
To: beginners
Subject: -e with single quotes


Hello group.

I'm tryign to do a perl -e '' command and am wondering if it is
possible to do single quotes inside the single quotes.
IE

perl -e 'print "joe's mama";'
Obvo=iously won't work
perl -e 'print "joe\'s mama";'
And any other versions of \\' all fail.

Is there a way to use a single quote inside a single quoted -e command?
Using a different character would just cause the same problem but with
different characters right?

TIA

Dan

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



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




RE: Match the first 3 characters of 2 words?

2003-12-10 Thread Tom Kinzer
perldoc -f substr

would be one way.  "easiest" is a loaded word, depends on the context and
the individual...

-Tom Kinzer

-Original Message-
From: Rod [mailto:[EMAIL PROTECTED]
Sent: Wednesday, December 10, 2003 12:19 PM
To: '[EMAIL PROTECTED]'
Subject: Match the first 3 characters of 2 words?


What is the easiest way to test the first 3 characters of two words for
a match.

IE:  "dasf" test "dasg" to return positive.


rod.



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



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




RE: file path pattern matching problem.

2003-12-10 Thread Tom Kinzer
Yes! And use Basename too.

these will also give you the advantage of making your programs more
portable!

-Tom Kinzer


-Original Message-
From: John W. Krahn [mailto:[EMAIL PROTECTED]
Sent: Wednesday, December 10, 2003 11:37 AM
To: [EMAIL PROTECTED]
Subject: Re: file path pattern matching problem.


Ben Crane wrote:
>
> Hi all,

Hello,

> I'm trying to split apart a filepath...e.g:
> c:\test\abc\what\somefile.txt
> The length of the filepath will never be constant...


$ perl -le'
use File::Spec;

my $path = q[c:\test\abc\what\somefile.txt];

my ( $vol, $dir, $file ) = File::Spec->splitpath( $path );
print qq[ "$vol"  "$dir"  "$file" ];

my @dirs = File::Spec->splitdir( $dir );
print map qq[ "$_" ], @dirs;

'
 "c:"  "\test\abc\what\"  "somefile.txt"
 ""  "test"  "abc"  "what"  ""



John
--
use Perl;
program
fulfillment

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




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




RE: Help needed on perl wrappers

2003-12-10 Thread Tom Kinzer
Hmmm, yes I don't know of anything off the top of my head, but if you are
doing terminal stuff, I would dig around (starting with CPAN of course) for
anything with text based menus where you can map areas of the screen.

Perl Tk is pretty cool (and well-named, I might add) and not too difficult
in case you have a windows manager running and it's an option.  I would
argue that learning Tk could be comparable to learning and mussing with a
text based menu module unless you can just get lucky enough to dig up
exactly a single method that you need.  In Tk, you would just drop those two
columns into two frames, make 'em scrollable and bob's your uncle - you're
done.

Good luck, let us know what you end up with and how it worked for you.

-Tom Kinzer

-Original Message-
From: Wiggins d Anconia [mailto:[EMAIL PROTECTED]
Sent: Wednesday, December 10, 2003 6:52 AM
To: Pandey Rajeev-A19514; '[EMAIL PROTECTED]'
Subject: RE: Help needed on perl wrappers


Please bottom post...

> Hi,
>
> I was interested in formatted display on screen.
>
> I can display ONE text paragraph in any part of the screen with
Text::wrap. My question was how to adjust MANY such independent
paragraphs in one screen (exactly in a newspaper format where you have
8-10 columns of news items on a single page).
>
> I wanted to know is there something like Text::wrap which can do this.
Or Text::wrap can handle only one paragraph. If nothing like that exists
then I might have to give up Text::wrap and use my own logic to adjust it.
>
> Moreover, I also wanted to use Term::Size to adjust the text with
changing screen size.
>
> Is there any convenient way to do this ? I was looking for readymade
stuff.
> Please suggest.
>

Have you looked into using ncurses?  There is at least one Perl module
for manipulating terminals using (n)curses. I have not yet used it for
anything in particular, though have seen it used in other apps,
centericq for instance.  I would think a combination of your text
wrapper with curses terminal control should provide what you want...

http://danconia.org


>
> -Original Message-
> From: Tom Kinzer [mailto:[EMAIL PROTECTED]
> Sent: Wednesday, December 10, 2003 12:05 PM
> To: [EMAIL PROTECTED]
> Subject: RE: Help needed on perl wrappers
>
>
>
> I'm trying to figure out WHY you would ever want to create what you are
> asking for.  Why-- is a good question here, because there may be a way to
> get to the real goal instead of creating this.  For instance if it's just
> going into an HTML document, a table of course, would be easier.  Just an
> example, so WHY are you wanting to do this?
>
> If this is really want you want, then: Do you really want a ragged left on
> the right column?  Do you really want to use tabs?  I'm thinking spaces
> would be easier to deal with for this problem and could buy you a
justified
> left margin on the right column.
>
> More info please.
>
> -Tom Kinzer
>
> -Original Message-
> From: Pandey Rajeev-A19514 [mailto:[EMAIL PROTECTED]
> Sent: Tuesday, December 09, 2003 8:16 PM
> To: '[EMAIL PROTECTED]'
> Subject: Help needed on perl wrappers
>
>
> Hi,
>
> I have a text that I read from a file. I want to display the text on the
> screen in a column in a newspaper style.
> I do it like this
>
> $initial_tab = "\t\t";
> $subsequent_tab = "\t\t";
> print wrap($initial_tab, $subsequent_tab, @text1);
> print fill($initial_tab, $subsequent_tab, @text1);
>
> It will print like this ...
> I am a boy and I go to school
> everyday. I have to do a lot of
> homework and I dont get time
> to play these days.
>
>
> But if I have more than one independent text i.e. @text2, @text3 to be
> displayed in different columns, then what shall i do.
> I want something like this ...
>
> I am a boy and I go to schoolShe is a girl and she
> also goes
> everyday. I have to do a lot ofto school. I do all
> her homework
> homework and I dont get time   and she gets plenty of
> time to
> to play these days   play.
>
> Is there any mechanism to achieve this ?
>
> Best Regards
> Rajeev
>

--
Boycott the Sugar Bowl! You couldn't pay me to watch that game.

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



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




RE: Help needed on perl wrappers

2003-12-09 Thread Tom Kinzer

I'm trying to figure out WHY you would ever want to create what you are
asking for.  Why-- is a good question here, because there may be a way to
get to the real goal instead of creating this.  For instance if it's just
going into an HTML document, a table of course, would be easier.  Just an
example, so WHY are you wanting to do this?

If this is really want you want, then: Do you really want a ragged left on
the right column?  Do you really want to use tabs?  I'm thinking spaces
would be easier to deal with for this problem and could buy you a justified
left margin on the right column.

More info please.

-Tom Kinzer

-Original Message-
From: Pandey Rajeev-A19514 [mailto:[EMAIL PROTECTED]
Sent: Tuesday, December 09, 2003 8:16 PM
To: '[EMAIL PROTECTED]'
Subject: Help needed on perl wrappers


Hi,

I have a text that I read from a file. I want to display the text on the
screen in a column in a newspaper style.
I do it like this

$initial_tab = "\t\t";
$subsequent_tab = "\t\t";
print wrap($initial_tab, $subsequent_tab, @text1);
print fill($initial_tab, $subsequent_tab, @text1);

It will print like this ...
I am a boy and I go to school
everyday. I have to do a lot of
homework and I dont get time
to play these days.


But if I have more than one independent text i.e. @text2, @text3 to be
displayed in different columns, then what shall i do.
I want something like this ...

I am a boy and I go to schoolShe is a girl and she
also goes
everyday. I have to do a lot ofto school. I do all
her homework
homework and I dont get time   and she gets plenty of
time to
to play these days   play.

Is there any mechanism to achieve this ?

Best Regards
Rajeev

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



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




RE: Pattern Match

2003-12-09 Thread Tom Kinzer
Rob, can you explain the details of that replace?  That's pretty slick.  I
see you're adding the hex value to get to the appropriate ASCII value, but
didn't know you could do some of that gyration inside a regex.

Thanks.

-Tom Kinzer

-Original Message-
From: Rob Dixon [mailto:[EMAIL PROTECTED]
Sent: Tuesday, December 09, 2003 11:58 AM
To: [EMAIL PROTECTED]
Subject: Re: Pattern Match


Eric Sand wrote:
>
> I am very new to Perl, but I sense a great adventure ahead after just
> programming with Cobol, Pascal, and C over the last umpteen years. I have
> written a perl script where I am trying to detect a non-printing
> character(Ctrl@ - Ctrl_) and then substitute  a printing ASCII sequence
such
> as "^@" in its place, but it does not seem to work as I would like. Any
> advice would be greatly appreciated.
>
>  Thank YouEric Sand
>
>

Your obvious guess is to write Perl as if it were C. That's slightly better
than treating it as a scripting language, but there are many joys left to be
found!

> $in_ctr=0;
> $out_ctr=0;
>
> while ($line = )
> {
> chomp($line);
> $in_ctr ++;
> if ($line = s/\c@,\cA,\cB,\cC,\cD,\cE,\cF,\cG,\cH,\cI,\cJ,\cK,
>   \cL,\cM,\cN,\cO,\cP,\cQ,\cR,\cS,\cT,\cU,\cV,\cW,
>   \cX,\cY,\cZ,\c[,\c\,\c],\c^,\c_
>  /^@,^A,^B,^C,^D,^E,^F,^G,^H,^I,^J,^K,
>   ^L,^N,^N,^O,^P,^Q,^R,^S,^T,^U,^V,^W,
>   ^X,^Y,^Z,^[,^\,^],^^,^_/)
> {
> $out_ctr ++;
> printf("Non-printing chars detected in: %s\n",$line);
> }
> }
> printf("Total records read =
%d\n",$in_ctr);
> printf("Total records written with non-printing characters =
%d\n",$out_ctr);

I would write this as below. The first things is to *always*

  use strict;
  use warnings;


after which you have to declare all of your variables with 'my'.

The second is to get used to using the default $_ variable which
is set to the value for the current 'while(<>)' or 'for' loop
iteration, and is a default parameter for most built-in functions.

Finally, in your particular case you're using the s/// (substitute)
operator wrongly. The first part, s/here//, is a regular expression,
not a list of characters. You'll need to read up on these at

  perldoc perlre

The second part, s//here/, is a string expression which can use
'captured' sequences (anything in brackets) from the first part
and, with the addition of the s///e (executable) qualifier can
also be an executable statement. Here I've used it to add 0x20
to the ASCII value of the control character grabbed by the regex.

A lot of this won't make sense until you learn some more, but I
hope you'll agree that this code is cuter than your original?

HTH,

Rob



use strict;
use warnings;

my $in_ctr = 0;
my $out_ctr = 0;

while (<>) {

  chomp;

  $in_ctr++;

  if (s/([\x00-\1F])/'^'.chr(ord($1) + 0x40)/eg) {
$out_ctr++;
printf "Non-printing chars detected in: %s\n", $_;
  }
}

printf "Total records read = %d\n", $in_ctr;
printf "Total records written with non-printing characters = %d\n",
$out_ctr;



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



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




RE: Reading a log file, again

2003-12-08 Thread Tom Kinzer
OP said:
"From what I understand, your script looks for 'Total:' and then for
following line with numbers, reads them and prints them. That is what I
need. However, there are 3 sections with 'Total:' and I am interested only
in one of them. "



2 preceding bits of info determine which is the right one.

-Tom Kinzer


-Original Message-
From: R. Joseph Newton [mailto:[EMAIL PROTECTED]
Sent: Monday, December 08, 2003 7:02 PM
To: Tom Kinzer
Cc: Katka a Daniel Dunajsky; Beginners Perl
Subject: Re: Reading a log file, again


Tom Kinzer wrote:

> Try this:
>
> Caveat: This all assumes LOTS about the format of your data being
> consistent, and so should be treated as a "quick and dirty" as opposed to
> anything resembling a robust application...  I'm not sure what your
> intention with the script is, but is worth mentioning.
>
> -Tom Kinzer

Hi Tom,

I think this may be getting too complicated.  My understanding is that the
OP was
actually interested in a single datum, the total figure at the bottom.  I
haven't
seen any clarification indicating otherwise, so I would suggest just doing
it:

my $junk = '';
$junk =  until $junk =~/^Total/;
$pot_o_gold = ;
$pot_o_gold =~ s/^\s*//;
chomp $pot_o_gold;
print "I got my value, and it's $pot_o_gold\n";
__DATA__
...
Format  count
a   100
b51
c   130
d 5
e 6
Total:  ---
292
I got my value, and it's 292

Remember KISS.

Joseph


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




RE: [OT] Education Level

2003-12-08 Thread Tom Kinzer
 http://perlcert.perlocity.org/

-Original Message-
From: J Ingersoll [mailto:[EMAIL PROTECTED]
Sent: Monday, December 08, 2003 4:16 PM
To: Perl Beginner's List
Subject: RE: [OT] Education Level



--- Wiggins d Anconia <[EMAIL PROTECTED]> wrote:
> > 
> > looking to break out of a
> > non-challenging career in mainframe work :^>  )
> > 
> 
> On my "own", meaning no formal education in Perl. I got my start on the
> job from 2 programmers that came before me (which is why it wasn't
> really on my own), but that was 1997 and times have changed, a lot. 
> However I learned *Perl programming* from this list and reading the docs
> over the last year and a half, before that I was, at best, doing Perl 4
> web programming, which *is* a different thing, though I wouldn't have
> admitted it (and didn't really know it), either, at the time :-).
> 
> You have hit on the key point for me, this game is about constantly
> learning, doctors have CME, dentists have CDE, other professions require
> re-education to remain licensed, while I don't know that I would agree
> with licensing programmers in a similar manner, if a developer believes
> they will not fall behind by sitting comfortably in their current
> position they are definitely going to find themselves as obsolete as the
> tech they work in.  Whether it matters is a different discussion and one
> that others have hinted to...
> 
> http://danconia.org
> 
> 
> --
> Boycott the Sugar Bowl! You couldn't pay me to watch that game.
THanks - actually i've done my best learning outside of the classroom -
however having discovered Linux about 2 yrs. ago and more recently Perl
has for the first time in a while given me something worth pursuing
"seriously". I'm working slowly towards the Linux Professional Institute's
exams - it would be nice to put down on a resume also "Perl Certified"
rather than "well I've written some neat scripts at home"...I'm looking
for good things to happen though...

ji

__
Do you Yahoo!?
Protect your identity with Yahoo! Mail AddressGuard
http://antispam.yahoo.com/whatsnewfree

-- 
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: How to process multi-line records ?

2003-12-08 Thread Tom Kinzer
Nice.

Don't forget to "get along well with the other children" by putting $/ back!

-Tom Kinzer

-Original Message-
From: Kevin Pfeiffer [mailto:[EMAIL PROTECTED]
Sent: Monday, December 08, 2003 1:52 PM
To: [EMAIL PROTECTED]
Subject: Re: How to process multi-line records ?


Hi Perl-List!

Stuart Clemons wrote:
[...]
>
> Name:  Joe Blow
> DataField1:  x
> DateField1: 07/07/77
> DataField2: x
> DateField2: 12/07/03
>
> Name:  Fi Doe
> DataField1:  x
> DateField1: 08/08/88
> DataField2: x
> DateField2: 12/12/03
>
> etc.
>
> There is an empty line that separates each record.   I need to extract the
> records that meet certain criteria.   I would really like to know how to
> do this in Perl.
> (For a simple task like this, in the past, I would just import these
> records into a database and write a query to extract the records that I
> wanted.)
>
> I've actually thought a lot about the problem, but I haven't done any perl
> coding that would allow me to put my woeful perl ineptitude on public
> display in this forum.   I hope to find the time to start on this problem
> in the next couple of days.  As I'm certain to run into problems, I will
> then share my ineptitude while looking for proper guidance from the valued
> learned ones.
>
> Until then, here's what I was thinking to do.  What I thought I would do
> is try to read each line of one record into an array or hash, then use a
> conditional to determine if that record meets the desired criteria.  If it
> meets the criteria, write out this record to another  file and then read
> in the next record.  If the record doesn't meet the criteria, read in the
> next  record.  I would keep doing this until EOF.

Here's a simple version that writes matching records to STDOUT...

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

# sample patterns
my $DateField1 = '07/\d+/77';   # July 77
my $Name = "Doe\n"; # Lastname is "Doe"

$/ = "";# treats empty line(s) as record terminator
while() {
   if (m{DateField1:\s+$DateField1} ||
   m{Name:.*$Name}) {
  print;
   }
}

--
Kevin Pfeiffer

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



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




RE: Reading a log file, again

2003-12-08 Thread Tom Kinzer
Try this:

Caveat: This all assumes LOTS about the format of your data being
consistent, and so should be treated as a "quick and dirty" as opposed to
anything resembling a robust application...  I'm not sure what your
intention with the script is, but is worth mentioning.

-Tom Kinzer

__SNIP__

my $input  = '/appl/log/200301130.txt';
my $total;
die "Usage: Arg1: Input File to Scan."
unless $input;

open IN, "< $input" or die "Unable to open $input for reading, $!, stopped";


while (  ) {
if ( /  Document Format/ ) { last };
}

while (  ) {
if ( /  Total: -/ ) { last };
}

while (  ) {
if ( /^\s*\d+/ ) {
   chomp;
   s/\s*(\d+)\s*/$1/;
   $total = $_;
   printf "Total: %010s\n", $total;
   last;
}
}

close IN;

__END__

-Original Message-
From: Katka a Daniel Dunajsky [mailto:[EMAIL PROTECTED]
Sent: Monday, December 08, 2003 12:15 PM
To: [EMAIL PROTECTED]
Subject: Reading a log file, again


Hello Tom,

I hope you are in a good time again, because I would like to ask you for
help – again.
The first script that you did send to me works well. The problem is that I
was not accurate with the situation description.
>From what I understand, your script looks for ‘Total:’ and then for
following line with numbers, reads them and prints them. That is what I
need. However, there are 3 sections with ‘Total:’ and I am interested only
in one of them. I was trying to solve this issue by modifying your script,
now it looks like this:

#!/usr/local/bin/perl -w
use strict;

my $input  = '/appl/log/200301130.txt';
my $total;
die "Usage: Arg1: Input File to Scan."
unless $input;

open IN, "< $input" or die "Unable to open $input for reading, $!, stopped";

while ( defined() ) {

while (  ) {
if ( /  Document Format/ ) { last };
}

while (  ) {
if ( /  Total: -/ ) { last };
}

while (  ) {
if ( /^\s*\d+/ ) {
chomp;
   s/\s*(\d+)\s*/$1/;
   $total = $_;
   printf "Total: %010s", $total;
}
}
}

close IN;

Your script without modification returns 3 values:
Total: 52,497Total: 49,670Total: 49,670.
After the change I implemented it returns 2 values:
Total: 49,670Total: 49,670.
The section I am interested in (in the log file) starts with “  Document
Format” and then there is the “  Total:” and the number returned is the
first 49,670 returned after modification. The second number I am not
interested in and I don’t know how to limit script from continuing further
down. Could you please advice?

Thank you for your time.

danield

_
Add photos to your messages with MSN 8. Get 2 months FREE*.
http://join.msn.com/?page=dept/features&pgmarket=en-ca&RU=http%3a%2f%2fjoin.
msn.com%2f%3fpage%3dmisc%2fspecialoffers%26pgmarket%3den-ca


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




RE: sorter script [was: Frustrated newbie question]

2003-12-07 Thread Tom Kinzer
*Consciously* making the decision that your script will no longer be
portable...

my $2Cents;

-Tom Kinzer

-Original Message-
From: Bryan Harris [mailto:[EMAIL PROTECTED]
Sent: Sunday, December 07, 2003 5:32 PM
To: Beginners Perl
Subject: Re: sorter script [was: Frustrated newbie question]




>> My next Perl task after I get my list of one name per line, is to sort
the
>> list and eliminate duplicate names.
>
> I have used the following script to sort and remove duplicate entries in
flat
> text files.
>
> http://www.downloaddatabase.com/databasesoftware/db-sorter-script.htm


Sometimes perl isn't quite the right tool for the job...

% man sort
% man uniq

- B



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




RE: stripping last field of a carriage return

2003-12-07 Thread Tom Kinzer
Oops.  012.  :(

-Original Message-
From: Tom Kinzer [mailto:[EMAIL PROTECTED]
Sent: Sunday, December 07, 2003 9:41 PM
To: R. Joseph Newton; Bryan Harris
Cc: Beginners Perl
Subject: RE: stripping last field of a carriage return


013 is line feed, aka "new line".

-Tom Kinzer

-Original Message-
From: R. Joseph Newton [mailto:[EMAIL PROTECTED]
Sent: Sunday, December 07, 2003 7:24 PM
To: Bryan Harris
Cc: Beginners Perl
Subject: Re: stripping last field of a carriage return


Bryan Harris wrote:

> > I have tried to strip the carriage return of the last field
> >
> > $field[8] =~ s/\015//g;
>
> Uh, isn't the carriage return code 13?
>
> - B

Not in octal.

Joseph


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



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



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




RE: stripping last field of a carriage return

2003-12-07 Thread Tom Kinzer
Owen, I've had trouble doing this exact thing before with Perl regular
expressions on AIX, I never got in and figured out what exactly was the root
cause, but I just switched to the 'tr' command and it worked fine.

Something to try.

-Tom Kinzer

-Original Message-
From: Owen [mailto:[EMAIL PROTECTED]
Sent: Sunday, December 07, 2003 6:39 PM
To: [EMAIL PROTECTED]
Subject: Re: stripping last field of a carriage return


On Sun, 07 Dec 2003 12:20:46 -0700
"Michael J. Golini" <[EMAIL PROTECTED]> wrote:

> I have tried to strip the carriage return of the last field
>
> $field[8] =~ s/\015//g;

You have to know how your original data was created. In Windows, each line
is terminated by "\r\n" (carriage return followed by line feed). In Unix,
lines end only in "\n". On old Mac systems, lines end only in"\r".
You might want to look at it in a hex editor.

Perl's record separator is $/ You can use this for portable programming.
Unix is ASCII \012
Windows is ASCII \015\012
Mac is ASCII \015


chomp could be the way to go. See perldoc chomp



 --
Owen


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



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




RE: stripping last field of a carriage return

2003-12-07 Thread Tom Kinzer
013 is line feed, aka "new line".

-Tom Kinzer

-Original Message-
From: R. Joseph Newton [mailto:[EMAIL PROTECTED]
Sent: Sunday, December 07, 2003 7:24 PM
To: Bryan Harris
Cc: Beginners Perl
Subject: Re: stripping last field of a carriage return


Bryan Harris wrote:

> > I have tried to strip the carriage return of the last field
> >
> > $field[8] =~ s/\015//g;
>
> Uh, isn't the carriage return code 13?
>
> - B

Not in octal.

Joseph


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



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




RE: Reading from a log - still a problem

2003-12-07 Thread Tom Kinzer
Also, Daniel Post what the data you're scanning looks like.  That should
help.


-Tom

-Original Message-
From: danield [mailto:[EMAIL PROTECTED]
Sent: Sunday, December 07, 2003 8:43 PM
To: [EMAIL PROTECTED]
Subject: Reading from a log - still a problem


Hello all,

I have received a solution for my problem (reading from log) from Tom
Kinzer. The code is:

#!/usr/bin/perl -w
use strict;
my $log_file = "/appl/log/4e4d/20031130.txt";
open LOG, "< $log_file" or die "Could not open file $!";
while (  ) {
  chomp;
  if ( /^GTotal Content:/ ) {
  my ($gtotal_content, $value) = split(/:/, $_);
  print $value;
  }
}
close LOG;

The problem is this code returns no value. When I remove all preceding
lines from the log (20031130.txt) and keep there only that GTotal
Content: 14,741,322, I will get desired result (14,741,322)

What may be a solution for this?

Thank you for your time.

danield




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



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




RE: Reading from a log - still a problem

2003-12-07 Thread Tom Kinzer
Debug time.  Need more info.

Is it ever meeting the if's condition's?

Try this and see what happens:

#!/usr/bin/perl -w
use strict;
my $log_file = "/appl/log/4e4d/20031130.txt";
open LOG, "< $log_file" or die "Could not open file $!";
my ($valueCount, $lineCount);
while (  ) {
  chomp;
  $lineCount++;
  if ( /^GTotal Content:/ ) {
 my ($gtotal_content, $value) = split(/:/, $_);
 printf "Value:%010\n", $value;
 $valueCount++;
   }
}
close LOG;
print "Found a total of $valueCount values in $lineCount lines\n";


__END__

-Tom Kinzer

-Original Message-
From: danield [mailto:[EMAIL PROTECTED]
Sent: Sunday, December 07, 2003 8:43 PM
To: [EMAIL PROTECTED]
Subject: Reading from a log - still a problem


Hello all,

I have received a solution for my problem (reading from log) from Tom
Kinzer. The code is:

#!/usr/bin/perl -w
use strict;
my $log_file = "/appl/log/4e4d/20031130.txt";
open LOG, "< $log_file" or die "Could not open file $!";
while (  ) {
  chomp;
  if ( /^GTotal Content:/ ) {
  my ($gtotal_content, $value) = split(/:/, $_);
  print $value;
  }
}
close LOG;

The problem is this code returns no value. When I remove all preceding
lines from the log (20031130.txt) and keep there only that GTotal
Content: 14,741,322, I will get desired result (14,741,322)

What may be a solution for this?

Thank you for your time.

danield




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



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




RE: How to process multi-line records ?

2003-12-07 Thread Tom Kinzer
array or two should do the trick.  depends on what you want to check in your
conditionals.

are the number of lines per data "element" static or dynamic?

to separate the logic between, collecting the data and the records
conditionals, just separate into 2 loops.


LOGIC code only:

while (  )

   until ( blankLine )
  push into @thisChunk
   if ( criteria )
  spit @thisChunk to fileA
   else
  spit @thisChunk to fileB
}

Kinda like that?

Post some code and/or more specific requirements and I'm sure we can help.
This is the beginner list so don't be shy.

-Tom Kinzer


-Original Message-
From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED]
Sent: Sunday, December 07, 2003 6:35 PM
To: [EMAIL PROTECTED]
Subject: How to process multi-line records ?


Hi all:

This newbie is back looking for some hints on how to handle this problem
in processing a file that has multiline records that look something like
this:

Name:  Joe Blow
DataField1:  x
DateField1: 07/07/77
DataField2: x
DateField2: 12/07/03

Name:  Fi Doe
DataField1:  x
DateField1: 08/08/88
DataField2: x
DateField2: 12/12/03

etc.

There is an empty line that separates each record.   I need to extract the
records that meet certain criteria.   I would really like to know how to
do this in Perl.
(For a simple task like this, in the past, I would just import these
records into a database and write a query to extract the records that I
wanted.)

I've actually thought a lot about the problem, but I haven't done any perl
coding that would allow me to put my woeful perl ineptitude on public
display in this forum.   I hope to find the time to start on this problem
in the next couple of days.  As I'm certain to run into problems, I will
then share my ineptitude while looking for proper guidance from the valued
learned ones.

Until then, here's what I was thinking to do.  What I thought I would do
is try to read each line of one record into an array or hash, then use a
conditional to determine if that record meets the desired criteria.  If it
meets the criteria, write out this record to another  file and then read
in the next record.  If the record doesn't meet the criteria, read in the
next  record.  I would keep doing this until EOF.

I think I can handle the conditional stuff, but what I don't know how to
do is read in each line of the record and stop reading when I hit the
empty line so that I can do the conditional stuff.

Is this a valid approach to take for this problem?  And if so, should I
use an array or hash ?   And again, how do I stop reading the input file
when I hit the empty line so that I can do the conditional stuff ?

Thanks in advance for any help and/or hints.  The feedback from my last
question was extremely helpful as I struggle to get Perl to do what I want
it to do. I think I'm making progress, although it doesn't always feel
that way !

- Stuart


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




RE: [OT] Education Level

2003-12-07 Thread Tom Kinzer
High school.  Been performing (well) in jobs "requiring" a masters degree
for the last 4 or 5 years.  Never had anyone balk at the lack of papers,
perhaps due to the fact that i have a stable professional experience record
with large corporations.

Like others, I've worked with people from GEDs to PHDs and found almost no
correlation between education level and skill when performing in a team
development environment.

Another factor is how dated is the education.  Who cares if I know PASCAL?
Nobody!  Does somebody who has a CS degree from 15 years ago know about
iterative, agile development methodologies?  Not from going to school,
that's for sure.

What have you been doing for the last 4 years?  That's what people care
about.

-Tom Kinzer

-Original Message-
From: Charles K. Clarkson [mailto:[EMAIL PROTECTED]
Sent: Sunday, December 07, 2003 9:34 AM
To: [EMAIL PROTECTED]
Subject: [OT] Education Level


Hello,

A recent job posting has left me curious. I would never
take a full time job as a programmer or as anything else for
that matter. I just don't make a good employee any more.
Been there. Done that.

The job posting demanded a college degree. I had one
semester of college 20 years ago and normally classify
myself as "finished high school". I'm curious: What level of
education have list members attained?


TEA,

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]
<http://learn.perl.org/> <http://learn.perl.org/first-response>



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




RE: Reading from log

2003-12-06 Thread Tom Kinzer
Typically I'm against just doing something for somebody, but you caught me
at a good time.

Here is an example to get you started:

#!/usr/local/bin/perl -w
use strict;

my $input  = shift;
my $total;
die "Usage: Arg1: Input File to Scan."
unless $input;

open IN, "< $input" or die "Unable to open $input for reading, $!, stopped";

while ( defined() ) {
while (  ) {
if ( /Total:/ ) { last };
}

while (  ) {
if ( /^\s*\d+/ ) {
chomp;
   s/\s*(\d+)\s*/$1/;
   $total = $_;
   printf "Total: %010s", $total;
}
}
}


close IN;


-Original Message-
From: danield [mailto:[EMAIL PROTECTED]
Sent: Friday, December 05, 2003 9:49 PM
To: [EMAIL PROTECTED]
Subject: Reading from log


Hello all,

I am looking for help with creating a digest of a log file. I have found
a nice tutorial that should help on
http://www.pageresource.com/cgirec/ptut14.htm. However, this tutorial
expects to have values in list separated by |   :

he Rock|Cheer|Rock Bottom
Triple H|Boo|Pedigree
Stone Cold|Cheer|Stone Cold Stunner

And I do have a log file, that looks like:

...
Format  count
a   100
b51
c   130
d 5
e 6
Total:  ---
292
...

And I need to go through that log and find that 292 and store it into
variable.
If it was something like 'total: 292', I might be able to do it, however the
value
is on completely new line and nothing precedes it.

Is anyone willing to help me?

I am a completely newbie in programming.

Thank you for your time.

danield


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

2003-12-05 Thread Tom Kinzer
To just use it for STDOUT, it's pretty straight forward, switching the
special $~ variable as needed.

You're switching FORMATs not filehandles.  There may be a shortcut but this
is how I would do it for this problem:

-Tom Kinzer

_

format TYPE_1 =
Im formated with type1: @<<<<<<<<<  @||
$field1, $field2
.

format TYPE_2 =
IM FORMATTED WITH TYPE2: @<<<<<<<<  @<<<<<<<<<<<<<<<<<<<<<<<<
$field1, $field2
.

open RECORDS, "< YourInput.log" or die;

while () {

   ($field1, $field2)  = split;

   if ( m/YourPatternRegExHere/ ) {

   $~ = 'TYPE_1';

   } else {

   $~ = 'TYPE_2';

   }

   write;

}
close RECORDS;

__END__

-Original Message-
From: Jose Malacara [mailto:[EMAIL PROTECTED]
Sent: Friday, December 05, 2003 6:40 PM
To: [EMAIL PROTECTED]
Subject: formats


Is it possible to use more than one format in a script? I am parsing a log
file to STDOUT and would like to be able to write to two (or more) different
formats depending on the information found in the log.

This is what I'm trying to do:

1. open and read logfile
2. if you find "some_string" print to STDOUT using TYPE_1 format
3. if you find "other_string" print to STDOUT using TYPE_2 format
5. continue parsing logfile, etc

I can open and parse the logfile, my script breaks whenever I try to call
more than one type of format. This doesn't seem to work for me, is this even
possible?


format TYPE_1 =
Type: @<<<<<<<<<<  Gateway: @<<<<<<<<<  Acct ID: @<<<<<<<<<<<<<<<<<<
$record_type,$gateway,$acct_id
Start Date: @<<<<<<<<<<  Start Time: @<<<<<<<<<
$start_date,$start_time
.
write TYPE_1;

format TYPE_2 =
Type: @<<<<<<<<<<  Gateway: @<<<<<<<<<  Acct ID: @<<<<<<<<<<<<<<<<<<
$record_type,$gateway,$acct_id
Start Date: @<<<<<<<<<<  Start Time: @<<<<<<<<<
$start_date,$start_time
Disconnect Date: @<<<<<<<<<<  Disconnect Time: @<<<<<<<<<
$disco_date,$disco_time
.
write TYPE_2;


Also, how would I go about keeping the filehandles open as it would be
repetively "writing" each format.


Thank you,
Jose


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




RE: Replacing text

2003-12-05 Thread Tom Kinzer
Good news, Dan.

That is arguably one of Perl's most famous features!

Regular expresions (Perl's own) are very similar to what you would do with
sed, if you are familiar with that.

open IN,  "< $input"  or die "Unable to open $input for reading, $!,
stopped";
open OUT, "> $output" or die "Unable to open $output for writing, $!,
stopped";

print "Munging $input, creating new file $output.\n";


while (  ) {
s/oldtext/newtext/g;  # substitute (replace) oldtext with newtext,
  # g means globally if happens more than once on a
line.
print OUT;
}

close IN;
close OUT;

print "Munge complete.\n";

-Original Message-
From: [EMAIL PROTECTED]
[mailto:[EMAIL PROTECTED] Behalf Of Dan Anderson
Sent: Friday, December 05, 2003 3:11 PM
To: [EMAIL PROTECTED]
Subject: Replacing text



I have a  script that reads text from a  file and inserts text
into different  places depending on  what it needs  to do.  But  I use
split to replace the text, i.e.:

($first_part, $second_part) = split "#INSERT#TEXT#HERE#", $document, 2;
print FILEHANDLE $firstpart, $text_to_insert, $secondpart;

Is  there a  replace function  in perl  that would  let  me do
something like  replace "#INSERT#TEXT#HERE", $text_to_insert;?   I was
going to  write my own  method but was  curious if perl  had something
faster?

Thanks in advance,

-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: remove control chars

2003-12-04 Thread Tom Kinzer
Hah! I'm unemployed right now, so how about a contract?!?  ;)

--Tom Kinzer
--Perl Gun for Hire--

-Original Message-
From: Rob Dixon [mailto:[EMAIL PROTECTED]
Sent: Thursday, December 04, 2003 8:56 AM
To: [EMAIL PROTECTED]
Subject: Re: remove control chars


James Kipp wrote:
>
> I have some C code that I need to convert to perl
> and I am pressed for time, which is why I am posting this.

Erm. Sorry to spoil the party an' all, but the answer
is surely to go to your management and say that you need
extra time? Many homework questions to the group have been
trounced. Surely it is worse to freely support someone
else's paid employment?

I'll happily back down here if nobody agrees, but surely..?

Rob



-- 
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: Beta Testing a Robot

2003-12-04 Thread Tom Kinzer
I also admire the effort and the good intentions, but,

 I think most Perl programmers can handle a Google search, and the bot
just creates unnecessary traffic on the list.  At a minimum, it should only
send to the original poster, not the whole list. 

my $2Cents;

-Tom Kinzer


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



RE: Timing several processes

2003-12-03 Thread Tom Kinzer
Correct.  You could spawn 5 and then do 5 waits.  Assuming you want to do
nothing until all 5 finish.

But:  Do you actually want to do a timer for those 5 processes, run for a
certain amount of time and then have them stop??  Then check to make sure
all 5 are done, then do some other stuff (reporting)??

The code below spawns a process but instead of waiting like it would for a
system call, it says I'm gonna keep on trucking -- course it doesn't do
anything except go straight to a wait in this example, but in theory, the
"main" could be doing other stuff at the same time.

Of course, all this has very little to do with terminating a child at a
certain time...

-Tom Kinzer


-Original Message-
From: Akens, Anthony [mailto:[EMAIL PROTECTED]
Sent: Wednesday, December 03, 2003 10:07 AM
To: Akens, Anthony; Tom Kinzer; [EMAIL PROTECTED]
Subject: RE: Timing several processes


To clarify, I found the following in "Learning Perl".

It doesn't quite make sense to me, though.  Perhaps someone
Can clarify what's going on in this?

defined(my $pid = fork) or die "Cannot fork: $!";
unless ($pid) {
  # Child process is here
  exec "date";
  die "cannot exec date: $!";
}
# Parent process is here
waitpid($pid, 0);


It seems I could use that code, modified to start (5) processes,
And a waitpid() for each of those (5).  It doesn't matter
Which processes would finish first.  (I put the 5 in quotes,
Because right now I'm looking at using 5 different tools that
I want to monitor).

-Tony



-Original Message-
From: Akens, Anthony
Sent: Wednesday, December 03, 2003 12:58 PM
To: Tom Kinzer; [EMAIL PROTECTED]
Subject: RE: Timing several processes


I already have some ideas for how I want to build the page, how
to parse the data I will generate, etc.

As I said, I've looked at some of the other tools out there,
and want to stick to some simple perl code to parse out the
information and return the results.

The only bit I'm not sure of is how to tell if all forked processes
have completed before moving on.


-Tony

-Original Message-
From: Tom Kinzer [mailto:[EMAIL PROTECTED]
Sent: Wednesday, December 03, 2003 12:35 PM
To: [EMAIL PROTECTED]
Subject: RE: Timing several processes


 http://poe.perl.org

Maybe this would be a good job for POE?

-Tom Kinzer


-Original Message-
From: Akens, Anthony [mailto:[EMAIL PROTECTED]
Sent: Wednesday, December 03, 2003 7:49 AM
To: [EMAIL PROTECTED]
Subject: Timing several processes


Hi all!

I'm wanting to write a simple web-based tool to see the status of
several servers at a glance.  I know there are many solutions existing,
but I can't learn as much about perl by just using one
of those as I can by writing my own.  The first step I want to do
is call a script from cron that runs several basic monitoring tools
(sar, vmstat, df, iostat, etc) and saves the output of each to a
file. Then I'd parse those files up, and write a summary file.

Easy enough.  And I could certainly do it with by calling the tools one
at a time.  However, I'd like to get roughly 1 minute of vmstat,
iostat, and sar output Simultaneously.  So I'm supposing I'd
want to fork off each process, and then when those are all done
come back and run a script that then parses those results out for
the individual statistics I'm looking for.

I've never used fork before, and while it looks fairly straight forward
what I am not sure of is how to make sure all of those forked
processes have completed before moving on and parsing the files.

Any pointers?

Thanks in advance

-Tony

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


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


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



RE: Timing several processes

2003-12-03 Thread Tom Kinzer
Right.  POE may be a good tool for handling those children processes.
(Instead of forking at all.)

 -Tom Kinzer

-Original Message-
From: Akens, Anthony [mailto:[EMAIL PROTECTED]
Sent: Wednesday, December 03, 2003 9:58 AM
To: Tom Kinzer; [EMAIL PROTECTED]
Subject: RE: Timing several processes


I already have some ideas for how I want to build the page, how
to parse the data I will generate, etc.

As I said, I've looked at some of the other tools out there,
and want to stick to some simple perl code to parse out the
information and return the results.

The only bit I'm not sure of is how to tell if all forked processes
have completed before moving on.


-Tony

-Original Message-----
From: Tom Kinzer [mailto:[EMAIL PROTECTED]
Sent: Wednesday, December 03, 2003 12:35 PM
To: [EMAIL PROTECTED]
Subject: RE: Timing several processes


 http://poe.perl.org

Maybe this would be a good job for POE?

-Tom Kinzer


-Original Message-
From: Akens, Anthony [mailto:[EMAIL PROTECTED]
Sent: Wednesday, December 03, 2003 7:49 AM
To: [EMAIL PROTECTED]
Subject: Timing several processes


Hi all!

I'm wanting to write a simple web-based tool to see the status of
several servers at a glance.  I know there are many solutions existing,
but I can't learn as much about perl by just using one
of those as I can by writing my own.  The first step I want to do
is call a script from cron that runs several basic monitoring tools
(sar, vmstat, df, iostat, etc) and saves the output of each to a
file. Then I'd parse those files up, and write a summary file.

Easy enough.  And I could certainly do it with by calling the tools one
at a time.  However, I'd like to get roughly 1 minute of vmstat,
iostat, and sar output Simultaneously.  So I'm supposing I'd
want to fork off each process, and then when those are all done
come back and run a script that then parses those results out for
the individual statistics I'm looking for.

I've never used fork before, and while it looks fairly straight forward
what I am not sure of is how to make sure all of those forked
processes have completed before moving on and parsing the files.

Any pointers?

Thanks in advance

-Tony

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


--
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: Timing several processes

2003-12-03 Thread Tom Kinzer
 http://poe.perl.org 

Maybe this would be a good job for POE?

-Tom Kinzer


-Original Message-
From: Akens, Anthony [mailto:[EMAIL PROTECTED]
Sent: Wednesday, December 03, 2003 7:49 AM
To: [EMAIL PROTECTED]
Subject: Timing several processes


Hi all!

I'm wanting to write a simple web-based tool to see the status
of several servers at a glance.  I know there are many solutions
existing, but I can't learn as much about perl by just using one 
of those as I can by writing my own.  The first step I want to do 
is call a script from cron that runs several basic monitoring tools 
(sar, vmstat, df, iostat, etc) and saves the output of each to a 
file. Then I'd parse those files up, and write a summary file.

Easy enough.  And I could certainly do it with by calling the tools
one at a time.  However, I'd like to get roughly 1 minute of vmstat, 
iostat, and sar output Simultaneously.  So I'm supposing I'd 
want to fork off each process, and then when those are all done 
come back and run a script that then parses those results out for 
the individual statistics I'm looking for.

I've never used fork before, and while it looks fairly straight
forward what I am not sure of is how to make sure all of those forked 
processes have completed before moving on and parsing the files.

Any pointers?

Thanks in advance

-Tony

-- 
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: Reading files

2003-12-02 Thread Tom Kinzer
OK, but how about:

1)where is $LOG being set?
2)does it get past the dies shown below?
3)got strict?  it's 'fer your own good, you know! ;)

-Tom Kinzer



#!/usr/bin/perl -w

$file="./text";
$|=1;
use Fcntl;
use IO::Handle;

$D_LOG = $ENV{MHCONTEXTFD};

open($LOG, "< logfile") or die "Unable to open 1st handle, stopped";
open($D_LOG, "<& LOG")  or die "Unable to open 2nd handle, stopped";
$LOG->autoflush(1);
$D_LOG->autoflush(1);

$line1=<$LOG>;
$line2=<$D_LOG>;

print "1:$line1 2:$line2";

-Original Message-
From: Mark Goland [mailto:[EMAIL PROTECTED]
Sent: Tuesday, December 02, 2003 7:40 PM
To: [EMAIL PROTECTED]
Subject: Re: Reading files


Sorry for not being more clear. The problem is that it doesnt seem to be
able to read of the duped handle { $line2 is empty on }.

- Original Message - 
From: "Tom Kinzer" <[EMAIL PROTECTED]>
To: <[EMAIL PROTECTED]>
Sent: Tuesday, December 02, 2003 4:15 PM
Subject: RE: Reading files


> I don't see $LOG being set...strict would catch that.
>
> -Tom Kinzer
>
>
>
> > Hello All,
> > I am trying to open a file once , and then duplicate it's
> > File Handle. I am trying to workout example straight from
> > FAQ5, with no luck. I will basicly trying to open a file, dup
> > off a few handles and spread them across other processes.
> > Here is the code
> >
>
> Try use strict; and use warnings;(or -w) right off and see what it tells.
> What exatcly is happening that you think shouldn't?
> I guess I didn't see a question?
>
>
> > #!/usr/bin/perl -w
> >
> > $file="./text";
> > $|=1;
> > use Fcntl;
> > use IO::Handle;
> >
> > $D_LOG = $ENV{MHCONTEXTFD};
> >
> > open($LOG, "< logfile");
> > open($D_LOG, "<& LOG");
> > $LOG->autoflush(1);
> > $D_LOG->autoflush(1);
> >
> > $line1=<$LOG>;
> > $line2=<$D_LOG>;
> >
> > print "1:$line1 2:$line2";
> >
> > Thanks in Advance,
> > Mark G.
>
>
> -- 
> 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]


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



RE: Reading files

2003-12-02 Thread Tom Kinzer
I don't see $LOG being set...strict would catch that.

-Tom Kinzer



> Hello All,
> I am trying to open a file once , and then duplicate it's 
> File Handle. I am trying to workout example straight from 
> FAQ5, with no luck. I will basicly trying to open a file, dup 
> off a few handles and spread them across other processes. 
> Here is the code
> 

Try use strict; and use warnings;(or -w) right off and see what it tells.
What exatcly is happening that you think shouldn't?
I guess I didn't see a question?


> #!/usr/bin/perl -w
> 
> $file="./text";
> $|=1;
> use Fcntl;
> use IO::Handle;
> 
> $D_LOG = $ENV{MHCONTEXTFD};
> 
> open($LOG, "< logfile");
> open($D_LOG, "<& LOG");
> $LOG->autoflush(1);
> $D_LOG->autoflush(1);
> 
> $line1=<$LOG>;
> $line2=<$D_LOG>;
> 
> print "1:$line1 2:$line2";
> 
> Thanks in Advance,
> Mark G.


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



RE: Reading files

2003-12-02 Thread Tom Kinzer
start off by putting some "or die"s on those file opens.

where are you breaking or what is the error message?

not sure what the problem is exactly.

-Tom Kinzer


-Original Message-
From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED]
Sent: Tuesday, December 02, 2003 9:53 AM
To: [EMAIL PROTECTED]
Subject: Reading files


Hello All,
I am trying to open a file once , and then duplicate it's File Handle. I am
trying to workout example straight from FAQ5, with no luck. I will basicly
trying to open a file, dup off a few handles and spread them across other
processes. Here is the code

#!/usr/bin/perl -w

$file="./text";
$|=1;
use Fcntl;
use IO::Handle;

$D_LOG = $ENV{MHCONTEXTFD};

open($LOG, "< logfile");
open($D_LOG, "<& LOG");
$LOG->autoflush(1);
$D_LOG->autoflush(1);

$line1=<$LOG>;
$line2=<$D_LOG>;

print "1:$line1 2:$line2";

Thanks in Advance,
Mark G.


--
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: search and replace using regex

2003-12-02 Thread Tom Kinzer
You may want to start looking at some XML parsing modules, but assuming this
is a quickie, I can point out that your problem is starting with the use of
forward slash.

Remember: your forward slash is your separator for the regular exp.

Try replacing it with something else like | or % and go from there - You can
do it!

Like this:
s| _\mailto:[EMAIL PROTECTED]
Sent: Wednesday, December 03, 2003 12:26 PM
To: [EMAIL PROTECTED]
Subject: search and replace using regex


I have trouble executing a search and replace through all files in a certain
directory.

I want to replace " _A_Z.new") || die "Couldn't open file.new
for writing!\n";
while(){
$_ =~ s/"_\
}

The docs don't answer all my questions. Any help will be highly appreciated.
I wish there was an absolute-beginners list...

Saskia

--
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: breaking lines with perl

2003-12-02 Thread Tom Kinzer
QA checks out, it does work with the data supplied.  (Naivete will have to
checked with the real data.)

You could add some nice indent formatting if you like by adding a tab to
Jame's expression:

s/\),\s*/),\n\t/



-Tom Kinzer



-Original Message-
From: James Edward Gray II [mailto:[EMAIL PROTECTED]
Sent: Tuesday, December 02, 2003 8:52 AM
To: David T-G
Cc: '[EMAIL PROTECTED]' List
Subject: Re: breaking lines with perl


On Dec 2, 2003, at 10:44 AM, David T-G wrote:

> Hi, all --
>
> I have some database sql dumps that look like
>
>   insert into table (f1,f2,f3) values (v1a,v2a,v3a),(v1b,v2b,v3b),...
>
> where of course the insert lines are whopping long.  I would like to
> break these lines at the commas like
>
>   insert into table (f1,f2,f3) values (v1a,v2a,v3a),
>   (v1b,v2b,v3b),
>   ...
>
> (and in fact split after 'values ' but that will just be an exercise on
> the first solution) but can't figure out how to spit out the newline.
> This *should* be a quick oneliner like
>
>   cat file | perl -ew ' ... ' > file.mod
>
> but I just can't get it :-)

Try:

perl -pe 's/\),\s*/),\n/' old_file.txt > file.mod

It's pretty naive, but I may get lucky.  ;)

James


--
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: Config file

2003-12-02 Thread Tom Kinzer
I've used Config::IniFiles before and it works very nice, especially nice if
you do a tie into a hash for all your values.

http://search.cpan.org/~wadg/Config-IniFiles-2.38/IniFiles.pm

-Tom Kinzer




-Original Message-
From: Rod [mailto:[EMAIL PROTECTED]
Sent: Tuesday, December 02, 2003 7:55 AM
To: beginners
Subject: Config file


What is the best way to read a config file for a perl script.  I have
some very ugly code that can do it, but I would like to find something
cleaner.

Thanks,
Rod.



--
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: Encrypting PERL source code...

2003-12-01 Thread Tom Kinzer
even better, check out PAR:

http://search.cpan.org/~autrijus/PAR/


-Tom Kinzer


-Original Message-
From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED]
Sent: Monday, December 01, 2003 10:40 AM
To: [EMAIL PROTECTED]
Subject: Encrypting PERL source code...



Can anyone suggest where I might be able to find (hopefully a freeware
or shareware script..) a program that runs either on a windows system or
a PERL script that would "encrypt" a perl script by doing such things as
removing whitespace, etc. so that it is much more difficult to read but
yet will execute as if "unencrypted"?? I'd like to make the source code
as difficult to pirate as I can for a program that I'm developing.
Thanks!

Portions of this message may be confidential under an exemption to Ohio's
public records law or under a legal privilege. If you have received this
message in error or due to an unauthorized transmission or interception,
please delete all copies from your system without disclosing, copying, or
transmitting this message.


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



RE: OFF TOPIC: Unix in a Nutshell Orielly 3rd edition

2003-11-28 Thread Tom Kinzer
check out the O'Reilly Unix Bookshelf, you get a "in a nutshell" hard copy
and 6 books in HTML on a cd.  Makes a really great quick reference.  I have
the Perl and Linux/Webserver bookshelves as well.  You can carry ~18 books
around with you in your laptop case!

-Tom Kinzer
714.404.9362

-Original Message-
From: Paul Kraus [mailto:[EMAIL PROTECTED]
Sent: Friday, November 28, 2003 11:01 AM
To: [EMAIL PROTECTED]
Subject: OFF TOPIC: Unix in a Nutshell Orielly 3rd edition


I need to beef up on my UNIX skills. Are major server is running Sco
Open server.

Will this book benefit me or is there another I should look at.

Not on topic and I apologize but beyond perl the list seems to have many
UNIX enthusiasts.

Paul


--
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: Sockets and Daemonizing - was Re: Count the no of times a script is called

2003-11-27 Thread Tom Kinzer
Not sure, I'm not an admin by trade, but I was actually referring to the
fact that some admins assume that user Perl processes that don't die, are
doing so unintentionally.

I'm sure there may also be security issues with the user/socket coding as
well.

---------
-Tom Kinzer
 Long Beach, California

-Original Message-
From: drieux [mailto:[EMAIL PROTECTED]
Sent: Wednesday, November 26, 2003 2:12 PM
To: begin begin
Subject: Sockets and Daemonizing - was Re: Count the no of times a
script is called



On Wednesday, Nov 26, 2003, at 13:28 US/Pacific, Tom Kinzer wrote:
> drieux suggests:
>
>> The alternative of course would be to have
>> the 'perl code' start up as a daemon that
>> handled requests on a socket, this way you
>> would save the 'start up' overhead of
>> invoking a new process each time through.
>
> Make sure your sys admin is OK with this one.

Good Point!

p0: My UberGeek just smacked me upside the head
that Fortran does not have a native Socket Library
and that the standard trick would be to compile
up some c code, a la
<http://people.web.psi.ch/rohrer_u/sample2.htm>

p1: You will forgive the bad habits of system
programming, where 'hey kids, why not just spin
up a daemon that will dish up services on a socket...'
is just a part of solving the overall throughput issues.

The idea had been to save on the overhead of repeated
compile, open counter file, update counter file, do
the required perl bit sequence each time the fortran
wanted to make a call to it.

p2: which are the specific issues worth underlining
that a sys admin would have with a 'mere user' doing
socket level coding?



ciao
drieux

---


--
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: Count the no of times a script is called

2003-11-26 Thread Tom Kinzer
drieux suggests:

>The alternative of course would be to have
>the 'perl code' start up as a daemon that
>handled requests on a socket, this way you
>would save the 'start up' overhead of
>invoking a new process each time through.


Make sure your sys admin is OK with this one.


-Tom Kinzer
 Long Beach, CA


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