use strict; use IPC::Open2; my $pid = open2 (\*RDRFH, \*WTRFH, '/usr/bin/wc', '-c') or die "Couldn't open pipe to wc: $!"; if ($pid) { my $string = "shoes and ships and sealing wax"; print WTRFH $string; close (WTRFH); my $len = ; $len =~ s/^\s+//; print "length: $len"; close (RDRFH); }