Thread Variable in Arbeitsspeicher halten (7 answers)
Opened by pktm at 2010-06-26 15:38

pktm
 2010-06-26 17:41
#139049 #139049
User since
2003-08-07
2921 Artikel
BenutzerIn
[Homepage]
user image
Ah, schön. Bei IPC::SharedLite bin ich über Storable gestolpert, das neheme ich jetzt, weil es so schön einfach ist:

Code: (dl )
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
#!/Perl/bin/perl

use strict;
use warnings;
use Storable qw(store retrieve);

=comment

Store a value:

>perl ser.pl store stored_value
set stored value to stored_value

Retrieve stored value:
>perl ser.pl other_task some_value
other_task: <stored_value, some_value>

=cut

my $task = $ARGV[0];
my $input = $ARGV[1];

if( $task eq 'store' ) {
store( {number => $input}, 'store.txt' );
print "set stored value to $input\n";
}else{
my $ref = retrieve('store.txt');
my $number = $ref->{number};
print "$task: <$number, $input>\n";
}
http://www.intergastro-service.de (mein erstes CMS :) )

View full thread Variable in Arbeitsspeicher halten