[7720] in Perl-Users-Digest

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

Perl-Users Digest, Issue: 1346 Volume: 8

daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Thu Nov 20 07:09:23 1997

Date: Thu, 20 Nov 97 04:00:25 -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           Thu, 20 Nov 1997     Volume: 8 Number: 1346

Today's topics:
     $a='001' ; $a++ ; print$a <koos_pol@bigfoot.com>
     Re: $a='001' ; $a++ ; print$a (Tina Marie Holmboe)
     Re: $a='001' ; $a++ ; print$a (Honza Pazdziora)
     Re: -e switch (Abigail)
     5.004_01 bug? (Vladimir Sovetov)
     Re: 5.004_01 bug? (Vladimir Sovetov)
     [Q] can detect the location of a FORM? <newschool@theoffice.net>
     Best way to find directory of a given file <usenet_post@bradfitz.com>
     Re: Best way to find directory of a given file <bgillette@corp.borland.com>
     Re: Best way to find directory of a given file <qdtcall@esb.ericsson.se>
     Re: Can't 'make' modules.  "bash: make: command not fou <qdtcall@esb.ericsson.se>
     Extracting Photoshop/IPTC annoation from JPEG <lars.schylberg@enator.se>
     File::Find, find() question <bgillette@corp.borland.com>
     Re: giving up on flock <markm@nortel.ca>
     Re: Help needed: Calling another program (Tina Marie Holmboe)
     Re: How to: GD-1.14, Perl 5.004.01 & OS/2? <koos_pol@bigfoot.com>
     Is there a sendmail utility for MIIS/NT <david@thames.com>
     Is this an array of hashes, or what? (Paddy Spencer)
     Re: Is this an array of hashes, or what? (Honza Pazdziora)
     Re: Last element of an anonymous array (Tony Bass)
     Re: Newbie Question (Brian Mitchell)
     Newbie, strange pop behavior? <rbroad@sprintmail.com>
     pass by reference? what is wrong? <designky@sonnets.dot.com>
     Re: pass by reference? what is wrong? <dshoyt@worldnet.att.net>
     Re: pass by reference? what is wrong? (Tina Marie Holmboe)
     Perl Programmer needed (John Mosey)
     Re: Perl Tutotial <billg@networkapparel.com>
     Re: Year2000 problem with localtime(); (Willi Burmeister)
     Re: Year2000 problem with localtime(); (Tina Marie Holmboe)
     Digest Administrivia (Last modified: 8 Mar 97) (Perl-Users-Digest Admin)

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

Date: Thu, 20 Nov 1997 11:49:34 +0100
From: Koos Pol <koos_pol@bigfoot.com>
Subject: $a='001' ; $a++ ; print$a
Message-Id: <347415BE.7936@bigfoot.com>

$a='001';
$a++;
print $a;

This nicely yields '002'. I was very positively shocked about this:-) !
Is this correct behaviour ?

-- 
Koos Pol
----------------------------------------------------------------------
S.C. Pol                                           tel: +31 20 3116122
PC Systems Administrator                   email: Koos_Pol@bigfoot.com
Compuware Europe                 PGP public key available upon request

      A little inaccuracy sometimes saves tons of explanation.
                        -- H. H. Munroe


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

Date: 20 Nov 1997 11:33:19 GMT
From: tina@scandinaviaonline.se (Tina Marie Holmboe)
Subject: Re: $a='001' ; $a++ ; print$a
Message-Id: <65175v$pak$1@news1.sol.no>

In article <347415BE.7936@bigfoot.com>,
	Koos Pol <koos_pol@bigfoot.com> writes:

> $a='001';
> $a++;
> print $a;
> 
> This nicely yields '002'. I was very positively shocked about this:-) !
> Is this correct behaviour ?

  I think you will find that Larry et all isn't :) This is what is known
as 'deep magic'. The scalar $a contains a string; "001", which when the
operator ++ is applied to it is incremented - magically.

  See also the perlop man-page under the section 

     "Auto-increment and Auto-decrement"


  If you, on the other hand, change the above to:

  $a = 001 ;
  $a++ ;
  print $a ;

  then a nice little '2' is output. Quite as one would expect...

--
 Tina Marie Holmboe                          tina@mail.scandinaviaonline.se

 The opinions expressed above are mine, and should in no way or under any
 circumstances be associated with Scandinavia Online AB unless this disclaimer
 is explicitly revoked.


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

Date: Thu, 20 Nov 1997 11:41:25 GMT
From: adelton@fi.muni.cz (Honza Pazdziora)
Subject: Re: $a='001' ; $a++ ; print$a
Message-Id: <adelton.880026085@aisa.fi.muni.cz>

Koos Pol <koos_pol@bigfoot.com> writes:

> $a='001';
> $a++;
> print $a;
> 
> This nicely yields '002'. I was very positively shocked about this:-) !
> Is this correct behaviour ?

And what did you expect, '005'? ;-)

You might want to check man page perlop, section about auto-increment.
The ++ is magical on strings.

--
------------------------------------------------------------------------
 Honza Pazdziora | adelton@fi.muni.cz | http://www.fi.muni.cz/~adelton/
                   I can take or leave it if I please
------------------------------------------------------------------------


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

Date: 20 Nov 1997 05:15:07 GMT
From: abigail@fnx.com (Abigail)
Subject: Re: -e switch
Message-Id: <slrn677hud.798.abigail@betelgeuse.wayne.fnx.com>

Joseph Kewish (jsrk@pipeline.com) wrote on 1542 September 1993 in
<URL: news:34739DD8.812C1DFB@pipeline.com>:
++ I'm having the damndest time trying to figure out how to use perl
++ straight from the command line. There are times when I just need a
++ little loop or what have you, but I've not been able to find a clear
++ example of how the -e switch is used.
++ 
++ Anyone care to give me an example?

perl -we 'print "Hello, world\n";'


Abigail
-- 
perl -wle 'print "Prime" if (1 x shift) !~ /^1?$|(11+?)\1+$/'


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

Date: 20 Nov 1997 08:21:40 GMT
From: sova@kpbank.ru (Vladimir Sovetov)
Subject: 5.004_01 bug?
Message-Id: <650ruk$6d6$1@home.kpbank.ru>

This is the FAQ's idea for HTML tags removing

    #!/usr/bin/perl -p0777
    s/<(?:[^>'"]*|(['"]).*?\1)*>//gs

This is the test script

%cat ts
#!/usr/bin/perl -p0777
    s/<(?:[^>'"]*|(['"]).*?\1)*>//gs

%cat index.html|./ts
/<(?:[^>'"]*|(['"]).*?\1)*>/: ?+* follows nothing in regexp at ./ts line 2.

% /usr/bin/perl5 -v

This is perl, version 5.004_01

Copyright 1987-1997, Larry Wall

Perl may be copied only under the terms of either the Artistic License or the
GNU General Public License, which may be found in the Perl 5.0 source kit.

  Strange?-))) Worked fine under  5.001. Upgrade or downgrade?
---
-Vladimir Sovetov | Kuzbassprombank


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

Date: 20 Nov 1997 09:25:44 GMT
From: sova@kpbank.ru (Vladimir Sovetov)
Subject: Re: 5.004_01 bug?
Message-Id: <650vmo$6d6$2@home.kpbank.ru>

Vladimir Sovetov (sova@kpbank.ru) wrote:
: This is the FAQ's idea for HTML tags removing

:     #!/usr/bin/perl -p0777
:     s/<(?:[^>'"]*|(['"]).*?\1)*>//gs

: This is the test script

: %cat ts
: #!/usr/bin/perl -p0777
:     s/<(?:[^>'"]*|(['"]).*?\1)*>//gs

: %cat index.html|./ts
: /<(?:[^>'"]*|(['"]).*?\1)*>/: ?+* follows nothing in regexp at ./ts line 2.

: % /usr/bin/perl5 -v

: This is perl, version 5.004_01

: Copyright 1987-1997, Larry Wall

: Perl may be copied only under the terms of either the Artistic License or the
: GNU General Public License, which may be found in the Perl 5.0 source kit.

    Forgot to add that OS is BSD/OS 2.1
    Absolutely the same behavior  under

BSD/OS 3.0: perl, version 5.003_02
+ two suidperl security patches


   While on DEC A400

OSF/1: perl, version 5.003 with EMBED
built under dec_osf at Nov 20 1997 14:26:18
+ suidperl security patch

   All work fine.

   So is it for Perl older than 5.003 or it's BSD/OS problem?
The link is too slow so I'm still waiting for the end of 5.004_04 download.:-(((
---
-Vladimir Sovetov | Kuzbassprombank


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

Date: Thu, 20 Nov 1997 01:26:15 -0500
From: Tsuyoshi Niwa <newschool@theoffice.net>
Subject: [Q] can detect the location of a FORM?
Message-Id: <3473D807.1714@theoffice.net>

Can CGI script detect from where a form are submitted?
I run a javascript on a form to strict people who can send
the form. However this form works from any local computer,
so that any one can change the script and submit the form.
I want only the form on the web to be able to access to the
CGI script.

Tsuyoshi Niwa


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

Date: Wed, 19 Nov 1997 23:01:53 -0800
From: "Brad Fitzpatrick" <usenet_post@bradfitz.com>
Subject: Best way to find directory of a given file
Message-Id: <650n86$8do$1@glisan.hevanet.com>

Suppose that I known the full path to a given file... I want to find that
file's directory so I can chdir() to it.

Is it safe to simply use a regex on the full path to chop off everything
past the last slash to find the directory?

That's what I've done in the past and seems the most obvious thing to do...
However, something eating away inside me says, "Hey!  You need to watch out
for those special cases!"  But I can't think of any.

Is there a Perl function to give me this information or is the regex method
acceptable?


Thanks,
Brad

--
Brad Fitzpatrick
http://www.bradfitz.com/




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

Date: Wed, 19 Nov 1997 23:51:54 -0800
From: BJ Gillette <bgillette@corp.borland.com>
Subject: Re: Best way to find directory of a given file
Message-Id: <3473EC1A.FBB3DDEB@corp.borland.com>

Brad Fitzpatrick wrote:
> 
> Suppose that I known the full path to a given file... I want to find that
> file's directory so I can chdir() to it.
> 
> Is it safe to simply use a regex on the full path to chop off everything
> past the last slash to find the directory?
> 
> That's what I've done in the past and seems the most obvious thing to do...
> However, something eating away inside me says, "Hey!  You need to watch out
> for those special cases!"  But I can't think of any.
> 
> Is there a Perl function to give me this information or is the regex method
> acceptable?


I don't know of cases where your method
wouldn't work, but there
is also the fileparse(..) function in
File::Basename.
You'd probably want to use it with also
want to use 
it with fileparse_set_fstype(..).  

Hmmm, maybe using the lib routines will
make your code
a bit more portable across various file
systems.  That
would make it worth while.

-- Brad G.


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

Date: 20 Nov 1997 10:41:11 +0100
From: Calle Dybedahl <qdtcall@esb.ericsson.se>
Subject: Re: Best way to find directory of a given file
Message-Id: <isen4bq4w8.fsf@godzilla.kiere.ericsson.se>

"Brad Fitzpatrick" <usenet_post@bradfitz.com> writes:

> Is it safe to simply use a regex on the full path to chop off everything
> past the last slash to find the directory?

It is safe -- on Unix systems. It'll fail miserably on MacOS, VMS and
probably on WinNT as well.

> Is there a Perl function to give me this information or is the regex method
> acceptable?

There is a module, File::Basename, in the standard distribution. It'll
do the right thing for just about any OS Perl runs on.

-- 
		    Calle Dybedahl, UNIX Sysadmin
       qdtcall@esavionics.se  http://www.lysator.liu.se/~calle/


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

Date: 20 Nov 1997 10:35:40 +0100
From: Calle Dybedahl <qdtcall@esb.ericsson.se>
Subject: Re: Can't 'make' modules.  "bash: make: command not found"
Message-Id: <isg1orq55f.fsf@godzilla.kiere.ericsson.se>

bsa@void.apk.net (Brandon S. Allbery KF8NH; to reply, change "void" to "kf8nh") writes:

> Anyway, the problem on Solaris, SCOv5, etc. is that /usr/ccs/bin needs to be
> added to your PATH.  To the *end* of your PATH, by preference:  some vendors
> put bad stuff in there (notably, Solaris has a /usr/ccs/bin/cc that's a shell
> script which essentially advertizes Sunsoft's compiler suite).

What kind of strange Solaris are you running? On all such I have
access to, the "Get Sunsoft" script is /usr/ucb/cc, not in /usr/ccs/bin.

-- 
		    Calle Dybedahl, UNIX Sysadmin
       qdtcall@esavionics.se  http://www.lysator.liu.se/~calle/


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

Date: Thu, 20 Nov 1997 11:04:25 +0100
From: Lars Schylberg <lars.schylberg@enator.se>
Subject: Extracting Photoshop/IPTC annoation from JPEG
Message-Id: <34740B29.63619EE@enator.se>

Hi,

I wonder if someone has a perl-script to
extract the IPTC annatation information that could
be saved in a JPEG file with Photoshop ?

Lars

Email: Lars.Schylberg@enator.se




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

Date: Thu, 20 Nov 1997 00:35:47 -0800
From: BJ Gillette <bgillette@corp.borland.com>
Subject: File::Find, find() question
Message-Id: <3473F663.70B5DC80@corp.borland.com>

1) I want to use find() from File::Find,
but I've hardly touched Unix for 4
years, so my familiarity w/ the find()
command has long since waned, to put it
mildly.  Where can us slaves to MS
Windows find "softcopy" help for the
Unix find() command -- I'm talking man
page, type of information.

2) I'm trying to find all the .zip files
under a dir. hierarchy,
and put them into an array.  
  find( \&wanted, $dir);
  sub wanted
  { 
    #Performs a case Insens. srch for
file names ending in .ZIP
    print "$File::Find::name" if $_ =~
/\.ZIP$/i;  #OK for printing
  }

#But the following seems quite clumsy,
and "barely" works (i.e. hack)
  sub wanted
  # Performs a case Insens. srch for
file names ending in .ZIP
  {
  my $zipFile = "$File::Find::name" if
$_ =~ /\.ZIP$/i;
  if ( $zipFile ne "")
    {
    $zipFile = "$File::Find::name";
    push (@ZIPS, "$File::Find::name" );
    #push (@ZIPS, $zipFile );
    }
  }

3) I'm a toddler here w/ Perl (and
RegEx's) so any other sugg's you have
will be quite welcome.  (e.g. is find()
the best tool for what I want to do?)  

TIA,
Brad G.


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

Date: 20 Nov 1997 02:57:13 -0500
From: Mark Mielke <markm@nortel.ca>
Subject: Re: giving up on flock
Message-Id: <lq1pvnwdmli.fsf@bmers2e5.nortel.ca>

syarbrou@ais.net (Steve) writes:
> I've pretty much had it with flock.  I open a file to read and
> append(+>>) and it just doesn't seem to work.  My file keeps getting
> cleared.  Can flock only work for reading or writing?  I hear this
> function is pretty much worthless unless the kernel supports it.   I
> also heard that as usual, freeware Linux supports this, and that's
> about it?  Any enlightenment on the above?  Thanks.

flock() should work on just about anything that calls itself unix. Perl
attempts to use any method possible to implement flock(), whether it
be by using fcntl() or otherwise. Win95/WinNT/etc? I really could not
tell you. But flock() will work for append. You just have to remember
that flock() is guaranteed to be portable, so the lock can only apply to
the entire file. You as someone who wants to append to the file would
request an exclusive lock on the file... append your stuff... then
unlock the file... all done. here's some pseudo-type code..

   sub append_to_file
   {
      if (open_the_file_for_writing) {
         if (request_exclusive_lock_on_the_open_file) {
            seek_to_the_end_of_the_file; <-- NECESSARY!!!!!!!!!!!!!!!
            print_your_stuff_to_the_filehandle;
            release_the_lock_on_the_open_file; <-- OPTIONAL
         } else {
            error_trying_to_lock_file!!!!
         }
         close_the_file;
      } else {
         error_trying_to_open_file!!!!
      }
   }

I'm feeling like not doing all the work today... so i leave it to you
to convert the above to perl :-)

mark

--                                                  _________________________
 .  .  _  ._  . .   .__    .  . ._. .__ .   . . .__  | Northern Telecom Ltd. |
|\/| |_| |_| |/    |_     |\/|  |  |_  |   |/  |_   | Box 3511, Station 'C' |
|  | | | | \ | \   |__ .  |  | .|. |__ |__ | \ |__  | Ottawa, ON    K1Y 4H7 |
  markm@nortel.ca  /  al278@freenet.carleton.ca     |_______________________|


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

Date: 20 Nov 1997 08:45:37 GMT
From: tina@scandinaviaonline.se (Tina Marie Holmboe)
Subject: Re: Help needed: Calling another program
Message-Id: <650tbh$h2v$4@news1.sol.no>

In article <34733752.81E0B961@atpco.com>,
	Marcos Lindekugel <mlinde@atpco.com> writes:

> get an "Internal Error" message. I think the problem is in the way I'm
> using the exec command:
> 
>     $programName = "/app/apache/cgi-bin/".$databaseName;
>     exec $programName;

  I would _guess_ that this may be due to one of two things:

  a) The 'user' running the script, usually the HTTP-server, does not have
     permission to actually run those other programs, or

  b) The path, which quite naturally works from the command line, isn't correct
     when run from 'inside' the server.

--
 Tina Marie Holmboe                          tina@mail.scandinaviaonline.se

 The opinions expressed above are mine, and should in no way or under any
 circumstances be associated with Scandinavia Online AB unless this disclaimer
 is explicitly revoked.


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

Date: Thu, 20 Nov 1997 11:41:25 +0100
From: Koos Pol <koos_pol@bigfoot.com>
Subject: Re: How to: GD-1.14, Perl 5.004.01 & OS/2?
Message-Id: <347413D5.10B5@bigfoot.com>

samdie@ibm.net wrote:
> 
> Has anyone managed to install GD under os/2?
> The following shows some of the problems that I'm running into:
> 

I never have succeeded installing modules using the install makefile
under OS/2.
I always just copy the module to the /perl/lib directory. I has never
failed me.

-- 
Koos Pol
----------------------------------------------------------------------
S.C. Pol                                           tel: +31 20 3116122
PC Systems Administrator                   email: Koos_Pol@bigfoot.com
Compuware Europe                 PGP public key available upon request

      A little inaccuracy sometimes saves tons of explanation.
                        -- H. H. Munroe


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

Date: Thu, 20 Nov 1997 10:16:15 +0000
From: David Rayner <david@thames.com>
Subject: Is there a sendmail utility for MIIS/NT
Message-Id: <34740DEF.5957@thames.com>

We debug our cgi's on our NT/MIIS intranet before uploading them to
the web, I can simulate everything except piping information
to sendmail is there a utility or work around for NT???

$mailprog = '/usr/lib/sendmail';



Please mail & post replies


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

Date: Thu, 20 Nov 1997 09:34:54 GMT
From: paddy.spencer@parallax.co.uk (Paddy Spencer)
Subject: Is this an array of hashes, or what?
Message-Id: <880018434.739012@red.parallax.co.uk>

Here's the background: I have embedded comments in C source files for online
help/documentation which I extract using a perl script which writes the comments
to a help file for use on Acorn machines. The help file format is plain ascii
and the fonts are set as follows:

	This is in a proportional font {fCode}this is monospaced {fStd}this is 
	back to normal.

For a long time the script wasn't outputting the parameter names, just the types
and the descriptions. I eventually figured it out; I had:

	print HELPFILE "{fCode}$ptype[$i] $pname[$i]{fStd} $pdesc[$i]\n";

I figure it was treating $pname[$i]{fStd} as a single variable, and I suspect
(in my C mentality) that it was thinking it was an array of hashes. 

Is this right? I have to admit I laughed aloud when I found what was going
wrong...

-- 
Paddy Spencer        Parallax Solutions Ltd (http://www.parallax.co.uk/)
No-one ever said to van Gogh, "Paint 'A Starry Night' again, man!" 
                              -- Joni Mitchell



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

Date: Thu, 20 Nov 1997 10:56:42 GMT
From: adelton@fi.muni.cz (Honza Pazdziora)
Subject: Re: Is this an array of hashes, or what?
Message-Id: <adelton.880023402@aisa.fi.muni.cz>

paddy.spencer@parallax.co.uk (Paddy Spencer) writes:

> Here's the background: I have embedded comments in C source files for online
> help/documentation which I extract using a perl script which writes the comments
> to a help file for use on Acorn machines. The help file format is plain ascii
> and the fonts are set as follows:
> 
> 	This is in a proportional font {fCode}this is monospaced {fStd}this is 
> 	back to normal.
> 
> For a long time the script wasn't outputting the parameter names, just the types
> and the descriptions. I eventually figured it out; I had:
> 
> 	print HELPFILE "{fCode}$ptype[$i] $pname[$i]{fStd} $pdesc[$i]\n";
> 
> I figure it was treating $pname[$i]{fStd} as a single variable, and I suspect
> (in my C mentality) that it was thinking it was an array of hashes. 
> 
> Is this right? I have to admit I laughed aloud when I found what was going
> wrong...

Yes you are right, but it seems to me that you do not run your script
with -w or use strict;

This is my test script and what it says:

$ perl -w
use strict;
my $i = 0;
my @ptype = (3, 4);
my @pname = ("jezek", "krtek");
my @pdesc = ("d1", "d2");
print "{fCode}$ptype[$i] $pname[$i]{fStd} $pdesc[$i]\n";
__END__
Can't use string ("jezek") as a HASH ref while "strict refs" in use at - line 6.

So that way you would know immediately what the problem is.

Hope this helps,

--
------------------------------------------------------------------------
 Honza Pazdziora | adelton@fi.muni.cz | http://www.fi.muni.cz/~adelton/
                   I can take or leave it if I please
------------------------------------------------------------------------


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

Date: 20 Nov 1997 09:59:27 -0000
From: aeb@brains.cartoon.bt.co.uk (Tony Bass)
Subject: Re: Last element of an anonymous array
Message-Id: <6511lv$nce$1@brains.cartoon.bt.co.uk>

>From article <lq1iutoofxp.fsf@bmers2e5.nortel.ca>, by Mark Mielke <markm@nortel.ca>:
[...]
> In perl you can do things like:

>    $hour = (localtime)[2];

> The question as to whether you can say:

>    @all_but_first = (localtime)[1..];

> I can only say... i wish :-) In fact i tried it before in hope or something...
> but it seems the ".." operator is simply that. It's not special when "in array
> element number context" :-) The only way i know of how to do it now is:

>    @all = localtime();
>    @all_but_first = @all[1..$#all];
[...]


A way of getting all but the first three (say) elements of an anonymous
list is

   calf$ cat try2
   #! /usr/local/bin/perl
   use strict;
   print join '', map "$_\n", splice @{[map $_*$_, 1..9]}, 3;
   calf$


   calf$ try2
   16
   25
   36
   49
   64
   81
   calf$ 

though I hesitate to recommend it, much as I like functional style,
since splice is a destructively overwriting function.  In particular,
if one absent-mindedly writes

   ... splice @a, 3

on a named array then @a is changed.  To leave @a unchanged,

   ... splice @{[@a]}, 3

is needed.

    Tony Bass

-- 
# A E Bass                                      Tel: (01473) 645305
# MLB 3/19, BT Laboratories                     e-mail: aeb@saltfarm.bt.co.uk
# Martlesham Heath, Ipswich, Suffolk, IP5 7RE   DO NOT e-mail to From: line
#                                               Opinions are my own


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

Date: Sun, 16 Nov 1997 18:51:15 -0500
From: brian@mindbendr.com (Brian Mitchell)
Subject: Re: Newbie Question
Message-Id: <brian-1611971851150001@ric-33.freedomnet.com>

"Warren Smith" <warren5@earthling.net> wrote:

> I am creating a script for the net on a foreign server. I don't know the
> physical path of my directory. How do I get the actual path of the script I
> am running?

Maybe the first thing I should say is this is comp.lang.perl.misc -- and you're
talking about CGI.  Secondly, how can you upload this file without knowing
where you are on the server (foreign or not) ?  Finally, maybe you're trying
to say how do I find the path to perl:  In that case, use one of these two 
Unix commands:

which perl

whereis perl

Hope this helps -- but, you could help us lots more if you were to explain yourself
more in-depth in order for us to give you a more in-depth answer.

B R I A N    M I T C H E L L 
________________________________________________________________

 "Imagination is the eye of the soul..."
 
  -- Joseph Joubert (1754-1824)

________________________________________________________________
"Reflections of my Imagination" - http://www.esva.net/~mitchell/


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

Date: Thu, 20 Nov 1997 00:37:27 -0500
From: Bob Broad <rbroad@sprintmail.com>
Subject: Newbie, strange pop behavior?
Message-Id: <3473CC97.348BF86F@sprintmail.com>

When playing around with references to array elements I found
that the reference still refered to the element after the element
had been removed by 'pop'ing the array as in 'pop @ary'.  However,
when I did '$element = pop @ary', the reference was no longer defined.

For example:
	$test = 'ok';
#	$test = 'strange';         
	@ary = ( 'one', 'two' );
	$r_ary_el = \$ary[1];
	pop @ary if $test eq 'ok';
	$test = pop @ary if $test eq 'strange';
	print $test, \$\$r_ary_el = $$r_ary_el\n";

# Outputs  'ok, $$r_ary_el = ok'  when $test = 'ok'
# Outputs  'strange', $$r_ary_el = ' when $test ='strange'
#  and says that $$r_ary_el is no longer defined (with -w flag)

What I find confusing is the apparent side effect of different
usage of the 'pop' operator.  Is Perl trying to be helpful here
by assuming that if I save the 'pop' result that the reference
value is no longer needed.  Is this a feature or bug, or am I
missing something obvious in the test code?
	This example was inspired by Fig 1-8, p21 of the book,
"Advanced Perl Programming" by Srinivasan which seems to explain
the 'ok' test above.  I am running 5.004.01 on linux.


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

Date: Thu, 20 Nov 1997 01:02:06 -0600
From: designky <designky@sonnets.dot.com>
Subject: pass by reference? what is wrong?
Message-Id: <3473E06E.BE31EAFB@sonnets.dot.com>

i searched the  newsgroup archive and read the perl faw, and this is supposed to
work for passing by refenrence:

&ps("yes",\%aa,\%bb);

print scalar keys %aa;
print "\n $bb{rr}\n";


sub ps {
        my $f = shift;
        my %aa = %{ shift };
        my %bb = %{ shift };

        $aa{'one'} = 1;
        $aa{'two'} = 2;

        $bb{rr} = "rr";

   
        print $f, "\n";

}

However, this simple program above doesn't work.  I can't seem to be able to
pass the hashes by references.  what is wrong?  I really got frustrated by this
when it is supposed to work and not working..... 

Please enligthen me.

thanks.

 
-----------------------------------------------------------------------------
Kang Soon Lai	skang_at_nori.lips.net	| "If there is any religion that would
http://www.tisl.ukans.edu/~skang/	| cope with modern scientific needs
(913) 385 5481				| it would be Buddhism."
Software Engineer			|		--Albert Einstein


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

Date: Wed, 19 Nov 1997 22:45:30 -1000
From: "Dave Hoyt" <dshoyt@worldnet.att.net>
Subject: Re: pass by reference? what is wrong?
Message-Id: <650rr5$8vp@bgtnsc03.worldnet.att.net>

 Obviously there's more than one way to do it, but this worked for me:

#!/usr/local/bin/perl -w

callsub("yes",\%aa, \%bb);
print "$aa{one}\n$bb{two}\n";
exit 1;

sub callsub {
local(*one, *two, *three) = @_;
print "$one\n";
$two{one} = 1;
$three{two} = 2;
}
I've not used the shift, but this is how I pass by reference.  The
asterix(*) allows for all incoming and then you reference the variable like
it should.  Hope this helps!
                                                                - Dave Hoyt

designky wrote in article <3473E06E.BE31EAFB@sonnets.dot.com>...

>i searched the  newsgroup archive and read the perl faw, and this is
supposed to
>work for passing by refenrence:
>
>&ps("yes",\%aa,\%bb);
>
>print scalar keys %aa;
>print "\n $bb{rr}\n";
>
>
>sub ps {
>        my $f = shift;
>        my %aa = %{ shift };
>        my %bb = %{ shift };
>
>        $aa{'one'} = 1;
>        $aa{'two'} = 2;
>
>        $bb{rr} = "rr";
>
>
>        print $f, "\n";
>
>}
>
>However, this simple program above doesn't work.  I can't seem to be able
to
>pass the hashes by references.  what is wrong?  I really got frustrated by
this
>when it is supposed to work and not working.....
>
>Please enligthen me.
>
>thanks.
>
>
>---------------------------------------------------------------------------
--
>Kang Soon Lai skang_at_nori.lips.net | "If there is any religion that would
>http://www.tisl.ukans.edu/~skang/ | cope with modern scientific needs
>(913) 385 5481 | it would be Buddhism."
>Software Engineer | --Albert Einstein




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

Date: 20 Nov 1997 08:59:37 GMT
From: tina@scandinaviaonline.se (Tina Marie Holmboe)
Subject: Re: pass by reference? what is wrong?
Message-Id: <650u5p$h2v$5@news1.sol.no>

In article <3473E06E.BE31EAFB@sonnets.dot.com>,
	designky <designky@sonnets.dot.com> writes:

> &ps("yes",\%aa,\%bb);
> 
> print scalar keys %aa;
> print "\n $bb{rr}\n";
> 
> 
> sub ps {
>         my $f = shift;
>         my %aa = %{ shift };
>         my %bb = %{ shift };
> 
>         $aa{'one'} = 1;
>         $aa{'two'} = 2;
> 
>         $bb{rr} = "rr";
> 
>    
>         print $f, "\n";
> 
> }
> 
> However, this simple program above doesn't work.  I can't seem to be able to
> pass the hashes by references.  what is wrong?  I really got frustrated by t

  Whilst I may be missing something - it works quite nicely methinks... it
does exactly what you have told it to do: It passes a reference *in*, and
then creates an, internal, copy of the associative array referenced. This
local copy is what you modify, and when it goes out of scope, the modification
is lost. Try:



 &ps("yes",\%aa,\%bb);
 
 print scalar keys %aa;
 print "\n $bb{rr}\n";
 
 
 sub ps {
         my $f = shift;
         my $aa = shift ;
         my $bb = shift ;
 
         $aa->{'one'} = 1;
         $aa->{'two'} = 2;
 
         $bb->{rr} = "rr";
 
    
         print $f, "\n";
 
 }

 and see if that doesn't give you what you wanted.


--
 Tina Marie Holmboe                          tina@mail.scandinaviaonline.se

 The opinions expressed above are mine, and should in no way or under any
 circumstances be associated with Scandinavia Online AB unless this disclaimer
 is explicitly revoked.


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

Date: 20 Nov 1997 05:16:36 GMT
From: mosey@alpha3.csd.uwm.edu (John Mosey)
Subject: Perl Programmer needed
Message-Id: <650h3k$cvq$1@uwm.edu>

I am looking for a perl programmer to do the code for some projects I have
in mind. My site is an established fantasy baseball site (www.mosey.com).
Interest in baseball is a plus, but not required. 

The projects range from a simple poll script with a cookie (I know, that's
javascript) to a reporting network with text based databases (no Oracle
stuff). From what I know of perl, this is all possible and for the most
part fairly simple. Anyone who finshed all 28 days should be able to do
it.

I'm looking for some one who can do this as a freetime project, not a
large corperation, and who will be available in the future to upgrade
these and other projects. A freelance programmer would be the best term.
Projects would need to be ready by Jan 1, 1998.

Pay is negotable (cheaper is of course better) and if you are still in
college we could sponsor it as a paid internship.

Email if interested,

John Mosey
mosey@mosey.com



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

Date: Thu, 20 Nov 1997 00:17:46 -0500
From: Bill Guindon <billg@networkapparel.com>
Subject: Re: Perl Tutotial
Message-Id: <3473C7FA.B1FB7D4D@networkapparel.com>

I would also recommend:
http://reference.perl.com/query.cgi?tutorials+index

Casper K. Clausen wrote:

> Simon Thangasamy <r64st@morgan.ucs.mun.ca> writes:
>
> > Can anyone please tell me where I can find a Perl tutorial on the web.
>
> <URL: http://www.ncsa.uiuc.edu/General/Training/PerlIntro/whatIs.html>
>
> It's not very elaborate, but it'll get you started. Note that either
> "Learning Perl" or "Programming Perl" (both from O'Reilly books),
> depending on your prior knowledge ("Learning" for utter newbies,
> "Programming" for people who know programming and want to move to
> Perl), come highly recommended.
>
> Regards,
> Kvan.
> --
> -------Casper Kvan Clausen------ | 'Ah, Warmark, everything that passes
> ----------<ckc@dmi.dk>---------- |  unattempted is impossible.'
>            Lokal  544            |
> I do not speak for DMI, just me. |        - Lord Mhoram, Son of Variol.





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

Date: 20 Nov 1997 05:26:16 GMT
From: wib@cs.uni-kiel.de (Willi Burmeister)
Subject: Re: Year2000 problem with localtime();
Message-Id: <650hlo$877@gutemine.informatik.uni-kiel.de>

In <8ck9e4a2qz.fsf@gadget.cscaper.com> Randal Schwartz <merlyn@stonehenge.com> writes:

>>>>>> "Yen-Ming" == Yen-Ming Chen <chenym@dufu.math.ncu.edu.tw> writes:

>Yen-Ming>  In a DEC Alpha, the localtime can present up to year 2038,
>Yen-Ming> Jan. 19th, 11:14:07. So that means it(Unix) will have a
>Yen-Ming> "year 2038" problem?? :)

>Of course, this depends on what timezone you are in.  For me:

>	$ perl
>	print scalar localtime 2 ** 31 - 1;
>	^D
>	Mon Jan 18 20:14:07 2038

>So that'd be some time ahead of you. :-)

Hmm,

eden{wib} uname -a
SunOS eden 5.6 Generic sun4m sparc SUNW,SPARCstation-10

eden{wib} perl -v
This is perl, version 5.004_04 built for sun4-solaris

eden{wib} perl
print scalar localtime 2 ** 31 - 1;
^D
Fri Dec 13 21:45:51 1901
                    ^^^^
Some testing shows:

eden{wib} perl
print scalar localtime 2 ** 31 - 3600;
^D
Fri Dec 13 20:45:52 1901

eden{wib} perl
print scalar localtime 2 ** 31 - 3601;
^D
Tue Jan 19 03:14:07 2038

a Bug?

Willi





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

Date: 20 Nov 1997 08:27:58 GMT
From: tina@scandinaviaonline.se (Tina Marie Holmboe)
Subject: Re: Year2000 problem with localtime();
Message-Id: <650sae$h2v$3@news1.sol.no>

In article <8ck9e4a2qz.fsf@gadget.cscaper.com>,
	Randal Schwartz <merlyn@stonehenge.com> writes:

> 	$ perl
> 	print scalar localtime 2 ** 31 - 1;
> 	^D
> 	Mon Jan 18 20:14:07 2038

  Iiiiinteresting indeed:


Script started on Thu Nov 20 09:26:11 1997
malt ~>	perl
print scalar localtime 2 ** 31 - 1;
Fri Dec 13 21:45:51 1901
malt ~>exit

script done on Thu Nov 20 09:26:21 1997



> So that'd be some time ahead of you. :-)

  Well, I'd better start planning *my* retirement rather quickly >:)

--
 Tina Marie Holmboe                          tina@mail.scandinaviaonline.se

 The opinions expressed above are mine, and should in no way or under any
 circumstances be associated with Scandinavia Online AB unless this disclaimer
 is explicitly revoked.


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

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

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