[LUGOS] perl zanka
Gregor Berginc
gregor.berginc at gmail.com
Thu Jun 16 14:04:55 CEST 2005
On 6/16/05, Dalibor <lugos at ice.si> wrote:
>
> Ker nisem vešč programiranja v perlu bi rabil nasvet. Zanima me kako naj
> izvedem zanko v stilu
> repeat
> until keypressed
Spodnja resitev dela bolj v smislu:
repeat
# delam delam delam...
until enter_pressed
#!/usr/bin/perl
for (my $i = 0; $i < 100; $i++) {
# Tvoje opravilo
print "$i...\n";
# Po izvedbi vsakega koraka preveri, ce je uporabnik kaj vnesel
my $rin = '';
my $input = '';
vec($rin, fileno(STDIN), 1) = 1;
$input = <STDIN> if select($rin, undef, undef, 0.1);
# ce naletis na neprazen string, izstopi iz zanke
if (!($input eq "")) {
last;
}
}
# Postprocesiranje
...
lp,
Gregor
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://liste2.lugos.si/pipermail/lugos-list/attachments/20050616/47b76e29/attachment.htm
More information about the lugos-list
mailing list