Beefy Boxes and Bandwidth Generously Provided by pair Networks
Just another Perl shrine
 
PerlMonks  

HeatSeekerCannibal's scratchpad

by HeatSeekerCannibal (Beadle)
on Apr 01, 2006 at 00:54 UTC ( #540587=scratchpad: print w/ replies, xml ) Need Help??

============ MY PROBLEM WITH IMAP4 ============
#!/usr/local/bin/perl -w use Mail::Box::IMAP4; my $f = Mail::Box::IMAP4->new(host => "10.X.X.X", username => "someuser", password => "somepassword", folder => "GENERADOR DE LISTAS", trace => 3, debug => 3) or die "Can't connect: $@"; foreach my $msg ($f->messages) { print "Message header: [".$msg->getHead()."]\n"; }
============ MY PROBLEM WITH PIPES ============
#!/usr/bin/perl -w my $NamedPipe = "/home/test/perl/named-pipes/.to-monica"; print "Reading from $NamedPipe\n"; open(FIFO, "< $NamedPipe") || die "Cant open $NamedPipe: $!"; while(1) #### This is UUUUGLY { while(<FIFO>) { chomp; print "I got: [".$_."]\n"; } } close FIFO;
======== MY SHOT AT REMOTE MODIFICATION OF INI FILES ======
my %IniStruct = ( qr/^MONICACTE RAIZ$/ => { qr/^DEPURACION$/ => qr/^(SI|NO)$/, qr/^DIRBASE$/ => { "EXPREG" => qr/^\/\w+[\/\w]*$/, "VALOR" => "-e ARCHIVO && -d _ && -r _", }, qr/^LOGFILE$/ => { "EXPREG" => qr/^\w+[\/\w]*$/, "VALOR" => "-e ARCHIVO && -f _ && -T _ && -r _ + && -w _", }, qr/^MONICASRVADDR$/ => qr/^\d{1,3}\.\d{1,2}\.\d{1,2}\. +\d{1,3}$/, qr/^CONNECTIONTIMEOUT$/ => qr/^\d{1,2}$/, qr/^MONICACTE CAT=\w+/ => { qr/^HABILITAR$/ => qr/^(SI|NO)$/, qr/^DEPURAR$/ => qr/^(SI|NO)$/, qr/^CAT=\w+ SUBCAT=\w+$/ => { qr/^HABILITAR$/ => qr/^(SI|NO)$/, qr/^DEPURAR$/ => qr/^(SI|NO)$/, }, qr/^SUBCAT=\w+ (PARAM=[\/\w]+|GPO=\w+) +$/ => { qr/^SCRIPT$/ => { "EXPREG" => qr/^\/\w+[ +\/\w]*$/, "VALOR" => "-e ARCHIVO + && -s _ && -r _ && -x _", }, qr/^ARGUMENTOS$/ => qr/.*/, qr/^EXPREG$/ => qr/.*/, }, }, }, ); my $CfgFileOb = new Config::IniFiles( -file => $ARGV[0] ); my ($RegExpRaiz, $Valor) = each(%IniStruct); foreach my $MatchingSection( grep(/$RegExpRaiz/, $CfgFileOb->Sections( +)) ) { print "$MatchingSection\tCoincide con regexpheader\n"; if (ref( qr($Valor) ) eq "Regexp") { print "regexp\n"; } elsif (ref( $Valor ) eq "HASH" ) { } else { } }
=====PROBLEM WITH CGI AND FRAMES=============
<HTML> <HEAD> <TITLE>Conjunto de frames</TITLE> </HEAD> <FRAMESET ROWS="15%,*" COLS="20%,*" FRAMEBORDER=0 SCROLLING="NO"> <FRAME SRC="/cgi-bin/sel_instancia.pl" NAME=SEL_INSTANCIA NORESI +ZE SCROLLING="NO" TARGET="_self"> <FRAME SRC="banner.html" NORESIZE> <FRAME SRC="sel_opciones.html" NAME=SEL_OPCIONES NORESIZE> <FRAME SRC="qry_empty.html" NAME=FRM_QRY NORESIZE> </FRAME> </HTML>
use strict; use CGI ':standard'; use HTML::Template; use DBI; my $BaseDatos = "dbi:SQLite:dbname=./personal.db3"; my $dbh = DBI->connect( $BaseDatos, "", "", { RaiseError => 1 } ) || die "ERR al conectarse a $BaseDatos: $DBI::errstr"; DBI->trace(1); my $template = HTML::Template->new( filename => 'sel_instancia.tmpl' ) +; my @hostnames = (); my @hosts = @{ $dbh->selectall_arrayref( "SELECT hostname FROM hosts", + { Slice => {} } ) }; foreach my $host( @hosts ) { push @hostnames, $host->{hostname}; } $template->param(HOSTS => \@hosts); $dbh->disconnect; print "Content-type: text/html\n\n"; print $template->output;
Sample of my sockets code...
use IO::Socket; my $SrvSaraPort = "10.180.19.19"; my $SrvSaraPort = "9001"; $server = IO::Socket::INET->new(Proto => 'tcp', LocalPort => $SrvSaraPort, Listen => SOMAXCONN, Reuse => 1); while($client = $server->accept()) { $client->autoflush(1); next unless $client->peerhost eq $SrvMonicaAddr; my $RcvString = <$client>; print $client "OK"; } close $client
This is something else....an example of a Tk i was trying to create....
use Tk; use Tk::HList; @ElementsList = ("one", "two", "three"); @SubElementsList = ("four", "five", "six"); @Hosts = ("this", "that", "them"); $mw = MainWindow->new; $upperframe = $mw->Frame(-relief => 'groove', -borderwidth => 3, )->pack(-side => 'top', -fill => 'x'); $label=$upperframe->Label(-text => "TEXT")->pack(-side => 'left'); $label->pack; $label->bind('' => sub { $mw->destroy }); $middleframe = $mw->Frame(-relief => 'groove', -borderwidth => 3, )->pack(-side => 'top', -fill => 'x'); $list=$middleframe->Scrolled(qw/Listbox -setgrid 1 -height 10 -scrollbars e/ )->pack(qw/-side left -expand yes -fill both/); $list->focus; $list->bind('<Double-1>' => sub { showdata($_[0]->get('active')) }); $list->insert(0, @Hosts); $list->activate(0); $lowerframe = $mw->Frame(-relief => 'groove', -borderwidth => 3, )->pack(-side => 'top', -fill => 'x'); $CfgDisplay = $lowerframe->Scrolled(qw\HList -separator | -selectmode extended -width 55 -height 20 -indent 35 -scrollbars se\ )->grid(qw/-sticky nsew/); MainLoop; sub showdata { $CfgDisplay->delete(all); foreach my $element(@ElementsList) { $CfgDisplay->add($element, -text => $element, -data => $element); foreach my $subelement(@SubElementsList) { $CfgDisplay->add("$element|$subelement", -text => $subelement, -data => $subelement); } } }
========== MY PROBLEM WITH DBI::SQLITE ==========
my @resultados = `rsh worst-station -l ab-user ls -lta /space`; open(LOG, ">archivo.txt") || die "fallo: $!"; print LOG @resultados; close LOG;
when executed, gives me the following message: DBI::st=HASH(0x5fa0d4)->bind_param(...): attribute parameter '2' is not a hash ref at ontapes2.pl line 370.
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 lurking in the Monastery: (2)
As of 2014-07-31 02:08 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    My favorite superfluous repetitious redundant duplicative phrase is:









    Results (244 votes), past polls