.\" Automatically generated by Pod::Man 4.14 (Pod::Simple 3.40) .\" .\" Standard preamble: .\" ======================================================================== .de Sp \" Vertical space (when we can't use .PP) .if t .sp .5v .if n .sp .. .de Vb \" Begin verbatim text .ft CW .nf .ne \\$1 .. .de Ve \" End verbatim text .ft R .fi .. .\" Set up some character translations and predefined strings. \*(-- will .\" give an unbreakable dash, \*(PI will give pi, \*(L" will give a left .\" double quote, and \*(R" will give a right double quote. \*(C+ will .\" give a nicer C++. Capital omega is used to do unbreakable dashes and .\" therefore won't be available. \*(C` and \*(C' expand to `' in nroff, .\" nothing in troff, for use with C<>. .tr \(*W- .ds C+ C\v'-.1v'\h'-1p'\s-2+\h'-1p'+\s0\v'.1v'\h'-1p' .ie n \{\ . ds -- \(*W- . ds PI pi . if (\n(.H=4u)&(1m=24u) .ds -- \(*W\h'-12u'\(*W\h'-12u'-\" diablo 10 pitch . if (\n(.H=4u)&(1m=20u) .ds -- \(*W\h'-12u'\(*W\h'-8u'-\" diablo 12 pitch . ds L" "" . ds R" "" . ds C` "" . ds C' "" 'br\} .el\{\ . ds -- \|\(em\| . ds PI \(*p . ds L" `` . ds R" '' . ds C` . ds C' 'br\} .\" .\" Escape single quotes in literal strings from groff's Unicode transform. .ie \n(.g .ds Aq \(aq .el .ds Aq ' .\" .\" If the F register is >0, we'll generate index entries on stderr for .\" titles (.TH), headers (.SH), subsections (.SS), items (.Ip), and index .\" entries marked with X<> in POD. Of course, you'll have to process the .\" output yourself in some meaningful fashion. .\" .\" Avoid warning from groff about undefined register 'F'. .de IX .. .nr rF 0 .if \n(.g .if rF .nr rF 1 .if (\n(rF:(\n(.g==0)) \{\ . if \nF \{\ . de IX . tm Index:\\$1\t\\n%\t"\\$2" .. . if !\nF==2 \{\ . nr % 0 . nr F 2 . \} . \} .\} .rr rF .\" ======================================================================== .\" .IX Title "Scrappy::Session 3pm" .TH Scrappy::Session 3pm "2021-01-07" "perl v5.32.0" "User Contributed Perl Documentation" .\" For nroff, turn off justification. Always turn off hyphenation; it makes .\" way too many mistakes in technical documents. .if n .ad l .nh .SH "NAME" Scrappy::Session \- Scrappy Scraper Session Handling .SH "VERSION" .IX Header "VERSION" version 0.94112090 .SH "SYNOPSIS" .IX Header "SYNOPSIS" .Vb 2 \& #!/usr/bin/perl \& use Scrappy::Session; \& \& my $session = Scrappy::Session\->new; \& \& \-f \*(Aqscraper.sess\*(Aq ? \& $session\->load(\*(Aqscraper.sess\*(Aq); \& $session\->write(\*(Aqscraper.sess\*(Aq); \& \& $session\->stash(\*(Aqfoo\*(Aq => \*(Aqbar\*(Aq); \& $session\->stash(\*(Aqabc\*(Aq => [(\*(Aqa\*(Aq..\*(Aqz\*(Aq)]); .Ve .SH "DESCRIPTION" .IX Header "DESCRIPTION" Scrappy::Session provides YAML-Based session file handling for saving recorded data across multiple execution using the Scrappy framework. .SS "\s-1ATTRIBUTES\s0" .IX Subsection "ATTRIBUTES" The following is a list of object attributes available with every Scrappy::Session instance. .PP \fIauto_save\fR .IX Subsection "auto_save" .PP The auto_save attribute is a boolean that determines whether stash data is automatically saved to the session file on update. .PP .Vb 1 \& my $session = Scrappy::Session\->new; \& \& $session\->load(\*(Aqscraper.sess\*(Aq); \& $session\->stash(\*(Aqfoo\*(Aq => \*(Aqbar\*(Aq); \& \& # turn auto\-saving off \& $session\->auto_save(0); \& $session\->stash(\*(Aqfoo\*(Aq => \*(Aqbar\*(Aq); \& $session\->write; # explicit write .Ve .PP \fIfile\fR .IX Subsection "file" .PP The file attribute gets/sets the filename of the current session file. .PP .Vb 1 \& my $session = Scrappy::Session\->new; \& \& $session\->load(\*(Aqscraper.sess\*(Aq); \& $session\->write(\*(Aqscraper.sess.bak\*(Aq); \& $session\->file(\*(Aqscraper.sess\*(Aq); .Ve .SH "METHODS" .IX Header "METHODS" .SS "load" .IX Subsection "load" The load method is used to read-in a session file, it returns its data in the structure it was saved-in. .PP .Vb 2 \& my $session = Scrappy::Session\->new; \& my $data = $session\->load(\*(Aqscraper.sess\*(Aq); .Ve .SS "stash" .IX Subsection "stash" The stash method accesses the stash object which is used to store data to be written to the session file. .PP .Vb 2 \& my $session = Scrappy::Session\->new; \& $session\->load(\*(Aqscraper.sess\*(Aq); \& \& $session\->stash(\*(Aqfoo\*(Aq => \*(Aqbar\*(Aq); \& $session\->stash(\*(Aqabc\*(Aq => [(\*(Aqa\*(Aq..\*(Aqz\*(Aq)]); \& $session\->stash\->{123} = [(1..9)]; .Ve .SS "write" .IX Subsection "write" The write method is used to write-out a session file, it saves the data stored in the session stash and it returns the data written upon completion. .PP .Vb 1 \& my $session = Scrappy::Session\->new; \& \& $session\->stash(\*(Aqfoo\*(Aq => \*(Aqbar\*(Aq); \& $session\->stash(\*(Aqabc\*(Aq => [(\*(Aqa\*(Aq..\*(Aqz\*(Aq)]); \& $session\->stash\->{123} = [(1..9)]; \& \& my $data = $session\->write(\*(Aqscraper.sess\*(Aq); .Ve .SH "AUTHOR" .IX Header "AUTHOR" Al Newkirk .SH "COPYRIGHT AND LICENSE" .IX Header "COPYRIGHT AND LICENSE" This software is copyright (c) 2010 by awncorp. .PP This is free software; you can redistribute it and/or modify it under the same terms as the Perl 5 programming language system itself.