By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
455,852 Members | 1,410 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 455,852 IT Pros & Developers. It's quick & easy.

words in a sentence

P: 1
hi i'm ramo.
i want to the splitting function of strings in perl
if u can provide the program about to find the words in a sentence i will be happy
your's
ramo
Jan 10 '08 #1
Share this Question
Share on Google+
3 Replies


parajaganesh
P: 17
hi i'm ramo.
i want to the splitting function of strings in perl
if u can provide the program about to find the words in a sentence i will be happy
your's
ramo
Hi ramo,

The following program will print the words in a string. It may be useful to you...

Expand|Select|Wrap|Line Numbers
  1. #! /usr/bin/perl
  2.  
  3. use strict;
  4.  
  5. my $str = "This is a testing string";
  6. my @list = split (" ", $str);
  7. my $tmp;
  8.  
  9. foreach $tmp(@list)
  10. {
  11.     print $tmp, "\n";
  12. }
  13.  
Regards,
Ganesh Kumar
Jan 10 '08 #2

P: 33
my $string = "this is a test string";
my @words = split (/\s+/, $string);
Jan 10 '08 #3

numberwhun
Expert Mod 2.5K+
P: 3,503
To the two OPs who posted code for this question:

This forum is not a scripting service. We do not just provide code upon request. Instead, this is a place of learning. That said, when OPs post a new thread without code, you are always seeing the experts and moderators alike, request the code that they have been working on. That way, we can see what they have tried thus far and can help them correct any issues with their code, in turn, learning from the whole experience. This OP has learned absolutely nothing from you providing code, beyond the fact of course that you are probably now their go-to person for any code they need. In the future, if you want to help the person, ask for their code and help them get it working. If they have no code, then they will have to try, giving it their best shot and again, we will assist them from there.


To the OP that started this thread:

Next time, you need to post your code and we will help you with what you have tried thus far.

Regards,

Jeff
Jan 10 '08 #4

Post your reply

Sign in to post your reply or Sign up for a free account.