[11522] in Perl-Users-Digest

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

Perl-Users Digest, Issue: 5121 Volume: 8

daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Fri Mar 12 18:07:27 1999

Date: Fri, 12 Mar 99 15:00:24 -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           Fri, 12 Mar 1999     Volume: 8 Number: 5121

Today's topics:
    Re: 
        \ regex problem <joelb@docent.com>
        Alias for object methods? <lrosen@harp.gsfc.nasa.gov>
    Re: Alias for object methods? (Tramm Hudson)
    Re: Are negative array indeces allowed? <droby@copyright.com>
    Re: Are negative array indeces allowed? (Tad McClellan)
    Re: CGI.pm - parameter count? <gellyfish@btinternet.com>
        chown problem.. question (Gigatron)
    Re: command-line CGI (Ethan H. Poole)
        Compiling PERL 5.005.02 for thread support <partha@mihy.mot.com>
        Deletion of a List Array Entry (G.IM)
    Re: Deletion of a List Array Entry <joelb@docent.com>
    Re: Determine Perl version with CGI script & script pro <rvdb@nedernet.nl>
        Error Message Mystery bmonti@my-dejanews.com
        Exporter question <prlawrence@lehigh.edu>
        Exporter question <prlawrence@lehigh.edu>
        Help searching text file <jfettig@students.uiuc.edu>
    Re: how to output in the desired order? <jglascoe@giss.nasa.gov>
    Re: how to output in the desired order? <stampes@xilinx.com>
    Re: IDE for Perl <jonz@rmi.nospam.net>
    Re: Learn the truth - In Dear Recruiter we establish ex (I R A Aggie)
    Re: Learn the truth - In Dear Recruiter we establish ex <elaine@cts.wustl.edu>
    Re: Module to find duplicate files? (Greg Ward)
    Re: NET::FTP with ActiveState <gregl@netaffect.com>
        perl installation need help vliaw@aa-net.com
    Re: Perl, IIS, writing to network drives (Ethan H. Poole)
    Re: Printing in Perl <emschwar@mail.uccs.edu>
        Special: Digest Administrivia (Last modified: 12 Dec 98 (Perl-Users-Digest Admin)

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

Date: Fri, 12 Mar 1999 10:23:15 -0500
From: tadmc@metronet.com (Tad McClellan)
Subject: Re: 
Message-Id: <3hbbc7.k2a.ln@magna.metronet.com>

Bob Langdon (bingdo19@earthlink.net) wrote:

: What is -T?


   Perl's command line switches are documented in the 'perlrun.pod'
   file that comes with the perl distribution.


: And why use it only in CGI?


   It is a security feature and there are Bad Guys out there.

   It is not "only" CGI. You use it when you want the extra
   security that it provides. (and you _do_ want it when
   you happen to be doing CGI stuff).


--
    Tad McClellan                          SGML Consulting
    tadmc@metronet.com                     Perl programming
    Fort Worth, Texas


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

Date: Fri, 12 Mar 1999 22:01:50 GMT
From: Joel Bremson <joelb@docent.com>
Subject: \ regex problem
Message-Id: <i9gG2.17435$FZ5.3910@news.rdc1.sfba.home.com>

This is a multi-part message in MIME format.
--------------A334E2FE04265EBBDD27404F
Content-Type: text/plain; charset=us-ascii
Content-Transfer-Encoding: 7bit

Hi,

I am trying to write a subroutine that when passed a file name
and a single quoted string containing a regex will apply the regex
to the file.

The problem is that I can't figure out how to get '\\' to not compress
to '\' without resorting to extra backslashes. This program illustrates
the problem:

		#!/usr/bin/perl
	
		$a = 's/([^\\]>)/$1\n/g';
		print $a, "\n";

OUTPUT: 	s/([^\]>)/$1\n/g
                     ^
		    should be '\\'


Ideally, I'd like my sub to be used without having to specially format
the regex.

(Fixing the passed the regex in the sub is an option, although it seems
hard. For example, how 
 to deal with a regex containing a string like '\\november' which would
become '\november' ?)

-Joel 

joelb at docent.com
--------------A334E2FE04265EBBDD27404F
Content-Type: text/x-vcard; charset=us-ascii;
 name="---joelb.vcf"
Content-Transfer-Encoding: 7bit
Content-Description: Card for Joel Bremson
Content-Disposition: attachment;
 filename="---joelb.vcf"

begin:vcard 
n:Bremson;Joel
x-mozilla-html:FALSE
org:Docent, Inc
adr:;;2444 Charleston;Mountain View;CA;94043;USA
version:2.1
email;internet:joelb@docent.com
title:Implementation Manager
tel;fax:650-962-9411
tel;work:650-934-9581
x-mozilla-cpt:;0
fn:Joel Bremson
end:vcard

--------------A334E2FE04265EBBDD27404F--



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

Date: Fri, 12 Mar 1999 16:29:23 -0500
From: Larry Rosen <lrosen@harp.gsfc.nasa.gov>
Subject: Alias for object methods?
Message-Id: <36E98732.8C4B4277@harp.gsfc.nasa.gov>

Is there a way to alias a method, perhaps using
a typeglob?

I've tried things like:
   my *func2 = *func1;
>>> Can't declare ref-to-glob cast.
   my *func2 = *&func1;
>>> Can't declare ref-to-glob cast, and Bareword error.

I know I can do the following:

sub func2 {
   $self = shift;
   $self->func1(@_);
}

but I was wondering if I could do it with an alias.

Thanks,
please cc: me at lrosen@harp.gsfc.nasa.gov



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

Date: 12 Mar 1999 15:17:04 -0700
From: hudson@swcp.com (Tramm Hudson)
Subject: Re: Alias for object methods?
Message-Id: <7cc3p0$nqn@boofura.swcp.com>

[cc'd as requested]

In article <36E98732.8C4B4277@harp.gsfc.nasa.gov>,
Larry Rosen  <lrosen@harp.gsfc.nasa.gov> wrote:
>Is there a way to alias a method, perhaps using a typeglob?

#!/usr/bin/perl -w
use strict;
 
{
        package Foo;
        sub new { bless {}, shift }
        sub foo { print "foo called @_\n" }
        *bar = \&foo;
}
 
my $foo = new Foo;

$foo->bar('via foo->bar');
$foo->foo('via foo->foo');
Foo::bar( 'via Foo::Bar');
Foo::foo( 'via Foo::Foo');

*local_foo = \&Foo::bar;
local_foo('via local_foo');

my $foo_ref = \&Foo::bar;
$foo_ref->('via foo_ref');

__END__

>I've tried things like:
>   my *func2 = *func1;
>>>> Can't declare ref-to-glob cast.
>   my *func2 = *&func1;
>>>> Can't declare ref-to-glob cast, and Bareword error.

The problem here is that you can not declare a lexical type glob.
Note that when I make the local_foo typeglob that it is -not-
declared lexical.  If you want a lexical function reference you
can make one, but it does not add anything to your symbol table.
Note that there is now a function named main::local_foo that can
be called by anyone else.  To avoid this, use:

	{
		local *local_foo = \&Foo::bar;
		local_foo('via local_foo');
	}

afterwhich the mapping of main::local_foo to Foo::bar is removed.

You could also say in package Foo:
	*bar = *foo;

but that also makes $Foo::bar and @Foo::bar and %Foo::bar be
the same as [$@%]Foo::bar, as well as formats and filehandles.
It is safer just to copy the function reference with:
	*bar = \&foo;

Tramm
-- 
  o   hudson@swcp.com                 tbhudso@cs.sandia.gov   O___|   
 /|\  http://www.swcp.com/~hudson/          H 505.266.59.96   /\  \_  
 <<   KC5RNF @ N5YYF.NM.AMPR.ORG            W 505.284.24.32   \ \/\_\  
  0                                                            U \_  | 


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

Date: Fri, 12 Mar 1999 21:16:44 GMT
From: Don Roby <droby@copyright.com>
Subject: Re: Are negative array indeces allowed?
Message-Id: <7cc07i$2fd$1@nnrp1.dejanews.com>

In article <36E92390.308C6E84@gte.com>,
  jc@eddie.mit.edu wrote:
> Sam Holden wrote:
> >
> > On 12 Mar 1999 12:43:27 +0100, Alex Farber <eedalf@eed.ericsson.se> wrote:
> > >Hi,
> > >
> > >I have just discovered that perl -e '@x = qw (a b c); print $x[-3]'
> > >prints "a" on my Solaris workstation (perl 5.004_04). So, is a
> > >negative array index allowed? Amazing, I haven't ever read about it
> > >in the 5 perl books I have or in "perldoc perldata"... When was it
> > >introduced? Can I rely on it now?
> >
> > Did you read the first paragraph of that perldata documentation you
> > claimed you did?
> >
> > I doubt it. It gives you your answer in simple English.
> >
> > Well it does in 5.005 under linux, and 5.002 under Solaris. So I assume
> > it didn't disappear in between.
>
> Jeez; it'd have been a lot less typing to simply answer the question:
>
> 	No.
>

Jeez.  Try at least answering it correctly, as Sam did.

	Yes.

Conciseness isn't everything.
--
Don Roby

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


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

Date: Fri, 12 Mar 1999 10:15:17 -0500
From: tadmc@metronet.com (Tad McClellan)
Subject: Re: Are negative array indeces allowed?
Message-Id: <52bbc7.k2a.ln@magna.metronet.com>

John Chambers (john.chambers@gte.com) wrote:
: Sam Holden wrote:
: > 
: > On 12 Mar 1999 12:43:27 +0100, Alex Farber <eedalf@eed.ericsson.se> wrote:
: > >Hi,
: > >
: > >I have just discovered that perl -e '@x = qw (a b c); print $x[-3]'
: > >prints "a" on my Solaris workstation (perl 5.004_04). So, is a
: > >negative array index allowed? Amazing, I haven't ever read about it
: > >in the 5 perl books I have or in "perldoc perldata"... When was it
: > >introduced? Can I rely on it now?
: > 
: > Did you read the first paragraph of that perldata documentation you
: > claimed you did?
: > 
: > I doubt it. It gives you your answer in simple English.
: > 
: > Well it does in 5.005 under linux, and 5.002 under Solaris. So I assume
: > it didn't disappear in between.

: Jeez; it'd have been a lot less typing to simply answer the question:

: 	No.


   Jeez it'd have been a lot better if you answered one of
   the questions that was asked.

   For which question is the answer "No"?


: So, is a negative array index allowed?

   Yes.


: When was it introduced?

   I don't know.


: Can I rely on it now?

   Yes.


   I don't see any that can be answered No...


--
    Tad McClellan                          SGML Consulting
    tadmc@metronet.com                     Perl programming
    Fort Worth, Texas


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

Date: 11 Mar 1999 21:34:58 -0000
From: Jonathan Stowe <gellyfish@btinternet.com>
Subject: Re: CGI.pm - parameter count?
Message-Id: <7c9cu2$pf$1@gellyfish.btinternet.com>

On Thu, 11 Mar 1999 17:39:46 GMT k_mcdermott@my-dejanews.com wrote:
> Hi,
> 
> I have a couple of scripts that create forms and then have an 'opposite
> number' which processes the output of the form.
> 
> I was wanting to combine these into one script, to create and then process the
> form.
> 
> Is this possible?
> 
> I had thought that the number of parameters would be useful since the creator,
> only has one parameter and the form processor has many, but I can't get
> the number of parameters out?
> 

If you are using CGI.pm then you could try something like:

use CGI qw(:standard);

$blah = @params = param();

print $blah,"\n";

Check out the documentation for CGI.pm

/J\
-- 
Jonathan Stowe <jns@btinternet.com>
Some of your questions answered:
<URL:http://www.btinternet.com/~gellyfish/resources/wwwfaq.htm>
Hastings: <URL:http://www.newhoo.com/Regional/UK/England/East_Sussex/Hastings>


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

Date: Fri, 12 Mar 1999 19:55:08 GMT
From: mikeob@itas.netnospam (Gigatron)
Subject: chown problem.. question
Message-Id: <36e97108.99091105@news.mtt.net>

Cannot get chown to change owner of a directory. Is there anyway
around this?
Things to remember
cgi script executes as nobody. ( I think)



$dirname="$in{'c_username'}"; ## value enter from web
$chanto="clients"; ## value to iddentify the directory to change to
chdir($chanto)|| die "cannot chdir clients"; ## change to that
directory
mkdir($dirname,0777) || die "cannot mkdir $dirname"; ##  making the
directorry
chown edigate,$dirname || die "cannot chown in"; # does not work.
chdir($dirname)|| die "cannot chdir $dirname";
mkdir(in,0766) || die "cannot mkdir in";
mkdir(out,0766) || die "cannot mkdir out";
chown edigate,in || die "cannot chown in";



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

Date: Fri, 12 Mar 1999 16:43:39 -0500
From: ehpoole@ingress.com (Ethan H. Poole)
Subject: Re: command-line CGI
Message-Id: <inM$jFNb#GA.174@rejz.ij.net>

[Posted and Emailed]  In article <36E93B10.760E5132@peon.oit.umass.edu>, 
dave@peon.oit.umass.edu says...
>
>I'm writing some CGI programs for work, and I would like to be able to
>test them from a command line, rather than having to test them on the
>web.  Is there any way to simulate the QUERY_STRING from the command
>line?  Thank you very much.
>
>-Dave

Yes, manually set the QUERY_STRING and REQUEST_METHOD environment variables 
before calling the script.

-- 
Ethan H. Poole              | Website Design and Hosting,
                            | CGI Programming (Perl & C)..
========Personal=========== | ============================
* ehpoole @ ingress . com * | --Interact2Day, Inc.--
                            | http://www.interact2day.com/



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

Date: Thu, 11 Mar 1999 17:43:29 +0530
From: Ramanujam Parthasarathi <partha@mihy.mot.com>
Subject: Compiling PERL 5.005.02 for thread support
Message-Id: <36E7B369.6AE37F5C@mihy.mot.com>

Hi

Compiling PERL 5.005.02 for thread support, gave this problem:
undefined symbol YIELD
I copied the definition of YIELD from dosish.h to unixish.h. This solved
the "make" problem. But "make test" failed :-(

Can anyone help please?
(The site configuration is mentioned below)

Thanks
-Partha
----------------------------------------------------------------------------------------

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

Site configuration information for perl 5.00502:

Configured by partha at Thu Dec 24 18:43:38 GMT 1998.

Summary of my perl5 (5.0 patchlevel 5 subversion 2) configuration:
  Platform:
    osname=solaris, osvers=2.6, archname=sun4-solaris
    uname='sunos telegana 5.6 generic_105181-09 sun4u sparc
sunw,ultra-5_10 '
    hint=recommended, useposix=true, d_sigaction=define
    usethreads=undef useperlio=undef d_sfio=undef
  Compiler:
    cc='cc', optimize='-O', gccversion=
    cppflags=''
    ccflags =''
    stdchar='unsigned char', d_stdstdio=define, usevfork=false
    intsize=4, longsize=4, ptrsize=4, doublesize=8
    d_longlong=define, longlongsize=8, d_longdbl=define, longdblsize=16
    alignbytes=8, usemymalloc=y, prototype=define
  Linker and Libraries:
    ld='cc', ldflags =''
    libpth=/usr/X/lib /usr/lib /usr/openwin/lib
    libs=-lsocket -lnsl -ldl -lm -lc -lcrypt
    libc=/lib/libc.so, so=so, useshrplib=false, libperl=libperl.a
  Dynamic Linking:
    dlsrc=dl_dlopen.xs, dlext=so, d_dlsymun=undef, ccdlflags=' '
    cccdlflags='-KPIC', lddlflags='-G'





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

Date: Fri, 12 Mar 1999 22:33:56 GMT
From: noone@home.com (G.IM)
Subject: Deletion of a List Array Entry
Message-Id: <oDgG2.17615$5e5.3954@news.rdc1.sdca.home.com>

Is it possible to delete an entry of a list array? I know it is possible to 
delete an entry in an associative array through the use of its key and its 
corresponding value, but how about an @list?
I've tried shift and unshift, but that doesn't seem to do much. It just adds 
the entry to the top and deletes the entry from the top, leaving the original 
entry I wanted to delete in tact. Those commands accomplish nothing.
I really want to be able to execute a command like this, delete (@list[0]), 
but  haven't come across any such thing. 
Thanks for any help!


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

Date: Fri, 12 Mar 1999 22:49:58 GMT
From: Joel Bremson <joelb@docent.com>
Subject: Re: Deletion of a List Array Entry
Message-Id: <36E999EA.5EAB9725@docent.com>

This is a multi-part message in MIME format.
--------------B2A27844FA6CD67EDD690F81
Content-Type: text/plain; charset=iso-8859-1
Content-Transfer-Encoding: 8bit

Use splice. For simply removing elements the syntax is:

splice ARRAY, OFFSET (starting point in array), LENGTH ( how many to
remove
starting at the starting point)

Example: 

	#!/usr/bin/perl

	@a = ('h','i','k');

	splice @a, 1, 1;

	print "@a\n";

OUTPUT: h k

HTH,
-Joel


"G.IM" wrote:
> 
> Is it possible to delete an entry of a list array? I know it is possible to
> delete an entry in an associative array through the use of its key and its
> corresponding value, but how about an @list?
> I've tried shift and unshift, but that doesn't seem to do much. It just adds
> the entry to the top and deletes the entry from the top, leaving the original
> entry I wanted to delete in tact. Those commands accomplish nothing.
> I really want to be able to execute a command like this, delete (@list[0]),
> but  haven't come across any such thing.
> Thanks for any help!
--------------B2A27844FA6CD67EDD690F81
Content-Type: text/x-vcard; charset=us-ascii;
 name="joelb.vcf"
Content-Transfer-Encoding: 7bit
Content-Description: Card for Joel Bremson
Content-Disposition: attachment;
 filename="joelb.vcf"

begin:vcard 
n:Bremson;Joel
x-mozilla-html:FALSE
org:Docent, Inc
adr:;;2444 Charleston;Mountain View;CA;94043;USA
version:2.1
email;internet:joelb@docent.com
title:Implementation Manager
tel;fax:650-962-9411
tel;work:650-934-9581
x-mozilla-cpt:;0
fn:Joel Bremson
end:vcard

--------------B2A27844FA6CD67EDD690F81--



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

Date: Fri, 12 Mar 1999 21:54:20 +0100
From: "RJHM van den Bergh" <rvdb@nedernet.nl>
Subject: Re: Determine Perl version with CGI script & script problem
Message-Id: <921271789.7962.0.rover.c29fe22b@news.demon.nl>

Thanks for your answer.

I got this returned

The Perl versiom is perl.c,v1.41996/08/27 02:32:29 Patch level: 36

So I asume they are using version 1.436 of Perl.
I think probably this is causing the problems.

Rob,
rvdb@nedernet.nl







Tobin Fricke wrote in message <36E83C1C.BF113B2@cory.eecs.berkeley.edu>...
>> So I do asume Hypermart is using another version of perl.
>> How do I determine the version they are using. ?
>
>If you have shell access, just run perl with the -v option (ie,
>/usr/bin/perl -v) and it will spew forth its version number and other
>information.  If you need to determine the version number from within a
>Perl program, use the $] special variable (try "print $]"), or
>$PERL_VERSION if you're doing Use English, documented on page 136 of the
>Camel book.
>
>> The error log on hypermart shows
>>  [Wed Mar 10 14:00:51 1999] access to /data1/hypermart.net/edah/chat.pl
>> failed for 194.159.226.43, reason: Premature end of script headers Search
>
>It's often easier to debug errors like this if you use nph (non-parsed
>headers).
>
>Tobin




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

Date: Fri, 12 Mar 1999 20:06:47 GMT
From: bmonti@my-dejanews.com
Subject: Error Message Mystery
Message-Id: <7cbs4h$uq5$1@nnrp1.dejanews.com>

Anybody know what causes this error:

"Out of memory! Attempt to free unreferenced scalar. "

Oh, and it only happens every now and then!

Thanks,
bmonti


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


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

Date: Fri, 12 Mar 1999 16:51:13 -0500
From: "Phil R Lawrence" <prlawrence@lehigh.edu>
Subject: Exporter question
Message-Id: <7cc294$17uc@fidoii.cc.Lehigh.EDU>

I normally use modules in an oo style, so I'm a little lost as to what my error
is in the following.  Can anyone help out?  My test.pl can't see the hash in
CASSENV.pl, it seems.

------------------------------------
package CASSENV;
use strict;

use Exporter ();
use vars  qw( @ISA @EXPORT );
@ISA    = qw( Exporter );
@EXPORT = qw( %CASSENV );

my %CASSENV = (
    COMMDIR => '/u/path/a',
    OTHERDIR => '/u/path/b'
);

1;
---------------------------------------
#!/usr/local/bin/perl -w
use diagnostics;
use strict;

use lib '/u/prl2/perl/modules';
use CASSENV;

print "My COMMDIR = ", $CASSENV{COMMDIR}, ".\n";
print "My OTHERDIR = $CASSENV{OTHERDIR}.\n";
----------------------------------------


Thanks,
Phil




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

Date: Fri, 12 Mar 1999 16:51:13 -0500
From: "Phil R Lawrence" <prlawrence@lehigh.edu>
Subject: Exporter question
Message-Id: <7cc30r$18sa@fidoii.cc.Lehigh.EDU>

I normally use modules in an oo style, so I'm a little lost as to what my error
is in the following.  Can anyone help out?  My test.pl can't see the hash in
CASSENV.pl, it seems.

------------------------------------
package CASSENV;
use strict;

use Exporter ();
use vars  qw( @ISA @EXPORT );
@ISA    = qw( Exporter );
@EXPORT = qw( %CASSENV );

my %CASSENV = (
    COMMDIR => '/u/path/a',
    OTHERDIR => '/u/path/b'
);

1;
---------------------------------------
#!/usr/local/bin/perl -w
use diagnostics;
use strict;

use lib '/u/prl2/perl/modules';
use CASSENV;

print "My COMMDIR = ", $CASSENV{COMMDIR}, ".\n";
print "My OTHERDIR = $CASSENV{OTHERDIR}.\n";
----------------------------------------


Thanks,
Phil




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

Date: Fri, 12 Mar 1999 15:04:23 -0600
From: John Fettig <jfettig@students.uiuc.edu>
Subject: Help searching text file
Message-Id: <Pine.SOL.3.96.990312145855.14924A-100000@ux7.cso.uiuc.edu>

I'm a newbie to perl, but I'm not sure if Perl is my problem.  I am trying
to search a text file using an online form generated by a Perl script.
The script basically calls the ms-dos command findstr on the string that
the user enters in, and searches the file I have specified.  Then I want
it to print the results from the search on the screen.  So far, I can't
get anything to show up.  Here's my code:

BEGIN {
                unshift(@INC);
        }

use CGI qw(:standard);

print header;
print start_html('Search the File'),
    h1('Search the File'),
    start_form,
    "Enter a string to search for: ",textfield('search'),
    submit,
    end_form,
    hr;

if (param()) {
    $searcher = param('search');
    $found = `findstr /I $searcher thefile.txt`;
     print 
        "Search Results for ",em($searcher),
        p,
        em($found),
        hr;
}

Now, I do get output from the "Search Results for ",em($searcher), line.
That works fine.  But I don't ever get any output from the $found.  My
best guess is that findstr doesn't return a string.  I've tried putting in
strings to search for, instead of $searcher, in my code but still no luck.
I've also tried just printing the findstr line.  Can anyone point out what
I am doing wrong?

                                             John Fettig
                                             University of Illinois



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

Date: Fri, 12 Mar 1999 15:05:08 -0500
From: Jay Glascoe <jglascoe@giss.nasa.gov>
To: du_bing@my-dejanews.com
Subject: Re: how to output in the desired order?
Message-Id: <36E97374.9BD43239@giss.nasa.gov>

[courtesy copy of post sent to cited author]

du_bing@my-dejanews.com wrote:
> 
> Hello there,
> 
> There is an array:
> 
> %array=(age,20,gender,female,name,guest);
> 
> I need to output each attribute/value pair in the following order:
> 
>              name: guest
>              age:  20
>              gender: female

my @preferred_key_order = qw(name age gender);
foreach my $key (@preferred_key_order) {
    my $val = $array{$key};
    # do something with qw($key $val)
}

> I tried coercing the order by running the following code:
> 
> %array=(name,guest,age,20,gender,female);

must you name your hash "array"?  It's quite confusing  ;)
You can't depend on a hash storing the key-value pairs in
any particular order.

these FAQs may be of interest:
perlfaq4: "How can I make my hash remember the order I put elements into it?"
perlfaq4: "How can I always keep my hash sorted?"

see also:
perldoc DB_File (look for "In Memory Databases")

	Jay Glascoe
-- 
	"Behold, I am not Gandalf the Grey, whom
	 you betrayed.  I am Gandalf the White,
	 who has returned from death.  You have
	 no colour now, and I cast you from the
	 order and from the Council."

	--Gandalf the White


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

Date: 12 Mar 1999 19:51:51 GMT
From: Jeff Stampes <stampes@xilinx.com>
Subject: Re: how to output in the desired order?
Message-Id: <7cbr8n$7p2@courier.xilinx.com>

du_bing@my-dejanews.com wrote:
: There is an array:

No there isn't...@array would be an array, %array is a hash
(for which 'array' is a silly name ;)

: %array=(age,20,gender,female,name,guest);

: I need to output each attribute/value pair in the following order:

Well it's not as easy as you want it to be.  There's no way to predict
what order the keys of a hash will come out when you iterate over them. 

perldoc perlfaq4:

 How can I make my hash remember the order I put elements
     into it?

     Use the Tie::IxHash from CPAN.
         use Tie::IxHash;
         tie(%myhash, Tie::IxHash);
         for ($i=0; $i<20; $i++) {
             $myhash{$i} = 2*$i;
         }
         @keys = keys %myhash;

This is one potential solution...but I imagine there's a simpler one for 
your needs...

HTHm
Jeff




-- 
Jeff Stampes -- Xilinx, Inc. -- Boulder, CO -- jeff.stampes@xilinx.com


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

Date: 12 Mar 1999 21:33:17 GMT
From: Jonesy <jonz@rmi.nospam.net>
Subject: Re: IDE for Perl
Message-Id: <7cc16t$5um$1@news1.rmi.net>

swamichandra@my-dejanews.com wrote:
: Is there any IDE (preferably graphical other than X-Emacs) for Perl
: programming.

And -- your usage -- would be on what platform?

Jonesy

-- 
Marvin L. Jones  jonz<AT>rmi.net
Gunnison, Colorado
294 days to go until the Year 2000 -- So what!
659 days to go until the 3rd Millennium of the C.E.


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

Date: 12 Mar 1999 22:07:40 GMT
From: fl_aggie@thepentagon.com (I R A Aggie)
Subject: Re: Learn the truth - In Dear Recruiter we establish exactly what a  recruiter does.
Message-Id: <slrn7ej4j2.701.fl_aggie@stat.fsu.edu>

On Fri, 12 Mar 1999 14:49:57 -0500, Elaine Ashton <elaine@cts.wustl.edu> wrote:

+ QualifiedConsultant wrote:
+ > This is the first in a series of documents I will be writing to educate the
+ > computer consulting industry as a whole.

+ This is a Perl newsgroup...we care because?...

Because some of us consult? I usually do it for my friends for free, or
margaritas -- but only _after_ I'm done consulting. If they have a grant,
or money for such work in contract, then we dicker about a price. And I
buy the first round... :)

+ somehow. Little of what we do on a daily basis actually _means_
+ something, anything, and will be forgotten in the depths of time. 

YM "we hope it will be forgotten in the depths of time"... :)

+ > I will except opinions from all QUALIFIED COMPUTER CONSULTANTS
+ 'qualified'? and that would be accept.

Heh. Maybe 'except' was the correct word...

James


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

Date: Fri, 12 Mar 1999 14:49:57 -0500
From: Elaine Ashton <elaine@cts.wustl.edu>
Subject: Re: Learn the truth - In Dear Recruiter we establish exactly what a  recruiter does.
Message-Id: <36E96FE5.948C4730@cts.wustl.edu>

QualifiedConsultant wrote:
 
> This is the first in a series of documents I will be writing to educate the
> computer consulting industry as a whole.

This is a Perl newsgroup...we care because?...

> The answer to the question "establish exactly what a recruiter does" is
> NOTHING.

We live in a world of intangibles. What does a stock broker do? All a
recruiter does is find people for a fee. Everyone has to make a living
somehow. Little of what we do on a daily basis actually _means_
something, anything, and will be forgotten in the depths of time. 

> But really are you actually doing anything?

Well...are you? I find petty bickering and childish behaviour such as
this quite unsavoury. Cast not the first stone unless you are the most
overworked underpaid person in the world, and, if you were, you wouldn't
have time nor care about it anyway.

> You may not like me but we are all entitled to our opinion and this is my
> opinion.

Such as it is....more like embittered ranting to me.

> CLIENTS AND COMPANY OWNERS: I charge between $35 and $50 to create MS Access
> databases as an independent consultant through telecommuting. How much are the
> consulting firms charging you? Please include your Human Resources employees
> free lunch we both paid for.

MS Access databases? A) this is an oxymoron B) takes little programming
effort. These are generally not the type of positions that recruiters
are really hot on the trail of these days anyway. 

> I will except opinions from all QUALIFIED COMPUTER CONSULTANTS. Everyone else
> will be ignored.

'qualified'? and that would be accept.

*grumble*

e.


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

Date: 12 Mar 1999 19:27:06 GMT
From: gward@cnri.reston.va.us (Greg Ward)
Subject: Re: Module to find duplicate files?
Message-Id: <7cbpqa$clr$1@ffx2nh5.news.uu.net>

[Philip's original request]
> how would I go about finding duplicate files under a certain directory?
> Is there a module to do that already? A quick glance through CPAN didn't
> bring up anything which sounded as if it would work.

[my response]
: Here's a script that does this.  It might take a few minutes to massage
: it into a module; most importantly, it should be changed to use the
: File::Compare module (standard with Perl 5.005) rather than exec'ing the
: Unix-specific "cmp" utility.  Left as an exercise for the reader.

[Tad's admonishment]
>    Except I think Philip meant to ask a different question.
> 
>    Judging by his code, I think he is trying to find duplicate
>    *filenames*, not duplicate files as he said.

Yeah, I read the post, thought, "Hey! I've already done that", and then
posted my script without reading his code.  And just think: the
answerers around are forever asking the questioners to post the code
that's giving them problems... somebody slap me with a wet noodle.  ;-)

Anyways, to answer Philip's original question (which I don't think
anyone has done yet): I assume you want a recursive directory scan to
find duplicate filenames.  This is a snap with the File::Find module;
try this on for size:

   use File::Find;

   my %seen;
   my %duplicates;

   sub check_file
   {
      if ($seen{$_})
      {
         if (exists $duplicates{$_})
         {
            push (@{$duplicates{$_}}, $File::Find::name);
         }
         else
         {
            $duplicates{$_} = [$seen{$_}, $File::Find::name];
         }
      }
      else
      {
         $seen{$_} = $File::Find::name;
      }
   }

   my $dir = $ARGV[0] or die "usage: $0 dir\n";
   find (\&check_file, $dir);

   if (%duplicates)
   {
      print "duplicates found:\n";
      foreach my $dupe (sort keys %duplicates)
      {
         print "$dupe:\n";
         foreach my $path (@{$duplicates{$dupe}})
         {
            print "  $path\n";
         }
      }
   }

Again, converting this to a module is left as an exercise for the
reader.  The code is quite obvious and straightforward, so I assume
nothing needs explaining.  It could probably be squashed into something
much tighter, but bye-bye readability...

For example, I run this on the Perl source tree (after building!), a the
output starts with:

duplicates found:
 .exists:
  ./lib/IPC/.exists
  ./lib/auto/DynaLoader/.exists
  ./lib/auto/B/.exists
  ./lib/auto/DB_File/.exists
   [...]
0README.txt:
  ./vms/ext/DCLsym/0README.txt
  ./vms/ext/Stdio/0README.txt
Asmdata.pm:
  ./ext/B/B/Asmdata.pm
  ./lib/B/Asmdata.pm
Assembler.pm:
  ./ext/B/B/Assembler.pm
  ./lib/B/Assembler.pm

Wow -- look at all the duplication!  ;-)

        Greg
-- 
Greg Ward - software developer                    gward@cnri.reston.va.us
Corporation for National Research Initiatives    
1895 Preston White Drive                      voice: +1-703-620-8990 x287
Reston, Virginia, USA  20191-5434               fax: +1-703-620-0913


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

Date: Fri, 12 Mar 1999 16:39:58 -0600
From: Greg Leibfried <gregl@netaffect.com>
Subject: Re: NET::FTP with ActiveState
Message-Id: <36E997BE.86EF7600@netaffect.com>

I've supposedly installed libnet module into my Activestate installation.
Unfortunately, I'm trying to get started on it, but I keep getting this script
that prompts me with questions when I try to run my TEST.PL program that I'm using
to learn with.
-------------------------------------------------------------------------
D:\dloads\source>test.pl

This script will prompt you to enter hostnames that can be used as
defaults for some of the modules in the libnet distribution.

To ensure that you do not enter an invalid hostname, I can perform a
lookup on each hostname you enter. If your internet connection is via
a dialup line then you may not want me to perform these lookups, as
it will require you to be on-line.

Do you want me to perform hostname lookups (y|n) ? [yes]
----------------snip snip snip--------------------------------------------

After answering all of these questions, a 'libnet.cfg' is written, but my program
doesn't execute.

Is my installation hosed?  Any suggestions?

Thanks!

 ...gregl




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

Date: Fri, 12 Mar 1999 21:47:31 GMT
From: vliaw@aa-net.com
Subject: perl installation need help
Message-Id: <7cc21f$4ag$1@nnrp1.dejanews.com>

Hi,

    A newbie question need your help.

     Symptom :

             Fail during installation (compilation).

  System : FreeBSD 3.1, newly installed with full source code and bin 
Version : Perl5.004_04	Steps :  rm config.sh  sh Configure  (using defaults)
 make  Result : 
--------------------------------------------------------------------------- 
DB_File.o: In function `btree_compare':  DB_File.o(.text+0x1a): undefined
reference to `Perl_stack_sp'  DB_File.o(.text+0x4f): undefined reference to
`Perl_push_scope'  DB_File.o(.text+0x55): undefined reference to `tmps_floor'
 DB_File.o(.text+0x5a): undefined reference to `Perl_save_int'	.  .  . 
---------------------------------------------------------------------------

             Most of the perl extensions face compilation errors like above.

  I follow INSTALL carefully and am sure that the perl directory is brand
new.

             Where am I doing wrong ?

             Thanks for help.

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


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

Date: Fri, 12 Mar 1999 16:41:45 -0500
From: ehpoole@ingress.com (Ethan H. Poole)
Subject: Re: Perl, IIS, writing to network drives
Message-Id: <RRu3fENb#GA.170@rejz.ij.net>

[Posted and Emailed]  In article <7cb8tj$c4d$1@nnrp1.dejanews.com>, 
ancics@cibc.ca says...
>
># For network drive
>open (FEEDBACK,
>">>\\\\servername\\sharename\\subdir\\ar$year-$yday.txt") || die
>"Couldn't create file; $!\n";

I haven't tried the UNC method, so I can't comment on this problem, but this 
next one will hurt pretty bad in about 9 months...

>
>print FEEDBACK "===Request - $month $mday,
>19$year====================\n\n";

No, No, No!  Do NOT prepend '19' to $year, ADD '1900' to $year, then use 
$year.  Your approach will yield the 'year' '19100' next year.  It is a bit 
silly (and potentially litigious) for us to be intentionally creating Y2K 
issues less than a year before 2000.

-- 
Ethan H. Poole              | Website Design and Hosting,
                            | CGI Programming (Perl & C)..
========Personal=========== | ============================
* ehpoole @ ingress . com * | --Interact2Day, Inc.--
                            | http://www.interact2day.com/



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

Date: 12 Mar 1999 14:09:30 -0700
From: Eric The Read <emschwar@mail.uccs.edu>
Subject: Re: Printing in Perl
Message-Id: <xkf1ziumn3p.fsf@valdemar.col.hp.com>

bart.lateur@skynet.be (Bart Lateur) writes:
> When a (potential) client's original data is fixed column width,
> formatted with spaces, I dare use a fixed pitch font for a quick demo.
> But even then, people complain about it.

Interestingly enough, *online* reading speeds are faster with monospaced
type, but hardcopy reads better with proportionally-spaced fonts.  Of
course, one could be using monospaced type because it's easier to OCR.
That's why the IRS' Form 1040PC looks so "primitive".

> It's ugly. It's primitive. It's amateuristic.

It's knowing your audience.

-=Eric


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

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

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