Beefy Boxes and Bandwidth Generously Provided by pair Networks
P is for Practical
 
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


Comment on Re: not able to get the output using split function
Select or Download Code

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 perusing the Monastery: (9)
As of 2015-07-29 11:55 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    The top three priorities of my open tasks are (in descending order of likelihood to be worked on) ...









    Results (263 votes), past polls