[9391] in Perl-Users-Digest

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

Perl-Users Digest, Issue: 2985 Volume: 8

daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Thu Jun 25 21:07:54 1998

Date: Thu, 25 Jun 98 18:00:40 -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, 25 Jun 1998     Volume: 8 Number: 2985

Today's topics:
        $size = `du -s $directory' is doubling value when runni <admin@bwsd.com>
    Re: $size = `du -s $directory' is doubling value when r <jdf@pobox.com>
    Re: ? Moderated clpm ? (Mark-Jason Dominus)
        [Q] Hash set in recursion, lost in caller kissel@kissel.spicerack.ibm.com
    Re: [Q] Hash set in recursion, lost in caller <jdf@pobox.com>
        ANNOUNCE: Net::Hotline 0.50 (John Siracusa)
    Re: Can Anyone help? Grehom@my-dejanews.com
    Re: Can someone explain the arrow operator ? <rra@stanford.edu>
    Re: CGI.pm VS. The World! <mattj@spaatz.org>
    Re: CGI.pm VS. The World! (I R A Aggie)
    Re: challenge: put search into an array Grehom@my-dejanews.com
    Re: cookie and redirect <jdf@pobox.com>
    Re: Date calculation formula needed <romeyde@mc0115.mcclellan.af.mil>
    Re: efficient director watching <rra@stanford.edu>
    Re: Hiding the Perl source (Abigail)
    Re: How do I get a system call to write it's informatio <rra@stanford.edu>
    Re: how do I parse a certain structured text? <jdf@pobox.com>
    Re: How do I pass more than one array as a parameter in (Thomas Wernitz)
    Re: How to set system time using Perl?? <rra@stanford.edu>
    Re: if statement, legal? (Andre L.)
    Re: if statement, legal? <jdf@pobox.com>
    Re: if statement, legal? <rra@stanford.edu>
    Re: Installing Perl on Windows95- Problem with Install. <jlguru@cris.com>
        iterating through files and subdirectories (Amanda Silver)
    Re: iterating through files and subdirectories (Matt Knecht)
    Re: Linked list <jdf@pobox.com>
    Re: MacPerl and odd filenames (Bob MacDowell)
        mastering regular expressions (Amanda Silver)
    Re: mastering regular expressions <rra@stanford.edu>
    Re: mastering regular expressions (I R A Aggie)
    Re: msqlperl and windows 95 (Jonathan Stowe)
    Re: Perl and Delphi <rra@stanford.edu>
        Digest Administrivia (Last modified: 8 Mar 97) (Perl-Users-Digest Admin)

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

Date: Thu, 25 Jun 1998 20:54:03 -0500
From: Beck Web Servers & Design <admin@bwsd.com>
Subject: $size = `du -s $directory' is doubling value when running from the web
Message-Id: <3592FF3B.2BB3B9BB@bwsd.com>

Here's what I have now
-------------------------
#!/usr/local/bin/perl

$directory = "/usr/local/etc/httpd/htdocs/dir";
$size = `du -s $directory`;

print "Content-type: text/plain\n\n";
print "$size\n\n";
----------------------
The output when run from the web is:
24062   /usr/local/etc/httpd/htdocs/dir

The outup when run from the shell is:
12031   /usr/local/etc/httpd/htdocs/dir

The shell value for the bytes used by the directory structure
"/usr/local/etc/httpd/htdocs/dir" is correct.

Why is the value doubling on the web run, and how can I correct it?

--- 
Eric Beck, BWSD
http://web-design.net/index.shtml
mailto:erbeck@web-design.net
Phone: 905 436 6814   Fax:  905 725 4023
============================================================
Internet Call Manager - Get Your Calls While Online!
http://internetcallmanager/agents/bwsd
============================================================
BECK WEB SERVERS & DESIGN - WHERE SUPPORT AND SERVICE ARE #1
============================================================


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

Date: 25 Jun 1998 20:58:49 -0500
From: Jonathan Feinberg <jdf@pobox.com>
To: admin@bwsd.com
Subject: Re: $size = `du -s $directory' is doubling value when running from the web
Message-Id: <g1gsx6sm.fsf@mailhost.panix.com>

Beck Web Servers & Design <admin@bwsd.com> writes:

> The output when run from the web is:
> 24062   /usr/local/etc/httpd/htdocs/dir
> 
> The outup when run from the shell is:
> 12031   /usr/local/etc/httpd/htdocs/dir

I'd guess that your PATH variable has a du on it that gives its
results in kilobytes, whereas the PATH available to processes spawned
by the web server has a du that gives sizes in blocks.  Try setting
$ENV{PATH} explicity at the top of the script, or giving the complete
path the the desired du.

-- 
Jonathan Feinberg   jdf@pobox.com   Sunny Brooklyn, NY
http://pobox.com/~jdf/


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

Date: 25 Jun 1998 19:34:02 -0400
From: mjd@op.net (Mark-Jason Dominus)
Subject: Re: ? Moderated clpm ?
Message-Id: <6mumpa$nra$1@monet.op.net>

In article <6mrb01$1c3i$1@nntp6.u.washington.edu>,
Darwin O.V. Alonso <dalonso@u.washington.edu> wrote:
>What is the status of getting a moderated comp.lang.perl?
>Has the been a call for votes? 

There has.  You can get a copy by sending email to mcq@best.com.

The voting deadline is July 1.


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

Date: Thu, 25 Jun 1998 18:35:27 -0400
From: kissel@kissel.spicerack.ibm.com
Subject: [Q] Hash set in recursion, lost in caller
Message-Id: <Pine.A32.3.91.980625182253.11908A-100000@kissel.spicerack.ibm.com>

In code roughly like this:

L1:	&recursive_subroutine( $param );
	#stuff
L2:	if ( $hash{'akey'} ) {
		#stuff
	}
L3:	sub recursive_subroutine {
		#stuff
L4:		$hash{'akey'} .= $stuff;
		if ( $somecondition ) {
			&recursive_subroutine( $some_other_thing );
		}
	}

I was surprised to find, that when $hash{'akey'} is assigned, two
levels into the recursion (L4), lo and behold, the value of it is wiped,
unexpectedly, when I'm back at the mainline (L2).  I followed it, one line
at a time, through the debugger, and sure enough, as soon as I return
from the FIRST call, it's gone--and this key/value pair isn't touched
anywhere else.

Moreover, if I replace $hash{'akey'} with $hash_akey, i.e., a scalar
instead of a hash, everything works as expected, and the right value
bubbles up out of the recursion (which is never a deep recursion--only
2 calls deep, generally).

I'm very puzzled by this, and have a feeling this isn't a bug, but 
something which I am overlooking about the language.  Comments are
welcome--and advise me if I've not provided sufficient detail.

The mentions of the hash and subroutine are in the above-given order
in the script, but that shouldn't have anything to do with it, should it?

Thank you for your kind attention.


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

Date: 25 Jun 1998 20:51:27 -0500
From: Jonathan Feinberg <jdf@pobox.com>
To: kissel@kissel.spicerack.ibm.com
Subject: Re: [Q] Hash set in recursion, lost in caller
Message-Id: <iulpvskg.fsf@mailhost.panix.com>

kissel@kissel.spicerack.ibm.com writes:

> I was surprised to find, that when $hash{'akey'} is assigned, two
> levels into the recursion (L4), lo and behold, the value of it is wiped,
> unexpectedly, when I'm back at the mainline (L2).

It seems that you've not shown us all of the code for that sub, since
you show yourself calling it with a param, but you don't show yourself
actually using @_.  Are you scoping that hash before the assignment?

-- 
Jonathan Feinberg   jdf@pobox.com   Sunny Brooklyn, NY
http://pobox.com/~jdf/


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

Date: 26 Jun 1998 00:06:07 GMT
From: macintsh@cs.bu.edu (John Siracusa)
Subject: ANNOUNCE: Net::Hotline 0.50
Message-Id: <6muolf$nrb$1@news.neta.com>

I am pleased to announce the initial release of Net::Hotline.

The package is available for download either from my web site at

        http://siracusa.home.mindspring.com/perl/

or from any CPAN mirror server:

        http://www.perl.com/CPAN-local/authors/id/J/JS/JSIRACUSA/


What does it do:
----------------

The Net::Hotline modules implement a Hotline interface in Perl.  Currently,
this includes only Hotline::Client.  Hotline is an internet client/server
system that's a sort of cross between IRC and a BBS.  See
http://www.hotlinesw.com/ for more information.


Legal issues:
-------------

Copyright(c) 1998 by John C. Siracusa.  All rights reserved.  This program is
free software; you can redistribute it and/or modify it under the same terms
as Perl itself.


Author's note:
--------------

This is my first whack at a "real" Perl module.  Suggestions, advice,
and corrections are welcome.

-----------------+----------------------------------------
  John Siracusa  | If you only have a hammer, you tend to
 macintsh@bu.edu | see every problem as a nail. -- Maslow




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

Date: Fri, 26 Jun 1998 00:17:04 GMT
From: Grehom@my-dejanews.com
Subject: Re: Can Anyone help?
Message-Id: <6mup9v$o7u$1@nnrp1.dejanews.com>

In article <3592748D.94092176@esp-multimedia.com>,
  Jason L Rudland <Jason@esp-multimedia.com> wrote:
>
> Hi,
>
> I'm fairly new to Perl, so forgive me if I being a bit thick, but I'm a
> stuck!
>
> I have a perl script which opens a DBM database and reads the
> appropriate record. I also pass the script a parameter, which contains a
>
> field name in the DBM database. What I want to do is print the contents
> of the DBM field with the same name as the contents of the parameter I
> passed to the script.
>
> What I think I need to do is perform a macro-substitution so that I can
> say :
>
> print $FieldName;
>
> and instead of printing the name of the field in the DBM file, it prints
>
> the contents of the DBM field.
>
> Is this clear??
> Can it be done???
>
> Any help is greatfully received,
>
> Jason Rudland
>
>
try this!
#!/usr/bin/perl -w
use English;
use diagnostics;
# get first parameter passed to program
$abbrev = $ARGV[0];
%team = ( "Ja" => "Japan", "Jm" => "Jamaica", "Ko" => "Korea" );
# use parameter passed to look up the value in the associative array to print
print $team{$abbrev};


-----== Posted via Deja News, The Leader in Internet Discussion ==-----
http://www.dejanews.com/   Now offering spam-free web-based newsreading


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

Date: 25 Jun 1998 17:26:26 -0700
From: Russ Allbery <rra@stanford.edu>
Subject: Re: Can someone explain the arrow operator ?
Message-Id: <m33ecthutp.fsf@windlord.Stanford.EDU>

Matt Knecht <hex@voicenet.com> writes:

> Note the use of {} as oppesed to ().  Also note that $hash_ref is a
> _scalar_, not a hash.  It _refers_ to an anonymous hash.  To access this
> data structure, you have a few choices.

> ${$hash_ref}{Adam}

> or

> $$hash_ref{Adam}

> Yuck!  That's some ugly syntax, and it only gets worse if you start
> making hashes of hashes of arrays of hashes!  So, as an alternative
> syntax (That also yields other benefits... it's not just syntactic
> sugar, but save that for when you look at OO) you can use the arrow:

> $hash_ref->{Adam}

> Which means exactly the same thing, but is much less noisy, and it's
> readily apparant that you're dealing with a reference.

In the spirit of TIMTOWTDI, I personally strongly dislike the last form,
considering it too verbose and harder to read, and always use the second
form (just doubling the dollar sign if the variable contains a reference
rather than the hash itself).

YMMV.

-- 
#!/usr/bin/perl -- Russ Allbery, Just Another Perl Hacker
$^=q;@!>~|{>krw>yn{u<$$<[~||<Juukn{=,<S~|}<Jwx}qn{<Yn{u<Qjltn{ > 0gFzD gD,
 00Fz, 0,,( 0hF 0g)F/=, 0> "L$/GEIFewe{,$/ 0C$~> "@=,m,|,(e 0.), 01,pnn,y{
rw} >;,$0=q,$,,($_=$^)=~y,$/ C-~><@=\n\r,-~$:-u/ #y,d,s,(\$.),$1,gee,print


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

Date: Thu, 25 Jun 1998 16:09:35 -0700
From: Matt Johnson <mattj@spaatz.org>
Subject: Re: CGI.pm VS. The World!
Message-Id: <3592D8AF.B10A6C21@spaatz.org>

These are identical, as far as your browser is concerned. CGI.pm's
'print query->redirect() function really just prints out the complete
fully-HTTP-compliant Location:  HTTP header, as in your method B.

Anyone feel free to correct me if I'm wrong.

Matt Johnson


Michael S. Brito, Jr. wrote:

> I would like a script I am writing to run on every browser (even old
> lynx and mosaic). So what would be the 'safest' way to redirect????
>
> ******Method A:*****
>
> #!/usr/bin/perl
> use CGI;
>
> print $query->redirect('http://www.domain.com/up/yours.html')
>
> *****Method B:******
>
> #!/usr/bin/perl
>
> print "Location:http://www.domain.com/up/yours.html\n\n";
>
> -----------------------------------------------------------
> Michael S. Brito, Jr., Web Developer
> Newfangled Graphics Co. Inc.
> mike@newfangled.com
>
> #!/bin/perl -sp0777i<X+d*lMLa^*lN%0]dsXx++lMlN/dsM0<j]dsj
> $/=unpack('H*',$_);$_=`echo 16dio\U$k"SK$/SM$n\EsN0p[lN*1
> lK[d2%Sa2/d0$^Ixp"|dc`;s/\W//g;$_=(#####censored######)
> -----------------------------------------------------------





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

Date: Thu, 25 Jun 1998 20:39:49 -0500
From: fl_aggie@thepentagon.com (I R A Aggie)
Subject: Re: CGI.pm VS. The World!
Message-Id: <fl_aggie-2506982039500001@aggie.coaps.fsu.edu>

In article <3592D8AF.B10A6C21@spaatz.org>, Matt Johnson <mattj@spaatz.org>
wrote:

+ These are identical, as far as your browser is concerned. CGI.pm's
+ 'print query->redirect() function really just prints out the complete
+ fully-HTTP-compliant Location:  HTTP header, as in your method B.

Well, it does a bit more than:

+ > print "Location:http://www.domain.com/up/yours.html\n\n";

% tester.pl
(offline mode: enter name=value pairs on standard input)
Status: 302 Found
Uri: http://www.bogus.com/bogus/web/site/
Location: http://www.bogus.com/bogus/web/site/
Content-type: text/html

Contents of tester.pl:

use CGI;
$query=new CGI;
$filename="http://www.bogus.com/bogus/web/site/";
print $query->redirect($filename);

James - I love offline mode in CGI.pm...


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

Date: Thu, 25 Jun 1998 23:43:17 GMT
From: Grehom@my-dejanews.com
Subject: Re: challenge: put search into an array
Message-Id: <6munal$kg3$1@nnrp1.dejanews.com>


> trying to search a string for "name="
> using this code.
>
> $temp =~ s/.*name=(.*)/$1/;
>
#!/usr/bin/perl -w
use diagnostics;
use English;
## $temp =~ s/.*name=(.*)/$1/;
$temp = "abcdefghname=123ijklmnoname=456pqrstuvname=abcwxyzname=def";
@parm = split /name=/, $temp;
foreach (@parm) {
    print $ARG, "\n";
}

-----== Posted via Deja News, The Leader in Internet Discussion ==-----
http://www.dejanews.com/   Now offering spam-free web-based newsreading


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

Date: 25 Jun 1998 20:33:20 -0500
From: Jonathan Feinberg <jdf@pobox.com>
To: due@murray.fordham.edu (Allan M. Due)
Subject: Re: cookie and redirect
Message-Id: <soktvten.fsf@mailhost.panix.com>

due@murray.fordham.edu (Allan M. Due) writes:

> The question asked to generate a cookie and then redirect the person
> to a new site, all in one script.

> getprint('http://www.amazon.com');

That's not exactly "redirecting"...

   #!//c/perl/bin/perl -w
   use CGI qw( :standard );

   my $c = cookie( -NAME  => 'fred',
		   -VALUE => 'flintstone',
		 );
   print header( -COOKIE  => $c,
		 -REFRESH => '0; URL=http://www.perl.com',
	       );
   print start_html(),end_html();

-- 
Jonathan Feinberg   jdf@pobox.com   Sunny Brooklyn, NY
http://pobox.com/~jdf/


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

Date: Thu, 25 Jun 1998 22:02:39 +0000
From: Derek Romeyn <romeyde@mc0115.mcclellan.af.mil>
Subject: Re: Date calculation formula needed
Message-Id: <3592C8FF.827A80DD@mc0115.mcclellan.af.mil>

Here's what I ended up doing.  Note any problems?

use Date::DateCalc qw( decode_month calc_days );

# Gets number of days from 0 BC till now
my $date = localtime;
my $yy   = substr($date,-4);
my $mm   = substr($date,4,3); 
$mm      = decode_month($mm);
my $dd   = substr($date,8,2);
my $days = calc_days($yy, $mm, $dd);

while (<ORDERS>) {
        # Get number of days from epoch from number like 8013
	# 8 is the year and 013 is days since Jan 1st
	# Known problem, only works between 1995-2004
	$BO_dateYY = substr($_,12,1);
        if ($BO_dateYY < 5) { $BO_dateYY += 2000; }
        else { $BO_dateYY += 1990; }
        $BO_days = calc_days ($BO_dateYY, 01, 01);
        $BO_days += substr($_,13,3);
        $difference = $days - $BO_days;
        if    (($difference < 31) && ($difference > 0)) {
                $BO_30{$BO_rcc}++;
        }
}       

-- 
Derek W Romeyn romeyde@calweb.com

I wish I could say everything there was to say in one word.  I hate 
all the things that can happen between the beginning of a sentence 
and the end.  -- Leonard Cohen, The Favourite Game


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

Date: 25 Jun 1998 17:33:15 -0700
From: Russ Allbery <rra@stanford.edu>
Subject: Re: efficient director watching
Message-Id: <m3u359gfxw.fsf@windlord.Stanford.EDU>

psj <psj@cgmlarson.com> writes:

> I was just wondering if anyone knows of an elegant and efficient way to
> keep an eye on a directory for changes.  I'd like to have a program that
> is inactive (mostly) unless the contents of the directory change.

> Is File::stat combined with a while/sleep loop going to be the best?

Pretty much, yeah, unless you're on IRIX.

(IRIX has this odd daemon called fam, the File Alteration Manager, which
is supposed to be usable for these sorts of applications, but I don't know
a tremendous amount about it and it's only available on IRIX so far as I
know.)

-- 
#!/usr/bin/perl -- Russ Allbery, Just Another Perl Hacker
$^=q;@!>~|{>krw>yn{u<$$<[~||<Juukn{=,<S~|}<Jwx}qn{<Yn{u<Qjltn{ > 0gFzD gD,
 00Fz, 0,,( 0hF 0g)F/=, 0> "L$/GEIFewe{,$/ 0C$~> "@=,m,|,(e 0.), 01,pnn,y{
rw} >;,$0=q,$,,($_=$^)=~y,$/ C-~><@=\n\r,-~$:-u/ #y,d,s,(\$.),$1,gee,print


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

Date: 25 Jun 1998 22:17:41 GMT
From: abigail@fnx.com (Abigail)
Subject: Re: Hiding the Perl source
Message-Id: <6muia5$9au$5@client3.news.psi.net>

Larry Rosler (lr@hpl.hp.com) wrote on MDCCLIX September MCMXCIII in
<URL: news:MPG.ffc3c67baf10b899896d2@nntp.hpl.hp.com>:
++ In article <6mu2mu$6m2$3@client3.news.psi.net>, Abigail <abigail@fnx.com> 
++ says...
++ ...
++ > I really dislike the attitude of "what I need to develop stuff should
++ > be free, but what I develop should not". It's anti-social.
++ 
++ I fear another flame war about to begin.
++ 
++ Your statement is very offensive, and more fitting for Stallman to use 
++ (as he repeatedly does).
++ 
++ The Perl code I write has economic value to my company, and they pay me 
++ to produce it.  If I use a 'free' tool, that is irrelevant to the value 
++ of the work product.  (In fact, for Windows I use a perl port for which 
++ my company pays MKS as part of their Toolkit, but that really doesn't 
++ change the issue -- I use free perl on Unix.)
++ 
++ This use for commercial purposes is explicitly permitted by the 
++ License(s), which my company would not violate.  It is *not* anti-social 
++ for me not to share my code freely -- it is anti-having-a-job.

I did not say it was anti-social not to share your code.

I said it was anti-social to expect the tools you are developing
with to be free, yet the things you are developing shouldn't be.

(And I mean free here mainly in the sense of 'open').

++ That doesn't prevent me from sharing my ideas here, presumably on my own 
++ time.



Abigail
-- 
perl -wleprint -eqq-@{[ -eqw+ -eJust -eanother -ePerl -eHacker -e+]}-


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

Date: 25 Jun 1998 17:40:00 -0700
From: Russ Allbery <rra@stanford.edu>
Subject: Re: How do I get a system call to write it's information into the file that calls it?
Message-Id: <m3lnqlgfmn.fsf@windlord.Stanford.EDU>

Bryan T Hoch <bth@acsu.buffalo.edu> writes:

> $x=0;
> #build the initial array of people who are logged on and what host
> foreach $personA (@people_array){
>     foreach $hostA (@host_array){
>         if ((system "rusers -l $hostA | fgrep $personA") == 0){
>             push(@logged_on, $personA."@".$hostA);
>             print $logged_on[i];
>             $x++;
>         }
>     }
> }

> what it's suppose to do is run the command line

> rusers -l $hostA | fgrep $personA

> for a list of different people on a list of different servers. What it
> does is just start spewing information about all users (not just the
> ones in my list $personA) (like it only receives the command line rusers
> -l $hostA and not the rest of the line. So I'm assuming my "s are being
> used wrong.  Any idea how to fix that?

That part is odd; I have no idea why the fgrep wouldn't be working right.

> And also the problem of not printing it to screen, but just send the
> information to an array in the program?

If you want to capture the output of an external command, don't use
system.  Use backticks.  In other words, you want:

        @output = `rusers -1 $hostA | fgrep $personA`;
        if ($? == 0 && @output) {
            ...
        }

-- 
#!/usr/bin/perl -- Russ Allbery, Just Another Perl Hacker
$^=q;@!>~|{>krw>yn{u<$$<[~||<Juukn{=,<S~|}<Jwx}qn{<Yn{u<Qjltn{ > 0gFzD gD,
 00Fz, 0,,( 0hF 0g)F/=, 0> "L$/GEIFewe{,$/ 0C$~> "@=,m,|,(e 0.), 01,pnn,y{
rw} >;,$0=q,$,,($_=$^)=~y,$/ C-~><@=\n\r,-~$:-u/ #y,d,s,(\$.),$1,gee,print


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

Date: 25 Jun 1998 20:16:52 -0500
From: Jonathan Feinberg <jdf@pobox.com>
To: mwang@tech.cicg.ml.com (Michael Wang)
Subject: Re: how do I parse a certain structured text?
Message-Id: <vhppvu63.fsf@mailhost.panix.com>

mwang@tech.cicg.ml.com (Michael Wang) writes:

> Suppose I want to get
> SID_NAME and ORACLE_HOME
> from the following construct, how should I do it. Please note
> the text can be arranged differently. 
> 
> SID_LIST_CICGPROD-DS2-P_LISTENER =
>   (SID_LIST =
>     (SID_DESC =
>       (SID_NAME = CICGNYP1)
>       (ORACLE_HOME = /ds2-export/apps/oracle/product/7.3.4)
>     )
>     (SID_DESC =
>       (SID_NAME = CICGNYP2)
>       (ORACLE_HOME = /ds2-export/apps/oracle/product/7.3.4)
>     )
>   )

Here's one way:

   while ( m{ 
             SID_NAME \s* = \s* 
             (\w+)   # $1
             \) \s* \( 
             ORACLE_HOME \s* = \s* 
             ([^)]+) # $2
            }gx)
   {
     push @stuff, { sidname => $1,
                    oracle_home => $2
                  };
   }

-- 
Jonathan Feinberg   jdf@pobox.com   Sunny Brooklyn, NY
http://pobox.com/~jdf/


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

Date: Thu, 25 Jun 98 21:27:49 GMT
From: NOSPAM.thomas_wernitz@tait.co.nz (Thomas Wernitz)
Subject: Re: How do I pass more than one array as a parameter into a subroutine?
Message-Id: <6muj31$k1m$1@wolfman.xtra.co.nz>

In article <Pine.GSO.3.96.980625132523.12373B-100000@armstrong.cs.Buffalo.EDU>, Bryan T Hoch <bth@cs.buffalo.edu> wrote:
>In basics, I want something like this...
>
>&sub_rout(@array1, @array2);
>
>
>and then somewhere in the subroutine called...
>
>sub sub_rout{
>        my(@this1, @this2) = @_;

There is, try references:

&sub_rout(\@array1, \@array2);

sub sub_rout{
        my($this1, $this2) = @_;
        print @$r;

HTH,
Thomas

"most people would die sooner than think -- in fact, they do so."
                                                         -- Bertrand Russell


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

Date: 25 Jun 1998 17:30:18 -0700
From: Russ Allbery <rra@stanford.edu>
Subject: Re: How to set system time using Perl??
Message-Id: <m3zpf1gg2t.fsf@windlord.Stanford.EDU>

Ye Ye <yey@cvilaser.com> writes:

> Is there a way to set the system clock using Perl?  I am able to using
> 'cu' to get the current time from National Institute of Standards and
> Technology, but which function am I suppose to use to set the clock?  I
> know there is a 'stime' function in C, do I have to use that?

I would recommend simply running the date command as root and giving it
the new system time on the command line, or alternately switching to
something like xntpd and letting it take care of all of it for you.
Setting the system clock is sufficiently system specific that I'd hesitate
to stray away from using the standard system tools and trying to roll your
own.

-- 
#!/usr/bin/perl -- Russ Allbery, Just Another Perl Hacker
$^=q;@!>~|{>krw>yn{u<$$<[~||<Juukn{=,<S~|}<Jwx}qn{<Yn{u<Qjltn{ > 0gFzD gD,
 00Fz, 0,,( 0hF 0g)F/=, 0> "L$/GEIFewe{,$/ 0C$~> "@=,m,|,(e 0.), 01,pnn,y{
rw} >;,$0=q,$,,($_=$^)=~y,$/ C-~><@=\n\r,-~$:-u/ #y,d,s,(\$.),$1,gee,print


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

Date: Thu, 25 Jun 1998 20:22:26 -0500
From: alecler@cam.org (Andre L.)
Subject: Re: if statement, legal?
Message-Id: <alecler-2506982022260001@dialup-513.hip.cam.org>

In article <3592B1D6.64495ACD@acuityinc.com>, markf@acuityinc.com wrote:

> if ($a > 0 or $b > 0 ) {}
> 
> It's the 'or' that I'm asking about.  Is it legal, possible, or am I
> using the wrong syntax?
> 
> -Mark


Because of the low precedence of "or", the statement is perfectly correct
and works as you would expect.

If you used ||, you would have to enclose each comparison in parentheses,
however.

   if (($a > 2) || ($b > 5)) { }

That's why I prefer to use "or" and "and" most of the time.

A.L.


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

Date: 25 Jun 1998 20:35:24 -0500
From: Jonathan Feinberg <jdf@pobox.com>
To: markf@acuityinc.com
Subject: Re: if statement, legal?
Message-Id: <pvfxvtb7.fsf@mailhost.panix.com>

markf@acuityinc.com writes:

> if ($a > 0 or $b > 0 ) {}
> 
> It's the 'or' that I'm asking about.  Is it legal, possible, or am I
> using the wrong syntax?

Yes, yes, and no.  What unexpected result are you getting?  What
version of perl are you using?  Are you using the -w switch?  Are you
sure that $a and $b are defined?

-- 
Jonathan Feinberg   jdf@pobox.com   Sunny Brooklyn, NY
http://pobox.com/~jdf/


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

Date: 25 Jun 1998 17:35:34 -0700
From: Russ Allbery <rra@stanford.edu>
Subject: Re: if statement, legal?
Message-Id: <m3ra0dgfu1.fsf@windlord.Stanford.EDU>

markf <markf@acuityinc.com> writes:

> if ($a > 0 or $b > 0 ) {}

> It's the 'or' that I'm asking about.  Is it legal, possible, or am I
> using the wrong syntax?

Sure, it's legal, although I'd normally write:

        if ($a > 0 || $b > 0)

instead and save the "or" for cases where I really need its special
precedence.

-- 
#!/usr/bin/perl -- Russ Allbery, Just Another Perl Hacker
$^=q;@!>~|{>krw>yn{u<$$<[~||<Juukn{=,<S~|}<Jwx}qn{<Yn{u<Qjltn{ > 0gFzD gD,
 00Fz, 0,,( 0hF 0g)F/=, 0> "L$/GEIFewe{,$/ 0C$~> "@=,m,|,(e 0.), 01,pnn,y{
rw} >;,$0=q,$,,($_=$^)=~y,$/ C-~><@=\n\r,-~$:-u/ #y,d,s,(\$.),$1,gee,print


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

Date: 25 Jun 1998 19:10:11 EDT
From: "Jerry L. Gubka" <jlguru@cris.com>
To: Vicky <vcolf@ix.netcom.com>
Subject: Re: Installing Perl on Windows95- Problem with Install.bat
Message-Id: <3592D793.BB9DF176@cris.com>

Vicky wrote:
> 
> I'm using Active States port of Perl for Windows 95 and NT and after I
> run Winzip and then run the install.bat file I get an error message
> (from install.bat) saying that it cannot find the file Y:command.com or
> that that file is in use.
> Anybody have an idea what the problem is here...why is it looking for a
> Y drive?
> Thanks!
> Vicky
> please email me
> vcolf@ix.netcom.com

Vicky: 

Every time I've used Activeware's install.bat it has mangled the
registry entries that point to the binary/lib/docs subdirectories
resulting in the kind of problems you describe. Check your registry
under the following:

HKEY_LOCAL_MACHINE\SOFTWARE\ACTIVEWARE\PERL5 

and see if the entries are pointing to the correct place. If not, change
them.

Live long, and prosper
Jerry L. Gubka


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

Date: 25 Jun 1998 20:58:45 GMT
From: aks@cs.brown.edu (Amanda Silver)
Subject: iterating through files and subdirectories
Message-Id: <6mudm5$9nm@cocoa.brown.edu>


there has got to be a command that iterates through all the files in a directory and then all the files in all subdirectories...what would this command be though?

(you can make fun of me for askinf such a stupid question all you want as long
as someone answers me...i know i am a beginner, you all know i'm a beginner, i can take the heat...even in this "master class") 

--
~      a m a n d a s i l v e r      ~
~   b r o w n u n i v e r s i t y   ~
~  a k s @ c s . b r o w n . e d u  ~


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

Date: Thu, 25 Jun 1998 22:47:33 GMT
From: hex@voicenet.com (Matt Knecht)
Subject: Re: iterating through files and subdirectories
Message-Id: <9sAk1.59$ja2.690401@news2.voicenet.com>

Amanda Silver <aks@cs.brown.edu> wrote:
>there has got to be a command that iterates through all the files in a
>directory and then all the files in all subdirectories...what would this
>command be though?

Not really a command, but a module, File::Find.

perldoc File::Find will explain a lot more uses than this quick example:

use File::Find;

$everything = sub { print "$_\n" };
find $everything, '.';

-- 
Matt Knecht - <hex@voicenet.com>
"496620796F752063616E207265616420746869732C20796F7520686176652066
617220746F6F206D7563682074696D65206F6E20796F75722068616E6473210F"


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

Date: 25 Jun 1998 20:44:40 -0500
From: Jonathan Feinberg <jdf@pobox.com>
To: Bryan Belanger <bbelang1@eccms1.dearborn.ford.com>
Subject: Re: Linked list
Message-Id: <lnqlvsvr.fsf@mailhost.panix.com>

Bryan Belanger <bbelang1@eccms1.dearborn.ford.com> writes:

>          %{$cur_ReOrder}->{'next'} = %{$next}->{'next'};
>          %{$next}->{'next'} = %{$temp}->{'next'};
>          %{$next}->{'previous'} = $temp;
>          %{$temp}->{'next'} = $next;

I'm not sure what's in the scalars $temp, $next, and $cur_ReOrder.  If
they are references to hashes, then you refer to their values as

   $temp->{foo}

and not

   %{$temp}->{foo}

which is perl nonsense-talk, along the lines of "please put that box
in these apple".  Please read and re-read perlref, perldsc, and
perllol.

-- 
Jonathan Feinberg   jdf@pobox.com   Sunny Brooklyn, NY
http://pobox.com/~jdf/


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

Date: Thu, 25 Jun 1998 23:38:30 GMT
From: bobmacd+cmp@netcom.com (Bob MacDowell)
Subject: Re: MacPerl and odd filenames
Message-Id: <bobmacdEv4sC7.L9s@netcom.com>

Found it myself.  Strange problem, strange workaround.

bobmacd+cmp@netcom.com (Bob MacDowell) writes:

>I need to open some files in MacPerl 5.2.0r4, and it's unable to open 
>certain files.  It can READDIR their names but when it tries to open them,
>it fails...
 ...
>  Opening Greg:Test:<RE>pcdir/jobs 100%      <--Error! Can't open!!
>  Opening Greg:Test:<RE>QuickMail problems      <--Error! Can't open!!
 ...
>Three of the files have "/" in them, which I could understand as a problem
>(even though macs use ":".) But why would "<RE>Quickmail problems" mess up?
>There's nothing weird in it.  

I made a copy of the "Quickmail problems" file and noticed something odd
about the filename.  So I re-ran the program with dashes around the 
filename, i.e. "-$file-"  (and appending the $! error to the end.) 

  Opening -:<RE>pcdir/jobs 100%\ -     <--Error! Can't open!! No such file or directory
  Opening -:<RE>QuickMail problems\ -     <--Error! Can't open!! No such file or directory
  Opening -:<RE>QuickMail problems  copy-

Notice the trailing blanks.  It wasn't the "/" after all.   Now, I think
blanks are perfectly legitimate parts of a filename, even trailing ones.
But obviously MacPerl didn't.  The fix? Put a colon (:) *after* the filename.  
It seems strange that that should work.  But it does. 

  Opening -:<RE>pcdir/jobs 100% :-
  Opening -:<RE>QuickMail problems :-
  Opening -:<RE>QuickMail problems  copy:-

-Bob


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

Date: 25 Jun 1998 21:45:37 GMT
From: aks@cs.brown.edu (Amanda Silver)
Subject: mastering regular expressions
Message-Id: <6muge1$bho@cocoa.brown.edu>


i also was wondering if the Mastering Regular Expressions book by o'reilly 
really is the best book and if it will help me alot, can anyone here provide a review?

thanks.



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

Date: 25 Jun 1998 17:41:54 -0700
From: Russ Allbery <rra@stanford.edu>
Subject: Re: mastering regular expressions
Message-Id: <m3iulpgfjh.fsf@windlord.Stanford.EDU>

Amanda Silver <aks@cs.brown.edu> writes:

> i also was wondering if the Mastering Regular Expressions book by
> o'reilly really is the best book and if it will help me alot, can anyone
> here provide a review?

<URL:http://language.perl.com/critiques/>.  And yes, it's an excellent
book for learning regular expressions.

-- 
#!/usr/bin/perl -- Russ Allbery, Just Another Perl Hacker
$^=q;@!>~|{>krw>yn{u<$$<[~||<Juukn{=,<S~|}<Jwx}qn{<Yn{u<Qjltn{ > 0gFzD gD,
 00Fz, 0,,( 0hF 0g)F/=, 0> "L$/GEIFewe{,$/ 0C$~> "@=,m,|,(e 0.), 01,pnn,y{
rw} >;,$0=q,$,,($_=$^)=~y,$/ C-~><@=\n\r,-~$:-u/ #y,d,s,(\$.),$1,gee,print


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

Date: Thu, 25 Jun 1998 20:47:49 -0500
From: fl_aggie@thepentagon.com (I R A Aggie)
Subject: Re: mastering regular expressions
Message-Id: <fl_aggie-2506982047490001@aggie.coaps.fsu.edu>

In article <6muge1$bho@cocoa.brown.edu>, aks@cs.brown.edu (Amanda Silver) wrote:

+ i also was wondering if the Mastering Regular Expressions book by o'reilly 
+ really is the best book

AFAIK, it is the _only_ book on regex's. If I'm wrong, I'll be corrected
shortly...

+ and if it will help me alot, can anyone here provide a review?

There should be a review on www.perl.com/ - look for a 'books' section.
It covers regex's, and not only those in perl - but the chapter on
perl is nearly 1/3 of the book.

Its quite helpful to me. It would be more helpful if I actually took
the time to read it cover-to-cover, instead of using it as a reference
guide/how-do-I-do-such-and-such-right-now.

James


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

Date: Thu, 25 Jun 1998 22:03:12 GMT
From: Gellyfish@btinternet.com (Jonathan Stowe)
Subject: Re: msqlperl and windows 95
Message-Id: <3592c49d.13288499@news.btinternet.com>

On Thu, 25 Jun 1998 13:56:43 -0700, josri wrote :

<snip>

>"make: rem: Command not found". I tried going through the makefile and
>found a line as "NOOP = rem" What does this line mean? 

It appears that makefile.PL has detected that you are using a DOSish
system and assumes that you would be using command.com / cmd.exe as a
shell and thus has used "rem" as a comment you might try altering that
line to NOOP = # if you are using some unixish shell instead.

/J\
Jonathan Stowe
Some of your questions answered:
<URL:http://www.btinternet.com/~gellyfish/resources/wwwfaq.htm>



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

Date: 25 Jun 1998 17:23:43 -0700
From: Russ Allbery <rra@stanford.edu>
Subject: Re: Perl and Delphi
Message-Id: <m367hphuy8.fsf@windlord.Stanford.EDU>

Todd Cary <todd@aristesoftware.com> writes:

> Is the a library for Perl that can be run under Delphi?

Not that I'm aware of, and I believe I looked into this a while back for a
friend.  Delphi is, as I recall, a Pascal varient, and most of the Perl
embedding work has been done in C.

-- 
#!/usr/bin/perl -- Russ Allbery, Just Another Perl Hacker
$^=q;@!>~|{>krw>yn{u<$$<[~||<Juukn{=,<S~|}<Jwx}qn{<Yn{u<Qjltn{ > 0gFzD gD,
 00Fz, 0,,( 0hF 0g)F/=, 0> "L$/GEIFewe{,$/ 0C$~> "@=,m,|,(e 0.), 01,pnn,y{
rw} >;,$0=q,$,,($_=$^)=~y,$/ C-~><@=\n\r,-~$:-u/ #y,d,s,(\$.),$1,gee,print


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

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

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