Sponsored Content
Top Forums Shell Programming and Scripting PERL: DBI - Is it possible to get a "nicer" formatted return? Post 302924574 by drl on Monday 10th of November 2014 05:46:24 PM
Old 11-10-2014
Automatic alignment code: perl align

Hi.
Code:
$ align z3
FIELDA   FIELDB   FIELDC FIELDD FIELDE

AAAAAAAA MASTER   0      0      0
AAAAAAAA ABCD     0      0      0
BBBBBBBA DEFG     0      0      0
BBBBBBBA ABCDEF01 0      0      0
CCCCCCCA ABCDEF02 0      0      0
CCCCCCC1 MASTER   0      0      0

for more separation we increase the gutter:
Code:
$ align -g 4 z3
FIELDA      FIELDB      FIELDC    FIELDD    FIELDE

AAAAAAAA    MASTER      0         0         0
AAAAAAAA    ABCD        0         0         0
BBBBBBBA    DEFG        0         0         0
BBBBBBBA    ABCDEF01    0         0         0
CCCCCCCA    ABCDEF02    0         0         0
CCCCCCC1    MASTER      0         0         0

The perl code for align can be obtained at align

This was done on a system:
Code:
OS, ker|rel, machine: Linux, 2.6.26-2-amd64, x86_64
Distribution        : Debian 5.0.8 (lenny, workstation) 
align 1.7.0

Best wishes ... cheers, drl
This User Gave Thanks to drl For This Post:
 

9 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

perl "system" cmd return values..

perl 5.6.1: when i try a "system" command(with if loops for $?), i get this: child exited with value 1 what is meant by this $? values and what does it meant if it returns 1?.. (0 Replies)
Discussion started by: sekar sundaram
0 Replies

2. UNIX for Dummies Questions & Answers

Explain the line "mn_code=`env|grep "..mn"|awk -F"=" '{print $2}'`"

Hi Friends, Can any of you explain me about the below line of code? mn_code=`env|grep "..mn"|awk -F"=" '{print $2}'` Im not able to understand, what exactly it is doing :confused: Any help would be useful for me. Lokesha (4 Replies)
Discussion started by: Lokesha
4 Replies

3. Shell Programming and Scripting

Perl - How to print a "carriage return" to an output file?

Let's say I want to write a program that run these 4 UNIX commands and redirect output to a file. #!/usr/local/bin/perl use strict; `cd \$HOME > output.txt`; `cut -f1 inputfile.txt >> output.txt`; `hostname >> output.txt`; `ifconfig >> output.txt`; I want to print a "carriage return"... (5 Replies)
Discussion started by: teiji
5 Replies

4. Shell Programming and Scripting

perl folder list with "..", without ".".

Hi Everyone, if my folder "foldera" inside has one file. so if i do if ($df =~ /^\./) { next; } then i will get ### filea ### if i want to have ### .. filea ### means also display the parent .., how should i modify the perl ~// in my code? Thanks ---------- Post updated... (6 Replies)
Discussion started by: jimmy_y
6 Replies

5. Shell Programming and Scripting

awk command to replace ";" with "|" and ""|" at diferent places in line of file

Hi, I have line in input file as below: 3G_CENTRAL;INDONESIA_(M)_TELKOMSEL;SPECIAL_WORLD_GRP_7_FA_2_TELKOMSEL My expected output for line in the file must be : "1-Radon1-cMOC_deg"|"LDIndex"|"3G_CENTRAL|INDONESIA_(M)_TELKOMSEL"|LAST|"SPECIAL_WORLD_GRP_7_FA_2_TELKOMSEL" Can someone... (7 Replies)
Discussion started by: shis100
7 Replies

6. Shell Programming and Scripting

Perl failure with "main::$fn" used only once:" in error logs

Hi all, Can anyone guess why this is happening? I am new to Perl, so please help me to fix this error: - I have a static html file which calls the cgi-perl script. HTML Code: <html> <head> <title> Hey Dude! </title> </head> <body> <form method="POST"... (3 Replies)
Discussion started by: bashily
3 Replies

7. UNIX for Dummies Questions & Answers

Using "mailx" command to read "to" and "cc" email addreses from input file

How to use "mailx" command to do e-mail reading the input file containing email address, where column 1 has name and column 2 containing “To” e-mail address and column 3 contains “cc” e-mail address to include with same email. Sample input file, email.txt Below is an sample code where... (2 Replies)
Discussion started by: asjaiswal
2 Replies

8. Shell Programming and Scripting

Bash script - Print an ascii file using specific font "Latin Modern Mono 12" "regular" "9"

Hello. System : opensuse leap 42.3 I have a bash script that build a text file. I would like the last command doing : print_cmd -o page-left=43 -o page-right=22 -o page-top=28 -o page-bottom=43 -o font=LatinModernMono12:regular:9 some_file.txt where : print_cmd ::= some printing... (1 Reply)
Discussion started by: jcdole
1 Replies

9. AIX

Apache 2.4 directory cannot display "Last modified" "Size" "Description"

Hi 2 all, i have had AIX 7.2 :/# /usr/IBMAHS/bin/apachectl -v Server version: Apache/2.4.12 (Unix) Server built: May 25 2015 04:58:27 :/#:/# /usr/IBMAHS/bin/apachectl -M Loaded Modules: core_module (static) so_module (static) http_module (static) mpm_worker_module (static) ... (3 Replies)
Discussion started by: penchev
3 Replies
DBI::PurePerl(3)					User Contributed Perl Documentation					  DBI::PurePerl(3)

NAME
DBI::PurePerl -- a DBI emulation using pure perl (no C/XS compilation required) SYNOPSIS
BEGIN { $ENV{DBI_PUREPERL} = 2 } use DBI; DESCRIPTION
This is a pure perl emulation of the DBI internals. In almost all cases you will be better off using standard DBI since the portions of the standard version written in C make it *much* faster. However, if you are in a situation where it isn't possible to install a compiled version of standard DBI, and you're using pure-perl DBD drivers, then this module allows you to use most common features of DBI without needing any changes in your scripts. EXPERIMENTAL STATUS
DBI::PurePerl is new so please treat it as experimental pending more extensive testing. So far it has passed all tests with DBD::CSV, DBD::AnyData, DBD::XBase, DBD::Sprite, DBD::mysqlPP. Please send bug reports to Jeff Zucker at <jeff@vpservices.com> with a cc to <dbi-dev@perl.org>. USAGE
The usage is the same as for standard DBI with the exception that you need to set the enviornment variable DBI_PUREPERL if you want to use the PurePerl version. DBI_PUREPERL == 0 (the default) Always use compiled DBI, die if it isn't properly compiled & installed DBI_PUREPERL == 1 Use compiled DBI if it is properly compiled & installed, otherwise use PurePerl DBI_PUREPERL == 2 Always use PurePerl You may set the enviornment variable in your shell (e.g. with set or setenv or export, etc) or else set it in your script like this: BEGIN { $ENV{DBI_PUREPERL}=2 } before you "use DBI;". INSTALLATION
In most situations simply install DBI (see the DBI pod for details). In the situation in which you can not install DBI itself, you may manually copy DBI.pm and PurePerl.pm into the appropriate directories. For example: cp DBI.pm /usr/jdoe/mylibs/. cp PurePerl.pm /usr/jdoe/mylibs/DBI/. Then add this to the top of scripts: BEGIN { $ENV{DBI_PUREPERL} = 1; # or =2 unshift @INC, '/usr/jdoe/mylibs'; } (Or should we perhaps patch Makefile.PL so that if DBI_PUREPERL is set to 2 prior to make, the normal compile process is skipped and the files are installed automatically?) DIFFERENCES BETWEEN DBI AND DBI
::PurePerl Attributes Boolean attributes still return boolean values but the actual values used may be different, i.e., 0 or undef instead of an empty string. Some handle attributes are either not supported or have very limited functionality: ActiveKids InactiveDestroy Kids Taint TaintIn TaintOut (and probably others) Tracing Trace functionality is more limited and the code to handle tracing is only embeded into DBI:PurePerl if the DBI_TRACE environment variable is defined. To enable total tracing you can set the DBI_TRACE environment variable as usual. But to enable individual handle tracing using the trace() method you also need to set the DBI_TRACE environment variable, but set it to 0. Parameter Usage Checking The DBI does some basic parameter count checking on method calls. DBI::PurePerl doesn't. Speed DBI::PurePerl is slower. Although, with some drivers in some contexts this may not be very significant for you. By way of example... the test.pl script in the DBI source distribution has a simple benchmark that just does: my $null_dbh = DBI->connect('dbi:NullP:','',''); my $i = 10_000; $null_dbh->prepare('') while $i--; In other words just prepares a statement, creating and destroying a statement handle, over and over again. Using the real DBI this runs at ~4550 handles per second whereas DBI::PurePerl manages ~2800 per second on the same machine (not too bad really). May not fully support hash() If you want to use type 1 hash, i.e., "hash($string,1)" with DBI::PurePerl, you'll need version 1.56 or higher of Math::BigInt (available on CPAN). Doesn't support preparse() The DBI->preparse() method isn't supported in DBI::PurePerl. Doesn't support DBD::Proxy There's a subtle problem somewhere I've not been able to identify. DBI::ProxyServer seem to work fine with DBI::PurePerl but DBD::Proxy does not work 100% (which is sad because that would be far more useful :) Try re-enabling t/80proxy.t for DBI::PurePerl to see if the problem that remains will affect you're usage. Others can() - doesn't have any special behaviour Please let us know if you find any other differences between DBI and DBI::PurePerl. AUTHORS
Tim Bunce and Jeff Zucker. Tim provided the direction and basis for the code. The original idea for the module and most of the brute force porting from C to Perl was by Jeff. Tim then reworked some core parts to boost the performance and accuracy of the emulation. Thanks also to Randal Schwartz and John Tobey for patches. COPYRIGHT
Copyright (c) 2002 Tim Bunce Ireland. See COPYRIGHT section in DBI.pm for usage and distribution rights. perl v5.12.1 2008-06-02 DBI::PurePerl(3)
All times are GMT -4. The time now is 11:17 AM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy