Beefy Boxes and Bandwidth Generously Provided by pair Networks
Your skill will accomplish
what the force of many cannot
 
PerlMonks  

Tommy's scratchpad

by Tommy (Chaplain)
on Dec 14, 2012 at 00:18 UTC ( #1008749=scratchpad: print w/ replies, xml ) Need Help??

#!/usr/bin/perl use strict; use warnings; use 5.10.0; use Fcntl qw( :flock ); use DB_File; my $db_file = '/var/tmp/dbfile_test'; my $db_hash = get_db_hash( $db_file ); $db_hash->{ rand 100 } = time; say for sort { uc $a cmp uc $b } keys %$db_hash; say scalar keys %$db_hash; exit; { my ( $dbobj, $dbfd, $dbfh, %dbhash ); sub get_db_hash { my $dbfile = shift @_; $dbobj = tie %dbhash, 'DB_File', $dbfile, O_TRUNC | O_CREAT, oct 644, $DB_HASH or die $!; $dbfd = $dbobj->fd; open $dbfh, '+<&=', $dbfd or die $!; flock $dbfh, LOCK_EX | LOCK_NB or die $!; return \%dbhash; } sub close_db_hash { flock $dbfh, LOCK_UN; undef $dbobj; untie %dbhash; } } END { local $@ = undef; eval { close_db_hash() }; warn $@ if $@; } __END__ use Modern::Perl; use Excel::Writer::XLSX; # Create a new Excel workbook my $workbook = Excel::Writer::XLSX->new( 'hello_perl_spreadsheet.xlsx' + ); # Add a worksheet my $worksheet = $workbook->add_worksheet(); # Add and define a format my $format = $workbook->add_format(); $format->set_bold(); $format->set_color( 'red' ); $format->set_align( 'center' ); # Write a formatted and unformatted string, row and column notation. my ( $col, $row ) = ( 0, 0 ); $worksheet->write( $row, $col, 'Hi Excel!', $format ); $worksheet->write( 1, $col, 'Hi Excel!' ); # Write a number and a formula using A1 notation $worksheet->write( 'A3', 1.2345 ); $worksheet->write( 'A4', '=SIN(PI()/4)' ); my $data = [ [ 'Product', 'Q1', 'Q2', 'Q3', 'Q4' ], [ 'Apples', 10000, 5000, 8000, 6000 ], [ 'Pears', 2000, 3000, 4000, 5000 ], [ 'Bananas', 6000, 6000, 6500, 6000 ], [ 'Oranges', 500, 300, 200, 700 ], ]; $worksheet->add_table( 'B3:F8', { data => $data, autofilter => 1, head +er_row => +1, banded_rows => 1 } ); say 'DONE'; exit;
Log In?
Username:
Password:

What's my password?
Create A New User
Chatterbox?
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others cooling their heels in the Monastery: (9)
As of 2015-04-27 13:45 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    Who makes your decisions?







    Results (503 votes), past polls