olecs has asked for the wisdom of the Perl Monks concerning the following question:
The question is how to get the $var variable into the perl code since I apparently can not get in is as regular argument while using the -e parameter.#!/bin/bash file=$1 var=$2 cat $1 | perl -e 'perlcodeinhere' >output
and that did not work. I guess that is because the while(<>) expects to find files to work on in the @ARGV list. When I changed it tocat $i | perl -e 'while(<>){$_=~ s/$ARGV[0]//g;print;}' $var >$i.new
it worked the way I expected.cat $i | perl -e 'while(<STDIN>){$_=~ s/$ARGV[0]//g;print;}' $var >$i. +new
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: arguments to perl -e
by borisz (Canon) on Apr 07, 2006 at 16:57 UTC | |
|
Re: arguments to perl -e
by explorer (Chaplain) on Apr 07, 2006 at 17:02 UTC | |
by explorer (Chaplain) on Apr 08, 2006 at 09:14 UTC | |
|
Re: arguments to perl -e
by kwaping (Priest) on Apr 07, 2006 at 19:34 UTC | |
|
Re: arguments to perl -e
by jcc (Sexton) on Apr 07, 2006 at 19:13 UTC | |
by graff (Chancellor) on Apr 08, 2006 at 06:42 UTC | |
by Anonymous Monk on Sep 16, 2013 at 19:20 UTC | |
|
Re: arguments to perl -e
by bart (Canon) on Apr 09, 2006 at 08:30 UTC |