line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
# |
2
|
|
|
|
|
|
|
# This file is part of Language::Befunge. |
3
|
|
|
|
|
|
|
# Copyright (c) 2001-2009 Jerome Quelin, all rights reserved. |
4
|
|
|
|
|
|
|
# |
5
|
|
|
|
|
|
|
# This program is free software; you can redistribute it and/or modify |
6
|
|
|
|
|
|
|
# it under the same terms as Perl itself. |
7
|
|
|
|
|
|
|
# |
8
|
|
|
|
|
|
|
# |
9
|
|
|
|
|
|
|
|
10
|
|
|
|
|
|
|
package Language::Befunge::lib::EVAR; |
11
|
|
|
|
|
|
|
|
12
|
1
|
|
|
1
|
|
4877
|
use strict; |
|
1
|
|
|
|
|
3
|
|
|
1
|
|
|
|
|
108
|
|
13
|
1
|
|
|
1
|
|
7
|
use warnings; |
|
1
|
|
|
|
|
3
|
|
|
1
|
|
|
|
|
534
|
|
14
|
|
|
|
|
|
|
|
15
|
0
|
|
|
0
|
1
|
|
sub new { return bless {}, shift; } |
16
|
|
|
|
|
|
|
|
17
|
|
|
|
|
|
|
|
18
|
|
|
|
|
|
|
# -- env vars |
19
|
|
|
|
|
|
|
|
20
|
|
|
|
|
|
|
# |
21
|
|
|
|
|
|
|
# 0gnirts = G(0gnirts) |
22
|
|
|
|
|
|
|
# |
23
|
|
|
|
|
|
|
# Get the value of an environment variable. |
24
|
|
|
|
|
|
|
# |
25
|
|
|
|
|
|
|
sub G { |
26
|
0
|
|
|
0
|
1
|
|
my ($self, $lbi) = @_; |
27
|
0
|
|
|
|
|
|
my $ip = $lbi->get_curip; |
28
|
0
|
|
|
|
|
|
my $k = $ip->spop_gnirts; |
29
|
0
|
|
|
|
|
|
$ip->spush( 0 ); |
30
|
0
|
|
|
|
|
|
$ip->spush( map { ord } split //, reverse $ENV{$k} ); |
|
0
|
|
|
|
|
|
|
31
|
|
|
|
|
|
|
} |
32
|
|
|
|
|
|
|
|
33
|
|
|
|
|
|
|
|
34
|
|
|
|
|
|
|
# |
35
|
|
|
|
|
|
|
# $n = N() |
36
|
|
|
|
|
|
|
# |
37
|
|
|
|
|
|
|
# get the number of environment variables |
38
|
|
|
|
|
|
|
# |
39
|
|
|
|
|
|
|
sub N { |
40
|
0
|
|
|
0
|
1
|
|
my ($self, $lbi) = @_; |
41
|
0
|
|
|
|
|
|
$lbi->get_curip->spush( scalar keys %ENV ); |
42
|
|
|
|
|
|
|
} |
43
|
|
|
|
|
|
|
|
44
|
|
|
|
|
|
|
|
45
|
|
|
|
|
|
|
# |
46
|
|
|
|
|
|
|
# P( 0gnirts ) |
47
|
|
|
|
|
|
|
# |
48
|
|
|
|
|
|
|
# update an environment variable (arg is of the form: name=value) |
49
|
|
|
|
|
|
|
# |
50
|
|
|
|
|
|
|
sub P { |
51
|
0
|
|
|
0
|
1
|
|
my ($self, $lbi) = @_; |
52
|
0
|
|
|
|
|
|
my $ip = $lbi->get_curip; |
53
|
0
|
|
|
|
|
|
my $str = $ip->spop_gnirts; |
54
|
0
|
|
|
|
|
|
my ($k, $v) = split /=/, $str; |
55
|
0
|
|
|
|
|
|
$ENV{$k} = $v; |
56
|
|
|
|
|
|
|
} |
57
|
|
|
|
|
|
|
|
58
|
|
|
|
|
|
|
|
59
|
|
|
|
|
|
|
# |
60
|
|
|
|
|
|
|
# 0gnirts = V($n) |
61
|
|
|
|
|
|
|
# |
62
|
|
|
|
|
|
|
# Get the nth environment variable (form: name=value). |
63
|
|
|
|
|
|
|
# |
64
|
|
|
|
|
|
|
sub V { |
65
|
0
|
|
|
0
|
1
|
|
my ($self, $lbi) = @_; |
66
|
0
|
|
|
|
|
|
my $ip = $lbi->get_curip; |
67
|
0
|
|
|
|
|
|
my $n = $ip->spop; |
68
|
0
|
0
|
|
|
|
|
if ( $n >= scalar keys %ENV ) { |
69
|
0
|
|
|
|
|
|
$ip->dir_reverse; |
70
|
0
|
|
|
|
|
|
return; |
71
|
|
|
|
|
|
|
} |
72
|
0
|
|
|
|
|
|
my @keys = sort keys %ENV; |
73
|
0
|
|
|
|
|
|
my $k = $keys[$n]; |
74
|
0
|
|
|
|
|
|
$ip->spush( 0 ); |
75
|
0
|
|
|
|
|
|
$ip->spush( map { ord } split //, reverse "$k=$ENV{$k}" ); |
|
0
|
|
|
|
|
|
|
76
|
|
|
|
|
|
|
} |
77
|
|
|
|
|
|
|
|
78
|
|
|
|
|
|
|
|
79
|
|
|
|
|
|
|
1; |
80
|
|
|
|
|
|
|
|
81
|
|
|
|
|
|
|
__END__ |