Andrew Metcalfe wrote at Mon, 02 Sep 2002 20:28:43 +0200: > I'm a MS and Java developer, trying to debug some perl code.
Perl is *very* different to Java. Better start with a Perl tutorial. Please look also first to the excellent answer of Jeff, as I won't re-explain what Jeff already has done. I'll try to write a Java pseudocode translation: > I'm generally confused over a few syntax issues.... > > In the line: > > my $self = { > LOCATION => { > USERNAME => $options{user_field} || 'username', > BILLING => $options{bill_field} || 'accounts', > INACTIVE => $options{inactive_field} || 'inactive', > }, public class ClassName { Map location; public ClassName(Map options) { location = new HashMap(); String username = options.get("user_field")); String billing = options.get("bill_field"); String inactive = options.get("inactive_field"); if (username == NULL) { username = "username"; } if (billing == NULL) { billing = "accounts"; } if (inactive == NULL) { inactive = "inactive"; } location.put("USERNAME", username); location.put("BILLING", billing); location.put("INACTIVE", inactive); } } [ugly] Could be that you would write an own LocationClass in Java, but I found already the above too long to type :-) > I'm also seeing code like: > > if ($self->{PRESENT}->{$self->{LOCATION}{INACTIVE}} && > $user_data->{$self->{LOCATION}{INACTIVE}} > ){ Similar to if ((this.present.get(this.location.get("inactive") != NULL) && (userData.get(this.location.get("inactive") != NULL))) { ... However, there's in Perl and in Java doubled code. Here's a real reason for debugging. In Perl you can avoid it with: my $inactive = $self->{LOCATION}{INACTIVE}; if ($self->PRESENT->{$inactive} && $user_data->{$inactive}) { ... } > .deletia. ^^^^^^^^^ That I also don't understand. > } > Greetings, Janek -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]