Path: utzoo!utgpu!jarvis.csri.toronto.edu!cs.utexas.edu!tut.cis.ohio-state.edu!ucbvax!decwrl!orc!mipos3!iwarp.intel.com!news From: merlyn@iwarp.intel.com (Randal Schwartz) Newsgroups: comp.lang.perl Subject: Re: StreamPerl (Was Re: Randal's one-liners) Message-ID: <1990Mar10.015518.4776@iwarp.intel.com> Date: 10 Mar 90 01:55:18 GMT References: Sender: news@iwarp.intel.com Reply-To: merlyn@iwarp.intel.com (Randal Schwartz) Organization: Stonehenge; netaccess via Intel, Beaverton, Oregon, USA Lines: 73 In-Reply-To: jv@mh.nl (Johan Vromans) In article , jv@mh (Johan Vromans) writes: | I found the following perl program very helpful in exercizing Randal's | one-liners: | | #!/usr/bin/perl | eval "exec perl -S $0 $*" | if $running_under_some_shell; | # | # StreamPerl - execute perl program from standard input | # | ($version,$patchlevel) = $] =~ /(\d+.\d+).*\nPatch level: (\d+)/; | print "StreamPerl version $version, patchlevel $patchlevel\n"; | | $prog = "/usr/tmp/spl$$"; | open (TMP, ">$prog") || die "Cannot create $prog, stopped"; | | print TMP while ; | close TMP; | | do $prog; | | unlink ($prog); Izzer something wrong with: some_process_that_generates_perl | perl instead of your script above? That's how *I* execute fragments from news postings. (I use GNU Emacs to read news, so I just mark a fragment as a region, then feed the region as stdin to Perl. In fact, the sequence "mark-region", ESC-| perl , is very much locked into my fingers... especially while attacking a new .sig. :-) | In addition, the following program, based on the idea of a perl shell, | has proven very helpful on trying perl: | | #!/usr/local/bin/perl | eval "exec perl -S $0 $*" | if $running_under_some_shell; | | ($version,$patchlevel) = $] =~ /(\d+.\d+).*\nPatch level: (\d+)/; | print "Interactive Perl version $version, patchlevel $patchlevel\n"; | | $Prompt = 'perl> '; | $Printing = "\n"; | print $Prompt; | while () { | $Pres = eval $_ . ';'; | print $Pres.$Printing if $Printing; | print $@; | print $Prompt; | } This is very similar to 'perlsh' in the old distribution. I now do something a *whole* lot simpler: perl -de '0;' Yup. That's right. Debug a simple program given on the command line. Larry was even going to look at removing the need for the semicolon in a command line '-e' switch (ala 'eval'), so I could just type: perl -de 0 but that didn't make it into Patch 9 from who-knows-where. Maybe Patch 13 (the one that fixes the debugger...? :-). printf "%c"x 25,74,117,115,116,32,97,110,111,116,104,101,114,32,80,101,114,108,32,104,97,99,107,101,114,44; -- /=Randal L. Schwartz, Stonehenge Consulting Services (503)777-0095 ==========\ | on contract to Intel's iWarp project, Beaverton, Oregon, USA, Sol III | | merlyn@iwarp.intel.com ...!any-MX-mailer-like-uunet!iwarp.intel.com!merlyn | \=Cute Quote: "Welcome to Portland, Oregon, home of the California Raisins!"=/