Re: GNU grep -C in Perl

2002-12-10 Thread John W. Krahn
"John W. Krahn" wrote: > > my $before = 1; > my $after = 1; > my @buffer; > > while ( my $line = ) { > > push @buffer, $line; > > shift @buffer if $#buffer > $before + $after; > > next if $#buffer < $before; > > if ( $buffer[ $before ] =~ /found matching regex/ ) { > >

Re: GNU grep -C in Perl

2002-12-10 Thread John W. Krahn
Jerry Rocteur wrote: > > Hi, Hello, > Anyone know how to write a grep -C in Perl ? Yes, someone definitely does: http://www.perl.com/language/ppt/src/grep/index.html > You know, I want to search for a string/regexp in a file and I want to > print the line before and the line a

Re: GNU grep -C in Perl

2002-12-10 Thread Jason Tiller
Hi, Jerry, :) On Tue, 10 Dec 2002, Jerry Rocteur wrote: > Anyone know how to write a grep -C in Perl ? Here is a script that mimics just the '-C' feature of GNU grep. It doesn't support the fanciness of printing filenames when multiple input files are specified. This may be

RE: GNU grep -C in Perl

2002-12-10 Thread Hanson, Rob
Message- From: Jerry Rocteur [mailto:[EMAIL PROTECTED]] Sent: Tuesday, December 10, 2002 3:23 PM To: [EMAIL PROTECTED] Subject: GNU grep -C in Perl Hi, Anyone know how to write a grep -C in Perl ? You know, I want to search for a string/regexp in a file and I want to print the line before

Re: GNU grep -C in Perl

2002-12-10 Thread Jerry Rocteur
c 10, 2002, at 21:22 Europe/Brussels, Jerry Rocteur wrote: Hi, Anyone know how to write a grep -C in Perl ? You know, I want to search for a string/regexp in a file and I want to print the line before and the line after the search string. I've tried a couple of ways and it takes a reall

Re: GNU grep -C in Perl

2002-12-10 Thread Larry Coffin
>Anyone know how to write a grep -C in Perl ? Why not just store the previous line, then when you have a match, print it, the matching line, then set a flag to print the next line as well? Something along the lines of: while ($line = ) { if ($print_n

GNU grep -C in Perl

2002-12-10 Thread Jerry Rocteur
Hi, Anyone know how to write a grep -C in Perl ? You know, I want to search for a string/regexp in a file and I want to print the line before and the line after the search string. I've tried a couple of ways and it takes a really long time, I load the file in memory, seach for the s

static variables and sub-routines with file-scope (like C) in Perl

2002-08-15 Thread Dharmendra Rai
hi, You may declare my variables at the outermost scope of a file to hide any such identifiers from the world outside that file. This is similar to C's static variables when they are used at the file level. To do this with a subroutine requires the use of a closure (an anonymous function th

Re: Embedding C in Perl

2002-08-01 Thread Paul Johnson
On Thu, Aug 01, 2002 at 10:13:42AM -0700, Andrew Killam wrote: > Hi, guys. This is my first message to the list, so if I'm violating > any posting procedures, please forgive me - I'll learn quickly enough. The only thing I would complain about is that your lines are too long, but I'd aim that m

Embedding C in Perl

2002-08-01 Thread Andrew Killam
Hi, guys. This is my first message to the list, so if I'm violating any posting procedures, please forgive me - I'll learn quickly enough. I'm working a program manipulating trees read in from a database. My employers want Perl used, but I believe parts of it would be better served using C fu

Re: C++ in perl.

2001-06-08 Thread Jeff Yoak
At 09:45 AM 6/8/01 -0400, [EMAIL PROTECTED] wrote: >Hey all, > >I'm rather new to perl, and was just woundering what was the best route to >go to Exec c++ from within a perl script. Is there a PM for this? I haven't used it personally, but there has been a fair amount of talk about Inline.pm .

Re: C++ in perl.

2001-06-08 Thread Peter_Farrar
cc: (bcc: Peter Farrar/Waltham/MCS/Concentra)| | Subject: C++ in perl.| >| Hey all, I'm rather new to perl, and was just wounder

Re: C++ in perl.

2001-06-08 Thread Chas Owens
On 08 Jun 2001 09:45:09 -0400, [EMAIL PROTECTED] wrote: > Hey all, > > I'm rather new to perl, and was just woundering what was the best route to > go to Exec c++ from within a perl script. Is there a PM for this? > > > > thank in advance. > > > Having never done it myself, I can only poin

C++ in perl.

2001-06-08 Thread kevin
Hey all, I'm rather new to perl, and was just woundering what was the best route to go to Exec c++ from within a perl script. Is there a PM for this? thank in advance.