Dear All,

my file looks like this

ICR000010::Proteinase inhibitor I25,
--ICR001713::Proteinase inhibitor I25A, stefin A::PR00295
ICR000014::PAS::PS50112::SM00091::TIGR00229
--ICR013655::PAS fold-3::PF08448
----ICR001321::Hypoxia-inducible factor-1 alpha, PAS

NOTE :
-- means one generation
---- means second generation

OUTPUT should be

Parent is ICR000010
ICR000010 First generation child is ICR001713
Parent is ICR000014
ICR000014 First generation child is ICR013655
ICR000014 Second generation child is ICR001321

here is my CODE to write the first line
##!/usr/bin/perl -w use strict; use warnings; open (FILE,"< C:/perl/ParentChildTreeFile.txt") or die "cannot open fi +le for reading: $!"; while (<FILE>){ if ($_ = /^(ICR\d+).*/){ my $parent = $1; print "\n Parent is $1"; } elsif ($_ = /^--(ICR\d+).*/){ my $firstchild = $1; print "\n $parent First generation child is $firstchild"; } elsif ($_ = /^----(ICR\d+).*/){ my $secondchild = $1; print "\n $parent Second generation child is $secondchild"; } }

OUTPUT :
Parent is ICR000010
Parent is ICR000014

Child Output is missing.I don't know why other if statements are not working. any help would be appreciated

Original code restored below by GrandFather

##!/usr/bin/perl -w use strict; use warnings; open (FILE,"< C:/perl/ParentChildTreeFile.txt") or die "cannot open fi +le for reading: $!"; while (<FILE>){ if ($_ = /^(IPR\d+).*/){ my $parent = $1; print "\n Parent is $1"; } elsif ($_ = /^--(IPR\d+).*/){ my $firstchild = $1; print "\n $parent First generation child is $firstchild"; } elsif ($_ = /^----(IPR\d+).*/){ my $secondchild = $1; print "\n $parent Second generation child is $secondchild"; } }

In reply to I could not use more than one IF ($_ = / /) condition for a single line by jawsai1224

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.