[7270] in Perl-Users-Digest

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

Perl-Users Digest, Issue: 894 Volume: 8

daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Wed Aug 20 12:07:23 1997

Date: Wed, 20 Aug 97 09:00:26 -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, 20 Aug 1997     Volume: 8 Number: 894

Today's topics:
     Re: another regex <sfairey@adc.metrica.co.uk>
     Re: Can You Title Case A String ?. <tom@mitra.phys.uit.no>
     Re: Chars into Array <merlyn@stonehenge.com>
     Re: Field Length <jpm@iti-oh.com>
     Germany_Colonge needs help... Path conflict ! <nc-werneral@netcologne.de>
     Re: Hailp!  Hailp! <tw36027@glaxowellcome.com>
     Re: HELP with script <mattrope@mdhost.cse.tek.com>
     Re: Help:Can't find Config.pm <erhmiru@erh.ericsson.se>
     How can I make this CGI script work <jmisiris@de.ibm.com>
     Re: How do I create a directory and then create a direc <jefpin@bergen.org>
     Re: How do I create a directory and then create a direc <clark@s3i.com>
     Re: How to Wrap long lines?? (Novice) <jpm@iti-oh.com>
     Re: Is there a perl IDE? (Daniel Bruce Lynes)
     Re: Is there a perl IDE? (Brian Wheeler)
     Re: naming arrays (Andrew M. Langmead)
     Re: naming arrays <arv@fcee.urv.es>
     Re: Number conversion help (Bart Lateur)
     Re: Passing multiple arrays to subroutine ??? <tw36027@glaxowellcome.com>
     Re: Passing multiple arrays to subroutine ??? <arv@fcee.urv.es>
     Re: Perl Win95 (Nic Gibson)
     Re: Perl Win95 <susan@graygraham.com>
     Re: readig a file into an array <arv@fcee.urv.es>
     Reading a string, splitting it, and using it <temp.ed.vanderbush@bentley.com>
     Right shift (">>") in 5.00401 <prt@Teleglobe.CA>
     Systems Architect Needed <cgaston@lds.com>
     Digest Administrivia (Last modified: 8 Mar 97) (Perl-Users-Digest Admin)

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

Date: Wed, 20 Aug 1997 11:56:07 +0100
From: Simon Fairey <sfairey@adc.metrica.co.uk>
To: Greg Land <gland@ccs.neu.edu>
Subject: Re: another regex
Message-Id: <33FACD47.15FB@adc.metrica.co.uk>

Greg Land wrote:
> 
> Ok... once again I am faced with a few lines of code and my problem
> is dealing with regexes.  I have a section that looks like this:
> 
> <TR>
>       <TD>
>          <P><CENTER>1995</CENTER>
>       </TD><TD>
>          <P>some, one
>       </TD><TD>
>          <P>Someone@somewhere.com
>       </TD></TR>
> <TR>
> 
> What I need is to make it look like this:
> <TR>
>       <TD>
>          <P><CENTER>1995</CENTER>
>       </TD><TD>
>          <P>some, one
>       </TD><TD>
>          <P><a href="Someone@somewhere.com">Someone@somewhere.com</a>
>       </TD></TR>
> <TR>
> 
> Any help would be apperaciated.
> 
>                                         Thanks in advance
>                                              Greg

Assuming you are always looking for x@y then how about:

$line =~ s#<P>(.*?@.*)#<P><a href="$1">$1</a>#;

Its very simple so if it matches things you don't want to you will have
to tighten it up a bit.

Simon


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

Date: 20 Aug 1997 11:28:20 +0000
From: Tom Grydeland <tom@mitra.phys.uit.no>
Subject: Re: Can You Title Case A String ?.
Message-Id: <nqo7mdh9jqj.fsf@mitra.phys.uit.no>


> Andy Marr wrote:
> > I have a string "THIS IS A STRING" and I want to
> > format it to "This Is A String". (Cap at the start of each word).

Shawn Gordon <sgordon@athena.lbl.gov> writes:
> How about:
> 
> #!/usr/bin/perl
> $string = "THIS IS A TEST";
>  
> $string =~ s/\b(\w+)\b/"\L\u$1"/eg;
> print $string,"\n";

This is a beautiful solution to the posed question.  I have a few
improvements to offer:

You don't need the second \b word end anchor, the greediness of + will
make sure you get as much as you can, leaving a \w\W at the end of the
match, with the \w in the matched part and the \W outside it.  Keeping
it shouldn't hurt, though.

You don't need the quotes, the substitution part is already a
double-quoted string.

As a matter of taste I tend to prefer \u\L over \L\u.  This is of no
consequence whatsoever.

> The /e switch evaluates everything in the replacement string as
> a perl expression.

This is unnecessary, since you don't have anything there that needs
evaluation.

Your elegant solution then becomes

$string =~ s/\b(\w+)/\u\L$1/g;

(tested)

> Shawn

-- 
//Tom Grydeland <Tom.Grydeland@phys.uit.no>


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

Date: 20 Aug 1997 07:03:57 -0700
From: Randal Schwartz <merlyn@stonehenge.com>
To: tadmc@flash.net (Tad McClellan)
Subject: Re: Chars into Array
Message-Id: <8c203par3l.fsf@gadget.cscaper.com>

>>>>> "Tad" == Tad McClellan <tadmc@flash.net> writes:

Tad> '-1.942' has seven null strings and five 'word boundaries' (\b).

Nope.  Only 4 \b.  Watch:

    $ perl
    while ("-1.942" =~ /\b/g) {
      print "$` <> $'\n";
    }
    ^D
    - <> 1.942
    -1 <> .942
    -1. <> 942
    -1.942 <> 
    $

(Really handy piece of code to whip out occasionally.)  The "outside"
of the string is considered \W, and since the first character of this
string is also \W, there's no word boundary in front.

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

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


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

Date: Wed, 20 Aug 1997 09:32:41 -0400
From: Joshua Marotti <jpm@iti-oh.com>
Subject: Re: Field Length
Message-Id: <33FAF1F9.3583F411@iti-oh.com>

John Grimm wrote:

> How do I determine the length of a variable?

I can't remember if this is totally correct... I may be wrong, but I
believe, if it is a string, you can place it into an array with a simple
assign declaration (@string = $string).  Then you find the count simply
by $count = $#string.
Hope that helps,
-Josh




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

Date: Wed, 20 Aug 1997 17:01:07 +0200
From: Alexander Werner <nc-werneral@netcologne.de>
Subject: Germany_Colonge needs help... Path conflict !
Message-Id: <33FB06B3.D4AADF28@netcologne.de>

after installation of perl.5.001 to windows nt 4.0 plattform
the scripts do not work fine ...

with the command :

<FORM  METHOD="POST"
ACTION="http://194.8.194.70/perl5/bin/perl.exe?D:\perl5\docs_pl\my_file.pl">

everything works well. But that is not a solution.

I have done the following: At the commandline...

- ASSOC  .pl=PerlScript
- FTYPE   PerlScript=E:\perl5\bin\perl.exe  %1 %*

- I have created lip-path.pl
- in Netscape/Communicator  i have put the path & program perl.exe for
 .pl

what else can I do ?

regards: Alexander


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

Date: Wed, 20 Aug 1997 07:31:15 -0400
From: Thad Welch <tw36027@glaxowellcome.com>
To: Hiawatha Bray <wathab@tiac.net>
Subject: Re: Hailp!  Hailp!
Message-Id: <33FAD583.8A96D4F6@glaxowellcome.com>

I would go to site,

http://www.activeware.com/

and get their port of Perl to windows.  This Perl will definitely work.


Hiawatha Bray wrote:

> I'm trying to teach myself Perl with a book from Waite Press.  Came
> with a
> CD-ROM with Perl 5.001 on it.  But I can't get it to run on my Win 95
> computer.  I can get the program PERL.EXE to fire up, but it won't run
> the
> basic Hello World program.  It just sits there.  Throws an error
> message
> once in awhile, but I don't understand how to get it to work.  What
> command
> do I type to tell it to execute a program?  Despite its cross-platform
>
> pretensions, the book seems to have been written as if everyone uses
> Unix.
> There doesn't seem to be any Win 95-specific info on how you get Perl
> to
> work.  Please, somebody, e-mail me!  I'm at wathab@tiac.net.  Thanks.
>
> Hiawatha Bray
> Quincy, MA





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

Date: Wed, 20 Aug 1997 07:40:47 -0700
From: Matt Roper <mattrope@mdhost.cse.tek.com>
To: "Lic. Juan Carlos Murillo" <murillo@infocostarica.com>
Subject: Re: HELP with script
Message-Id: <Pine.SUN.3.95q.970820073906.23042C-100000@tekgp4.cse.tek.com>

On Tue, 19 Aug 1997, Lic. Juan Carlos Murillo wrote:

> Hi everybody,
> 
> could someone tell me how to make my script so each time it writes to
> the log file it appends the new data to the old log file instead of
> making a new one every time. The part of my script that does the writing
> looks like this:
> 
> 
> # Open the log file and write the data
> open(FILE, ">$logfile") || die "I can't open $logfile\n";

^^^  This is the line you need to change.  It should be:

open(FILE, ">>$logfile") || die "I can't open $logfile\n";
            ^^
            You need two of these if you want to append, one to overwrite.


> print FILE "Someone filled the legal info form\n";
> print FILE "with the following information:\n";
> print FILE "Name: $in{'Name-'}\n";
> print FILE "Company: $in{'Company-'}\n";
> print FILE "E-mail: $in{'E-mail-'}\n";
> print FILE "Subject: $in{'Subject-'}\n";
> print FILE "Comments: $in{'Comments-'}\n";
> print FILE "Treatment: $in{'overview'} - $in{'general'} -
> $in{'indepth'}\n";
> print FILE "\n";
> close(FILE);
> 
> 

Hope this helps.

==============
Matt Roper
mattrope@mdhost.cse.tek.com



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

Date: Wed, 20 Aug 1997 12:49:31 +0200
From: Michal Rutka <erhmiru@erh.ericsson.se>
To: w4vu@unb.ca
Subject: Re: Help:Can't find Config.pm
Message-Id: <33FACBBB.41C67EA6@erh.ericsson.se>

Hi,

The Net::Config.pm is automaticly generated during making of
Net package. This is done by script Configure. If you don't
have the Configure script, try to get libnet-x.x from CPAN.

Regards,

Michal

David Tweedie wrote:
> 
> Hi,
> 
> Our current installation of perl does not contain the Config.pm file
> which is necessary to use the Net::FTP module. Apparently the Config.pm
> is a core module of perl's and so I don't understand why it is not
> already on our system.
> 
> Can anyone point me to a location to retrive it. It is not in the CPAN
> area. There is a link to it, but there is nothing there.
> 
> Thanks,
> Dave

-- 
Michal Rutka <erhmiru@erh.ericsson.se>

MScEE, PhD                              Ericsson Radio Systems BV
Digital IC Design Engineer              P.O. Box 2015
Wide Area Pagers                        7801CA Emmen
                                        The Netherlands
voice:  +31 591 637352
fax:    +31 591 632784


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

Date: Wed, 20 Aug 1997 15:45:41 -0400
From: "I. John Misiris" <jmisiris@de.ibm.com>
Subject: How can I make this CGI script work
Message-Id: <33FB4965.29BC@hotmail.com>

Hi !

Sorry guys if my question seems boring or even stupid, 
i'm a newcomer with cgi programming be patient with this.

I have the following problem:

I run the OS2HTTPD Ver. 1.04 and try to run my first cgi perl script

first.pl
----------------------------
#!/perl5/perl5
use CGI ':standard";

print h1("Just a test.").
       
---------------------------

index.htm:
----------------------------
<A HREF="/cgi-bin/first.pl">Do Script</A>
----------------------------

After clicking the link i get the error:
----------------------------
404 Not found
The requested URL/ was not found on this server.
----------------------------

I checked the server log:

----------------------------
"GET /cgi-bin/first.pl HTTP/1.0" 302 0
"GET /cgi-bin/ HTTP/1.0" 404 -
----------------------------

What I'm I doing wrong ??????


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

Date: Wed, 20 Aug 1997 08:00:34 -0400
From: Anagrams of the Word 'A' <jefpin@bergen.org>
To: mcgucken@physics.unc.edu
Subject: Re: How do I create a directory and then create a directory within that directory?
Message-Id: <Pine.SGI.3.95.970820075733.22757A-100000@vangogh.bergen.org>

>#!/usr/local/bin/perl
>mkdir(etc,"/etc1/etc2") 
>
>I'm looking to create a directory named etc2 within a directory named
>etc1, but this doesn't seem to work.  How would I go about doing this?

The syntax for the Perl5 mkdir() function is:
	mkdir DIRNAME, MODE

So it would be something like:
	mkdir ("/etc1/etc2",755);

Check the chmod() command on your UNIX machine if you don't know its
syntax.

To change to that directory, try:
	chdir "/etc1/etc2";

Ok?  Hope it helps.


----------------
| Before you think UNIX is family-oriented, note that all children must die. 
| 	- Cross-Platform Perl
----------------
Jeff "TechMaster" Pinyan | http://users.bergen.org/~jefpin
I do: HTML!! CGI!! Perl!! JavaScript!! jefpin@bergen.org
Got a JavaScript/CGI/Perl question or problem?  Let me know!

webXS - the new eZine for WebProgrammers! TechMaster@bergen.org
Visit us @ http://users.bergen.org/~jefpin/webXS



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

Date: 20 Aug 1997 10:14:52 -0400
From: Clark Dorman <clark@s3i.com>
Subject: Re: How do I create a directory and then create a directory within that directory?
Message-Id: <du3gleyar.fsf@s3i.com>


Anagrams of the Word 'A' <jefpin@bergen.org> writes:
> >#!/usr/local/bin/perl
> >mkdir(etc,"/etc1/etc2") 
> >
> >I'm looking to create a directory named etc2 within a directory named
> >etc1, but this doesn't seem to work.  How would I go about doing this?
> 
> The syntax for the Perl5 mkdir() function is:
> 	mkdir DIRNAME, MODE
> 
> So it would be something like:
> 	mkdir ("/etc1/etc2",755);

Danger Will Robinson! Danger!

You need to remember that the MODE needs to be in octal.  Therefore, you need
to do:

mkdir( "p2", 0755 );

Please remember the 0 before the rest of the numbers.


-- 
Clark Dorman				"Evolution is cleverer than you are."
http://cns-web.bu.edu/pub/dorman/D.html                -Francis Crick


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

Date: Wed, 20 Aug 1997 09:30:14 -0400
From: Joshua Marotti <jpm@iti-oh.com>
Subject: Re: How to Wrap long lines?? (Novice)
Message-Id: <33FAF166.7CB54C8@iti-oh.com>

Satyajit Patel wrote:

> Hi all,

Hello!

>         I have been working with perl for a bit now. But I have not
> figured out
> how to
> wrap a very long line when printing it to screen.
>

Try playing with the format command.

> example:
>
> my $string = " This is a very very long string that should be wrapped
> when printed to screen. But I can't seem to be able to do so....
> please
> help!!\n";

try this...
write STDOUT;

format STDOUT =
 ^<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<
$string
~~ ^<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<
$string
 .

That would wrap the string at 50 characters.  The ~ means to only print
the line if it contains something, and the ~~ means to continually print
the line until there is nothing.
Hope that helps,
-Josh



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

Date: 19 Aug 1997 23:06:50 GMT
From: dlynes@plenary-software.com (Daniel Bruce Lynes)
Subject: Re: Is there a perl IDE?
Message-Id: <5td8ua$1gg@news.bc>

In article <EEnFBt.M7v@world.std.com>, aml@world.std.com says...

>"IDE". It is "Notepad" or "Any Other Text Editor", with a side note of
>"does that other text editor offer an IDE."
>
>Personally, I've found Notepad to be lacking in features to do much
>editting in (still using the same DOS based editor that I'm
>comfortable with.), but have found that with all I need to do is have
>a command shell open in a second window for running and debugging.

Try one of the following editors (I think they'll both have the features you're 
looking for, and then some...):

CodeWright Professional 6.0 - excellent editor; will also synchronize with 
Microsoft Visual C++ 4.0 or higher.  It also includes its own poor-man's 
revision control system.  Codewright also has its own macro language for 
expandability.

vim 4.6 for Win32.  - there's a few problems when trying to run this program 
under 95; however, it works just fine under NT.  As you'll soon find out (if 
you decide to try it), it wields considerable power, due to its use of ex 
configuration commands, and its regex parser.  (Most UNIX programs and UNIX 
ports use a regex parser.  It is definitely one of the true jewels of UNIX 
programs: regex=REGular EXpression.)  If you've got the imagination, vim can 
probably do whatever your imagination suggests (providing it's technically 
possible.)  vim 5.0 will also have syntax highlighting.  However, in the 
mean-time, syntax highlighting is still achievable through use of ANSI escape 
sequences in the .vimrc file.



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

Date: 20 Aug 1997 14:42:18 GMT
From: bdwheele@indiana.edu (Brian Wheeler)
Subject: Re: Is there a perl IDE?
Message-Id: <5tevoa$mec$1@dismay.ucs.indiana.edu>

In article <5td8ua$1gg@news.bc>,
	dlynes@plenary-software.com (Daniel Bruce Lynes) writes:
>In article <EEnFBt.M7v@world.std.com>, aml@world.std.com says...
>
>>"IDE". It is "Notepad" or "Any Other Text Editor", with a side note of
>>"does that other text editor offer an IDE."
>>
>>Personally, I've found Notepad to be lacking in features to do much
>>editting in (still using the same DOS based editor that I'm
>>comfortable with.), but have found that with all I need to do is have
>>a command shell open in a second window for running and debugging.
>
>Try one of the following editors (I think they'll both have the features you're 
>looking for, and then some...):
>
>CodeWright Professional 6.0 - excellent editor; will also synchronize with 
>Microsoft Visual C++ 4.0 or higher.  It also includes its own poor-man's 
>revision control system.  Codewright also has its own macro language for 
>expandability.
>
>vim 4.6 for Win32.  - there's a few problems when trying to run this program 
>under 95; however, it works just fine under NT.  As you'll soon find out (if 
>you decide to try it), it wields considerable power, due to its use of ex 
>configuration commands, and its regex parser.  (Most UNIX programs and UNIX 
>ports use a regex parser.  It is definitely one of the true jewels of UNIX 
>programs: regex=REGular EXpression.)  If you've got the imagination, vim can 
>probably do whatever your imagination suggests (providing it's technically 
>possible.)  vim 5.0 will also have syntax highlighting.  However, in the 
>mean-time, syntax highlighting is still achievable through use of ANSI escape 
>sequences in the .vimrc file.
>

	You forgot the "one true editor": emacs.  It has a perl mode which
indents for you and will flash matching parens/brackets/braces.



-- 
Brian Wheeler
bdwheele@indiana.edu


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

Date: Wed, 20 Aug 1997 11:06:35 GMT
From: aml@world.std.com (Andrew M. Langmead)
Subject: Re: naming arrays
Message-Id: <EF7LJ0.30L@world.std.com>

mahanta@cs.concordia.ca (MAHANTA girish) writes:

>	I have a large number of arrays named:  @bw00, @bw01, .... @bw050
>Inside the program I want to reference the arrays dynamically, with help of 
>the numbers following the @bw string. Say @bw$n where $n has the subscript
>of the array I want to reference, without having to wrtie @bw00 explicitely. 

Take a look at "symbolic references" in the perlref man page.

$array_count = 0;
while(defined @{$array = sprintf 'bw%02d', $array_count}) {
  print join "-", @{$array};
  $array_count++;
}

If you have some sort of control of your data structure, you might
want to condisder turning into a two dimensional array. Then you could
refer to @{$bw[0]} instead of @bw00 and finding the number of
@bw.. arrays is simply counting up the elements of @bw.

#!/usr/bin/perl -w
use strict;

my $index;
my @bw = ([1 .. 10],[11 .. 20],[21 .. 30]);

for($index = 0; $index < @bw; $index++) {
  print join "-", @{$bw[$index]};
}
-- 
Andrew Langmead


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

Date: Tue, 19 Aug 1997 23:46:59 +0200
From: Alexis Roda <arv@fcee.urv.es>
To: MAHANTA girish <mahanta@cs.concordia.ca>
Subject: Re: naming arrays
Message-Id: <33FA1453.3C6EF362@fcee.urv.es>

MAHANTA girish wrote:

>         I have a large number of arrays named:  @bw00, @bw01, .... @bw050
> Inside the program I want to reference the arrays dynamically, with help of
> the numbers following the @bw string. Say @bw$n where $n has the subscript
> of the array I want to reference, without having to wrtie @bw00 explicitely.

You can use soft references, I think that something like:

@a1=(1,2);
@a2=('a','b');
$what = 1;
$softref = "bw$what";
print ${$softref}[1],"\n";

will work.


Saludos
Alexis Roda


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

Date: Wed, 20 Aug 1997 10:35:04 GMT
From: bart.mediamind@tornado.be (Bart Lateur)
Subject: Re: Number conversion help
Message-Id: <3407c32c.7332377@news.tornado.be>

John Grimm <ken1@earthlink.net> wrote:

>I need to translate a number like -1.7 to -017000 or something like 9.3
>to +093000

What is the connection between -1.7 and +9.3?



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

Date: Wed, 20 Aug 1997 07:48:10 -0400
From: Thad Welch <tw36027@glaxowellcome.com>
To: "James H. Blackwell" <jim.blackwell@gsfc.nasa.gov>
Subject: Re: Passing multiple arrays to subroutine ???
Message-Id: <33FAD97A.93AB96@glaxowellcome.com>

Right, when you pass @arr1, @arr2, @arr3, Perl will glob all the arrays
elements into
the parameter array @_.   The way to keep all the arrays distinct is to
pass them
by reference, like you had:

my_routine(\@arr1, \@arr2, \@arr3)

sub my_routine {
    my $arr1Ref = shift;
    my $arr2Ref = shift;
    my $arr3Ref = shift;

}

the parameter array  @_ will contain 3 array references.  Note, you will
need to
dereference  the $arr1Ref. For example,

push ( @{$arr1Ref}, '1' );  #list context
$arr1Ref->[0]; # 0 element


James H. Blackwell wrote:

> Hi all,
>
> Before I go completely gaa gaa, I thought I'd ask the question in
> hopes
> that someone can help me.
>
> I have a subroutine that gets passed to it a number of arrays.
>
> my_routine(@arr1, @arr2, @arr3)
>
> In the subroutine, I do this:
>
> sub my_routine {
>
>   my (@ar1, @ar2, @ar3) = @_;
>
> ...
>
> However, all the values go into @ar1.  I have tried a number of
> things like
>
> my_routine(\@arr1, \@arr2, \@arr3)
>
> How does one get these three arrays passed to a subroutine properly ?
>
> In a nutshell, what is the proper, or is there a proper way to do
> this sort of thing ?  Am using latest Perl.
>
> Please send email to jim.blackwell@gsfc.nasa.gov
>
> Thanks





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

Date: Tue, 19 Aug 1997 21:35:24 +0200
From: Alexis Roda <arv@fcee.urv.es>
To: "James H. Blackwell" <jim.blackwell@gsfc.nasa.gov>
Subject: Re: Passing multiple arrays to subroutine ???
Message-Id: <33F9F57C.18A178B6@fcee.urv.es>

James H. Blackwell wrote:
> 
> I have a subroutine that gets passed to it a number of arrays.
> 
> my_routine(@arr1, @arr2, @arr3)
> 
> In the subroutine, I do this:
> 
> sub my_routine {
> 
>   my (@ar1, @ar2, @ar3) = @_;
> 
> ...
> 
> However, all the values go into @ar1.  

Yes, this is how it is. When you assign to a list, the first array or
hash variable sucks the rest of the value assigned, so @ar2 and @ar3 get
undefined.

> I have tried a number of
> things like
> 
> my_routine(\@arr1, \@arr2, \@arr3)
> 
> How does one get these three arrays passed to a subroutine properly ?

Array references is the simplest way. Something like:

sub my_routine {
	my @ar1 = @{$_[0]};	# here we dereference the first
				# array reference and
				# convert it back to an array
	my @ar2 = @{$_[1]};
	my @ar3 = @{$_[2]};

# if you write my (@ar1 ... ) = @_; @ar1 will suck all the references
	....
}

my_routine(\@arr1, \@arr2, \@arr3)

should do the trick. Alto its more efficient since PERL only passes to
the subroutine the "addres" of the array, not a copy of the whole array.


Saludos
Alexis Roda


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

Date: 20 Aug 1997 11:28:46 GMT
From: nic@cocoon.co.uk (Nic Gibson)
Subject: Re: Perl Win95
Message-Id: <slrn5vll43.nmq.nic@larvae.cocoon.co.uk>

On Wed, 20 Aug 1997 12:26:53 +1000, Geoffrey Dunn <gdunn@lis.net.au> wrote:
>mudd97@nac.net wrote:
>> 
>> I am trying to test perl stuff on PWS on win95. I can't get anything
>> going.

>P.S. Don't listen to the idiots who think your trying to run CGI.

As one of those idiots, I think I'd like to point out that he was trying
to run perl under Personal Web Server. If that's not cgi, it's ISAPI.

btw, your solution would work quite nicely for running perl scripts assuming
that they don't want any input but it's tad unnecessary and irrelevant in
context.

Next time you decide to call people idiots, you might care to make sure that
you know what you are talking about first.

Nic
-- 
Nic Gibson, Senior Programmer, VFM(UK) Ltd.
http://www.global-strategist.com/
Email: nic@global-strategist.com
Phone: 0171 831 7704 Mobile: 0976 408436


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

Date: Wed, 20 Aug 1997 09:18:54 -0400
From: "Susan" <susan@graygraham.com>
Subject: Re: Perl Win95
Message-Id: <5teqq0$9du@mtinsc05.worldnet.att.net>

>Geoffrey Dunn wrote:
> snip...
>
>P.S. Don't listen to the idiots who think your trying to run CGI.
> snip...

Was it my altruism, wit, or stunning beauty that makes you hurl such an
uninformed insult? :-)

Let's see now....

PWS = Personal Web Server
CGI = Web programming
PWS + Perl = CGI

- Susan






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

Date: Tue, 19 Aug 1997 23:50:44 +0200
From: Alexis Roda <arv@fcee.urv.es>
To: temp.ed.vanderbush@bentley.com
Subject: Re: readig a file into an array
Message-Id: <33FA1534.C0048E97@fcee.urv.es>

Ed Vander Bush wrote:
> 
> Can I
> open a file
> @my_array = filehandle
> close file
> Id there anything wrong with this?

It's not PERL syntax, so expect a bunch of errors :). Seriously

open FILEHANDLE, "filename" or die "bla bla bla";
@my_array = <FILEHANDLE>;
close FILEHANDLE;


Saludos
Alexis Roda


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

Date: Wed, 20 Aug 1997 10:54:41 -0400
From: Ed Vander Bush <temp.ed.vanderbush@bentley.com>
Subject: Reading a string, splitting it, and using it
Message-Id: <33FB0531.4888@bentley.com>

I am reading information from a database I created into an aray
A line of data in the Database woulde be in this format
var1|var2|var3|var4|var5|var6|var7
With Var 1 being a specific id number
$id = $Cookies{'itg'};                                                
open(USERDATABASE, "$database")||die "Database cannot be opened";       
@database = <USERDATABASE>;                                          
close(USERDATABASE);                                                    
foreach (@database){                                                    
if(/^$id/) {                                                            
($idn,$name,$itemone,$itemtwo,$itemthree,$itemfour,$itemfive) =
split(/|/,7);  
open(LOG, ">$logfile");                                                 
print LOG $name, $itemthree;                                            
close(LOG);                                                            
My problem is that the variable are not being returned.... Why?


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

Date: Wed, 20 Aug 1997 10:24:30 -0400
From: Pierre Thibaudeau <prt@Teleglobe.CA>
Subject: Right shift (">>") in 5.00401
Message-Id: <Pine.HPP.3.96.970820101104.8100D-100000@alpha.Teleglobe.CA>

After upgrading from Perl5.003 to 5.00401, I discovered a rather annoying
behaviour.

As shown below, the right shift operator ">>" does not extend the sign bit
in 5.00401 as it was doing in earlier versions:

   mtts01% perl -e 'print "Version$] : ", (-1 >> 24), "\n";'
   Version5.00401 : 255

   mtts01% /opt/local/perl5.003/perl -e 'print "Version$] : ", (-1 >> 24), "\n";'
   Version5.003 : -1

Thanks for looking at it.
__

Pierre Thibaudeau                     |   e-mail: <prt@Teleglobe.CA>
TELEGLOBE CANADA                      |
1000, rue de La Gauchetiere ouest     |      Tel: +1-514-868-7257
Montreal, QC   H3B 4X5                |
Canada                                |      fax: +1-514-868-8446



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

Date: Wed, 20 Aug 1997 11:44:44 -0400
From: Chris Gaston <cgaston@lds.com>
Subject: Systems Architect Needed
Message-Id: <33FB10EB.188C7F2F@lds.com>

Logical Design Solutions, a leader in the design and development of
Interactive Business Communications has an immediate full-time opening
in their Morristown, NJ office for a Web Architect.

Job Description:
In this visible role, the ideal candidate will possess experience in
configuration of Internet technologies as part of a multi-tiered
information technology architecture.  Keeping up-to-date with
current technology trends is essential, as is the ability to evaluate
appropriate technology components for development and delivery
environments.  This individual must also have the ability to integrate
application support technologies with preexisting client IT
infrastructure.  Experience with C/C++, Perl, HTML, Java, CGI and
knowledge of Internet protocols and standards is required.
Knowledge of Active X a plus.

Send resume with cover letter and salary requirements or contact:

Technical Recruiter
Logical Design Solutions
Phone: (201) 971-0100
Fax:   (201) 971-0103
email: recruiter@lds.com

For further info:   http://www.lds.com




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

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

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