genyded has asked for the wisdom of the Perl Monks concerning the following question:

I am pulling some data from a terminal command into an array:

@lines = $telnet->cmd($some_command);
Some of the values are exponential such as 2.496E+09. Whenever the array reaches one of these, it seems to terminte at the + sign. So, when parsing the array values, what should look like:

Value1, Value2, 2.496E+09, Value4, Value5

Ends up looking like:

Value1, Value2, 2.496E

Any thoughts on how to deal with this and get all the values correctly into the array?

TIA!

Replies are listed 'Best First'.
Re: + sign in array value
by amarquis (Curate) on Oct 17, 2007 at 17:10 UTC

    I just tested this out running a remote script using Net::Telnet (which I assume you are using as well). I couldn't replicate your error, sadly.

    One thing to check might be the record separator parameters for the cmd function. If changing them from the defaults doesn't work, I believe you can also send a scalar reference that it'll dump all the output into. You could then break it up yourself, at least.

    Edit: beaten. I have to learn to start refreshing the page before I submit a node.

      You were a little "slow" because you actually tried to replicate the error. Nothing to apologize for.
Re: + sign in array value
by kyle (Abbot) on Oct 17, 2007 at 17:06 UTC

    Are you using Net::Telnet (you didn't say)? I wonder what the prompt is set to, or the input record separator. The documentation recommends using dump_log() to help.

      Yes, I am using Net::Telnet, but that's not the issue. The data comes out fine from there (at least in the dump) but gets truncated when the array is populated.

        Maybe you could show us some more of what's going on. What does the dump say? How do you see it truncated "when the array is populated"? What do you get if you read into a scalar instead of an array and then try to parse out your values? What kind of machine are you connecting to (I notice a scary warning about Windows in the Net::Telnet documentation)? What does last_prompt() say after the problem shows?

A reply falls below the community's threshold of quality. You may see it by logging in.