Beefy Boxes and Bandwidth Generously Provided by pair Networks
Perl: the Markov chain saw

Re: Including files

by Aristotle (Chancellor)
on Sep 26, 2004 at 16:16 UTC ( #393966=note: print w/replies, xml ) Need Help??

in reply to Including files

You probably want to fix this:

my $code = join( "\n", qq[#line 1 "$filename"], File::Slurp::read_file($filename) );

You provide list context to read_file, only to then glue all the lines back together anyway. Except that you didn't chomp them, so joining with \n doubles all EOLs which throws off your line numbers. You want a simple concatenation instead.

my $code = qq[#line 1 "$filename"\n] . File::Slurp::read_file($filenam +e);

Very nice work on the node.

Makeshifts last the longest.

Replies are listed 'Best First'.
Re^2: Including files
by Juerd (Abbot) on Sep 26, 2004 at 20:24 UTC

    You provide list context to read_file, only to then glue all the lines back together anyway.

    Oops. That join is a left over bit of an earlier, more complex, attempt. Because Perl doesn't care about double newlines, and I didn't test with multi-line strings, and haven't even looked at line numbers, I never noticed that anything was wrong.

    You are of course right that simple concatenation is better here. I'll update the node right away.

    Juerd # { site => '', plp_site => '', do_not_use => 'spamtrap' }

Log In?

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://393966]
[Corion]: Two-way data binding means that if you change something in a text box, the corresponding variable in your Javascript gets updated immediately as well, and if you then change the variable, the corresponding text box also gets updated
[Corion]: That is a horrible approach that was also taken by Access, but if you have hooks that prevent automatic saving to the database, it is incredibly handy

How do I use this? | Other CB clients
Other Users?
Others drinking their drinks and smoking their pipes about the Monastery: (9)
As of 2017-03-30 07:56 GMT
Find Nodes?
    Voting Booth?
    Should Pluto Get Its Planethood Back?

    Results (355 votes). Check out past polls.