Perl6-Doc

 view release on metacpan or  search on metacpan

share/Synopsis/S29-functions.pod  view on Meta::CPAN

=back


=head2 OS

=over

=item gethost

 our OS::Name multi gethost()
 our OS::Name multi gethost( Str $name, OS::Addfamily :$type )
 our OS::Name multi method gethost( OS::Addr $addr: ) is export
 our OS::Name multi method gethost( URI $uri: ) is export

The C<gethost> function operates on host naming or address information
and returns an C<OS::Name>. An C<OS::Name> is, minimally:

 class OS::Name {
   has Str $.name;
   has OS::Addr $.addr;
   has Array of Str @.aliases;
   has Array of OS::Addr @.addrs;
 }

Such names can apply to anything which has a name that maps
to an address, however, in this case the name is a hostname
and the address is some sort of network identifier (e.g.
an IPV4 address when resolving hosts that have IPV4 addresses).

When stringified, an C<OS::Name> yields its name. When
stringified, an C<OS::Addr> yields its address in an
appropriate text format (e.g. "10.1.2.3" for an IPV4 address).

The optional C<type> adverb can be passed when resolving a hostname,
and will filter the result to only those addresses that are of
the appropriate address family. This feature may be supported by
the underlying operating system, or Perl may emulate it.

Examples:

  say "Connection from {$socket.peer.gethost}";
  my $address = gethost("foo.example.com").addr;
  my $hostname = gethost(:addr<"10.1.2.3">);

=item chroot

 our Bool multi chroot ( Str $path = CALLER::<$_> )

On POSIX systems, changes the process context of the current process such
that the "root" directory becomes C<$path> and all rooted paths
(those that begin with a leading path separator) are relative to
that path. For security reasons, many operating systems limit
this functionality to the superuser. The return value will be
true on success.

=item getlogin

 our Str multi getlogin ()

Returns the username of the account running the program. This may
not be as secure as using C<getpwuid> on some platforms.

=item kill

 our Bool multi kill ( OS::Signal $signal, Bool :$group, *@pids )
 our Bool multi method kill ( Proc::PID $pid: OS::Signal $signal?, Bool :$group )

Sends the given C<$signal> to the process(es) given and returns a boolean
value indicating success (true) if all of the processes existed and were
sent the signal and failure (false) if any of the processes did not exist
or the signal could not be delivered to them.

The C<$signal> can be initialized from an integer signal number or a
string. Common signals are:

 KILL - stop the process, do not allow it to exit gracefully
 TERM - stop the process, allow it to exit gracefully
 HUP  - Hangup, often used as a request to re-run from scratch
 STOP - Pause execution
 CONT - Continue after a STOP

Consult your operating system documentation for the full list
of signal names and numbers. For compatibility, a signal name
may be prefixed with "SIG".

The method form may omit the signal. In this case, the default signal is
C<'TERM'>.

If the C<:group> named parameter is passed, C<kill> will attempt to
send the signal to a process I<group> rather than a single process.
This functionality is platform-specific.

The special signal C<0> can be sent which does not actually deliver a
signal at all, and is used to determine if processes are still running:

  say "Still running" if $proc.kill(0);

=item run

 our Proc::Status multi run ( ; Str $command, :%env = %*ENV )
 our Proc::Status multi run ( ; Str $path, *@args, :%env = %*ENV )
 our Proc::Status multi run ( Str @path_and_args, :%env = %*ENV )

 our Proc multi run ( ; Str $command, Bool :$bg!, :%env = %*ENV )
 our Proc multi run ( ; Str $path, Bool :$bg!, *@args, :%env = %*ENV )
 our Proc multi run ( Str @path_and_args, Bool :$bg!, :%env = %*ENV )

C<run> executes an external program, and returns control to the caller
once the program has exited.

The default form expects a single string argument which contains the
full command-line. This command-line will be scanned for special
characters that the operating system's shell might interpret such as
C<;> or embedded quotes. If any are found, the command will be run
through a sub-shell in an operating system specific fashion (on
POSIX systems, this means C<sh -c>).

If called like this:

 run( :path<'/some/path'>, 'arg1', 'arg2', ... )

share/Synopsis/S29-functions.pod  view on Meta::CPAN

accept, bind, binmode, chdir, chmod, chown, close, closedir, connect
eof, fcntl, fileno, flock, getc, getsockname, getsockopt, glob, ioctl, link, listen
lstat, mkdir, open, opendir, pipe, print, printf, read, readdir, readline, readlink
readpipe, recv, rename, rewinddir, rmdir, say, seek, seekdir, select, send, setsockopt
shutdown, socket, socketpair, stat, symlink, sysopen, sysread, sysseek
syswrite, tell, telldir, truncate, umask, unlink

=head3 Temporal

The following functions can now be found in or replaced by something in the Temporal
modules.

gmtime, localtime, time

=head3 String

The following functions can now be found in or replaced by something in the String
module.

chop, chomp, index, lc, lcfirst, pack, quotemeta, rindex, split, sprintf, substr, uc,
ucfirst, unpack

=head2 Obsolete Functions

Some of these are obsoleted only as general functions, and are still available by using
the right packages.  Others are obsoleted in that they're keywords, rather than functions
(these are in their own section, below).

=over 4

=item %

 $num1 % $num2

Does a floating point modulo operation, i.e. 5.5 % 1 == 0.5 and 5 % 2.5 == 0.

=item dbmopen, dbmclose

 use DB_File;

=item dump

Dumped.  Restoring from core dumps is in any event not very useful on modern
virtual-memory operating systems.  Startup acceleration should be accomplished
using a precompiler of some kind (details will be very implementation specific),
or a pre-forking daemon such as Perl 5's App::Persistant (which will be an
external module when it is ported).

=item each

See .pairs() method, above.

=item endpwent, endgrent, endservent, endprotoent, endnetent, endhostent

The NameServices role in S16 covers most of these.

=item format, formline

See Exegesis 7.

=item getgrgid, getgrnam, getpwnam, getpwuid

The User and Group roles in S16 cover most of these.

=item getpwent, getgrent, getservent, getnetent, gethostent

The NameServices role in S16 covers most of these.

=item length()

This word is banned in Perl 6.  You must specify units.  In practise, this probably means
you want Str.chars(), although it could be Str.bytes(), or even something else.  See
S32-setting-library/String for details.

=item msgctl, msgget, msgrcv, msgsnd

See IPC::SysV

=item local

Replaced by C<temp> which, unlike C<local>, defaults to not changing the value.

=item lock

See L<S17/Concurrency>. C<lock> has been replaced by
C<is atomic>.

=item pos

There is no C<pos> function in Perl 6 because that would not allow a string
to be shared among threads.  Generally you want to use C<$/.to> for that now,
or keep your own position variable as a lexical.

=item prototype

 &func.meta.signature;
 &func.^signature;

=item ref

There is no ref() any more, since it was almost always used to get
the type name in Perl 5.  If you really want the type name, you can
use C<$var.WHAT.perl>.  If you really want P5 ref
semantics, use C<Perl5::p5ref>.

But if you're just wanting to test against a type, you're likely better off
performing an C<isa> or C<does> or C<can>, or just C<$var ~~ TYPE>.

=item reset

Was there a I<good> use for this?

=item semctl, semget, semop

See IPC::SysV;

=item setpwent, setgrent, setservent, setprotoent, setnetent, sethostent

The NameServices role in S16 covers most of these.

=item shmctl, shmget, shmread, shmwrite



( run in 3.546 seconds using v1.01-cache-2.11-cpan-39bf76dae61 )