Beefy Boxes and Bandwidth Generously Provided by pair Networks
XP is just a number
 
PerlMonks  

Re^4: help with regular expression required

by PitifulProgrammer (Acolyte)
on Aug 18, 2014 at 15:25 UTC ( [id://1097863]=note: print w/replies, xml ) Need Help??


in reply to Re^3: help with regular expression required
in thread help with regular expression required

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.

Replies are listed 'Best First'.
Re^5: help with regular expression required
by Anonymous Monk on Aug 18, 2014 at 15:53 UTC
    my $outfile = $ARRGV[2];

    Perhaps you meant $ARGV[1]?

    I can only assume you removed the use warnings; use strict; from the top of the script, otherwise, Perl would have told you about the typo. So don't do that!

      Yeah, I cannot believe how stupid I was. I mean I always keep strict and warnings enabled as my teacher told me.

      In my search for the error I ignored the RR and was just thinking about the usual mistakes, i.e. wrong assignment etc.

      I will pay more attention to conventional spelling mistakes in the future.

      Thanks for your reply.

      I need to continue with this experiment. More questions ahead :)

      Kind regards

      C.

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: note [id://1097863]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others sharing their wisdom with the Monastery: (4)
As of 2024-04-25 13:27 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found