[10942] in Perl-Users-Digest

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

Perl-Users Digest, Issue: 4544 Volume: 8

daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Mon Jan 4 20:17:17 1999

Date: Mon, 4 Jan 99 17:02:07 -0800
From: Perl-Users Digest <Perl-Users-Request@ruby.OCE.ORST.EDU>
To: Perl-Users@ruby.OCE.ORST.EDU (Perl-Users Digest)

Perl-Users Digest           Mon, 4 Jan 1999     Volume: 8 Number: 4544

Today's topics:
        flock(2) <gala@sonic.net>
    Re: flock(2) (Nathan Clemons)
    Re: flock(2) (Andrew M. Langmead)
    Re: Formatting Dates (Searching for date + 30) webmaster@entrepreneur-online.com
        hash of hashes <netog@ziplink.net>
    Re: hash of hashes (Martien Verbruggen)
    Re: hash of hashes <netog@ziplink.net>
    Re: hash of hashes (Martien Verbruggen)
        Special: Digest Administrivia (Last modified: 12 Dec 98 (Perl-Users-Digest Admin)

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

Date: Mon, 4 Jan 1999 11:15:15 -0800
From: "Gala Grant" <gala@sonic.net>
Subject: flock(2)
Message-Id: <76r3uf$qq1$1@ultra.sonic.net>

I have been trying to learn a bit about the flock function, but everywhere I
look it tells me to look up flock(2) for operation info.  I have been unable
to find this info about flock(2).  could someone point me in the right
direction?
Thanks,
Gala Grant
gala@sonic.net




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

Date: Mon, 04 Jan 1999 20:19:57 GMT
From: nathan@ici.net (Nathan Clemons)
Subject: Re: flock(2)
Message-Id: <3691224a.342158237@news.ici.net>

On Mon, 4 Jan 1999 11:15:15 -0800, "Gala Grant" <gala@sonic.net>
wrote:

>I have been trying to learn a bit about the flock function, but everywhere I
>look it tells me to look up flock(2) for operation info.  I have been unable
>to find this info about flock(2).  could someone point me in the right
>direction?
>Thanks,
>Gala Grant
>gala@sonic.net
>
>

Try man 2 flock. That's what the parenthesis is for, to separate
sections of man pages.

_________________________________________________________________________
Nathan Clemons
Associate Systems Engineer
WinStar iCi
Broadband Services
Great Woods Office Park 800 South Main St. Mansfield, MA 02048
_________________________________________________________________________
nclemons@winstar.com   http://www.winstar.com/  (v) 800-234-0002 ext.1109
   nathan@ici.net      http://www.ici.net/      (f) 508-261-0430
</html>


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

Date: Mon, 4 Jan 1999 21:44:42 GMT
From: aml@world.std.com (Andrew M. Langmead)
Subject: Re: flock(2)
Message-Id: <F521qI.pv@world.std.com>

"Gala Grant" <gala@sonic.net> writes:

>I have been trying to learn a bit about the flock function, but everywhere I
>look it tells me to look up flock(2) for operation info.  I have been unable
>to find this info about flock(2).  could someone point me in the right
>direction?

The notation "flock(2)" is the traditional Unix way of specifying to
look for flock in section 2 of the manual. So first of all, I'm
assuming you are using a Unix or Unix-like operating system.

The manual is set up in with the following sections:

1. User Commands
2. System Calls
3. Library functions
4. File Formats
(and so on)

The man command, however uses the following way of specifying which
section of the manual to search.

man 2 flock

To make things just a little bit harder, flock isn't available under
all versions of Unix. And if it is, it may be a library function
(which would be in section 3) rather than a system call (which would
be in section 2.) In this case, usually the system has a lockf()
system call, and flock() is a mostly compatible wrapper function.

Many version of the man command have a "-w" option that will search
the "NAME" section of all the man pages. (Others have it as a separate
command called "apropos". If you aren't sure of the section, or you
aren't sure of the name of the command that you want, "-w" or
"apropos" may be helpful. If your man program is too brain dead to
have either "-w" or "apropos", there is a replacement man program at
<URL:http://www.perl.com/CPAN/scripts/manstuff/index.html>

To make things harder still, some versions of Unix don't have an
flock() system call or library function, but perl emulates it with
lockf(). In that case, there will be no flock man page at all. You're
best bet is to grab a set of man pages from a freely distributable
Unix or Unix-like system that has some sort of flock.

-- 
Andrew Langmead


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

Date: Mon, 04 Jan 1999 17:31:42 GMT
From: webmaster@entrepreneur-online.com
To: ebohlman@netcom.com
Subject: Re: Formatting Dates (Searching for date + 30)
Message-Id: <76qttu$6ih$1@nnrp1.dejanews.com>

In article <ebohlmanF5118y.A3s@netcom.com>,
  Eric Bohlman <ebohlman@netcom.com> wrote:
> You're correct.  My eye skipped over the initial '|' on each line of your
> data file, and I interpreted it as the more common pipe-*separated* file
> rather than the pipe-*delimited* file you had.
>
> Where does $datestamp come from and what format does it have?

I must confess, I don't understand how it works. I snipped some code from a
program that showed 30 days in the past & set about making it show 30 days in
the future. I have tried two versions. Both use these inital lines of code at
the top:

	$dateCmd = '/bin/date';

	chop ($dateStamp = `$dateCmd +"%Y%m%d"`);
	chop ($timeStamp = `$dateCmd +"%a %D %H%M%Z"`);

Here is the first and initial version:
(Prints entire file)

open (Event,"<$event") || &endIt;
  while ($LINE = <Event>)
  { @terms = split(/\|/,$LINE);

  if ($dateStamp %10000 <200)
  { $pastDate = $dateStamp -8900;
  } else
  { $pastDate = $dateStamp -100;
  }

print "<LI> <INPUT TYPE=CHECKBOX NAME=\"$terms[1]\"><INPUT TYPE=hidden
NAME=\"$terms[2]\">";
print "$terms[3]  --  $terms[4]";

  }
  close (Event);

Here is the second:
(Did print dates but Prints nothing now)

if ($dateStamp %10000 <200)
  { $startDate = $dateStamp -8500;
  }
if ($dateStamp %10000 >200)
  { $endDate = $dateStamp +8800;
  }

open (Event,"<$event") || &endIt;
  while ($LINE = <Event>)
  { @terms = split(/\|/,$LINE);
    if ($startDate <= $terms[2] && $endDate >=$terms[2])
    { print "<LI> <INPUT TYPE=CHECKBOX NAME=\"$terms[1]\"><INPUT TYPE=hidden
NAME=\"$terms[2]\">";
        print "$terms[3]  --  $terms[4]";
    }
  }
  close (Event);

-----------== Posted via Deja News, The Discussion Network ==----------
http://www.dejanews.com/       Search, Read, Discuss, or Start Your Own    


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

Date: Mon, 04 Jan 1999 18:51:22 -0500
From: Ernesto Gianola <netog@ziplink.net>
Subject: hash of hashes
Message-Id: <369153FA.E1F6919E@ziplink.net>

Hello. I have a simple question.

In Perl you can assign a values to a hash of hashes as so.
$hash{$key1}{$key2} = $value;

But is it possible to assign it mulitple values?
Why doesn't this work.

$hash{$key1}{$key2} = [@values]


thanks,

Ernesto


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

Date: Tue, 05 Jan 1999 00:04:30 GMT
From: mgjv@comdyn.com.au (Martien Verbruggen)
Subject: Re: hash of hashes
Message-Id: <iGck2.19$Mw1.1018@nsw.nnrp.telstra.net>

In article <369153FA.E1F6919E@ziplink.net>,
	Ernesto Gianola <netog@ziplink.net> writes:

> Why doesn't this work.
> 
> $hash{$key1}{$key2} = [@values]

That does work. it stores a reference to an anonymous array. To get at
the values you can do a few things..

$aref = $hash{$key1}{$key2}  # now $aref is a reference to that array

foreach (@$aref) { #do something }

$el1 = $hash{$key1}{$key2}->[0]  # first element of that array

etc.. etc.. 

There is a lot of information about this sort of thing in the
documentation

# perldoc perlref
# perldoc perllol
# perldoc perldsc

Martien
-- 
Martien Verbruggen                  | 
Webmaster www.tradingpost.com.au    | Make it idiot proof and someone will
Commercial Dynamics Pty. Ltd.       | make a better idiot.
NSW, Australia                      | 


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

Date: Mon, 04 Jan 1999 19:25:49 -0500
From: Ernesto Gianola <netog@ziplink.net>
Subject: Re: hash of hashes
Message-Id: <36915C0D.45C3C4FC@ziplink.net>

Martien Verbruggen wrote:
> 
> In article <369153FA.E1F6919E@ziplink.net>,
>         Ernesto Gianola <netog@ziplink.net> writes:
> 
> > Why doesn't this work.
> >
> > $hash{$key1}{$key2} = [@values]
> 
> That does work. it stores a reference to an anonymous array. To get at
> the values you can do a few things..
> 
> $aref = $hash{$key1}{$key2}  # now $aref is a reference to that array
> 
> foreach (@$aref) { #do something }
> 
> $el1 = $hash{$key1}{$key2}->[0]  # first element of that array
> 
> etc.. etc..
> 
> There is a lot of information about this sort of thing in the
> documentation
> 


My mistake I forgot it does work. Just not the way I want it to.
I am using a tied hash to a DBM file.

Ernesto


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

Date: Tue, 05 Jan 1999 00:34:28 GMT
From: mgjv@comdyn.com.au (Martien Verbruggen)
Subject: Re: hash of hashes
Message-Id: <o6dk2.26$Mw1.1154@nsw.nnrp.telstra.net>

In article <36915C0D.45C3C4FC@ziplink.net>,
	Ernesto Gianola <netog@ziplink.net> writes:

>> > $hash{$key1}{$key2} = [@values]
>> 
>> That does work. it stores a reference to an anonymous array. To get at
>> the values you can do a few things..
>> 
>> $aref = $hash{$key1}{$key2}  # now $aref is a reference to that array

[snip]

> My mistake I forgot it does work. Just not the way I want it to.
> I am using a tied hash to a DBM file.

I don't think you can use any of the standard tied hash modules to
store complex structures, but you can get the MLDBM module from CPAN,
which does allow you to do that.

# perl -MCPAN -e shell
cpan> i MLDBM
Module id = MLDBM
    DESCRIPTION  Transparently store multi-level data in DBM
    CPAN_USERID  GSAR (Gurusamy Sarathy <gsar@umich.edu>)
    CPAN_VERSION 2.00
    CPAN_FILE    GSAR/MLDBM-2.00.tar.gz
[snip]

cpan> readme MLDBM
This is the README file for MLDBM, the Perl module that can 
be used to store multidimensional hash structures in tied hashes
(including DBM files).

This is version 2.00.  It requires:
   Perl Version 5.004 or later.
   The Data::Dumper package from CPAN, version 2.08 or later.
[snip]

HTH
Martien
-- 
Martien Verbruggen                  | 
Webmaster www.tradingpost.com.au    | Very funny Scotty, now beam down my
Commercial Dynamics Pty. Ltd.       | clothes.
NSW, Australia                      | 


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

Date: 12 Dec 98 21:33:47 GMT (Last modified)
From: Perl-Request@ruby.oce.orst.edu (Perl-Users-Digest Admin) 
Subject: Special: Digest Administrivia (Last modified: 12 Dec 98)
Message-Id: <null>


Administrivia:

Well, after 6 months, here's the answer to the quiz: what do we do about
comp.lang.perl.moderated. Answer: nothing. 

]From: Russ Allbery <rra@stanford.edu>
]Date: 21 Sep 1998 19:53:43 -0700
]Subject: comp.lang.perl.moderated available via e-mail
]
]It is possible to subscribe to comp.lang.perl.moderated as a mailing list.
]To do so, send mail to majordomo@eyrie.org with "subscribe clpm" in the
]body.  Majordomo will then send you instructions on how to confirm your
]subscription.  This is provided as a general service for those people who
]cannot receive the newsgroup for whatever reason or who just prefer to
]receive messages via e-mail.

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.  

To submit articles to comp.lang.perl.misc (and this Digest), send your
article to perl-users@ruby.oce.orst.edu.

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.

The Meta-FAQ, an article containing information about the FAQ, is
available by requesting "send perl-users meta-faq". The real FAQ, as it
appeared last in the newsgroup, can be retrieved with the request "send
perl-users FAQ". Due to their sizes, neither the Meta-FAQ nor the FAQ
are included in the digest.

The "mini-FAQ", which is an updated version of the Meta-FAQ, is
available by requesting "send perl-users mini-faq". It appears twice
weekly in the group, but is not distributed in the digest.

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 V8 Issue 4544
**************************************

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