hi, I am a beginer in PERL. got stuck in trying to figure out how strings are converted to character arrays.
for ex: I want to convert @str1=("apple") to a charcter array like
@chr1=('a','p','p','l','e')
can some one help me how to implement the above?
I basically need to get a string form the user and address each character(letter) of that string. well, iam in the middle of my assignment...so a quick reply from any one is appreciated.
regards,
bhanumathy.
11 42535
I am also having the same problem. Let me know if you find a solution!
Thanks
I want to convert @str1=("apple") to a charcter array like
@chr1=('a','p','p','l','e')
can some one help me how to implement the above?
A function for doing that was implemented in Perl a long time ago. Time to RTFM?
TFM: http://perldoc.perl.org/functions/split.html
Yeah, that's indeed the function I was thinking of. ;)
My point is that being a beginner isn't an excuse for asking for help without first making a serious effort to find the answer by help of the docs. Browsing the perlfunc manpage for a suitable function should always be part of such an effort IMO. Now I had told him that there is an applicable function, which should have been enough of a pointer.
There are too many people nowadays who expect to be spoon feeded. :(
I am also having the same problem. Let me know if you find a solution!
Thanks
Hi,
check out this link.
http://perldoc.perl.org/functions/split.html
hi, I am a beginer in PERL. got stuck in trying to figure out how strings are converted to character arrays.
for ex: I want to convert @str1=("apple") to a charcter array like
@chr1=('a','p','p','l','e')
can some one help me how to implement the above?
I basically need to get a string form the user and address each character(letter) of that string. well, iam in the middle of my assignment...so a quick reply from any one is appreciated.
regards,
bhanumathy.
Hi ,
use the following code for ur problem
@chars=split(/(?=\w)/,$string);
Regards ,
sharif.
@chars=split(/(?=\w)/,$string);
Slightly overcomplicated there sharif. This works just as well, and is quite a bit easier to read, I think. -
@chars = split '', $string;
-
Again, they should just read the manual: http://perldoc.perl.org/functions/split.html
"spoon feeded".
I think it's time for you to RTF Dictionary!!
litenin
Yeah, that's indeed the function I was thinking of. ;)
My point is that being a beginner isn't an excuse for asking for help without first making a serious effort to find the answer by help of the docs. Browsing the perlfunc manpage for a suitable function should always be part of such an effort IMO. Now I had told him that there is an applicable function, which should have been enough of a pointer.
There are too many people nowadays who expect to be spoon feeded. :(
"spoon feeded".
I think it's time for you to RTF Dictionary!!
litenin
Litenin,
First, this is a place of learning. Being condescending as you were is not beneficial to those trying to learn something. Sometimes spoon feeding a person something is the way to get them to learn, sometimes it isn't. It all depends on the situation. Lets try to be a little more understanding of those who do not "know it all".
Also, seeing as how this thread is a year and a half old, I doubt that the original OP will be reading it. Besides, they have probably have learned this material already.
Regards, Moderator
In Litenin's defense... it appears he was taking a poke at GunnarH for using the word "feeded" instead of "fed" in GunnarH's belittling of the requestor for asking for help too soon (hence, the "Dictionary" reference). Litenen was, in fact, defending the newbie, not attacking him.
Litenin,
First, this is a place of learning. Being condescending as you were is not beneficial to those trying to learn something. Sometimes spoon feeding a person something is the way to get them to learn, sometimes it isn't. It all depends on the situation. Lets try to be a little more understanding of those who do not "know it all".
Also, seeing as how this thread is a year and a half old, I doubt that the original OP will be reading it. Besides, they have probably have learned this material already.
Regards, Moderator
lock this thread already.
This discussion thread is closed Replies have been disabled for this discussion. Similar topics
6 posts
views
Thread by lkrubner |
last post: by
|
1 post
views
Thread by flam |
last post: by
|
reply
views
Thread by Tom Warren |
last post: by
|
16 posts
views
Thread by Don Starr |
last post: by
|
20 posts
views
Thread by Opettaja |
last post: by
|
14 posts
views
Thread by Shhnwz.a |
last post: by
|
232 posts
views
Thread by robert maas, see http://tinyurl.com/uh3t |
last post: by
| |
19 posts
views
Thread by est |
last post: by
| | | | | | | | | | |