To pipe in a string to a Raku program, you can use the echo
command to output the string and pipe it to the Raku program. For example, if your Raku program is called my_program.raku
, you can use the following command:
echo "my string" | raku my_program.raku
Alternatively, you can pass the string as an argument to the Raku program by using the -e
option with the echo
command, like this:
echo -e "my string" | raku my_program.raku
This will pass the string "my string" to the Raku program, which you can then access using the @*ARGS
array variable. For example, you can print the string using the following code in your Raku program:
# Print the first argument passed to the program
say @*ARGS[0];
You can also use the $*IN
variable to read from the standard input stream in a Raku program, like this:
# Read a line from the standard input stream
my $line = $*IN.get;
# Print the line that was read
say $line;
In this case, you don't need to use the echo
command to pipe the string to the Raku program. Instead, you can simply use the |
(pipe) operator to redirect the output of the echo command to the Raku program, like this:
echo "my string" | raku my_program.raku
The Raku program will then read the string from the standard input stream and print it using the say function.