in reply to Resetiing business day

my $d = new Date::Business(); ... my $temp_bd=$d;

Here, $temp_bd and $d refer to the same object. Simple assignment in Perl does not copy an object. So if you modify $temp_bd, you also modify $d.

Replies are listed 'Best First'.
Re^2: Resetiing business day
by bimleshsharma (Beadle) on Sep 08, 2011 at 07:21 UTC

    Yah, You are right. I found a way to do that. Here is modified code.

    use Date::Business;
    my %start;
    my $n=1;
    my $temp_bd;
    my $d = new Date::Business();
    while ($n <=10)
    {
    $temp_bd= new Date::Business($d);
    $temp_bd->addb(2);
    $start{'date'}= $temp_bd->image();
    $start{'date1'}= $d->image();
    print "\n Date- $start{'date'}";
    print "\n Date1- $start{'date1'}";
    $n++;
    }
    Just new object had to start with original using method of package instead of assignment operator.