perl -e equivalent of short script...
- From: alancam73@xxxxxxxxx (Alan Campbell)
- Date: Wed, 21 Mar 2007 14:54:30 -0700 (PDT)
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
- Follow-Ups:
- Re: perl -e equivalent of short script...
- From: Tom Phoenix
- Re: perl -e equivalent of short script...
- Prev by Date: Re: hash table
- Next by Date: Re: How to add a dir to @INC
- Previous by thread: hash table
- Next by thread: Re: perl -e equivalent of short script...
- Index(es):
Relevant Pages
|
|