Beefy Boxes and Bandwidth Generously Provided by pair Networks Frank
There's more than one way to do things.
 
PerlMonks

Seekers of Perl Wisdom

 | Log in | Create a new user | The Monastery Gates | Super Search | 
 | Seekers of Perl Wisdom | Meditations | PerlMonks Discussion | 
 | Obfuscation | Reviews | Cool Uses For Perl | Perl News | Q&A | Tutorials | 
 | Poetry | Recent Threads | Newest Nodes | Donate | What's New | 

( #479=superdoc: print w/ replies, xml ) Need Help??

If you have a question on how to do something in Perl, or you need a Perl solution to an actual real-life problem, or you're unsure why something you've tried just isn't working... then this is the place to ask.

However, you might consider asking in the chatterbox first (if you're a registered user). The response time tends to be quicker, and if it turns out that the problem/solutions are too much for the cb to handle, the kind monks will be sure to direct you here.

User Questions
Can't close STDIN/STDOUT/STDERR
on Feb 09, 2010 at 16:03
2 direct replies by brp4h
    Does anyone know why I might get an error when I try to close STDIN, STDOUT, and STDERR in a child process? I get this error: child process STDIN is not a real system file handle thanks...
Module::Build and required packages not installed
on Feb 09, 2010 at 15:23
0 direct replies by pileofrogs

    Hi, all ye Monks.

    I'm using Module::Build and have done for years. One thing seems odd to me: If you don't have a required module, it displays a nice message, but it still exits with success. This means you can't do this:

    perl Build.pl && ./Build && ./Build test && sudo ./Build install

    ... and have it do what you'd think it would do, namely stop after the 'perl Build.pl' stage noticed that the prerequisite modules aren't there.

    I'm guessing either a) I'm doing something wrong and it should work that way or b) I'm doing something wrong by trying to use it that way.

    So, if I want to install Module::Build packaged modules via a shell script, what's the best way to tell the shell script if the prerequisite modules are or aren't installed?

    Thanks!
    --Pileofrogs

DNS filter
on Feb 09, 2010 at 15:10
1 direct reply by Anonymous Monk

    Hi,

    I am trying to make DNS filter where I can send 'A' entry for some of the requested domains and redirect the request to a real DNS server if no domain matched.

    I am stucked with the fact that tools like 'nslookup' send un-understandable characters to my perl script so I am unable to match anything and stopped working on the code until I get some help.

    Here is my code:

    use IO::Socket; my $server = IO::Socket::INET->new( Proto => 'udp', LocalPort => 53, ); die "Couldn't setup server: $@" unless $server; while ( $server->recv(my $data , 1024, my $flag ) ) { print "Got: $data\n"; }
My own readme and changelog files with Dist::Zilla?
on Feb 09, 2010 at 15:06
0 direct replies by flamey
    How do I use my own readme and changelog files with Dist::Zilla, instead of generated ones?
WWW::MECHANIZE Get Errors Ending Program Early?
on Feb 09, 2010 at 14:35
2 direct replies by jdlev
    Every once in a while, I'm getting a "GET" error on my program. I am fairly certain it is the website that is down. Rather than stopping the program and throwing off this error, is there a way to simply restart the program from the top? Thanks!
    I love it when a program comes together - jdhannibal
MIME::Lite not including Attachments
on Feb 09, 2010 at 10:11
1 direct reply by guitarplayer68
    Greetings All,

    I am having an issue where mime lite is not including the attachment when it sends out the file. The main part of the script creates the attachment and is quite involved. Simply it creates a tab separated file since some of the data elements contain commas. The script runs and mime lite sends the message but doesn't include the attachment.
    Here is the section of my script for MIME::Lite

    my $msg = MIME::Lite->new( From => $from, To => $lobmail, Subject => 'DUA '. $lobn .' Ticket Activity Report', Type => 'multipart/alternative', ); $msg->attach ( Type => 'TEXT', Data => "Attached is the ticket activity report for $lobn", ); $msg->attach( Type => 'text/plain', Encoding => 'base64', Path => '/home/eric/tmp/lobreport.tsv', Filename => 'LobReport.tsv', Disposition => 'attachment' ) or die "Unable to add attachment: $!\n"; $msg->send();
Count number of words on a web page?
on Feb 09, 2010 at 08:33
3 direct replies by jdlev
    Is there a simple way to count the number of times a word appears on a web page?
    I love it when a program comes together - jdhannibal
A suicidal parent OR death of a forking server
on Feb 09, 2010 at 07:44
6 direct replies by MonkeyMonk

    I seek the knowledge of the enlightened monks to help me reach the last leg of a forking server.

    I have tried to read documentation available online, in cookbooks but I am not sure if it is the same as what I want.

    The aim is to:

      1. Create a telnet server running on port 7070.
      2. Enable 5 clients at MAX to connect to it.
      3. When 1 client is connected and running a command, all commands from other clients should be queued.(There are only 5 possible commands that a client can invoke, 2 of which are "printhelp" and "quit")

    I have managed to reach level 1 and partially level 2. Multiple clients are able to connect to the server.

    The problems that I face are these

      A) When the first client dies, the server commits suicide. Advise is sought on this.
      B) How can I prevent more than 5 clients from connecting.
      C) How can I enable queuing of commands and ensuring the result of the commands are sent to the right client.
    #!/usr/bin/perl -w use IO::Socket; use strict; $SIG{CHLD} = sub{ wait; }; my $inputLine; my $new_sock; my $main_sock; my $pid; # Create Socket on port 7070 $main_sock = new IO::Socket::INET ( LocalHost => 'localhost', LocalPort => '7070', Proto => 'tcp', Listen => 1, Reuse => 1, ); die "Could not create socket: $!\n" unless $main_sock; print "Telnet Server listening on 7070....\n"; # Accept connection and fork child! while( $new_sock = $main_sock->accept() ){ $pid = fork(); unless( defined($pid) ){ die "Cannot fork\n"; } ################## # CHILD PROCESS ################## if($pid == 0) { # Print Welcome message! welcomeClient($new_sock); while( defined( $inputLine=<$new_sock>) ) { $inputLine =~ s/[\r\n]//g; if( $inputLine eq "printhelp" ){ callPrintHelp($new_sock); }elsif( $inputLine eq "quit" ){ callQuit($new_sock); exit(0); }else{ print $new_sock "INFO> Not implemented yet +\n"; } }#while exit(0); } ################## # CHILD PROCESS ################## }# while main_sock close($main_sock); sub welcomeClient { # Show starting point for client and help messages my ($client_sock) = @_; print $client_sock "######################################\n"; print $client_sock " Telnet Interface \n"; print $client_sock "######################################\n\n"; print $client_sock "INFO> Type 'printhelp' for help\n\n"; print $client_sock "READY:\n"; print $client_sock ">"; } sub callPrintHelp{ my ($client_sock) = @_; ...... ..... } sub callQuit{ my ($client_sock) = @_; ...... ..... }
Can Win32::Scheduler Module used to schedule a remote host?
on Feb 09, 2010 at 06:57
1 direct reply by muralidharan

    Hello Monks!!! The Win32::Scheduler module works fine in local machine to schedule a perl file. But when trying to connect to a remote go grid machine, it doesn't, and creates the job in local machine itself. There is a method - SetTargetComputer() where the host machine name is given. But i'm unaware where to give the Go grid machine's password. Here is my code

    $scheduler = Win32::TaskScheduler->New(); $scheduler->SetTargetComputer("173.1.105.147"); $tsk="my_task"; %trig=( 'BeginYear' => 2010, 'BeginMonth' => 02, 'BeginDay' => 9, 'StartHour' => 13, 'StartMinute' => 06, 'TriggerType' => $scheduler->TASK_TIME_TRIGGER_DAILY, 'Type'=>{ 'DaysInterval' => 1, }, ); $scheduler->Activate($tsk); foreach $k (keys %trig) {print "$k=" . $trig{$k} . "\n";} $scheduler->NewWorkItem($tsk,\%trig); $scheduler->SetApplicationName("cmd.exe"); $scheduler->SetAccountInformation('usrname','pwd'); #username and pwd +for the particular task $scheduler->Save(); $scheduler->End();

    I just want to schedule a job in remote windows machine using this module. Thank You Monks!!!!!!

Howto send mail using TLS?
on Feb 09, 2010 at 06:12
3 direct replies by afrika

    Hi all,

    what is the best way/module to send mail using TLS?

    Thanks :)
 (1-10) of 300 Next entries--> 

Add your question
Title:
Your question


  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul
  • Outside of code tags, you may need to use entities for some characters:
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.
  • Login:
    Password
    remember me
    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 musing on the Monastery: (18)
    jdporter
    McDarren
    holli
    johngg
    atcroft
    salva
    CardinalNumber
    jaldhar
    kennethk
    thezip
    Eyck
    pileofrogs
    LanX
    trwww
    ssandv
    MikeDexter
    weegee
    im2
    As of 2010-02-09 22:27 GMT
    Sections?
    The Monastery Gates
    Seekers of Perl Wisdom
    Meditations
    PerlMonks Discussion
    Categorized Q&A
    Tutorials
    Obfuscated Code
    Perl Poetry
    Cool Uses for Perl
    Perl News
    Information?
    PerlMonks FAQ
    Guide to the Monastery
    What's New at PerlMonks
    Voting/Experience System
    Tutorials
    Reviews
    Library
    Perl FAQs
    Other Info Sources
    Find Nodes?
    Nodes You Wrote
    Super Search
    List Nodes By Users
    Newest Nodes
    Recently Active Threads
    Selected Best Nodes
    Best Nodes
    Worst Nodes
    Saints in our Book
    Leftovers?
    The St. Larry Wall Shrine
    Offering Plate
    Awards
    Craft
    Snippets Section
    Code Catacombs
    Quests
    Editor Requests
    Buy PerlMonks Gear
    PerlMonks Merchandise
    Planet Perl
    Perlsphere
    Use Perl
    Perl.com
    Perl 5 Wiki
    Perl Jobs
    Perl Mongers
    Perl Directory
    Perl documentation
    CPAN
    Random Node
    Voting Booth?

    What level of existential comfort do you require?

    Palace
    Executive suite at the best hotel
    Regular hotel in a decent part of town
    Motel
    Boarding house
    Sleeping Bag on Couch in Basement
    Any port in a storm
    Camping under the freeway overpass
    Jail
    Other

    Results (283 votes), past polls