Dear Monks,

Thank you so much for your help

The code worked fine, but curiosity got the better of me and I tried to find a way how specify both infile and outfile on the command line.

This was the point when I realised that I have not yet proper understood how functions and parameters work, especially how to pass arguments to a function. I guess it is back to books for me.

While reading the code, I was thinking that parsefile was the crucial element and this is where my infile should go through. However I could not establish the connection between parsefile and the  $ofh open in the first lines.

However when I tried the new code I always got the following message:

.pm line 773. Couldn't open : No such file or directory at replace_tmx_ori.pl line 19. at replace_tmx_ori.pl line 19.

I figure the programm does not know which file is passed for input

Is there a possibility to specify the in and outfile in the code? Please find my endeavours below

Comments and explanations are appreciated.

my $infile = $ARGV[0]; my $outfile = $ARRGV[2]; open my $ofh, '>:utf8', $outfile or die $!; XML::Twig->new( keep_spaces => 1, twig_print_outside_roots => $ofh, twig_roots => { tu => sub { my ($twig, $elt) = @_; $elt->set_att('creationid',"Simon Simonsen"); $elt->print($ofh); } }, )->parsefile( $infile ); close $ofh;

Thanks a mil in advance for helping us noobs out here

kind regards C.

In reply to Re^4: help with regular expression required by PitifulProgrammer
in thread help with regular expression required by PitifulProgrammer

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.