man perlretut or <a href="http://perldoc.perl.org/perlretut.html">http://perldoc.perl.org/perlretut.html</a>.<br><br>I'll create an example for you which will capture 'We go to the ' plus one word terminated by a period, EOL, or non-word character. Be careful, as hyphenated places will not be included. Also, if the place is on the next line, or the spaces are wrong, we won't catch that either.
<br><br>Create a file:<br>>>>>>>>START-OF-FILE<<<<<<<<<<<br>#!/bin/perl<br><br>while(<>) {<br> if( $_ =~ /(We go to the \w+)($|\W|\.)/ ) {<br> print $1 . "\n";
<br> }<br>}<br>>>>>>>>END-OF-FILE<<<<<<<<<<<br>Chris<br><br><div><span class="gmail_quote">On 9/2/07, <b class="gmail_sendername">Todd Walton</b> <<a href="mailto:tdwalton@gmail.com">
tdwalton@gmail.com</a>> wrote:</span><blockquote class="gmail_quote" style="border-left: 1px solid rgb(204, 204, 204); margin: 0pt 0pt 0pt 0.8ex; padding-left: 1ex;">Can someone refresh my memory? I have a file with many lines of text.
<br> One (or two) of those lines has an expression in it, "We go to the ",<br>followed by another one word. I want to use perl to find that<br>expression and print "We go to the park" or "We go to the game" or
<br>whatever it is. How do I do that?<br><br>So far I know that -e will run a perl command from the shell command<br>line. And I saw a -Fpattern in man perl, but I couldn't find anything<br>else on command-line options in man perl. I did find a page about it
<br>on <a href="http://perl.com">perl.com</a> and then at the end of that article it said to see 'man<br>perlrun'. So I'm all over that.<br><br>But how do I yank and return just "We go to the " out of it?
<br><br>-todd<br>_______________________________________________<br>Cialug mailing list<br><a href="mailto:Cialug@cialug.org">Cialug@cialug.org</a><br><a href="http://cialug.org/mailman/listinfo/cialug">http://cialug.org/mailman/listinfo/cialug
</a><br></blockquote></div><br>