[7064] in Perl-Users-Digest
Perl-Users Digest, Issue: 689 Volume: 8
daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Tue Jul 1 16:37:11 1997
Date: Tue, 1 Jul 97 13:00:25 -0700
From: Perl-Users Digest <Perl-Users-Request@ruby.OCE.ORST.EDU>
To: Perl-Users@ruby.OCE.ORST.EDU (Perl-Users Digest)
Perl-Users Digest Tue, 1 Jul 1997 Volume: 8 Number: 689
Today's topics:
2 Scripts in 2 Frames <mrski@gist-inc.com>
Closing Open3 <bromberek@cems.umn.edu>
Re: dir tree search (Honza Pazdziora)
Re: Empty loops... <merlyn@stonehenge.com>
Re: Empty loops... (Craig Berry)
Re: Forcing a browser auth w Perl <Jan.Krynicky@st.mff.cuni.cz>
Format ques. and Dereference ques. <k.james@bangor.ac.uk>
Re: Fun with ".cgi contained no blank line separating h <cgs@vip.net>
help me...Perl save all messages again in my file... :( <serginho@alpha.hydra.com.br>
Help w/newbie Perl runtime Error <jkeller@gridnet.com>
how does one save a file <cruel@cs.mcgill.ca>
How to filter Word Processing Files? (Charles Shehadi)
mkdir w/ perl & chmod blah blah <jason@koolsites.com>
Re: msqlPERL - comon' baby! <Jan.Krynicky@st.mff.cuni.cz>
Re: Need example of Tputs for single line terminal outp (Don Smith)
passing arrays as parameters <dmoss@instinet.com>
Re: passing arrays as parameters (A. Deckers)
Re: perl script on WinNT <webmaster@-no-spam-nstate.net>
Perl Scripts and forms <rodgeral@jmu.edu>
perl-mode for emacs <schattev@imb-jena.de>
Re: Perl: How to delete spaces from an value/element in <pociask@maricopa.edu>
Re: Q: an alternative to this use of "goto"? (Charles DeRykus)
Re: Request for Bids - Web Site Mirroring Script <oliver@inetu.net>
SFIO (Ronald E. Fortin)
Re: strange problem... (Nathan V. Patwardhan)
Re: string to integer HELP !! (Tung-chiang Yang)
Re: string to integer HELP !! <jhi@alpha.hut.fi>
Re: Use Perl in C <borup@DK.net>
Re: using @_ <sfairey@adc.metrica.co.uk>
Re: Y2K and Perl (was Re: Y2K problems??) <jhi@alpha.hut.fi>
Digest Administrivia (Last modified: 8 Mar 97) (Perl-Users-Digest Admin)
----------------------------------------------------------------------
Date: 26 Jun 1997 14:13:56 GMT
From: "Mitch Duszynski" <mrski@gist-inc.com>
Subject: 2 Scripts in 2 Frames
Message-Id: <01bc823b$089b2d40$a3df94ce@mrski.gist-inc.com>
I am trying to update 2 frames at the same time. Both frames require a
script to generate the HTML for display since they have to read a users
file to detect what to display.
When I run on an ISDN line, all works fine. But when I try to access the
same work from home on a 28.8 dialup, I can not get both frames to react
properly.
I have researched all the "Change Two Frames at one time" solutions and
still the same trouble.
Is a PERL script unable to run when another is operating and still be able
to transfer the data over a slower connection without jamming?
I am looking for any answer. Thanks!
--
Mitch "SKI" Duszynski
Global Information Systems Technology, Inc.
------------------------------
Date: Tue, 01 Jul 1997 09:10:44 -0500
From: Bruce Bromberek <bromberek@cems.umn.edu>
Subject: Closing Open3
Message-Id: <33B90FE3.4097@cems.umn.edu>
I'm using IPC::Open3 and find myself wondering 'what is the proper way
to close it?' Do I kill the process since I know the ID number, or
close the handles (ie Close ($wtr) one? both?) or do I have to terminate
the cammand. FYI the command in question is a kermit session. The
Camel book is silent on the matter.
------------------------------
Date: Tue, 1 Jul 1997 07:21:05 GMT
From: adelton@fi.muni.cz (Honza Pazdziora)
Subject: Re: dir tree search
Message-Id: <adelton.867741665@aisa.fi.muni.cz>
"rferr" <rferr@voicenet.com> writes:
> are there any scripts available (or how would it be done) that read an
> entire directory
> tree structure file by file and search for a string in each file ?
Depends on you application:
Sometimes the easier way is
$ grep pattern `find . -print`
but if you want to do it inside of your Perl script, you should check
the module File::Find (comes with your Perl distribution). There, in
the function wanted you have to open the file and do
while (<FILE>)
{ print if /$pattern/; }
loop.
Hope this helps.
--
------------------------------------------------------------------------
Honza Pazdziora | adelton@fi.muni.cz | http://www.fi.muni.cz/~adelton/
I can take or leave it if I please
DES is dead. Let's fight RC5 now. --> http://rc5.distributed.net/
------------------------------
Date: 01 Jul 1997 08:02:16 -0700
From: Randal Schwartz <merlyn@stonehenge.com>
To: cberry@cinenet.net (Craig Berry)
Subject: Re: Empty loops...
Message-Id: <8cpvt2zuh3.fsf@gadget.cscaper.com>
>>>>> "Craig" == Craig Berry <cberry@cinenet.net> writes:
Craig> 1 while (...);
The nice thing about this particular idiom is that you don't even need
those parens:
1 while some-expr-that-you-want-done-and-the-truth-value-tested;
Of course, to be really perverse, you can do something like:
1 while sub {
arbitrary block of code;
return true-or-false if some-condition;
more code;
maybe another return true-false;
last-expr-evaluated-for-its-true/false-to-continue;
}->();
Presuming you have 5.004 (and who doesn't, yet? :-).
print "Just another Perl hacker," # but not what the media calls "hacker!" :-)
## legal fund: $20,495.69 collected, $182,159.85 spent; just 427 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: 1 Jul 1997 06:13:15 GMT
From: cberry@cinenet.net (Craig Berry)
Subject: Re: Empty loops...
Message-Id: <5pa75r$9a2$1@marina.cinenet.net>
Tom Phoenix (rootbeer@teleport.com) wrote:
: On Mon, 30 Jun 1997, David J. Clark wrote:
:
: > In searching an array, I want to say something like:
: >
: > while($array[$i++] ne $string_to_look_for);
:
: > Right now I just have:
: >
: > while(...) {0}
: >
: > which works, but seems kind of arbitrary.
:
: So, if it works, what are you griping about? :-)
:
: The compiler is smart enough to optimize that constant to Tumbolia, so you
: don't have to worry that it's slowing things down. But you could even omit
: it, if you wanted.
:
: while (...) {} # Empty loop body
One will also very commonly see the equivalent idiom
1 while (...);
This one puzzled the heck out of me before I became a pod-- er, um,
learned to see the beauty of The Perl Way.
---------------------------------------------------------------------
| Craig Berry - cberry@cinenet.net
--*-- Home Page: http://www.cinenet.net/users/cberry/home.html
| Member of The HTML Writers Guild: http://www.hwg.org/
"Every man and every woman is a star."
------------------------------
Date: Tue, 01 Jul 1997 20:43:39 -0700
From: Jan Krynicky <Jan.Krynicky@st.mff.cuni.cz>
To: "Daniel G. Drumm" <dgd@nebula.is.rpslmc.edu>
Subject: Re: Forcing a browser auth w Perl
Message-Id: <33B9CE6B.4DB7@st.mff.cuni.cz>
Daniel G. Drumm wrote:
>
> I'm searching for a way to force a browser to authenticate, as with a httpd
> protected page, strictly from within Perl.
>
> I want to write a CGI, that when you call it:
>
> http://www.foo.com/test.cgi
>
> It will open the browser dialog box (on most browsers) and ask you for your
> name and password, read it, and then continue based on that information.
>
> This doesn't work the same way as CGI, this is not a GET or PUT, but I know
> it can be done without resorting to the Web server to do it. In a worse
> case scenario, perhaps the HTTP::Daemon module could be used to open a
> socket to the client's browser and issue the code, although that seems
> nuts.
>
> I've done all kinds of Web authentication, using Selena's auth module,
> Java, and even Javascript. But can't do what I want strictly within Perl.
>
> --
> --
> Daniel G. Drumm - ddrumm@rush.edu
I'm pretty sure this cannot be done. You can send a request for
authentification,
but you'll get back only the login name, NOT the password. The server
will not give it
to you.
If you'd resort only to logins with no passwords (I think AdultCheck
used to work this way), you would be able to do it.
See some HTTP specs for the synax of an authentification request.
Jenda
------------------------------
Date: 01 Jul 1997 15:26:12 +0100
From: Keith James <k.james@bangor.ac.uk>
Subject: Format ques. and Dereference ques.
Message-Id: <m3hgeealx7.fsf@pwilliams.bangor.ac.uk>
I wrote a messy script which I'm fixing up to 'use strict'. It has
raised a couple of issues which I'd like some advice on. Firstly
the bit that I broke with use strict. In the code below the scalars
$i and $j are empty when the formatted output is written and I
can't see why because the format is called from within the loop.
This snippet is part of the main block of code. All the variables
are 'my' d at the outset and the script passes -w and use strict.
It works apart from getting 'uninitialised variables on the format
line.
# print output to STDOUT and files
$~ = "SUMMARY";
select ( STDOUT );
for $i ( 0 .. $#contig_list ) {
for $j ( 0 .. $#{ $contig_list[$i] } ) {
$name = $contig_list[$i][$j];
write STDOUT if ( $verbose );
# if we want to export files
if ( $writeout ) {
open ( OUTFILE, ">$name" ) or die "Couldn't open outfile $name\n";
@outseq = split //, $seq_names{ $name };
# if we want the bottom strand 5'->3' in the files
if ( $revcomp && $name =~ /.*-$/ ) {
@outseq = reverse ( @outseq );
# move the last linebreak to the right end
shift @outseq;
push @outseq, "\n";
foreach ( @outseq ) { tr/ACGTNacgtn/TGCANtgcan/ }
}
unshift ( @outseq, ">$name\n" );
print OUTFILE @outseq;
}
}
close OUTFILE;
}
# Formats
format SUMMARY =
Contig: @## Sequence: @<<< Name: @<<<<<<<<<<<<<<<<<<<<
$i, $j + 1, $name
The second question is one of style really, because this code works
(it's from the a sub in the same script). I've passed some arrays
to the sub, or rather refs to the arrays. I de-reffed the arrays at
the start of the sub to make it easier for myself. What I'd like to
know is this- is there a more elegant way to do the assignments using
the reference, rather than making a new array in the sub (which I
think is what I've done)?
What I've got is a hash %lseq_names whose keys are in a 2-D array
@lcontig_list. The loop assigns stuff from a file to the hash using
one of the keys from the array.
sub extract {
my (@lfile,
$lfile_ref,
$lline,
@lcontig_list,
$lcontig_list_ref,
%lseq_names,
$lseq_names_ref,
); #locals
my ( $ldetailed, $i, $j, $lkey ); #switches
( $lfile_ref, $lcontig_list_ref, $lseq_names_ref ) = @_;
@lfile = @{$lfile_ref};
@lcontig_list = @{$lcontig_list_ref};
%lseq_names = %{$lseq_names_ref};
# Put the sequences into the hash
foreach $lline ( @lfile ) {
for $i ( 0 .. $#lcontig_list ) {
for $j ( 0 .. $#{ $lcontig_list[$i] } ) {
$ldetailed++ if ( $lline =~ /DETAILED/ );
next unless ( $ldetailed );
last if ( $lline =~ /CONSENSUS/ );
# line starting with sequence name with/without a "+"
if ( $lline =~ /^($lcontig_list[$i][$j]\+*)\s+(\S+)/ ) {
# concatenate the sequence with the hash value
$lseq_names{$1} .= $2 . "\n";
}
}
}
}
if ( $debug ) {
foreach $lkey ( keys %lseq_names ) {
print "At $lkey we have: \n$lseq_names{ $lkey }\n";
}
}
return %lseq_names;
}
I've messed with a few things from the CPAN LoL tutorial, the LoL
manpage and some cool-looking stuff from the Camel book. Trouble is
that I've got no background in another language and most of the Camel
goes over my head. FWIW this is about my 12th script, so (best
Cockney accent)... 'elp a newbie mistah (or miss)... gawd bless yah
Thanks to anyone who read this far!
--
Keith James Ph.D. - k.james@bangor.ac.uk PGP 2.6.2i Key ID 469A9FA1
Biodegradation Group *Encrypt and Survive*
School of Biological Sciences Guvf znl znxr ab frafr vs bar bs gur
University of Wales, Bangor, UK vasvavgr ahzore bs zbaxrlf vf bssyvar
------------------------------
Date: Mon, 30 Jun 1997 16:07:08 -0700
From: Customer Service <cgs@vip.net>
Subject: Re: Fun with ".cgi contained no blank line separating header and data"
Message-Id: <33B83C1C.129@vip.net>
Bryan Hart wrote:
> > >>This Server Error 500 message has plagued me for weeks with
> > >Folowed by two spaces?? It must be 2 new lines "\n\n"
> > >
> > >Hope your problem was as simple as that.
> >
> > Alas it was not.... I stated incorrectly in my original post and apologize
> > for the error humbly. Indeed I did have the necessary "\n\n" and was looking
> > at the blank line.
> >
>
> You mention it's a Win95 system, have you tried using "\r\n\r\n" instead
> of "\n\n"? Non-unix systems sometimes use different variants of \n and
> \r to denote newlines.
Actually the same thing happened to me when i started with .pl
on NT server. I got irritated and threw in four \n. It worked.
I'm not sure why though.
--
Chris / cgiroux@vip.net
www.KOSMONET.com / contact@kosmonet.com / 1-888-4KOSMOS
------------------------------
Date: 1 Jul 1997 14:47:15 GMT
From: "Sergio Stateri Jr" <serginho@alpha.hydra.com.br>
Subject: help me...Perl save all messages again in my file... :((
Message-Id: <01bc862e$04b01f00$6875e7c8@Term104>
Hi again Perl Users!
Now I'm having a terrible problem. I did a script that read a file of
messages saved and get the lastest ID message and increment one. The
problem is that when I save a new message (with this new id), Perl save all
other messages again, or repeat all the messages in the file...But I'm
saving only the new message...Here is the script that do this...
if (open(SAIDA,"+<mensag.dat"))
{
$existe_from = 0;
if (open(LISTA,"<lista.txt"))
{
@lista_total = <LISTA>;
foreach $value(@lista_total)
{
$email = substr($value,34,40) if
(substr($value,4,length($in{'from'})) eq $in{'from'});
$cod_from = substr($value,0,4) if
(substr($value,4,length($in{'from'})) eq $in{'from'});
}
$existe_from = 1;
}
@tot_mensagens = <SAIDA>;
$msg_id = '000000';
foreach $value(@tot_mensagens)
{
if (substr($value,0,4) eq '!NM!') # i inmcio de registro
{ $msg_id = substr($value,4,6); }
}
$msg_id++; # Soma 1 ao id da ultima mensagem
print SAIDA "!NM!"; # New Message ID
print SAIDA "0" x (6-length($msg_id)), $msg_id; # Message ID
print SAIDA $cod_from, " " x (4-length($cod_from)); # Sender
print SAIDA $ip_remoto, " " x (15-length($ip_remoto)); # IP
print SAIDA "$mday/$mon/$year","$hour:$min:$sec";
print SAIDA "\n";
print SAIDA $in{'subject'};
print SAIDA "\n";
print SAIDA $in{'message'},"\n";
close(SAIDA);
----------------------------------------------------------------------------
------------------------------------------------------------
What's happenning ? I save one time the new message, and Perl sve all other
messages again...
Thanks for any help...
--
--------------------------------------------
Sergio Stateri Jr
Sco Paulo (SP) - Brazil
e-mail: serginho@usa.net
--------------------------------------------
------------------------------
Date: 1 Jul 97 18:02:44 GMT
From: "John Keller" <jkeller@gridnet.com>
Subject: Help w/newbie Perl runtime Error
Message-Id: <01bc8649$14be9460$4fa150ce@jkeller.gridnet.com>
Hi All-
I'm having a problem when running a PERL script I wrote (copied). I get the
following error:
Can't locate sys/socket.ph in @INC (did you run h2ph?) at recep.pl line 8.
It is pointing to line 8 , which is:
require 'sys/socket.ph'; <---- line 8
require 'sys/errno.ph';
require 'sys/wait.ph';
require 'getopts.pl';
I'm assuming I need some libraries that I managed to not install. I am
running PERL on a SunOS v4.1.4 Sparc 20. Any idea as to where I can get the
missing files, or is my problem something else? What is h2ph? Help
appreciated, send a reply to jkeller@gridnet.com, or reply to the
newsgroup.
Thanks,
John Keller
------------------------------
Date: 30 Jun 97 02:31:31 GMT
From: "Thomas Contaxakis" <cruel@cs.mcgill.ca>
Subject: how does one save a file
Message-Id: <01bc84fe$39f44280$a256eccd@default>
how can you given a file from a user online, like an url to a graphic or
something, how does one save that file?
cruel@cs.mcgill.ca
------------------------------
Date: 1 Jul 1997 03:41:03 GMT
From: cshehadi@panix.com (Charles Shehadi)
Subject: How to filter Word Processing Files?
Message-Id: <cshehadi-3006972347260001@cshehadi.dialup.access.net>
Is there a module out there that will let me read in files from word
processors, stripping out the formatting codes and ending up with text
only?
If there isn't one for particular word processors, how about for standard
formats, such as "RTF (rich text format)"?
I couldn't tell from the CPAN module listings if there was such a thing or
not...
-Charlie
------------------------------
Date: Tue, 01 Jul 1997 08:34:06 -0500
From: jlinscom <jason@koolsites.com>
Subject: mkdir w/ perl & chmod blah blah
Message-Id: <33B9074E.4555003E@koolsites.com>
can perl execute the command: "mkdir dirname" ???
i am wanting to create directories and files using perl, and have the
files approved to be used by anyone. this is the command sequence i'm
thinking.... maybe i should start thinking perl and less dos?
mkdir school
open(FILE,">school/$filename");
print "whatever";
close(FILE);
make the directory named "school".
write the file named what ever $filename is.
and save it in the school directory.
now, don't i have to chmod 755 $filename?
please help,
jason
------------------------------
Date: Tue, 01 Jul 1997 21:08:09 -0700
From: Jan Krynicky <Jan.Krynicky@st.mff.cuni.cz>
To: david@manifold-id.com, prof@katz.com
Subject: Re: msqlPERL - comon' baby!
Message-Id: <33B9D429.395D@st.mff.cuni.cz>
david@manifold-id.com wrote:
>
> In article <prof-ya02408000R2206971256230001@snews.zippo.com>,
>
> prof@katz.com (professor katz) wrote:
>
> >
>
> > Is it me, or is the documentation for msqlperl woefully inadequate? I'm a
>
> > SQL newbie to be sure, but I just want a list of functions and usage. I've
>
> > checked through ALL of the documentation, but there is just some confusing
>
> > stuff, and it's not at all clearly laid out.
>
> >
>
> > For instance the documentation points out:
>
> >
>
> > # Now we create two tables that are certainly not in the test database
>
> > # If you don't understand the trickery here, just skip this section, No big
>
> > deal.
>
> > {
>
> > my $goodtable = "TABLE00";
>
> > my(%foundtable,@foundtable);
>
=variable definition
> > @foundtable = $dbh->listtables;
>
=making a list of tables
> > @foundtable{@foundtable} = (1) x @foundtable;
> > # all existing tables are now keys in %foundtable
>
=creating a hash, every table is defined as an element, all with value =
1
= say @foundtable=('one','two','three');
= =>
= %foundtable{one}=1; %foundtable{two}=1; %foundtable{three}=1;
= and no other elements are defined.
> > my $limit = 0;
>
> >
>
> > for ($firsttable, $secondtable) {
>
> > while () {
>
> > next if $foundtable{++$goodtable};
>
= looking for a first table not in database - testing TABLE00, TABLE01,
TABLE02, ...
> > my $query = qq{
>
> > create table $goodtable (
>
> > she char(32),
>
> > him char(32) not null,
>
> > who char (32)
>
> > )
>
> > };
>
= prepared the query into a variable, good for testing if you use some
variables to make up = the query
> > unless ($dbh->query($query)){
>
> > die "Cannot create table: query [$query] message
>
> > [$Msql::db_errstr]\n" if $limit++ > 1000;
>
> > next;
>
> > }
>
= If (failed creating table) {print an error message and try again with
next TABLExx}
> > $_ = $goodtable;
>
= set the $_ variable to the name of the table that was successfully
created.
= and since $_ points to an item of the list passed to foreach you are
setting $firsttable
= or $secondtable
= see the docs about for/foreach (perlsyn if I'm not mistaken).
> > last;
>
> > }
>
> > }
>
> > # For the tests in this script we have two tablenames that we can
>
> > # peruse: $firsttable and $secondtable
>
> > }
>
> >
>
> > Well, I don't understand the trickery, but I really need to! That qq{}
>
> > business really throws me. But I'm new to PERL object-oriented stuff. The
qq{} has nothing in common with objects. It means the same as "" except
you can use
" inside with no backlash
qq{I say: "Hello world."} is the same as "I say: \"Hello world.\""
Read perlsyn.
>
> > thing that really throws me, is that I can create a table just by typing:
>
> >
>
> > $sth = $dbh->query("create table test_table (
>
> > name char(32),
>
> > rank char(32),
>
> > sn char(32)
>
> > ));
>
> >
>
Sure you can, they are just testing whether it is already in, and
preparing the query before the call. Nothing more.
> > So what's the big whoop here? But one thing that I can't figure out is how
>
> > to make a keyfield using msqlperl. There's no mention anywhere that I can
>
> > find.
>
Sorry what's a keyfield?
> >
>
> > Any help, support, or hints to finding more material would be greatly
>
> > appeciated. BTW, I already found the mailing list archives, and I have
>
> > subscribed to the mailing list. Most of my problems are pretty basic
>
> > programming issues, and not related to setting up the programs on the
>
> > server. LIke I said, I am fairly new to this stuff but I am struggling to
>
> > find decent documentation. Also, If you're in my position, respond to my
>
> > post and we'll start a mutual support group via email or something.
>
> >
>
> > Thanks,
>
> > Katz
>
> Katz,
>
> Sounds like we're in the same boat. Have you had any luck finding better
> documentation for msqlperl?
>
You'd better read the docs about Perl.
Jenda
------------------------------
Date: Tue, 01 Jul 97 18:07:49 GMT
From: art@NOSPAM.oz.net (Don Smith)
Subject: Re: Need example of Tputs for single line terminal output
Message-Id: <5pbh2f$s4t$3@hourglass.oz.net>
In article <5p926u$ocs$2@d2.tufts.edu>, jrozes@tcs.tufts.edu wrote:
>Hi--
>
[snip]
>Can somebody give me an example of this or point me to a tutorial
>that will help me figure it out?
>
>Thanks,
>jonathan
>--
>+++ Jonathan Rozes, Unix Systems Administrator, Tufts University
>++ jrozes@tcs.tufts.edu, http://rozes.tcs.tufts.edu/
There's several Perl 5 tutorials at
http://www.oz.net/1world/bstore.html
Don
------------------------------
Date: Tue, 01 Jul 1997 15:50:49 -0400
From: David Mossakowski <dmoss@instinet.com>
Subject: passing arrays as parameters
Message-Id: <33B95F99.8E743026@instinet.com>
Hi,
I need to pass a bunch of arrays to a subroutine:
&displayCategories (@spnf,@saae,@uree);
then I want to have all the elements of each displayed but when one ends
and the other begins I need to put some text:
this is stuff from spnf:
spnf1
spnf2
this is stuff from saae:
saae77
this is stuff from uree:
ureej
ureej453...
but it seems that once in subroutine all the elements in these arrays
are treated as one big array under the @_. Is that so?
if yes then how can I do the above thing?
any help greatly appreciated.
dAVe.
--
David Mossakowski
Instinet Corporation
212-310-7275
dmoss@instinet.com
"I don't sit idly by,
I'm planning a big surprise" FUGAZI
------------------------------
Date: 1 Jul 1997 19:41:42 GMT
From: deckers@man.ac.uk (A. Deckers)
Subject: Re: passing arrays as parameters
Message-Id: <slrn5rinb2.a5g.deckers@nessie.mcc.ac.uk>
In <33B95F99.8E743026@instinet.com>,
David Mossakowski <dmoss@instinet.com> wrote:
>Hi,
>
>I need to pass a bunch of arrays to a subroutine:
>
>&displayCategories (@spnf,@saae,@uree);
Pass them by reference:
display(\@spnf, \@saae, \@uree);
Then deref them in your sub:
sub display {
my($ref1, $ref2, $ref3) = @_;
my @spnf = @$ref1;
# etc...
}
See man perlref for more info.
HTH,
Alain
--
Perl information: <URL:http://www.perl.com/perl/>
Perl FAQ: <URL:http://www.perl.com/perl/faq/>
Perl archive: <URL:http://www.perl.com/CPAN/>
>>>>>>>> comp.lang.perl.misc is NOT a CGI group <<<<<<<<<<
------------------------------
Date: Mon, 30 Jun 1997 22:28:35 -0700
From: Webmaster <webmaster@-no-spam-nstate.net>
Subject: Re: perl script on WinNT
Message-Id: <33B89583.5F2@-no-spam-nstate.net>
Jonathan Feinberg wrote:
>
> petri.backstrom@icl.fi said...
> > The "shebang" line is ignored on Windows NT.
>
> Not so.
>
> The switches after the word "perl" are used by all versions of perl, e.g.,
> #!/usr/local/bin/perl -w
> turns on warnings on an NT box.
> --
> Jonathan Feinberg jdf@pobox.com Sunny Manhattan, NY
Did he mention switches?.. Or was he speaking of the "#!"??????.. I
think you missed something.. sorry..
--
* Chatmaster/Admin Chat Hub http://www.chathub.com -
http://chat.nstate.net E-Mail Contact: chatmaster@chathub.com,
webmaster@chathub.com, sales@chathub.com, info@chathub.com,
admin@chathub.com, chatmaster@nstate.net
* Webmaster Northstate Net http://www.nstate.net E-Mail Contact:
webmaster@nstate.net * TRG Custom Graphics - http://www.nstate.net/trg
E-Mail Contact: customdesign@nstate.net
------------------------------
Date: Tue, 01 Jul 1997 15:12:29 -0500
From: Angel Rodgers <rodgeral@jmu.edu>
Subject: Perl Scripts and forms
Message-Id: <33B964A9.138A@jmu.edu>
I am new to Perl and CGI. I am trying to verify that all of the blanks
in an html form I have created are filled in before I run the another
program. How would I write a perl script to verify that the text fields
in my form are filled in? So far I have tried:
open (FILE, ">$file")
if ($input{'title'} eq '') {
print FILE "Please input title\n\n" ;
} elsif ($input{'Designation'} eq '') {
etc.
However, I am getting the an error message of
syntax error at line 17 near "{"
Any suggestions?
Thanks,
Angel Rodgers
rodgeral@jmu.edu
------------------------------
Date: Tue, 01 Jul 1997 13:52:32 +0200
From: Ruben Schattevoy <schattev@imb-jena.de>
Subject: perl-mode for emacs
Message-Id: <33B8EF80.65A@imb-jena.de>
Dear All,
I have problems with the perl-mode of emacs (version 19.34.1). Whenever
I use constructions like this: ${...} the indent-region algorithm fails.
Is there a patched version of the relevant emacs style file available?
Thanks,
Ruben
------------------------------
Date: Tue, 01 Jul 1997 08:14:50 -0700
From: Jason Pociask <pociask@maricopa.edu>
Subject: Re: Perl: How to delete spaces from an value/element in an assoc array
Message-Id: <33B91EEA.5C6F@maricopa.edu>
For those of us old enough to remember, Perl syntax
does have a remarkable resemblance to 300 baud modem
line noise...
Doug Seay wrote:
>
> [posted and mailed]
>
> Shaun O'Shea wrote:
> >
> > I want to remove the spaces from something similar to the following:
> >
> > 152 41-cax 102 577
> >
> > Someone else suggested:
> > $string= s/\s//g;
> ^^^^ =~
>
> > But this seemed to remove all characters!
>
> I'm not surprised. I think that this parses to
>
> $string = ( $_ =~ s/\s//g );
>
> which isn't what you want.
>
> - doug
------------------------------
Date: Tue, 1 Jul 1997 00:57:51 GMT
From: ced@bcstec.ca.boeing.com (Charles DeRykus)
Subject: Re: Q: an alternative to this use of "goto"?
Message-Id: <ECM80G.33w@bcstec.ca.boeing.com>
In article <33B25B10.4F975DA2@hotmail.com>,
Scott Blanksteen <sibsib@hotmail.com> wrote:
>Mike Stok wrote:
>> In article <33B1EF30.629CFCC6@ix.netcom.com>,
>> Larry D'Anna <ldanna@ix.netcom.com> wrote:
>>
>> >but the amazingly useful goto is not a goto, it is a homophone. goto
>> >&funcis no more the same as the much hated other forms of goto then
>> >'too' is the
>> >same as 'two' or 'to'.
>>
>> Then maybe it should be renamed gotoo or gotwo. It is unusual in English
>> to have a homophone whose different written forms have meanings which are
>> easily confused, and it's also unusual to condisider a word to be a
>> homophone of itself, otherwise all languages are just brimming with
>
>
>Hmm. Doesn't really have much to do with Perl, does it...
Yeah, but this fun ;)
I seem to recall from the mists of time in some obscure place
a language with both "go to" and "goto". The former would clearly
have more class being spared the indignity of a run-together phrase.
"goto &sub" would easily be worthy of this elevated status.
But, "gotoo" or "gotwo" as possibilities ... nah :)
--
Charles DeRykus
ced@carios2.ca.boeing.com
------------------------------
Date: Wed, 02 Jul 1997 02:55:59 -0400
From: Oliver Giller <oliver@inetu.net>
Subject: Re: Request for Bids - Web Site Mirroring Script
Message-Id: <33B9FB7F.DF149B9C@inetu.net>
This is a multi-part message in MIME format.
--------------05229BF4E37C95A8A6F75A3B
Content-Type: text/plain; charset=us-ascii
Content-Transfer-Encoding: 7bit
> overby@crl.com writes:
> > The Internet Guide to Hostelling (www.hostels.com), is currently
> > seeking assistance to develop a script that will be used to
> > mirror web sites at other locations to our server.
Check out webcopy, it will copy files (recursively) via HTTP protocol.
Works great at mirroring sites, just through it in a shell script and
there you go.
http://www.inf.utfsm.cl/~vparada/webcopy.html
--------------05229BF4E37C95A8A6F75A3B
Content-Type: text/x-vcard; charset=us-ascii; name="vcard.vcf"
Content-Transfer-Encoding: 7bit
Content-Description: Card for Oliver Giller
Content-Disposition: attachment; filename="vcard.vcf"
begin: vcard
fn: Oliver Giller
n: Giller;Oliver
org: INetU
adr: 744 Roble Rd;;Suite 70;Allentown;PA;18103;US
email;internet: oliver@inetu.net
tel;work: 610-266-7441
tel;fax: 610-266-7434
x-mozilla-cpt: ;0
x-mozilla-html: TRUE
end: vcard
--------------05229BF4E37C95A8A6F75A3B--
------------------------------
Date: Tue, 01 Jul 1997 14:51:02 GMT
From: ref@mesasys.com (Ronald E. Fortin)
Subject: SFIO
Message-Id: <5pb5ma$6f8$1@hal.brainiac.com>
Keywords: sfio fastcgi
Hello,
I'm trying to build perl5.004-01 with sfio on my HPUX 10 system. And I'm
getting the following errors:
Making Fcntl (dynamic)
cc -c -D_HPUX_SOURCE -Ae
-I/usr/local/include
-I/sos/web/tools/Languages/perl/add_ons/sfio97/include -O
-DVERSION=\"1.03\" -DXS_VERSION=\"1.03\" +z -I../.. Fcntl.c
cc: "/usr/include/pwd.h", line 89: error 1000: Unexpected symbol: "*".
cc: "/usr/include/pwd.h", line 94: error 1000: Unexpected symbol: "*".
cc: "/usr/include/pwd.h", line 89: error 1506: Parameters allowed in
function definition only.
cc: "/usr/include/pwd.h", line 94: error 1506: Parameters allowed in
function definition only.
*** Error exit code 1
>From examining the code in pwd.h it would appear that FILE is not being
defined (here's the suspect code):
# if defined(__STDC__) || defined(__cplusplus)
# ifndef _STDIO_INCLUDED
# include <stdio.h>
# endif /* _STDIO_INCLUDED */
extern struct passwd *fgetpwent(FILE *);
extern struct s_passwd *getspwent(void);
extern struct s_passwd *getspwuid(int);
extern struct s_passwd *getspwaid(int);
extern struct s_passwd *getspwnam(char *);
extern struct s_passwd *fgetspwent(FILE *);
# ifdef _REENTRANT
Does anyone have any ideas as to why this is happening?
Thanks
---
Ronald E. Fortin
Senior Engineer
ref@mesasys.com
Mesa Systems Guild, Inc.
60 Quaker Lane
Warwick, RI 02886
401-828-8500
www.mesasys.com
------------------------------
Date: 1 Jul 1997 02:26:42 GMT
From: nvp@shore.net (Nathan V. Patwardhan)
Subject: Re: strange problem...
Message-Id: <5p9pt2$iom@fridge-nf0.shore.net>
Tom Phoenix (rootbeer@teleport.com) wrote:
: > 553 Invalid address syntax
: Well, this looks like a disagreement with the mail system, rather than a
: problem with Perl. But maybe when you read that address from a file, you
: didn't chomp it to remove a trailing newline, or there's something else
: wrong with it.
Yep. It's possibly sendmail being unhappy about teste.com. My
version will do the same thing if you try to use something weird when
sending the MAIL command. Kind of breaks down on sending fake email. :-)
Loving undocumented features ...
--
Nathan V. Patwardhan
nvp@shore.net
------------------------------
Date: Tue, 1 Jul 1997 05:15:25 GMT
From: tcyang@netcom.com (Tung-chiang Yang)
Subject: Re: string to integer HELP !!
Message-Id: <tcyangECMJxp.JIC@netcom.com>
$a = '123';
then you can use the magical operator '=' to convert it to an integer, say,
$b = $a;
now $b would be equal to 100+20+3=3x41=123, which is an integer :)
================================
david wrote on his Best Friend's Wedding:
: Hello, I'm David.
: I need that someone help me.
: I want to convert a string into a integer number. How can i do it?
: Thanks.
: davidvr@redestb.es
--
========= Try the low-crossposting robomoderated 'alt.culture.taiwan' ===
soc.culture.taiwan, soc.culture.china (by SCC FAQ Team) FAQ's:
http://www.iglou.com/tcyang/Taiwan_faq.shtml, China_faq.shtml
------------------------------
Date: 01 Jul 1997 11:19:01 +0300
From: Jarkko Hietaniemi <jhi@alpha.hut.fi>
Subject: Re: string to integer HELP !!
Message-Id: <oeek9jbchhm.fsf@alpha.hut.fi>
> I want to convert a string into a integer number. How can i do it?
Why? What for?
Given
$a = "123";
$b = "456 bottles of beer";
these work
$c = $a * $b;
print "c = $c\n";
printf("b as a number is %d\n", $b);
For most tasks there is no need to do any conversions. If a string
looks like a number, it will be used as a number for operations that
make sense for numbers.
If the _integer_ is really needed, use the - (drum roll, maestro) -
int() function.
$d = "789.123";
$e = int($d);
--
$jhi++; # http://www.iki.fi/~jhi/
# There is this special biologist word we use for 'stable'.
# It is 'dead'. -- Jack Cohen
------------------------------
Date: Tue, 01 Jul 1997 10:55:09 +0200
From: Christian Borup <borup@DK.net>
To: Howard Yen <howard.yen@mci2000.com>
Subject: Re: Use Perl in C
Message-Id: <33B8C5ED.4F0943D7@DK.net>
Howard Yen wrote:
> How do I run Perl subroutine from C. I have tried reading the
> documents however I got as far as compling very
> simple perl subroutines (sub's that does not use any modules)
The perlembed man pages, in the latest version of perl 5.004, explains
this rather throughly. The examples mostly deal with modules using XS,
but perl-only modules should be simpler still. Also be sure to get
Devel::Embed from CPAN, embeding perl without it is a pain.
I hope this helps
Borup
------------------------------
Date: Tue, 01 Jul 1997 10:08:55 +0100
From: Simon Fairey <sfairey@adc.metrica.co.uk>
To: gardipj@nu.com
Subject: Re: using @_
Message-Id: <33B8C926.167E@adc.metrica.co.uk>
gardipj@nu.com wrote:
>
> In the following routine, I am trying to capture the $price variable
> locally (this is a shopping cart program) and then multiply that
> by 5% sales tax. Why won't the following work? Is it because I am
> using @_? If so, how can I get around that?
>
> When I run this, the MAtax output is 0.
>
> I am fairly new to Perl and cannot find the answer in any of my books.
>
> ******************************
> sub cart_table_footer {
> local($price) = @_;
> local($MAtax) = $price * 0.05;
> print qq!
> <P>
> Pre-shipping, Pre-tax Total = $price
> <P>
> Price after MA tax = $MAtax
> <P>!;
> }
>
> ******************************
>
> Thanks,
> Pam
There is nothing wrong with your syntax. By 'not working' I am going to
assume that it runs but you just don't get the right result. If that is
the case then I think the maths is where your problem is you want to be
multiplying the price by 1.05 rather than 0.05 if you want the price
plus 5%, at the moment it is just giving you 5% of the price.
Simon
------------------------------
Date: 01 Jul 1997 16:31:11 +0300
From: Jarkko Hietaniemi <jhi@alpha.hut.fi>
Subject: Re: Y2K and Perl (was Re: Y2K problems??)
Message-Id: <oee67uuc31c.fsf@alpha.hut.fi>
mjtg@cus.cam.ac.uk (M.J.T. Guy):
> So is my SunOS different from everyone else's?
box1 (74) >/bin/date
Tue Jul 1 16:30:17 EET DST 1997
box1 (75) >uname -a
SunOS box1 4.1.4 2 sun4m
box1 (76) >
box2 (51) >/bin/date
Tue Jul 1 16:31:34 EET DST 1997
box2 (52) >uname -a
SunOS box2 5.5.1 Generic_103640-03 sun4m sparc sun4m
box2 (53) >
I have no idea what Russ is trying to say here:
Russ Allbery <rra@stanford.edu>:
> For example, on SunOS /bin/date has no way of returning the full year rather
>than just the last two digits.
--
$jhi++; # http://www.iki.fi/~jhi/
# There is this special biologist word we use for 'stable'.
# It is 'dead'. -- Jack Cohen
------------------------------
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 689
*************************************