Beefy Boxes and Bandwidth Generously Provided by pair Networks
Perl: the Markov chain saw
 
PerlMonks  

Re: IP address - decimal to octal

by Petruchio (Vicar)
on Apr 23, 2001 at 01:21 UTC ( #74600=note: print w/ replies, xml ) Need Help??

Help for this page

Select Code to Download


  1. or download this
    ./ipdec2oct.pl 10.m55.000.001
    
  2. or download this
    octal   012.0.0.1
    
  3. or download this
    Argument "m55" isn't numeric in lt at ./ipdec2oct.pl line 22.
    
  4. or download this
    $octet10 =~ /^\d{1,3}$/
    
  5. or download this
        if ( $octet10 < 0 ) {
            &USAGE("\"$address{decimal}\" don't cut it:  \"$octet10\" is l
    +ess than 0");
        }
    
  6. or download this
    &USAGE("\"$address{decimal}\" don't cut it:  \"$octet10\" is greater t
    +han 255");
    
  7. or download this
    &USAGE(qq["$address{decimal}" don't cut it:  "$octet10" is greater tha
    +n 255]);
    
  8. or download this
    &USAGE(qq."$address{decimal}" don't cut it:  "$octet10" is greater tha
    +n 255.);
    
  9. or download this
    if ( $octet10 > 255 ) {
        print qq/"$address{decimal}" don't cut it:  /,
              qq/"$octet10" is greater than 255./;
        &USAGE;
    }
    
  10. or download this
        if ($octet8 > 7) { 
            $octetpadded = "0$octet8";
    ...
        else { 
            $octetpadded = $octet8; 
        }
    
  11. or download this
        $octetpadded = ($octet8 > 7) ? "0$octet8" : $octet8;
    
  12. or download this
        $octetpadded = ($octet8 > 7) ? "0$octet8" : $octet8;
        push @octets8, $octetpadded;
    
  13. or download this
        push @octets8, ($octet8 > 7) ? "0$octet8" : $octet8;
    
  14. or download this
    for my $octet10(@octets10) {
    
  15. or download this
    for (@octets10) {
    
  16. or download this
    my @octets10 = split /\./, $address{decimal};
    for (@octets10) {
    
  17. or download this
    for (split /\./, $address{decimal}) {
    
  18. or download this
    $address{octal}  = join '.', @octets8;
    print "\n decimal $address{decimal}\n octal   $address{octal}\n\n";
    
  19. or download this
    print "\n decimal ", $address{decimal},
          "\n octal   ", join('.',@octets8),
          "\n\n";
    
  20. or download this
    #!/usr/bin/perl -w
    
    ...
              $0, "Perl $]", $^O, "\n";
        exit;
    }   
    

Log In?
Username:
Password:

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

How do I use this? | Other CB clients
Other Users?
Others chanting in the Monastery: (11)
As of 2014-12-27 17:37 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    Is guessing a good strategy for surviving in the IT business?





    Results (177 votes), past polls