Beefy Boxes and Bandwidth Generously Provided by pair Networks
P is for Practical
 
PerlMonks  

Re: replacing the last portions of an octet

by blue_cowdawg (Monsignor)
on Sep 18, 2012 at 19:40 UTC ( #994343=note: print w/replies, xml ) Need Help??


in reply to replacing the last portions of an octet

Something like this?

#!/usr/bin/perl -w use strict; my $ips='192.168.1.1-192.168.1.254'; my ($first,$second)=split('-',$ips); printf "%s-%s\n",$first,$second; $first = incip($first); $second = incip($second); printf "%s-%s\n",$first,$second; exit(0); sub incip { my $ip=shift; my @o=split(/[\.]/,$ip); $o[3]++; return sprintf("%d.%d.%d.%d",@o); }


Peter L. Berghold -- Unix Professional
Peter -at- Berghold -dot- Net; AOL IM redcowdawg Yahoo IM: blue_cowdawg

Replies are listed 'Best First'.
Re^2: replacing the last portions of an octet
by diamondsandperls (Beadle) on Sep 18, 2012 at 20:03 UTC
    sorry just noticed those are subroutines ill play around some more
Re^2: replacing the last portions of an octet
by diamondsandperls (Beadle) on Sep 18, 2012 at 20:06 UTC
    thanks was able to play around with your sample code to get what i was looking for thanks for the heads up and insight

Log In?
Username:
Password:

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://994343]
help
Chatterbox?
[Corion]: thezip: Quite good, after a one week vacation in the sun ;)
[Corion]: I hope you're well too!
[thezip]: Where did you go? We've already set a record for all-time February rainfall here.
[Corion]: thezip: The Canary Islands - they have a constant climate
[Corion]: Maybe a bit too many old people, but for some do-nothing vacation for R&R exactly the right thing ;)=
[thezip]: That's awesome. I bet you feel totally rejuvenated and ready for the next thing.

How do I use this? | Other CB clients
Other Users?
Others cooling their heels in the Monastery: (7)
As of 2017-02-23 17:03 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?
    Before electricity was invented, what was the Electric Eel called?






    Results (349 votes). Check out past polls.