Hi Perl Monkers, I wrote a stupid code (see below) to combine two files and it obviously is wrong. I am not very familiar with Perl Join or grep and can't seem to figure out the code from scratch using these functions. ANy help perl monkers?

1st file: pizza pickle omellete coke blackforest croissant 2nd file: salt pizza 1 salt pickle 1 pepper omelette 1 pepper pickle 1 I want is: (If ingredient in file 2 is not found in food from file 1, +annotate it as "0" instead of "1"). salt pizza 1 salt pickle 1 salt omellette 1 salt coke 0 salt blackforest 0 salt croissant 0 sugar pizza 0 sugar pickle 0 sugar omellette 0 sugar coke 1 sugar blackforest 1 sugar croissant 0 I wrote this which is obviously wrong: open(INPUTR,"<$1file") || die "Can't open \$1file for reading.\n"; while($line=<INPUTR>){     chomp $line;     $food = $line;         open(INPUTR1,"<$2file") || die "Can't open \$2file for reading +.\n";         while($line1=<INPUTR1>){             chomp $line1;             @toks = split(/\t/, $line1);             $ingredient = uc$toks[0];             $food1 = uc$toks[1];             $linemod = $line1;             if ($food1 !~ $food){                 $linemod = $ingredient."\t".$food."\t"."0";             }         }         close(INPUTR1);         print OUTD $linemod."\n"; }

In reply to Is it Perl "join" that can help me? by angerusso

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.