File: test_weak.pl

package info (click to toggle)
munin 2.0.25-1+deb8u3~bpo70+1
  • links: PTS, VCS
  • area: main
  • in suites: wheezy-backports
  • size: 6,184 kB
  • sloc: perl: 11,818; sh: 3,545; java: 1,880; makefile: 767; python: 272
file content (35 lines) | stat: -rw-r--r-- 605 bytes parent folder | download | duplicates (9)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
#! /usr/bin/perl

use warnings;
use strict;

use File::Temp;
use Data::Dumper;
use Storable qw(nstore_fd fd_retrieve);
use Scalar::Util qw(weaken isweak);

my $number = shift || 10;
my $a = {};

for my $i (0 .. $number) {
	$a->{$i} = {
		"$i$i" => "$i$i",
		"$i$i" => "$i$i",
	};
}

for my $i (0 .. $number) {
	$a->{$i}{next} = $a->{ ($i + 1) % $number };
	weaken($a->{$i}{next}) if $ENV{WEAKEN};
}

my $temp_storable = File::Temp->new();

nstore_fd($a, $temp_storable);

for my $j (0 .. ($number * $number)) {
	$temp_storable->seek( 0, SEEK_SET );
	$a = fd_retrieve($temp_storable);
}

print Dumper($a);