agidden has asked for the wisdom of the Perl Monks concerning the following question:
Note that the end of each line is escaped with a backslash. We expected to have to do this. But we get this error when you run the script on Sun UNIX:#!/usr/bin/csh -f # perl -e '$outputDir = "/tmp/foo/";\ $input = "file.java";\ open( INPUT_FILE,"<$input" ) or die ("Could not open $input :$!"); \ $file = "";\ $dir = "";\ $package = "";\ @imports = "";\ while( <INPUT_FILE> ) {\ if(s/^\/\/<END_CLASS: (.*) ?$/$1/) {\ close(OUTPUT);\ $file = "";}\ if($file) {\ print OUTPUT $_;}\ if(s/^package ([a-zA-Z\._0-9]+).*$/$1/) {\ $package = $dir = $1;\ $dir =~ tr/\./\//;}\ if(/^import.*/) {\ push(@imports,$_);}\ if(s/^\/\/<BEGIN_CLASS: ([a-zA-Z_0-9]+).*$/$1/) {\ if($dir) {\ $file = "$dir/$1.java";\ } else {\ $file = "$1.java";}\ open(OUTPUT,">$outputDir$file") or die("Could not open output file + $outputDi r$file $!"); \ print "Created $file\n";\ if($package) {\ print OUTPUT "package $package;\n";}\ print OUTPUT @imports;\ }\ }\ close( INPUT_FILE );'
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: Need help using Perl -e in C shell
by merlyn (Sage) on Apr 27, 2005 at 19:02 UTC | |
by agidden (Novice) on Apr 27, 2005 at 21:10 UTC | |
|
Re: Need help using Perl -e in C shell
by Corion (Patriarch) on Apr 27, 2005 at 19:01 UTC | |
by agidden (Novice) on Apr 27, 2005 at 21:03 UTC | |
|
Re: Need help using Perl -e in C shell
by davidrw (Prior) on Apr 27, 2005 at 19:16 UTC | |
|
Re: Need help using Perl -e in C shell
by blazar (Canon) on Apr 28, 2005 at 10:15 UTC |