PerlCookBook - henk52/knowledgesharing GitHub Wiki
- http://search.cpan.org/~mjd/Text-Template-1.46/lib/Text/Template.pm
- http://perldoc.perl.org/functions/uc.html
- http://perldoc.perl.org/perlre.html - regular expressions
- http://perldoc.perl.org/File/Temp.html - temporary files
- http://stackoverflow.com/questions/9444915/how-to-check-if-a-hash-is-empty-in-perl - empty hash
my $nEpoch = 0;
if ( $szTimeStampLine =~ m/.*?UTC seconds: (\d+)/ ) {
$nEpoch = $1;
}
use FindBin;
push( @INC, "$FindBin::RealBin", "$FindBin::RealBin/Linux" ); ## Path to local modules
system("$FindBin::RealBin/support_script.pl");
See: http://perldoc.perl.org/Getopt/Std.html
use Getopt::Std;
my %hOptions;
getopts('oif:', \%hOptions); # Values in %hOptions.
http://perldoc.perl.org/Getopt/Long.html
http://perldoc.perl.org/Carp.html
- http://www.perlmonks.org/?node_id=624484
- scalar @{ $arrayref }
- http://search.cpan.org/~mirod/XML-Twig-3.52/Twig.pm
- http://search.cpan.org/dist/XML-LibXML/LibXML.pod
- DEPRECATED: http://search.cpan.org/~grantm/XML-Simple-2.24/lib/XML/Simple.pm
- https://stackoverflow.com/questions/31589948/how-to-delete-a-node-from-xml-using-xmlsimple-in-perl
#!/usr/bin/perl -w
use strict;
use XML::Twig;
my $twig = XML::Twig->new;
$twig->parsefile('/tmp/v2vlibvirt1f5bf4.xml.org');
my ($eth1) = $twig->findnodes('/domain/devices/interface/source[@network]');
$eth1->set_att(network => "default");
my ($eth2) = $twig->findnodes('/domain/devices/interface/source[@network = "Ethernet 2"]');
$eth2->set_att(network => "j434_cont1");
for my $number ( $twig->findnodes('/domain/devices/disk[@device = "floppy"]') ) {
$number->delete;
}
# Hopefully this is the second cdrom entry.
for my $number ( $twig->findnodes('/domain/devices/disk/target[@dev = "hdb"]') ) {
$number->parent->delete;
}
$twig->set_pretty_print('indented_c');
$twig->print;
See: http://search.cpan.org/~mjd/Text-Template-1.46/lib/Text/Template.pm
use Text::Template;
- # $szHeadline would be 'description' then the HEADLINE content would be the same as the DESCRIPTION content.
- my $stmt = qq(UPDATE SERIES set HEADLINE = '$szHeadline', DESCRIPTION = '$szDescription' where ID=1;);
PerlCD3.0/tk/ch05_01.htm
- Text You get and set data through the return reference you get when creating the 'Text' field.
The '-variable' If set to one of the names in the list, will ensure that, that name is highlighted/selected.
You can provide the options as either an array of scalar or an array of hashes.
- If the option is a scalar, then both the -variable and @_ will be the option text.
- If the option is a hash, then both the -variable and @_ will be the option value(referenced in hash).
my $palette="Magenta";
my @colors = qw/Black red4 DarkGreen NavyBlue gray75 Red Green Blue
gray50 Yellow Cyan Magenta White Brown DarkSeaGreen DarkViolet/;
my $om = $window->Optionmenu(
-variable => \$palette,
-options => [@colors],
-command => [sub {print "args=@_ variable=$palette\n"}],
);
$om->pack;
#$om->addOptions(['chlorophyll' => '#8395ffff0000']);
- http://www.perlmonks.org/?node_id=634530
- file:///home/cadm/Dropbox/books/PerlCD3.0/tk/ch13_01.htm
- You can actually change the list at run-time, with the $widget-configure(--option => newvalue)
- Only use one geometry manager within the same area, otherwise you can cause infinite re-calculation loops.
- Each call to grid will create another row in the window.
- grid($widget1, $widget2, $widget3);
- $widget1->grid($widget2, $widget3);
- Special characters:
- "-" : span, previous to this coloumn.
- "x" : leave this cell empty.
- "^" : Span previous row into this one.
- http://www.perlmonks.org/?node_id=1050387 - Simple example of CGI (Perl) + HTML + CSS + Javascript/jQuery + Ajax
- MVP - Model View Presenter
- MVC - Model View Controller
- http://www.perlmonks.org/?node_id=402070 The Model View Controller pattern in web applications
- http://martinfowler.com/eaaDev/uiArchs.html
- http://stackoverflow.com/questions/8221210/how-to-avoid-globals-in-perl-tk-tkx-gui-programming-using-an-mvc-model?lq=1
Error: Evaluation Error: Error while evaluating a Resource Statement, Invalid resource type file_line at /etc/puppet/modules/logstash/elk.pp:34:1 on node localhost