Well, why didn't you just say so? Here's an uglier
script that does something similar; namely, it 'clones'
packages to a new name and location.

use Win32; use Cwd; print<<EOTitle; ##################################################################### # # Rob's package cloner # # Clones entire packages. # ##################################################################### EOTitle my $source = Win32::GetCwd; my $sourcePackage; my $dest = Win32::GetCwd; my $destPackage; my $oldSub; my $newSub; my @files; $sourcePackage = $1 if $source =~ /^.*\\(com\\nortel\\ipc.*)$/; $sourcePackage =~ s/\\/\./g; print "The script has found this package to clone: $sourcePackage\n"; $oldSub = &query( 'Which part of the package name is changing?' ); $newSub = &query( 'What is that part changing to? ' ); $destPackage = $sourcePackage; $destPackage =~ s/$oldSub/$newSub/; $dest =~ s/$sourcePackage/$destPackage/; $dest =~ s/\./\\/g; print "\n Cloning\n package $sourcePackage into\n package $de +stPackage\n"; print "\n Using these directories:\n $source and\n $dest\n"; unless ( &query( "\nOkay?" ) =~ /[YKyk]/ ) { die "Okay. Script aborted.\n"; } mkdir $dest, 0777; print Win32::GetCwd; print "\nCopying package files...\n\n"; system( "xcopy *.java $dest\\" ); print "\ndone.\n"; chdir $dest; print Win32::GetCwd; print "\nEditing package files...\n\n"; @files = <*.java>; foreach ( @files ) { print "$_\n"; &checkFile( $_ ); } print "\ndone.\n"; print "\nScript done.\n"; sub query { my ($question) = @_; my $reply; print "$question "; chomp( $reply = <STDIN> ); return $reply; } sub checkFile { my ($file) = @_; open( IN, $file ) || (print STDERR "ERROR: cannot read $file\n", ne +xt); my @data = <IN>; close IN; foreach ( @data ) { if (/^\s*package\s*$sourcePackage\s*;$/) { print " - repackaged: old: $_"; $_ = "package $destPackage;\n"; print " new: $_"; } if ( /^\s*import\s*/ && /$oldSub/) { print " - import fixed: old: $_"; s/$oldSub/$newSub/; print " new: $_"; } } open( OUT, ">$file" ) || (print STDERR "ERROR: cannot write $file\n +", next); print OUT @data; close OUT; }
rje

In reply to Re: Re: Java Repackager... by rje
in thread Java Repackager... by rje

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.