Hello again, I have the follwing text file (portion below)
[get4] $uri=/LRA/RiskApplicationPage.aspx $method=GET [get5] $uri=/LRA/CSS/RiskManagement.css $method=GET
I need to format it to look like this
[RiskApplicationPage.aspx get4] $uri=/LRA/RiskApplicationPage.aspx $method=GET [RiskManagement.css get5] $uri=/LRA/CSS/RiskManagement.css $method=GET
I want to take the text following the last / and copy it to the inside of the get before it. This is how I'm currently attempting it...
#!C:\Perl\bin\perl -w use Getopt::Std; $USAGE = <<USAGE; Usage: Absolute_Path\\file A script to adjust the request ID and replace it with something a little more descriptive USAGE ; # process command line getopts('x') || die $USAGE; # get parameters $script = shift || die $USAGE; # rename .tst file to a .txt file chomp ($script); my $temp = $script; $temp =~ s/\.tsv$//; $new_script = join("", $temp, ".txt"); rename ($script, $new_script); open (DATA, "$new_script") || die "Error: Couldn't open $new_script : $!\n"; while(<DATA>) { push @Array, $_; } foreach $_ (@Array) { if ($_ =~ /^\[get/) { $_ = join("", $_, "TEST"); print $_; } }
Any suggestions? Thanks

In reply to Need RegEx assistance by Anonymous Monk

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.