Path: utzoo!attcan!uunet!snorkelwacker!usc!elroy.jpl.nasa.gov!jpl-devvax!lwall From: lwall@jpl-devvax.JPL.NASA.GOV (Larry Wall) Newsgroups: comp.lang.perl Subject: Re: internal pipes? chaining functions? Message-ID: <9678@jpl-devvax.JPL.NASA.GOV> Date: 26 Sep 90 17:20:40 GMT References: <1990Sep26.011749.2999@uvaarpa.Virginia.EDU> Reply-To: lwall@jpl-devvax.JPL.NASA.GOV (Larry Wall) Organization: Jet Propulsion Laboratory, Pasadena, CA Lines: 39 In article <1990Sep26.011749.2999@uvaarpa.Virginia.EDU> eichin@athena.mit.edu writes: : I've got a script which I was able to express conveniently as : tr \\015 \\012 | : sed -e 's/^[/^[F\n' -e 's/\(%CO:.,[0-9]*,[0-9]*%\)/\1\n/' | : perl mksc.perl : : (where mksc is a while(<>) { if(//)..elsif(//)..else.. } script.) I : expect there is a convenient way of expressing the whole thing in : perl, but I'm not quite sure what it is... Essentially, I'd like to : have the nicer features (like <>) in later stages be able to operate : on the result of earlier ones. Is there a "model" that I'm missing : here, or is this just messy? I know I could do this with three perl : processes easily enough. Going from that to one is the important part. tr and sed commands are easily translated to the corresponding Perl commands (disregarding the fact that your first sed substitution is missing its trailing slash). while (<>) { tr/\015/\012/; s/^\[/^[F\n/; s/(%CO:.,\d*,\d*%)/$1\n/; if (//) ... elsif (//) ... } Or something like that, depending on whether there are line feeds after the carriage returns. If not, then you probably just want: $/ = "\015"; # Set input delimiter. while (<>) { s/\r$/\n/; # Or just chop it. s/^\[/^[F\n'; s/(%CO:.,\d*,\d*%)/$1\n/; if (//) ... elsif (//) ... } Larry