So the problem is that i need to add leading zeros back to the numbers after i put them into an array. But the split function joins all the data into 1 long stream so i cant do that. It also means that typing more than 1 word can break the code. Sorry if the answer is simple i am self learning. For the file, you can make an array of 10 fruits, then for numbers an array using 1..10

use strict; use warnings; use JSON qw( decode_json); use File::Find; #Change This Root Depending On File Location open (MYFILE, "F:/Program Files (x86)/Spreadsheets/Words.txt") or die "Could not open required file $!"; my $firstText = do { local $/; <MYFILE> }; my @firstText = split(' ', $firstText); open (FILE, "F:/Program Files (x86)/Spreadsheets/Numbers.txt") or die "Could not open required file $!"; my $firstNumbers = do { local $/; <FILE> }; my @firstNumbers = split(' ', $firstNumbers); print "Text Enter\n"; my $sentance = <>; my @sentance = split(' ', $sentance); print @sentance; print $sentance; use List::MoreUtils qw(first_index); my @indexes; foreach my $place (sentance) { push (@indexes, first_index { $_ eq $place } @firstText); }; print @indexes;

In reply to Seperating values with spaces in array by RuZombieSlayer

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.