Front page | perl.beginners |
Postings from August 2009
Re: two questions
Thread Previous
|
Thread Next
From:
John W. Krahn
Date:
August 5, 2009 07:01
Subject:
Re: two questions
Message ID:
4A7990B0.90204@shaw.ca
Ed Avis wrote:
> sys adm <sysadm <at> computermail.net> writes:
>
>> 1. why perl doesn't have a built-in strip() function?
>> each time I need to say $var =~ s/^\s+|\s+//g to strip
>
> Good question. Perl 6 is fixing this by adding a 'trim' operator.
> The code I use is
>
> for ($var) { s/\A\s+//; s/\s+\z/ }
^^
^^
You have a missing delimiter there.
>> 2. what's the standard module or method to generate a random string, for example
>> the string will be used as part of url.
>
> If you want to use the string in a URL then it cannot be truly random, because
> not every character can appear in a URL.
That does not make sense.
> Why not just generate a random number and use that as the string?
How is that different?
John
--
Those people who think they know everything are a great
annoyance to those of us who do. -- Isaac Asimov
Thread Previous
|
Thread Next