Venkateswarlu Bulusu wrote:
> 
> hi

Hello,

>   i was trying to do negation (~) on a string and i was getting strange result.

~ is a numerical operator, not a string operator.

> #!/usr/bin/perl
> use warnings;
> $a = "venkat";
> $b = ~ $a;
> print $a, "\n";
> print $b, "\n";
> 
> when i run this i am getting blank for $b, and getting
> 1;2c on the command prompt. when i changed $a from venkat to abcdef nothing
> was there at command prompt. i am pretty new to perl, hope someone helps me
> out. thanks.

$ perl -e'
$a = "venkat";
$b = ~ $a;
print unpack( "l", $a ), "\n";
print unpack( "l", $b ), "\n";
'
1802397046
-1802397047
$ perl -e'
$a = "abcdef";
$b = ~ $a;
print unpack( "l", $a ), "\n";
print unpack( "l", $b ), "\n";
'
1684234849
-1684234850
$ perl -e'
$a = pack "l", 123456;   
$b = ~ $a;
print unpack( "l", $a ), "\n";
print unpack( "l", $b ), "\n";
'
123456
-123457




John
-- 
use Perl;
program
fulfillment

-- 
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to