🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: pl.comp.lang.perl
Article #52226

Re: Perl cwiczenia...

#52226
From: Sl
Date: Sun, 22 May 2011 20:12
39 lines
1837 bytes
W dniu 2011-05-22 22:03, Adam Osuchowski pisze:
>> #v+
>> #!/usr/bin/perl
>> $liczba_dni = 30;
>> $nazwa_zmiennej = "liczba_dni";
>> print $$nazwa_zmiennej, "\n";
>> #v-
> 
> Jak nie działa, jak działa? Masz jakiś komunikat o błędzie?
> 

Faktycznie działa, sorry za spam :) Ja miałem lekka modyfikację którą
nie usunąłem ze skryptu testując:

#v+
#!/usr/bin/perl
my $liczba_dni = 30;
my $nazwa_zmiennej = "liczba_dni";
print $$nazwa_zmiennej, "\n";
#v-

I na wyjściu otrzymywałem coś takiego:

$ ./test.pl

$

Poza tym jak dodaję use strict i use warnings to powyższy kod zwraca
komunikat:

$ ./test.pl
Can't use string ("liczba_dni") as a SCALAR ref while "strict refs" in
use at ./test.pl line 6.

Pytanko więc jak powinien wyglądać ten kod aby się nie czepiał ;)

-- 
pzdr.
sl@er
Technical Details
Message-ID: <irbqnb$9h$1@news.vectranet.pl>
Path: mbox-mo1.pugleaf.net!news-archive.icm.edu.pl!news.rmf.pl!nf1.ipartners.pl!ipartners.pl!news.nask.pl!news.nask.org.pl!plix.pl!newsfeed1.plix.pl!news.vectranet.pl!not-for-mail
References: <irbpsa$pab$1@news.vectranet.pl> <20110522200349.6b8b4567@polsl.pl>

Show Full Headers
Complete Article Headers
Path: mbox-mo1.pugleaf.net!news-archive.icm.edu.pl!news.rmf.pl!nf1.ipartners.pl!ipartners.pl!news.nask.pl!news.nask.org.pl!plix.pl!newsfeed1.plix.pl!news.vectranet.pl!not-for-mail
From: "Sl@eR" <future_with_off_spam@nospam.com>
Newsgroups: pl.comp.lang.perl
Subject: Re: Perl cwiczenia...
Date: Sun, 22 May 2011 22:12:28 +0200
Organization: VectraNET - http://www.vectranet.pl
Lines: 39
Message-ID: <irbqnb$9h$1@news.vectranet.pl>
References: <irbpsa$pab$1@news.vectranet.pl> <20110522200349.6b8b4567@polsl.pl>
NNTP-Posting-Host: 082139015185.jeleniagora.vectranet.pl
Mime-Version: 1.0
X-Trace: news.vectranet.pl 1306095147 305 82.139.15.185 (22 May 2011 20:12:27 GMT)
X-Complaints-To: usenet@news.vectranet.pl
NNTP-Posting-Date: Sun, 22 May 2011 20:12:27 +0000 (UTC)
User-Agent: Mozilla/5.0 (Windows; U; Windows NT 5.1; pl; rv:1.9.2.17) Gecko/20110414 Thunderbird/3.1.10
In-Reply-To: <20110522200349.6b8b4567@polsl.pl>
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit