the function:
[sub modify_element
{
my ($element, $new_value) = @_;
if(&pm_check eq "yes")
{
&init($wholeline);
my $s = $input{'session'};
%input = %values;
$input{'session'} = $s;
if ($element ne "")
{$input{$element} = $new_value;}
$input{'action'} = "modified";
&pm_modify;
}
else { &err($error_message{'no permission'});&end; } }]
how can i call this function more than once without my data doubling?
or what can i do?
any suggestions or help is appreciated..
thanks,
Tarek
sub pm_modify
{
foreach (keys %values) {
if (not exists $input{$_}) {
$input{$_} = $values{$_};
}
}
my %before = %values;
$modify = 1;
&pm_delete;
&pm_register;
my $changes = "";
foreach(@base){
if($input{$_} ne $before{$_}){
if($input{$_} eq " " && $before{$_} eq ""){
next;
}
if($_ eq "action"){
next;
}
$changes .= "\n------------------------------\n$_:\nbefore:$before{$_}\nafter:$input{$_}\n";
}
}
#if($changes ne ""){
#&sendemail($from, $from, "Modification Changes for $input{'login'}", $changes);
#}
}
what variable should i initialize or declare as ".
im really new to this so please help..
thanks,
Tarek
foreach $var (keys %input) {
$input{$var} = 'BLAH';
}
I personnally hate it when people use $_ or other crazy variables because they can easily be overwritten or corrupted without you even knowing it!
I suggest leaving Perl's internal variables to perl's functions and use your own on your functions.
Can you post an example of the output this function produces and what you put in as input? Thanks!