Path: utzoo!attcan!utgpu!jarvis.csri.toronto.edu!cs.utexas.edu!samsung!usc!henry.jpl.nasa.gov!elroy.jpl.nasa.gov!jpl-devvax!lwall From: lwall@jpl-devvax.JPL.NASA.GOV (Larry Wall) Newsgroups: comp.unix.questions Subject: Re: Perl soelim (was Re: software tools question) Keywords: software tools question macro include text processing Message-ID: <6600@jpl-devvax.JPL.NASA.GOV> Date: 14 Dec 89 23:24:22 GMT References: <694@dgis.dtic.dla.mil> <128978@sun.Eng.Sun.COM> <5339@omepd.UUCP> <2586A576.9028@ateng.com> Reply-To: lwall@jpl-devvax.JPL.NASA.GOV (Larry Wall) Organization: Jet Propulsion Laboratory, Pasadena, CA Lines: 37 In article <2586A576.9028@ateng.com> chip@ateng.com (Chip Salzenberg) writes: : According to merlyn@iwarp.intel.com (Randal Schwartz): : >#!/usr/bin/perl -p : >next unless /^\.so\s+(.*)/; : >if (open(SO,$1)) { : > $_ = join("",); : > close(SO); : >} else { : > warn "Cannot open $1 at $ARGV (line $.): $!"; : >} : : I should really hope that people would prefer NOT to read in the entire : file and assign it to $_. Rather, I'd do this: : : #!/usr/bin/perl -p : next unless /^\.so\s+(\S+)/; # A better regexp : $SO = $1; : if (open(SO)) { : while () { : print; : } : close(SO); : } else { : warn "Cannot open $SO at $ARGV (line $.): $!"; : } : $_ = ""; # You forgot this, Randal : : >This only works one level deep (no nested .so's), and requires Perl : >3.0, although the only 3-ism is the "warn". : : Ditto. There's an example of nested include file processing (thought not specifically .so files) in the perl manual. Look under "open". Larry Wall lwall@jpl-devvax.jpl.nasa.gov