Path: utzoo!utgpu!jarvis.csri.toronto.edu!mailrus!cs.utexas.edu!sun-barr!newstop!sun!bitbug From: bitbug@lonewolf.sun.com (James Buster) Newsgroups: comp.lang.perl Subject: script efficiency improvement Message-ID: Date: 3 Jan 90 06:55:03 GMT Sender: news@sun.Eng.Sun.COM Organization: Sun Microsystems Federal, Inc. Lines: 35 I have the following script, called make_symlinks: #!/usr/local/bin/perl # make_symlinks: each argument is 'oldfile newlink' while (<>) { chop; $limit = (@array = split); for ($i = 0; $i < $limit; $i++) { symlink(@array[$i], @array[++$i]); } } This script takes argument pairs (from standard input usually) of the form 'oldfile link', and makes symbolic links to 'oldfile'. Its primary purpose is the create clone symlink trees of a directory hierarchy. I would like any pointers on how this script may be optimized. Here is how this script is invoked (from a much larger /bin/sh script: THERE=`(cd $1; pwd)` type_arg="! -type d" (cd $THERE; find . $type_arg -print | sed -e 's/^..//') | \ sed -e "s/'/'\\\\''/" -e "s#.*#$THERE/& &#" | $BIN/make_symlinks I would also appreciate any pointers on how this these sh pipelines can be optimized. Thanks for your support (and perl!). -- --------------------------------------------------------------------- James Buster (Domain) bitbug@lonewolf.ebay.sun.com Mad Hacker Extraordinaire (UUCP) ...!sun.com!lonewolf!bitbug ---------------------------------------------------------------------