meechl has asked for the wisdom of the Perl Monks concerning the following question:

Hi monks,

I would simply like to print out the character "&". All my attempts thus far have been futile, including use of "\&" or ascii codes. Thanks for the help!

Edit: Thanks for the replies! I am running perl on the command line and printing to a file. Here is the code for the out file generation and print statement:

my $outFile = $outbase . "_temp_stems_RNAcofold.txt"; open(OUT, ">$outFile") or die "Could not open $outFile.\n"; print OUT ">$name\t$compName\n$seq" . "&" . "$compSeq\n";

Edit 2: Wow, I'm an idiot. Was looking at the wrong output.

Replies are listed 'Best First'.
Re: Print &
by Your Mother (Archbishop) on May 04, 2016 at 17:19 UTC

    I have to assume you're printing to HTML. You want & if so. :P See also: HTML::Entities.

Re: Print &
by morgon (Priest) on May 04, 2016 at 17:09 UTC
    print '&';
    works for me.

    What exactly are you doing and what error do you get?

Re: Print &
by NetWallah (Canon) on May 04, 2016 at 20:45 UTC
    An alternative to Your Mother's proposal:

    If you are using the CGI module, use "escapeHTML".

    >perl -MCGI -E "say CGI::escapeHTML('&')" &

            This is not an optical illusion, it just looks like one.

Re: Print &
by toolic (Bishop) on May 04, 2016 at 17:10 UTC
    You need to post runnable code that you've tried. This works for me:
    use warnings; use strict; print "here is an ampersand ... & ...\n"; __END__ here is an ampersand ... & ...