[27277] in Perl-Users-Digest

home help back first fref pref prev next nref lref last post

Perl-Users Digest, Issue: 9033 Volume: 10

daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Thu Mar 9 00:05:57 2006

Date: Wed, 8 Mar 2006 21:05:06 -0800 (PST)
From: Perl-Users Digest <Perl-Users-Request@ruby.OCE.ORST.EDU>
To: Perl-Users@ruby.OCE.ORST.EDU (Perl-Users Digest)

Perl-Users Digest           Wed, 8 Mar 2006     Volume: 10 Number: 9033

Today's topics:
    Re: simple pointer operations (newbe) robic0
    Re: Year of day in localtime and timelocal don't match? (J Moreno)
        Digest Administrivia (Last modified: 6 Apr 01) (Perl-Users-Digest Admin)

----------------------------------------------------------------------

Date: Wed, 08 Mar 2006 19:00:59 -0800
From: robic0
Subject: Re: simple pointer operations (newbe)
Message-Id: <2s5v02lacn6ubga1r00v8aufqosou3st6u@4ax.com>

On 01 Mar 2006 19:41:35 GMT, Abigail <abigail@abigail.nl> wrote:

>Uri Guttman (uri@stemsystems.com) wrote on MMMMDLXV September MCMXCIII in
><URL:news:x7slq2c6uo.fsf@mail.sysarch.com>:
>`` >>>>> "R" == Ruud  <rvtol+news@isolution.nl> writes:
>``  
>``   R> Uri Guttman schreef:
>``   >> the fact that perl uses the a
>``   >> real c address as part of the value (numeric or string) of references
>``   >> is total smart as it will guarantee the uniqueness of the ref value
>``   >> since the ram address is also unique.
>``  
>``   R> Well, unique until the allocated block is moved. Unless the address is
>``   R> more like a handle. Or the block was allocated as fixed.
>``  
>``  the sv (or whatever the internal thing the ref is) never get reallocated
>``  as they are fixed sized. only the string/array/hash buffers get
>``  reallocated as needed and they are pointed to by a member of the sv. so
>``  the ref value will never change as long as the ref is valid (not garbage
>``  collected).
>
>
>SV might get reallocated - or rather, copied, when you may not expect it,
>for instance when using threads.
>
>
>    #!/opt/perl/5.8.8/bin/thr-perl-64 -l
>
>    use threads;
>    use strict;
>    use warnings;
>
>    my $ref = do {\my $var};
>
>    print $ref;
>
>    threads -> create (sub {print $ref}) -> join;
>
>    __END__
>    SCALAR(0x81a8390)
>    SCALAR(0x828649c)
>
>
>Abigail

Where's the C constructs Abigail? Are you back to
Perl now?

SCALAR(0x81a8390)

Whats this a virtual address to a Perl malloc'ed 
er, ahh... something you can change?

0x81a8390 does seem like an awfully big damn number
you know? What do you think 0x81a8391 is?

Oh yeah, its a void pointer (or typedef) to an array
of structures. By incrementing the pointer in Perl
you can get the contents of the next structure:

struct mine {
  struct *mine;
  int *asdf;
  char sdf[25];
} MINE;

MINE *minehdr = malloc (1000 * sizeof(MINE));
// assign

yadayadayada


------------------------------

Date: Wed, 8 Mar 2006 23:35:18 -0500
From: planB@newsreaders.com (J Moreno)
Subject: Re: Year of day in localtime and timelocal don't match?
Message-Id: <1hbwjbj.u6midr1ik9cqoN%planB@newsreaders.com>

Gunnar Hjalmarsson <noreply@gunnar.cc> wrote:

> J Moreno wrote:
> > As I read the documentation, the day of the year in both should be the
> > same, but when I run the script below, they differ by a day (I get the
> > day before the today's day as returned by localtime).
> > 
> > Is this a problem with the documentation, my reading of the
> > documentation, or a bug (i.e. do I have to check to see if the behavior
> > changes based upon version or something)?
> 
> <snip>
> > ($b,$b,$b,$b,$b,$b,$b,$day_of_year) = localtime;
> > 
> > print "From localtime: " . $day_of_year;
> 
>  From "perldoc -f localtime":
> "$yday is the day of the year, in the range 0..364 (or 0..365 in leap 
> years.)"
> 
> Hence you need to pass $day_of_year+1 to timelocal_nocheck() to make the 
> 8:th element returned by localtime() equal $day_of_year.

I'm clear as to what localtime returns, it's timelocal_nocheck's desired
input that I'm not so clear on.

(OK, now I see where it is sorta clear --- the first example for
timelocal_nocheck is for the 365th day of 1999, i.e. the last day of a
year without a leap day, which localtime will return as 364 but the
example shows as using 365).

To all, 
Sorry about the bad example, my original example was slightly different,
changed at the last minute to "simplify" the output and make things even
more clear, and I didn't think of the year change.

Here's the orginal script:

###
use warnings;
use strict;

use Time::Local 'timelocal_nocheck';

$\ = "\n";

my $b;
my $day_of_year;
my $l_year;

($b,$b,$b,$b,$b,$l_year,$b,$day_of_year) = localtime;

print scalar localtime;

print scalar localtime timelocal_nocheck  0,0,0,$day_of_year, 0, $l_year;

###

And output...

Wed Mar  8 23:26:19 2006
Tue Mar  7 00:00:00 2006

-- 
JM
"Everything is futile." -- Marvin of Borg


------------------------------

Date: 6 Apr 2001 21:33:47 GMT (Last modified)
From: Perl-Users-Request@ruby.oce.orst.edu (Perl-Users-Digest Admin) 
Subject: Digest Administrivia (Last modified: 6 Apr 01)
Message-Id: <null>


Administrivia:

#The Perl-Users Digest is a retransmission of the USENET newsgroup
#comp.lang.perl.misc.  For subscription or unsubscription requests, send
#the single line:
#
#	subscribe perl-users
#or:
#	unsubscribe perl-users
#
#to almanac@ruby.oce.orst.edu.  

NOTE: due to the current flood of worm email banging on ruby, the smtp
server on ruby has been shut off until further notice. 

To submit articles to comp.lang.perl.announce, send your article to
clpa@perl.com.

#To request back copies (available for a week or so), send your request
#to almanac@ruby.oce.orst.edu with the command "send perl-users x.y",
#where x is the volume number and y is the issue number.

#For other requests pertaining to the digest, send mail to
#perl-users-request@ruby.oce.orst.edu. Do not waste your time or mine
#sending perl questions to the -request address, I don't have time to
#answer them even if I did know the answer.


------------------------------
End of Perl-Users Digest V10 Issue 9033
***************************************


home help back first fref pref prev next nref lref last post