> "sa" == sys adm writes:
sa> 1. why perl doesn't have a built-in strip() function? each time I
sa> need to say $var =~ s/^\s+|\s+//g to strip the blank space before
sa> and after the variable, specially if this is a CGI var.
because it is so easy to write a strip thing with regexes. a
sys adm wrote:
1. why perl doesn't have a built-in strip() function?
Why doesn't BASIC have built-in regular expressions? Why doesn't C have
built-in strings? Why doesn't $LANGUAGE have built-in $FEATURE?
Because that is the way the language was designed.
each time I need
to say $var =
sys adm 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/ }
>2. what's the standard m
On Wed, Aug 5, 2009 at 05:12, Ed Avis wrote:
> sys adm 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
Ed Avis wrote:
sys adm 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/ }
On Wed, Aug 5, 2009 at 10:01, John W. Krahn wrote:
snip
>> 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.
snip
I believe he/she meant that not every character is allowed in a regex,
so you
Chas. Owens wrote:
On Wed, Aug 5, 2009 at 10:01, John W. Krahn wrote:
snip
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.
snip
I believe he/she meant that not every character is allowed in a reg
Chas. Owens wrote:
On Wed, Aug 5, 2009 at 10:01, John W. Krahn wrote:
snip
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.
snip
I believe he/she meant that not every character is allowed in a reg
On Wed, Aug 5, 2009 at 11:06, John W. Krahn wrote:
> Chas. Owens wrote:
>>
>> On Wed, Aug 5, 2009 at 10:01, John W. Krahn wrote:
>> snip
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
"John W. Krahn"
To: Perl Beginners
Subject: Re: two questions
Date: Tue, 04 Aug 2009 23:24:56 -0700
sys adm wrote:
>
> 1. why perl doesn't have a built-in strip() function?
Why doesn't BASIC have built-in regular expressions? Why doesn't C have
built-in strings?
On Thu Aug 06 2009 @ 2:29, sys adm wrote:
> I do hate to write s/^\s+|\s+$//g for each and each time,just got tired of it.
> So I hope perl can have that a string operator, since many script languages
> have that, and it's used universally.
Write the subroutine once, and then you won't have to d
> On Thu, Aug 6, 2009 at 11:15, Bryan R Harris
> wrote:
>>
According to the FAQ you want to do it like this:
s/^\s+//, s/\s+$// for $var;
>>
>>
>> I can't find documentation of this notation anywhere, i.e. the comma between
>> statements with a trailing for.
>>
>> John, where d
> "BRH" == Bryan R Harris writes:
BRH> For some reason the back of my brain thinks if I knew perl as
BRH> well as you two seem to I could easily make all the money I
BRH> wanted. Just between you and me =), is that true??
it would be true if you were very good in any language, not jus
On Thu, Aug 6, 2009 at 11:54, Bryan R Harris wrote:
snip
> Now that's just impressive.
>
> For some reason the back of my brain thinks if I knew perl as well as you
> two seem to I could easily make all the money I wanted. Just between you
> and me =), is that true??
>
> Thanks for the responses,
> On Thu, Aug 6, 2009 at 11:54, Bryan R Harris
> wrote:
> snip
>> Now that's just impressive.
>>
>> For some reason the back of my brain thinks if I knew perl as well as you
>> two seem to I could easily make all the money I wanted. Just between you
>> and me =), is that true??
>>
>> Thanks for
On Thu, 6 Oct 2005, ZHAO, BING wrote:
>1. How do I change the unix system background to black,
> mine is while which is so annoying whenever I do perl.
How? Carefully.
(Hint: that's not a Perl question, so this is the wrong place to ask. If
you have general Unix questions, I su
Chris Devers wrote:
On Thu, 6 Oct 2005, ZHAO, BING wrote:
1. How do I change the unix system background to black,
mine is while which is so annoying whenever I do perl.
How? Carefully.
(Hint: that's not a Perl question, so this is the wrong place to ask. If
you have g
> On Thu, 6 Oct 2005, ZHAO, BING wrote:
>
> >1. How do I change the unix system
> background to black,
> > mine is while which is so annoying whenever I do
> perl.
>
Hello ,
Try
$ echo -e "\33[40m" #to change the background color
and
$ echo -e "\33[33m" #to change the f
Adriano Allora wrote:
hi to all,
I'd like to know two things:
1 - Perl vs. AWK
I'm learning Perl to use it in text processing. Recently I start to
argue with a friend of mine about the best language to process texts
(clear them, or markup them, tokenize them or parse them), he says awk
is be
> 1 - Perl vs. AWK
> (my friend also forwarded me a mail of AWK
> mailing list in which someone who did a
> benchmark demonstrated the speed of awk...)
Did he benchmark the time it took to write it? :)
I'm not an authority on Awk, but it seems to me that Awk has one purpose,
and it isn't good at
Hanson, Rob wrote:
Just because Awk shaves off a few seconds on a job doesn't make it better.
If that were the case we would all code directly in C.
Or assembly...ick
http://danconia.org
--
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
On Mon, Dec 30, 2002 at 10:10:50PM +0100, Adriano Allora wrote:
> 1 - Perl vs. AWK
> I'm learning Perl to use it in text processing. Recently I start to
> argue with a friend of mine about the best language to process texts
> (clear them, or markup them, tokenize them or parse them), he says awk
Lunedì, 30 Dic 2002, alle 23:38 Europe/Rome, Wiggins d'Anconia ha
scritto:
Adriano Allora wrote:
hi to all,
I'd like to know two things:
1 - Perl vs. AWK
I'm learning Perl to use it in text processing. Recently I start to
argue with a friend of mine about the best language to process texts
y, December 31, 2002 11:10 AM
To: [EMAIL PROTECTED]
Subject: Re: two questions
Lunedì, 30 Dic 2002, alle 23:38 Europe/Rome, Wiggins d'Anconia ha
scritto:
>
>
> Adriano Allora wrote:
>> hi to all,
>> I'd like to know two things:
>> 1 - Perl vs. AWK
>>
OTECTED]]
Sent: Tuesday, December 31, 2002 11:10 AM
To: [EMAIL PROTECTED]
Subject: Re: two questions
Lunedì, 30 Dic 2002, alle 23:38 Europe/Rome, Wiggins d'Anconia ha
scritto:
>
>
> Adriano Allora wrote:
>> hi to all,
>> I'd like to know two things:
>> 1 - Perl v
> I don't like who look for a complete and correct script here, but I
> cannot solve my problem: this is my input-type:
>
> Dante Alighieri
> Cecco Angiolieri
> Brunetto Latini
> EugenioMontale
> GiacomoLeopardi
> NiccolòTommaseo
> Guido Gozzano
> (and s
thank you all (Dan Muey, Wiggins d'Anconia, Rob Hansom in particular),
the party is finished, there was a perl-experienced-user but I used all
my selfcoltrol to avoid to ask him something about programming (my
girlfriend would have never forgiven me ;P ).
After some hours of sleep, I was rewarded
On 11/13/06, Tim Wolak <[EMAIL PROTECTED]> wrote:
Can anyone tell me why when matching E$ option it finds ZE instead?
$ is special in regexps. Used like that /(E$)/, it means a string
which where you find 'E' at the end of line. To match literal 'E$' you
need to say /(E\$)/ to make the dollar l
On 11/13/06, Tim Wolak <[EMAIL PROTECTED]> wrote:
My second question
is when I use getopt it never detects incorrect usage if you leave out
an options and complains about the variable not being there instead of
informing the user they missed an option.
People will tell you that's how options
AIL PROTECTED]
Sent: Monday, November 13, 2006 9:58 AM
To: Tim Wolak; beginners@perl.org
Subject: Re: two questions
On 11/13/06, Tim Wolak <[EMAIL PROTECTED]> wrote:
> Can anyone tell me why when matching E$ option it finds ZE instead?
$ is special in regexps. Used like that /(E$)/, it m
On 11/13/06, Tim Wolak <[EMAIL PROTECTED]> wrote:
I have changed it to:
if ($grp =~ /E\$/) {
$grp = "E\$";
}
This however still does not grab the "E$" from the file, I have done it
several ways to try and get it to work.
You have problems because of the interpolation
PROTECTED]
Sent: Monday, November 13, 2006 10:23 AM
To: Tim Wolak; beginners@perl.org
Subject: Re: two questions
On 11/13/06, Tim Wolak <[EMAIL PROTECTED]> wrote:
> I have changed it to:
>
> if ($grp =~ /E\$/) {
> $grp = "E\$";
> }
> This h
On 11/13/06, Tim Wolak <[EMAIL PROTECTED]> wrote:
That worked, so basicly what the \Q \E is doing is searching for
non-word characters from the beginning of the line and then stops after
the "E$" in my variable?
Not quite right. \Q \E tell that everything in between should be
interpreted as lit
On Tue, Oct 21, 2008 at 08:49, birdinforest <[EMAIL PROTECTED]> wrote:
> I am a student and enrolled Unix programing this semester.
> There are two questions relating to perl I can not work out in the
> last exam ( Actually I have write out my code, however the exam system
> marked it as "wrong").
birdinforest wrote:
>
> I am a student and enrolled Unix programing this semester.
> There are two questions relating to perl I can not work out in the
> last exam ( Actually I have write out my code, however the exam system
> marked it as "wrong"). Please help me to point out the fault. Thanks.
>
On Tue, Oct 21, 2008 at 10:43, Rob Dixon <[EMAIL PROTECTED]> wrote:
snip
snip
> use strict;
> use warnings;
>
> print join('', "@ARGV" =~ /[0-9]/g), "\n";
snip
The perl interpreter in my brain throws a syntax error on the line 4
character 15.
Since you have put your code out there here is mine
birdinforest wrote:
I am a student and enrolled Unix programing this semester.
There are two questions relating to perl I can not work out in the
last exam ( Actually I have write out my code, however the exam system
marked it as "wrong"). Please help me to point out the fault. Thanks.
QUESTION
Thanks for your suggestions and all of them make sense. However, since
I am a totally beginner never learned programing, it should take me
sometime to understand them clearly. I will also try to get answer
from my lecturer, then post here that what I have learned from both
questions.
Programing
Telemachus wrote:
Good morning,
Hello,
I'm using a recipe from The Perl Cookbook (11.10 for anyone browsing at
home) to produce a record structure from items in a text file. The text
file itself has a simple structure:
field:value
field:value
field:value
field:value
field:value
On Mon Nov 17 2008 @ 10:21, John W. Krahn wrote:
> Set paragraph mode.
>
>> while (<>) {
>
> Read a paragraph into $_. In your example a paragraph is:
>
> " field:value
> field:value
> field:value
>
> "
>
>> my @fields = split /^([^:]+):\s*/m;
>
> Since there are multiple lines in a p
On Mon, Nov 17, 2008 at 13:21, John W. Krahn <[EMAIL PROTECTED]> wrote:
snip
>> push(@Array_of_Records, { map /(.*)/, @fields });
>
> Store the fields as a hash at the end of @Array_of_Records. The filter
> /(.*)/ ensures that no newlines are included in the keys or values of the
> hash.
snip
Telemachus wrote:
On Mon Nov 17 2008 @ 10:21, John W. Krahn wrote:
Set paragraph mode.
while (<>) {
Read a paragraph into $_. In your example a paragraph is:
" field:value
field:value
field:value
"
my @fields = split /^([^:]+):\s*/m;
Since there are multiple lines in a parag
42 matches
Mail list logo