Revision 6b293028
Von Moritz Bunkus vor mehr als 17 Jahren hinzugefügt
SL/MoreCommon.pm | ||
---|---|---|
1 |
package SL::MoreCommon; |
|
2 |
|
|
3 |
require Exporter; |
|
4 |
@ISA = qw(Exporter); |
|
5 |
|
|
6 |
@EXPORT = qw(save_form restore_form); |
|
7 |
|
|
8 |
use YAML; |
|
9 |
|
|
10 |
sub save_form { |
|
11 |
$main::lxdebug->enter_sub(); |
|
12 |
|
|
13 |
my $old_form = YAML::Dump($main::form); |
|
14 |
$old_form =~ s|!|!!|g; |
|
15 |
$old_form =~ s|\n|!n|g; |
|
16 |
$old_form =~ s|\r|!r|g; |
|
17 |
|
|
18 |
$main::lxdebug->leave_sub(); |
|
19 |
|
|
20 |
return $old_form; |
|
21 |
} |
|
22 |
|
|
23 |
sub restore_form { |
|
24 |
$main::lxdebug->enter_sub(); |
|
25 |
|
|
26 |
my ($old_form, $no_delete) = @_; |
|
27 |
|
|
28 |
my $form = $main::form; |
|
29 |
|
|
30 |
map { delete $form->{$_}; } keys %{$form} unless ($no_delete); |
|
31 |
|
|
32 |
$old_form =~ s|!r|\r|g; |
|
33 |
$old_form =~ s|!n|\n|g; |
|
34 |
$old_form =~ s|!!|!|g; |
|
35 |
|
|
36 |
my $new_form = YAML::Load($old_form); |
|
37 |
map { $form->{$_} = $new_form->{$_}; } keys %{$new_form}; |
|
38 |
|
|
39 |
$main::lxdebug->leave_sub(); |
|
40 |
} |
|
41 |
|
|
42 |
1; |
bin/mozilla/common.pl | ||
---|---|---|
10 | 10 |
###################################################################### |
11 | 11 |
|
12 | 12 |
use SL::Form; |
13 |
use YAML; |
|
14 |
|
|
15 | 13 |
use SL::Common; |
16 |
|
|
17 |
sub save_form { |
|
18 |
$lxdebug->enter_sub(); |
|
19 |
|
|
20 |
my $old_form = YAML::Dump($form); |
|
21 |
$old_form =~ s|!|!!|g; |
|
22 |
$old_form =~ s|\n|!n|g; |
|
23 |
$old_form =~ s|\r|!r|g; |
|
24 |
|
|
25 |
$lxdebug->leave_sub(); |
|
26 |
|
|
27 |
return $old_form; |
|
28 |
} |
|
29 |
|
|
30 |
sub restore_form { |
|
31 |
$lxdebug->enter_sub(); |
|
32 |
|
|
33 |
my ($old_form, $no_delete) = @_; |
|
34 |
|
|
35 |
map({ delete($form->{$_}); } keys(%{$form})) unless ($no_delete); |
|
36 |
$old_form =~ s|!r|\r|g; |
|
37 |
$old_form =~ s|!n|\n|g; |
|
38 |
$old_form =~ s|!!|!|g; |
|
39 |
my $new_form = YAML::Load($old_form); |
|
40 |
map({ $form->{$_} = $new_form->{$_}; } keys(%{$new_form})); |
|
41 |
|
|
42 |
$lxdebug->leave_sub(); |
|
43 |
} |
|
14 |
use SL::MoreCommon; |
|
44 | 15 |
|
45 | 16 |
sub build_std_url { |
46 | 17 |
$lxdebug->enter_sub(); |
Auch abrufbar als: Unified diff
Die Funtktionen save_form() und restore_form() aus common.pl in ein eigenes Modul verlagert, das sie auch automatisch in den Namensraum des Aufrufers exportiert. Damit können sie auch von den Modulen in SL/ benutzt werden.