haswalt has asked for the wisdom of the Perl Monks concerning the following question:

Hi Monks,

I have a script extracting all post data from the client into a hash.

This hash contains a key value pair which i check to work out whether to perform a subroutine or not.

When i check the value it fails since the string i get isn't what i expected.

Now when printing to my log file i tried putting some carachters around the hash value ("|") to check it's value.

my log prints like this "time: value posted to subroutine"

for some reason my log shows "|79592858: COMPLETE = |postComplete".

So it appearc that the pipe is being put at the beginning of the line by the hash, I have no idea why?

any help would be great

thanks
Harry

Replies are listed 'Best First'.
Re: printing hash
by blazar (Canon) on May 19, 2007 at 17:50 UTC
    So it appearc that the pipe is being put at the beginning of the line by the hash, I have no idea why?

    As others wrote, hard to say without seeing the code. But hard to believe too:

    #!/usr/bin/perl use strict; use warnings; use Data::Dumper; my %hash=(foo => 1, bar => 2, baz => 3); $hash{$_}="|$hash{$_}|" for keys %hash; print Dumper \%hash; __END__
    So it appearc that the pipe is being put at the beginning of the line by the hash, I have no idea why?

    It's hard to believe that the hash is putting anything "at the beginning of the line". And no, I don't know if you have no idea why.

Re: printing hash
by kyle (Abbot) on May 19, 2007 at 16:54 UTC

    It would be easier to answer your question if you could show us the relevant parts of your code. It's hard to tell what's going on from what you've told us so far. See How (Not) To Ask A Question.

Re: printing hash
by imp (Priest) on May 19, 2007 at 16:54 UTC
    It's hard to diagnose behaviour without seeing code. Could you post a minimal working example that demonstrates the problem you are having?
Re: printing hash
by hesco (Deacon) on May 20, 2007 at 07:34 UTC
    <cite> So it appearc that the pipe is being put at the beginning of the line by the hash </cite>

    Again, we're all grasping at straws without code to look at, but I'd guess that perhaps you'd want to chomp the newlines off the end of your data somewhere in the mix. That might make it easier to successfully match.

    -- Hugh

    if( $lal && $lol ) { $life++; }