This is actually a follow-up of that same project, and while I feel that this should be simple I cannot find (or don't know enough to adapt) a solution online. I have a text file with a line (there will only ever be a single line that matches) like this:
N1*PE*COMPANY NAME INC*XX*123456~
**edit: on Windows using Strawberry Perl with a .pl script** I need to extract the number at the end of this line, excluding the tilde, and add it to a variable so that $number = 123456. So far I have only been able to come up with the match regex, but I'm not sure how to get the text at the end. So far I have this which gives the entire line:
perl -ne "print if /INC\*XX\*/" cr835.txt
Inside my perl script I assume that I will use something like this, but of course including any recommended code changes:
my $number = "perl -ne "print if /INC\*XX\*/" cr835.txt";
My end goal is to detect this number and use it to rename the file. I already have the code tested for renaming the file with a timestamp and I just need help populating this variable.
Thanks a bunch!
peridicalcoder
In reply to Print text on the same line after match by periodicalcoder
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |