Beefy Boxes and Bandwidth Generously Provided by pair Networks
Syntactic Confectionery Delight
 
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 avoiding work at the Monastery: (10)
As of 2014-08-22 09:08 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    The best computer themed movie is:











    Results (152 votes), past polls