[Israel.pm] Coroutines in Perl

Shlomi Fish shlomif at iglu.org.il
Thu Mar 9 08:30:17 PST 2006

On Thursday 09 March 2006 17:17, Madani, Srikanth, VF-DE wrote:
> Hi all!
> I want to use the RCS program rcs to break a lock on an RCS file set by
> another user. (rcs -u12.1.1 hello.c)
> The program asks me if I'm sure etc.:
> $> rcs -u12.1.1 hello.c
> Do you want to break the lock? [ny](n): y
> State the reason for breaking the lock:
> (terminate with single '.' or end of file)
> >> .
> unlocked
> done
> $>
> I want to make this non-interactive and execute through a Perl program.
> So my Perl code must not only call rcs with options -u12.1.1 hello.c,
> but also supply the needed 'y' character and '.' + 'carriage return'.

Try something along the following lines:

open my $rcs, "|rcs -u12.1.1 hello.c";
print {$rcs} "y\n.\n";

If this doesn't work for you, you should try Expect.pm. See "perldoc perlopen" 
for more information.

BTW, why are you calling this thing "coroutines"? Aren't coroutines 

> I'm running Perl v5.8.1 on GNU/Linux and Solaris.

v5.8.1 is very out of date. Consider upgrading.


	Shlomi Fish

Shlomi Fish      shlomif at iglu.org.il
Homepage:        http://www.shlomifish.org/

95% of the programmers consider 95% of the code they did not write, in the
bottom 5%.

More information about the Perl mailing list