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

serf's scratchpad

by serf (Chaplain)
on Mar 03, 2005 at 20:08 UTC ( #436355=scratchpad: print w/replies, xml ) Need Help??

Help for this page

Select Code to Download

  1. or download this
    my(@array1) = (1, 2, 3, 4);
    my(@array2) = ('a', 'b', 'c', 'd', 'e', 'f');
  2. or download this
    push my @array3, @array1, @array2;
  3. or download this
    Parentheses missing around "my" list at line 12.
  4. or download this
    push (my @array3, @array1, @array2);
  5. or download this
    push (my @array3, @array1, @array2);
  6. or download this
    push my @array3, @array1, @array2;
  7. or download this
    foreach my $enum_type ( eval $enum_types ) {
        print qq[<option value="$enum_type">$enum_type</option>\n];
  8. or download this
    my $enum_types = "'On Order','Waiting, Pending Payment','Dispatched','
    # NB: one value has a , in it and another a ' just to make this challe
    +nging... ;-)
    foreach my $enum_type ( eval $enum_types ) {
        print qq[<option value="$enum_type">$enum_type</option>\n];
  9. or download this
    while ( $enum_types =~ m/('(.*?)'|([^']*?))($|,\s*)/g ) {
        my $match = $3 || $2;
        print qq[<option value="$match">$match</option>\n] if $match;
  10. or download this
    foreach my $enum_type ( split /(?:^'|','|'$)/, $enum_types ) {
        print qq[<option value="$enum_type">$enum_type</option>\n];
  11. or download this
    $ ./
    <option value=""></option>
    <option value="Cancelled">Cancelled</option>
    <option value="Renewal">Renewal</option>
    <option value="Amen'ded">Amen'ded</option>
  12. or download this
    my $command = '/usr/local/bin/program_with_multiline_output';
    chomp(my(@output) = `$command`);
    my $returned = $? >> 8;
    print "Returned: [$returned]\n";
    print "Message: [$output]\n";
  13. or download this
    and all is quiet...

Log In?

What's my password?
Create A New User
[choroba]: It should greatly simplify the parsing code, no flags or additional reading of the next buffer needed
[Corion]: choroba: Yeah, that's why I like that approach; it seems even quite obvious in retrospect to me, but many things are in hindsight ;)

How do I use this? | Other CB clients
Other Users?
Others lurking in the Monastery: (9)
As of 2016-12-06 15:38 GMT
Find Nodes?
    Voting Booth?
    On a regular basis, I'm most likely to spy upon:

    Results (109 votes). Check out past polls.