Beefy Boxes and Bandwidth Generously Provided by pair Networks
Don't ask to ask, just ask
 
PerlMonks  

Re: not able to get the output using split function

by NetWallah (Abbot)
on Sep 01, 2012 at 22:09 UTC ( #991201=note: print w/replies, xml ) Need Help??


in reply to not able to get the output using split function

Your code:
my $sentence = shift;
will pick up the FIRST argument passed-in.

Your test probably looked something like:

>perl myprogram i amd testing this.
and it picked-up just the "i".

There are two possible fixes:
1. Add quotes to the argument, like this:

>perl myprogram "i amd testing this."
2. Programattically capture ALL passd arguments:
my $sentence = join " ",@ARGV;
If you notice, @ARGV already contains the same information as @words for this case, so split is unnecessary.

             I hope life isn't a big joke, because I don't get it.
                   -SNL

Log In?
Username:
Password:

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://991201]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others chilling in the Monastery: (3)
As of 2016-09-30 23:59 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?
    Extraterrestrials haven't visited the Earth yet because:







    Results (574 votes). Check out past polls.