The print routine

Combined from primary sources listed below.

In role IO::Socket ( Type/IO/Socket )§

See primary docmentation in context for method print.

method print§

method print(IO::Socket:D: Str(Cool$string)

Writes the supplied string to the socket, thus sending it to other end of the connection. The binary version is method write.

Fails if the socket is not connected.

In class IO::Socket::Async ( Type/IO/Socket/Async )§

See primary docmentation in context for method print.

method print-to§

method print-to(IO::Socket::Async:D: Str() $host, Int() $port, Str() $str --> Promise)

This is the equivalent of print for UDP sockets that have been created with the udp method, it will try send a UDP message of $str to the specified $host and $port returning a Promise that will be kept when the data is successfully sent or broken if it was unable to send the data. In order to send to a broadcast address the :broadcast flag must have been specified when the socket was created.

In class IO::Socket::Async ( Type/IO/Socket/Async )§

See primary docmentation in context for method print.

method print§

method print(IO::Socket::Async:D: Str $str --> Promise)

Attempt to send $str on the IO::Socket::Async that will have been obtained indirectly via connect or listen, returning a Promise that will be kept with the number of bytes sent or broken if there was an error sending.

In class Proc::Async ( Type/Proc/Async )§

See primary docmentation in context for method print.

method print§

method print(Proc::Async:D: Str() $str, :$scheduler = $*SCHEDULER)

Write the text data in $str to the standard input stream of the external program, encoding it as UTF-8.

Returns a Promise that will be kept once the data has fully landed in the input buffer of the external program.

The Proc::Async object must be created for writing (with Proc::Async.new(:w, $path, @args)). Otherwise an X::Proc::Async::OpenForWriting exception will the thrown.

start must have been called before calling method print, otherwise an X::Proc::Async::MustBeStarted exception is thrown.

In Independent routines ( Type/independent-routines )§

See primary docmentation in context for sub print.

sub print§

multi print(**@args --> True)
multi print(Junction:D --> True)

Prints the given text on standard output (the $*OUT filehandle), coercing non-Str objects to Str by calling .Str method. Junction arguments autothread and the order of printed strings is not guaranteed.

print "Hi there!\n";       # OUTPUT: «Hi there!␤»
print "Hi there!";         # OUTPUT: «Hi there!»
print [1, 2, 3];           # OUTPUT: «1 2 3»
print "Hello" | "Goodbye"# OUTPUT: «HelloGoodbye»

To print text and include the trailing newline, use put.

In class Mu ( Type/Mu )§

See primary docmentation in context for method print.

method print§

multi method print(--> Bool:D)

Prints value to $*OUT after stringification using .Str method without adding a newline at end.

"abc\n".print;          # OUTPUT: «abc␤»

In class IO::Handle ( Type/IO/Handle )§

See primary docmentation in context for method print.

method print§

multi method print(**@text --> True)
multi method print(Junction:D --> True)

Writes the given @text to the handle, coercing any non-Str objects to Str by calling .Str method on them. Junction arguments autothread and the order of printed strings is not guaranteed. See write to write bytes.

Attempting to call this method when the handle is in binary mode will result in X::IO::BinaryMode exception being thrown.

my $fh = 'path/to/file'.IO.open: :w;
$fh.print: 'some text';
$fh.close;

In class IO::Handle ( Type/IO/Handle )§

See primary docmentation in context for method print.

method print-nl§

method print-nl(IO::Handle:D: --> True)

Writes the value of $.nl-out attribute into the handle. This attribute, by default, is , but see the page on newline for the rules it follows in different platforms and environments.

Attempting to call this method when the handle is in binary mode will result in X::IO::BinaryMode exception being thrown.

my $fh = 'path/to/file'.IO.open: :w, :nl-out("\r\n");
$fh.print: "some text";
$fh.print-nl# prints \r\n
$fh.close;