The London Perl and Raku Workshop takes place on 26th Oct 2024. If your company depends on Perl, please consider sponsoring and/or attending.

NAME

Scrappy::Session - Scrappy Session Storage Mechanism

VERSION

version 0.9111110

SYNOPSIS

    #!/usr/bin/perl
    use Scrappy;

    my  $session = Scrappy::Session->new;
        $session->load('file.yml');
        $session->stash('foo' => 123); # writes back to file.yml automatically
        $session->write('new_file.yml'); # writes new file based on memory

DESCRIPTION

Scrappy::Session provides Scrappy with methods for storing stash and cookie data in a session (YAML) file for sharing important data across executions.

METHODS

load

The load method is used to read the specified session file.

    my  $session = Scrappy::Session->new;
    my  $data = $session->load('session.yml');

stash

The stash method sets a stash (shared) variable or returns a reference to the entire stash object.

    my  $session = Scrappy::Session->new;
        $session->stash(age => 31);
        
    print 'stash access works'
        if $session->stash('age') == $session->stash->{age};
    
    my @array = (1..20);
    $session->stash(integers => [@array]);

write

The write method is used to write the specified session file.

    my  $session = Scrappy::Session->new;
        $session->write('file.yml');

AUTHOR

Al Newkirk <awncorp@cpan.org>

COPYRIGHT AND LICENSE

This software is copyright (c) 2010 by awncorp.

This is free software; you can redistribute it and/or modify it under the same terms as the Perl 5 programming language system itself.