Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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

Tags:

syntax

perl

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";```

like image 700
Benjy Strauss Avatar asked Sep 22 '19 01:09

Benjy Strauss


1 Answers

$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
like image 56
ikegami Avatar answered Nov 14 '22 07:11

ikegami