Beefy Boxes and Bandwidth Generously Provided by pair Networks
Your skill will accomplish
what the force of many cannot

Resetiing business day

by bimleshsharma (Beadle)
on Sep 08, 2011 at 05:43 UTC ( #924725=perlquestion: print w/replies, xml ) Need Help??
bimleshsharma has asked for the wisdom of the Perl Monks concerning the following question:

Business day value resetting

Here in loop everytime $d value is being stored in new variable but $tem_bd value is being increased instead of resetting. How do we reset business day. Code is as below

my $d = new Date::Business();
while ($n <=10)
my $temp_bd=$d;
$start{'date'}= $temp_bd->image();
print "\n Date- $start{'date'}";

Replies are listed 'Best First'.
Re: Resetiing business day
by Corion (Pope) on Sep 08, 2011 at 06:56 UTC
    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.

      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);
      $start{'date'}= $temp_bd->image();
      $start{'date1'}= $d->image();
      print "\n Date- $start{'date'}";
      print "\n Date1- $start{'date1'}";
      Just new object had to start with original using method of package instead of assignment operator.

Re: Resetiing business day
by Anonymous Monk on Sep 08, 2011 at 06:50 UTC

    Here in loop everytime $d value is being stored in new variable but $tem_bd value is being increased instead of resetting

    addb doesn't spell reset

    for my $n ( 0 .. 10 ){ my $date = Date::Business->new; ... }

Log In?

What's my password?
Create A New User
Node Status?
node history
Node Type: perlquestion [id://924725]
Approved by toolic
[Your Mother]: It would hillarious to learn the Flat Earth movement was started by misunderstood sarcasm.
[Corion]: Your Mother: Aah - Server Side Events maybe, which mostly sends events from the server as they come up?
[Your Mother]: Sounds right.
[Corion]: Your Mother: I think that that is basically the origin story. Flat earth started as trolling, but then the real believers drove out the trolls
LanX is pretty brown in summer
[Your Mother]: Though a bad match for the OP in question here. :P
[Corion]: Your Mother: Yeah
[Your Mother]: Americans are still pumping out video games where you get to slaughter as many Germans as you have the GPU for... It has always struck me as odd that this particular case seems fine to people. :\
[LanX]: yep heard the same origin story

How do I use this? | Other CB clients
Other Users?
Others surveying the Monastery: (17)
As of 2018-03-19 13:37 GMT
Find Nodes?
    Voting Booth?
    When I think of a mole I think of:

    Results (240 votes). Check out past polls.