Re: accessing chars in a string

2009-09-02 Thread Chas. Owens
On Wed, Sep 2, 2009 at 11:49, Telemachus wrote: > On Tue Sep 01 2009 @ 10:44, Steve Bertrand wrote: >> A good place to reference regex is [1]. >> >> [1]: http://perldoc.perl.org/perlretut.html > > I will throw in my two cents and mention that if you are starting regular > expressions, you may find

Re: accessing chars in a string

2009-09-02 Thread Telemachus
On Tue Sep 01 2009 @ 10:44, Steve Bertrand wrote: > A good place to reference regex is [1]. > > [1]: http://perldoc.perl.org/perlretut.html I will throw in my two cents and mention that if you are starting regular expressions, you may find perldoc perlrequick a little more gentle, as an introduct

Re: accessing chars in a string

2009-09-01 Thread Steve Bertrand
Tim Bowden wrote: > On Tue, 2009-09-01 at 23:11 -0400, Uri Guttman wrote: >> SB> newbs don't understand that, without simple code examples. >> >> and i explained it. it is when you are asking about X (thinking that a >> specific way to do something) when you should be asking about Y (usually >>

Re: accessing chars in a string

2009-09-01 Thread Tim Bowden
On Tue, 2009-09-01 at 23:11 -0400, Uri Guttman wrote: > > "SB" == Steve Bertrand writes: > > SB> Uri Guttman wrote: > > >> so ask your real question about string munging and not how to do a > >> particular technique. > > SB> Searching "crisler" in the archives results in four messa

Re: accessing chars in a string

2009-09-01 Thread Uri Guttman
> "SB" == Steve Bertrand writes: SB> Uri Guttman wrote: >> so ask your real question about string munging and not how to do a >> particular technique. SB> Searching "crisler" in the archives results in four messages. I believe SB> he was trying, and his original question was a re

Re: accessing chars in a string

2009-09-01 Thread Steve Bertrand
Chuck Crisler wrote: > My immediate problem was checking a specific position in a string for a > specific value (if the char in the first position == '#', skip the > record). substr works OK in that case. However, I also want to learn > more and it seems regex is a better and more powerful answer.

Re: accessing chars in a string

2009-09-01 Thread Chuck Crisler
My immediate problem was checking a specific position in a string for a specific value (if the char in the first position == '#', skip the record). substr works OK in that case. However, I also want to learn more and it seems regex is a better and more powerful answer. Thank you, Chuck On Tue, 20

Re: accessing chars in a string

2009-09-01 Thread Steve Bertrand
Uri Guttman wrote: >> "CC" == Chuck Crisler writes: > > CC> How do I access specific character positions in a scalar string? In case > CC> it makes any difference, I specifically want to test the zeroth > CC> character. Something like the following. > > CC> my $str = "abc"; > CC> i

Re: accessing chars in a string

2009-09-01 Thread Uri Guttman
> "CC" == Chuck Crisler writes: CC> How do I access specific character positions in a scalar string? In case CC> it makes any difference, I specifically want to test the zeroth CC> character. Something like the following. CC> my $str = "abc"; CC> if ($str[0] == '#') CC> { CC>

Re: accessing chars in a string

2009-09-01 Thread John W. Krahn
Chuck Crisler wrote: How do I access specific character positions in a scalar string? In case it makes any difference, I specifically want to test the zeroth character. Something like the following. my $str = "abc"; if ($str[0] == '#') { do something... } if ( substr( $str, 0, 1 ) eq '

Re: accessing chars in a string

2009-09-01 Thread Steve Bertrand
Chuck Crisler wrote: > substr($str, 0, 1); Thanks for responding with your own solution. I like follow-ups like this. Personally, I have those 'duh' moments all the time. Unfortunately, some of them relate to real life, and not Perl ;) Nice. Steve smime.p7s Description: S/MIME Cryptographic

Re: accessing chars in a string

2009-09-01 Thread Chuck Crisler
duh substr($str, 0, 1); On Tue, 2009-09-01 at 20:49 -0400, Chuck Crisler wrote: > How do I access specific character positions in a scalar string? In case > it makes any difference, I specifically want to test the zeroth > character. Something like the following. > > my $str = "abc"; > if ($str[

accessing chars in a string

2009-09-01 Thread Chuck Crisler
How do I access specific character positions in a scalar string? In case it makes any difference, I specifically want to test the zeroth character. Something like the following. my $str = "abc"; if ($str[0] == '#') { do something... } Thank you in advance! Chuck -- To unsubscribe, e-ma