09-22-2009
Hello,
Thanks for your time, i've been testing your code and it has a bug, it works perfectly with any address starting with "128.x.x.x" and lower, but, when you try and address greater than 128, you'll always get the same result, for example, if you input "192.168.1.1/24", the program will show you up "128.168.1.0".
Might it be the power functions incremented by three?
9 More Discussions You Might Find Interesting
1. UNIX for Advanced & Expert Users
Hi
I have a CSV file with me in this format
Currency, USD, EUR,
USD, 1.00, 1.32,
EUR, 0.66, 1.00,
How do I transpose the file to get to the format below.
currency, currency, rate
USD, USD, 1.00
USD, EUR, 1.32
EUR, USD, 0.66
EUR, EUR, 1.00
Thanks for your help
We are using... (2 Replies)
Discussion started by: cdesiks
2 Replies
2. Shell Programming and Scripting
Hello,
I have a file which has a range of date like:
00:00 test
00:01 test2
00:02 test3
00:03 test4
00:04 test5
00:05 test6
Using input (stdin) i would like to parse the data 00:01 to 00:04. The output file should be like this:
00:01 test2
00:02 test3
00:03 test4
00:04 test5
... (5 Replies)
Discussion started by: BufferExploder
5 Replies
3. Shell Programming and Scripting
Hi All,
I have an xml file with the below format.
<a>111</a><b>222</b><c>333<c><d><e>123</e><f>234</f><d><e>456</e><f>789</f>
output needed is
111,222,333,123,234
111,222,333,456,789
nawk 'BEGIN{FS="<|>"}
{print a,b,c,e,f
a=""
... (7 Replies)
Discussion started by: natalie23
7 Replies
4. Shell Programming and Scripting
Hi,
I have a file with 3 fields in csv format:
/tmp/foo/,MODIFY,bar/toto
"/tmp/foo, bar/","ATTRIB,ISDIR","toto, tata/foobar"I would like to split fields in order to obtain the following:
Line1:
/tmp/foo/
MODIFY
bar/totoLine2:
/tmp/foo, bar/
ATTRIB,ISDIR
toto, tata/foobarCan't find my way... (11 Replies)
Discussion started by: chebarbudo
11 Replies
5. Shell Programming and Scripting
Hey there...
I am looking for a way to take the below contents ( small excerpt) of this file called PTR.csv
ptrrecord,0000002e0cc0.homeoffice.anfcorp.com,,10.11.191.62,,,False,62.191.11.10.in-addr.arpa,,302400,default... (6 Replies)
Discussion started by: richsark
6 Replies
6. Shell Programming and Scripting
Hi Forum.
Need your expertise on the following question.
I have the following file which I would like to parse, find first block of SELECT statment and concatenate all input fields as 1 field (~ delimited):
Old File:
SELECT /*+ USE_HASH(CCOMM ICAR IMAP IAS IP IMAS IMPS IAP SPCA) */
... (5 Replies)
Discussion started by: pchang
5 Replies
7. Shell Programming and Scripting
Hi all, I would appreciate if someone could share how to convert CIDR notation to netmask and vice versa.
The value below is just an example. it could be different numbers/ip addresses.
Initial Output, let say file1.txt
Final Output, let say file2.txt (3 Replies)
Discussion started by: type8code0
3 Replies
8. Shell Programming and Scripting
My source file looks like this:
Cust-Number = "101"
Cust-Name="Joe"
Cust-Town="London"
Cust-hobby="tennis"
Cust-purchase="200"
Cust-Number = "102"
Cust-Name="Mary"
Cust-Town="Newyork"
Cust-hobby="reading"
Cust-purchase="125"
Now I want to parse this file (leaving out hobby) and... (10 Replies)
Discussion started by: Balav
10 Replies
9. Programming
Scripting Language: bash shell script, python
I want to parse .nessus file in human readable format. If any one have any ideas please help me. (2 Replies)
Discussion started by: sk151993
2 Replies
LEARN ABOUT DEBIAN
paranoid::network::ipv4
Paranoid::Network::IPv4(3pm) User Contributed Perl Documentation Paranoid::Network::IPv4(3pm)
NAME
Paranoid::Network::IPv4 - IPv4-related functions
VERSION
$Id: IPv4.pm,v 0.1 2012/05/29 21:37:44 acorliss Exp $
SYNOPSIS
use Paranoid::Network::IPv4;
@net = ipv4NetConvert($netAddr);
$rv = ipv4NetIntersect($net1, $net2);
or
use Paranoid::Network::IPv4 qw(:all);
print "Valid IP address
" if $netAddr =~ /^@{[ IPV4REGEX ]}$/;
@net = ipv4NetConvert($netAddr);
$broadcast = $net[IPV4BRDCST];
DESCRIPTION
This module contains a few convenience functions for working with IPv4 addresses.
By default only the subroutines themselves are imported. Requesting :all will also import the constants as well.
SUBROUTINES
/METHODS
ipv4NetConvert
@net = ipv4NetConvert($netAddr);
This function takes an IPv4 network address in string format and converts it into an array containing the base network address, the
broadcast address, and the netmask, in integer format. The network address can have the netmask in either CIDR format or dotted quads.
In the case of a single IP address, the array with only have one element, that of the IP in integer format.
Passing any argument to this function that is not a string representation of an IP address (including undef values) will cause this
function to return an empty array.
ipv4NetIntersect
$rv = ipv4NetIntersect($net1, $net2);
This function tests whether an IP or subnet intersects with another IP or subnet. The return value is essentially boolean, but the true
value can vary to indicate which is a subset of the other:
-1: destination range encompasses target range
0: both ranges do not intersect at all
1: target range encompasses destination range
The function handles the same string formats as ipv4NetConvert, but will allow you to test single IPs in integer format as well.
CONSTANTS
These are only imported if explicity requested or with the :all tag.
MAXIPV4CIDR
Simply put: 32. This is the largest CIDR notation supported in IPv4.
IPV4REGEX
Regular expression: qr/(?:d{1,3}.){3}d{1,3}/sm
You can use this for validating IP addresses as such:
$ip =~ m#^@{[ IPV4REGEX ]}$#;
or to extract potential IPs from extraneous text:
(@ips) = ( $string =~ m#(@{[ IPV4REGEX ]})#gsm);
IPV4CIDRRGX
Regular expression:
qr#(@{[ IPV4REGEX ]})(?:/(d+|@{[ IPV4REGEX ]}))?#sm
By default this will extract an IP or CIDR notation network address:
($net, $mask) = ( $ip =~ m#^@{[ IPV4CIDRRGX ]}$# );
In the case of a simple IP address $mask will be undefined.
IPV4BASE
This is the ordinal index of the base network address as returned by ipv4NetConvert.
IPV4BRDCST
This is the ordinal index of the broadcast address as returned by ipv4NetConvert.
IPV4MASK
This is the ordinal index of the network mask as returned by ipv4NetConvert.
DEPENDENCIES
o Paranoid
o Paranoid::Network::Socket
BUGS AND LIMITATIONS
AUTHOR
Arthur Corliss (corliss@digitalmages.com)
LICENSE AND COPYRIGHT
This software is licensed under the same terms as Perl, itself. Please see http://dev.perl.org/licenses/ for more information.
(c) 2012, Arthur Corliss (corliss@digitalmages.com)
perl v5.14.2 2012-05-29 Paranoid::Network::IPv4(3pm)