[12278] in Perl-Users-Digest

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

Perl-Users Digest, Issue: 5878 Volume: 8

daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Thu Jun 3 15:07:21 1999

Date: Thu, 3 Jun 99 12:00:20 -0700
From: Perl-Users Digest <Perl-Users-Request@ruby.OCE.ORST.EDU>
To: Perl-Users@ruby.OCE.ORST.EDU (Perl-Users Digest)

Perl-Users Digest           Thu, 3 Jun 1999     Volume: 8 Number: 5878

Today's topics:
        Get WinNT login <110363.3163@compuserve.com>
    Re: Help for a newbie <rootbeer@redcat.com>
    Re: lvalue subroutine returns in perl (Andrew Allen)
    Re: microso?t perl (Scott McMahan)
    Re: miliseconds in a timestamp? (Larry Rosler)
        Newbie: NT/checking for file permissions <sysop@bintug.org>
        PERL FOR NT (sam@cheapnet.co.uk)
    Re: PERL FOR NT (sam@cheapnet.co.uk)
    Re: PERL FREELANCERS: WANT TO MAKE A QUICK $500? <rootbeer@redcat.com>
    Re: PERL FREELANCERS: WANT TO MAKE A QUICK $500? (Ook!)
    Re: PERL FREELANCERS: WANT TO MAKE A QUICK $500? (Marc Bissonnette)
    Re: Perl script keeps terminating <rootbeer@redcat.com>
    Re: Perl Script wanted (to send SMS by WWW) <rootbeer@redcat.com>
    Re: Problem with opening 2 files at once. Please Help!! <rootbeer@redcat.com>
    Re: sh2perl <rootbeer@redcat.com>
    Re: stupid ISP? <rootbeer@redcat.com>
    Re: The artistic license and perl: <gbartels@xli.com>
    Re: Trouble with script output <rootbeer@redcat.com>
    Re: turn cache off in IE <cassell@mail.cor.epa.gov>
    Re: Using DLL functions in Perl (Scott McMahan)
    Re: Using DLL functions in Perl (Scott McMahan)
        where did I go wrong? (Marc Bissonnette)
    Re: where did I go wrong? <uri@sysarch.com>
    Re: where did I go wrong? (Marc Bissonnette)
    Re: Why dones't this oneliner work? (M.J.T. Guy)
        Special: Digest Administrivia (Last modified: 12 Dec 98 (Perl-Users-Digest Admin)

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

Date: Thu, 03 Jun 1999 19:51:14 +0200
From: Reiner Fischer <110363.3163@compuserve.com>
Subject: Get WinNT login
Message-Id: <3756C092.6352D902@compuserve.com>

Hello,

I would be very happy, if I would get some help from you.
I use Perl on WindowsNT. Is it possible to get the Login
from the User, who starts a Perl Script?

Many thanks in advance!

Best regards,
Reiner Fischer




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

Date: Thu, 3 Jun 1999 11:04:33 -0700
From: Tom Phoenix <rootbeer@redcat.com>
Subject: Re: Help for a newbie
Message-Id: <Pine.GSO.4.02A.9906031103320.22017-100000@user2.teleport.com>

On Mon, 31 May 1999 reddogg1471@my-deja.com wrote:

> Subject: Help for a newbie

Please check out this helpful information on choosing good subject
lines. It will be a big help to you in making it more likely that your
requests will be answered.

    http://www.perl.com/CPAN/authors/Dean_Roehrich/subjects.post

> I need to insert a header and footer from a text file and am
> unsure how to go about it. I need to first check the html file and see
> if the header and footer is already there, and if not, I need to add
> it. This needs to be done for all html files in the directory.

Sounds as if you'll be parsing the HTML. See HTML::Parser from CPAN.
Cheers!

-- 
Tom Phoenix       Perl Training and Hacking       Esperanto
Randal Schwartz Case:     http://www.rahul.net/jeffrey/ovs/



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

Date: 3 Jun 1999 18:08:44 GMT
From: ada@fc.hp.com (Andrew Allen)
Subject: Re: lvalue subroutine returns in perl
Message-Id: <7j6gbc$fva$5@fcnews.fc.hp.com>

Brian McCauley (B.A.McCauley@bham.ac.uk) wrote:
: If you remember in January we discussed the possibility of creating
: functions in perl that return lvalues.  I spouted some rubbish about
: using prototypes. 

: The initial idea is to have a "use lvalue" pragma that modifies the
: behaviour of "return"

I don't like this. Too global. At least make "use lvalue" be
block-scoped.  But it's applying a global flag to a per-sub
attribute. Bad design karma.

: (and the "leavesub" the implicit return at the
: end of a subroutine block) so that they don't copy mortalize the
: return list.

Is this how do-blocks do it?

: Another possibility would be to introduce a new list operator that
: could be used in place of "return".  Since I hate to extend the set of
: reserved words how about "tied return" for this?

Nope, too clunky. returnlval sounds good. Or how about just an '=' as
the first character of the prototype? (or the last character. Both
make sense to me.) Or even the possibly bizarre (but DWIM) syntax:

 return=$myval;

Andrew


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

Date: 3 Jun 1999 18:54:12 GMT
From: scott@aravis.softbase.com (Scott McMahan)
Subject: Re: microso?t perl
Message-Id: <3756cf54.0@news.new-era.net>

Yeah, but ...

If they add extensions which do Windows-specific stuff like
empty the recycle bin or do NetBEUI networking or whatever,
and these modules aren't opensourced, who cares? They'd
only work on Windows and only be needed for Windows stuff
anyway.

Besides, you can *ALREADY* use Windows Scripting Host
automation components in Perl to do anything you can do
in any other scripting language, so it is likely
that the extensions will be in the form of Automation
components.

Scott


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

Date: Thu, 3 Jun 1999 10:48:29 -0700
From: lr@hpl.hp.com (Larry Rosler)
Subject: Re: miliseconds in a timestamp?
Message-Id: <MPG.11c05fcafef68e59989b63@nntp.hpl.hp.com>

[Posted and a courtesy copy mailed.]

In article <7j6600$hju$1@nnrp1.deja.com> on Thu, 03 Jun 1999 15:12:08 
GMT, amidalla@my-deja.com <amidalla@my-deja.com> says...
> I'm looking for a smaller unit than the second to write to a log file
> when an action is encountered.  Currently I'm just using minutes and
> seconds:  ($sec, $min) = localtime(time)           ..Thanx..

>From perlfaq8:  "How can I measure time under a second?"
 
In general, you may not be able to. The Time::HiRes module (available 
from CPAN) provides this functionality for some systems. 
 ...

-- 
(Just Another Larry) Rosler
Hewlett-Packard Company
http://www.hpl.hp.com/personal/Larry_Rosler/
lr@hpl.hp.com


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

Date: Thu, 3 Jun 1999 08:01:07 -1000
From: "da kine" <sysop@bintug.org>
Subject: Newbie: NT/checking for file permissions
Message-Id: <928432890.100.36@news.remarQ.com>

I'm trying to determine if a file or subdir has write privileges on an
NTServer4.0 box in a script by checking
if (!-w "$path")
and it doesn't work.  It seems as if the NT box is not listing the
permissions bit even though write permissions are enabled for everyone.
a check if the file exists
if (!-e "$path")
works

Can anyone help?




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

Date: Thu, 03 Jun 1999 18:26:16 GMT
From: sam@cheapnet.co.uk (sam@cheapnet.co.uk)
Subject: PERL FOR NT
Message-Id: <3756c8c3.15555299@news.cheapnet.co.uk>

I need some sample scripts for Perl with NT
I want to create user accounts etc


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

Date: Thu, 03 Jun 1999 18:28:54 GMT
From: sam@cheapnet.co.uk (sam@cheapnet.co.uk)
Subject: Re: PERL FOR NT
Message-Id: <3756c911.15633029@news.cheapnet.co.uk>

>You'll be pleased to know that there are tons of such scripts
>on the Web.  Just use Alta Vista [or something similar] to
>search for them.  Or use DejaNews [deja.com] to search the
>archives of this newsgroup and the win32-perl-users listserv 
>for NT admin scripts.  There are very good Perl NT admin
>scripts in the O'Reilly 'octopus' book NT Administration
>too.  And check out Dave Roth's latest book too.
>
i looked all dya and didnt find one decent perl script for NT.
any further pointers.

>OTOH, this is really not a good place to ask for scripts.
>This newsgroup is oriented toward Perl programming.  That
>means that once you've written or adapted a Perl program,
>if you have some problems you can come here for some help.
>Just follow the directions in the nice e-mail you've just
>received from gnat about this newsgroup and Perl.
i have received nothing from gnat.



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

Date: Thu, 3 Jun 1999 11:33:12 -0700
From: Tom Phoenix <rootbeer@redcat.com>
Subject: Re: PERL FREELANCERS: WANT TO MAKE A QUICK $500?
Message-Id: <Pine.GSO.4.02A.9906031126070.22017-100000@user2.teleport.com>

On Wed, 2 Jun 1999 salbarcar@my-deja.com wrote:

> We have a calendar that we're trying to modify. It utilizes an SQL
> database. All that we need it to do is search by a DATE RANGE and
> RETURN RESULTS IN BATCHES OF 25. Right now it only searches one month
> at a time.

Gee, this sounds a lot like Randal's second WebTechniques column. Randal
even chose to use BATCHES OF 25, although he didn't remember to say so in
all caps. :-)

    http://www.stonehenge.com/merlyn/WebTechniques/

> My familiarity with Perl suggests that this is an easy job. Maybe 12?
> hours of work. Our bid is $500.

Hey, that's less than $50/hour. I'm not sure about this. Of course, I'd
have to spend the first eleven hours watching Baywatch reruns in order to
stretch this out to twelve hours, so maybe I should reconsider.

> Please e-mail me at speralta@awwa.org for further details. Only e-mail
> responses will be answered. In other words, I don't come to this group
> often so if you want to get a hold of me, E-MAIL ME.

Ah, well, some quick go-getter has probably already agreed to do this for
$500. I hope that Randal gets a share!

-- 
Tom Phoenix       Perl Training and Hacking       Esperanto
Randal Schwartz Case:     http://www.rahul.net/jeffrey/ovs/



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

Date: Thu, 03 Jun 1999 11:03:11 -0700
From: ookookook@yahoo.com (Ook!)
Subject: Re: PERL FREELANCERS: WANT TO MAKE A QUICK $500?
Message-Id: <ookookook-0306991103120001@ip174.r6.d.pdx.nwlink.com>

--In article <7j3jsd$mhb$1@nnrp1.deja.com>, salbarcar@my-deja.com posted:
--
--> We have a calendar that we're trying to modify. It utilizes an SQL
--> database. All that we need it to do is search by a DATE RANGE and RETURN
--> RESULTS IN BATCHES OF 25. Right now it only searches one month at
--> a time.
--> 
--> My familiarity with Perl suggests that this is an easy job. Maybe 12?
--> hours of work. Our bid is $500.
 
12 hours of work? My familiarity with freelance consulting suggests
that'll be $1080, half up front, feature freeze on signing, with the
actual work taking twice as long once you include testing and getting the
client to figure out what the hell it is they actually want.

-- 
"Television: a medium. So called because it is neither rare nor well done."
           - Ernie Kovacs


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

Date: Thu, 03 Jun 1999 18:56:19 GMT
From: dragnet@internalysis.com (Marc Bissonnette)
Subject: Re: PERL FREELANCERS: WANT TO MAKE A QUICK $500?
Message-Id: <ndA53.2563$5a.5021@news20.bellglobal.com>

In article <ookookook-0306991103120001@ip174.r6.d.pdx.nwlink.com>, 
ookookook@yahoo.com says...

>12 hours of work? My familiarity with freelance consulting suggests
>that'll be $1080, half up front, feature freeze on signing, with the
>actual work taking twice as long once you include testing and getting the
>client to figure out what the hell it is they actually want.

Agreed, 12 hours at $500 = $41 an hour. Personally, I bill $85 ($cdn) an hour, 
and I understand even that's cheap (Though I'm no Perl guru yet, either)

-- 
----------------------------
Marc Bissonnette
InternAlysis
Corporate Internet Research and Results!
http://www.internalysis.com



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

Date: Thu, 3 Jun 1999 11:12:33 -0700
From: Tom Phoenix <rootbeer@redcat.com>
Subject: Re: Perl script keeps terminating
Message-Id: <Pine.GSO.4.02A.9906031106440.22017-100000@user2.teleport.com>

On Thu, 3 Jun 1999, kevin wrote:

> My perl script has been running fine until recently when it appears to
> auto-terminate within 2-5 mins of of commencing.

Well, that's not Perl doing that. It sounds to me as if your process is
getting an unexpected signal.

> Any know if this is likely to be a code/server problem?
> 
> I suspect because it was previously OK it must be the server?

Sure, a server could be doing this. Check the docs, FAQs, and newsgroups
about your server and servers in general for more information. Of course,
if you're talking about a webserver and CGI program, your program
shouldn't be taking more than a few seconds to respond, so killing it
would be a Good Thing for a webserver to do. But this isn't a Perl matter,
since it's the same whether your program is written in Perl or in any
other language.

Cheers!

-- 
Tom Phoenix       Perl Training and Hacking       Esperanto
Randal Schwartz Case:     http://www.rahul.net/jeffrey/ovs/




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

Date: Thu, 3 Jun 1999 11:46:49 -0700
From: Tom Phoenix <rootbeer@redcat.com>
Subject: Re: Perl Script wanted (to send SMS by WWW)
Message-Id: <Pine.GSO.4.02A.9906031146330.22017-100000@user2.teleport.com>

On Thu, 3 Jun 1999, Oliver Timme wrote:

> I'm looking for a Perl script 

If you're wishing merely to _find_ (as opposed to write) programs,
this newsgroup may not be the best resource for you. There are many
freeware and shareware archives which you can find by searching Yahoo
or a similar service. Hope this helps!

-- 
Tom Phoenix       Perl Training and Hacking       Esperanto
Randal Schwartz Case:     http://www.rahul.net/jeffrey/ovs/



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

Date: Thu, 3 Jun 1999 11:51:47 -0700
From: Tom Phoenix <rootbeer@redcat.com>
Subject: Re: Problem with opening 2 files at once. Please Help!!!!
Message-Id: <Pine.GSO.4.02A.9906031148140.22017-100000@user2.teleport.com>

On Thu, 3 Jun 1999, Chris Manolis wrote:

> The Script works fine on an WinNT PC but when I try to run it on a LINUX
> PC I get the error
> 
> Can't write file : No such file or directory at pbx line 27, <INPUT>
> chunk 1.
> 
> line 27 contains this:
>          open (OUTPUT, ">> /root/$datafile") or die "Can't write file :
> $!";  

Your system seems to be telling you that the name "/root/$datafile" (for
whatever is your value of $datafile) isn't a valid filename. I'd guess
that the directory /root doesn't exist, or that $datafile doesn't contain
what you thought it contained. (Could it possibly have something really
odd, such as a control character?)

I'd probably re-write that line like this to make the message a touch more
informative:

    open OUTPUT, ">> /root/$datafile"
	or die "Can't open '/root/$datafile' for append: $!";

Hope this helps!

-- 
Tom Phoenix       Perl Training and Hacking       Esperanto
Randal Schwartz Case:     http://www.rahul.net/jeffrey/ovs/



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

Date: Thu, 3 Jun 1999 11:23:32 -0700
From: Tom Phoenix <rootbeer@redcat.com>
Subject: Re: sh2perl
Message-Id: <Pine.GSO.4.02A.9906031121090.22017-100000@user2.teleport.com>

On Wed, 2 Jun 1999 akluyskens@my-deja.com wrote:

> I just downloaded the sh2perl program written by :
> 
> Randal L. Schwartz, C<merlyn@stonehenge.com>,
> C<http://www.stonehenge.com/merlyn/>.
> 
> I tried to use it but it seemed buged. 

It ought to work, at least as documented. Complain to the author. :-)

> I also wonder how it is even possible to write a sh 2 perl converter
> (except if it is a joke) because the way the shell have access to OS
> commands is completly different than the way you handle it in perl.
> Except using the system module I could not find any other method for
> automatic conversion. Does someone already succeeded in using this
> program?

It may be enlightening to realize that the release date for that program
is 1 April, and that Randal is not without a sense of humor. The Perl FAQ
has more information on converting from shell scripts. Cheers!

-- 
Tom Phoenix       Perl Training and Hacking       Esperanto
Randal Schwartz Case:     http://www.rahul.net/jeffrey/ovs/



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

Date: Thu, 3 Jun 1999 11:37:38 -0700
From: Tom Phoenix <rootbeer@redcat.com>
Subject: Re: stupid ISP?
Message-Id: <Pine.GSO.4.02A.9906031135220.22017-100000@user2.teleport.com>

On 3 Jun 1999, Jonathan Stowe wrote:

> Yes they are correct Perl does not make logs - however when used in a
> CGI program then any error messages Perl creates will go into the HTTP
> servers error_log.

To be sure, this is true only in the most common configurations of the
most common servers. And, even there, you can have your program redirect
errors to your favorite destination. But you knew that. :-)

-- 
Tom Phoenix       Perl Training and Hacking       Esperanto
Randal Schwartz Case:     http://www.rahul.net/jeffrey/ovs/



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

Date: Thu, 03 Jun 1999 13:37:55 -0400
From: Greg Bartels <gbartels@xli.com>
Subject: Re: The artistic license and perl:
Message-Id: <3756BD73.D718D178@xli.com>

Chris Nandor wrote:
> 
> In article <3756a789@cs.colorado.edu>, tchrist@mox.perl.com (Tom
> Christiansen) wrote:
> 
> #      [courtesy cc of this posting mailed to cited author]
> #
> # In comp.lang.perl.misc, pudge@pobox.com (Chris Nandor) writes:
> # :The AL cannot reasonably be a barrier for use of
> # :Perl, because it is completely optional.
> #
> # But it's important.  There have been very large companies whose lawyers
> # have contacted Larry for clarification.  They aren't allowed to touch
> # the GPV (why why WHY won't people understand this issue?), so have to
> # use the AL,
> 
> Right, so in these cases, it is not the AL that is a barrier for use, but
> a combination of the AL and GNU GPL.  I think that is an important
> distinction.
> 
> # but want clarification.  Larry always manages to talk them
> # into being happy with it all.
> 
> Perhaps Larry should publish a paper on the AL.
> 
> Note: I don't see the fact that lawyers asking for clarification as
> evidence that the AL is significantly ambiguous.  Lawyers ask for
> clarification on all kinds of legal documents, all the time.  And the idea
> that it can be taken to mean something it wasn't meant to mean ... that
> can, and probably will, happen in any event, no matter who drafts it or
> how it is drafted.
> 
> --
> Chris Nandor          mailto:pudge@pobox.com         http://pudge.net/
> %PGPKey = ('B76E72AD', [1024, '0824090B CE73CA10  1FF77F13 8180B6B6'])


my point is that a sufficiently friendly license would / could support
perl in being adopted by companies similar to the way Red Hat has 
adopted Linux. 

how many companies look at the AL and dont even bother calling Larry,
and scrap the idea entirely?  Even if gettting clarification from
Larry works, why not just clarify it in the license in the first place?
hopefully he'll at least do this before he passes the Perl torch on
to someone else.

the question is:

"how do keep perl open source, encouraging profit-based companies
to develop extensions and return it to open-source, and prevent
the language from forking?"

you can dismiss it as a 'non-technical' question, but thats not
entirely true. its a question, whose answer just happens to be
programmed in a language other than Perl or C.  Its programmed
as a legal document, as a "script" that gets "interpreted" on 
systems such as "the supreme court" and "corporate legal teams".

The answer is in the form of a solidly written license.

There is also such a thing as perception. if people believe
the license is shakey, and avoid using perl, then it doens't
really matter whether or not the license is shakey/ambigous
or not. 

the whole "open source" movement was, in part, a marketing
campaign to overcome all the perceptions that the public
had around "free-ware" and the rather extreme sounding language
of the Gnu Public License.

so this marketing campaign was part of the answer to making
free-ware into something palatable to profit companies, and 
still keep it open source.

as far as mighcrowsoft and perl are  concerned, I still say
that if there is a loophole in the license, it would be the
microsoft legal team that would find it and exploit it.
why not just tighten up the license now rather than wait till
something happens and responding "hey, no fair".

Greg


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

Date: Thu, 3 Jun 1999 11:00:31 -0700
From: Tom Phoenix <rootbeer@redcat.com>
Subject: Re: Trouble with script output
Message-Id: <Pine.GSO.4.02A.9906031059420.22017-100000@user2.teleport.com>

On Tue, 1 Jun 1999 domat6905@my-deja.com wrote:

> I'm writing a perl cgi script 

When you're having trouble with a CGI program in Perl, you should first
look at the please-don't-be-offended-by-the-name Idiot's Guide to solving
such problems. It's available on CPAN.

   http://www.perl.com/CPAN/
   http://www.perl.org/CPAN/
   http://www.perl.org/CPAN/doc/FAQs/cgi/idiots-guide.html
   http://www.perl.org/CPAN/doc/manual/html/pod/

Hope this helps!

-- 
Tom Phoenix       Perl Training and Hacking       Esperanto
Randal Schwartz Case:     http://www.rahul.net/jeffrey/ovs/



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

Date: Thu, 03 Jun 1999 11:03:59 -0700
From: David Cassell <cassell@mail.cor.epa.gov>
To: Nick Lee <leenick@interchange.ubc.ca>
Subject: Re: turn cache off in IE
Message-Id: <3756C38F.6F1EE361@mail.cor.epa.gov>

[courtesy cc to poster]

Nick Lee wrote:
> 
> Hi,
> 
> Anyone knows how to turn OFF the cache in IE? I've tried using the
> header called Pragma (with a value of "no-cache"), but it seems to
> work only in NS, not in IE. IE still cache the document and doesn't
> reload unless I press 'refresh' explicitly.

I'm sorry to be the one to tell you, but you seem to be in
the wrong newsgroup.  If you want help with your version of
IE, then you'll probably do much better asking in one of the
newsgroups that focuses on browsers.  In fact, there's probably
a newsgroup specifically for your version of IE where lots of
knowledgeable people could help you.

BTW, was there a reason why you posted this to a newsgroup
devoted to programming in a specific computer language?

HTH,
David
-- 
David Cassell, OAO                     cassell@mail.cor.epa.gov
Senior computing specialist
mathematical statistician


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

Date: 3 Jun 1999 19:00:42 GMT
From: scott@aravis.softbase.com (Scott McMahan)
Subject: Re: Using DLL functions in Perl
Message-Id: <3756d0da.0@news.new-era.net>

Vincent Vanbiervliet (vincent_vanbiervliet@be.ibm.com) wrote:
> How can I call a DLL function in Perl?

The simplest way is to make the DLL an Automation server DLL,
and use Win32::OLE to load the component like you would
any Automation component. Making an Automation DLL is as
easy as making a regular one in modern compilers.

Scott



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

Date: 3 Jun 1999 19:01:49 GMT
From: scott@aravis.softbase.com (Scott McMahan)
Subject: Re: Using DLL functions in Perl
Message-Id: <3756d11d.0@news.new-era.net>

Lewis Perin (perin@panix7.panix.com) wrote:
> "Vincent Vanbiervliet" <vincent_vanbiervliet@be.ibm.com> writes:

> > How can I call a DLL function in Perl?
> > I don't have any source code from the dll (it's an encryption/decryption
> > algorithm that has to stay secret, even from me :-( ), but
> > I know the arguments to pass to the function.
> > I'm using a Win32 platform.
> > 
> > Any suggestions?

> Aldo Calpini's Win32:API will do this.  Be sure you read the
> documentation extremely carefully and don't even think of using it if
> you aren't comfortable with pack/unpack.

The nice thing about Automation is the parameter passing is
done magically on both ends, and you don't have to worry
about this kind of thing. You can call your function as
a normal function and the glue layer on both ends
does the parameter passing for you.

Scott


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

Date: Thu, 03 Jun 1999 18:34:58 GMT
From: dragnet@internalysis.com (Marc Bissonnette)
Subject: where did I go wrong?
Message-Id: <mVz53.2560$5a.5021@news20.bellglobal.com>

Hey All,

I'm trying to read in a file, pipe delimited, in order to work with the data 
loaded into hashes. When running the following, I get nothing. It's probably 
something really obvious, but I just can't seem to see it.

A typical line from the (<DATAIN>) would be:

Marc|Bissonnette|Consultant|Internalysis|

while (<DATAIN>) {
	push (@lines, $_);
}
close DATAIN;
foreach (@lines) {
	@line = (split /\|/,$_);
	push (@names, $line[0]);
	$ident=$line[0];
	%$ident={
		fname => "$line[0]",
		lname => "$line[1]",
		title => "$line[2]",
		comp  => "$line[3]",
	};
}

foreach (@names)	{
	print $$ident{"fname"};
}


Help is much appreciated
-- 
----------------------------
Marc Bissonnette
InternAlysis
Corporate Internet Research and Results!
http://www.internalysis.com



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

Date: 03 Jun 1999 14:47:25 -0400
From: Uri Guttman <uri@sysarch.com>
Subject: Re: where did I go wrong?
Message-Id: <x7d7zdazpe.fsf@home.sysarch.com>

>>>>> "MB" == Marc Bissonnette <dragnet@internalysis.com> writes:


  MB> while (<DATAIN>) {
  MB> 	push (@lines, $_);
  MB> }

much simpler is:

	@lines = <DATAIN> ;

  MB> foreach (@lines) {

or do this and no need for the previous while loop:

	while( <DATAIN> ) {

  MB> 	@line = (split /\|/,$_);

no need for the parens as split returns a list. also it defaults to $_.

	@line = split /\|/ ;

  MB> 	push (@names, $line[0]);
  MB> 	$ident=$line[0];

how about this which saves an array lookup:

	$ident = $line[0] ;
	push (@names, $ident );

  MB> 	%$ident={
  MB> 		fname => "$line[0]",

again, use $ident here

  MB> 		lname => "$line[1]",
  MB> 		title => "$line[2]",
  MB> 		comp  => "$line[3]",

no need for the quotes here. $line[0] is fine as is.

  MB> 	};

you are using symbolic references which is not cool. use a hash of
hashes and your life and code will be easier. read perldsc and the faq
for more about this. the cookbook also has good stuff on this subject

uri

-- 
Uri Guttman  -----------------  SYStems ARCHitecture and Software Engineering
uri@sysarch.com  ---------------------------  Perl, Internet, UNIX Consulting
Have Perl, Will Travel  -----------------------------  http://www.sysarch.com
The Best Search Engine on the Net -------------  http://www.northernlight.com


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

Date: Thu, 03 Jun 1999 18:54:05 GMT
From: dragnet@internalysis.com (Marc Bissonnette)
Subject: Re: where did I go wrong?
Message-Id: <hbA53.2561$5a.5021@news20.bellglobal.com>

In article <x7d7zdazpe.fsf@home.sysarch.com>, uri@sysarch.com says...
>

>you are using symbolic references which is not cool. use a hash of
>hashes and your life and code will be easier. read perldsc and the faq
>for more about this. the cookbook also has good stuff on this subject

Thank you! Ironically, I found out the %$ident was what was causing the big 
error (I've got the "Programming Perl" right in front of me, but I must be 
going blind, since I missed the obvious example)

Your code shortened mine much, thanks!

Yes, I'm looking up hash of hashes now, though I'm pleased to at least be able 
to pull data now (meaning something, at least has stuck in my brain so far)

Thanks again!

-- 
----------------------------
Marc Bissonnette
InternAlysis
Corporate Internet Research and Results!
http://www.internalysis.com



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

Date: 3 Jun 1999 18:08:28 GMT
From: mjtg@cus.cam.ac.uk (M.J.T. Guy)
Subject: Re: Why dones't this oneliner work?
Message-Id: <7j6gas$2hm$1@pegasus.csx.cam.ac.uk>

>Hi Perl-ers..
>
>I have two lines that I'm trying to combine into 1. Basically I do a
>conditional push, then increment $i:
>
>THIS WORKS:
> foreach (@y) {$_ && push @z,$x[$i]; $i++;}
>
>THIS DOESN'T, but I don't know why not. The logic appears OK:
> foreach (@y) {(($i++ + 1) && $_) && push @z,$x[$i];}
>^
>
>(Statement above ^ should always be true). In the latter, I'm not
>certain that $i isn't incremented too soon, but I don't think it should
>be until the entire block executes, which is the desired behavior.

&& is one of the few Perl operations whose order of evaluation is defined.
The LHS is always evaluated before the right, so you see the updated
$i value.

And as TomC has pointed out, there are more Perlish ways of doing this,
for example

     @z = map { $y[$_] ? $x[$_] : () } 0..$#y;

 
Mike Guy


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

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 5878
**************************************

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