Beefy Boxes and Bandwidth Generously Provided by pair Networks
The stupid question is the question not asked
 
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
Login to BGP via Perl
No replies — Read more | Post response
by varalaxmibbnl
on Jul 13, 2014 at 01:30

    Hi Monks

    I want to login to bgp to run few commands often so i thought of making script to run those commands and i used

    Net::SSH::Perl

    to login to bgp and run a command..the script is as follows

    #!/usr/bin/perl use Net::SSH::Perl; use POSIX qw(strftime); $time = strftime "%d-%b-%Y", localtime; $host = "XXX.XXX.XXX.XXX"; $username = "user"; $password = "password"; $port = "XXXX"; $ssh = Net::SSH::Perl->new($host,port=>"$port",protocol=>2); @array = $ssh->login($username,$password); #@ary = $ssh ->cmd("show arp"); @data = $ssh->cmd("show interfaces"); print "@array\n@data\n"; @data2 = $ssh ->cmd("exit"); print "@data2\n";

    if i run the above script it will login but it prints invalid command show

    please some one suggest how to solve this problem

    Thanks in advance

sort on hash / hash / hash doesn't work
3 direct replies — Read more / Contribute
by PsySkeletor
on Jul 12, 2014 at 13:19
    Hi monks! I facing a problem what it should be easy to fix it but i don't know how. I have a script which opens a lot of log files and pull the data to different hashes. For the sake of organization, i translate the dates to epoc and organize in my hash the info using the epoc time as the second hash, to prevent duplicates and to sort the hash results to present them in chronologic order. Well, the problem its sort isn't sorting epoc numbers :(
    foreach $cat ( keys %data ) { foreach $date ( keys %{ $data{$cat} }) { print "<tr>"; foreach $data_type (sort { $a cmp $b } keys %{ $data{$cat}{$da +te} } ) { print "<td align='left'>$data{$cat}{$date}{$data_type}</td +>"; #print "<br>"; } print "</tr>"; } }
    $cat = category, i have 4, that runs. $date = its the date en epoc, this doesn't run $date_type = the type of data we are going to print, this works. The results of the sort that is not shorting are:
    EPOC IP 1405799856 79.223.46.211 1405879428 79.200.95.44 1405702121 87.149.76.154 1407101135 188.138.41.140 1406108233 82.139.192.95 1407162997 87.149.66.39 1405810508 80.187.110.214 1405791762 84.159.197.17 1405870826 2.246.106.240 1406040423 87.154.119.73 1405810525 85.22.101.198 1405620262 87.149.72.59 1405603261 178.12.215.30 1405806556 80.187.102.26
    As you can see, there is not sorting. :(
Strange behaviour with Arrays and print?
3 direct replies — Read more / Contribute
by pingufreak83
on Jul 12, 2014 at 08:55
    Hi,
    I'm currently refreshing my Perl experience by reading some books. During testing some scripts, I've noticed a strange behaviour during the following script:
    #!/usr/bin/perl binmode(STDOUT, ":utf8"); use 5.010; use strict; use warnings; use diagnostics; use utf8; my @fred; my $fred; $fred = "HALLO"; $fred[0] = "eins"; $fred[1] = "zwei"; $fred[2] = "drei"; $fred[3] = "vier"; $fred[4] = "fünf"; $fred[5] = "sechs"; $fred[6] = "sieben"; $fred[7] = "acht"; $fred[8] = "neun"; $fred[9] = "zehn"; print @fred; print "\n"; print @fred."\n";
    The output result is the following:
    einszweidreivierfünfsechssiebenachtneunzehn 10
    Why is the array counted if I use a new line?
    Is this normal and why?

    Thanks!

    Kind regards,

    Pingu
Updating hash using it's reference ...
3 direct replies — Read more / Contribute
by karthikin2asic
on Jul 12, 2014 at 04:05
    Hi, I have hash addresses in an array. Is it possible to access each of these hash addresses and add a key using references? Can you please share the code with me? Thanks, -Karthik
Is REST best?
2 direct replies — Read more / Contribute
by traveler
on Jul 11, 2014 at 16:34

    I am building a simple web tool for a client. It will query a database and display some data. They will be able to search, sort, etc., so a simple javascript tool can handle the display. I want to use perl on the back end, as I have done in other situations. It has been suggested that I implement it via REST and then I can add new features fairly easily (this client likes to request that).

    I've read modern ways of doing web services. I've also read Apache2::REST. I don't see many servers using the latter, even though it looks good. Is something better? I don't want to do it all from scratch, of course.

last_insert_id() in sybase
5 direct replies — Read more / Contribute
by Shreyak
on Jul 11, 2014 at 15:04

    i am not able to get value in last_insert_id() after insert operation in sybase database. I had to use do statement instead of prepare statement for both insert and update operations to get value from last_insert_id(). Does anyone know the reason of this behavior?

Strawberry Perl cannot locate Statistics/Basic.pm
2 direct replies — Read more / Contribute
by pimperator
on Jul 11, 2014 at 14:55
    I'm dumb
next and last within subs
5 direct replies — Read more / Contribute
by xorl
on Jul 11, 2014 at 14:54

    I'm looping through the contents of an array.

    Before each iteration of the loop is completed, I want a couple of things done (increment a count, print some debug info, and a few other things). There are a number of conditions that cause the loop to move on to the next one early so my though is to put these into a subroutine and call that. However, one of these things is:

    if ($x > $stop) { last; } elsif ($y ne $text) { foobar(); } else { next; }

    So of course I get the warning "Exiting subroutine via last" (or next)

    Is there a good way of doing this without having to put that snippet of code into every place where I need to move the loop forward?

Not able to put more than 10k uncommited messages in queue
3 direct replies — Read more / Contribute
by Shreyak
on Jul 11, 2014 at 14:28

    i am not able to put more than 10k messages in MQSeries queue without committing them. I've to put all the messages as single unit and therefore could only commit once i put all messages in queue successfully . But i am getting error in putting more than 10k messages . Is there a way to do it?

Using Perl To Manage My Brocade Switches
1 direct reply — Read more / Contribute
by PerlCramps
on Jul 11, 2014 at 14:07
    This message is for all my Perl Monks; I am new to Perl and still wet behind the ears. But I do remember some things my parents taught me; why reinvent the wheel is someone else has already done it. I have a large Brocade switch environment crossing across multiple networks. Does any of my Monks scriptures have any scripts they would be willing to share with the new guy on the block? My workstation is Windows 7, 32 bit.

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
  • 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.
  • 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 browsing the Monastery: (4)
    As of 2014-07-13 09:08 GMT
    Sections?
    Information?
    Find Nodes?
    Leftovers?
      Voting Booth?

      When choosing user names for websites, I prefer to use:








      Results (248 votes), past polls