Form of I/O statements

2011-07-12 Thread Parrot Raiser
To print the contents of $skeleton to a file whose name is in
$new_file, what should the code look like? I cannot find an example in
the tests.

Printing to STDOUT (by default) works; every attempt to write to a
named file has failed. Is this another Not Yet Implemented?

Executing this code:

my $skeleton = bones\n;
my $new_file = x_file;
my $handle   = open($new_file, :w);
$handle.print $skeleton;

produces

===SORRY!===
Confused at line 4, near $handle.pr


Re: Form of I/O statements

2011-07-12 Thread Moritz Lenz

Am 11.07.2011 23:27, schrieb Parrot Raiser:

Printing to STDOUT (by default) works; every attempt to write to a
named file has failed. Is this another Not Yet Implemented?


No, you just didn't get the syntax right :-)


Executing this code:

my $skeleton = bones\n;
my $new_file = x_file;
my $handle   = open($new_file, :w);
$handle.print $skeleton;


'print' is just a method on $handle, and method call with arguments must 
be written as either


$handle.print(arguments here)

or

$handle.print: arguments here

(note the colon)

Rakudo's error message isn't very good though, STD gives you this error 
message:


Two terms in a row (method call requires colon or parens to take arguments)

Sorry for the inconvenience.

Cheers,
Moritz