Re: OT programming languages/ systems for advanced applications on Linux
On 2011-12-24 23:43:18 +0800, lina wrote:
> Tonight I am pretty free, so started to read something about perl.
>
> #!/usr/bin/perl
>
> print "Hello World! \n";
>
> $a = 3;
>
> print "$a \n";
>
> @food = {"apples", "pears", "eels"};
I suppose you want:
@food = ("apples", "pears", "eels");
{...} is used for a hash reference, and [...] for an array reference.
> @music = {"whistel", "flute"};
>
> @moremusic = {"organ", @music, "harp"};
Ditto.
> push(@food, "eggs");
>
> print @food;
> print "@food";
>
> I am so CONFUSED why the output is:
> Hello World!
> 3
> HASH(0x19ec998)eggsHASH(0x19ec998) eggs
print @food;
gives
HASH(0x19ec998)eggs
(because it contains a hash reference and "eggs"), without a newline.
print "@food";
gives
HASH(0x19ec998) eggs
(same thing, but with a space between the elements).
I suggest that you read more about perl ("man perl" tells you what
you can read...).
--
Vincent Lefèvre <vincent@vinc17.net> - Web: <http://www.vinc17.net/>
100% accessible validated (X)HTML - Blog: <http://www.vinc17.net/blog/>
Work: CR INRIA - computer arithmetic / Arénaire project (LIP, ENS-Lyon)
Reply to: