jawsai1224 has asked for the wisdom of the Perl Monks concerning the following question:
##!/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"; } }
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"; } }
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: I could not use more than one IF ($_ = / /) condition for a single line
by davorg (Chancellor) on Jul 01, 2009 at 16:26 UTC | |
by jawsai1224 (Initiate) on Jul 01, 2009 at 16:37 UTC | |
by spx2 (Deacon) on Jul 01, 2009 at 17:09 UTC | |
by jawsai1224 (Initiate) on Jul 01, 2009 at 16:32 UTC | |
|
Re: I could not use more than one IF ($_ = / /) condition for a single line
by Anonymous Monk on Jul 01, 2009 at 16:25 UTC |