[9568] in Perl-Users-Digest

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

Perl-Users Digest, Issue: 3162 Volume: 8

daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Wed Jul 15 11:27:13 1998

Date: Wed, 15 Jul 98 07:01:44 -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           Wed, 15 Jul 1998     Volume: 8 Number: 3162

Today's topics:
        "reset" does not work ?! <jak@tx1.elex.co.il>
    Re: -w on production code (was Re: better way of gettin <John.Adams@BentonvilleAR.ncr.com>
    Re: a foreach within a foreach? (Bart Lateur)
        AWK Interpreter <irisbeau@wolsi.com>
    Re: AWK Interpreter <Eric.Zylberstejn@wanadoo.com>
    Re: Dump a GUI to /dev/null on SGI workstation merzky@physik.hu-berlin.de
        Editing files tim221175@my-dejanews.com
    Re: Editing files (Real)
    Re: Editing files <Eric.Zylberstejn@wanadoo.com>
        graphic production <Tootedom@exchange.ch.ml.com>
    Re: graphic production <Eric.Zylberstejn@wanadoo.com>
    Re: Help! MacPerl and STDIN (Chris Nandor)
    Re: inconstant behavior of constants <jdf@pobox.com>
        Keeping the layout of a database separately? <horowitz@ulb.ac.be>
    Re: Midnight Oil reference in Perl book? <tjchamberlain@hotmail.com>
    Re: module help <Eric.Zylberstejn@wanadoo.com>
        Net::Netmask problem <bross@mindspring.net>
        passing variables by reference <matalon@jouy.inra.fr>
    Re: passing variables by reference (David A. Black)
    Re: passing variables by reference <Eric.Zylberstejn@wanadoo.com>
    Re: passing variables by reference <quednauf@nortel.co.uk>
    Re: Regular expression matech for ( non-fixed number of (Al Aab)
        Remote registry editing on NT (Zach Maxwell)
    Re: Remote registry editing on NT <nguyend7@egr.msu.edu>
    Re: Sticking in NULL after split (David Alan Black)
        Working with Frame <R.Sukhahuta@uea.ac.uk>
        Special: Digest Administrivia (Last modified: 12 Mar 98 (Perl-Users-Digest Admin)

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

Date: Wed, 15 Jul 1998 13:06:14 GMT
From: Yakov Yukhnovetsky <jak@tx1.elex.co.il>
Subject: "reset" does not work ?!
Message-Id: <Pine.HPP.3.96.980715155837.3667U-100000@tlprh22>


Hi!

I perform several sequential pattern searches, OK.
 .
 .
$_  = "1111  fffffff 7777777777 jjjjjjjjjjjj";

# the first search:
/(\d+)\s+(\w+)\s+(.+)/;
print "$1\n$2\n$3\n\n";

# the second one:
/(\d+)\s+(RRR)(\w+)\s+(.+)/;
print "$1\n$2\n$3\n";
 .
 .
 .


Obviously, the second search will fail, but $1, $2 and $3 are still exist from
the first search.

"reset" does not help. (so "undef" does not).

I have to put each search into {} block. The scope of $1, $2 and so on variable
is within their {} block. But, this way, perl program looks weird.

What's wrong with reset I use ?

Thanks.

 ___________________________________________________________
|===========================================================|
|             Shalom,                                       |
|    __/\__       Yakov Yukhnovetsky <jak@cpm.elex.co.il>   |
|   `\/~~\/'                          (972)-8-9134415 (w)   |
|    /\__/\                           (972)-8-9134410 (fax) |
|   `~~\/~~'                          (972)-8-9350527 (h)   |
| Telrad Telecommunications and Electronic Industries Ltd.  | 
|===========================================================|
 -----------------------------------------------------------



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

Date: Wed, 15 Jul 1998 08:36:11 -0500
From: John Adams <John.Adams@BentonvilleAR.ncr.com>
Subject: Re: -w on production code (was Re: better way of getting the last modified file?)
Message-Id: <35ACB04B.363A@BentonvilleAR.ncr.com>

Abigail wrote:

> The fact that an upgrade of perl might emit new warnings is a *GOOD*
> reason to keep -w on production code. What do you customers prefer if
> their sysadmins upgrade Perl? Warnings, or silently going on, perhaps
> producing wrong results, or even stop working all together on the next
> upgrade of Perl?

And the SYSADMIN is the person who needs the incoming emails of the -w
warnings. Abigail kinda implies that but, really, why hasn't anyone else
pointed that out? Am I missing something here? (Other than needing to
configure so that others can get those emails as well--for instance, if
you've got problems with DBD or DBI, it'd might be nice to email your
friendly neighborhood dba.)

And, while I'd be distressed to find that my Perl was emailing someone
_without_ my permission, I could be easily, happily persuaded to let it
email _some_ people _with_ my explicit permission--like perlbug does.

	John A
	...who is proud to speak for his employer, when he does, which he isn't
right now


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

Date: Wed, 15 Jul 1998 11:25:13 GMT
From: bart.mediamind@tornado.be (Bart Lateur)
Subject: Re: a foreach within a foreach?
Message-Id: <35af8e4c.5455041@news.tornado.be>

I can count only one foreach. Is that your problem?

Darrick Wolfe wrote:

>		foreach $line (@chat){
>			@checkig = split(/ /,$line);
>			if($checkig[0] eq "<B>$gone[0]:</B>"){

You want to check every item in @checkig? Then try something like this:

	foreach $line (@chat){
		@checkig = split(/ /,$line);
		foreach $checkig (@checkig) {
			if($checkig eq "<B>$gone[0]:</B>"){
				# ...
			}
		}
	}



HTH,
Bart.


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

Date: Tue, 14 Jul 1998 05:44:41 -0700
From: "David Reynolds" <irisbeau@wolsi.com>
Subject: AWK Interpreter
Message-Id: <6oi40u$7ea$1@news.wolsi.com>

I am learning Perl and have have programmed a great deal in AWK.  I was
looking for a perl program that converted AWK code to Perl.  I would like to
see the differences between the two.


David




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

Date: Wed, 15 Jul 1998 14:33:19 +0200
From: Eric Zylberstejn <Eric.Zylberstejn@wanadoo.com>
To: David Reynolds <irisbeau@wolsi.com>
Subject: Re: AWK Interpreter
Message-Id: <35ACA18F.2997D9D@wanadoo.com>

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

Hello.

David Reynolds wrote:
> 
> I am learning Perl and have have programmed a great deal in AWK.  I was
> looking for a perl program that converted AWK code to Perl.  I would like to
> see the differences between the two.

It's a2p. It's part of the standard Perl distribution. Unfortunately, this is
program, and the produced Perl is not the best you can write.
I'd rather rewrite from scratch than use a2p. Especially since you can control
how you read lines in Perl.


	Eric
--------------AC7D1922FBA4B831EA403684
Content-Type: text/x-vcard; charset=us-ascii; name="vcard.vcf"
Content-Transfer-Encoding: 7bit
Content-Description: Card for Zylberstejn, Eric
Content-Disposition: attachment; filename="vcard.vcf"

begin:          vcard
fn:             Eric Zylberstejn
n:              Zylberstejn;Eric
org:            FTI
adr:            41 r Camille Desmoulins;;;Issy-les-Moulineaux;;92130;France
email;internet: Eric.Zylberstejn@wanadoo.com
tel;work:       01 41 33 94 59
x-mozilla-cpt:  ;0
x-mozilla-html: FALSE
version:        2.1
end:            vcard


--------------AC7D1922FBA4B831EA403684--



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

Date: Wed, 15 Jul 1998 12:46:46 GMT
From: merzky@physik.hu-berlin.de
Subject: Re: Dump a GUI to /dev/null on SGI workstation
Message-Id: <6oi8bm$arf$1@nnrp1.dejanews.com>

In article <35AC6C2A.4058DB00@iet.mavt.ethz.ch>,
  Butty Vincent <butty@iet.mavt.ethz.ch> wrote:
> Hi,
>
> As my knowledge of Perl is not so deep, I need some help from you. Here
> is my problem:
>
> I want to use Perl in order to call a program with the system() or
> exec() command, but I want to dump the graphic interface of this program
> to /dev/null for security problem.
>
> I try to redirect the STDOUT and STDERR to /dev/null but the GUI still
> appears.
>
> If somebody has an idea how to dump the GUI to /dev/null using Perl, I
> would be glad to get some tips.
>
> Thanks,
>
> Vincent Butty

Usually you cannot send a GUI to /dev/null. It is nothing like data stream
to move around. A solution would be to set the display to an invalid
value: "setenv DISPLAY non.existing.host:0", but the program very
likely is designed to detect this and not to run at all.

Another ugly method which works for *some* programs is to place them off
screen. Some windows managers allow you to place a window at certain
coordinates. If these are outside of you actually valid screen, you at
least do not see the gui, and cfannot interact with it. But: only some
Windows Managers support this, AND: there are usually some ways to get
this window on screen, anyway.

Hmm, I know this does not help at all. ;-)
Anyway... - cheers, Andre.

--
Andre Merzky
pinocchio@earthling.net
http://pino.home.pages.de/

-----== Posted via Deja News, The Leader in Internet Discussion ==-----
http://www.dejanews.com/rg_mkgrp.xp   Create Your Own Free Member Forum


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

Date: Wed, 15 Jul 1998 12:23:45 GMT
From: tim221175@my-dejanews.com
Subject: Editing files
Message-Id: <6oi70h$8u9$1@nnrp1.dejanews.com>

 Is there an easy way of editing a file. I want to append a line of text in
the middle of a text file. Will I have to cut the file in two halves and then
concatenate them with new line in the middle or is there an easy way to do
this in perl?


-----== Posted via Deja News, The Leader in Internet Discussion ==-----
http://www.dejanews.com/rg_mkgrp.xp   Create Your Own Free Member Forum


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

Date: Wed, 15 Jul 1998 14:49:56 +0200
From: real@earthling.net (Real)
Subject: Re: Editing files
Message-Id: <MPG.1016c3dc3bf9e9499896b2@news.surfnet.nl>

tim221175@my-dejanews.com wrote;
>  Is there an easy way of editing a file. I want to append a line of text in
> the middle of a text file. Will I have to cut the file in two halves and then
> concatenate them with new line in the middle or is there an easy way to do
> this in perl?

Yes it is possible but you'll have to specify 'the middle of a text 
file'. Is this after a certain number of lines, etc, etc, ?  Once this is 
determined, a simple Perl script can do something like;

  - read (next) line of file #1
  - middle of file encountered ?   if yes: write extra line
  - write line of file #1

Cheers,
Real


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

Date: Wed, 15 Jul 1998 14:54:58 +0200
From: Eric Zylberstejn <Eric.Zylberstejn@wanadoo.com>
To: tim221175@my-dejanews.com
Subject: Re: Editing files
Message-Id: <35ACA6A2.C53586AD@wanadoo.com>

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

Hello,

tim221175@my-dejanews.com wrote:
> 
>  Is there an easy way of editing a file. I want to append a line of text in
> the middle of a text file. Will I have to cut the file in two halves and then
> concatenate them with new line in the middle or is there an easy way to do
> this in perl?

I'd use Perl's -i and -p options.

To add one line, you just need :

print "a new line in between\n" if some_condition;

For example this program inserts a new line in second position :
#! /usr/local/progs/gnu/bin/perl -w -pi
print "a new line\n" if $. == 2;

	Eric
--------------7F4847A121581F397E34B0F7
Content-Type: text/x-vcard; charset=us-ascii; name="vcard.vcf"
Content-Transfer-Encoding: 7bit
Content-Description: Card for Zylberstejn, Eric
Content-Disposition: attachment; filename="vcard.vcf"

begin:          vcard
fn:             Eric Zylberstejn
n:              Zylberstejn;Eric
org:            FTI
adr:            41 r Camille Desmoulins;;;Issy-les-Moulineaux;;92130;France
email;internet: Eric.Zylberstejn@wanadoo.com
tel;work:       01 41 33 94 59
x-mozilla-cpt:  ;0
x-mozilla-html: FALSE
version:        2.1
end:            vcard


--------------7F4847A121581F397E34B0F7--



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

Date: Wed, 15 Jul 1998 03:03:34 +0200
From: Dominid Tootell <Tootedom@exchange.ch.ml.com>
Subject: graphic production
Message-Id: <35ABFFE6.58F2@exchange.ch.ml.com>

hey there

I need some serious help.

Does anybody have any clues on the following problem.

I have a list of numbers in an ascii text file, which I want to pass to
a cgi script, which will then convert these numbers into a graphic that
I can view on my web browser, by grapic I mean chart, graph.

the help is much appreciated

Dominic

please mail me at:-

tootedom@exchange.ch.ml.com


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

Date: Wed, 15 Jul 1998 13:50:13 +0200
From: Eric Zylberstejn <Eric.Zylberstejn@wanadoo.com>
To: Tootedom@exchange.ch.ml.com
Subject: Re: graphic production
Message-Id: <35AC9775.4C225B02@wanadoo.com>

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

Hello,

Dominid Tootell wrote:
> I have a list of numbers in an ascii text file, which I want to pass to
> a cgi script, which will then convert these numbers into a graphic that
> I can view on my web browser, by grapic I mean chart, graph.

Take a look at :
http://reference.perl.com/query.cgi?graphics

Visit http://reference.perl.com/ regularly, you'll find interesting things
there.

	Eric
--------------CD1B38BE43A16E55340F8F36
Content-Type: text/x-vcard; charset=us-ascii; name="vcard.vcf"
Content-Transfer-Encoding: 7bit
Content-Description: Card for Zylberstejn, Eric
Content-Disposition: attachment; filename="vcard.vcf"

begin:          vcard
fn:             Eric Zylberstejn
n:              Zylberstejn;Eric
org:            FTI
adr:            41 r Camille Desmoulins;;;Issy-les-Moulineaux;;92130;France
email;internet: Eric.Zylberstejn@wanadoo.com
tel;work:       01 41 33 94 59
x-mozilla-cpt:  ;0
x-mozilla-html: FALSE
version:        2.1
end:            vcard


--------------CD1B38BE43A16E55340F8F36--



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

Date: Wed, 15 Jul 1998 12:05:52 GMT
From: pudge@pobox.com (Chris Nandor)
Subject: Re: Help! MacPerl and STDIN
Message-Id: <pudge-1507980805230001@dynamic186.ply.adelphia.net>

In article <35a91098.0@news2.lightlink.com>, schissel@adore.lightlink.com
(Eric Schissel) wrote:

# Perl5 for Dummies has a page on how to create a dialog box in MacPerl (a
# simple open box or a simple save box).  I could check my own files for an
# example and send it along by email, if you want (email me if you need it).

Yeah, but why would you buy that book, when it is wrong in so many places?

Further, there is a perfectly good MacPerl book available for stuff like
that.  :-)

-- 
Chris Nandor          mailto:pudge@pobox.com         http://pudge.net/
MacPerl: Power and Ease (ISBN 1881957322), http://www.ptf.com/macperl/
%PGPKey = ('B76E72AD', [1024, '0824090B CE73CA10  1FF77F13 8180B6B6'])


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

Date: 15 Jul 1998 09:33:54 -0500
From: Jonathan Feinberg <jdf@pobox.com>
To: miko@idocs.com
Subject: Re: inconstant behavior of constants
Message-Id: <ogur420d.fsf@mailhost.panix.com>

miko@idocs.com writes:

> I'm having a hard time understanding some of the details in using
> constants in Perl.  The behavior that is most perplexing is when the
> constant is used as a key in an asociative array.  In that situation
> the constant's name is used instead of the constant's value.

That's as documented in perldata:

  As in some shells, you can put curly brackets around the name to
  delimit it from following alphanumerics.  In fact, an identifier
  within such curlies is forced to be a string, as is any single
  identifier within a hash subscript. Our earlier example,

     $days{'Feb'}

  can be written as

     $days{Feb}

  and the quotes will be assumed automatically. But anything more
  complicated in the subscript will be interpreted as an expression.


Here's an example of how to get around it:

   use constant C => 'foo';
   $h{C} = 'C here';
   $h{foo} = 'foo here';
   print $h{C},"\n";
   print $h{+C},"\n";
   print $h{C()},"\n";
   print $h{&C},"\n";


But why aren't you just keying the hash (note, they're called
"hashes", not "associative  arrays") off those strings, rather than
those wacky negative numbers?

  $thing{startyear} = 1984;

You should

   C:\> perldoc perldata
   C:\> perldoc constant

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


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

Date: Wed, 15 Jul 1998 13:19:51 GMT
From: Joel Horowitz <horowitz@ulb.ac.be>
Subject: Keeping the layout of a database separately?
Message-Id: <6oia9n$d8n$1@nnrp1.dejanews.com>

Hye,
I'm developping a small website which will use CGI programming in Perl,
and will access a Mysql database.

    My main purpose is to write an efficient (i.e. fast) program that
will parse a html-page that contains information lines like this

(html code ... )
(html code ... )
<!-- TABLE
$database="mydatabase"
$table="customers"
$layout="<TR><TD>$NAME</TD><TD>$TEL</TD></TR>"
-->
(html code ... )
(html code ... )

I want my program to fetch the data from a database and create a
html-table whose rows are in the format given by $layout (i.e. replace
$NAME by the value of the NAME field, etc...). The purpose of all this is to
enable a non-programmer to change the layout of the table, and to choose
the fields he wants to see, without needing to touch my perl code.

    I thought about the following possibilities:

    - doing a s/ / / operation on $layout for every row in the database
    - using something like Text::Template

    Those two possibilities seem a little too slow, because a regexp
operation must be done for each row of incoming data... (not to forget
that I'm running this on a Webserver, and that many people might query
the server at the same time, so performance is critical).

  - replace the syntax of $layout by something that can be used by my script
quicker.  - create a procedure 'create_replace_sub' that takes "$layout" as
argument, and returns "an anonymous subroutine that does the replacements".
For instance:

  $layout = "<TR><TD>$NAME</TD><TD>$TEL</TD></TR>";
==>  create_replace_sub($layout) =
     sub { my %parms = @_;
	   my $output;
	   $output =
             '<TR><TD>'.$parms{'NAME'}.'</TD><TD>'.$parms{'TEL'}.'</TD></TR>';
	   return $output;
         }

     - use something like PHP?

     Does anybody have a suggestion for doing this, with the best
possible performance speed?

	 Thanks


-----== Posted via Deja News, The Leader in Internet Discussion ==-----
http://www.dejanews.com/rg_mkgrp.xp   Create Your Own Free Member Forum


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

Date: Wed, 15 Jul 1998 21:02:17 +1000
From: Toby Chamberlain <tjchamberlain@hotmail.com>
Subject: Re: Midnight Oil reference in Perl book?
Message-Id: <35AC8C39.223F5A64@hotmail.com>




> Americans probably still learn that bit of patriotism in elementary
> school.  But I see you are Australian, so all is forgiven. :-)
>

And a queenslander what's worse :)



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

Date: Wed, 15 Jul 1998 13:55:18 +0200
From: Eric Zylberstejn <Eric.Zylberstejn@wanadoo.com>
To: Matt Eckhaus <matt2@lonelyplanet.com.au>
Subject: Re: module help
Message-Id: <35AC98A6.A049CFF2@wanadoo.com>

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

Hello,

Matt Eckhaus wrote:
> Does it cause each module to be loaded twice?
No. 'Use' is smarter than #include.

Seems your modules are really tied. Usually, it's bad practice to have
interdependant modules because they are really hard to test. You cannot test
one without the other and if something fails, you're not sure which module is
wrong. Tied modules hinder unit testing.

	Eric
--------------13A9AE502FC58A0BA40A3E97
Content-Type: text/x-vcard; charset=us-ascii; name="vcard.vcf"
Content-Transfer-Encoding: 7bit
Content-Description: Card for Zylberstejn, Eric
Content-Disposition: attachment; filename="vcard.vcf"

begin:          vcard
fn:             Eric Zylberstejn
n:              Zylberstejn;Eric
org:            FTI
adr:            41 r Camille Desmoulins;;;Issy-les-Moulineaux;;92130;France
email;internet: Eric.Zylberstejn@wanadoo.com
tel;work:       01 41 33 94 59
x-mozilla-cpt:  ;0
x-mozilla-html: FALSE
version:        2.1
end:            vcard


--------------13A9AE502FC58A0BA40A3E97--



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

Date: Wed, 15 Jul 1998 04:21:06 -0400
From: Brandon Ross <bross@mindspring.net>
Subject: Net::Netmask problem
Message-Id: <35AC6672.5569A312@mindspring.net>

I'm trying to use the Net::Netmask module that I just got from CPAN, and
if I so much as

perl -e "use Net::Netmask"

It does this:

Global symbol "i" requires explicit package name at
/usr/local/lib/site_perl/Net/Netmask.pm line 122.
Variable "$i" is not imported at /usr/local/lib/site_perl/Net/Netmask.pm
line 122.
Global symbol "i" requires explicit package name at
/usr/local/lib/site_perl/Net/Netmask.pm line 122.
Variable "$i" is not imported at /usr/local/lib/site_perl/Net/Netmask.pm
line 123.
Global symbol "i" requires explicit package name at
/usr/local/lib/site_perl/Net/Netmask.pm line 123.
Variable "$i" is not imported at /usr/local/lib/site_perl/Net/Netmask.pm
line 136.
Global symbol "i" requires explicit package name at
/usr/local/lib/site_perl/Net/Netmask.pm line 136.
Variable "$i" is not imported at /usr/local/lib/site_perl/Net/Netmask.pm
line 136.
Global symbol "i" requires explicit package name at
/usr/local/lib/site_perl/Net/Netmask.pm line 136.
Variable "$i" is not imported at /usr/local/lib/site_perl/Net/Netmask.pm
line 137.
Global symbol "i" requires explicit package name at
/usr/local/lib/site_perl/Net/Netmask.pm line 137.
Variable "$i" is not imported at /usr/local/lib/site_perl/Net/Netmask.pm
line 214.
Global symbol "i" requires explicit package name at
/usr/local/lib/site_perl/Net/Netmask.pm line 214.
Variable "$i" is not imported at /usr/local/lib/site_perl/Net/Netmask.pm
line 214.
Global symbol "i" requires explicit package name at
/usr/local/lib/site_perl/Net/Netmask.pm line 214.
Variable "$i" is not imported at /usr/local/lib/site_perl/Net/Netmask.pm
line 215.
Global symbol "i" requires explicit package name at
/usr/local/lib/site_perl/Net/Netmask.pm line 215.
Variable "$i" is not imported at /usr/local/lib/site_perl/Net/Netmask.pm
line 215.
Global symbol "i" requires explicit package name at
/usr/local/lib/site_perl/Net/Netmask.pm line 215.
Variable "$i" is not imported at /usr/local/lib/site_perl/Net/Netmask.pm
line 216.
Global symbol "i" requires explicit package name at
/usr/local/lib/site_perl/Net/Netmask.pm line 216.
Variable "$i" is not imported at /usr/local/lib/site_perl/Net/Netmask.pm
line 216.
Global symbol "i" requires explicit package name at
/usr/local/lib/site_perl/Net/Netmask.pm line 216.
 at -e line 1.
BEGIN failed--compilation aborted at -e line 1.

While I can diagnose simple perl problems, this one is a bit out of my
league.  Any help would be appreciated, cc's to email would also be
appreciated since I don't normally read this group.  TIA

Brandon Ross


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

Date: Wed, 15 Jul 1998 11:51:08 +0200
From: Cyril Matalon <matalon@jouy.inra.fr>
Subject: passing variables by reference
Message-Id: <35AC7B8C.7C56@jouy.inra.fr>

I have a little problem with this simple example :

sub test1 
{
    local (\@liste1,\@liste2) = @_;

    shift (@liste1);
}


@liste1 = ('un','deux','trois');
@liste2 = ('quatre','cinq','six');

&test1 (\@liste1,\@liste2);

print join ('--',@liste1)."\n";
print join ('--',@liste2)."\n";

result :
deux--trois
quatre--cinq--six


I would like that the list @list1 don't been modified, is there a
solution ?


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

Date: Wed, 15 Jul 1998 08:27:04 EDT
From: dblack@saturn.superlink.net (David A. Black)
Subject: Re: passing variables by reference
Message-Id: <6oi76o$dm7$1@earth.superlink.net>

Hello -

Cyril Matalon <matalon@jouy.inra.fr> writes:

>I have a little problem with this simple example :

>sub test1 
>{
>    local (\@liste1,\@liste2) = @_;

>    shift (@liste1);
>}


>@liste1 = ('un','deux','trois');
>@liste2 = ('quatre','cinq','six');

>&test1 (\@liste1,\@liste2);

>print join ('--',@liste1)."\n";
>print join ('--',@liste2)."\n";

>result :
>deux--trois
>quatre--cinq--six


>I would like that the list @list1 don't been modified, is there a
>solution ?

Remove the shift() statement, maybe?

Actually, what you probably want to do is something like this:

sub test1 {
   my ($ref1, $ref2) = @_;
   my @lcopy1 = @$ref1;    # create a copy of the original list
   shift @lcopy1;          # now the original @liste1 is not involved
}


David Black
dblack@saturn.superlink.net


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

Date: Wed, 15 Jul 1998 14:46:14 +0200
From: Eric Zylberstejn <Eric.Zylberstejn@wanadoo.com>
To: Cyril Matalon <matalon@jouy.inra.fr>
Subject: Re: passing variables by reference
Message-Id: <35ACA496.9CF1B213@wanadoo.com>

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

Hello,
Cyril Matalon wrote:
> 
> sub test1
> {
>     local (\@liste1,\@liste2) = @_;
> 
>     shift (@liste1);
> }
> 
> @liste1 = ('un','deux','trois');
> @liste2 = ('quatre','cinq','six');
> 
> &test1 (\@liste1,\@liste2);
> 
> print join ('--',@liste1)."\n";
> print join ('--',@liste2)."\n";
> 
> result :
> deux--trois
> quatre--cinq--six
> 
> I would like that the list @list1 don't been modified, is there a
> solution ?

I think you cannot avoid copying the lists in the subroutine. Try :
sub test1 
{
    my ($refListe1, $refListe2) = @_;
    my @liste1 = @$refListe1;
    
    shift (@liste1);
}


@liste1 = ('un','deux','trois');
@liste2 = ('quatre','cinq','six');

test1 (\@liste1,\@liste2);

$" = '--';
print "@liste1\n";
print "@liste2\n";


Incidentally, you don't need to use join() to print a list, set the $" variable
instead.

	Eric
--------------1508551676A27C8DCFC2D130
Content-Type: text/x-vcard; charset=us-ascii; name="vcard.vcf"
Content-Transfer-Encoding: 7bit
Content-Description: Card for Zylberstejn, Eric
Content-Disposition: attachment; filename="vcard.vcf"

begin:          vcard
fn:             Eric Zylberstejn
n:              Zylberstejn;Eric
org:            FTI
adr:            41 r Camille Desmoulins;;;Issy-les-Moulineaux;;92130;France
email;internet: Eric.Zylberstejn@wanadoo.com
tel;work:       01 41 33 94 59
x-mozilla-cpt:  ;0
x-mozilla-html: FALSE
version:        2.1
end:            vcard


--------------1508551676A27C8DCFC2D130--



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

Date: Wed, 15 Jul 1998 14:16:23 +0100
From: "F.Quednau" <quednauf@nortel.co.uk>
Subject: Re: passing variables by reference
Message-Id: <35ACABA7.E8449527@nortel.co.uk>

Cyril Matalon wrote:
> 
> I have a little problem with this simple example :
> 
> sub test1
> {
>     local (\@liste1,\@liste2) = @_;
> 
>     shift (@liste1);
> }
> 
> @liste1 = ('un','deux','trois');
> @liste2 = ('quatre','cinq','six');
> 
> &test1 (\@liste1,\@liste2);
> 
> I would like that the list @list1 don't been modified, is there a
> solution ?

What interests me is why you would like to do that. If you wanted the
first element of the array for something you could just say:

sub first
 {
     my ($lref1, $lref2) = @_;
     return $$lref1[0];
 }

@liste1 = ('un','deux','trois');
@liste2 = ('quatre','cinq','six');

print first(\@liste1, \@liste2);


-- 
____________________________________________________________
Frank Quednau               
http://www.surrey.ac.uk/~me51fq
________________________________________________


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

Date: Wed, 15 Jul 1998 10:57:13 GMT
From: af137@torfree.net (Al Aab)
Subject: Re: Regular expression matech for ( non-fixed number of () pairs )?
Message-Id: <Ew4uFD.571.0.queen@torfree.net>

to  master      regular  expressions         
to  master      sed                          
join my         seders  informal  email  list

-- 
=-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-
al aab, seders moderator                                      sed u soon 
               it is not zat we do not see the  s o l u t i o n          
-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-+


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

Date: 15 Jul 1998 12:48:22 GMT
From: maxwelzy@email.uc.edu (Zach Maxwell)
Subject: Remote registry editing on NT
Message-Id: <6oi8em$2pr@mailgate.lexis-nexis.com>

Does anyone have a slick way to do remote registry manipulation
in PERL scripting?

Zach



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

Date: 15 Jul 1998 13:53:47 GMT
From: Dan Nguyen <nguyend7@egr.msu.edu>
Subject: Re: Remote registry editing on NT
Message-Id: <6oic9b$19d$1@msunews.cl.msu.edu>

Zach Maxwell <maxwelzy@email.uc.edu> wrote:
: Does anyone have a slick way to do remote registry manipulation
: in PERL scripting?

: Zach

Wouldn't that be a security violation.  Is it over the internet, or a network?

-- 
Dan Nguyen                         |
nguyend7@cse.msu.edu               |   I am Grey.
http://www.cps.msu.edu/~nguyend7   |   



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

Date: 15 Jul 1998 09:34:18 -0400
From: dblack@pilot.njin.net (David Alan Black)
Subject: Re: Sticking in NULL after split
Message-Id: <6oib4q$q39$1@pilot.njin.net>

merzky@physik.hu-berlin.de writes:

>A simple workaround would be:
>(for all vars, you could use a field here...)

>@vars = split (/:/);
>foreach $var (@vars) {
>   unless (defined ($var)) {
>      $var = "NULL";
>}

>#... stick them togethsr:
>$outstring = join (/,/, @vars);


That doesn't compile (missing }) - also, see Larry's point about
empty split()-resultant fields being nonetheless defined.


David Black
dblack@pilot.njin.net (or whatever)


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

Date: Wed, 15 Jul 1998 14:11:45 +0100
From: Rattasit Sukhahuta <R.Sukhahuta@uea.ac.uk>
Subject: Working with Frame
Message-Id: <35ACAA91.112C061@uea.ac.uk>

Is there a perl command to send an output to different frame?  The
problem that I have is when I use the following command,

print "Content-type: text/html\n\n";
 print "<html><head><title>Error Page</title></head>\n";
 print "<center><font color=\"#8000FF\" size=+3>Error
Page</font></center><br>\n";
 print "<body>\n";
 print "<font size=+2>$str</font><br>\n";
 print "</body></html>\n";

it always send back to the first frame.  What I want to do is to send
the error message to a different frame.

Thanks.




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

Date: 12 Jul 98 21:33:47 GMT (Last modified)
From: Perl-Request@ruby.oce.orst.edu (Perl-Users-Digest Admin) 
Subject: Special: Digest Administrivia (Last modified: 12 Mar 98)
Message-Id: <null>


Administrivia:

Special notice: in a few days, the new group comp.lang.perl.moderated
should be formed. I would rather not support two different groups, and I
know of no other plans to create a digested moderated group. This leaves
me with two options: 1) keep on with this group 2) change to the
moderated one.

If you have opinions on this, send them to
perl-users-request@ruby.oce.orst.edu. 


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

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