Beefy Boxes and Bandwidth Generously Provided by pair Networks
Your skill will accomplish
what the force of many cannot

Re: new dilemma on the same song that remains... umm the same

by chromatic (Archbishop)
on Jun 02, 2012 at 02:12 UTC ( #973907=note: print w/replies, xml ) Need Help??

in reply to new dilemma on the same song that remains... umm the same

I don't understand what you mean by "comparing each value of $col[0]"; it has one value. You can get rid of the loop altogether, as it does nothing.

Here's another problem:

open FILE, ">feckyou.txt" or die $!;

This will overwrite your file every time through the loop. You'll only ever get one entry. If you want an entry for each row, move this open outside of the outermost loop.

I don't entirely understand your problem (showing some sample data would help), but if you need to see if any of the values from column A are in column D anywhere, you need to loop through each row once, put the values from column A in a hash, then loop through each row again and check if the value for column D exists anywhere in the hash.

Does that make more sense?

Improve your skills with Modern Perl: the free book.

Replies are listed 'Best First'.
Re^2: new dilemma on the same song that remains... umm the same
by trickyq (Acolyte) on Jun 02, 2012 at 11:44 UTC

    ok let me explain. my company has an excel spreadsheet that is essentially a price list. For industrial construction parts. Once a week we get a price sheet from our distributor of price changes and new items. The spreadsheet that we keep has a column (Column A) of Product IDs. The IDs range from 7-10 numbers or letters and dont follow a particular pattern. The girl at the office copies and pastes the list from the distributor to Column D of the Spreadsheet. She then manually scrolls through all the stuff in Column D (which is in a random order) and finds matches with the product ids in Col A. A match means a price change. Then the girl copies the new price into our price sheet.

    I am trying to automate this a little. There are 3700 lines this person has to go through once a week. Where my problem lies is that once the new product Ids are copied into column D they are in any order. So the ID in A17 may match an ID in D347 and if so I need to know about it. The reverse doesnt need to work. I just need to know if the product id in A exists anywhere in D and then use a conditional to copy the corresponding new price to another column (easy part)

    so if ($stufffromA eq $stufffromanywhereinD) { copy new price to column R }

    hope that clears it up and doesnt make it muddier

Log In?

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

How do I use this? | Other CB clients
Other Users?
Others exploiting the Monastery: (6)
As of 2018-06-22 22:16 GMT
Find Nodes?
    Voting Booth?
    Should cpanminus be part of the standard Perl release?

    Results (124 votes). Check out past polls.