[Israel.pm] does anyone understand why this code is not working?

Yuval Yaari yuval at windax.com
Fri Jul 16 16:07:23 PDT 2004

This is NOT the problem but:
$urls_lenght should be $urls_length

$urls_lenght = pack('N', at urls_lines);
should be:
$urls_lenght = pack('N*', at urls_lines);
$urls_lenght = pack('N',scalar(@urls_lines));
[depends on what you want to achieve. same thing for the coresponding unpack]
I'm not such a low-level-stuff (read: LSB vs MSB) kind of person, but was
there a reason you chose N over V?

are Client & SOCK contants or what???
Can we see a broader part of the script?
I think sending a much bigger buffer (I always use 1024, I don't even
remember why :)) is ok, and better than just using the length of

Also try sending non-Storable data first to weed the option that
networking is your problem out.


liat said:
> hellow all,
> I try to move a LIST from server to client and it is not working
> i use the pack/unpack functions.
>  i think i miss something and it's not working
> i also tried to get the size of the list using the length functions and
> send the "size" to the client and it's not working
> The Error i get is:
> "Magic number checking on storable string failed at
> ..\..\lib\Storable.pm <autosplit into
> ..\..\lib\auto\Storable\thaw.al> line 358. at C:\liatperl\COPYOF~4.CGI
> line 27"
> and line 27 is on the client side:"my @urls_lines = @{
> thaw($urls_serialized) }; "
> if anyone knows this error plz let me know what's wrong..
> thanks
>  Liat
> the server side:
>    open(FILE,"url");
>    my @urls_lines = <FILE>; # slurps all the file.
>    my $urls_serialized = nfreeze(\@urls_lines);
>    my $urls_lenght = pack('N', length($urls_serialized)); ## or my
> $urls_lenght = pack('N', at urls_lines);
>    send(client, $urls_lenght, 4);
>    send(Client, $urls_serialized,length($urls_serialized),);
> the client side:
>     my $urls_lenght;
>     my $urls_serialized;
>     recv(SOCK, $urls_lenght,4,0)or die "recv() failed: $!";
>     $urls_lenght = unpack ('N', $urls_lenght);
>     recv(SOCK, $urls_serialized,$urls_lenght,0);
>     my @urls_lines = @{ thaw($urls_serialized) };
> _______________________________________________
> Perl mailing list
> Perl at perl.org.il
> http://perl.org.il/mailman/listinfo/perl

More information about the Perl mailing list