Skip to content

Instantly share code, notes, and snippets.

@zoffixznet

zoffixznet/md.md Secret

Created December 1, 2016 18:51
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save zoffixznet/b419d7c3c8a74c0e91f773a553c6c545 to your computer and use it in GitHub Desktop.
Save zoffixznet/b419d7c3c8a74c0e91f773a553c6c545 to your computer and use it in GitHub Desktop.

There were no print books available and only a handful of online resources like https://docs.perl6.org/, http://perl6intro.com/, [missing and] https://learnxinyminutes.com/docs/perl6/.

A direct translation to Perl 6 would use ".lc" (lowercase) as a Str method, and Perl 5's "binding operator" is now ~~ "smart match": [I wouldn't use "is now" since our binding operator is :=. Just say regex matching can be done with the smartmatch operator]

"(I could have also used the Python-like "end-with" operator.)" [ends-with is a method]

if $kegg-id.match(/^ K \d ** 5 $/) { It's also possible to write that with the smart-match operator if I wanted to get the Match: [ .match also gives you a Match ]

The ecosystem of Perl 6 modules doesn't match Perl 5's BioPerl or Python's BioPython, [ May be worth mentioning that most of Perl 5's modules work via Inline::Perl5, support for which is mandated by Perl 6's specification ]

that people can steal as much of steal as they want to get started. [ ...as much of steal... is that intentional? Never saw such usage ]

@cjfields
Copy link

cjfields commented Dec 1, 2016

A quick and dirty example of using perl5 BioPerl from Perl6:

use v6;

# This is using p5 BioPerl Bio::SeqIO
use Bio::SeqIO:from<Perl5>;

my $file = @*ARGS.shift;

# Note: left side needs quotes; keys are not automaically strings in p6
my $in = Bio::SeqIO.new('-format' => 'fasta', '-file' => $file);

my $ct = 0;

while $in.next_seq -> $record {
    say $record.display_id;
}

say "Count: $ct";

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment