Beefy Boxes and Bandwidth Generously Provided by pair Networks
XP is just a number

Re: Why do i get an extra (duplicate) array element?-

by perlfan (Priest)
on Jun 23, 2016 at 18:38 UTC ( #1166401=note: print w/replies, xml ) Need Help??

in reply to Why do i get an extra (duplicate) array element?-

Post tested input and how you're getting handle <IN>. And if you are not:
use strict; use warnings;

Replies are listed 'Best First'.
Re^2: Why do i get an extra (duplicate) array element?-
by rickman1 (Novice) on Jun 23, 2016 at 20:14 UTC

    From command-line argument. It's a fixed text file, in this case it only contains 4 lines but it can be thousands. The amount is always on that position on every line. The only way i could think of snatching them was through substr.

    open IN, "<$ARGV[0]" or die "Could not open input file '$ARGV[0]' $!";

    Flat text file would be many lines of equal length with the amounts at that same position in every line.

      If you could show us an actual data line(s), then most likely other techniques than substr() could be used. Split with an array slice is often a good approach. Just post your 4 lines within <code>...</code> blocks and we can tell exactly what is going on.

Log In?

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://1166401]
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others drinking their drinks and smoking their pipes about the Monastery: (5)
As of 2020-06-02 16:55 GMT
Find Nodes?
    Voting Booth?
    Do you really want to know if there is extraterrestrial life?

    Results (19 votes). Check out past polls.