Path: utzoo!utgpu!news-server.csri.toronto.edu!cs.utexas.edu!uwm.edu!wuarchive!emory!ogicse!iwarp.intel.com!news From: merlyn@iwarp.intel.com (Randal L. Schwartz) Newsgroups: comp.lang.perl Subject: Re: Learning perl -- generlized file loading w/var assignment Message-ID: <1991Feb15.211722.4339@iwarp.intel.com> Date: 15 Feb 91 21:17:22 GMT References: <16785@venera.isi.edu> Sender: news@iwarp.intel.com Reply-To: merlyn@iwarp.intel.com (Randal L. Schwartz) Distribution: comp Organization: Stonehenge; netaccess via Intel, Beaverton, Oregon, USA Lines: 58 In-Reply-To: jas@ISI.EDU (Jeff Sullivan) In article <16785@venera.isi.edu>, jas@ISI (Jeff Sullivan) writes: | #Set abbreviation eval line (run for each abbr file.). | #$filestub will be set to the root of the file name, which is always | #of the form -LIST. | $eval_line = "%$filestub = ();\n&abbrev(*$filestub, @tmp);\n"; This stuff is getting double-quote interpreted even before $filestub is defined. Blech. Try this instead: ### if you cut here, you will likely damage your crt. :-) ### #!/usr/bin/perl # Load abbreviation package require "abbrev.pl"; #Load abbreviation files. foreach $filename ("ATTR-LIST", "HELP-LIST", "TYPE-LIST", "CMD-LIST") { # Open the file for input open(TMP, "$filename") || die "Can't load $filename: $!"; $filename =~ /(\w+)-LIST/; $filestub = $1; # or ($filestub = $filename) =~ s/\W.*//; #Slurp in the whole file, one line per element of @tmp @tmp = ; chop(@tmp); # toss those newlines # close the file close TMP; #Fill in the array of abbreviations. eval <<"END_EVAL"; die $@ if $@; %$filestub = (); &abbrev(*$filestub, \@tmp); END_EVAL } while (<>) { chop; $long = $CMD{$_}; print "$long\n" if length($long); } ### but if you cut up above, you might as well cut here too. :-) ### print "Just another Perl hacker," -- /=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: "Intel: putting the 'backward' in 'backward compatible'..."====/