Rechercher une page de manuel
Sprog::Gear::PerlCode.3pm
Langue: en
Version: 2005-07-24 (mandriva - 01/05/08)
Section: 3 (Bibliothèques de fonctions)
Sommaire
NAME
Sprog::Gear::PerlCode - execute your own Perl code for each line of inputDESCRIPTION
This gear allows the user to define a snippet of Perl code that will be executed for each line of input. The code snippet is wrapped with a small amount of boilerplate code (similar in purpose to Perl's "-p" option):$_ = $input_line; LINE: { # Perl snippet inserted here print $_; }
The built-in "print" function is also overridden to pass its arguments to the next downstream gear as a "data" message.
Thus, the default behaviour is to take the line of input in $_ and pass it directly to the next downstream gear. The code snippet can alter the contents of $_. It can also call "print" as many times as it wants to generate additional lines of output.
Note: unlike Perl's -p option, the "print" is not in a "continue" block so if you call next, the print will be skipped.
COPYRIGHT
Copyright 2004-2005 Grant McLean <grantm@cpan.org>This library is free software; you can redistribute it and/or modify it under the same terms as Perl itself.
Contenus ©2006-2024 Benjamin Poulain
Design ©2006-2024 Maxime Vantorre