perl -e equivalent of short script...



hello folks,

I'm trying to use cmd line perl -e to do some fairly basic sed-style find/replace. Was able to get first few things working but stumbled when I wanted to do the following....

- given an i/p (piped o/p from a previous perl -e cmd on DOS) of...
dtor_list.obj:
newnothrow.obj:
vars.obj:
_lock.obj:

....then if regex match w/ any lines in file all_fxns.txt of form...
/* array_del.obj: */ -u ___dla__FPv
/* array_nonew.obj: */ -u ___nwa__FUiRCQ2_3std9nothrow_t
/* dtor_list.obj: */ -u ___already_marked_for_destruction
/* memzero.obj: */ -u ___memzero

....then replace entry in all_fxns.txt w/ a blank line

So...
/* dtor_list.obj: */ -u ___already_marked_for_destruction
....should get replaced w/ an empty line.

This .pl does the job just fine....
my $all_syms_file = "all_fxns.txt";

open (SYMSINFO, "<$all_syms_file") or die "Cannot open $all_syms_file: $!";
my @syms_info = <SYMSINFO>;
close SYMSINFO;

while (my $bss_sym = <>) {
chomp($bss_sym);
for (my $ctr = 0; $ctr < scalar(@syms_info); $ctr++) {
$syms_info[$ctr] = "\n" if ($syms_info[$ctr] =~ $bss_sym);
}

}
print @syms_info;

....but I'd like a (somewhat convoluted perhaps) 1-liner w/ perl -e cmd-liner. Seems like it should be feasible in 1/10th the code.
Any thots?

Many thanks indeed,
Alan

-----



____________________________________________________________________________________
Be a PS3 game guru.
Get your game face on with the latest PS3 news and previews at Yahoo! Games.
http://videogames.yahoo.com/platform?platform=120121

Relevant Pages

  • RE: Perl-Postgres connection: Commit method not found in DBI. Advice?
    ... Thanks for the advice; I'm new to Perl, and I didn't realize that wasn't correct. ... Be a PS3 game guru. ... Get your game face on with the latest PS3 news and previews at Yahoo! ...
    (perl.dbi.users)
  • Re: query status of STDIN
    ... the program on the left of the pipe. ... I know the game. ... post, at night, many of you boys were posting both ignorant ... the Perl FAQ maintainer agreed to add code much like mine. ...
    (comp.lang.perl.misc)
  • Re: What makes diablo fun?
    ... The time needed to dispatch a single enemy is lower. ... Diablo has great graphics and music and is turnwise. ... The game is very straightforward -- you always know WHAT to do, ... "It is by Perl alone I set my webpages in motion. ...
    (rec.games.roguelike.development)
  • Re: EmotionRL -- Its here
    ... I had to install the curses module for perl as you ... The game may become the first of a new ...
    (rec.games.roguelike.development)
  • Re: EmotionRL -- Its here
    ... I had to install the curses module for perl as you ... Personally I prefer arrow keys or the numpad for movement and ... The game may become the first of a new ...
    (rec.games.roguelike.development)