[19169] in Perl-Users-Digest

home help back first fref pref prev next nref lref last post

Perl-Users Digest, Issue: 1364 Volume: 10

daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Tue Jul 24 06:05:44 2001

Date: Tue, 24 Jul 2001 03:05:16 -0700 (PDT)
From: Perl-Users Digest <Perl-Users-Request@ruby.OCE.ORST.EDU>
To: Perl-Users@ruby.OCE.ORST.EDU (Perl-Users Digest)
Message-Id: <995969116-v10-i1364@ruby.oce.orst.edu>
Content-Type: text

Perl-Users Digest           Tue, 24 Jul 2001     Volume: 10 Number: 1364

Today's topics:
    Re: Appanding to hash_key_value (Eric Bohlman)
    Re: Bad Return-Path when using Mail::Mailer nobull@mail.com
        CGI -> Apache Problem <Georg.Vassilopulos@SoftwareAG.de>
        CGI Uploads <darkbeast@darkbeast.com>
    Re: CGI Uploads (Eric Bohlman)
    Re: converting numeric-string to integer doesn't work f (Villy Kruse)
    Re: create files from a list & use join to add an exten <mbudash@sonic.net>
        encrypt a password <Patrick_member@newsguy.com>
    Re: Escaped period! Someone apprehend it! (Eric Bohlman)
    Re: Escaped period! Someone apprehend it! <rhavu@csc.fi>
        FAQ: How can I output Roman numerals? <faq@denver.pm.org>
        Generating elements based on input (samantha)
    Re: Generating elements based on input <tom.melly@ccl.com>
    Re: getting users ip <dbe@wgn.net>
    Re: getting users ip nobull@mail.com
    Re: How can I determine how many charcters to represnt  (Stan Brown)
    Re: How do I count the number of characters in a string <krahnj@acm.org>
        How to cause navigation to occur in same WebBrowser win <efi@enbaya.com>
    Re: How to redirect a user ? <cvule@eunet.yu>
    Re: How to redirect a user ? (el)
        how to sort by the Nth ip addr in string? <mdufault@dynamicservers.com>
    Re: how to sort by the Nth ip addr in string? <krahnj@acm.org>
    Re: Large Filesystem Scrubbers (Logan Shaw)
    Re: manpage styles/templates??? <pne-news-20010724@newton.digitalspace.net>
    Re: My actual problem ( was: Re: Printing results of a  <ren@tivoli.com>
        Need Perl User Login Source code <bill@antrix.com>
    Re: Need Perl User Login Source code <Tassilo.Parseval@post.rwth-aachen.de>
    Re: nested forks - help.... (Anno Siegel)
        Digest Administrivia (Last modified: 6 Apr 01) (Perl-Users-Digest Admin)

----------------------------------------------------------------------

Date: 24 Jul 2001 01:55:21 GMT
From: ebohlman@omsdev.com (Eric Bohlman)
Subject: Re: Appanding to hash_key_value
Message-Id: <9jiki9$bud$1@bob.news.rcn.net>

Nipa <npatel@webley.com> wrote:
> here is an example of my code:

> assume that all the variables are declared using 'my'.

> while($line = <LOG>)
> {
>    chomp($line);
>    ($key, $value) = split(/:/,$line, 2);
>     if(exists $form{$key}) { $form{$key} .= $value; }
>     else { $form{$key} = $value ;  }

This is unnecessarily complicated; you can skip the test altogether and 
just write $form{$key} .= $value; perl does the Right Thing here and 
creates a new, empty hash entry if you're trying to append to a 
non-existent one.

> }

> Here is the STRANGE action. the 'chomp($line)' in the first line over
> writes.
> HOWEVER, if I do this instead, it works:

> while($line = <LOG>)
> {
>    ($key, $value) = split(/:/,$line, 2);
>     if(exists $form{$key}) 
>     { 
>        $form{$key} .= $value; 
>        chomp($form{$key}); 
>     }
>     else { $form{$key} = $value ;  }
> }

> If I print the hash,(if above code is used to store values) , correct
> value prints. However values are printed in double spaced manner.
> something like this:

> key : value

> key: value

> key: value

> .....

> I know it does this because when i print i have put \n at the end of
> the print statement. BUT if i don't have the \n at the end it once
> prints the last key and value of the hash and ON TOP OF THAT it prints
> on the commadline.
> this is what i mean:
> -=> key: value    (# it shouldn't do that)

I'm starting to suspect that the line endings in your file are different 
from the default line endings for your platform, so chomp() is either 
chomping too much or not chomping enough.  The stuff getting printed on 
top of other stuff suggests that, after chomping, your lines still end 
with a \r, as might happen if you were running on a Unix system and 
reading a file that was created on a Windows system without having the 
line endings converted.



------------------------------

Date: 24 Jul 2001 08:52:42 +0100
From: nobull@mail.com
Subject: Re: Bad Return-Path when using Mail::Mailer
Message-Id: <u91yn6pwdi.fsf@wcl-l.bham.ac.uk>

Henri Sivonen <henris@clinet.fi> writes:

> I noticed that messages sent over SMTP with Mail::Mailer have a header 
> like this:
> Return-Path: <uid-that-runs-the-script@domain-without-computer-name>

Yes that stripping of the computer name always struck me as a poor idea.

Set $ENV{MAILADDRESS}

AFAIK this will not help if you are using Mail::Mailer in the
"sendmail" mode as Mail::Mailer::sendmail does not pass the -f switch
to sendmail.
 
> I tried adding a header called Return-Path explicitly, but it didn't 
> work. How can I put my real address in the Return-Path header? Where is 
> the header generated?

The Return-Path header is generated on the _receiving_ system.  It is a
copy of what was in the envelope-from of the received message.

-- 
     \\   ( )
  .  _\\__[oo
 .__/  \\ /\@
 .  l___\\
  # ll  l\\
 ###LL  LL\\


------------------------------

Date: Tue, 24 Jul 2001 11:01:38 +0200
From: "Georg Vassilopulos" <Georg.Vassilopulos@SoftwareAG.de>
Subject: CGI -> Apache Problem
Message-Id: <9jjdhl$b55$1@gamma.ecomp.net>

Hello People,

Hope this request is not too much "off topic".

I really freak out. Following situation:

On Win NT 4.0 I wrote my CGI scripts. I have to "port" it to Win NT 4.0
Server.
I use same Apache versions (SERVER_SOFTWARE="Apache/1.3.12 (Win32)
DAV/1.0.1")

Now in one script a system call is made. I want to run a zip programm if
someone uploads a "*.zip" file.

My code snippet:

my $command = "p:/tools/wni/unzip.exe $myFile";
system ($command) or print "Fuck the system command:$!";


Why does ist work under Win NT and not under Win NT Server?

Can I specify wrights in Apache what to execute and what not?

Where do I set permissions for executing programms in Apache?

My environment is the same. I checkt for the silly mistakes like path
variable, file permission.....





Have a good time!!!
Georg
georg.vassilopulos@softwareAG.com






------------------------------

Date: Mon, 23 Jul 2001 23:30:42 -0500
From: Static-Pulse <darkbeast@darkbeast.com>
Subject: CGI Uploads
Message-Id: <3B5CF9F2.1F2F5974@darkbeast.com>

Can anyone point me to sample code that demonstartes how to construct
a Perl/cgi script that handles data presented through the <input
type=file> html tag?  I'm looking through google/deja archives, but so
far I can oly find vague -- that might just be my not searching well
enoug.  Anywho, I would really appreciate an example of the
parser/file handler.  Thanks.

-- 
Static-Pulse | darkbeast at darkbeast dot com
   & Roxanne | www dot hypervac dot net slash
-------------+-------------------------------
 #!/usr/bin/perl makes all the pain go away!


------------------------------

Date: 24 Jul 2001 04:37:54 GMT
From: ebohlman@omsdev.com (Eric Bohlman)
Subject: Re: CGI Uploads
Message-Id: <9jiu32$20h$1@bob.news.rcn.net>

Static-Pulse <darkbeast@darkbeast.com> wrote:
> Can anyone point me to sample code that demonstartes how to construct
> a Perl/cgi script that handles data presented through the <input
> type=file> html tag?  I'm looking through google/deja archives, but so
> far I can oly find vague -- that might just be my not searching well
> enoug.  Anywho, I would really appreciate an example of the
> parser/file handler.  Thanks.

Read the section "Creating a file upload field" in the manual for CGI.pm.  
The examples of how to read the uploaded file are still applicable even if 
you don't use CGI's output methods to create the form.




------------------------------

Date: 24 Jul 2001 08:13:58 GMT
From: vek@pharmnl.ohout.pharmapartners.nl (Villy Kruse)
Subject: Re: converting numeric-string to integer doesn't work for me... help!
Message-Id: <slrn9lqbi5.d6a.vek@pharmnl.ohout.pharmapartners.nl>

On Mon, 23 Jul 2001 21:03:23 +0200,
    Samuel Kilchenmann <skilchen@swissonline.ch> wrote:


>
>2. If your numbers (and results) are guaranteed to be smaller than 2**53 
>   then you should not have problems doing integer arithmetic on them (Perl
>   will store numbers between 2**32 and 2**53 as "floating-point integers"
>   and there is enough precision to exactly represent a difference of 1
>   between two such numbers).
>


I'm even convinced it will store any number in floating point as soon
as you use it in an arithmetic context; unless you "use integer;".
Until then it will most likely be stored as a text string only.



Villy


------------------------------

Date: Tue, 24 Jul 2001 04:29:08 GMT
From: Michael Budash <mbudash@sonic.net>
Subject: Re: create files from a list & use join to add an extension
Message-Id: <mbudash-70FFE4.21291223072001@news.sonic.net>

In article <a15e3f18.0107231146.2a3b1949@posting.google.com>, 
cchambli@lycos.com (Casey Chambliss) wrote:

[snip]

> $ExcelFile = join($MasterProjectList[1], ".xls");

'join' does not do what it looks like you think it does... check your 
docs... put simply, it doesn't concatenate its args, it glues a list 
together; the first arg is the glue, the rest of the args make up the 
list...

hth-
-- 
Michael Budash ~~~~~~~~~~ mbudash@sonic.net


------------------------------

Date: 23 Jul 2001 23:27:25 -0700
From: Patrick Flaherty <Patrick_member@newsguy.com>
Subject: encrypt a password
Message-Id: <9jj4gd0b9i@drn.newsguy.com>

Hello,

  ActiveState Perl on W2000.

What do people recommend for encrypting a password to be put into code that
makes use of Net::FTP?

CPAN tells me of 15 modules (or are they packages?) that correspond to .*crypt.*
However what I think I need is, obviously, something that encrypts the password
_outside_ of Perl that I can then put into the code where it will be decrypted. 
I'm not going to worry yet about what form of the password travels over the wire
during the ftp transaction.  I just don't want the plaintext of my password
sitting in my Perl source.

  pat



------------------------------

Date: 24 Jul 2001 02:04:28 GMT
From: ebohlman@omsdev.com (Eric Bohlman)
Subject: Re: Escaped period! Someone apprehend it!
Message-Id: <9jil3c$bud$2@bob.news.rcn.net>

--Rick <no_trick@my-de(remove the obvious)ja.com> wrote:
> Please bear with me as I'm still new to perl.  This solution didn't work
> at all for me.  If it does work, then I would love to learn how.  I
> suspect that there is a question-mark missing just ahead of the tail
> anchor that is needed to make the decimal portion optional.  When I
> tested it, only whole numbers would pass.  To get decimals I think it
> should look like this:  /^\d+(?:\.\d+)?$/.

Yep, my typo.


------------------------------

Date: Tue, 24 Jul 2001 09:29:57 +0300
From: Roope Havu <rhavu@csc.fi>
Subject: Re: Escaped period! Someone apprehend it!
Message-Id: <Pine.LNX.4.33.0107240921370.12012-100000@sampo.csc.fi>

On Mon, 23 Jul 2001, Joe Smith wrote:

[ Lots of stuff cut out ]

>
> 0) Optional minus sign.
> 1) String of digits, a period, then 0 or more digits.

Hmm, doesn't that also accept 32. or any number followed by a period?

> 2) A period followed by 1 or more digits
> 3) Digits only
>
> 	print "OK!" if /^-?(\d+\.\d*|\.\d+|\d+)$/;

Why not just:

       print "OK!" if /^-?(\d+|\d*\.\d+)$/;

With the optional minus sign, then either a whole number or a decimal,
which I think is just a period with numbers after it, and maybe before it.

Hmm, that does still accept -.5, but I guess that might be okay.


- Roope



------------------------------

Date: Tue, 24 Jul 2001 06:16:52 GMT
From: PerlFAQ Server <faq@denver.pm.org>
Subject: FAQ: How can I output Roman numerals?
Message-Id: <op877.11$os9.183479808@news.frii.net>

This message is one of several periodic postings to comp.lang.perl.misc
intended to make it easier for perl programmers to find answers to
common questions. The core of this message represents an excerpt
from the documentation provided with every Standard Distribution of
Perl.

+
  How can I output Roman numerals?

    Get the http://www.perl.com/CPAN/modules/by-module/Roman module.

- 

Documents such as this have been called "Answers to Frequently
Asked Questions" or FAQ for short.  They represent an important
part of the Usenet tradition.  They serve to reduce the volume of
redundant traffic on a news group by providing quality answers to
questions that keep coming up.

If you are some how irritated by seeing these postings you are free
to ignore them or add the sender to your killfile.  If you find
errors or other problems with these postings please send corrections
or comments to the posting email address or to the maintainers as
directed in the perlfaq manual page.

Answers to questions about LOTS of stuff, mostly not related to
Perl, can be found by pointing your news client to

    news:news.answers

or to the many thousands of other useful Usenet news groups.

Note that the FAQ text posted by this server may have been modified
from that distributed in the stable Perl release.  It may have been
edited to reflect the additions, changes and corrections provided
by respondents, reviewers, and critics to previous postings of
these FAQ. Complete text of these FAQ are available on request.

The perlfaq manual page contains the following copyright notice.

  AUTHOR AND COPYRIGHT

    Copyright (c) 1997-1999 Tom Christiansen and Nathan
    Torkington.  All rights reserved.

This posting is provided in the hope that it will be useful but
does not represent a commitment or contract of any kind on the part
of the contributers, authors or their agents.

                                                           04.08
-- 
    This space intentionally left blank


------------------------------

Date: 24 Jul 2001 01:06:57 -0700
From: sammi79@hotmail.com (samantha)
Subject: Generating elements based on input
Message-Id: <428efa34.0107240006.2ed14003@posting.google.com>

hey!

     could someone please tell me how i can generate a popupmenu based
on an input that i have received. both the input received and the
popup menu have to be on the same form. urgent!!! please reply asap.
thx

regards
samantha


------------------------------

Date: Tue, 24 Jul 2001 09:18:33 +0100
From: "Tom Melly" <tom.melly@ccl.com>
Subject: Re: Generating elements based on input
Message-Id: <3b5d2f59$0$3758$ed9e5944@reading.news.pipex.net>

"samantha" <sammi79@hotmail.com> wrote in message
news:428efa34.0107240006.2ed14003@posting.google.com...

<snip>

Not to sure yet what you want - how can you have a pop-up based on data not yet
submitted?




------------------------------

Date: Tue, 24 Jul 2001 01:05:56 -0700
From: "$Bill Luebkert" <dbe@wgn.net>
Subject: Re: getting users ip
Message-Id: <3B5D2C64.76834381@wgn.net>

Chris Micallef wrote:
> 
> I am using perl to write cgi scripts for a web page.
> 
> Can some one explain to me how and why the following code successfully
> obtains users ip.
> 
> $RemoteHost = (gethostbyaddr(pack('C4',$1,$2,$3,$4),2))[0] ||
> $ENV{'REMOTE_ADDR'};

This handles num=>name or name=>num (modify to suit):

use strict;

my $result = lookup ($REMOTE_ADDR);
print "$REMOTE_ADDR = $result\n";

sub lookup {
	local ($_) = shift;
	use Socket;

if (/^[\d\.]+$/) {	# if dotted decimal address

	if (my $host = gethostbyaddr (&inet_aton ($_), AF_INET)) {
		return $host;
	} else {
		return "Error on gethostbyaddr '$_': $!";
	}
} else {		# must be a hostname

	if (my $raddr = (gethostbyname ($_))[4]) {
		return &inet_ntoa ($raddr);
	} else {
		return "Error on gethostbyname '$_': $!";
	}
}

}


-- 
  ,-/-  __      _  _         $Bill Luebkert   ICQ=14439852
 (_/   /  )    // //       DBE Collectibles   Mailto:dbe@todbe.com 
  / ) /--<  o // //      http://dbecoll.webjump.com/ (Free site for Perl)
-/-' /___/_<_</_</_     Castle of Medieval Myth & Magic http://www.todbe.com/


------------------------------

Date: 24 Jul 2001 08:34:04 +0100
From: nobull@mail.com
Subject: Re: getting users ip
Message-Id: <u93d7mpwec.fsf@wcl-l.bham.ac.uk>

Chris Micallef <cmicallef@playground.net> writes:

> I am using perl to write cgi scripts for a web page.

You need to develop the ability to destinguish what questions relate to
the "using perl" part and what questions relate to the "write cgi
scripts" part.  There are separate newsgroup hierachies for the two
subject areas.

> Can some one explain to me how and why the following code successfully
> obtains users ip.
> 
> $RemoteHost = (gethostbyaddr(pack('C4',$1,$2,$3,$4),2))[0] ||
> $ENV{'REMOTE_ADDR'};

It does not.  For several reasons.

There's nothing in the above code to set $1,$2,$3,$4.  The above call
to gethostbyaddr() appears to be partial code to translate an IP
address to a host name.  But since your stated goal is to obtain an IP
address this is counterproductive and it should be removed.  (For
details of the gethostbyaddr() function "perldoc -f gethostbyaddr".)
That's the end of Perl part of the answer.

Under CGI the enviroment variable REMOTE_ADDR holds the IP address of
the last HTTP proxy in the chain between the HTTP client and the HTTP
server.  In the degenerate case where there are no proxies then this
is the client's address.  This has nothing to do with Perl.

For further details (e.g. how some proxies sometimes record the
address of the origninating client) see numerous previous threads.

Ideally you should look in a newsgroup where such discussions are
on-topic but in practice you'll find about two threads per week on
this subject here.

-- 
     \\   ( )
  .  _\\__[oo
 .__/  \\ /\@
 .  l___\\
  # ll  l\\
 ###LL  LL\\
	


------------------------------

Date: 23 Jul 2001 20:31:51 -0400
From: stanb@panix.com (Stan Brown)
Subject: Re: How can I determine how many charcters to represnt a given int value?
Message-Id: <9jifln$ak7$1@panix2.panix.com>

In <3B5C8B61.42CFF2BB@vpservices.com> Jeff Zucker <jeff@vpservices.com> writes:

>Stan Brown wrote:
>> 
>> I'm doing something (wrong perhaps) with PerlTK that requires that I tell
>> the widget how much space to reserve for a given number (integer).
>> 
>> How can I do this in perl? In C I would kust printf it into a temporary
>> char array, anddo len() on it.
>> 
>> What's a better perl way of doing it?

>print length 1234567;


ARGH! I thought I ollked in the function reference.

Thanks



------------------------------

Date: Tue, 24 Jul 2001 03:39:41 GMT
From: "John W. Krahn" <krahnj@acm.org>
Subject: Re: How do I count the number of characters in a string
Message-Id: <3B5CEDF9.EC1EAADC@acm.org>

[top-posting fixed]

novastar wrote:
> 
> "J.D. Fieldsend" <u9jdf@csc.liv.ac.uk> wrote in message
> news:3B5C0795.A79D7050@csc.liv.ac.uk...
> >
> > I want to be able to tabulate text without knowing beforehand how many
> > characters are in each string.
> 
> you could also do th following
> print $myline=~s/././g ;

Which has the nasty side effect of replacing every character in $myline
(except the newline) with a period.



John
-- 
use Perl;
program
fulfillment


------------------------------

Date: Tue, 24 Jul 2001 12:16:53 +0200
From: Efi Fogel <efi@enbaya.com>
Subject: How to cause navigation to occur in same WebBrowser window (on windows)?
Message-Id: <3B5D4B15.E9809EE9@enbaya.com>

I'd like the navigation to occur in my Internet Explorer and not other
Internet Explorer windows. In simple words, assume that I have 2 URLs.
I'd like to launch Internet Explorer with the first URL, and then later
on navigate to the second URL using the same window of the Internet
Explorer.

I know it can be done with Visual Basic in a simple way (see
http://support.microsoft.com/support/kb/articles/Q185/5/38.asp ), but I
need to it with Perl.

--
  ____  _        ____             _
 /_____/_) o    /__________  __  //
(____ (   (    (    (_/ (_/-(-'_(/
                        _/




------------------------------

Date: Tue, 24 Jul 2001 08:32:06 +0200
From: "Ciric Vukasin" <cvule@eunet.yu>
Subject: Re: How to redirect a user ?
Message-Id: <9jj4kn$cho$1@news.eunet.yu>

Is that going to work in PHP ?

Alexis Roda <alexis.roda@si.urv.es> wrote in message
news:3B5C08C0.EB27001D@si.urv.es...
> Ciric Vukasin wrote:
> >
> > How to redirect user to another page ?
> >
> > Thanks in adv.
>
> use CGI;
>
> my $cgi = new CGI();
> print $cgi->redirect($some_url);
>
>
> HTH
> --
>                                   ////
>                                  (@ @)
> ---------------------------oOO----(_)----OOo------------------------
>         Los pecados de los tres mundos desapareceran conmigo.
> Alexis Roda - Universitat Rovira i Virgili - Reus, Tarragona (Spain)
> --------------------------------------------------------------------




------------------------------

Date: 24 Jul 2001 00:52:20 -0700
From: el@wilmington.net (el)
Subject: Re: How to redirect a user ?
Message-Id: <58929d2c.0107232352.656c3a6@posting.google.com>

Alexis Roda <alexis.roda@si.urv.es> wrote in message news:<3B5C08C0.EB27001D@si.urv.es>...
> Ciric Vukasin wrote:
> > 
> > How to redirect user to another page ?
> > 
> > Thanks in adv.
> 
> use CGI;
> 
> my $cgi = new CGI();
> print $cgi->redirect($some_url);
> 
> 
> HTH

Here's another way, but be careful that you don't call a print
'Content...' line before it.
 print "Location: http://redirect_user_here.com\n\n";
el


------------------------------

Date: Tue, 24 Jul 2001 01:16:15 GMT
From: "Mark W. Dufault" <mdufault@dynamicservers.com>
Subject: how to sort by the Nth ip addr in string?
Message-Id: <z%377.182103$v5.16579630@news1.rdc1.ct.home.com>

Any ideas on how best to sort by the Nth IP match in the string. This
algorithm works on the first IP address it comes across but I would like add
the ability to sort by the Nth occurance of an IP address.

file.cfg below...
static (inside,dmz2) 172.16.4.2 10.1.3.5 netmask 255.255.255.255 0 0
static (inside,dmz1) 172.16.3.4 10.2.5.7 netmask 255.255.255.255 0 0
static (inside,dmz3) 172.16.4.1 10.5.6.8 netmask 255.255.255.255 0 0
static (inside,dmz2) 172.16.32.1 10.2.3.4 netmask 255.255.255.255 0 0

The above lines are the input...

sub sortbyip {
 @out = sort {
        pack('C4' => $a =~
         /(\d+)\.(\d+)\.(\d+)\.(\d+)/)
        cmp
        pack('C4' => $b =~
         /(\d+)\.(\d+)\.(\d+)\.(\d+)/)
    } @_ ;
    return @out ;
}
while ( defined($filename = glob("*.cfg")) ) {
 open (INPUTFILE, "< $filename") || die "can't open $filename: $!" ;
    @config = (<INPUTFILE>) ;
    foreach $line (@config) {
     if ($line =~ /^static/) { push  (@static,$line) ; } ;
        if ($line =~ /^conduit/) { push  (@conduit,$line) ; } ;
    }
    print "-" x 79, "\n", "File = $filename\n", "-" x 79, "\n" ;
 print (sortbyip(@static), sortbyip(@conduit)) ;
}


Thanks,
Mark




------------------------------

Date: Tue, 24 Jul 2001 06:33:16 GMT
From: "John W. Krahn" <krahnj@acm.org>
Subject: Re: how to sort by the Nth ip addr in string?
Message-Id: <3B5D16FE.B43B5BC3@acm.org>

"Mark W. Dufault" wrote:
> 
> Any ideas on how best to sort by the Nth IP match in the string. This
> algorithm works on the first IP address it comes across but I would like add
> the ability to sort by the Nth occurance of an IP address.
> 
> file.cfg below...
> static (inside,dmz2) 172.16.4.2 10.1.3.5 netmask 255.255.255.255 0 0
> static (inside,dmz1) 172.16.3.4 10.2.5.7 netmask 255.255.255.255 0 0
> static (inside,dmz3) 172.16.4.1 10.5.6.8 netmask 255.255.255.255 0 0
> static (inside,dmz2) 172.16.32.1 10.2.3.4 netmask 255.255.255.255 0 0
> 
> The above lines are the input...
> 
> [snip code]


my $offset = 1;	# which ip on line to sort by
my $separator = '-' x 79;

while ( defined( $filename = glob( "*.cfg" ) ) ) {
    open INPUTFILE, $filename or die "can't open $filename: $!";
    while ( <INPUTFILE> ) {
        push @static,  $_ if /^static/;
        push @conduit, $_ if /^conduit/;
        }
    print "$separator\nFile = $filename\n$separator\n";
    print( sortbyip( @static ), sortbyip( @conduit ) );
    }

sub sortbyip {
return map { substr $_, 10 }
       sort
       map { 
           my @ips = /(\d+)\.(\d+)\.(\d+)\.(\d+)/g;
           die "This line does not have $offset ip addresses\n" if
$offset and @ips / 4 < $offset;
           sprintf( '%010u%s', unpack( 'N', pack( 'C4', splice( @ips,
($offset - 1)*4, 4 ) ) ), $_ )
           }
       @_;
    }



John
-- 
use Perl;
program
fulfillment


------------------------------

Date: 24 Jul 2001 00:04:10 -0500
From: logan@cs.utexas.edu (Logan Shaw)
Subject: Re: Large Filesystem Scrubbers
Message-Id: <9jivka$2nt$1@charity.cs.utexas.edu>

In article <3B5C3756.760B3B01@ucar.edu>, Rob Kirby  <kirbyr@ucar.edu> wrote:
>We have a relatively large GPFS filesystem that we support (~2TB), 
>and we have a home grown filesystem scrubber which will get rid of files
>based on thresholds
   :
   :
>The problem I currently have though is that I have inherited the 
>scrubber and it was written by different people no longer involved 
>and consists of a half dozen home-brew utilities written very generically, 
>to work on other platforms besides AIX. I would like to convert the
>whole thing from C code into Perl code, but I fear that performance
>will suffer seeings how I need to walk the complete tree and stat every
>single file, excluding open files, then sorting on the oldest files 
>first.......... if you catch my drift ;-)

The only potential problem I see is if your program needs to store a
big list of potentially-scrubbable files in memory.  If so, a Perl
solution isn't going to be as memory-efficient as a carefully-written
C/C++ solution.  Perl might even use ten times as much memory, but it
would depend.  The point is that if your C/C++ implementation is
using lots of memory as it is now, Perl might not be a good choice.

Otherwise, as others have said, the thing is probably I/O bound anyway.

By the way, it sounds like what really matters is not how
many bytes are on your filesystem but how many files.  If
you have 2 TB of 100 KB files, that's going to be a
different story than if you have 2 TB of 20 GB files.

  - Logan
-- 
"Our grandkids love that we get Roadrunner and digital cable."
(Advertisement for Time Warner cable TV and internet access, July 2001)


------------------------------

Date: Tue, 24 Jul 2001 07:35:43 +0200
From: Philip Newton <pne-news-20010724@newton.digitalspace.net>
Subject: Re: manpage styles/templates???
Message-Id: <li1qlto3s7au4b6s33m24uli55dmne02au@4ax.com>

On Tue, 24 Jul 2001 08:29:35 +0800, MMX166+2.1G HD <no@mail.addr>
top-posted full-quoted:

> yes I know the usage. but I can't find the pod file.(for
> NEWS:NNTPClient)

I would expect the pod to be inside the module file itself. Find the
module file (e.g. with `perldoc -l News::NNTPClient`) and have a look
inside it; if you have =head2 and C<markup> etc., pod2html should be
able to extract the POD from the file.

Cheers,
Philip
-- 
Philip Newton <nospam.newton@gmx.li>
That really is my address; no need to remove anything to reply.
If you're not part of the solution, you're part of the precipitate.


------------------------------

Date: 23 Jul 2001 19:05:29 -0500
From: Ren Maddox <ren@tivoli.com>
Subject: Re: My actual problem ( was: Re: Printing results of a subroutine to a file
Message-Id: <m3puarp4xi.fsf@dhcp9-161.support.tivoli.com>

On Thu, 19 Jul 2001, racso83@bellatlantic.net wrote:

[snip]

>     } elsif ($line =~ /^&.*;/) {
>       $line =~ s/^&(.*);/$1/ig;
> 
>       &get_sub_output("$line"); ## this subroutine is shown below

[snip]

> sub get_sub_output {
>   $eval = $_[0];
>   $output = eval { &$eval; };
>   $output =~ s/(.*)1$/$1/ig; ## this just gets rid of that pesky "1"
>   return($output);
> }

It seems a bit over-complicated, but it looks like it should work.  Are
you 100% certain that the require statement executes before this code?
You could print *$eval{CODE} to verify that there is a code reference
there.

-- 
Ren Maddox
ren@tivoli.com


------------------------------

Date: Mon, 23 Jul 2001 18:57:11 -0700
From: "Swim Boy" <bill@antrix.com>
Subject: Need Perl User Login Source code
Message-Id: <my477.53202$aW5.695634@dfw-read.news.verio.net>

Hello I need user login, password authentication source
via html pages

1) interacting with flat ascii file
2) interacting with mysql database

thanks

bill@antrix.com




------------------------------

Date: Tue, 24 Jul 2001 10:51:44 +0200
From: Tassilo von Parseval <Tassilo.Parseval@post.rwth-aachen.de>
Subject: Re: Need Perl User Login Source code
Message-Id: <3B5D3720.3060604@post.rwth-aachen.de>

Swim Boy wrote:

>Hello I need user login, password authentication source
>via html pages
>
You need that, eh? You don't expect us to write that for you, do you?
=> perldoc CGI

>
>
>1) interacting with flat ascii file
>
perldoc -f open etc.

>
>2) interacting with mysql database
>
perldoc DBI


-- 
Man and wife make one fool.




------------------------------

Date: 24 Jul 2001 09:52:14 GMT
From: anno4000@lublin.zrz.tu-berlin.de (Anno Siegel)
Subject: Re: nested forks - help....
Message-Id: <9jjgge$mju$1@mamenchi.zrz.TU-Berlin.DE>

According to Elias_Haddad <Elias_Haddad@tertio.com>:
> Hi all,
> 
> Any help will be much appreciated on the subject.
> I am writing an application whereby I would like to fork a few processes,
> and in these forked processes, fork additionnal processes without any of
> the parent processes to have to wait for their children to finish. It is
> something of the form:
> 
> foreach $customer (@customers) {
>      if ($cust_pid = fork) { #in parent
>           sleep 1;

Why are you sleeping before you set the SIGCHLD handler?  You should
probably set it once before the first fork, otherwise some signal
may arrive before the handler is set.

>            $SIG{CHLD} = 'IGNORE';
>      }
>      if ($cust_pid == 0) { #in child

This second "if" is better written as an "else" alternative to the
first one.

>           foreach $router (@routers) {
>                if ($router_pid = fork) { #in parent
>                     sleep 1;
>                     $SIG{CHLD} = 'IGNORE';
>                }
>                if ($router_pid == 0) { #in child
>                     #do something, main application here
>                     exit; #this exits child process at router level
>                }
>           }
>      }
>      exit; #this exits child process at customer level
> }
> 
> So basically, what I am trying to do is for each customer in my list of
> customers, fork a process, and then for each router owned by that customer,
> fork another process and this is where my main application takes place, at
> router level. I think what I have here are nested forks.
> My probelm is that my application is giving me really strange results when
> I have nested forks. Perl seems to be confusing which child belongs to
> which parent or something of the kind.

"Strange results" is not a very precise description of what you are
seeing.  Nothing in your code shows any sensitivity as to which
child belongs to which parent; you are ignoring (most of) the
SIGCHLDs anyhow.

[...]

> Any help on possible alternative ways will be VERY appreciated as I am
> writing this application for a customer.

Do you realize what you are saying?  "I'm being paid for this, so
I need your free help urgently."  Not a very diplomatic thing to say.

[...]

Anno


------------------------------

Date: 6 Apr 2001 21:33:47 GMT (Last modified)
From: Perl-Users-Request@ruby.oce.orst.edu (Perl-Users-Digest Admin) 
Subject: Digest Administrivia (Last modified: 6 Apr 01)
Message-Id: <null>


Administrivia:

The Perl-Users Digest is a retransmission of the USENET newsgroup
comp.lang.perl.misc.  For subscription or unsubscription requests, send
the single line:

	subscribe perl-users
or:
	unsubscribe perl-users

to almanac@ruby.oce.orst.edu.  

To submit articles to comp.lang.perl.announce, send your article to
clpa@perl.com.

To request back copies (available for a week or so), send your request
to almanac@ruby.oce.orst.edu with the command "send perl-users x.y",
where x is the volume number and y is the issue number.

For other requests pertaining to the digest, send mail to
perl-users-request@ruby.oce.orst.edu. Do not waste your time or mine
sending perl questions to the -request address, I don't have time to
answer them even if I did know the answer.


------------------------------
End of Perl-Users Digest V10 Issue 1364
***************************************


home help back first fref pref prev next nref lref last post