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

Re^2: Flat File Comment

by PilotinControl (Pilgrim)
on Dec 17, 2013 at 22:45 UTC ( #1067542=note: print w/replies, xml ) Need Help??

in reply to Re: Flat File Comment
in thread Flat File Comment

I've hit a snag and it seems if I have a field that states both Expedition XLT and Expedition when either one is selected one Expedition ends up getting a ##Expedition in the used file. The script is not recognizing via the

chomp(my $selection = <STDIN>);

as it is only taking the first part of the input and not the whole input as one. I believe I may have to use a while loop or use the m// operator correct? Thanks for the suggestions.

Replies are listed 'Best First'.
Re^3: Flat File Comment
by kcott (Chancellor) on Dec 18, 2013 at 13:01 UTC

    I can't reproduce the problem with the code I posted. You haven't shown what code you're using: see "How do I post a question effectively?" for guidelines on what to post such that we can help you.

    Here's my test:

    $ cat pm_year_make_model_file_models.master Sorento Cavalier Expedition
    $ cat >> pm_year_make_model_file_models.master Expedition XLT
    $ rm pm_year_make_model_temp_file
    $ Available years: 1999 2000 2001 Select year: 1999 Available makes: Chevrolet Ford KIA Select make: Ford Available models: Cavalier Expedition Expedition XLT Sorento Select model: Expedition Temp file contents: 1999 Ford Expedition
    $ cat pm_year_make_model_file_models.used Sorento Cavalier #Expedition Expedition XLT
    $ Available years: 2000 2001 Select year: 2000 Available makes: Chevrolet KIA Select make: KIA Available models: Cavalier Expedition XLT Sorento Select model: Expedition XLT Temp file contents: 1999 Ford Expedition 2000 KIA Expedition XLT
    $ cat pm_year_make_model_file_models.used Sorento Cavalier #Expedition #Expedition XLT

    -- Ken

      The added code is below. Since the program is actually sharing the master files which look like this:

      Expedition:XLT:Power Locks:Power Doors

      The code added strips the ":" and then joins only the two fields needed for my side of the program. I am not originating the files another program is doing that.

      for (@models) { my @mfields = split /:/; $_ = join ' ' => $mfields[0], $mfields[1]; }

      When selected the program only recognizes the first field not the second when joined together creating the following output:

      Expedition XLT

      Thus not commenting out each Expedition

      FIXED!! Using the below code I have no issues splitting the fields and rejoining the fields using split and splice together. Thanks for the suggestions they have been most helpful.

      for (@models) { my @mfields = split /:/, $_; $_ = join ( ' ',splice( @mfields, 0, 2)); }

Log In?

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://1067542]
and all is quiet...

How do I use this? | Other CB clients
Other Users?
Others rifling through the Monastery: (4)
As of 2018-04-21 10:53 GMT
Find Nodes?
    Voting Booth?