Beefy Boxes and Bandwidth Generously Provided by pair Networks
We don't bite newbies here... much
 
PerlMonks  

Seekers of Perl Wisdom

( #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 section is the place to ask. Post a new question!

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
How To Pass A DateTime Object in $c->flash
1 direct reply — Read more / Contribute
by phildeman
on May 03, 2016 at 17:36

    Hi All,

    I am having a bit of a problem with DateTime objects and $c->flash.

    I am using Perl Catalyst, Mason, DBIx::Class, where the DBIx::Class database packages uses DBIx::Class::InflateColumn::DateTime.
    Where any column with a date or datetime data type can be displayed using DateTime methods.

    I don't have any problem with $c->stash, only with $c->flash.

    CONTROLLER

    . . sub show_rsvp_POST :Local{ my ($self, $c) = @_; my $model = $c->model( 'RSVP' ); my $params = $c->req->params; my $rsvps = $model->srch_user_info( $params->{ 'srchuser' } ); if($individualRSVP) { $c->flash->{ 'rsvps' } = $rsvps; $c->response->redirect("show_individual_rsvp"); return; } else { $c->flash->{ 'error' } = "There are no users with with that na +me"; $c->response->redirect("show_rsvplist"); return; } } . .

    $rsvps is an array of database objects. It contains a DateTime field called rsvpdate. I am using a $c-flash, because I am redirecting the data to a different View, called show_rsvplist.
    When I loop through each row to display, it will display the data, when I don't include the rsvpdate. Howwever, when I include the rsvpdate column, I use the DateTime method to display that data
    as follows:

    MASON TEMPLATE

    . . <table> <tr> <td>Name</td> <td>RSVP Date</td> <tr> % foreach my $rsvp (@$rsvps) { <tr> <td><% $rsvp->name %></td> <td><% $rsvp->rsvpdate-mdy('/') %></td> <tr> % } </table> . . <%init> my $rsvps = $c->flash->{ 'rsvps' }; </%init>

    As I mentioned, when $c->stash is used, I don't have problems with DateTime objects. But, I need to use the $c->flash because I am calling a different view with a redirect.
    When I attempt to display the datetime object with $c-flash, I get the following message:

    DBIx::Class::ResultSource::schema(): Unable to perform storage-dependent operations with a detached result source (source 'VRsvps' is not associated with a schema). You need to use $schema->thaw() or manually set $DBIx::Class::ResultSourceHandle::thaw_schema while thawing.....

    It suggest that I am not associating the database table with a schema. That is not the case at all.

    If anyone has experienced this problem, please help. Thanks.

connect to AndroidDebugBrigde (adb) using PERL
1 direct reply — Read more / Contribute
by State_Space
on May 03, 2016 at 16:21
    Hi,
    Can anyone tell or link me how to send Android Debug Commands using perl? I've googled, but haven't found any examples.

    mock code would look like:
    open adb console
    check devices (i.e. adb devices)
    pick a device
    send adb commands (i.e. adb reboot)

    Thank you

    I guess I should update this. How do I issue or print commands to the cmd.exe window?
question on hash behavior
4 direct replies — Read more / Contribute
by shamat
on May 03, 2016 at 12:33
    Dear monks, I have a question for you concerning the behavior of exists on hash keys. Please consider this code:
    use strict; use warnings; use Data::Dumper; my %hash_data = (); my $key1 = "a"; my $key2 = "1"; my $key3 = "B"; my $key4 = "_"; if (exists $hash_data{$key1}{$key2}{$key3}{$key4}) { print "exists\n"; } else { print "DOES NOT EXIST\n" } print "-----\n"; print Dumper (\%hash_data);
    prints:
    DOES NOT EXIST ----- $VAR1 = { 'a' => { '1' => { 'B' => {} } } };
    It looks like some sub-keys are generated (in this case $k1,$k2,$k3) if they don't exist. How can I avoid that? Thanks for sharing your wisdom!
comparing two sound files - percent similiar
7 direct replies — Read more / Contribute
by slloyd
on May 03, 2016 at 09:14
    I am interested in comparing two short wav files and getting the percent similar. For instance, if I record two sound files with me saying the exact same thing then the two sound files should be at least 70 percent similar, right?

    Any suggestions on how to go about comparing two sound files? I found http://www.perlmonks.org/?node_id=169641 but the thread is quite old and did not really give me any starting points.

    I look forward to your thoughts.

    s/te/ve/
Win32::GUI::ListView in virtual mode
1 direct reply — Read more / Contribute
by artem78
on May 03, 2016 at 08:33

    Hello. I need an example, how create virtual listview with Win32::GUI. I want to know, how to use LVM_SETITEMCOUNT hook and where in code I need to add items in ListView?

    use warnings; use strict; no strict 'subs'; my @list_items; use constant LVM_SETITEMCOUNT => 4143; use Win32::GUI::Constants qw(/^(MB_|ILC_|IDYES|SB_|DT_|WS_|LVS_)/); use Win32::GUI(); my $wnd = Win32::GUI::Window->new( -size => [500, 500] ); my $lines = $wnd->AddTextfield( -prompt => ['Lines:', 80], -pos => [160, $wnd->ScaleHeight - 30], -height => 24, -width => 100, -popstyle => WS_BORDER, -tabstop => 1, -text => 5000 ); my $refresh_btn = $wnd->AddButton( -pos => [10, $wnd->ScaleHeight - 30], -size => [100, 24], -text => 'Refresh', -onClick => \&update_list ); my $list = $wnd->AddListView( -name => 'list', -pos => [10, 10], -size => [$wnd->ScaleWidth - 20, $wnd->ScaleHeight - 50], -gridlines => 1, -popstyle => WS_BORDER, -pushstyle => LVS_OWNERDATA ); $list->Hook(LVM_SETITEMCOUNT, sub { ################ # What I need to write there? ################ }); $list->InsertColumn( -width => 24 ); $list->InsertColumn( -width => 200 ); $wnd->Center(); $wnd->Show(); Win32::GUI::Dialog; sub update_list() { my $line = 0; my $max_lines = $lines->Text(); $list->Clear(); @list_items = (); for (1 .. $max_lines) { push(@list_items, {-text => [$_, rand(9999999)]}); } $list->SetItemCountEx(scalar @list_items, 0); }
Need help to implement Net::SSH::Any
2 direct replies — Read more / Contribute
by mr.sagarbhamare
on May 03, 2016 at 02:04

    Hello Folks & Salva,

    I need your help in troubleshooting with below code,

    Scenario :- 1. Need to implement Net::SSH::Any module to run command on remote linux server.

    Please find below modules are installed on my host.

    Available commands are: l - List all installed modules m <module> - Select a module q - Quit the program cmd? l Installed modules are: Algorithm::C3 Algorithm::Diff App::cpanminus Archive::Tar Archive::Zip Authen::DecHpwd Authen::Passphrase B::Hooks::EndOfScope B::Utils CPAN CPAN::Meta CPAN::Meta::Check CPAN::Meta::Requirements CPAN::Meta::YAML Carp Carp::Clan Class::C3 Class::C3::XS Class::Inspector Class::Load Class::Load::XS Class::MethodMaker Class::Mix Compress::Raw::Bzip2 Compress::Raw::Zlib Crypt::DES Crypt::Eksblowfish Crypt::MySQL Crypt::PasswdMD5 Crypt::Rijndael Crypt::SSLeay Crypt::UnixCrypt_XS Cwd Data::Dump Data::Dumper Data::Entropy Data::Float Data::Integer Data::OptList Devel::GlobalDestruction Devel::GlobalDestruction::XS Devel::NYTProf Devel::StackTrace Devel::ptkdb Digest::CRC Digest::HMAC Digest::MD4 Digest::MD5 Digest::SHA Digest::SHA1 Dist::CheckConflicts Enbugger Encode Encode::Locale Eval::Closure Exporter ExtUtils::CBuilder ExtUtils::Config ExtUtils::Depends ExtUtils::Helpers ExtUtils::InstallPaths ExtUtils::MakeMaker ExtUtils::ParseXS File::HomeDir File::Listing File::Path File::Temp File::Which Getopt::Long HTML::Parser HTML::Tagset HTTP::Cookies HTTP::Daemon HTTP::Date HTTP::Lite HTTP::Message HTTP::Negotiate IO IO::Compress IO::HTML IO::Pipely IO::SessionData IO::Socket::SSL IO::Tty IO::Zlib IPC::Cmd IPC::Run IPC::Run3 JSON::Any LWP LWP::MediaTypes LWP::Protocol::https List::MoreUtils List::Util Locale::Maketext::Simple MRO::Compat Mail::Sendmail Module::Build Module::Build::Tiny Module::CoreList Module::Implementation Module::Load Module::Load::Conditional Module::Metadata Module::Runtime Module::Signature Moose MooseX::Types MooseX::Types::Path::Class Mozilla::CA Net Net::DNS Net::HTTP Net::ISC::DHCPd Net::SSH::Any Net::SSLeay NetAddr::IP POE POE::Filter::DHCPd::Lease POE::Test::Loops Package::DeprecationManager Package::Stash Package::Stash::XS Params::Check Params::Classify Params::Util Parse::CPAN::Meta Path::Class Perl Perl::OSType Pod Pod::Escapes Pod::Simple Probe::Perl SOAP::Lite Scalar::String Storable Sub::Exporter Sub::Exporter::Progressive Sub::Install Sub::Name Sub::Uplevel Task::Weaken Term::ReadKey Term::ReadLine Test::Deep Test::Differences Test::Exception Test::Fatal Test::Harness Test::NoWarnings Test::Requires Test::Script Test::Simple Test::Tester Test::Warnings Test::Without::Module Text::Diff Text::Glob Time::Local Try::Tiny URI UUID Variable::Magic WWW::RobotRules XML::LibXML XML::NamespaceSupport XML::SAX XML::SAX::Base XML::Simple YAML base namespace::autoclean namespace::clean parent cmd?
    #############################################

    Below is actual code, where there are three IP's of my server.

    cat check_lib.pl #!/usr/local/bin/perl #Check tape library status # use strict; use warnings; use Net::SSH::Any; use v5.10; my %library = ( 9 => "pwxs1", 10 => "pwxs2", 11 => "pwxs3", ); foreach my $lib ( sort keys %library ) { print "$lib $library{$lib}\n"; my $hostname = "$library{$lib}"; my $username = "root"; my $password = "XXXX"; #Change for this example my $cmd = "ls -l"; if ( my $ssh = Net::SSH::Any->new($hostname, user => $username +, password => $password)) { print "I am connected to $hostname \n"; my @out = $ssh->capture($cmd); $ssh->error and die "capture method failed: " +. $ssh->error; say "Below is the output: \n"; say "@out"; } else { print "I am not able to connect $library{$lib}"; } }

    ######################################## Below is my output of script :-

    ./check_lib.pl 10 172.23.246.78 I am connected to 172.23.246.78 capture method failed: no backend available at ./check_lib.pl line 27.
    ############################################### Awsome it worked for Linux server to fetch uptime command output. Now my next part is to connect to quantum scalar i6000 and i2000 library and run command "show library status" I have below parameters. 1. Username 2. IP address 3. ssh access 4. password See below sequence of output what i have tried but its failing again during execution.
    ################################################ cat check_lib.pl #!/usr/local/bin/perl #Check tape library status # use strict; use warnings; use Net::SSH::Any; use v5.10; my %library = ( 9 => "XX.XX.XX.XX", # for security reasons changed 10 => "YY.YY.YY.YY", # for security reasons changed 11 => "ZZ.ZZ.ZZ.ZZ", # for security reasons changed ); foreach my $lib ( sort keys %library ) { print "$lib $library{$lib}\n"; my $hostname = "$library{$lib}"; my $username = "root"; my $password = "XXXXXXXX"; # for security reasons changed my $cmd = "show library status"; if ( my $ssh = Net::SSH::Any->new($hostname, user => $username +, password => $password)) { print "I am connected to $hostname \n"; my @out = $ssh->capture($cmd); $ssh->error and die "capture method failed: " +. $ssh->error; say "Below is the output: \n"; say "@out"; } else { print "I am not able to connect $library{$lib}"; } } ################################################ > ./check_lib.pl 10 YY.YY.YY.YY Permission denied (publickey,password). I am connected to YY.YY.YY.YY capture method failed: unable to establish master SSH connection: bad +password or master process exited unexpectedly at ./check_lib.pl line + 27. ################################################ > ssh admin@YY.YY.YY.YY admin@YY.YY.YY.YY's password: Hello admin, welcome to the Command Line Interface for Quantum Scalar +i6000 library: LTO0XX Type 'help' at the prompt for context-sensitive help. />show library status Component Status Description ------------------------ ------- ----------------------------------- +------------------------- System Health Orange Degraded Control Green Operational Connectivity Green Operational Power Green Operational Cooling Green Operational Robotics Green Operational Robotics Green Operational Robot Green Online Active Drives Yellow Warning; Active events: 4 Event: 458 Yellow Data cartridge L60368L6 has issued +a Tape Alert 3 Event: 459 Yellow Data cartridge L60466L6 has issued +a Tape Alert 3 Event: 460 Yellow Drive sled at [1,1,1,4,1,1] has iss +ued a Tape Alert 37 Event: 462 Yellow Data cartridge C05155L3 has issued +a Tape Alert 33 Drive# 1 (P1 D1) Green Online; Drive Empty Media Loads: 1941 - Read Errors: 50 + - Write Errors: 1207 Read: 89266699MB - Written: 2254575 +167MB Drive# 2 (P1 D2) Green Online; Drive Empty Media Loads: 1160 - Read Errors: 83 + - Write Errors: 571 Read: 205251608MB - Written: 736927 +492MB Drive# 3 (P1 D3) Green Online; Drive Mounted Media Loads: 700 - Read Errors: 46 +- Write Errors: 360 Read: 103106456MB - Written: 473463 +422MB Drive# 4 (P1 D4) Yellow Online; Drive Mounted Media Loads: 285 - Read Errors: 5 - + Write Errors: 31 Read: 21165341MB - Written: 6581404 +8MB Drive# 5 (P1 D5) Green Online; Drive Mounted Media Loads: 1453 - Read Errors: 46 + - Write Errors: 159 Read: 5449221MB - Written: 10000760 +1MB Drive# 6 (P1 D6) Green Online; Drive Mounted Media Loads: 839 - Read Errors: 17 +- Write Errors: 56 Read: 3844530MB - Written: 74439198 +MB Drive# 7 (P1 D7) Green Online; Drive Empty Media Loads: 657 - Read Errors: 10 +- Write Errors: 59 Read: 4948358MB - Written: 42267420 +MB Drive# 8 (P1 D8) Green Online; Drive Empty Media Loads: 526 - Read Errors: 11 +- Write Errors: 113 Read: 11475257MB - Written: 4465934 +4MB Drive# 9 (P1 D9) Green Online; Drive Empty Media Loads: 4153 - Read Errors: 30 +40 - Write Errors: 7810 Read: 51868269MB - Written: 2270923 +27MB Drive# 10 (P1 D10) Green Online; Drive Empty Media Loads: 3547 - Read Errors: 84 + - Write Errors: 167 Read: 29919339MB - Written: 1668944 +70MB Drive# 11 (P1 D11) Green Online; Drive Empty Media Loads: 3090 - Read Errors: 11 +6 - Write Errors: 76 Read: 33787260MB - Written: 1317133 +77MB Drive# 12 (P1 D12) Green Online; Drive Empty Media Loads: 812 - Read Errors: 6 - + Write Errors: 14 Read: 6607257MB - Written: 15037428 +MB /> /> />exit Connection to YY.YY.YY.YY closed. $
    Great, that was my type mistake. New stucked at new error. It seems module not working with if target OS is not Unix / Linux. As in my case i am trying to run my command of one of the tape library.
    ./check_lib.pl 10 172.23.246.78 I am connected to 172.23.246.78 Option not supported capture method failed: child exited with code 1 at ./check_lib.pl line + 27. cat check_lib.pl #!/usr/local/bin/perl #Check tape library status # use strict; use warnings; use Net::SSH::Any; use v5.10; my %library = ( 9 => "172.23.246.7", 10 => "172.23.246.78", 11 => "172.23.246.79", ); foreach my $lib ( sort keys %library ) { print "$lib $library{$lib}\n"; my $hostname = "$library{$lib}"; my $username = "admin"; my $password = "XXXXXXXX"; my $cmd = "show library status"; if ( my $ssh = Net::SSH::Any->new($hostname, user => $username +, password => $password)) { print "I am connected to $hostname \n"; my @out = $ssh->capture($cmd); $ssh->error and die "capture method failed: " +. $ssh->error; say "Below is the output: \n"; say "@out"; } else { print "I am not able to connect $library{$lib}"; } } ./check_lib.pl 10 172.23.246.78 I am connected to 172.23.246.78 Option not supported capture method failed: child exited with code 1 at ./check_lib.pl line + 27. > perl -d check_lib.pl Loading DB routines from perl5db.pl version 1.32 Editor support available. Enter h or `h h' for help, or `man perldebug' for more help. main::(check_lib.pl:10): my %library = ( main::(check_lib.pl:11): 9 => "XX.XX.XX.XX", main::(check_lib.pl:12): 10 => "YY.YY.YY.YY", main::(check_lib.pl:13): 11 => "ZZ.ZZ.ZZ.ZZ", main::(check_lib.pl:14): ); DB<1> s main::(check_lib.pl:16): foreach my $lib ( sort keys %library ) + { DB<1> s main::(check_lib.pl:18): print "$lib $library{$lib} +\n"; DB<1> s 10 172.23.246.78 main::(check_lib.pl:19): my $hostname = "$library{$lib} +"; DB<1> s main::(check_lib.pl:20): my $username = "admin"; DB<1> s main::(check_lib.pl:21): my $password = "XXXXXXXX"; DB<1> s main::(check_lib.pl:22): my $cmd = "show library status +"; DB<1> main::(check_lib.pl:24): if ( my $ssh = Net::SSH::Any-> +new($hostname, user => $username, password => $password)) DB<1> s Net::SSH::Any::new(/usr/local/perl510/lib/site_perl/5.10.1/Net/SSH/Any +.pm:21): 21: my $class = shift; DB<1> s Net::SSH::Any::new(/usr/local/perl510/lib/site_perl/5.10.1/Net/SSH/Any +.pm:22): 22: my %opts = (@_ & 1 ? (host => @_) : @_); DB<1> s Net::SSH::Any::new(/usr/local/perl510/lib/site_perl/5.10.1/Net/SSH/Any +.pm:24): 24: my $target = delete $opts{host}; DB<1> s Net::SSH::Any::new(/usr/local/perl510/lib/site_perl/5.10.1/Net/SSH/Any +.pm:25): 25: defined $target or croak "mandatory parameter host missing +"; DB<1> s Net::SSH::Any::new(/usr/local/perl510/lib/site_perl/5.10.1/Net/SSH/Any +.pm:27): 27: my ($user, $passwd, $ipv6, $host, $port) = 28: $target =~ m{^ 29: \s* # space 30: (?: 31: ([^\@:]+) # username 32: (?::(.*))? # : password 33: \@ # @ 34: )? 35: (?: # host 36: ( # IPv6... 37: \[$IPv6_re\] # [IPv6] 38: | # or 39: $IPv6_re # IPv6 40: ) 41: | # or 42: ([^\[\]\@:]+) # hostname / ipv4 43: ) 44: (?::([^\@:]+))? # port 45: \s* # space 46: $}ix or croak "bad host/target '$target' +specification"; DB<1> s Net::SSH::Any::new(/usr/local/perl510/lib/site_perl/5.10.1/Net/SSH/Any +.pm:48): 48: ($host) = $ipv6 =~ /^\[?(.*)\]?$/ if defined $ipv6; DB<1> s Net::SSH::Any::new(/usr/local/perl510/lib/site_perl/5.10.1/Net/SSH/Any +.pm:50): 50: $user = delete $opts{user} unless defined $user; DB<1> s Net::SSH::Any::new(/usr/local/perl510/lib/site_perl/5.10.1/Net/SSH/Any +.pm:51): 51: $port = delete $opts{port} unless defined $port; DB<1> s Net::SSH::Any::new(/usr/local/perl510/lib/site_perl/5.10.1/Net/SSH/Any +.pm:52): 52: $passwd = delete $opts{passwd} unless defined $passwd; DB<1> s Net::SSH::Any::new(/usr/local/perl510/lib/site_perl/5.10.1/Net/SSH/Any +.pm:53): 53: $passwd = delete $opts{password} unless defined $passwd; DB<1> s Net::SSH::Any::new(/usr/local/perl510/lib/site_perl/5.10.1/Net/SSH/Any +.pm:54): 54: my ($key_path, $passphrase); DB<1> print $passwd XXXXXXXX DB<2> Net::SSH::Any::new(/usr/local/perl510/lib/site_perl/5.10.1/Net/SSH/Any +.pm:55): 55: unless (defined $passwd) { DB<2> s Net::SSH::Any::new(/usr/local/perl510/lib/site_perl/5.10.1/Net/SSH/Any +.pm:59): 59: my $timeout = delete $opts{timeout}; DB<2> s Net::SSH::Any::new(/usr/local/perl510/lib/site_perl/5.10.1/Net/SSH/Any +.pm:60): 60: my $target_os = _first_defined delete $opts{target_os}, 'u +nix'; DB<2> s Net::SSH::Any::Util::_first_defined(/usr/local/perl510/lib/site_perl/5 +.10.1/Net/SSH/Any/Util.pm:59): 59: sub _first_defined { defined && return $_ for @_; return } DB<2> print $target_os DB<3> s Net::SSH::Any::Util::_first_defined(/usr/local/perl510/lib/site_perl/5 +.10.1/Net/SSH/Any/Util.pm:59): 59: sub _first_defined { defined && return $_ for @_; return } DB<3>
who can help me for a very interesting perl program
2 direct replies — Read more / Contribute
by Anonymous Monk
on May 03, 2016 at 01:41
    BEGIN { push ( @INC, '/usr/local/lib/perl/5.14.2/File/') } #!/usr/bin/perl use File::Basename; use File::Spec::Functions; use Data::Dumper; use diagnostics; use warnings; use strict; my $data = data_for_path('/root/excerise_perl/test'); #print Dumper($data); sub data_for_path { my ($path) = @_; my $data = {}; my @queue = ([$path, $data]); while (my $next = shift @queue) { my($path, $ref ) = @$next; my $basename = basename ($path); $ref->{$basename} = do { if (-f $path or -l $path) {undef} else { my $hash = {}; opendir ((my $dh) , $path); my @new_paths =map { catfile ($path , $_) } grep {! /^\.\.?\z/ } readdir $dh; unshift @queue , map {[$_, $hash]} @new_paths; $hash; } }; } $data; }

    this script is used to print one directory structure. if it is a file, then this values would be "undef", if it is a directory, it would be the hash reference for its child directory. now I run this script in my pc, the result is as below: root@TestMachine:~/excerise_perl# perl data_for_path.pl $VAR1 = { 'test' => { 'file2' => undef, 'file1' => undef, 'dir1' => { 'file3' => undef } } }; the directory have two files named "file1" and "file2", one director named "dir1" that has only one file named "file3". I can't understand this sentence "unshift @queue , map {$_, $hash} @new_paths;" the $hash seems not to be assigned a value, but why is $hash returned? what thing does "map {$_, $hash} @new_paths"? someone can help me to understand this script? thanks a lot!!

CGI listener SOAP webserver
1 direct reply — Read more / Contribute
by pazt
on May 02, 2016 at 22:57
    Hi Monks,

    I am rookie about web service. I did some successful test in this examples: http://guide.soaplite.com/

    However, all examples in http://guide.soaplite.com/ only teach exercises like "hi" or "bye" and "hello" as response.

    And I would like to learn how could I do to my cgi web server can receive a xml structure like this below:
    <EventMessage xmlns="http://localhost/Demo"> <CustomerEvents> <createdDateTime>?</createdDateTime> <Customer> <Names> <name>?</name> </Names> </Customer> </CustomerEvents> </EventMessage>
    Thanks for help
Need help with Excel::Writer::XLSX in using 'or'
2 direct replies — Read more / Contribute
by ravi45722
on May 02, 2016 at 22:47
    my $date = $ARGV[0]; $date or $date = `date --date='1 hour ago' +%Y-%m-%d`; chomp $date;

    In this code if the "$date" is NULL then its taking the system date.

    But in this code if the hash element is NULL I need to write '0'. For that I tried this way

    foreach my $sub_user_error (@db_user_errors) { $worksheet->write( $row, $col, $db_error_data{$hour}{'Submissio +n_user_error'}{$sub_user_error} or 0, $number); $col++; } $row++;

    But its not working. Later I tried like

    foreach my $sub_user_error (@db_user_errors) { if ($db_error_data{$hour}{'Submission_user_error'}{$sub_user_erro +r} eq "") { $worksheet->write( $row, $col, 0, $number); $col++; } else { $worksheet->write( $row, $col, $db_error_data{$hour}{'Submiss +ion_user_error'}{$sub_user_error}, $number); $col++; } } $row++;

    Its working but seems too ugly. Is there any better way for doing this.

    Thanks in Advance for helping

“Non-blocking socket operation” error in LWP::UserAgent package
2 direct replies — Read more / Contribute
by lmocsi
on May 02, 2016 at 20:07

    The below code produces an error on Windows 7 Pro, it reads 5-8K bytes of the web page, then terminates:

    use strict; use LWP::UserAgent; my $url = 'https://www.flickr.com/photos/71475421@N02/26176178323/'; my $ua = LWP::UserAgent->new; my $res = $ua->get($url); print $res->headers->as_string;
    The error is:
    X-Died: read failed: A non-blocking socket operation could not be completed immediately. at C:/Perl/lib/LWP/Protocol/http.pm line 467.

    OS: Win 7 Pro (64bit)
    Perl: 5.20.1 (32bit)
    LWP: 6.08
    LWP-Protocols-https: 6.06

    Any ideas why is it not working, and how it can be fixed?

    Thanks.

Add your question
Title:
Your question:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post; it's "PerlMonks-approved HTML":


  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • 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, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            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.
  • 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 about the Monastery: (12)
    As of 2016-05-04 18:23 GMT
    Sections?
    Information?
    Find Nodes?
    Leftovers?
      Voting Booth?