get
ErrorsCollection

get

Synthesised documentation from type/independent-routines type/IO/Socket type/IO/Handle type/IO/CatHandle type/IO/Socket/INET

From type/independent-routines

See Original text in context

multi sub get  (IO::Handle:D $fh = $*ARGFILES{ $fh.get  }

This routine is a wrapper for the method of the same name in IO::Handle>. If no Handle is specified, defaults to $*ARGFILES.

From type/IO/Socket

See Original text in context

method get(IO::Socket:D: --> Str:D)

Reads a single line of input from the socket, removing the trailing newline characters (as set by .nl-in). Returns Nil, if no more input is available.

Fails if the socket is not connected.

From type/IO/Handle

See Original text in context

method get(IO::Handle:D: --> Str:D)
multi sub get (IO::Handle $fh = $*ARGFILES --> Str:D)

Reads a single line of input from the handle, removing the trailing newline characters (as set by .nl-in) if the handle's .chomp attribute is set to True. Returns Nil, if no more input is available. The subroutine form defaults to $*ARGFILES if no handle is given.

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

$*IN.get.say;              # Read one line from the standard input 
 
my $fh = open 'filename';
$fh.get.say;               # Read one line from a file 
$fh.close;
 
say get;                   # Read one line from $*ARGFILES 

From type/IO/CatHandle

See Original text in context

method get(IO::CatHandle:D: --> Bool:D)

Returns a single line of input from the handle, with the new line string defined by the value(s) of $.nl-in attribute, which will be removed from the line if $.chomp attribute is set to True. Returns Nil when there is no more input. It is an error to call this method when the handle is :$encoding, resulting in X::IO::BinaryMode exception being thrown.

(my $f1 = 'foo'.IO).spurt: "a\nb\nc";
(my $f2 = 'bar'.IO).spurt: "d\ne";
my $cat = IO::CatHandle.new: $f1$f2;
.say while $_ = $cat.get# OUTPUT: «a␤b␤c␤d␤e␤» 

From type/IO/Socket/INET

See Original text in context

method get()

Reads a line from the socket and returns it as of type Str. Return Nil on end-of-file (EOF).