exercism-perl5

Repository for my Perl 5 Exercism exercises
git clone git://git.samirparikh.com/exercism-perl5
Log | Files | Refs

commit 85e41fb8720fa5ef80ce73ed7018b9115f7be0dd
Author: Samir Parikh <noreply@samirparikh.com>
Date:   Tue, 16 Nov 2021 01:29:24 +0000

add hello-world

Diffstat:
Ahello-world/.exercism/config.json | 23+++++++++++++++++++++++
Ahello-world/.exercism/metadata.json | 2++
Ahello-world/HELP.md | 36++++++++++++++++++++++++++++++++++++
Ahello-world/HelloWorld.pm | 13+++++++++++++
Ahello-world/README.md | 36++++++++++++++++++++++++++++++++++++
Ahello-world/hello-world.t | 17+++++++++++++++++
6 files changed, 127 insertions(+), 0 deletions(-)

diff --git a/hello-world/.exercism/config.json b/hello-world/.exercism/config.json @@ -0,0 +1,23 @@ +{ + "blurb": "The classical introductory exercise. Just say \"Hello, World!\"", + "authors": [ + "m-dango" + ], + "contributors": [ + "kotp", + "rfilipo" + ], + "files": { + "solution": [ + "HelloWorld.pm" + ], + "test": [ + "hello-world.t" + ], + "example": [ + ".meta/solutions/HelloWorld.pm" + ] + }, + "source": "This is an exercise to introduce users to using Exercism", + "source_url": "http://en.wikipedia.org/wiki/%22Hello,_world!%22_program" +} diff --git a/hello-world/.exercism/metadata.json b/hello-world/.exercism/metadata.json @@ -0,0 +1 @@ +{"track":"perl5","exercise":"hello-world","id":"70019d15999f4389997fdb91e985fcb8","url":"https://exercism.org/tracks/perl5/exercises/hello-world","handle":"confidentidiot","is_requester":true,"auto_approve":false} +\ No newline at end of file diff --git a/hello-world/HELP.md b/hello-world/HELP.md @@ -0,0 +1,35 @@ +# Help + +## Running the tests + +There is a Perl 5 script with the extension `.t`, which will be used to test +your solution. You can run through the tests by using the command: + +```bash +`prove .` +``` + +## Submitting your solution + +You can submit your solution using the `exercism submit HelloWorld.pm` command. +This command will upload your solution to the Exercism website and print the solution page's URL. + +It's possible to submit an incomplete solution which allows you to: + +- See how others have completed the exercise +- Request help from a mentor + +## Need to get help? + +If you'd like help solving the exercise, check the following pages: + +- The [Perl 5 track's documentation](https://exercism.org/docs/tracks/perl5) +- [Exercism's support channel on gitter](https://gitter.im/exercism/support) +- The [Frequently Asked Questions](https://exercism.org/docs/using/faqs) + +Should those resources not suffice, you could submit your (incomplete) solution to request mentoring. + +To get help if you're having trouble, you can use one of the following resources: + +- [/r/perl5](https://www.reddit.com/r/perl5) is the perl5 subreddit. +- [StackOverflow](http://stackoverflow.com/questions/tagged/perl5) can be used to search for your problem and see if it has been answered already. You can also ask and answer questions. +\ No newline at end of file diff --git a/hello-world/HelloWorld.pm b/hello-world/HelloWorld.pm @@ -0,0 +1,13 @@ +# Declare package 'HelloWorld' +package HelloWorld; +use strict; +use warnings; +use Exporter qw<import>; +our @EXPORT_OK = qw<hello>; + +sub hello { + #return 'Goodbye, Mars!'; + return 'Hello, World!'; +} + +1; diff --git a/hello-world/README.md b/hello-world/README.md @@ -0,0 +1,35 @@ +# Hello World + +Welcome to Hello World on Exercism's Perl 5 Track. +If you need help running the tests or submitting your code, check out `HELP.md`. + +## Instructions + +The classical introductory exercise. Just say "Hello, World!". + +["Hello, World!"](http://en.wikipedia.org/wiki/%22Hello,_world!%22_program) is +the traditional first program for beginning programming in a new language +or environment. + +The objectives are simple: + +- Write a function that returns the string "Hello, World!". +- Run the test suite and make sure that it succeeds. +- Submit your solution and check it at the website. + +If everything goes well, you will be ready to fetch your first real exercise. + +## Source + +### Created by + +- @m-dango + +### Contributed to by + +- @kotp +- @rfilipo + +### Based on + +This is an exercise to introduce users to using Exercism - http://en.wikipedia.org/wiki/%22Hello,_world!%22_program +\ No newline at end of file diff --git a/hello-world/hello-world.t b/hello-world/hello-world.t @@ -0,0 +1,17 @@ +#!/usr/bin/env perl +use Test2::V0; + +use FindBin qw<$Bin>; +use lib $Bin, "$Bin/local/lib/perl5"; # Find modules in the same dir as this file. + +use HelloWorld qw<hello>; +plan 2; # This is how many tests we expect to run. + +imported_ok qw<hello> or bail_out; + +# Run the 'is' sub from 'Test2::V0' with three arguments. +is( + hello(), # Run the 'hello' sub imported from the module. + 'Hello, World!', # The expected result to compare with 'hello'. + 'Say Hi!' # The test description. +);