How can I convert this Perl code to Java easily?

Discussion in 'Programming' started by SR_Bruno, Oct 18, 2008.

  1. #1
    I do not program in Perl or Java, but must convert this Perl code to Java by this Thursday (10/23/08). Any suggestions?

    Sal.



    #!/usr/bin/perl
    # $Id: pxref.perl,v 1.1 2008-10-14 18:34:55-07 - - $
    use strict;
    use warnings;

    $0 =~ s|/*$||;
    $0 =~ s|^.*/||;

    my $EXITCODE = 0;
    END {exit $EXITCODE}
    sub note(@) {print STDERR "@_"};
    $SIG{'__WARN__'} = sub {note @_; $EXITCODE = 1};
    $SIG{'__DIE__'} = sub {warn @_; exit};

    my $sep = ":" x 64;
    push @ARGV, "-" unless @ARGV;
    for my $filename (@ARGV) {
    my %xref;
    open my $file, "<$filename" or warn "$0: $filename: $!\n" and next;
    print "\n$sep\n$filename\n$sep\n\n";
    while (defined (my $line = <$file>)) {
    push @{$xref{$1}}, $. while $line =~ s|^.*?(\w+([-'.:/]\w+)*)||;
    }
    close $file;
    printf "%s [%d] %s\n", $_, @{$xref{$_}} + 0, join " ", @{$xref{$_}}
    for sort keys %xref;
    }
     
    SR_Bruno, Oct 18, 2008 IP
  2. MrMarvin

    MrMarvin Peon

    Messages:
    5
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    0
    #2
    Do you know what this code does?

    If you do, then just write new Java code that does the same.
     
    MrMarvin, Oct 23, 2008 IP