[Linuxtrent] Re: W Perl ;)

  • From: Flavio Visentin <THe_ZiPMaN@xxxxxxxxx>
  • To: linuxtrent@xxxxxxxxxxxxx
  • Date: Thu, 30 Sep 2004 16:47:35 +0200

-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

|     #!/usr/bin/perl
|
|     $b = { "c" => [ { "a" => 1 } ] };
|     $a = [ keys(%{shift(@{$b->{'c'}})}) ];
|     print join("\n", @{$a}), "\n";

$b è una referenza ad un hash.

$b->{"c"} è una referenza ad un array che contiene una referenza ad un
altro hash.

La prima riga è più capibile scritta così:
$b->{"c"}[0]->{"a"} = 1

$a è una referenza ad un array che contiene tutte le chiavi dell'hash
puntato da $b->{"c"}.
quindi ne consegue che $a = [ "a" ]

alla fine viene stampato il valore dell'array separandone gli elementi
con "\n" ed aggiungendo un "\n" alla fine.

Certo che per scrivere a video la stringa "a\n" è un po' lunga la strada
intrapresa :-)

|
|    ma capire che cosa fa non mi pare assolutamente semplice.
|
| 9. Sicuramente c'è altro ma adesso non mi viene in mente...
|
| Ciao

- --
Flavio Visentin

|                     \|||/
|                    @/0.0\@
|                     \ - /
+------------------oOOo---oOOo------------------

There are only 10 types of people in this world:
those who understand binary, and those who don't.

GPG Key: http://www.zipman.it/gpgkey.asc
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.2.5 (GNU/Linux)

iD8DBQFBXByHusUmHkh1cnoRArDdAJ9VEjwVQBQTrel7x8fbuJzHwu3qIQCfTFpT
NLnB5OiUZjn0D0/KsCP1dQY=
=M8Z+
-----END PGP SIGNATURE-----
--
Per iscriversi  (o disiscriversi), basta spedire un  messaggio con OGGETTO
"subscribe" (o "unsubscribe") a mailto:linuxtrent-request@xxxxxxxxxxxxx


Other related posts: