[7111] in Perl-Users-Digest

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

Perl-Users Digest, Issue: 736 Volume: 8

daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Tue Jul 15 17:07:23 1997

Date: Tue, 15 Jul 97 14:00:38 -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           Tue, 15 Jul 1997     Volume: 8 Number: 736

Today's topics:
     Re: 2 xor 0 -> 1 (??) (M.J.T. Guy)
     Re: adressing SCSI devices (Scott McMahan)
     Backtick Commands in Server Apps (Gary Chambers)
     Re: cause browser to go to a url <mortensi@idt.ntnu.no>
     Re: Dear Spammer!  We are NOT happy with you. (Richard Greene)
     Re: File permission in Perl (Clay Irving)
     GDBM errors/problems <mfiresto@racerx.speed.org>
     Re: help - need recursive chown() for big restore. <smalunjk@cisco.com>
     How to embed a gif source in perl script ?? <lmfhava@lmf.ericsson.se>
     Re: How to round numbers in perl (Clay Irving)
     Re: How to round numbers in perl <zenin@best.com>
     Re: How to round numbers in perl (Brand and Karina Hilton)
     Is there a tool similar to lex and awk combined <antony@exit109.com>
     Re: Namespace warning in Perl5.004_01 (Charles DeRykus)
     Re: Obtaining full path for a command quickly (Matthew D. Healy)
     Re: output with Unix commands <rootbeer@teleport.com>
     Re: Perl Editors <merlyn@stonehenge.com>
     Re: Perl Editors (Paul Faulstich)
     PERL-C++ <yreptak@cyberphilia.com>
     Re: Read a hash within a hash <mortensi@idt.ntnu.no>
     Re: Read a hash within a hash (M.J.T. Guy)
     Re: Sorting multi-dimensonal array? <sfairey@adc.metrica.co.uk>
     Re: This is a stupid question, but ... <rootbeer@teleport.com>
     what's better?,, what's the difference? <perlprogrammer@hotmail.com>
     Re: what's better?,, what's the difference? <rootbeer@teleport.com>
     Re: what's going on here?? (Tim Gim Yee)
     Re: while.problem (Tim Gim Yee)
     Digest Administrivia (Last modified: 8 Mar 97) (Perl-Users-Digest Admin)

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

Date: 15 Jul 1997 16:36:18 GMT
From: mjtg@cus.cam.ac.uk (M.J.T. Guy)
Subject: Re: 2 xor 0 -> 1 (??)
Message-Id: <5qg8u2$cm7@lyra.csx.cam.ac.uk>


Grant Reaber <greaber@joker.cme.nist.gov> wrote:
>How come "2 or 0" and "0 or 2" evaluate to 2, but "2 xor 0" and "0 xor
>2" evaluate to "1"?  In other words, how come "and" and "or" both
>return interesting true values, but "xor" just returns boring old 1?

Because there isn't a valid analogy between the cases.   "and" and "or"
are "short cut" operators which only evaluate as many of their arguments
as they need.    "xor" always depends on all its arguments, so there is
no sensible meaning to returning a particular argument.

There isn't an ^^ operator for similar reasons.


Mike Guy


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

Date: 14 Jul 1997 15:47:41 GMT
From: scott@lighthouse.softbase.com (Scott McMahan)
Subject: Re: adressing SCSI devices
Message-Id: <5qdhmt$gcv$1@mainsrv.main.nc.us>

L. Baltus (lbaltus@declanet.nl) wrote:
: I am not very familiar with perl so bear with me.

: I would like to read, write set scsi devices so I can
: rewind, set blocklength, set density,(of course write
: and read data) etc. from/to SCSI devices like DAT, EXABYTE
: and 1/2" tapes.
: Can you do that (how?) with perl? Do I need specific modules.
: BTW I am using SCO-Unix 3.2v4.2 and 3.2v5.0 as my perl platform

Wouldn't it be easier to use the operating-system supplied
device files for this kind of thing?

Anyway, I don't think Perl is the right language for this
job, since these kind of device drivers have to be compiled
into the kernel.

Scott



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

Date: 14 Jul 97 01:28:03 GMT
From: geecee@netquarters.net (Gary Chambers)
Subject: Backtick Commands in Server Apps
Message-Id: <slrn5sj068.kv1.geecee@burbot.netquarters.net>

I'm following the example on page 349 of the Camel book to create a
server utility that sends the load averages of the machine upon which
it's running.

My problem is that I can't use the backticks or qx() features to get
the program to grab the results.  What must I do to accomplish this? 
I'm using the following command line (also right out of the Camel book)
in my script:

my ($one, $five, $fifteen) = (`uptime` =~ /(\d+\.\d+)/g);

The errors I receive are:

Use of uninitialized value at /home/geecee/bin/loadd line 32.
Use of uninitialized value at /home/geecee/bin/loadd line 32.
Unable to create sub named "" at /home/geecee/bin/loadd line 32.

Any help will be greatly appreciated...

-- 
GeeCee/NQ

//------------------------------------------
// Gary Chambers <geecee@netquarters.net>
// NetQuarters, Inc., Brunswick, ME 04011
// 207-798-8400 (Voice) 207-798-8403 (Fax)
// Midcoast Maine's Internet Provider
//------------------------------------------


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

Date: 15 Jul 1997 16:06:03 GMT
From: Morten Simonsen <mortensi@idt.ntnu.no>
Subject: Re: cause browser to go to a url
Message-Id: <5qg75b$bsr@due.unit.no>

: : >What command do I 'print' to a web browser to get it to go to a
: : >specified URL?

: The only way you can do this is to include some JavaScript to the page
: you're outputting that plays with the window.location setting. There's
: no non-scripting way to make a browser do anything.

Hmm, I don't know if this is right. I have used this statement myself:
---------------------------
print "Location: URL \n\n";
---------------------------
and if I interpret you correctly, this is what you want. 

Morten Simonsen



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

Date: Tue, 15 Jul 1997 01:28:52 GMT
From: r.greene@ieee.org (Richard Greene)
Subject: Re: Dear Spammer!  We are NOT happy with you.
Message-Id: <5qejok$3a0i6_002@world1.bellatlantic.net>


In article <aca97922.22ee9d2aYAT1@wsb39.hiu.ac.jp>, aca97922@hiu.ac.jp wrote:
>
>In article <33C6685B.3338@sungardams.com>
>        David Director <ddirecto@sungardams.com> writes:
>
> >
> >Richard Greene wrote:
> >> 
> >> There is a WEB site run by the E-MAIL Marketing Council. They "claim" that
> if
> >> you register with them to have your name removed from mailings by their
> >> "spammer" members they will pass it to them. Their main interest is to stop
> >> pending congressional legislation which could potentially put them out of
> >> business. Their address is
> >>                           http://www.jemmc.org
> >
> >I just tried to get to that web site and got a 404 message, "hostname
> >unknown".
> >
> >-- David
Sorry David ... one day I'll learn how to read ... the address is:
                                        http://www.iemmc.org.

Richard Greene

--------------------------------------------------------------------
       _______      _______                                       ?
      / _____ \    / _____ \          AEROSPACE DESIGN CONCEPTS   ^
     / /     \ \  / /     \ \            MEMORIES INTO SPACE     ^
  __/ /__    | |__| |    __\ \__             PLVS VLTRA . . . . ^    
 /__| |_ \   /      \   / _| |__\          
    | | | | | _    _ | | | | |             THE RAMMAN 
    | |_| | | \\  // | | |_| |              Richard Greene  
     \___/   \ "  " /   \___/                ULSI MICRO-CHIP & MEMORY DESIGNS 
              |    |                          INTELLECTUAL PROPERTY EXPERT 
              | oo |                           E-MAIL:R.GREENE@IEEE.ORG 
               \__/                             VINCENTOWN, NJ 

                                                                


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

Date: 15 Jul 1997 09:00:21 -0400
From: clay@panix.com (Clay Irving)
Subject: Re: File permission in Perl
Message-Id: <5qfs95$kl3@panix.com>

In <33CA53F9.54A79065@clockwork.net> Dan Brian <dan@clockwork.net> writes:

>Does someone know how to read a file owner in Perl? I am trying to
>compare the permissions of two files to one another. How can this be
>done? The executable is run as root.

  #!/usr/local/bin/perl5.003 -w
  
  $filename = "foo.pl";
  
  $owner = getpwuid((stat($filename))[4]);
  print "The owner of $filename is $owner\n";
  
outputs:

  The owner of foo.pl is clay

-- 
Clay Irving                                        See the happy moron,
clay@panix.com                                     He doesn't give a damn,
http://www.panix.com/~clay                         I wish I were a moron,
                                                   My God! Perhaps I am!


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

Date: 15 Jul 1997 20:02:10 GMT
From: Michael Firestone <mfiresto@racerx.speed.org>
Subject: GDBM errors/problems
Message-Id: <5qgl02$be6@camel12.mindspring.com>

I am attempting to create a GDBM database, using the following code:
 
    #!/usr/local/bin/perl -w

    use strict;
    use GDBM_File;

    my ( $ref, %hash, $status );

    $ref = tie %hash, 'GDBM_File', "person.gdbm", &GDBM_WRCREAT, 0644;
    die "Couldn't create file:$!\n" unless ( $ref );

    $status = $ref->put( "Bob", "Good friend" );
    print "Status = $status\n";

Please note I have used -w.  It compiles just fine - it almost too simple
not to compile.

When I actually run it, I get this error message:
  Can't locate auto/GDBM_File/put.al in @INC (@INC contains:
  /usr/local/lib/perl5/i386-freebsd/5.00401 /usr/local/lib/perl5
  /usr/local/lib/perl5/site_perl/i386-freebsd /usr/local/lib/perl5/site_perl
  .) at bob.pl line 11

Which is correct, because I cannot find that file anywhere in
/usr/local/lib/perl5.  

The thing that is bothering me is that this is a fresh build/install of
perl 5.004_01 - I just did the build an hour ago.  I have gdbm installed,
and Configure found it.  Which implies to me that nothing has been
accidently deleted - I haven't had time to delete anything.

perl -V reports:
Summary of my perl5 (5.0 patchlevel 4 subversion 1) configuration:
  Platform:
    osname=freebsd, osvers=3.0-970522-snap, archname=i386-freebsd
    uname='freebsd racerx.speed.org 3.0-970522-snap freebsd 3.0-970522-snap
#0: fri jul 4 16:21:16 edt 1997
root@racerx.speed.org:usrsrcsyscompileracerx i386 '
    hint=recommended, useposix=true, d_sigaction=define
    bincompat3=n useperlio= d_sfio=
  Compiler:
    cc='cc', optimize='-O', gccversion=2.7.2.1
    cppflags='-I/usr/local/include'
    ccflags ='-I/usr/local/include'
    stdchar='char', d_stdstdio=, usevfork=true
    voidflags=15, castflags=0, d_casti32=, d_castneg=define
    intsize=4, alignbytes=4, usemymalloc=y, randbits=31
  Linker and Libraries:
    ld='ld', ldflags =' -L/usr/local/lib'
    libpth=/usr/local/lib /usr/lib
    libs=-lgdbm -lm -lc -lcrypt
    libc=/usr/lib/libc.so.3.0, so=so
    useshrplib=false, libperl=libperl.a
  Dynamic Linking:
    dlsrc=dl_dlopen.xs, dlext=so, d_dlsymun=define,
ccdlflags='-DDEBUGGING_MSTATS -DTWO_POT_OPTIMIZE -DPACK_MALLOC'
    cccdlflags='-DPIC -fpic', lddlflags='-Bshareable  -L/usr/local/lib'


Characteristics of this binary (from libperl): 
  Built under freebsd
  Compiled at Jul 15 1997 15:13:35
  @INC:
    /usr/local/lib/perl5/i386-freebsd/5.00401
    /usr/local/lib/perl5
    /usr/local/lib/perl5/site_perl/i386-freebsd
    /usr/local/lib/perl5/site_perl
    .


What am I missing, doing wrong, etc?  
Thanks for any help.  Email if you want, but replying to the news group
means DejaNews can archive this.


-- 
Mik Firestone  mfiresto@mindspring.com
Marriage is what happens when blackmail is no longer effective.
  -- My Wife


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

Date: Tue, 15 Jul 1997 10:50:19 -0700
From: Sanjay Malunjkar <smalunjk@cisco.com>
To: Fil Krohnengold <fil@amnh.org>
Subject: Re: help - need recursive chown() for big restore.
Message-Id: <33CBB85B.8551B77A@cisco.com>

Fil Krohnengold wrote:

> Hello, all.
>
> .  So anyway, I need
> to come up with some way to restore the owner and group permissions
> to the user directories.  Somewhere around 3am I came up with this:
>
 I f I understand ur problem alright then, You might just want  to say :

blah
blah

if (-d $name)
{
system('/bin/chown','-R',"$uid","$name");
system('/bin/chgrp','-R',"$gid","$name");
}

I have not tested this code,but when I have to do this at command line,
I normally
use -R flag and let the OS do the work for me. Also note that the path
to chown and
chgrp may be different on your system.

Once again test the code before using it. Good luck.



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

Date: Tue, 15 Jul 1997 08:48:48 +0300
From: Harri Vainio <lmfhava@lmf.ericsson.se>
Subject: How to embed a gif source in perl script ??
Message-Id: <33CB0F40.957E2893@lmf.ericsson.se>


Hey!

Got this job from my boss, and I'm a bit puzzled.

I have to do a perl script (been there) that creates a page (done that)
so that the single image on the page would be embedded in the perl
source (never done that).

My idea would be to include the hex code of the image(Gif) in the perl
source, but how to tell this to the browser ?? I would be filled with
thanx to anyone with any information to my problem...

       Harri Vainio
       Ericsson LMF/T/FI, Finland
       lmfhava@lmf.ericsson.se



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

Date: 15 Jul 1997 08:46:23 -0400
From: clay@panix.com (Clay Irving)
Subject: Re: How to round numbers in perl
Message-Id: <5qfrev$ieh@panix.com>

In <33CA2300.1701@nortel.ca> James Phillips <phillips@nortel.ca> writes:

>Hi Folks,

>Does anyone know how to round numbers in perl?

>If you do please post.



>	#We want x to be 62 and y to be 61 on the screen

>	$x = 61.7;
>	$y = 61.2;

>	print "$x, $y\n";

http://www.perl.org/CPAN/doc/manual/html/pod/perlfaq4/Does_perl_have_a_round_function_.html

-- 
Clay Irving                                        See the happy moron,
clay@panix.com                                     He doesn't give a damn,
http://www.panix.com/~clay                         I wish I were a moron,
                                                   My God! Perhaps I am!


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

Date: 15 Jul 1997 14:30:41 GMT
From: Zenin <zenin@best.com>
Subject: Re: How to round numbers in perl
Message-Id: <5qg1ih$j0j$9@nntp2.ba.best.com>

amit kothari <amit@csd.sgi.com> wrote:
> James Phillips wrote:
> > Does anyone know how to round numbers in perl?
	>snip<
> sub round{
>         my($l_arg1)=@_;
>         return 0 if ($l_arg1 == 0);
>         my($l_num) = 0;
>         $l_num = int($l_arg1 + 1);
>         $l_num = $l_num -1 if ($l_num - $l_arg1 > 0.5);
>         $l_num;
> }
	>snip<

	Boy, you work to hard...

	$Float      = 1.2;
	$RoundInt   = int ($Float + 0.5);

	Anyway, as has been mentioned, this is in the FAQ.  READ IT!
	http://www.perl.org/CPAN/doc/manual/html/pod/perlfaq4/Does_perl_have_a_round_function_.html
-- 
-Zenin
 zenin@best.com


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

Date: Tue, 15 Jul 1997 19:08:31 GMT
From: bkhilton@netcom.com (Brand and Karina Hilton)
Subject: Re: How to round numbers in perl
Message-Id: <bkhiltonEDDJu8.Ky0@netcom.com>

In article <5qg7l7$bhn@lyra.csx.cam.ac.uk>,
M.J.T. Guy <mjtg@cus.cam.ac.uk> wrote:
>
>In article <5qg1ih$j0j$9@nntp2.ba.best.com>, Zenin  <zenin@best.com> wrote:
>>
>>	Boy, you work to hard...
>>
>>	$Float      = 1.2;
>>	$RoundInt   = int ($Float + 0.5);
>
>And you work inaccurately.   Think about negative numbers.

Unfortunately, your solution doesn't do much better for negative numbers.
(e.g., round -1.7 returns -1 and round -2.7 returns -2)
 
Like the FAQ says, printf and sprintf are best.  Specifically: 

   sprintf "%1.0f", $myfloat


	Brand


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

Date: Tue, 15 Jul 1997 00:59:11 -0400
From: Antony & Minimol <antony@exit109.com>
Subject: Is there a tool similar to lex and awk combined
Message-Id: <33CB039F.302D27D7@exit109.com>

Hi all
	I am looking for a tool which is similar to lex with interpreting
capability of awk or perl. This tool should treat input as stream of
 characters not as
stream of records. When a pattern matches, it should perform some
action.
There are lot of such patterns and I do not have the flexibility of
compiling
 otherwise I could have used lex.
Input is only a stream of characters without any record or field
separators.
If this can be done with awk or perl without doing much fuss,
please let me know. If there is some other tool, please let me know that
also.

Thanks in Advance
Antony P. Joseph


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

Date: Tue, 15 Jul 1997 17:30:39 GMT
From: ced@bcstec.ca.boeing.com (Charles DeRykus)
Subject: Re: Namespace warning in Perl5.004_01
Message-Id: <EDDFB4.76G@bcstec.ca.boeing.com>


In article <33CAE724.D3C1E1BB@ml.com>, Anatol Filin  <anatol@ml.com> wrote:
 > Hello,
 > 
 > I got this warning
 > 
 >     "my" variable $PACK_NAME masks earlier declaration in same scope at
 > twarning.pl line 7.
 > 
 > in Perl5.004_01 on the following code
 > 
 >     #! ../perl
 > 
 >     package One;
 >     my $PACKAGE_NAME = "One";
 > 
 >     package Two;
 >     my $PACKAGE_NAME = "Two";
 > 
 > 
      From the blue Camel re: "my" on pg 189: "This operator declares
      one or more private variables to exist only within the inner-
      most enclosing block, subroutine, eval, or file."

      So "my" is not respecting of package boundaries but only of the
      constraints mentioned above. If you "my" the same variable   
      name within the same scope, i.e, "innermost enclosing block, 
      etc", the initial assignment will get "masked" (i.e, clobbered). 


HTH,
--
Charles DeRykus
ced@carios2.ca.boeing.com
      


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

Date: Tue, 15 Jul 1997 15:30:22 -0500
From: Matthew.Healy@yale.edu (Matthew D. Healy)
Subject: Re: Obtaining full path for a command quickly
Message-Id: <Matthew.Healy-1507971530220001@pudding.med.yale.edu>

In article <5q3f9a$qur@marple.umd.edu>, cwt02@csc.umd.edu (CMSC 430) wrote:

>         $full_path_of_command = chop(`which $command_name`);
> 
> Is there an easy way to do this?  Or if not, can someone point me to
> some code which can do this (probably by explicitly looking in all

Why not take a look at the code for 'which' itself:

(61)% which which
/usr/ucb/which
(62)% file /usr/ucb/which
/usr/ucb/which: executable c-shell script
(63)%

So, use 'which which' to find out where 'which' lives on your system
and then look at its code.  That should give you some ideas...
--------
Matthew.Healy@yale.edu           http://ycmi.med.yale.edu/~healy/
As of 09 Jul 1997, only 905 days until Y2K....
Any person with a phone line can become a town crier with a voice
that resonates farther than it could from any soapbox.
--The US Supreme Court, overturning the Communications Decency Act


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

Date: Tue, 15 Jul 1997 08:21:00 -0700
From: Tom Phoenix <rootbeer@teleport.com>
To: Jack Coursey <jcoursey@sed.nist.gov>
Subject: Re: output with Unix commands
Message-Id: <Pine.GSO.3.96.970715082013.20153Q-100000@kelly.teleport.com>

On Tue, 15 Jul 1997, Jack Coursey wrote:

> I would like to print the output to a file instead of to the screen.

See the description of open() in the perlfunc(1) manpage. Hope this helps!

-- 
Tom Phoenix           http://www.teleport.com/~rootbeer/
rootbeer@teleport.com  PGP   Skribu al mi per Esperanto!
Randal Schwartz Case:  http://www.rahul.net/jeffrey/ovs/



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

Date: 15 Jul 1997 07:18:10 -0700
From: Randal Schwartz <merlyn@stonehenge.com>
To: perrella andrew c <perrella@ehsn8.cen.uiuc.edu>
Subject: Re: Perl Editors
Message-Id: <8cvi2cjt5p.fsf@gadget.cscaper.com>

>>>>> "perrella" == perrella andrew c <perrella@ehsn8.cen.uiuc.edu> writes:

perrella> 	Does anybody know of any programming editors for perl.
perrella> I am just looking for simple text editor that colors codes
perrella> important stuff like sub, {, $, @, etc..

Gnu Emacs "cperl-mode" does a nice job at that... see CPAN/id/ILYAZ/*.

print "Just another Perl hacker," # but not what the media calls "hacker!" :-)
## legal fund: $20,495.69 collected, $182,159.85 spent; just 413 more days
## before I go to *prison* for 90 days; email fund@stonehenge.com for details

-- 
Name: Randal L. Schwartz / Stonehenge Consulting Services (503)777-0095
Keywords: Perl training, UNIX[tm] consulting, video production, skiing, flying
Email: <merlyn@stonehenge.com> Snail: (Call) PGP-Key: (finger merlyn@ora.com)
Web: <A HREF="http://www.stonehenge.com/merlyn/">My Home Page!</A>
Quote: "I'm telling you, if I could have five lines in my .sig, I would!" -- me


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

Date: 15 Jul 1997 20:15:24 GMT
From: psf@gwi.net (Paul Faulstich)
Subject: Re: Perl Editors
Message-Id: <5qglos$n31@noc1.gwi.net>

also, Visual SlickEdit (Win95 & most UNIX flavors) does a nice job and has
a GUI.

dRandal Schwartz (merlyn@stonehenge.com) wrote:
: >>>>> "perrella" == perrella andrew c <perrella@ehsn8.cen.uiuc.edu> writes:
: 
: perrella> 	Does anybody know of any programming editors for perl.
: perrella> I am just looking for simple text editor that colors codes
: perrella> important stuff like sub, {, $, @, etc..
: 
: Gnu Emacs "cperl-mode" does a nice job at that... see CPAN/id/ILYAZ/*.
--
Paul Faulstich
psf@gwi.net 
http://www.gwi.net/~psf  


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

Date: Tue, 15 Jul 1997 13:43:32 -0400
From: Yuri Reptak <yreptak@cyberphilia.com>
Subject: PERL-C++
Message-Id: <33CBB6C4.7E7F@cyberphilia.com>

I would like to include some c++ subroutine into my perl script on
WINDOWSNT (not UNIX). May someone to write some instruction how to do
this?
I read a documentationC:/Perl/docs/Perl-Win32/win32xs.html,
but I did not understand everything and my program does not run.

Where can I get extern.h, perl.h
Yuri


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

Date: 15 Jul 1997 17:09:43 GMT
From: Morten Simonsen <mortensi@idt.ntnu.no>
Subject: Re: Read a hash within a hash
Message-Id: <5qgasn$bsr@due.unit.no>

M.J.T. Guy <mjtg@cus.cam.ac.uk> wrote:
: Morten Simonsen  <mortensi@idt.ntnu.no> wrote:
: >%hash1 = (); %hash2=();
: >
: >$hash1{'test1'} = \$hash2;
: >$hash2{'test2'} = "test3";
: >
: >How can I easily print out the content of $hash2? 

: That doesn't look right.   \$hash2 is a reference to the scalar $hash2.
: You want a reference to the hash %hash2, i.e.  \%hash2.

I did even found out how to print this thing out. Here
is the newwritten program, and the answer, if anyone care:

%hash1 = (); %hash2=();
$hash2{'test2'} = "test3"; # Switched these two lines, I think that is
$hash1{'test1'} = \%hash2; # a bit safer. Changed $ to %

print "HASH: ${$hash1{'test1'}}{'test2'}\n";

Thanks a lot to Mike and myself:)

Morten Simonsen


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

Date: 15 Jul 1997 16:55:04 GMT
From: mjtg@cus.cam.ac.uk (M.J.T. Guy)
Subject: Re: Read a hash within a hash
Message-Id: <5qga18$dda@lyra.csx.cam.ac.uk>

Morten Simonsen  <mortensi@idt.ntnu.no> wrote:
>%hash1 = (); %hash2=();
>
>$hash1{'test1'} = \$hash2;
>$hash2{'test2'} = "test3";
>
>How can I easily print out the content of $hash2? 

That doesn't look right.   \$hash2 is a reference to the scalar $hash2.
You want a reference to the hash %hash2, i.e.  \%hash2.


Mike Guy


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

Date: Tue, 15 Jul 1997 16:16:28 +0100
From: Simon Fairey <sfairey@adc.metrica.co.uk>
To: hulda@rhi.hi.is
Subject: Re: Sorting multi-dimensonal array?
Message-Id: <33CB944C.E5DC2326@adc.metrica.co.uk>

Hulda Birna Helgadottir wrote:

> Few facts:
> I have a file wich looks like this:
> field1\tfield2\tfield3\n
> field1\tfield2\tfield3\n
> etc..
> Typical file-in routine:
> while (<IN>)
> {
>         s/[\r\n]//g;

You really want to be using chomp() here unless you are expecting
newlines in the middle of a line.

>         @offarray = split(/\t/);
>         for ($j=0; $j<=$#offarray; $j++) {
>                 $off_array{$ocount++,$j}=$offarray[$j];
>         }
> }
> Can I sort this array in a simple way on, say, field2, either before
> or after I put it into the 2-dimensional array?
> Hints? Example?
>
> H.

If my understanding of this is correct you are not actually creating a
2D array, rather you are creating a single hash where the keys are
strings of the form '1,2' '2,3' etc.Now the question is what do you
actually want?
I suggest you look in the perllol man page, you will find comprehensive
examples of how to create and manipulate lists of lists and there are
sections in the perl FAQ at www.perl.com which have details on how to
sort such things. If you are still having problems after reading these
then post another message (there is always more than enough help
available once you have a clearly defined problem).

Simon



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

Date: Tue, 15 Jul 1997 11:52:43 -0700
From: Tom Phoenix <rootbeer@teleport.com>
To: TColl78218 <tcoll78218@aol.com>
Subject: Re: This is a stupid question, but ...
Message-Id: <Pine.GSO.3.96.970715115141.7560D-100000@kelly.teleport.com>


On 15 Jul 1997, TColl78218 wrote:

> How do I call the script so that it executes before they get to the
> page?

See your server's documentation, since it's the server which will call
your program. If you still have questions, a server newsgroup (or its FAQ)
will be able to help. Good luck! 

-- 
Tom Phoenix           http://www.teleport.com/~rootbeer/
rootbeer@teleport.com  PGP   Skribu al mi per Esperanto!
Randal Schwartz Case:  http://www.rahul.net/jeffrey/ovs/



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

Date: Tue, 15 Jul 1997 04:00:04 -0700
From: perl guy <perlprogrammer@hotmail.com>
Subject: what's better?,, what's the difference?
Message-Id: <33CB575B.47DC@hotmail.com>

## Instead of typing this...
if ($something ne "")

##Couldn't I just type this?.. 
if ($something)

# but then if so, what would the best idea for 
if ($something eq "")

#what would be equal to nothing? I'm dealing with numbers and
characters, etc.. 

# Also, What's better? Rather, what's the difference in this?         

$msg_to_read = $user_last_read + 1;
$msg_to_read -= $how_many_old;
if ($msg_to_read < 1)
   {
    $msg_to_read = 1;
   }
if ($high_message >= $msg_to_read)
    {
     for ($x = $high_message; $x >= $msg_to_read; $x--)
      {
########### this...
        $x = sprintf("%6d",$x);
        $x =~ tr/+/ /;
########### Or this ...
        $x = sprintf("%6d",$x);
        $x =~ tr/ /0/;
#### what's better? what's the differnce?..
        if (-e "$dir/$x.msg")
          {
           open(MSG,"$dir/$x.msg") |


if ($function ne "")
   { 
    $message eq "EVERYONE";
    $high_number = &GetHighMessageNumber;
    $high_number++; 
###This...
    $high_number = sprintf("%6d",$high_number);
    $high_number =~ tr/ /0/;
#####Or this....
    $high_number = sprintf("%6d",$high_number);
    $high_number =~ tr/+/ /;
## Is there any differnce?
    open(FILE, ">$path/$file.msg");
    print FILE 

can I change the order of messages with this?.. I.e., from newest at the
bottom and oldest at the top? This order makes sense to me, to read from
oldest to newest info, yet not many people do that?.. 

Anyway, I assume the above doesn't make any difference at all?.


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

Date: Tue, 15 Jul 1997 07:36:00 -0700
From: Tom Phoenix <rootbeer@teleport.com>
To: perl guy <perlprogrammer@hotmail.com>
Subject: Re: what's better?,, what's the difference?
Message-Id: <Pine.GSO.3.96.970715073042.20153J-100000@kelly.teleport.com>

On Tue, 15 Jul 1997, perl guy wrote:

> ## Instead of typing this...
> if ($something ne "")
> 
> ##Couldn't I just type this?.. 
> if ($something)

In general, no. Consider that $something might be the string '0', which
would be true in the first case and false in the second. 

> ########### this...
>         $x = sprintf("%6d",$x);
>         $x =~ tr/+/ /;

Maybe I'm missing something, but I don't see what that's doing. On my
system, at least, that format string won't produce any plus signs.

> ########### Or this ...
>         $x = sprintf("%6d",$x);
>         $x =~ tr/ /0/;

This code is simpler, and accomplishes the same thing on my system. Could
this be what you want? 

    $x = sprintf "%06d", $x;

Hope this helps!

-- 
Tom Phoenix           http://www.teleport.com/~rootbeer/
rootbeer@teleport.com  PGP   Skribu al mi per Esperanto!
Randal Schwartz Case:  http://www.rahul.net/jeffrey/ovs/



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

Date: Sat, 12 Jul 1997 03:58:15 GMT
From: tgy@chocobo.org (Tim Gim Yee)
Subject: Re: what's going on here??
Message-Id: <33c6ff06.107483063@news.oz.net>

On Sat, 12 Jul 1997 02:09:48 GMT, FANNGMAIL@prodigy.net (Fan Ng)
wrote:

>Hi all:
>
>I saw this in a book and I realy don't what's this means?
>who can explain to me, thank you.
>$/ = " ";      

Perhaps '$/ = "";' which sets the input record separator to 'paragraph
mode.'  See perlvar in the documentation.

>while ($paragraph=<>)     #Here I can't see any relate with first line.

Changing $/ affects how <> will read in data.

>{ while ($paragraph =~ /[a-z] [' ")] * [.!?] + [' " )] * \s/g)  {             
>$sevtences++;

$sentences++;

>   }
>}
>print "$sentences\n";
>
>fanng@prodigy.net

--
tgy@chocobo.org


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

Date: Sat, 12 Jul 1997 03:49:08 GMT
From: tgy@chocobo.org (Tim Gim Yee)
Subject: Re: while.problem
Message-Id: <33c6fc9e.106866803@news.oz.net>

On Sat, 12 Jul 1997 02:07:27 GMT, FANNGMAIL@prodigy.net (Fan Ng)
wrote:

>Hi all:
>
>I don't know what is while(<>) means.
>I know that while(1), while will be loop.
>and if while(0) wouldn't loop.
>so what's <> means.

<> is the same as <STDIN>.  Since it's the only thing in the while
condition, it automatically assigns to $_.  These are equivalent:

print while $_ = <STDIN>;
print while <STDIN>;
print while <>;

--
tgy@chocobo.org


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

Date: 8 Mar 97 21:33:47 GMT (Last modified)
From: Perl-Request@ruby.oce.orst.edu (Perl-Users-Digest Admin) 
Subject: Digest Administrivia (Last modified: 8 Mar 97)
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.  

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

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