Re: Home made mail news search tool, and folded header lines

2004-03-27 Thread Smoot Carl-Mitchell
velope information. So it is easy to generate a technically illegal message. Also note that any header can be folded, although it is typically only the Received: headers which are routinely wrapped for readability. As usual when writing code against a protocol standard, be liberal in what you will accep

Re: Home made mail news search tool, and folded header lines

2004-03-27 Thread Smoot Carl-Mitchell
} Write get_mail_header to return the next valid header or undef at the end of the headers. -- Smoot Carl-Mitchell Systems/Network Architect email: [EMAIL PROTECTED] cell: +1 602 421 9005 home: +1 480 922 7313 -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail:

Re: How to determine if STDIN has piped data?

2004-03-28 Thread Smoot Carl-Mitchell
; { > print $_ . "\n"; > } You can use the POSIX module's isatty function. Something like: use POSIX qw(isatty); exit 0 if isatty(STDIN); If STDIN is not a tty then it must be a pipe. Alternatively, you can use the '-t' operator: exit 0 if -t STDIN -- S

Re: string change problem

2004-03-29 Thread Smoot Carl-Mitchell
something like: $name =~ s/\d+.*//; which matches one or more digit characters followed by anything. See the perlre man page for details on Perl regular expressions. -- Smoot Carl-Mitchell Systems/Network Architect email: [EMAIL PROTECTED] cell: +1 602 421 9005 home: +1 480 922 7313 -- To uns

Re: How to determine if STDIN has piped data?

2004-03-29 Thread Smoot Carl-Mitchell
my simple Perl tools with the following paradigm: process any flags here while (<>) { do something with the input } The magical <> operator is very handy. -- Smoot Carl-Mitchell Systems/Network Architect email: [EMAIL PROTECTED] cell: +1 602 421 9005 home: +1 480 922 7313

Re: string change problem

2004-03-29 Thread Smoot Carl-Mitchell
On Mon, 29 Mar 2004 12:14:49 -0600 James Edward Gray II <[EMAIL PROTECTED]> wrote: > On Mar 29, 2004, at 11:02 AM, Smoot Carl-Mitchell wrote: > > > On Mon, 29 Mar 2004 15:05:34 +0530 > > "MuthuKumar" <[EMAIL PROTECTED]> wrote: > > > >>

Re: Incrementing count

2004-03-29 Thread Smoot Carl-Mitchell
unter. % is the modulo operator. See perlvar for the details on $. and perlop for the modulo operator. -- Smoot Carl-Mitchell Systems/Network Architect email: [EMAIL PROTECTED] cell: +1 602 421 9005 home: +1 480 922 7313 -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] <http://learn.perl.org/> <http://learn.perl.org/first-response>

Re: problem with fork & wait

2004-03-29 Thread Smoot Carl-Mitchell
$pid1=wait; > } The above works, but it is equivalent to: system("XYZ -a $check"); You should check the return value of system. A non-zero value means the forked program returned a non-zero exit status which depending on what you do with the output may or may not be an error. -- Smoo

Re: determing number of records returned with DBI

2004-03-30 Thread Smoot Carl-Mitchell
rds) { > ... > } $#records returns the index of the last element in the array. @records in scalar context returns the number of elements in the array. With array indices starting at zero, #$records + 1 == @records. -- Smoot Carl-Mitchell Systems/Network Architect email: [EMAIL PR

Re: How to determine if STDIN has piped data?

2004-03-31 Thread Smoot Carl-Mitchell
stead of reading or writing from a file, the program reads or writes a socket which is typically connected to another program via a network protocol which is either local or remote. See perldoc -f socket. -- Smoot Carl-Mitchell Systems/Network Architect email: [EMAIL PROTECTED] cell: +1 602 421

Re: Matching ranges of IP addresses

2004-03-31 Thread Smoot Carl-Mitchell
nvert the dotted decimal representation of each IP address to a number and do a direct numeric comparison. You might also take a look at the CPAN module Net::IP::Match. It looks like it does what you want to do unless you really want to code up your own solution from scratch. -- Smoot Carl-Mitchel

Re: Check if another script running

2004-04-01 Thread Smoot Carl-Mitchell
king routine which explains how to use flock to grant exclusive access to a file. -- Smoot Carl-Mitchell Systems/Network Architect email: [EMAIL PROTECTED] cell: +1 602 421 9005 home: +1 480 922 7313 -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAI

Re: Is this possible? (file handles)

2004-04-01 Thread Smoot Carl-Mitchell
ter opening it. The directory entry for the file is deallocated, but the file is still open. When the file is closed, the disk allocation for the file is reclaimed. This is a handy method for creating temporary files that you want to be sure get deallocatted when the program using the temporary f

Re: loop using backticks stalls after ~30x

2004-04-02 Thread Smoot Carl-Mitchell
copy of itself and is waiting for input or waiting to send output to the terminal or has been stopped. That is what the 'T' means in the ps listing. Are you sure you are executing /bin/ls and not some other ls program in your PATH? Try doing an strace on the stopped process and see wh

Re: Using $_ in a function if no argument is passed

2004-04-02 Thread Smoot Carl-Mitchell
ther the given argument > or $_ how would you do that? $_ is global, so do something like: sub test { my $arg; $arg = shift or $arg = $_; } -- Smoot Carl-Mitchell Systems/Network Architect email: [EMAIL PROTECTED] cell: +1 602 421 9005 home: +1 480 922 7313 -- To unsubs

Re: HOT: Search/Replace || and *|

2004-04-02 Thread Smoot Carl-Mitchell
$line =~ s/\*|/|/mg; > print NEWFILE "$line\n"; > } > close OLDFILE; > close NEWFILE; > > print "$newfile has now been created\n"; > } > > > -- > To unsubscribe, e-mail: [EMAIL PROTECTED

Re: Using $_ in a function if no argument is passed

2004-04-03 Thread Smoot Carl-Mitchell
On 3 Apr 2004 14:40:43 - [EMAIL PROTECTED] (Peter Scott) wrote: > In article <[EMAIL PROTECTED]>, > [EMAIL PROTECTED] (Smoot Carl-Mitchell) writes: > >On Fri, 02 Apr 2004 10:37:14 -0600 > >"JupiterHost.Net" <[EMAIL PROTECTED]> wrote: > > > &

Re: Using $_ in a function if no argument is passed

2004-04-03 Thread Smoot Carl-Mitchell
On Sat, 3 Apr 2004 11:04:35 -0600 "Charles K. Clarkson" <[EMAIL PROTECTED]> wrote: > Smoot Carl-Mitchell <[EMAIL PROTECTED]> wrote: > : > >sub test { > : > > > : > > my $arg; > : > > $arg = shift or $arg = $_; > : > >

Re: Using $_ in a function if no argument is passed

2004-04-03 Thread Smoot Carl-Mitchell
er in my original response, since I had never done such a thing in my own Perl coding and I was curious enough to come up with what turned out to be a buggy solution. Live and learn. -- Smoot Carl-Mitchell Systems/Network Architect email: [EMAIL PROTECTED] cell: +1 602 421 9005 home: +1

Re: tracking mail logs

2004-04-05 Thread Smoot Carl-Mitchell
ntly has no copyright at all. If there is interest, I will do the work to GPL it and put it up on my FTP site. -- Smoot Carl-Mitchell Systems/Network Architect email: [EMAIL PROTECTED] cell: +1 602 421 9005 home: +1 480 922 7313 -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional comma

Re: Perl/TK

2004-04-07 Thread Smoot Carl-Mitchell
st > with perldoc.com) and check out the FAQs > (http://www.lns.cornell.edu/~pvhp/ptk/ptkFAQ.html) and go from there. I concur with this assessment. Also the Perl/Tk module comes with some example programs which are also very useful learning tools. -- Smoot Carl-Mitchell Systems/Network A

Re: flock return value / bit wise or'd LOCK_NB

2004-04-07 Thread Smoot Carl-Mitchell
if($rc == 4) { warn "rats! Exclusive lock not granted, oh well..."; > } if(!$rc) { die "Could not get lock no how mr flock guy!"; } The return code with LOCK_NB is false if the file is locked by another process, true is you got the lock. $! holds the appropriate error message

Re: flock return value / bit wise or'd LOCK_NB

2004-04-07 Thread Smoot Carl-Mitchell
et = flock(ZZZ, LOCK_EX | LOCK_NB); print "$ret $!\n"; sleep 60; > Thanks for the info BTW I really appreciate it! :) No problem. -- Smoot Carl-Mitchell Systems/Network Architect email: [EMAIL PROTECTED] cell: +1 602 421 9005 home: +1 480 922 7313 -- To unsubscribe, e-mai

Re: Who is running my program?

2004-04-10 Thread Smoot Carl-Mitchell
On Sat, 10 Apr 2004 17:07:02 -0700 "Chance Ervin" <[EMAIL PROTECTED]> wrote: > Is there an easy way to check which user is running your scripts? See $< and $> in perlvar. -- Smoot Carl-Mitchell Systems/Network Architect email: [EMAIL PROTECTED] cell: +1 602 421 9

Re: Password Changer and rexec help

2004-04-21 Thread Smoot Carl-Mitchell
nctionality as expect, but is IMHO a bit more rational. BTW, expect is not written in Tcl. It uses Tcl syntax for flow control, but it is a separate language. The Unix version is written in C as is Tcl. -- Smoot Carl-Mitchell Systems/Network Architect email: [EMAIL PROTECTED] cell: +1 602 421

Re: Password Changer and rexec help

2004-04-22 Thread Smoot Carl-Mitchell
ss, since you do need the Tcl libraries to build the expect binary on Unix systems. I went thru that process around 1992 when I first discovered expect. -- Smoot Carl-Mitchell Systems/Network Architect email: [EMAIL PROTECTED] cell: +1 602 421 9005 home: +1 480 922 7313 -- To unsubscribe,

Re: Finding the current IP of my laptop

2004-04-22 Thread Smoot Carl-Mitchell
vided your laptop has a valid host to IP address translation available. On Unix typically either an entry in /etc/hosts or a DNS A record entry. Take a look at Net::Interface on CPAN. It appears to let you look at interface information in a system independent way. -- Smoot Carl-Mitchell Sy

Re: alias in the shell

2003-10-17 Thread Smoot Carl-Mitchell
Note the quoting gets really convoluted, since you have to worry about Perl's quoting conventions and two layers of shell quoting. Anything more complicated than this short example and I would go ahead and create a shell script and call it explicitly. Better, yet, write the shell functionality i

Re: alias in the shell

2003-10-18 Thread Smoot Carl-Mitchell
the quoting gets really convoluted > > No kidding... Sometimes the list form of system() makes this easier, > and non-interpolating quotes always help. > > system qw(ksh -c), 'TEST=hello; echo $test'; Good point. This does make it easier to read. In your example $test should

Re: serial console with perl

2003-10-22 Thread Smoot Carl-Mitchell
>error. Any ideas ?? Look at the Expect module. It gives you the ability to automate interactive tasks. -- Smoot Carl-Mitchell Systems/Networking Consultant email: [EMAIL PROTECTED] cell: +1 602 421 9005 home: +1 480 922 7313 -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additiona

Re: find and multiline delete

2008-07-04 Thread Smoot Carl-Mitchell
my $skip_count = 0; while (<>) { chomp; if (/^Foo$/) { $found_foo = 1; print "$_\n"; next; } if ($found_foo) { $skip_count++; next if $skip_count <= 2; }