in reply to Re: Split array and join with results
in thread Split array and join with results

hi, Thank you for replying! I sort of understand what you've done but the phone models are read from a text file and they can vary from anything from a few models to loads more so i cant hard code that into the code, can that be adapted into the coding? I'm currently using this array for the list of all the colours:
@colours = ( "baby blue", "baby pink", "black", "dark blue", "brown" +, "dark purple", "green", "orange", "hot pink", "light purple", "red" +, "white", "yellow"); foreach $colour (@colours) { print $colour; }
I hope this makes sense?

Replies are listed 'Best First'.
Re^3: Split array and join with results
by perlnoobster (Sexton) on Aug 22, 2012 at 15:15 UTC
    to simply, how do i adapt the following: @phones=qw(iph1 iph2 iph3); so that it reads the phone titles from the text file:
    chomp $results; push (@oid,$results[0]); $_ = defined($_) ? $_ : '' for @results;
    I hope that makes sense?
      Assuming your text file contains one entry on each line like this:
      iph1 iph2 iph3 ...
      You can simply slurp this file into an array like this:
      @phones=<FILE_HANDLE>;
      Make sure you use chomp on the array elements appropriately!

      Does this make sense?