Consider the following command line output using grep:
[gjempty@gjempty]$ find . -name "*.php" | xargs grep __construct | tail
./ilserverd/src/php/ImageLoopIntegrationService.php: public function __construct($input, $output=null) {
./ilserverd/src/php/ImageLoopIntegrationService.php: public function __construct($vals=null) {
./ilserverd/src/php/ImageLoopIntegrationService.php: public function __construct($vals=null) {
./ilserverd/src/php/ImageLoopIntegrationService.php: public function __construct($vals=null) {
./ilserverd/src/php/ImageLoopIntegrationService.php: public function __construct($vals=null) {
./ilserverd/src/php/ImageLoopIntegrationService.php: public function __construct($handler) {
./ilserverd/src/php/il_server_types.php: public function __construct($vals=null) {
./ilserverd/src/php/il_server_types.php: public function __construct($vals=null) {
./utilities/studio/legacy/full_bleed_update_photobook_themes.php: public function __construct() {
./utilities/studio/legacy/full_bleed_update_photobook_themes.php: parent::__construct();
This is my first step in trying to extract constructor arguments, and because it will require a number of steps, I’m trying to use Perl as an improvement over grep. But first, I want to retain the file names so I can refer back to those in my final “report” output.
But when I switch to the following Perl one-liner the file names are no longer part of the output. How can I retain them and still use Perl as a command-line replacement for grep?
[gjempty@gjempty]$ find . -name "*.php" | xargs perl -wnl -e '/__construct/ and print' | tail
public function __construct($input, $output=null) {
public function __construct($vals=null) {
public function __construct($vals=null) {
public function __construct($vals=null) {
public function __construct($vals=null) {
public function __construct($handler) {
public function __construct($vals=null) {
public function __construct($vals=null) {
public function __construct() {
parent::__construct();
You can try using
$ARGVas: