Beefy Boxes and Bandwidth Generously Provided by pair Networks
Your skill will accomplish
what the force of many cannot
 
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
Can't close pipe to invalid process
2 direct replies — Read more / Contribute
by cLive ;-)
on Aug 28, 2015 at 17:37
    I was debugging why this test to create a PDF worked in the shell, but not from Jenkins (both environments running as the same user):
    my $fh; ok( open($fh, "|-", "prince - 2>/dev/null $test_file"), "Open +$test_file for writing" ); print $fh "<html><body><h1>Hello, world!</h1></body></html>"; ok( close($fh), "Close $test_file");

    Turns out it was because the PATH didn't exist in the Jenkins environment.

    Problem solved, but now I'm left scratching my head.

    ok 3 - Open /opt/humana/svn/checkouts/rosalind-repo/prod/tmp/testfile. +pdf for writing not ok 4 - Close /opt/humana/svn/checkouts/rosalind-repo/prod/tmp/test +file.pdf

    Why would the open succeed to an unknown executable? Is it because it dosen't fail until you attempt to use it? For some reason that feels a little off to me. What am I missing?

apache 2.4 mod_perl permission denied on standard modules
1 direct reply — Read more / Contribute
by Crackers2
on Aug 28, 2015 at 14:20

    I'm running on SLES12, with apache 2.4.10 and mod_perl 2.0.8

    In a vhost config file, I have a "PerlFixupHandler MyHandler" directive. Myhandler.pm is in /etc/apache2/script

    If I do a perl -e'use MyHandler' from the commandline, everything works fine. But when it gets used from the server, it fails and is logging this in the error_log:

    [Fri Aug 28 18:15:43.053198 2015] [perl:error] [pid 22133] [client x.x +.x.x:x] failed to resolve handler `MyHandler': Can't locate Digest/SH +A.pm: Permission denied at /etc/apache2/script/MyHandler.pm line 7. +\nBEGIN failed--compilation aborted at /etc/apache2/script/MyHandler. +pm line 7.\nCompilation failed in require at (eval 5) line 2.\n, refe +rer: https://x.x.x.x/

    If I comment out the reference to Digest::SHA, it just fails on the next module.

    For debugging, I added a BEGIN block to dump INC and to try and read the SHA.pm file, and that does not appear to cause any errors.

    This configuration used to work fine on apache 2.2 ; I did some minimal updates to the configuration files for the new authentication stuff in 2.4, but nothing related to perl.

    Any idea on what's wrong and how to fix it?

    Edit: Here's the start of the .pm in question:

    package MyHandler; use strict; use warnings; use Apache2::Const qw(:common); use Digest::SHA qw(sha256_hex sha1_hex); use OtherModule; use Apache2::RequestRec; use Apache2::RequestIO; use Apache2::Const; use Apache2::Log; use APR::Table; use CGI::Cookie; use Apache2::URI (); use APR::URI; use APR::Pool ();
Given month last day
4 direct replies — Read more / Contribute
by Anonymous Monk
on Aug 28, 2015 at 14:18
    Hi Monks!
    Can I pass a given month to Time::Piece and get its last day?
    #!/usr/bin/perl use strict; use warnings; use Time::Piece; use Time::Seconds qw(ONE_DAY ONE_WEEK ONE_MONTH ONE_YEAR); # Create Time::Piece New Object for the dates my $t = Time::Piece->new(); my $year = $t->year; # Pass November, but it can be any month my $month = "11"; my $last_day_month = $t->month_last_day($month); #?? print $last_day_month." days\n"; # 30
Replicating perl instance on AIX 6.1
3 direct replies — Read more / Contribute
by twieckow
on Aug 28, 2015 at 13:59
    Hello , What I would like to do, is create a "duplicate" perl instance from the OS installed system perl . This would be 5.8.8. This is in relation to an early post I had made (#1135687). My perl users have been using the OS install and I now want to move them off of it to their own. So that my OS upgrades do not effect their current perl. I can easily copy/create a new directory structure for them ( /usr/opt/perl5/* -> /segregated). But not sure how best to alter the @INC declaration or any other pieces that may need pointed to this area. In looking at perlbrew, I'm not quite sure if this will do it (not installing different, but replicated). Nor do I know/think autobundle is what I need , or if autobundle is overkill. I know that future module adds would require me to add Prefix= to the "perl Makefile.PL " step.Would appreciate any wisdom/suggestions you may have on this. Thanks very much in advance.
email exchange
1 direct reply — Read more / Contribute
by Sandy
on Aug 28, 2015 at 11:48
    Hello all

    I am trying to access an exchange server (over the web) via Email::Folder::Exchange

    While running the sample code, I run into the following error:

    Can't call method "attr" on an undefined value at Email/Folder/Exchange/EWS.pm line 123.

    After a little investigation, it comes down to:

    my code

    use Email::Folder::Exchange::EWS; my $folder = Email::Folder::Exchange::EWS->new('my_server', $user,$p +ass);
    Looking at the EWS.pm file, line 123 is:
    $self->folder_id( $som->dataof('//FolderId')->attr->{Id} );
    I inspected the $som object, and looked at some of the stuff in the code, and I think I can see where there might be an error, (and it is not with my credentials) but I am hesitant to start debugging all of this, when the point is to have a package that just works.

    So, the question is: Is there an easy way to access an exchange server, via the web, with a perl program. What would be the best package?

    Sandy

    UPDATE:

    Making a bit of progress... but can't seem to find the right credentials to log in.

    Have established that the server is NOT https://exchange.domain.com/owa

    as that is for the web-client not the soap client.

    Am able to login (via a browser) to https:://exchange.domain.com/EWS/Services.wsdl with my standard username password, but does not work when I am using this from a perl script.

    Still stymied.

getting is_deeply test::more to print to log
2 direct replies — Read more / Contribute
by teamassociated
on Aug 28, 2015 at 11:12
    Hi! I want to print test::more is_deeply's output to a log file or conjure some other way to notify via email when any one test fails. Please share your ideas? Thank you!
    use strict; use warnings; use File::Find; use Mail::Mailer; use Test::More tests => 2; use vars ('*name', '*dir', '*prune'); *name = *File::Find::name; *dir = *File::Find::dir; *prune = *File::Find::prune; $| = 1; #snip #.... my $runlog = qq(/var/log/stgpool_lun_compare.log); my $errlog = qq(/var/log/stgpool_lun_compare.errlog); my (%lsmap15a,$lsm15a,$client15a,$status15a,$bdev15a,$lsmap15a); my (%lsmap15b,$lsm15b,$client15b,$status15b,$bdev15b,$lsmap15b); my (%lsmap16a,$lsm16a,$client16a,$status16a,$bdev16a,$lsmap16a); my (%lsmap16b,$lsm16b,$client16b,$status16b,$bdev16b,$lsmap16b,$mesg); open ( RLOG, "+>", $runlog ) or warn "$runlog did not open $!\n"; open ( ELOG, "+>", $errlog ) or warn "$errlog did not open $!\n"; my $regex = qr/\-$|^svsa.*$|^mirrored.*|^physloc.*|^$/i; open (LSMAP16B, "+< $lsmap16b") or die $!; while ( $lsm16b = (<LSMAP16B>) ) { next if $lsm16b =~ m/$regex/; if ( $lsm16b =~ m/vtopt\d+/i ) { my $skip = 3; <LSMAP16B> while $skip-- >0 and not eof LSMAP16B; next; } if ( $lsm16b =~ /^vhost\d+\s+\w+\.\d+\w\.\w+\-\w+\-\w+\s+(0x\w+$)/ +i ) { $client16b = $1; } if ( $lsm16b =~ /^status\s+(\w+$)/i ) { $status16b = $1; push ( @{$lsmap16b{$client16b}}, $status16b ); next; } if ( $lsm16b =~ /^backing\sdevice\s+(\w+_\w+\.\w+$)/i ) { $bdev16b = $1; push ( @{$lsmap16b{$client16b}}, $bdev16b ); next; } } ### These 2 print lines below are not printing to the log ### print RLOG is_deeply(\%lsmap16a, \%lsmap16b, 'vios16a-vios16b-map-comp +are' ); print ELOG grep {/failed.*/i}<RLOG>; __STDOUT__ # Failed test 'vios16a-vios16b-map-compare' # at stgpool_lun_compare.plx line 194. # Structures begin differing at: # $got->{0x00000012}[1] = 'twcsapxrqdb1_r1.c24452093bce96e2f4 +8808ed3f7d7eab' # $expected->{0x00000012}[1] = 'twcsapxrqdb1_r1.c24452093bce96e2f4 +8808ed3f7d7eac' $VAR1 = { '0x00000019' => [ 'Available', 'sapepd00_r1.b2094c34c4a13b0a726a39f92a9e9 +ed7', 'Available', 'sapepd00_r2.96db0cd89258769f4ab05247ac2b3 +fa2', 'Available', 'sapepd00_e1.b56cbd304aa61c6ca9ae9edc1b68b +5e4', 'Available', 'sapepd00_e2.f41786148a3beeeef9c7b1b53fe54 +0e8', 'Available', 'sapepd00_p1.4a2facfe0f6f4237817de94c06f2f +ccd' ], '0x00000012' => [ 'Available', 'twcsapxrqdb1_r1.c24452093bce96e2f48808ed3 +f7d7eab', 'Available', 'twcsapxrqdb1_r2.dd39252cef8d45a4c24d59be4 +38ef60d', 'Available', 'twcsapxrqdb1_x1.4d9b58368e93e12fa7ab4a2d1 +950ec13', 'Available', 'twcsapxrqdb1_x2.51369af641d03701e977f7e95 +0c00905', 'Available', 'twcsapxrqdb1_x3.24ebd57b77a43ba21d46da58c +7fa5323', 'Available', 'twcsapxrqdb1_p1.60dc076867436ed6af776adb4 +05fe269' ] };
Compiling Perl5.8.8 on ARMv7eb
1 direct reply — Read more / Contribute
by Fearless
on Aug 28, 2015 at 10:15

    I have cross compiled tool chain for armv7eb. Now I have copied the tools to my target machine and tried to build perl on target. In this process of building perl, there is a binary called 'miniperl' which gets crashed saying "ILLEGAL INSTRUCTION".

    Can someone help me point out what I should be doing ? PERL VERSION: 5.8.8 GCC: 4.1.3 PLease find the crash log below. anybody has any suggestions.

    sh cflags "optimize='-O'" opmini.o` -DPIC -fPIC -DPERL_EXTERNAL_GLOB opmini.c CCCMD = cc -DPERL_CORE -c -msoft-float -dynamic -fno-strict-aliasing -pipe -Wdeclaration-after-statement -O -Wall LD_LIBRARY_PATH=/usr/pkg/src/perl-5.8.8:/lib:/usr/lib:/usr/pkg/lib:/usr/pkg/src/PTHREAD/lib cc -Wl,-rpath,/usr/pkg/lib -Wl,-rpath,/usr/local/lib -L/usr/pkg/lib -L/lib -L/usr/lib -o miniperl miniperlmain.o opmini.o -L. -lperl -lm -lcrypt -lutil -lc -lposix LD_LIBRARY_PATH=/usr/pkg/src/perl-5.8.8:/lib:/usr/lib:/usr/pkg/lpid 25563 (miniperl), uid 0: exited on signal 4 (core not dumped, err = 2) ib:/usr/pkg/src/PTHREAD/lib ./miniperl -w -Ilib -MExporter -e '<?>' || make minitest 1 Illegal instruction LD_LIBRARY_PATH=... cp ext/re/re.pm lib/re.pm LD_LIBRARY_PATH=/usr/pkg/src/perpid 8052 (miniperl), uid 0: exited on signal 4 (core not dumped, err = 2) l-5.8.8:/lib:/usr/lib:/usr/pkg/lib:/usr/pkg/src/PTHREAD/lib ./miniperl -Ilib configpm --heavy=lib/Config_heavy.pl lib/Config.pm 1 Illegal instruction LD_LIBRARY_PATH=... *** Error code 132 Stop. make: stopped in /upid 25595 (miniperl), uid 0: exited on signal 4 (core not dumped, err = 2) sr/pkg/src/perl-5.8.8 *** Error code 1 (ignored)

parse Excel number which represents a date
4 direct replies — Read more / Contribute
by fionbarr
on Aug 28, 2015 at 09:48
    good morning I am trying to parse an xlsx file with Spreadsheet::XLSX There are text data that appears on the Excel sheet as 'Thu, Jan 14' where the extracted data has the value '42387'. Any clue how I can parse this value to derive the text date?
Perl with Expect Module not working with Cygwin
1 direct reply — Read more / Contribute
by adi001
on Aug 28, 2015 at 05:09
    Hello Experts

    I am new to perl and don;t have much expertise. I was trying to get the below mentioned script working but it always throw following error when running from the windows using Cygwin

    "admin@cisco-hbi76wq1f /Expect/Login/Login $ perl Postchange.pl Telnet to 10.106.97.194 No password prompt (that we recognize anyways for 10.106.97.194. at Po +stchange.pl line 257, <FH> line 1. "

    The same script when executed from Linux (ubuntu) works fine without any issues.

    Below is the script :
    #!/usr/bin/perl use strict; use warnings; use lib "./Expect-1.21/blib/lib"; use Expect; my $device = "0.0.0.0"; if ( -e "PostOutput.txt" ) #If PostOutputfile already exists will be r +emoved. { `rm PostOutput.txt`; } my $timeout = 15; #Number of seconds to wait aftre each command is exe +cuted.Can be increased or decreased. my $user = "cisco"; #Initialize username. my $pass = "cisco"; #Initialize password. if ( open ( FH, "GatewayList.txt" ) ) #This is the input file with IP +address in column1 and SSHorTelnet in column2. { while ( defined ( my $line = <FH> ) ) { $line =~ s/\s+$//; my @line_split = split(" ", $line); $device = $line_split[0]; if ( $line_split[1] eq "SSH" ) { &checkssh; } else { &checktelnet; } } close FH; } else { print "GatewayList.txt file not found\n"; } exit; sub checkssh { #SSH procedure. my @out = (); my @out1 = (); my @out2 = (); open FILE, ">>", "PostOutput_".$device.".txt" or die $!; print "SSH to $device\n"; my $check1 = Expect->spawn("ssh -o StrictHostKeyChecking=no -o + UserKnownHostsFile=/dev/null $user\@$device"); $check1->log_stdout(0); if ($check1->expect($timeout, -re => "Are you sure you want to co +ntinue connecting (yes/no)?") ) { print $check1 "yes\r"; } $check1->expect($timeout, -re => "password:|Password:"); print $check1 "$pass\r"; $check1->expect($timeout, -re => ">"); print $check1 "enable\r"; #If enable password is different th +an the regular password initialize as a seperate variable in the begi +nning. #$check1->expect($timeout, -re => "password:|Password:"); #print $check1 "$pass\r"; #If enable password is different th +an the regular password use enable password variable. if ( $check1->expect($timeout, -re => "#")) { #Specify all device commands in this section. print $check1 "term len 0\r"; #Command to be executed. $check1->expect($timeout, -re => "#"); #Return prompt. #@out = split(/\r/, $check1->before()); #@out2 = split(/\r/, $check1->after()); $check1->clear_accum(); #@out2 = (); #@out = (); #print $check1 "sh flash:\r"; print $check1 "sh flash:\r"; $check1->expect($timeout, -re => "#"); @out = split(/\r/, $check1->before()); #Command PostOutput wil +l be stored in the array variable. @out2 = split(/\r/, $check1->after()); #$file_handle->print($check1 . "\n"); print FILE @out;#`echo "@out" >> H323Log.txt`; #Data stored in + the array variable will be written to the PostOutput file. print FILE @out2; @out = (); #This will empty the array contents so that the nex +t command PostOutput can be stored in the same variable. @out2 = (); $check1->clear_accum(); #This will clear the previous command +PostOutput so that the next command PostOutput can be loaded to the a +rray variable. print $check1 "sh ver\r"; $check1->expect($timeout, -re => "#"); @out1 = split(/\r/, $check1->before()); @out2 = split(/\r/, $check1->after()); #`echo "@out1" >> H323Log.txt`; print FILE @out1; print FILE @out2; @out1 = (); @out2 = (); @out = (); $check1->clear_accum(); print $check1 "sh dspfarm all\r"; $check1->expect($timeout, -re => "#"); @out = split(/\r/, $check1->before()); @out1 = split(/\r/, $check1->after()); #`echo "@out" >> H323Log.txt`; print FILE @out; print FILE @out1; @out = (); @out1 = (); @out2 = (); $check1->clear_accum(); print $check1 "sh voice dsp group all\r"; $check1->expect($timeout, -re => "#"); @out = split(/\r/, $check1->before()); @out1 = split(/\r/, $check1->after()); #`echo "@out" >> H323Log.txt`; print FILE @out; print FILE @out1; @out = (); @out1 = (); @out2 = (); $check1->clear_accum(); print $check1 "sh ip int bri\r"; $check1->expect($timeout, -re => "#"); @out = split(/\r/, $check1->before()); @out1 = split(/\r/, $check1->after()); #`echo "@out" >> H323Log.txt`; print FILE @out; print FILE @out1; @out = (); @out1 = (); @out2 = (); $check1->clear_accum(); print $check1 "sh isdn status\r"; $check1->expect($timeout, -re => "#"); @out = split(/\r/, $check1->before()); @out1 = split(/\r/, $check1->after()); #`echo "@out" >> H323Log.txt`; print FILE @out; print FILE @out1; @out = (); @out1 = (); @out2 = (); $check1->clear_accum(); print $check1 "sh isdn service\r"; $check1->expect($timeout, -re => "#"); @out = split(/\r/, $check1->before()); @out1 = split(/\r/, $check1->after()); #`echo "@out" >> H323Log.txt`; print FILE @out; print FILE @out1; @out = (); @out1 = (); @out2 = (); $check1->clear_accum(); print $check1 "sh controller t1\r"; $check1->expect($timeout, -re => "#"); @out = split(/\r/, $check1->before()); @out1 = split(/\r/, $check1->after()); #`echo "@out" >> H323Log.txt`; print FILE @out; print FILE @out1; @out = (); @out1 = (); @out2 = (); $check1->clear_accum(); print $check1 "sh gateway\r"; $check1->expect($timeout, -re => "#"); @out = split(/\r/, $check1->before()); @out1 = split(/\r/, $check1->after()); #`echo "@out" >> H323Log.txt`; print FILE @out; print FILE @out1; @out = (); @out1 = (); @out2 = (); $check1->clear_accum(); print $check1 "sh ephone registered \r"; $check1->expect($timeout, -re => "#"); @out = split(/\r/, $check1->before()); @out1 = split(/\r/, $check1->after()); #`echo "@out" >> H323Log.txt`; print FILE @out; print FILE @out1; @out = (); @out1 = (); @out2 = (); $check1->clear_accum(); print $check1 "sh run \r"; $check1->expect($timeout, -re => "#"); @out1 = split(/\r/, $check1->before()); @out2 = split(/\r/, $check1->after()); #`echo "@out" >> H323Log.txt`; print FILE @out1; print FILE @out2; @out = (); @out1 = (); @out2 = (); $check1->clear_accum(); print $check1 "sh status \r"; $check1->expect($timeout, -re => "#"); @out1 = split(/\r/, $check1->before()); @out2 = split(/\r/, $check1->after()); #`echo "@out" >> H323Log.txt`; print FILE @out1; print FILE @out2; @out = (); @out1 = (); @out2 = (); $check1->clear_accum(); print $check1 "sh status \r"; $check1->expect($timeout, -re => "#"); @out1 = split(/\r/, $check1->before()); @out2 = split(/\r/, $check1->after()); #`echo "@out" >> H323Log.txt`; print FILE @out1; print FILE @out2; @out = (); @out1 = (); @out2 = (); $check1->clear_accum(); #print $check1 "wr\r"; #Use this command only if configuration + needs to be written to memory. #$check1->expect($timeout, -re => "#"); `echo "$device - Success(SSH)" >> PostOutput.txt`; print $check1 "quit\r"; #This will exit the SSH session. $check1->soft_close; } else { `echo "$device - Unable to SSH" >> PostOutput.txt`; return; } } sub checktelnet { #Telnet Procedure.All SSH comments applies for teln +et too. my @out = (); my @out1 = (); my @out2 = (); open FILE, ">>", "PostOutput_".$device.".txt" or die $!; print "Telnet to $device\n"; my $check1 = Expect->spawn("telnet $device"); $check1->log_stdout(0); if ( $check1->expect($timeout, -re => "username|Username") ) { print $check1 "$user\r"; } $check1->expect($timeout, -re => "password|Password") or die ( +"No password prompt (that we recognize anyways for $device."); print $check1 "$pass\r"; if ( $check1->expect($timeout, -re => "#")) { print $check1 "term len 0\r"; #Command to be executed. $check1->expect($timeout, -re => "#"); #Return prompt. #@out = split(/\r/, $check1->before()); #@out2 = split(/\r/, $check1->after()); $check1->clear_accum(); #@out2 = (); #@out = (); #print $check1 "sh flash:\r"; print $check1 "sh flash:\r"; $check1->expect($timeout, -re => "#"); @out = split(/\r/, $check1->before()); #Command PostOutput wil +l be stored in the array variable. @out2 = split(/\r/, $check1->after()); #$file_handle->print($check1 . "\n"); print FILE @out;#`echo "@out" >> H323Log.txt`; #Data stored in + the array variable will be written to the PostOutput file. print FILE @out2; @out = (); #This will empty the array contents so that the nex +t command PostOutput can be stored in the same variable. @out2 = (); $check1->clear_accum(); #This will clear the previous command +PostOutput so that the next command PostOutput can be loaded to the a +rray variable. print $check1 "sh ver\r"; $check1->expect($timeout, -re => "#"); @out1 = split(/\r/, $check1->before()); @out2 = split(/\r/, $check1->after()); #`echo "@out1" >> H323Log.txt`; print FILE @out1; print FILE @out2; @out1 = (); @out2 = (); $check1->clear_accum(); print $check1 "sh dspfarm all\r"; $check1->expect($timeout, -re => "#"); @out = split(/\r/, $check1->before()); @out1 = split(/\r/, $check1->after()); #`echo "@out" >> H323Log.txt`; print FILE @out; print FILE @out1; @out = (); @out1 = (); $check1->clear_accum(); print $check1 "sh voice dsp group all\r"; $check1->expect($timeout, -re => "#"); @out = split(/\r/, $check1->before()); @out1 = split(/\r/, $check1->after()); #`echo "@out" >> H323Log.txt`; print FILE @out; print FILE @out1; @out = (); @out1 = (); $check1->clear_accum(); print $check1 "sh ip int bri\r"; $check1->expect($timeout, -re => "#"); @out = split(/\r/, $check1->before()); @out1 = split(/\r/, $check1->after()); #`echo "@out" >> H323Log.txt`; print FILE @out; print FILE @out1; @out = (); @out1 = (); $check1->clear_accum(); print $check1 "sh isdn status\r"; $check1->expect($timeout, -re => "#"); @out = split(/\r/, $check1->before()); @out1 = split(/\r/, $check1->after()); #`echo "@out" >> H323Log.txt`; print FILE @out; print FILE @out1; @out = (); @out1 = (); $check1->clear_accum(); print $check1 "sh isdn service\r"; $check1->expect($timeout, -re => "#"); @out = split(/\r/, $check1->before()); @out1 = split(/\r/, $check1->after()); #`echo "@out" >> H323Log.txt`; print FILE @out; print FILE @out1; @out = (); @out1 = (); $check1->clear_accum(); print $check1 "sh controller t1\r"; $check1->expect($timeout, -re => "#"); @out = split(/\r/, $check1->before()); @out1 = split(/\r/, $check1->after()); #`echo "@out" >> H323Log.txt`; print FILE @out; print FILE @out1; @out = (); @out1 = (); $check1->clear_accum(); print $check1 "sh gateway\r"; $check1->expect($timeout, -re => "#"); @out = split(/\r/, $check1->before()); @out1 = split(/\r/, $check1->after()); #`echo "@out" >> H323Log.txt`; print FILE @out; print FILE @out1; @out = (); @out1 = (); $check1->clear_accum(); print $check1 "sh ephone registered \r"; $check1->expect($timeout, -re => "#"); @out = split(/\r/, $check1->before()); @out1 = split(/\r/, $check1->after()); #`echo "@out" >> H323Log.txt`; print FILE @out; print FILE @out1; @out = (); @out1 = (); $check1->clear_accum(); print $check1 "sh run \r"; $check1->expect($timeout, -re => "#"); @out = split(/\r/, $check1->before()); @out1 = split(/\r/, $check1->after()); #`echo "@out" >> H323Log.txt`; print FILE @out; print FILE @out1; @out = (); @out1 = (); $check1->clear_accum(); print $check1 "sh status \r"; $check1->expect($timeout, -re => "#"); @out1 = split(/\r/, $check1->before()); @out2 = split(/\r/, $check1->after()); #`echo "@out" >> H323Log.txt`; print FILE @out1; print FILE @out2; @out = (); @out1 = (); @out2 = (); $check1->clear_accum(); print $check1 "sh status \r"; $check1->expect($timeout, -re => "#"); @out1 = split(/\r/, $check1->before()); @out2 = split(/\r/, $check1->after()); #`echo "@out" >> H323Log.txt`; print FILE @out1; print FILE @out2; @out = (); @out1 = (); @out2 = (); $check1->clear_accum(); `echo "$device - Success(Telnet)" >> PostOutput.txt`; print $check1 "quit\r"; #This will exit the SSH session. $check1->soft_close; } else { `echo "$device - Unable to Telnet" >> PostOutput.txt`; return; } }
    Thanks in Advance /Adi
Value of a query is returning without any delimiter
5 direct replies — Read more / Contribute
by parthodas
on Aug 28, 2015 at 03:27
    I need to get the output of a query in a file. It is running fine. Though when I open the file, I see there is no delimiter between two values. Please help me in rectifying this.
    open my $OUT, '>>', "$mycrdir/file_detail.txt" or die "Can't creat +e '$mycrdir/file_detail.txt'" ; while (my @row = $sth->fetchrow_array) { print $OUT @row, "\n"; } close $OUT;

    The output looks something like this --
    117365theme-mb-structure-override.css$/Compass/CodeFreeze/SIEBEL 117365login.css$/Compass/CodeFreeze/SIEBEL

    Am expecting a delimiter(a space or a comma). Something like this --
    117365 theme-mb-structure-override.css $/Compass/CodeFreeze/SIEBEL 117365 login.css $/Compass/CodeFreeze/SIEBEL

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!
  • 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 making s'mores by the fire in the courtyard of the Monastery: (5)
    As of 2015-08-30 00:46 GMT
    Sections?
    Information?
    Find Nodes?
    Leftovers?
      Voting Booth?

      The oldest computer book still on my shelves (or on my digital media) is ...













      Results (346 votes), past polls