Excuse me for dropping this into the discussion, but
this reminds me a proposal made (by me;-) in p5p last month :
define a new prototype (") that allows to define quotelike
functions. Example :
sub rot13 (") {
my $s = shift; $s =~ tr/A-Za-z/N-ZM-An-zm-A/; return $s;
}
print rot13/uryyb $jbeyq\n/;
# the previous statement being equivalent to "print rot13(qq/uryyb
# $jbeyq\n/);" if rot13 had a ($) prototype
See the threads:
http://www.xray.mpe.mpg.de/mailing-lists/perl5-porters/2001-09/msg01718.html
http://www.xray.mpe.mpg.de/mailing-lists/perl5-porters/2001-09/msg01800.html
Aaron Sherman wrote in perl.perl6.language:
} On Tue, Oct 16, 2001 at 09:30:44AM -0700, David Wheeler wrote:
} >
} > That's part of the reason that I almost never use here docs, but the
} > qq{} operator, instead. No need for a closing newline.
}
} I have not read the RFC, but I do agree that qq is the way to go for
} formatted content. Or, perhaps something like it that in turn
} resembles the s{}{} operator?
}
} qf{^\s+}{ Now is the time
} for all good men...};
}
} eq
}
} sub qf ($pat,$str) {
} $str =~ s/$pat//mg;
} return $str;
} }
} qf('^\s+', qq{ Now is the time
} for all good men...});
}
} eq
}
} qq{Now is the time\nfor all good men...};
}
} That fits with the current trend and gives us a very flexible
} way to deal with just about any sort of formatting.
}
} You would want to allow the usual m{} options after the second
} close, but I think the default behavior should be that of m{}mg
}
} I also think that the above should be abbreviated as:
}
} qf{}{ Now is the time
} for all good men...};
}
} since useful defaults are always good.
--
Rafael Garcia-Suarez