Beefy Boxes and Bandwidth Generously Provided by pair Networks
"be consistent"

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
Strange behaviour with Arrays and print?
3 direct replies — Read more / Contribute
by pingufreak83
on Jul 12, 2014 at 08:55
    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?


    Kind regards,

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/
2 direct replies — Read more / Contribute
by pimperator
on Jul 11, 2014 at 14:55
    I'm dumb
next and last within subs
4 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.
How to retain a value passed from another link to a script
3 direct replies — Read more / Contribute
by terrykhatri
on Jul 11, 2014 at 13:27
    favorite I am calling a script from a HTML Template giving it a value to load the script as follows:
    <a href="<!-- TMPL_VAR NAME=OrderID - +->">Details</a>
    The script gets executed with the value passed however I cannot use this value in other routines within the same script i.e., so the question is how can I retain this value, I am already declaring a Global variable for it :
    my $orderid = $q->param('orderid');
    Rgds. Terry
to process big text file, use java or perl?
4 direct replies — Read more / Contribute
by toughhou
on Jul 11, 2014 at 13:18
    I'm doing Data Warehourse related work. I have lots of files (size is about 1G for each), which are extracted from Oracle and need to be processed. Here I can use Java and Perl based on the host environment. But I'm not sure which kind of language can have a better performance to process such kind of big text file? Anyone can give me some suggestions? Thanks a lot.

Add your question
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?

    What's my password?
    Create A New User
    and the web crawler heard nothing...

    How do I use this? | Other CB clients
    Other Users?
    Others cooling their heels in the Monastery: (2)
    As of 2014-07-12 16:49 GMT
    Find Nodes?
      Voting Booth?

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

      Results (240 votes), past polls