Re: Ternary Regex Evaluation
Yes, we didn't even think about that until after someone else on this list mentioned it. We fixed it. John Pitchko Data Services Saskatchewan Government Insurance Shawn [EMAIL PROTECTED] 07/12/02 04:07am my $title; open (FH, HTML_HOME . $directory . $content) or die Cannot open file : $!; while (FH){ chomp; $title=m/title(.*)\/title/i?$1:$content; } print $title; But, I don't see how this will work to well if this file has more than one line (unless the title tag is on the last line of the file...) You are iterating over every line, and constantly replacing $title with each pass... Maybe add this below the $title=m/...: last if($title ne $content); Shawn - Original Message - From: John Pitchko [EMAIL PROTECTED] To: [EMAIL PROTECTED] Sent: Monday, July 08, 2002 11:57 AM Subject: Ternary Regex Evaluation Hello, I am trying to do some pattern matching in a ternary evaluation, but it does not seem to work. If I place the regex into a structured if statement, it evaluates fine, but not in a ternary evaluation. Here is what I have so far. my $title; ... ... ... open FH, HTML_HOME . $directory . $content or die Cannot open file : $!; while (FH) { chomp; (m/title(.*)\/title/i) ? $title = $1 : $title = $content; } print $title; Does anyone have any suggestions? TIA John Pitchko Data Services Saskatchewan Government Insurance
Ternary Regex Evaluation
Hello, I am trying to do some pattern matching in a ternary evaluation, but it does not seem to work. If I place the regex into a structured if statement, it evaluates fine, but not in a ternary evaluation. Here is what I have so far. my $title; .. .. .. open FH, HTML_HOME . $directory . $content or die Cannot open file : $!; while (FH) { chomp; (m/title(.*)\/title/i) ? $title = $1 : $title = $content; } print $title; Does anyone have any suggestions? TIA John Pitchko Data Services Saskatchewan Government Insurance
Re: Ternary Regex Evaluation
Yes that would work, but I was really curious as to why the ternary operation does not work. In fact, none of my other ternary operations seem to work. Is there something wrong with my syntax? Thanks, John Pitchko Data Services Saskatchewan Government Insurance Connie Chan [EMAIL PROTECTED] 07/08/02 11:12am Sorry, I am poor in English, but is this what you want ? $title = $content; while (FH) { chomp; $title = $1 if ( /title(.+)\/title/i ); } print $title; Rgds, Connie - Original Message - From: John Pitchko [EMAIL PROTECTED] To: [EMAIL PROTECTED] Sent: Tuesday, July 09, 2002 12:57 AM Subject: Ternary Regex Evaluation Hello, I am trying to do some pattern matching in a ternary evaluation, but it does not seem to work. If I place the regex into a structured if statement, it evaluates fine, but not in a ternary evaluation. Here is what I have so far. my $title; ... ... ... open FH, HTML_HOME . $directory . $content or die Cannot open file : $!; while (FH) { chomp; (m/title(.*)\/title/i) ? $title = $1 : $title = $content; } print $title; Does anyone have any suggestions? TIA John Pitchko Data Services Saskatchewan Government Insurance
Re: Ternary Regex Evaluation
John Pitchko wrote: Yes that would work, but I was really curious as to why the ternary operation does not work. In fact, none of my other ternary operations seem to work. Is there something wrong with my syntax? probably. try putting each true/false statement inside a parenthesis. ps - this really doesn't have anything to do with cgi, so a question like this would be better off asked on a different list. -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]