Perl 6
Perl 6 IO Tablet: Revision 37

Overview - Chapter: 0:History, 1:Design, 2:Basics, 3:Var, 4:Op, 5:IO, 6:{}, 7:Sub, 8:OOP, 9:Rx, 10:Meta
Intro - Appendices: A:Index, B:Tables, C:Cook, D:Delta, E:Best of, F:Links




Herbert Breunung: Inside a shell might be a Perl.

This tablet is about the old core business of Perl.

Command Line

The shell, command line (or STDOUT to Perl 5 programmer and $*OUT in Perl 6) is the first and most fundamental communication device for a script with it's user. And most tutorials begin just with putting a line to that black window.

say

say "dear earthlings";

This just drops a quoted string but any other kind of value is possible. say will just append an invisible newline character, according to you operating system. So every time you "say" something, it will start on a fresh line.

You can also give say a list of values. Each item will be taken as an expression, that has to evaluated. The results will be combined, just like with ~ and the \n will be added on the end.

say "dear earthlings, we come from ", $our_home_planet, ",that is ", compute_distance($earth, $our_home_planet), 'parsecs away.';

print

.. does pretty much the same as say, just without the "\n". Maybe you can memorize it with the following thought: Machines to print, character by character without stop and hidden meaning. People on the other hand speak in sentences or speech balloons, which have to be seperated.

printf

It's a print that understands also the syntax of sprintf. Its a very lightweight framework for formated output. If you need more, use formats or even a template engine.

note

Works like say and writes also on the command line, but via the $*ERR handler, formally known as STDERR which can be redirected to other programs who want just listen to you error messages.

warn

The print version that writes to to $*ERR.

prompt

That allows a 2 way communication with the commandline. It does an output like say and waits then for intput, until the user hits the enter key. It returns everything typed, except the trailing enter per default. So unlike Perl 5 you normally don't have to chomp any input from the command line. All following commands behave that way.

$location = prompt "Where is the next service station, we have almost no anti matter left?";

read

$*CWD

Files

file test operators

slurp

lines

open

readline

get

getc

read for files

say for files

open

Synopsis:

open('new', :w).close

given open('foo', :w) { # "Anonymous" filehandle
.say('Hello, world!');
.close
}

Valid modes are:

r : read

w : write

a : append (Note: you must specify "wa", not just "a")

p : pipe

close

rename for files

Directories

dir

mkdir

chdir

chroot

rmdir

rename

Sockets

Processes

run

runinstead

fork

wait

kill


Overview - Chapter: 0:History, 1:Design, 2:Basics, 3:Var, 4:Op, 5:IO, 6:{}, 7:Sub, 8:OOP, 9:Rx, 10:Meta
Intro - Appendices: A:Index, B:Tables, C:Cook, D:Delta, E:Best of, F:Links



Upload Files

Click "Browse" to find the file you want to upload. When you click "Upload file" your file will be uploaded and added to the list of attachments for this page.

Maximum file size: 50MB

 
 
 
File Name Author Date Uploaded Size

Save Page As

Enter a meaningful and distinctive title for your page.

Page Title:

Tip: You'll be able to find this page later by using the title you choose.

Page Already Exists

There is already a page named XXX. Would you like to:

Save with a different name:

Save the page with the name "XXX"

Append your text to the bottom of the existing page named: "XXX"

Upload Files

Click "Browse" to find the file you want to upload. When you click "Add file" this file will be added to the list of attachments for this page, and uploaded when you save the page.

 
 
 
Add Tags

Enter a tag and click "Add tag". The tag will be saved when you save the page.

Tag: 

Suggestions: