Changeset 13732 for docs/Perl6/Spec

Show
Ignore:
Timestamp:
09/29/06 22:13:41 (2 years ago)
Author:
ajs
Message:

gethost function / methods added

Files:
1 modified

Legend:

Unmodified
Added
Removed
  • docs/Perl6/Spec/Functions.pod

    r13589 r13732  
    586586 
    587587  %cars_by_color = classify { .color } @cars; 
    588   say "The following people own red cars: ", 
    589         %cars_by_color<red>.map:{.owner}.join ", "; 
     588  red_car_owners(%cars_by_color<red>.map:{.owner}); 
    590589 
    591590=item grep 
     
    14441443=over 
    14451444 
     1445=item gethost 
     1446 
     1447 our OS::Name multi OS::gethost() 
     1448 our OS::Name multi OS::gethost( Str $name, OS::Addfamily :$type ) 
     1449 our OS::Name multi method gethost( OS::Addr $addr: ) is export 
     1450 our OS::Name multi method gethost( URI $uri: ) is export 
     1451 
     1452The C<gethost> function operates on host naming or address information 
     1453and returns an C<OS::Name>. An C<OS::Name> is, minimally: 
     1454 
     1455 class OS::Name { 
     1456   has Str $.name; 
     1457   has OS::Addr $.addr; 
     1458   has Array of Str @.aliases; 
     1459   has Array of OS::Addr @.addrs; 
     1460 } 
     1461 
     1462Such names can apply to anything which has a name that maps 
     1463to an address, however, in this case the name is a hostname 
     1464and the address is some sort of network identifier (e.g. 
     1465an IPV4 address when resolving hosts that have IPV4 addresses). 
     1466 
     1467When stringified, an C<OS::Name> yields its name. When 
     1468stringified, an C<OS::addr> yields its address in an 
     1469appropriate text format (e.g. "10.1.2.3" for an IPV4 address). 
     1470 
     1471The optional C<type> adverb can be passed when resolving a hostname, 
     1472and will filter the result to only those addresses that are of 
     1473the appropriate address family. This feature may be supported by 
     1474the underlying operating system, or Perl may emulate it. 
     1475 
     1476Examples: 
     1477 
     1478  say "Connection from {$socket.peer.gethost}"; 
     1479  my $address = gethost("foo.example.com").addr; 
     1480  my $hostname = gethost(:addr<"10.1.2.3">); 
     1481 
    14461482=item getpw 
    14471483