No such thing as a small change | |
PerlMonks |
Print text on the same line after matchby periodicalcoder (Novice) |
on Dec 14, 2018 at 20:16 UTC ( [id://1227265]=perlquestion: print w/replies, xml ) | Need Help?? |
periodicalcoder has asked for the wisdom of the Perl Monks concerning the following question:
Hello all, it has been a while for me. You were all a huge help with my last project.
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
Back to
Seekers of Perl Wisdom
|
|