This is a test version of Biostars. For the public version, visit https://www.biostars.org.
How to output your variable to a file in Perl?

Lets say I have a variable $x=1. I want to print this variable to file, but not open a file ant print it there. Just output it in file form and not in my command promt . Any hint???. thanks!

output file perl print

Hello Dimitri C!

We believe that this post does not fit the main topic of this site.

Not a bioinformatics question. Just use "print $x" or "say $x"

For this reason we have closed your question. This allows us to keep the site focused on the topics that the community can help with.

If you disagree please tell us why in a reply below, we'll be happy to talk about it.

Cheers!

Via Perl:

open my $fh, ">", $fn or die "could not open $fn\n";
print $fh "$x\n";
close $fh;

Careful, there is a syntax error in your code (need to quote the mode).

0 answers

No answers yet.

Log in to answer this question.