Beefy Boxes and Bandwidth Generously Provided by pair Networks
Syntactic Confectionery Delight

String in array

by Sun751 (Beadle)
on Jul 26, 2009 at 22:46 UTC ( #783397=perlquestion: print w/replies, xml ) Need Help??
Sun751 has asked for the wisdom of the Perl Monks concerning the following question:

I hanve an array where elements are strings and separated my ";" so while doing split,
my ($cmd, $chdir) = split(';',$run[$element],2);
I am getting following error,
Argument "and/people" isn't numeric in array element at line 130.' Any suggestion how to achieve split without above warnings???

Replies are listed 'Best First'.
Re: String in array
by ikegami (Pope) on Jul 26, 2009 at 22:48 UTC

    $element contains "and/people", and it's nonsense to use that as an array index.

    5 seconds of debugging would have confirmed that if you weren't sure what the message meant :( If Perl tells your variables contain something funky, make sure your variables contains what you think they contain!

Re: String in array
by afoken (Abbot) on Jul 26, 2009 at 23:14 UTC
      Sorry about this thread, figure out the problem....... as I am new to perl and I am trying different things........... which bring simple bug a big problem to me................ Sorry again!!!

        Nobody here has a problem with Perl beginners. All of us, except for Larry Wall, had to learn Perl from zero. And all of us are willing to help beginners to learn Perl. That's one of the main purposes of the Monastery.

        We all do this for free, yet still it has a price: YOU must show that you are willing to learn and to study.

        This means that you should try to solve problems alone, as far as you can. Use the excellent documentation, available on your computer and on The latter is searchable, so use the search function. The Monastery has a search function, use it. Use Google.

        If all that does not help, then, and only then, post your question. Try to explain your problem as precise as possible. What do you get, what do you expect? Explaining often means that you should show us the relevant code (in <code> tags, of course). When it is related to a previous question, post it as reply to the previous question (i.e. stay in the same thread). That allows all of us to see what you have already tried, what solutions were offered, and what problems were already excluded (i.e. the problem context).

        If you behave that way, you avoid unneeded and repeated guesswork by people who are willing to help you. This reduces frustration on both sides and allows us to help other people instead.

        All of your 40 threads, from the very first up to this one, rotate around the same obscure program, so they should have been a single thread. (We could discuss if it was better to merge them to three or four threads instead, but 40 threads are just ridiculous!). In each single thread, you demonstrate your unwillingness to read manuals, to read answers, and to explain you real problem.

        In short: You ask for help, but refuse to accept it.

        This is frustrating for everyone. Just look how often your threads were downvoted to negative scores reputations. Look at those scores reputations as a big fat warning for you.

        If you want help, show us that you are willing to learn, accept what we tell you, and research for yourself before posting. If you don't like these rules, go away and search for help elsewhere.

        Don't fear to write bad english. We come from all over the world, and a lot of us learned english as second or third language in school or at work. We don't celebrate english writing contests here, we try to help each other getting things done with Perl, and have some fun with it. No one criticises you for spelling errors or a weired grammar.


        Today I will gladly share my knowledge and experience, for there are no sweeter words than "I told you so". ;-)
Re: String in array
by Anonymous Monk on Jul 26, 2009 at 22:51 UTC
    Argument "and/people" isn't numeric in array element at line 1 +30.' (#1) (W numeric) The indicated string was fed as an argument to an oper +ator that expected a numeric value instead. If you're fortunate the me +ssage will identify which operator was so unfortunate.
    Use strict warnings and diagnostics or die,
Re: String in array
by mzedeler (Pilgrim) on Jul 27, 2009 at 07:13 UTC

    Just try some print(tm)-debugging:

    my ($cmd, $chdir) = split(';',$run[$element],2);


    print '@run:', join ', ', @run, "\n"; print "\$element: $element\n"; my ($cmd, $chdir) = split(';',$run[$element],2); print "\$cmd: $cmd\n"; print "\$chdir: $chdir\n";

    You'll be surprised when you discover how many problems you can solve on your own using this technique.

Log In?

What's my password?
Create A New User
Node Status?
node history
Node Type: perlquestion [id://783397]
Approved by ikegami
and all is quiet...

How do I use this? | Other CB clients
Other Users?
Others pondering the Monastery: (10)
As of 2017-11-22 15:40 GMT
Find Nodes?
    Voting Booth?
    In order to be able to say "I know Perl", you must have:

    Results (326 votes). Check out past polls.