Beefy Boxes and Bandwidth Generously Provided by pair Networks
Perl-Sensitive Sunglasses
 
PerlMonks  

comment on

( [id://3333]=superdoc: print w/replies, xml ) Need Help??
Toolic, that did work, and thank you!

One detail that I forgot to mention, and I edited the original post, is that I am working on Windows with Strawberry Perl. I had some trouble integrating the command into my script and could not store the output into a variable as it just went to stdout due to the "print $1 if" portion. I tried to redirect stdout, and not using "print" at all, but I ended up creating a temp file using this code to store the resulting number in a variable:

use IO::Handle; # Extract the Payee ID from the file and store it into a temporary fil +e my $payeeid; system( q(perl -ne "print $1 if /INC\*XX\*(\d+)/" cr835.txt > payee.tx +t) ); # Define a file variable and read the contents to a variable my $file; $file = path("./payee.txt"); my $payeeid = $file->slurp; # Define the date and time for use in the new file name use constant DATETIME => strftime("%Y-%m-%d_%H-%M", localtime); # Define the new file name my $file = "CR835.txt"; my $newfilename = "CR835-" . $payeeid . "-processed_" . DATETIME . ".t +xt"; # Rename the file move $file, $newfilename;
Is there a better way to store the result into the variable?

In reply to Re^2: Print text on the same line after match by periodicalcoder
in thread Print text on the same line after match by periodicalcoder

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



  • Are you posting in the right place? Check out Where do I post X? to know for sure.
  • Posts may use any of the Perl Monks Approved HTML tags. Currently these include the following:
    <code> <a> <b> <big> <blockquote> <br /> <dd> <dl> <dt> <em> <font> <h1> <h2> <h3> <h4> <h5> <h6> <hr /> <i> <li> <nbsp> <ol> <p> <small> <strike> <strong> <sub> <sup> <table> <td> <th> <tr> <tt> <u> <ul>
  • Snippets of code should be wrapped in <code> tags not <pre> tags. In fact, <pre> tags should generally be avoided. If they must be used, extreme care should be taken to ensure that their contents do not have long lines (<70 chars), in order to prevent horizontal scrolling (and possible janitor intervention).
  • Want more info? How to link or How to display code and escape characters are good places to start.
Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others chanting in the Monastery: (4)
As of 2024-04-18 18:37 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found