Beefy Boxes and Bandwidth Generously Provided by pair Networks
We don't bite newbies here... much
 
PerlMonks  

Re^2: Flat File Comment

by PilotinControl (Scribe)
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.


Comment on Re^2: Flat File Comment
Download Code
Re^3: Flat File Comment
by kcott (Abbot) 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
    $ pm_year_make_model.pl 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
    $ pm_year_make_model.pl 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
      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?
Username:
Password:

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

How do I use this? | Other CB clients
Other Users?
Others chilling in the Monastery: (8)
As of 2014-12-21 11:28 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    Is guessing a good strategy for surviving in the IT business?





    Results (104 votes), past polls