[rt-users] Doubt in Perl

Atom Powers APowers at PyramidBrew.com
Fri Jul 1 14:59:58 EDT 2005


# Parameters passed in during an import that we probably don't want to touch,
otherwise 
    foreach my $attr qw(id Creator Created LastUpdated LastUpdatedBy) { 
        $params{$attr} = $args{$attr} if ( $args{$attr} ); 
    } 

It goes something like this:
for each string in the list "(id Creator Created LastUpdated LastUpdatedBy)"
assign it to the variable attr
then get the value of that attribute from the hash table args (if it is
defined) and put it into the hash table params.
 
So if you have a ticket where id is "111", Creator is "me", and Created is
"now" this code will copy those values from the %args hast table into the
%params hast table. But it won't put LastUpdated into %params because it
doesn't have a value associated with it.
 
Check out "Learning Perl" from O'Reilly; it does a good job explaining the
basics of perl, including variables and hash tables.



----
Perfection is just a word I use occasionally with mustard.

Atom Powers
Systems Administrator
Pyramid Breweries Inc.
206.682.8322 x251 

 

________________________________

From: rt-users-bounces at lists.bestpractical.com
[mailto:rt-users-bounces at lists.bestpractical.com] On Behalf Of
Ahalya_Nathan at mudnebr.com
Sent: Friday, July 01, 2005 9:37 AM
To: rt-users at lists.bestpractical.com;
rt-users-bounces at lists.bestpractical.com
Subject: [rt-users] Doubt in Perl



Hi all, 
I am still brushing up on my perl skills and wondering if any of you can tell
me what this piece of code does. 

# Parameters passed in during an import that we probably don't want to touch,
otherwise 
    foreach my $attr qw(id Creator Created LastUpdated LastUpdatedBy) { 
        $params{$attr} = $args{$attr} if ( $args{$attr} ); 
    } 
Thanks,
Ahalya Nathan
Senior Programmer / Analyst
Information Technology, Metropolitan Utilities District 
(402) 449-8218 phone
(402) 449-8131 fax
ahalya_nathan at mudnebr.com
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.bestpractical.com/pipermail/rt-users/attachments/20050701/7d1928bd/attachment.htm>


More information about the rt-users mailing list