in reply to Re: Print Output to New File (UPDATED)
in thread Print Output to New File

Hi thanos1983,

What is p %hash;? Typo?

$ perl -c 1202669.pl Operator or semicolon missing before %hash at 1202669.pl line 13. Ambiguous use of % resolved as operator % at 1202669.pl line 13. Bareword "p" not allowed while "strict subs" in use at 1202669.pl line + 13. Bareword "hash" not allowed while "strict subs" in use at 1202669.pl l +ine 13. 1202669.pl had compilation errors


The way forward always starts with a minimal test.

Replies are listed 'Best First'.
Re^3: Print Output to New File (UPDATED)
by thanos1983 (Parson) on Nov 03, 2017 at 15:50 UTC

    Hello 1nickt,

    I was experimenting with Data::Printer as an alternative way.

    You can use it for example like:

    use Data::Printer; p %hash;

    This why you could see the printing part. Hope is more clear now. :)

    Update: Sample of code that I was experimenting, see below:

    #!/usr/bin/perl use strict; use warnings; use Data::Printer; my %hash = ( ';LCBO - Prolactin precursor - Bovine' => "a sample seque +nce in FASTA format MDSKGSSQKGSRLLLLLVVSNLLLCQGVVSTPVCPNGPGNCQVSLRDLFDRAVMVSHYIHD +LSS EMFNEFDKRYAQGKGFITMALNSCHTSSLPTPEDKEQAQQTHHEVLMSLILGLLRSWNDPL +YHL VTEVRGMKGAPDAILSRAIEIEEENKRLLEGMEMIFGQVIPGAKETEPYPVWSGLPSLQTK +DED ARYSAFYNLLHCLRRDSSKIDTYLKLLNCRIIYNNNC*" ); my $filename = 'output.txt'; open(my $fh, '>', $filename) or die "Could not open file '$filename' $!"; p(%hash, output => $fh); close $fh or warn "Could not open file '$filename' $!"; print "Done\n"; __END__ $ perl test.pl Done $ cat output.txt { ';LCBO - Prolactin precursor - Bovine' "a sample sequence in FAS +TA format MDSKGSSQKGSRLLLLLVVSNLLLCQGVVSTPVCPNGPGNCQVSLRDLFDRAVMVSHYIHD +LSS EMFNEFDKRYAQGKGFITMALNSCHTSSLPTPEDKEQAQQTHHEVLMSLILGLLRSWNDPL +YHL VTEVRGMKGAPDAILSRAIEIEEENKRLLEGMEMIFGQVIPGAKETEPYPVWSGLPSLQTK +DED ARYSAFYNLLHCLRRDSSKIDTYLKLLNCRIIYNNNC*" }

    BR / Thanos

    Seeking for Perl wisdom...on the process of learning...not there...yet!