>>>>> "Bob" == Bob Maccione <[EMAIL PROTECTED]> writes:
Bob> Simple question on some code that I've been looking at (in this case:
Bob> Component::Server::TCP ).
Bob> Is there a good reason for doing the following:
Bob> my $var = delete $param{Fld};
Bob> I see this a lot when parsing the input args and am trying to figure out any
Bob> advantage of doing the delete over just an assignment (ie: $var =
Bob> $param{Fld} )
Bob> example:
Bob> # Extract parameters.
Bob> my $alias = delete $param{Alias};
Bob> my $address = delete $param{Address};
Bob> my $port = delete $param{Port};
Bob> my $domain = delete $param{Domain};
It permits you afterwards to say:
warn "unknown parameters: ", join(" ", sort keys %param)
if keys %param;
Since anything you didn't look for will be "left over".
Caveat executor, though. delete is no longer promised to return the
deleted item(s), as it was in the "old days". It just happens to work
for now.
--
Randal L. Schwartz - Stonehenge Consulting Services, Inc. - +1 503 777 0095
<[EMAIL PROTECTED]> <URL:http://www.stonehenge.com/merlyn/>
Perl/Unix/security consulting, Technical writing, Comedy, etc. etc.
See PerlTraining.Stonehenge.com for onsite and open-enrollment Perl training!