Quick Search for:  in language:    
simple,code,will,take,make,normal,long,like,3
   Code/Articles » |  Newest/Best » |  Community » |  Jobs » |  Other » |  Goto » | 
CategoriesSearch Newest CodeCoding ContestCode of the DayAsk A ProJobsUpload
Perl Stats

 Code: 74,273. lines
 Jobs: 25 postings

 How to support the site

 
Sponsored by:

 
You are in::
 
Login





Latest Code Ticker for Perl
Click here to see a screenshot of this code!Mailing List v2.0
By Aaron L. Anderson on 1/7

(Screen Shot)

ShowIMG
By Jeff Mills on 1/5


Simple Perl Ping
By John Hass on 12/29


Very basic login script template with cookies
By Aaron L. Anderson on 12/29


Click here to put this ticker on your site!


Add this ticker to your desktop!


Daily Code Email
To join the 'Code of the Day' Mailing List click here!

Affiliate Sites



 
 
   

IP to Long IP! Check it out!

Print
Email
 
VB icon
Submitted on: 3/22/2001 5:58:56 PM
By: Bruno Ribeiro 
Level: Beginner
User Rating: By 4 Users
Compatibility:5.0 (all versions), 4.0 (all versions), 3.0 (all versions)

Users have accessed this code 7457 times.
 
(About the author)
 
     This is a simple code that will take a make a normal ip a long ip! Long ips are like this one: 3333866552 (type this in the url on your browser if u doubt it works) The code is fully commented so any one with one day of perl coding can understand it. The code also explains how the convertion is done. I hope you like the code, and if u do, plz vote high for it =). If u have any doubt on it, post a comment here, i'll be glad on helping you =). Cya.
 
code:
Can't Copy and Paste this?
Click here for a copy-and-paste friendly version of this code!
 
Terms of Agreement:   
By using this code, you agree to the following terms...   
1) You may use this code in your own programs (and may compile it into a program and distribute it in compiled format for languages that allow it) freely and with no charge.   
2) You MAY NOT redistribute this code (for example to a web site) without written permission from the original author. Failure to do so is a violation of copyright laws.   
3) You may link to this code from another website, but ONLY if it is not wrapped in a frame. 
4) You will abide by any additional copyright restrictions which the author may have placed in the code or code's description.

    =**************************************
    = Name: IP to Long IP! Check it out!
    = Description:This is a simple code that
    =     will take a make a normal ip a long ip! 
    =     Long ips are like this one: 3333866552 (
    =     type this in the url on your browser if 
    =     u doubt it works) The code is fully comm
    =     ented so any one with one day of perl co
    =     ding can understand it. The code also ex
    =     plains how the convertion is done. I hop
    =     e you like the code, and if u do, plz vo
    =     te high for it =). If u have any doubt o
    =     n it, post a comment here, i'll be glad 
    =     on helping you =). Cya.
    = By: Bruno Ribeiro
    =
    =This code is copyrighted and has    = limited warranties.Please see http://w
    =     ww.Planet-Source-Code.com/vb/scripts/Sho
    =     wCode.asp?txtCodeId=174&lngWId;=6    =for details.    =**************************************
    
    #!/usr/bin/perl
    #################
    #Long ips are not very well known and are a nice 
    #alternate to the normal ip
    #ex: www.linux.org = 198.182.196.56 = 3333866552
    #so if u type 3333866552 in your browser u will 
    #be taken to linux.org.
    #Long ips are usefull for other things too, 
    #like on irc dcc chats
    #(if u don't know how irc dcc chats work go learn it)
    #LongIPS can also be used to bypass firewalls that 
    #blocks certain ips.
    #O well this code is really only to show 
    #how to do long ips
    #and i also commented every line so 
    #even a complete begginer can
    #understand this =)
    #Bye
    #Bruno Ribeiro
    ###################
    print "Ip to LongIP by Bruno Ribeiro\n\nEnter the ip to be made long: ";
    #gets the user entry for ip
    $ip = <STDIN>;
    #when reading from stdin it is a nice idea to chomp the var =) 
    #comment the line below and run if u doubt me =)
    #it will have the same longip as result
    #but it will insert a line break when u print $ip =)
    chomp $ip;
    #this var only exists for u to understand better how to convert an ip to a long ip.
    $n = 256;
    #this takes the $ip entered and splits it into the . so 
    #each part of it is stored in the array
    @sip = split(/\./,$ip);
    #this calculates the long ip
    $fip = (@sip[0]*($n * $n * $n))+(@sip[1]*($n * $n))+(@sip[2] * $n) + (@sip[3]);
    print "The long ip for $ip is: $fip";

 
Report Bad Submission
Use this form to notify us if this entry should be deleted (i.e contains no code, is a virus, etc.).
Reason:
 
Your Vote!

What do you think of this code(in the Beginner category)?
(The code with your highest vote will win this month's coding contest!)
Excellent  Good  Average  Below Average  Poor See Voting Log
 
Other User Comments
3/22/2001 6:51:33 PM:Jeff
Very Handy! Simple yet Small thanks!
Keep the Planet clean! If this comment was disrespectful, please report it:
Reason:

 
3/29/2001 10:03:51 AM:Orhan
Nice and concise!
But the correct 
format of accessing array elements 
is
: $array[index]
Not
: 
@array[index]
If you had used strict, 
then this would have been pointed out.
Keep the Planet clean! If this comment was disrespectful, please report it:
Reason:

 
3/29/2001 12:14:21 PM:Bruno Ribeiro
O well, it is known that on perl u have 
lots of ways of doing the same thing 
=). But thanks for the comment =)
Keep the Planet clean! If this comment was disrespectful, please report it:
Reason:

 
3/31/2001 2:05:57 AM:PaC
why go through all 
that.
chomp($_=<STDIN>);
$longip=$lo
ngip*256+$_ for split /\./;
Orhan 
and yes you can use @array[] to access 
an element.
@array[index] is an array 
slice.
I suggest you check out 
perldoc/man perldata
Keep the Planet clean! If this comment was disrespectful, please report it:
Reason:

 
10/1/2002 8:18:52 AM:
Long IP is more formally known as IPv6 
as well.
Keep the Planet clean! If this comment was disrespectful, please report it:
Reason:

 
2/27/2003 1:05:37 PM:serpent
mine comes up with loads of errors
Keep the Planet clean! If this comment was disrespectful, please report it:
Reason:

 
Add Your Feedback!
Note:Not only will your feedback be posted, but an email will be sent to the code's author in your name.

NOTICE: The author of this code has been kind enough to share it with you.  If you have a criticism, please state it politely or it will be deleted.

For feedback not related to this particular code, please click here.
 
Name:
Comment:

 

Categories | Articles and Tutorials | Advanced Search | Recommended Reading | Upload | Newest Code | Code of the Month | Code of the Day | All Time Hall of Fame | Coding Contest | Search for a job | Post a Job | Ask a Pro Discussion Forum | Live Chat | Feedback | Customize | Perl Home | Site Home | Other Sites | About the Site | Feedback | Link to the Site | Awards | Advertising | Privacy

Copyright© 1997 by Exhedra Solutions, Inc. All Rights Reserved.  By using this site you agree to its Terms and Conditions.  Planet Source Code (tm) and the phrase "Dream It. Code It" (tm) are trademarks of Exhedra Solutions, Inc.