in reply to while loop with diamond operator
while(<>){ $data = $data . $_ ; }
... can be better written as:
$data = do { local $/; <> };
Not only is that shorter, but it should actually run faster. In your version, Perl has to split STDIN on each new line character, and then join them back together. Localizing $/ just slurps the whole thing in at once.
How exactly are you getting Tomcat to launch your Perl script? Are you 100% sure that whatever mechanism it's using is actually passing data to STDIN?
|
|---|