Beefy Boxes and Bandwidth Generously Provided by pair Networks
Welcome to the Monastery
 
PerlMonks  

RFC: Tutorial for "Using Google Cloud Shell with Perl"

by Corion (Pope)
on Jan 28, 2018 at 14:34 UTC ( #1208008=perlmeditation: print w/replies, xml ) Need Help??

Why would you want to?

Maybe you are just starting out with Perl and don't have a computer set up for Perl. Unix computers already include Perl, but maybe you don't have the permissions to run it on your computer.

Maybe you just want to try a Perl module for some external program that you don't want to install on your machine. Maybe you just got a bug report for Linux that you can't easily replicate. Maybe you are online and don't have access to your home machine. Maybe you just need 5GB of storage quickly.

You just need four steps to get to Perl in the Google Cloud Shell:

  1. Log in with your Google credentials

    That's how you pay for it - with information about yourself. Google will monitor what programs you invoke but not the command line parameters. In return, you get 5GB of permanent storage and a 2GB RAM virtual machine that includes Perl 5.24, other programming languages, the Google Cloud SDKs and other stuff.

  2. Set up CPAN to use local::lib

    Run the cpan command to perform the initial setup:

    cpan

    There, you need to answer two questions:

    • Choose the quick, no questions asked setup
    • Choose the proposed local::lib method of installing modules
  3. Install some stuff that you maybe want to try out

    Upgrade Test::More, because the Debian stock 1.01 version causes some spurious test failures
    cpan Test::More cpan App::cpanminus Moo Future::AsyncAwait DBD::SQLite
  4. Enjoy

More documentation on the Cloud Shell

Using the Cloud Shell as a web development environment

The cloud shell also comes with an included web proxy so that you (and only you) can try out web applications served from any web server on that machine. This makes the Cloud Shell a convenient testbed to try out web frameworks like Mojolicious, Dancer2, Dancer or even CGI::Application in PSGI mode.

Using Mojolicious

Install Mojolicious

cpan Mojolicious

Run minimal Mojolicious program:

perl -Mojo -E 'a("/hello" => {text => "Hello Mojo!"})->start' daemon - +l http://127.0.0.1:8080

Visit /hello in the Web Preview pane

Using Dancer2

Install Dancer2

cpan Dancer2

Run minimal Dancer2 program:

perl -MDancer2 -e 'set port => 8080; get "/" => sub { "<i>Just</i> Ano +ther <b>Perl</b> <u>Hacker</u>," }; dance'

Using Dancer with Twiggy

Install Dancer and Twiggy

cpan Dancer Twiggy

Run minimal Dancer program:

plackup -e 'use Dancer; get "/hello/:name" => sub { return "Why, hello + there " . param("name"); }; dance;' --port 8080 -s Twiggy

Visit /hello/yourname in the Web Preview pane

Replies are listed 'Best First'.
Re: RFC: Tutorial for "Using Google Cloud Shell with Perl"
by choroba (Bishop) on Jan 28, 2018 at 21:07 UTC
    Yay, I tried the following commands after upgrading Test::More:

    cpan Dancer2 perl -MDancer2 -e 'set port => 8080; get "/" => sub { "<i>Just</i> Ano +ther <b>Perl</b> <u>Hacker</u>," }; dance'

    I then clicked on the Web Preview icon (top right) and... voilą! It works!

    ($q=q:Sq=~/;[c](.)(.)/;chr(-||-|5+lengthSq)`"S|oS2"`map{chr |+ord }map{substrSq`S_+|`|}3E|-|`7**2-3:)=~y+S|`+$1,++print+eval$q,q,a,
Re: RFC: Tutorial for "Using Google Cloud Shell with Perl"
by Crosis (Beadle) on Apr 23, 2018 at 07:23 UTC

      While some servers are equipped with powerful GPUs, this is not typical. Most don't.

Log In?
Username:
Password:

What's my password?
Create A New User
Node Status?
node history
Node Type: perlmeditation [id://1208008]
Front-paged by Discipulus
help
Chatterbox?
and dust plays in a shaft of sunlight...

How do I use this? | Other CB clients
Other Users?
Others musing on the Monastery: (3)
As of 2018-07-18 03:12 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?
    It has been suggested to rename Perl 6 in order to boost its marketing potential. Which name would you prefer?















    Results (383 votes). Check out past polls.

    Notices?