in reply to Re^3: How to read a file containing filenames and pass as input to perl script?
in thread How to read a file containing filenames and pass as input to perl script?

Thanks, that works like a charm! One last question - I'm also trying to prefix every line in the output pipe separated file with this text "XML". I tried this, on the while loop right before the chomp, but the substitution isn't working as expected.
$xmlfile =~ 's/^/XML|/' ;
Where do i insert the above line in the code for the prefixing to work?
while (my $xmlfile = <$list>) { $xmlfile =~ 's/^/XML|/' ; chomp $xmlfile; $twig->parsefile($xmlfile); }

Replies are listed 'Best First'.
Re^5: How to read a file containing filenames and pass as input to perl script?
by hippo (Archbishop) on Apr 23, 2018 at 14:47 UTC
    $xmlfile =~ 's/^/XML|/' ;

    Omit the quotes:

    $xmlfile =~ s/^/XML|/;
Re^5: How to read a file containing filenames and pass as input to perl script?
by poj (Abbot) on Apr 23, 2018 at 15:20 UTC
    prefix every line in the output pipe separated file

    Use unshift to add 'XML' to the front of @values array

    sub process_EDI_DC40 { my ($twig, $thingy) = @_; my @values = map { my $ch = $thingy->first_child( $_ ); $ch ? $ch->text : "" } qw( DOCNUM MESTYP SNDPRN RCVPOR RCVPRN ); unshift @values,'XML'; # add $csv->say(*STDOUT, \@values); }
    poj
      unshift works perfectly, thanks!