Benjy Strauss
Benjy Strauss

Reputation: 99

Perl: What's the meaning of $hashName{"a","b","c"} = "d";?

I'm trying to convert a large perl program to Java. In an initialization function, it creates a hash using parentheses and then starts assigning values. But then the keys become pairs and triplets of comma-separated strings. What does it mean?

 %par=( ...  )

 $par{"symbolChainAny"}=     "*";   # chain name if ...
 $par{"acc2Thresh"}=         16;    # threshold for...
 $par{"txt","copyright"}=       "elided";
 $par{"txt","contactEmail"}=    "elided";

 $par{"txt","modepred","sec"}=  "prediction of secondary structure";
 $par{"txt","modepred","cap"}=  "prediction of secondary structure caps";```

Upvotes: 5

Views: 141

Answers (1)

ikegami
ikegami

Reputation: 386541

$foo{$x, $y, $z}

is equivalent to

$foo{join($;, $x, $y, $z)}

where $; defaults to a control character ("\x1C").


Not just similar...

$ diff \
   <( perl -MO=Concise,-exec -e'$foo{$x,$y,$z}' 2>&1 ) \
   <( perl -MO=Concise,-exec -e'$foo{join($;,$x,$y,$z)}' 2>&1 ) \
   && echo identical
identical

Upvotes: 9

Related Questions