Slash Boxes
NOTE: use Perl; is on undef hiatus. You can read content, but you can't post it. More info will be forthcoming forthcomingly.

All the Perl that's Practical to Extract and Report

use Perl Log In

Log In

[ Create a new account ]

Journal of rafael (2125)

Wednesday May 03, 2006
05:15 PM

New tuits

[ #29520 ]
After some hard times (work related, mainly), I happy to announce I seem to have got some tuits back. Here's what I did this evening, implementing a new keyword, state, which is a Perl 6 thing and that appears in the latest perltodo manpage.

$ bleadperl -Mfeature=state -wle 'sub f { state $x = 42; print $x++ } f; f; f'

This, of course, brand new and subject to change; more about that in David Landgren's next wonderful P5P summary!

The Fine Print: The following comments are owned by whoever posted them. We are not responsible for them in any way.
More | Login | Reply
Loading... please wait.
  • An example of how this might be used in Perl6 []

    # Demo of the state() variable declaration.
    # This is also a neat way of doing OO without actually having OO available.
    # Please remember to update t/examples/examples.t and rename
    # examples/output/cashiers if you rename/move this file.

    use v6;

    sub gen_cashier () {
        # This variable corresponds to a class variable.
        # It is shared across all "instances" of gen_cashier().
        state $cash_in_store = 0;