Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Wanet Telecoms Ltd on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

$_ = shift(@tony) until /xx/ or die;

Status
Not open for further replies.

darkreaper00

Technical User
Aug 5, 2002
23
US
Here's my snippet of code:

Code:
else {
	$_=shift(@tony) until (/Genomic: .*\|([\dyxpq_])+[Tt]el/); 
	print STDERR "6.5 ";
	$telomere  = $1; print STDERR "7 ";
	
	$_=shift(@tony) until (m!mRNA: .*/gb=([\w]+)!) 
		or die("eep! mrna $h doesn't have a genbank accession! you lose!"); 
	#....
}

My output is inevitably
Code:
6.5 7 eep! mrna 2 doesn't have a genbank accession! you lose!
The /Genomic/ line is proof that
Code:
shift until...
works, and I definitely have lines that contain "mRNA:" at the front and "/gb=xxxxx" inside -- in fact, if I simply tell it to find that, I don't have a problem. I realize that I could (and probably will) fix this by making it search for mRNA, and then putting the /gb=/ inside an if statement with the die as an else condition, but I really would like to know why what I have doesn't work -- it really stumps me.
 
I am not sure (should check precedence of 'until' versus 'or') but is it possible that perl do this:
Code:
$_=shift(@tony) until
Code:
(
Code:
(m!mRNA: .*/gb=([\w]+)!) 
        or die("eep! mrna $h doesn't have a genbank accession! you lose!")
Code:
)
Code:
;
 
You probably meant to write it as
[tt]
$_=shift(@tony) or die("eep! mrna $h doesn't have a genbank accession! you lose!")
until (m!mRNA: .*/gb=([\w]+)!);
[/tt]
What you have written is equivalent to
[tt]
$_=shift(@tony) until ((m!mRNA: .*/gb=([\w]+)!)
or die("eep! mrna $h doesn't have a genbank accession! you lose!"));
[/tt]
This will die if the match is unsuccessful, which will be the case unless you find it on the first try.

jaa
 
I think you're both right about what it's doing with my code, but justice41, your code does the same thing. I fixed it using this loop:

Code:
		while ($_=shift(@tony)) {
			if (m!mRNA: .*/gb=([\w]+)!) {	last;	}
			elsif (m!mRNA:!) {	die("eep! mrna $h doesn't have a genbank accession! you lose!"); }
			else {	next;	}
		}

nevertheless, I still don't understand why we couldn't get it to work with an or statement :c) Thanks for the direction, anyhow.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top