I'm assuming then that each line is the name of a folder, spaces included. A bit of RegEx would do, as in the code below.

I'm sure the RegEx section could be redone to be cleaner and smaller, but I'm not at that level yet :) so I just did it in seperate steps.

use strict; my $Car0 = "2011 Chevy Camaro"; my $Car1 = "2011 Dodge Ram Crew Cab Short Bed"; my $Car2 = "2011 Ford F150 Platinum"; my $Car3 = "2011 Ford Flex"; my $Car4 = "2011 Ford Transit"; my $Car5 = "2011 GMC Cargo Van Extended"; my $Car6 = "2011 Hyundai Genesis Coupe"; my $Car7 = "2011 Kia Sol"; my $Car8 = "2011 Nissan Cube"; my $Car9 = "2011 Toyota Prius"; my $OneCar = ""; my $Year = 0; my $Make = ""; my $Model = ""; push( my @CarInfo, ( $Car0, $Car1, $Car2, $Car3, $Car4, $Car5, $Car6, +$Car7, $Car8, $Car9 ) ); foreach $OneCar( @CarInfo ) { # initialize the variables $Year = $OneCar; $Make = $OneCar; $Model = $OneCar; # drop everything after the Year including the first space char $Year =~ s/\s.*//; # drop the year and the first space char $Make =~ s/\d*\s*//; # drop everything after the Make including the first space char $Make =~ s/\s.*//; # drop the year and the first space char, same as with $Make $Model =~ s/\d*\s//; # drop everything up to and including the first space char $Model =~ s/\w*\s//; print "$Year\t\t$Make\t\t$Model\n"; }
Dyslexics Untie !!!

In reply to Re^3: Parse file, split by JockoHelios
in thread Parse file, split by mewoq

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.