Beefy Boxes and Bandwidth Generously Provided by pair Networks
Keep It Simple, Stupid

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.

Log In?

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://991201]
and all is quiet...

How do I use this? | Other CB clients
Other Users?
Others chanting in the Monastery: (7)
As of 2017-02-19 17:28 GMT
Find Nodes?
    Voting Booth?
    Before electricity was invented, what was the Electric Eel called?

    Results (293 votes). Check out past polls.