Path: utzoo!attcan!utgpu!jarvis.csri.toronto.edu!cs.utexas.edu!uunet!ateng!chip From: chip@ateng.com (Chip Salzenberg) Newsgroups: comp.unix.questions Subject: Re: Perl soelim (was Re: software tools question) Keywords: software tools question macro include text processing Message-ID: <2586A576.9028@ateng.com> Date: 13 Dec 89 19:39:31 GMT References: <694@dgis.dtic.dla.mil> <128978@sun.Eng.Sun.COM> <5339@omepd.UUCP> Organization: A T Engineering, Tampa, FL Lines: 34 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. -- You may redistribute this article only to those who may freely do likewise. Chip Salzenberg at A T Engineering; or "The Usenet, in a very real sense, does not exist."