On Jul 9, Connie Chan said: >Yes, you've made an error. use { statement } : { statement }
I think you mean 'do { ... } : do { ... }'. Perl is expecting EXPRESSIONS, not statements, and a block is a statement. do BLOCK turns a block into an expression. >$title =~ /<title>(.*)<\/title>/i ? {$title = $1} : {$title = $content}; $title =~ /.../ ? do { this } : do { that }; >> (m/<title>(.*)<\/title>/i) ? $title = $1 : $title = $content; The original problem is that ?: binds more tightly than =, so your code is (/..(..)../ ? $title = $1 : $title) = $content; which has the effect of ALWAYS assigning $content to $title, no matter how the regex matches. You could get around this problem with parentheses: /..(..)../ ? ($title = $1) : ($title = $content); or with Connie's do { ... } approach, but you can go one level better: $title = /..(..)../ ? $1 : $content; In fact, you could be a bit sneakier and do: ($title) = (/..(..)../, $content); The ($title) places the right-hand side in LIST context, which means the regex will return an empty list () if it fails, and a list of the $DIGIT variables if it succeeds. Thus, if the regex succeeds, you get ($title) = ($1, $content); in which case $title = $1 and $content is discarded; if the regex fails, you get ($title) = ((), $content); # which is ($title) = ($content); which assigns $content to $title. -- Jeff "japhy" Pinyan [EMAIL PROTECTED] http://www.pobox.com/~japhy/ RPI Acacia brother #734 http://www.perlmonks.org/ http://www.cpan.org/ ** Look for "Regular Expressions in Perl" published by Manning, in 2002 ** <stu> what does y/// stand for? <tenderpuss> why, yansliterate of course. [ I'm looking for programming work. If you like my work, let me know. ] -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]