|
|
|||||||||
|
|||||||||
| |||||||||
|
|
|
| |||||||||
![]() |
|
|
«
Previous Thread
|
Next Thread
»
|
Thread Tools | Search this Thread | Rate Thread | Display Modes |
|
#1
|
|||
|
|||
|
Quick question, when using substr, how can you refer to more than two letters, say the 1st, 2nd and 3rd bar simply joining more than one substr together?
|
|
#2
|
||||
|
||||
|
Hmm. I'm not really sure what you're asking. . .
Are you looking to concatenate two substrings together? Code:
my $string='foobar'; my $substring1=substr($string,0,3); my $substring2=substr($string,2,3); my $totalstring=$substring1.$substring2; #which could also be my $totalstring=substr($string,0,3).substr($string,2,3); #In both cases, $totalstring is "foobar" |
|
#3
|
|||
|
|||
|
i mean getting 3 letters from a string with just one substr call
|
|
#4
|
||||
|
||||
|
exactly,
not clear wat u want to do. if u want 3 chracters, substr($string,0,3) would do that. but i think u want some different thing. can u explain with example what u want to achieve ?? jd
__________________
_____________________________ d.k.jariwala (JD) ~ simple thought, simple act ~ I blog @ http://jdk.phpkid.org |
|
#5
|
||||
|
||||
|
http://www.perlmonks.com/index.pl?n...lastnode_id=169
That's what I was doing in my substr() above. Read the docs about substr at the address above. Fortunately, they are pretty clear in this case. |
![]() |
| Viewing: Dev Shed Forums > Programming Languages > Perl Programming > substr |
| Thread Tools | Search this Thread |
| Display Modes | Rate This Thread |
|
|
|
|