hello, Good questions.
> I'm trying to use cmd line perl -e to do some fairly basic sed-style > find/replace. Why don't you just use sed for that, if you're not doing the main program in Perl? Maybe I'm misunderstanding you, but it sounds like you're saying that you're writing shell scripts in which you're frequently calling 'perl -e'. That's like buying a Hefty bag to carry your Louis Vuitton. >> 3 reasons for using perl -e (a) it has the *full* regex set. My sed (under cygwin) has some limitations....like no \d. I have to do [0-9] each time. (b) I know my users will have a perl install [prerequisite from other stuff]. Dont know if they have cygwin/unix/linux (c) theory behind it being a cmd line was that as u allude to...users could look at it & say "I'm on unix...i'll just replace it w/ sed/awk" > Was able to get first few things working but stumbled when I wanted to > do the following.... I won't quote "the following"; I'll just say that It took me about twenty minutes of puzzling before I realized what you're trying to do. I think. Your program is doing something resembling code coverage checking, trying to find out which items in a list are not mentioned in a number of files. Am I close? >> really? Sure sign I made the .pl overcomplicated then. All I'm trying to do >> is replace anything that matches w/ a newline. Okay, I will quote one loop: > for (my $ctr = 0; $ctr < scalar(@syms_info); $ctr++) { > $syms_info[$ctr] = "\n" if ($syms_info[$ctr] =~ $bss_sym); > } This is what a foreach loop is made to do; if you recode it as a foreach, you'll only have to mention 'syms_info' once, instead of three times, and you won't need $ctr or the scalar operator at all. Also, $bss_sym is from a line of input; is the input in the form of a regular expression? If not, probably you want to use 'eq' (string equality) instead of '=~' (pattern matching). >> true, but I'm tweaking the orig array in-place. So how to modify a given >> element if I dont have some index? ....But I'm unclear why you want to use a newline to represent matched items. Why not remove them from the list entirely? I'm sure I'm missing something. If removing would work, consider grep instead of the foreach loop. >> replacing w/ a newline makes diffs easier. User can diff all_syms orig i/p >> w/ the trimmed syms i/p and just see what got deleted. > ...but I'd like a (somewhat convoluted perhaps) 1-liner w/ perl -e cmd-liner. Why do you want a 'perl -e' program, as opposed to an ordinary perl program? It's not going to be easier to read, write, understand, maintain, or debug. It's not going to run faster. It's always cool to condense a program to a one-liner. However, this sounds like a program that needs to be improved in the realm of correctness, not coolness. >> sounds like advice is to not bother w/ perl -e. Seems a pity. Looked like a >> perfect job for perl -e but perhaps its pushing it a bit. Good luck with your project! --Tom Phoenix Stonehenge Perl Training -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] http://learn.perl.org/ ____________________________________________________________________________________ Sucker-punch spam with award-winning protection. Try the free Yahoo! Mail Beta. http://advision.webevents.yahoo.com/mailbeta/features_spam.html