Beefy Boxes and Bandwidth Generously Provided by pair Networks
more useful options
 
PerlMonks  

Re: Compressing .sigs more

by jynx (Priest)
on Sep 20, 2001 at 01:23 UTC ( [id://113476]=note: print w/replies, xml ) Need Help??


in reply to Compressing .sigs more


AFAICT,

It looks like the part you want changed is the last three lines of perl, kinda like so:

while(<STDIN>) { chomp; if (/^Received:[^\[]+\[(\d+)\.(\d+)\.(\d+)\.(\d+)\]/) { $n=`host $4.$3.$2.$1.$ARGV[0] 2>&1`; exit(0) if ($n=~/$ARGV[1]/m); } } exit(1);
Well, the best i could come up with looks something like this:
while(<STDIN>){$_="host ".join'.',map{s/(\d+)/$1/}split /./."$ARGV[0] 2>&1";`$_`=~/$ARGV[1]/m&&exit 0}exit 1
(or if we spread that out for readability):
while (<STDIN>) { $_= "host " . join '.', map {s/(\d+)/$1/} split /./ . "$ARGV[0] 2>&1"; `$_` =~ /$ARGV[1]/m && exit 0 } exit 1
Which reduces it one line. It has not been tested well at all (but should have the same functionality), and could probably be reduced more. Does this help at all?

jynx

Replies are listed 'Best First'.
Re: Re: Compressing .sigs more
by strredwolf (Chaplain) on Sep 20, 2001 at 08:23 UTC
    That partly helps, but I do need to do the filtering and lookup on that Received header.

    --
    $Stalag99{"URL"}="http://stalag99.keenspace.com";


      here's my next attempt,

      Actually, this is two attempts. After playing around with my original twist a couple of times, i found that to do what it needs to do it would have to be longer than your original code. So i instead took your original code and chopped off unimportant bits and did some reformatting. Both of the following snippets seem to test out correctly (using warnings and strict):

      /^Received[^\[]+\[(\d+).(\d+).(\d+).(\d+)]/?`host $4.$3. $2.$1.$ARGV[0] 2>&1`=~/$ARGV[1]/m&&exit 0:1while<STDIN>; exit 1 while(<STDIN>){s/^Received[^\[]+//&&s/].*//?($_='host ' .(join'.',(reverse map{s/(\D+)//;$_}split/\./),$ARGV[0] ).' 2>&1',`$_`=~/$ARGV[1]/m&&exit 0):1}exit 1
      The first one is based off of yours, i'm sure there's a way to squeeze it further, but i can't see it from here. The second is a re-working of my previous answer, and is obviously inadequate space-wise.

      Hope This Helps,
      jynx


      PS i'm not sure how space-conscientious you want to be, but you could also shorten the first line to:

      eval join"",map{chop;s/^[^>]+>\s*//&&$_}<DATA>__END__
      if you're really desperate for space. As always, it could probably be shortened more... :)

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: note [id://113476]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others cooling their heels in the Monastery: (8)
As of 2024-04-23 10:31 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found