Tutorial by Examples

perl -pe"s/foo/bar/g" file.txt Or in-place: perl -i -pe's/foo/bar/g' file.txt On Windows: perl -i.bak -pe"s/foo/bar/g" file.txt
perl -lane'print "$F[0] $F[-1]"' data.txt # prints the first and the last fields of a space delimited record CSV example: perl -F, -lane'print "$F[0] $F[-1]"' data.csv
perl -ne'print if 5..10' file.txt
Without a backup copy (not supported on Windows) perl -i -pe's/foo/bar/g' file.txt With a backup copy file.txt.bak perl -i.bak -pe's/foo/bar/g' file.txt With a backup copy old_file.txt.orig in the backup subdirectory (provided the latter exists): perl -i'backup/old_*.orig' -pe's/foo/bar/g' ...
perl -0777 -ne'print "The whole file as a string: --->$_<---\n"' Note: The -0777 is just a convention. Any -0400 and above would de the same.
With XML::Rabbit it is possible to consume XML files easily. You define in a declarative way and with an XPath syntax what you are looking for in the XML and XML::Rabbit will return objects according to the given definition. Definition: package Bookstore; use XML::Rabbit::Root; has_xpath_object_...
It is good practice to test the calling program's __name__ variable before executing your code. import sys def main(): # Your code starts here # Don't forget to provide a return code return 0 if __name__ == "__main__": sys.exit(main()) Using this pattern ens...
Adding components one after another results in a UI that's hard to use, because the components all are somewhere. The components are ordered from top to bottom, each component in a separate "row". To remedy this and provide you as developer with a possibility to layout components easily S...
I always think it is nice to have a very simple, self-contained example so that nothing is assumed when I am learning a new task. This answer is that for deleting UITableView rows. The project performs like this: This project is based on the UITableView example for Swift. Add the Code Create a ...
Weka is a collection of machine learning algorithms for data mining tasks. The algorithms can either be applied directly to a dataset or called from your own Java code. Weka contains tools for data pre-processing, classification, regression, clustering, association rules, and visualization. It is al...
Margin is one of a few CSS properties that can be set to negative values. This property can be used to overlap elements without absolute positioning. div{ display: inline; } #over{ margin-left: -20px; } <div>Base div</div> <div id="over">Overlapping div&lt...
One of the easiest ways to deploy Grails 3.x is to build an executable jar file that embeds a servlet container (Tomcat, Undertow, etc) with the application. Modify build.gradle: // Remove or comment out the war plugin: // apply plugin:"war" // Enable the executable jar: springBoot ...
3.0 The => operator has the same precedence as the assignment operator = and is right-associative. It is used to declare lambda expressions and also it is widely used with LINQ Queries: string[] words = { "cherry", "apple", "blueberry" }; int shortestWordLength...
genRandom creates a stream of random numbers that has a one in four chance of terminating each time it's called. def genRandom: Stream[String] = { val random = scala.util.Random.nextFloat() println(s"Random value is: $random") if (random < 0.25) { Stream.empty[String] ...
curl -XGET 'http://www.example.com:9200/myIndexName/_count?pretty' Output: { "count" : 90, "_shards" : { "total" : 6, "successful" : 6, "failed" : 0 } } The index has 90 documents within it. Reference Link: Here
curl -XGET 'http://www.example.com:9200/myIndexName/myTypeName/1' Output: { "_index" : "myIndexName", "_type" : "myTypeName", "_id" : "1", "_version" : 1, "found": true, "_source&qu...
curl -XPUT 'www.example.com:9200/myIndexName?pretty' Output: { "acknowledged" : true } Reference Link: Here
curl 'www.example.com:9200/_cat/indices?v' output: health status index pri rep docs.count docs.deleted store.size pri.store.size green open logstash-2016.07.21 5 1 4760 0 4.8mb 2.4mb green open logstash-2016.07.20 5 1 7232 ...
curl -XDELETE 'http://www.example.com:9200/myIndexName?pretty' output: { "acknowledged" : true } Reference Link: Here
Let's say there's a collection called Todos and the autopublish package is added. Here is the basic component. import { createContainer } from 'meteor/react-meteor-data'; import React, { Component, PropTypes } from 'react'; import Todos from '/imports/collections/Todos'; export class List exte...

Page 492 of 1336