Tutorial by Examples

If you'd like to start implementing best practices, for yourself or your team, then Perl::Critic is the best place to start. The module is based on the Perl Best Practices book by Damien Conway and does a fairly good job implementing the suggestions made therein. Note: I should mention (and Conwa...
Install DateTime on your PC and then use it in perl script: use DateTime; Create new current datetime $dt = DateTime->now( time_zone => 'Asia/Ho_Chi_Minh'); Then you can access elements's values of date and time: $year = $dt->year; $month = $dt->month; $day = $dt->day; $...
Set single element: $dt->set( year => 2016 ); Set many elements: $dt->set( year => 2016, 'month' => 8); Add duration to datetime $dt->add( hour => 1, month => 2) Datetime subtraction: my $dt1 = DateTime->new( year => 2016, month => 8, ...
#!/usr/bin/env perl use Dancer2; get '/' => sub { "Hello World!" }; dance;
#!/usr/bin/perl use Term::ANSIColor; print color("cyan"), "Hello", color("red"), "\tWorld", color("green"), "\tIt's Me!\n", color("reset");
Time::Piece is available in perl 5 after version 10 use Time::Piece; my $date = localtime->strftime('%m/%d/%Y'); print $date; Output 07/26/2016
use strict; use warnings; use Gtk2 -init; my $window = Gtk2::Window->new(); $window->show(); Gtk2->main(); 0;
perl -Mojo -E 'p("http://localhost:3000" => form => {Input_Type => "XML", Input_File => {file => "d:/xml/test.xml"}})' File d:/xml/test.xml will be uploaded to server which listen connections on localhost:3000 (Source) In this example: -Mmodule execu...
Perl has a number of sigils: $scalar = 1; # individual value @array = ( 1, 2, 3, 4, 5 ); # sequence of values %hash = ('it', 'ciao', 'en', 'hello', 'fr', 'salut'); # unordered key-value pairs &function('arguments'); # subroutine *typeglob; # symbol table entry These look like sigils, but...
Type below command: instmodsh It'll show you the guild as below: Available commands are: l - List all installed modules m <module> - Select a module q - Quit the program cmd? Then type l to list all the installed modules, you can also use command m &l...
Pig provides an engine for executing data flows in parallel on Hadoop. It includes a language, Pig Latin, for expressing these data flows. Pig Latin includes operators for many of the traditional data operations (join, sort, filter, etc.), as well as the ability for users to develop their own fun...
package main import ( "fmt" "k8s.io/client-go/1.5/kubernetes" "k8s.io/client-go/1.5/pkg/api/v1" "k8s.io/client-go/1.5/tools/clientcmd" ) func main() { config, err := clientcmd.BuildConfigFromFlags("", <kube-config-path&g...
A Bootstrap modal dialog is a Bootstrap component which creates a modal dialog window which floats over page-level content. Here is an example of the basic usage of a Bootstrap modal dialog in HTML: <div class="modal fade" tabindex="-1" role="dialog"> <div...
Modal dialog components can be instantiated via jQuery with the function $('#myModal').modal(options), where $('#myModal') is a top-level reference to the specific modal dialog and options is a Javascript object specifying the modal dialog's default attributes. The options object allows for multipl...
ARFF files (Attribute-Relation File Format) are the most common format for data used in Weka. Each ARFF file must have a header describing what each data instance should be like. The attributes that can be used are as follows: Numeric Real or integer numbers. Nominal Nominal attributes m...
Depending on the version of Weka being used different methods for loading ARFF files should be utilised. Weka <3.5.5 The following sample code shows how to load an ARFF file: import weka.core.Instances; import java.io.BufferedReader; import java.io.FileReader; ... BufferedReader reader = n...
Many databases can be used in Weka. Firstly, the DatabaseUtils.props file must be edited to match your database; specifically you must provide your database's name, location, port and correct driver. jdbcDriver=org.gjt.mm.mysql.Driver jdbcURL=jdbc:mysql://localhost:3306/my_database Then the dat...
IronPython enables to use generic classes and methods from the .net framework. Generics can be used with the same syntax as accessing an index. For passing more than one type-parameter, they must be separated with a comma: l = Dictionary[int, str]() That way we create a dictionary where keys on...
url = 'http://your_url' files = {'file': open('myfile.test', 'rb')} r = requests.post(url, files=files)
url = 'http://httpbin.org/post' files = {'file': ('report.xls', open('report.xls', 'rb'), 'application/vnd.ms-excel', {'Expires': '0'})} r = requests.post(url, files=files)

Page 822 of 1336