nataraj: (Default)
[personal profile] nataraj
Хочу создать строку из N пробелов. Можно ли это сделать эффективнее чем в цикле добавлять по пробелу? (сишную вставку писать не хочу) Может быть есть готовая функция? ;-)

Date: 2007-06-16 09:01 am (UTC)
From: [identity profile] maravan.livejournal.com
#!perl -w
use strict;

my $n = 50;
my $spaces = ' ' x $n;

Date: 2007-06-16 09:23 am (UTC)
ext_613079: Default userpic (Default)
From: [identity profile] shaplov.livejournal.com
О! Работает!
А в каком месте об этом можно почитать?

Date: 2007-06-16 09:40 am (UTC)
vitus_wagner: My photo 2005 (Default)
From: [personal profile] vitus_wagner
Коля, может тебе Camel book бумажную почитать дать?

Date: 2007-06-16 09:50 am (UTC)
ext_613079: Default userpic (Default)
From: [identity profile] shaplov.livejournal.com
;-)
В свое время Белявский каждый второй мой вопрос встречал словами "Коля, купис себе Вюрблюда"

Проблема в том, что я его последовательно читать не смогу, а для ряда задач, для которых поисковая фраза неочивидна, так же и не очевиден и метод поиска в Вюрблюде... :-/

Поэтому увы, время от времени у меня возникают такие странные воросы. Слава богу что сейчас очень редко ;-)

Date: 2007-06-16 10:20 am (UTC)
From: [identity profile] maravan.livejournal.com
Купи тогда perl cookbook (я уж не помню, что там за зверюга).

Date: 2007-06-16 10:23 am (UTC)
ext_613079: Default userpic (Default)
From: [identity profile] shaplov.livejournal.com
Там баран...

Я ее не только купил, но и попытался почитать... В течении страницы читал рассуждения американского автора на тему, как его жена готовит русский борщ и не кладет в него при этом свеклы... А потом мне надоели, и я читать бросил ;-)

Date: 2007-06-16 10:36 am (UTC)
From: [identity profile] maravan.livejournal.com
точно, баран..
а вот как раз её-то можно и не читать линейно :)

Date: 2007-06-16 01:40 pm (UTC)
From: [identity profile] alexkuklin.livejournal.com
man perlop, вообще-то

Multiplicative Operators

Binary ``*'' multiplies two numbers.

Binary ``/'' divides two numbers.

Binary ``%'' computes the modulus of two numbers. Given integer operands $a and $b: If $b is positive, then $a % $b is $a minus the largest multiple of $b that is not greater than $a. If $b is negative, then $a % $b is $a minus the smallest multiple of $b that is not less than $a (i.e. the result will be less than or equal to zero). Note that when use integer is in scope, ``%'' gives you direct access to the modulus operator as implemented by your C compiler. This operator is not as well defined for negative operands, but it will execute faster.

Binary ``x'' is the repetition operator. In scalar context or if the left operand is not enclosed in parentheses, it returns a string consisting of the left operand repeated the number of times specified by the right operand. In list context, if the left operand is enclosed in parentheses or is a list formed by qw/STRING/, it repeats the list. If the right operand is zero or negative, it returns an empty string or an empty list, depending on the context.


print '-' x 80; # print row of dashes

Date: 2007-06-16 09:24 am (UTC)
ext_613079: Default userpic (Default)
From: [identity profile] shaplov.livejournal.com
Хотя, нет, вопрос глуп. Где читать -- понятно ;-)

Date: 2007-06-16 09:35 am (UTC)
From: [identity profile] maravan.livejournal.com
"-Папа, как работает телевизор?
-RTFM!
-(грустно) man что? :)

Profile

nataraj: (Default)
Swami Dhyan Nataraj

July 2024

S M T W T F S
 123456
789 10111213
14151617181920
21222324252627
28293031   

Most Popular Tags

Style Credit

Expand Cut Tags

No cut tags
Page generated Jan. 20th, 2026 09:28 pm
Powered by Dreamwidth Studios