david_lyon has asked for the wisdom of the Perl Monks concerning the following question:
I have a bad habit of throwing in a one line command wihtin perl code like this:
#!/usr/bin/perl $file="test"; $cmd="perl -pi -e s\'\/^\\s+\/\/'g $file"; print "$cmd\n"; system($cmd);
Is there a quick and proper way of doing the above in a script without having something like this:
open(DATA, "$file"); while(<DATA>){ chomp; $line=$_; $line=~ s/^\s+//g; print "$line\n"; }
Thanks again for your help much appreciated.
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: perl -pi -e s'/^\s+//'g $file
by wind (Priest) on Apr 08, 2011 at 01:41 UTC | |
by david_lyon (Sexton) on Apr 08, 2011 at 02:24 UTC | |
|
Re: perl -pi -e s'/^\s+//'g $file
by duelafn (Parson) on Apr 08, 2011 at 02:57 UTC | |
|
Re: perl -pi -e s'/^\s+//'g $file
by InfiniteSilence (Curate) on Apr 08, 2011 at 03:43 UTC | |
|
Re: perl -pi -e s'/^\s+//'g $file
by goibhniu (Hermit) on Apr 12, 2011 at 18:37 UTC | |
by Anonymous Monk on Apr 12, 2011 at 18:49 UTC | |
by goibhniu (Hermit) on Apr 12, 2011 at 19:12 UTC | |
by Anonymous Monk on Apr 26, 2011 at 11:57 UTC | |
by Anonymous Monk on Mar 22, 2012 at 10:55 UTC | |
by Anonymous Monk on Nov 23, 2012 at 07:34 UTC |