Permalink
Browse files

gobal overhaul: make private lexical variables more private

  • Loading branch information...
1 parent 9eaceae commit 8f074e69c13958de2050d88f4cfeaa976995acdb @marschap marschap committed Dec 28, 2012
Showing with 19 additions and 29 deletions.
  1. +4 −8 lib/LWP/Protocol/ldap.pm
  2. +5 −7 lib/Net/LDAP.pm
  3. +4 −6 lib/Net/LDAP/Entry.pm
  4. +6 −8 lib/Net/LDAP/LDIF.pm
View
12 lib/LWP/Protocol/ldap.pm
@@ -151,10 +151,9 @@ sub request {
require JSON;
my $entry;
- my $index;
my %objects;
- for ($index = 0 ; $entry = $mesg->entry($index); $index++) {
+ for (my $index = 0 ; $entry = $mesg->entry($index); $index++) {
my $dn = $entry->dn;
$objects{$dn} = {};
@@ -172,23 +171,20 @@ sub request {
$content = "<head><title>Directory Search Results</title></head>\n<body>";
for ($index = 0 ; $entry = $mesg->entry($index); $index++) {
- my $attr;
-
- $content .= $index ? qq{<tr><th colspan="2"><hr>&nbsp</tr>\n} : "<table>";
+ $content .= $index ? qq{<tr><th colspan="2"><hr>&nbsp</tr>\n} : '<table>';
$content .= qq{<tr><th colspan="2">} . $entry->dn . "</th></tr>\n";
- foreach $attr ($entry->attributes) {
+ foreach my $attr ($entry->attributes) {
my $vals = $entry->get_value($attr, asref => 1);
- my $val;
$content .= q{<tr><td align="right" valign="top"};
$content .= q{ rowspan="} . scalar(@$vals) . q{"}
if (@$vals > 1);
$content .= ">" . $attr . "&nbsp</td>\n";
my $j = 0;
- foreach $val (@$vals) {
+ foreach my $val (@$vals) {
$val = qq!<a href="$val">$val</a>! if $val =~ /^https?:/;
$val = qq!<a href="mailto:$val">$val</a>! if $val =~ /^[-\w]+\@[-.\w]+$/;
$content .= "<tr>" if $j++;
View
12 lib/Net/LDAP.pm
@@ -575,17 +575,15 @@ sub modify {
my @ops;
my $opcode;
- my $op;
if (exists $arg->{changes}) {
- my $chg;
my $opcode;
my $j = 0;
while($j < @{$arg->{changes}}) {
return _error($ldap, $mesg, LDAP_PARAM_ERROR,"Bad change type '" . $arg->{changes}[--$j] . "'")
unless defined($opcode = $opcode{$arg->{changes}[$j++]});
- $chg = $arg->{changes}[$j++];
+ my $chg = $arg->{changes}[$j++];
if (ref($chg)) {
my $i = 0;
while ($i < @$chg) {
@@ -602,14 +600,13 @@ sub modify {
}
}
else {
- foreach $op (qw(add delete replace increment)) {
+ foreach my $op (qw(add delete replace increment)) {
next unless exists $arg->{$op};
my $opt = $arg->{$op};
my $opcode = $opcode{$op};
- my($k,$v);
if (ref($opt) eq 'HASH') {
- while (($k,$v) = each %$opt) {
+ while (my ($k,$v) = each %$opt) {
push @ops, {
operation => $opcode,
modification => {
@@ -620,7 +617,8 @@ sub modify {
}
}
elsif (ref($opt) eq 'ARRAY') {
- $k = 0;
+ my $k = 0;
+
while ($k < @{$opt}) {
my $attr = ${$opt}[$k++];
my $val = $opcode == 1 ? [] : ${$opt}[$k++];
View
10 lib/Net/LDAP/Entry.pm
@@ -320,7 +320,6 @@ sub dump {
print $fh "-" x 72,"\n";
print $fh "dn:",$asn->{objectName},"\n\n" if $asn->{objectName};
- my($attr,$val);
my $l = 0;
for (keys %{ $self->{attrs} ||= _build_attrs($self) }) {
@@ -329,12 +328,11 @@ sub dump {
my $spc = "\n " . " " x $l;
- foreach $attr (@{$asn->{attributes}}) {
- $val = $attr->{vals};
+ foreach my $attr (@{$asn->{attributes}}) {
+ my $val = $attr->{vals};
printf $fh "%${l}s: ", $attr->{type};
- my($i,$v);
- $i = 0;
- foreach $v (@$val) {
+ my $i = 0;
+ foreach my $v (@$val) {
print $fh $spc if $i++;
print $fh $v;
}
View
14 lib/Net/LDAP/LDIF.pm
@@ -305,11 +305,10 @@ sub _read_entry {
my @attr;
my $last = "";
my $vals = [];
- my $line;
my $attr;
my $xattr;
- foreach $line (@ldif) {
+ foreach my $line (@ldif) {
$line =~ s/^([-;\w]+):([\<\:]?)\s*// &&
(($attr, $xattr) = ($1, $2)) or next;
@@ -395,9 +394,9 @@ sub _wrap {
sub _write_attr {
my($attr,$val,$wrap,$lower) = @_;
- my $v;
my $res = 1; # result value
- foreach $v (@$val) {
+
+ foreach my $v (@$val) {
my $ln = $lower ? lc $attr : $attr;
$v = Encode::encode_utf8($v)
@@ -423,10 +422,10 @@ sub _cmpAttrs {
sub _write_attrs {
my($entry,$wrap,$lower,$sort) = @_;
my @attributes = $entry->attributes();
- my $attr;
my $res = 1; # result value
+
@attributes = sort _cmpAttrs @attributes if ($sort);
- foreach $attr (@attributes) {
+ foreach my $attr (@attributes) {
my $val = $entry->get_value($attr, asref => 1);
$res &&= _write_attr($attr,$val,$wrap,$lower);
}
@@ -486,7 +485,6 @@ sub write_version {
sub _write_entry {
my $self = shift;
my $change = shift;
- my $entry;
my $wrap = int($self->{wrap});
my $lower = $self->{lowercase};
my $sort = $self->{sort};
@@ -500,7 +498,7 @@ sub _write_entry {
my $saver = SelectSaver->new($self->{fh});
my $fh = $self->{fh};
- foreach $entry (@_) {
+ foreach my $entry (@_) {
unless (ref $entry) {
$self->_error("Entry '$entry' is not a valid Net::LDAP::Entry object.");
$res = 0;

0 comments on commit 8f074e6

Please sign in to comment.