Skip site navigation (1)Skip section navigation (2)

FreeBSD Manual Pages

  
 
  

home | help
TemporaryBag(3)	      User Contributed Perl Documentation      TemporaryBag(3)

    my $self = shift;
    my $fn = $self->[FILENAME];
    my $fh = $self->[FILEHANDLE];

    if ($fh) {
	seek $fh, 0, SEEK_END;
	return tell($fh)- $self->[STARTPOS];
    } elsif ($fn) {
	return (-s $fn)	- $self->[STARTPOS];
    } else {
	return length($self->[BUFFER]);
    }

NAME
       Data::TemporaryBag - Handle long	size data using	temporary file .

SYNOPSIS
	 use Data::TemporaryBag;

	 $data = Data::TemporaryBag->new;
	 # add long string
	 $data->add('ABC' x 1000);
	 # You can use an overridden operator
	 $data .= 'DEF'	x 1000;
	 ...
	 $substr = $data->substr(2997, 6);  # ABCDEF

DESCRIPTION
       Data::TemporaryBag module provides a bag	object class handling long
       size data.  The short size data are kept	on memory.  When the data size
       becomes over $Threshold size, they are saved into a temporary file
       internally.

   METHOD
       Data::TemporaryBag->new(	[$data]	)
	   Creates a bag object.

       $bag->clear
	   Clears $bag.

       $bag->add( $data	)
	   Adds	$data to $bag.	You can	use an assignment operator '.='
	   instead.

       $bag->substr( $offset, $length, $replace	)
	   Extracts a substring	out of $bag.  It behaves similar to
	   CORE::substr	except that it can't be	an lvalue.

       $bag->clone
	   Creates a clone of $bag.

       $bag->value
	   Gets	data of	$bag as	a string.  It is possible that the string is
	   extremely long.

       $bag->length
	   Gets	length of data.

       $bag->defined
	   Returns if the data in $bag are defined or not.

       $bag->is_saved
	   Returns the file name if $bag is saved in a temporary file.

   GLOBAL VARIABLES
       $Data::TemporaryBag::Threshold
	   The threshold of the	data size in kilobytes whether saved into file
	   or not.  Default is 10.

       $data::TemporaryBag::MaxOpen
	   The maximum number of the opened temporary files.  Default is 10.

COPYRIGHT
       Copyright 2001 Yasuhiro Sasama (ySas), <ysas@nmt.ne.jp>

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

perl v5.24.1			  2006-01-25		       TemporaryBag(3)

NAME | SYNOPSIS | DESCRIPTION | COPYRIGHT

Want to link to this manual page? Use this URL:
<https://www.freebsd.org/cgi/man.cgi?query=Data::TemporaryBag&sektion=3&manpath=FreeBSD+12.1-RELEASE+and+Ports>

home | help