[6387] in Perl-Users-Digest

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

Perl-Users Digest, Issue: 12 Volume: 8

daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Tue Feb 25 16:27:14 1997

Date: Tue, 25 Feb 97 13:00:25 -0800
From: Perl-Users Digest <Perl-Users-Request@ruby.OCE.ORST.EDU>
To: Perl-Users@ruby.OCE.ORST.EDU (Perl-Users Digest)

Perl-Users Digest           Tue, 25 Feb 1997     Volume: 8 Number: 12

Today's topics:
     Re: bash to  perl script (Terence Jordan)
     Re: Built-in variable for loop iteration#? (Brian L. Matthews)
     Re: Calling subroutines (Nathan V. Patwardhan)
     Can you create file on the fly with perl? (Dico Reyers)
     Re: Can you create file on the fly with perl? (Nathan V. Patwardhan)
     Re: Can you create file on the fly with perl? (Terence Jordan)
     Re: Converting date "serial number" back to a "normal"  <jander@ml.com>
     Re: Determine perl program memory usage (Keith Thompson)
     double fork? <kin@sampras.isi.com>
     Formatting numbers (Dico Reyers)
     Re: Generating a randomly sorted list of integers spammers@must.die.com  
     Re: Gross error in regular expression (...)? clause <dbenhur@egames.com>
     Re: Gross error in regular expression (...)? clause <rootbeer@teleport.com>
     Re: How to spam - legitimately <twpierce+usenet@mail.bsd.uchicago.edu>
     Re: How to spam - legitimately (Chris Nandor)
     Re: html parser <eryq@enteract.com>
     mSQL calls from Perl <timr@zimmers.com>
     PDF on the Fly with Perl5 <joneil@is.ssd.k12.wa.us>
     Perl 5.003+ for MS-DOS ? (Petr Prikryl)
     Re: perl probs with files <jander@ml.com>
     Re: Perl Reference (Marcelo)
     Re: PERL script for HTTP transfer ? <jander@ml.com>
     Re: Q: How to delete several files in one operation (ne <rootbeer@teleport.com>
     Re: syntax error <hub@club-internet.fr>
     Re: upper to lowercase replace <powers@ml.com>
     Use "use" when and where (Eric Palmer)
     Using a variable for mode in chmod and mkdir <ragoff@sandia.gov>
     weird split prob <dcordero@giss.nasa.gov>
     Re: weird split prob (Nathan V. Patwardhan)
     Re: What happens if you use a -l switch without -[np]? (Brian L. Matthews)
     Why do I get a ^\ when doing "multi-dimension" key in a (Wai Fai Yee~)
     Re: Writing a subroutine (Nathan V. Patwardhan)
     Re: Writing a subroutine <rootbeer@teleport.com>
     Digest Administrivia (Last modified: 8 Jan 97) (Perl-Users-Digest Admin)

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

Date: Tue, 25 Feb 1997 20:14:54 GMT
From: tjordan@ns15.cca.rockwell.com (Terence Jordan)
Subject: Re: bash to  perl script
Message-Id: <331347ce.26999623@news>

On Tue, 25 Feb 1997 11:24:12 -0600, Steve Vandiver <buxx@buxx.com>
wrote:

>Need to detect if file exists then ... else ...  

if (-e "c:/autoexec.bat") {
 print "File exists!";
} else {
 print "D'oh! File's left town!";
}
# no "fi", either


+--Terence Jordan(x7233)----------------+----------------------------+
|TJordan@NS15.CCA.ROCKWELL.COM          | "When in danger,     <O>   |
|(parenthesis)                          |  Or in doubt,         |    |
|---------------------------------------|  Run in circles,    _/ \   |
|Views expressed are Terence's          |  Scream and shout!"    /   |
+-----and of no other.------------------|----------------------------+


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

Date: 25 Feb 1997 09:40:15 -0800
From: blm@halcyon.com (Brian L. Matthews)
Subject: Re: Built-in variable for loop iteration#?
Message-Id: <5ev85v$s8e$1@halcyon.com>

In article <5et26u$rp3@taurus.fccc.edu>,
Michael N. Edmonson <edmonson@yulara.fccc.edu> wrote:
|I'm wondering if there's a built-in "counter" variable somewhere in
|Perl that will tell me number of the current iteration of a loop.

Nope. You'll either have to do:

for (0..$#array)
{
	# do something with $array[$_]
}

or, if @array could be big:

for ($_ = 0; $_ < @array; $_++)
{
	# do something with $array[$_]
}

Brian
-- 
Brian L. Matthews				Illustration Works, Inc.
	For top quality, stock commercial illustration, visit:
		  http://www.halcyon.com/artstock


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

Date: 25 Feb 1997 18:40:47 GMT
From: nvp@shore.net (Nathan V. Patwardhan)
Subject: Re: Calling subroutines
Message-Id: <5evbnf$4m0@fridge-nf0.shore.net>

Luis Torres (ltorres@campus.ruv.itesm.mx) wrote:

: Undefined subroutine &main::parse_form_data called at multiplearchivo.pl
: Do I have to include my sub in another file or what??

Yes.

If I have a file called include.pl, and a file called client.pl that
needs a subroutine, the set-up should look like:

### include.pl

sub send_out {

#etc

}

### return true
1;


### client.pl
require 'include.pl';

&send_out();

You should be all set, now.

--
Nathan V. Patwardhan
nvp@shore.net
"Lane, I've been in high school for
seven years.  I'm no dummy"
	--Charles Demar from _Better Off Dead_


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

Date: Tue, 25 Feb 1997 17:58:56 GMT
From: dico@isn.net (Dico Reyers)
Subject: Can you create file on the fly with perl?
Message-Id: <33132804.15873481@nntp.uunet.ca>

	
Hello...

I would like to know if you can create a file on the fly with PERL.

Say if $filename = johnny;  I would like the PERL script to make an
empty file called johnny.  

Could someone please help me?

~Dico


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

Date: 25 Feb 1997 18:46:37 GMT
From: nvp@shore.net (Nathan V. Patwardhan)
Subject: Re: Can you create file on the fly with perl?
Message-Id: <5evc2d$4m0@fridge-nf0.shore.net>

Dico Reyers (dico@isn.net) wrote:

: Say if $filename = johnny;  I would like the PERL script to make an
: empty file called johnny.  

What's wrong with doing:

open(NEWFILE, ">$filename") || die("No: $!\n");
close(NEWFILE);

--
Nathan V. Patwardhan
nvp@shore.net
"Lane, I've been in high school for
seven years.  I'm no dummy"
	--Charles Demar from _Better Off Dead_


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

Date: Tue, 25 Feb 1997 20:12:01 GMT
From: tjordan@ns15.cca.rockwell.com (Terence Jordan)
Subject: Re: Can you create file on the fly with perl?
Message-Id: <3313468d.26679016@news>

On Tue, 25 Feb 1997 17:58:56 GMT, dico@isn.net (Dico Reyers) wrote:
>Say if $filename = johnny;  I would like the PERL script to make an
>empty file called johnny.  
>
>Could someone please help me?

$johnny="c:/windows/desktop/redic/ulous/folder/struct/johnny.txt";

open(foo,">".$johnny); #output
 print foo "If I could be a vegetable, I\'d be a carrot!\n\n\n";
close(foo);

open(foo,"<".$johnny); #input
 binmode(foo);
 @slurp = <foo>; #burp
 print @slurp;
close(foo);

open(foo,">>".$johnny); #append
 print foo "ok, maybe I'd be a spinnach...\n\n\n";
close(foo);



+--Terence Jordan(x7233)----------------+----------------------------+
|TJordan@NS15.CCA.ROCKWELL.COM          | "When in danger,     <O>   |
|(parenthesis)                          |  Or in doubt,         |    |
|---------------------------------------|  Run in circles,    _/ \   |
|Views expressed are Terence's          |  Scream and shout!"    /   |
+-----and of no other.------------------|----------------------------+


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

Date: 25 Feb 1997 16:27:20 +0000
From: Jim Anderson <jander@ml.com>
Subject: Re: Converting date "serial number" back to a "normal" date
Message-Id: <wkb3euku9zr.fsf@swapsdvlp15.i-did-not-set--mail-host-address--so-shoot-me>

"Andrew Pollock" <apollock@bit.net.au> writes:

> Hi,
> 
> I am trying to convert the output of a /bin/date +%j back into a normal
> date. I understand that this value is not the Julian date in the manner of
> speaking that the Date modules I have looked at from CPAN are talking
> about. Is there any easy way of doing this?
> 
> Eg. date +%j = 056, 56 = Feb 25, 1997.

I suspect you are either not looking closely enough at the various
CPAN date modules, or you've overlooked one. I believe it can be done
either with DateCalc or DateManip--I don't remember which.


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

Date: Tue, 25 Feb 1997 09:51:43 GMT
From: kst@sd.aonix.com (Keith Thompson)
Subject: Re: Determine perl program memory usage
Message-Id: <E65Kq7.GDC@thomsoft.com>

In <5eku6r$cl0$1@csnews.cs.colorado.edu> Tom Christiansen <tchrist@mox.perl.com> writes:
[...]
>     system "ps l$$";

This won't work in all versions of Unix.  For example, it works under
SunOS 4.x, but not Solaris 2.x.  (I suppose it's a System V thing.)

I think the Solaris equivalent is "ps -l -p $$".

-- 
Keith Thompson (The_Other_Keith) kst@sd.aonix.com <http://www.aonix.com> <*>
TeleSo^H^H^H^H^H^H Alsy^H^H^H^H Thomson Softw^H^H^H^H^H^H^H^H^H^H^H^H^H Aonix
10251 Vista Sorrento Parkway, Suite 300, San Diego, CA, USA, 92121-2706
"Humor is such a subjective thing." -- Cartagia


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

Date: 25 Feb 1997 10:48:25 -0800
From: Kin Cho <kin@sampras.isi.com>
Subject: double fork?
Message-Id: <nwafosafie.fsf@sampras.isi.com>

I'd like to start an xterm via the system() in my perl script
but I'd like the rest of my perl script to continue without blocking.

I tried the double fork trick described in FORK in the PERLFUNC online
reference without success:

unless ($pid = fork) {
    unless (fork) {
       exec 'xterm';
       die "no exec";
       exit 0;
    }
    exit 0;
}
waitpid($pid,0);
print "hello\n";

When this script is run, "hello" is printed, but nothing else happens.
"exec 'xterm';" does work by itself.

-kin

-- 
Kin Cho, Staff Engineer (408)542-1644 Fax (408)542-1958
Integrated Systems Inc., 201 Moffett Park Drive, Sunnyvale, CA 94089
http://www.isi.com

I'll procrastinate tomorrow
				-- Garfield.



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

Date: Tue, 25 Feb 1997 18:00:30 GMT
From: dico@isn.net (Dico Reyers)
Subject: Formatting numbers
Message-Id: <33132863.15968595@nntp.uunet.ca>

	
Hello There...

I would like some help with formating numbers.

Say that:

$number = 1.345;

I would like that number rounded off to two decimal spots. So number
would be  1.35  .

Please.... any help

~Dico


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

Date: Tue, 25 Feb 1997 18:04:46 GMT
From: spammers@must.die.com  
Subject: Re: Generating a randomly sorted list of integers
Message-Id: <wsandersE667Jy.3r0@netcom.com>

>"I'm writing this on my Timex Sinclair, with only 2K of memory..."  ;-)

I was surprised how little memory I had available when I ported some
scripts from Unix to MacPerl. I "randomize" /usr/dict/words or whatever
for input to my morse code practice program:

#!/usr/local/bin/perl
srand ( time() ^ ($$ + ($$ << 15)));
for (<STDIN>) {
   $r=rand;
   $words{$r} = $_;
   }
for (sort(keys(%words))) { 
   print $words{$_};
   }

Slurping big wads of data like this won't work on a Mac (or at least
mine. with 16 MB memory.) Or on my Sinclair either (yeah - let's
develop a Perl chip for swapping out the Basic VLSI in the ZX-80.)

-w


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

Date: Tue, 25 Feb 1997 10:58:05 -0800
From: Devin Ben-Hur <dbenhur@egames.com>
To: Mark-Jason Dominus <mjd@plover.com>
Subject: Re: Gross error in regular expression (...)? clause
Message-Id: <3313363D.69FD@egames.com>

Mark-Jason Dominus wrote:
> I don't know whether the gross error is in Per's regular expressions,
> or in me.  I suspect it's in me.  Maybe someone here can fix it.

it's you. we can.
 
> $RX_US = "U(\.|nited)?\s*S(\.|tates)?(\s*(of\s*)?A(\.|merica)?)?";
> @usalist = ('USA', 'U.S.A.', 'US', 'USA', 'United States',
>             'United States of America', 'US of A', 'U.S. of A.', 'US of A.');
> foreach $usa (@usalist) {
>   if ($usa !~ /$RX_US/oi) {
>     warn "WARNING: `$usa' did NOT match \$RX_US.\n";
>   }
> }
> WARNING: `United States' did NOT match $RX_US.
> WARNING: `United States of America' did NOT match $RX_US.
> Why didn't those two strings match?

look at this:
  $RX_US = "U(\.|nited)?\s*S(\.|tates)?(\s*(of\s*)?A(\.|merica)?)?";
  print "rx='$RX_US'\n";
prints:
  rx='U(.|nited)?s*S(.|tates)?(s*(ofs*)?A(.|merica)?)?'

See, the '\.' and '\s' strings got collapsed (the \ just
escaped the next character) when you specified your
literal double quoted string.

do this instead:
  $RX_US =
"U(\\.|nited)?\\s*S(\\.|tates)?(\\s*(of\\s*)?A(\\.|merica)?)?";
if you want those backslashes to survive until you use it
in the regexp.

HTH
--
Devin Ben-Hur      <dbenhur@egames.com>
eGames.com, Inc.   http://www.egames.com/
eMarketing, Inc.   http://www.emarket.com/
"Don't run away. We are your friends."  O-



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

Date: Tue, 25 Feb 1997 12:29:04 -0800
From: Tom Phoenix <rootbeer@teleport.com>
To: Mark-Jason Dominus <mjd@plover.com>
Subject: Re: Gross error in regular expression (...)? clause
Message-Id: <Pine.GSO.3.95q.970225122736.18288Y-100000@kelly.teleport.com>

On 25 Feb 1997, Mark-Jason Dominus wrote:

> $RX_US = "U(\.|nited)?\s*S(\.|tates)?(\s*(of\s*)?A(\.|merica)?)?";

The double quotes are interpolating those backslashes. I think you want
single quotes. Hope this helps!

-- Tom Phoenix        http://www.teleport.com/~rootbeer/
rootbeer@teleport.com   PGP  Skribu al mi per Esperanto!
Randal Schwartz Case:     http://www.lightlink.com/fors/



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

Date: Tue, 25 Feb 1997 18:14:59 GMT
From: Tim Pierce <twpierce+usenet@mail.bsd.uchicago.edu>
Subject: Re: How to spam - legitimately
Message-Id: <E6680z.FCq@midway.uchicago.edu>

In article <pudge-ya02408000R2402971534480001@news.idt.net>,
Chris Nandor <pudge@pobox.com> wrote:

>If this were a language with a more full tense structure, we would have two
>plural forms, one for "email" and one for "pieces of email."  But we do
>not.  And since we are too lazy to say "pieces of email," "emails" will
>have to suffice.  You can't stop it.  Don't even bother trying.

If this were actually happening, I would tend to agree with you.
But so far, I know no native speaker of English who uses the
plural term ``emails'' when referring to distinct electronic mail
messages, so I tend to doubt this analysis.  Tom is right to
object to its use.

-- 
Support the Hawaii Equal Rights Marriage Project: call 1-900-97-MARRY ($5/call)


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

Date: Tue, 25 Feb 1997 15:20:48 -0500
From: pudge@pobox.com (Chris Nandor)
Subject: Re: How to spam - legitimately
Message-Id: <pudge-ya02408000R2502971520480001@news.idt.net>

In article <E6680z.FCq@midway.uchicago.edu>, Tim Pierce
<twpierce+usenet@mail.bsd.uchicago.edu> wrote:

#If this were actually happening, I would tend to agree with you.
#But so far, I know no native speaker of English who uses the
#plural term ``emails'' when referring to distinct electronic mail
#messages, so I tend to doubt this analysis.

Hi, my name is Chris, nice to meet you.  Every morning I mull through
various emails, filing them away, as it is a rare email indeed that I
actually delete.

BTW, this reply is being emailed to the original author.

#================================================================
Lots of comedians have people they try to mimic.  I mimic my
shadow.

   --Steven Wright

Chris Nandor                                      pudge@pobox.com
PGP Key 1024/B76E72AD                           http://pudge.net/
Keyfingerprint = 08 24 09 0B CE 73 CA 10  1F F7 7F 13 81 80 B6 B6


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

Date: Tue, 25 Feb 1997 13:05:51 -0600
From: Eryq <eryq@enteract.com>
To: Sugree Phatanapherom <ioisgp@std.cpc.ku.ac.th>
Subject: Re: html parser
Message-Id: <3313380F.5EB19720@enteract.com>

Sugree Phatanapherom wrote:
> 
> Have anyone can help me to write some code to parse html? Now I really
> need function that accepts a string and returns me next tag or any words
> until next tag.

Go to your nearest CPAN site (www.perl.com/CPAN) and install a copy
of the HTML::Parser module.

Hope that helps,
-- 
  ___  _ _ _   _  ___ _   Eryq (eryq@enteract.com)
 / _ \| '_| | | |/ _ ' /  Hughes STX, NASA/Goddard Space Flight Cntr.
|  __/| | | |_| | |_| |   http://www.enteract.com/~eryq
 \___||_|  \__, |\__, |__ 
           |___/    |___/ UNIX-FM: more talk ; less yacc yacc yacc


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

Date: 25 Feb 1997 17:50:33 GMT
From: "Timothy B. Rutherford" <timr@zimmers.com>
Subject: mSQL calls from Perl
Message-Id: <01bc2344$ca3a54e0$20cb70ce@timr.access.one.net>

Howdy,

Hopefully someone can help me.  I need to make SQL calls from Perl.  I
haven't been able to find any references to it on the net.  Does anyone
know any of the basic commands?  I am somewhat familiar with SQL (the basic
commands) and I am pretty familiar with Perl, but I am not sure how the two
intermingle.  What I need to be able to do from Perl is:

Find a record and update the information in that record.
Find a record and delete it (completely).
Find a record and display that information only.

All I've really been able to figure out is how to add a record to the end
of a table and to display all records whose fields meet a certain criteria.

Variations of the following command are all I have gotten to work:

use Msql;
Msql->Connect(zimmers)->Query("insert into testdata (number,seccode)
values ('5150','1013')");

If anyone has any information or can direct me to a web site with this
information, I would be very appreciative!

Thanks,
Tim Rutherford
Zimmers Interactive




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

Date: Tue, 25 Feb 1997 11:41:43 -0800
From: Jerome O'Neil <joneil@is.ssd.k12.wa.us>
Subject: PDF on the Fly with Perl5
Message-Id: <33134077.34CF@is.ssd.k12.wa.us>

I have been investigating methods to manipulate Adobe PDF documents with
Perl5 using the University of Nottingham's PDF on the Fly Pdf.pm
module.  While the module shows great promise, I realy need to be able
to manupulate existing documents, with the goal of distributing uniquely
indexed PDFs from a common template.  Has anyone developed a Perly way
of doing this, or has the PDF on the Fly module developed these
capabilities since September '96 (Date on my documentation)?

Thanks much!

Jerome O'Neil
Seattle Public Schools
Information Services


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

Date: 25 Feb 1997 17:05:39 GMT
From: prikryl@dcse.fee.vutbr.cz (Petr Prikryl)
Subject: Perl 5.003+ for MS-DOS ?
Message-Id: <5ev653$fl5@boco.fee.vutbr.cz>

Hallo to all who like Perl,

My question is: Does anybody have an experience with a port of Perl 5.003
or higher for pure MS-DOS (like version 6.22; namely short file names)? 
I have played for a while with Ilya Zakharevich's Perl 5.00305 port for
OS/2, but I was unsuccessful considering really working instalation.

Following the advices from Ilya's documentation and also given by
palincsars.isc@gao.gov (I do not know his/her name) and Dean Pentcheff 
<dean@tbone.biol.sc.edu> (named here just to thank them ;-), I could not
avoid problems with long filenames. I did a lot of patchwork on the 
perl_.exe, I have shortened the names of directories and of files (trying
to reflect the changhes where it could be expected), but finaly I have
got many messages of the kind "Process terminated by SIGPIPE" for the
scripts that ran smoothly on Darryl Okahata's port of 5.0beta (knowing
that some functions like utime were not implemented).

I also want to run the scripts under MS-Windows and Windows'95, but
NOT ONLY under these systems -- plain old MS-DOS is a MUST for me
as the scripts are used to install local configurations of Windows
on computers where only MS-DOS is. Running the scripts under Win'95
I've got messages like "WARNING: emx 0.9b or later required" even
when emx 0.9c was used (and rsx 5.10). Morover, the scripts also 
crashed with the above mentioned "Process terminated by SIGPIPE" message
(I suspect the glob()).

Does exist some other port of Perl 5.003+ that can be used for MS-DOS?
Is anybody involved in porting the Perl for DOS under DJGPP ?

Thanks for information,

Petr

--
Petr Prikryl (prikryl@dcse.fee.vutbr.cz)   http://www.fee.vutbr.cz/~prikryl/
TU of Brno, Dept. of Computer Sci. & Engineering;     tel. +42-(0)5-7275 218


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

Date: 25 Feb 1997 16:34:07 +0000
From: Jim Anderson <jander@ml.com>
Subject: Re: perl probs with files
Message-Id: <wkbzpwssv40.fsf@swapsdvlp15.i-did-not-set--mail-host-address--so-shoot-me>

Iqbal Gandham <igandham@prestel.net> writes:

> Hi
> 
> I have a file which contains two kinds of records. 
> 
> e.g upload blah blah blah
> and group eenie meenie etc etc
> 
> the thing is that I need to add another upload record to the file. I do
> not just want to append it to the end of the file, but instead add it
> after the last upload line. I then want to add another record to the
> group line, agian I do not just want to  create a new line with group in
> it, just append it to the last record. 
> 
> Basically I just want to be able to insert text into a file where I
> want.
> 
> Also is is possible to delete one line from a file which matches a
> pattern.

1. Read the file into an array, skipping any records you want to delete.

2. Use splice or a foreach loop to insert records into the array
   anywhere you like.

3. Using the array, rewrite the file.



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

Date: Tue, 25 Feb 1997 19:54:43 GMT
From: mfioroni@art.com.br (Marcelo)
Subject: Re: Perl Reference
Message-Id: <33134355.27579918@silicon.teknowledge.com>

On 24 Feb 1997 16:00:51 GMT, clay@panix.com (Clay Irving) wrote:

>With great trepidation, I announce the Perl Reference (written in
>Perl, of course.). The URL is:
>
>	http://www.panix.com/~clay/perl
>
>It works for me -- Maybe it will work for you. :) 
>
>-- 
>See the happy moron,                             
>He doesn't give a damn,                                    Clay Irving N2VKG  
>I wish I were a moron,                                        clay@panix.com
>My God! Perhaps I am!                             http://www.panix.com/~clay
>
>

Dear Clay,
Thanks for your tip. I was very very useful!


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

Date: 25 Feb 1997 16:45:32 +0000
From: Jim Anderson <jander@ml.com>
Subject: Re: PERL script for HTTP transfer ?
Message-Id: <wkbrai4sukz.fsf@swapsdvlp15.i-did-not-set--mail-host-address--so-shoot-me>

"iSAEW aNDREJ" <iae@exchange.spb.inkom.ru> writes:

> Help to me! I would like to use MIRROR but it works only via native FTP,
> and my access in INTERNET is possible only through HTTP PROXY (Squid )!
> Where is possible get  PERL SCRIPT for work with HTTP by the protocol or
> better MIRROR for HTTP PROXY ?

get the latest LWP package from CPAN


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

Date: Tue, 25 Feb 1997 12:06:09 -0800
From: Tom Phoenix <rootbeer@teleport.com>
To: Jarle Aasland <sajaa@sn.no>
Subject: Re: Q: How to delete several files in one operation (newbie)
Message-Id: <Pine.GSO.3.95q.970225120457.18288T-100000@kelly.teleport.com>

On Tue, 25 Feb 1997, Jarle Aasland wrote:

> Problem: I can now delete each file by itself (by clicking it's
> respective "Delete" link), but what I want to do is choose several
> files, and then "Delete all marked files".

Perhaps you're looking for this? Hope this helps!

     unlink @goners;		# Poof!

-- Tom Phoenix        http://www.teleport.com/~rootbeer/
rootbeer@teleport.com   PGP  Skribu al mi per Esperanto!
Randal Schwartz Case:     http://www.lightlink.com/fors/



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

Date: Sun, 23 Feb 1997 06:13:29 +0100
From: Nicolas Hubert <hub@club-internet.fr>
To: mpanfilo@mailbox.syr.edu
Subject: Re: syntax error
Message-Id: <330FD1F9.20B731E3@club-internet.fr>

Hummmm. I use Perl 5.003 and your source compiles just fine.

Nicolas

Maksym Panfilov wrote:
> 
> I just could not come up with that simple suyntax error problem. Perl
> says: syntax error in file cg.cgi at line 30, next 2 tokens "]["
> 
> But I don't get what's wrong with that line.
> Line 30 is: $grade[$j][$quiz] = $score;
> And here is a part of the program with that line.
> 
> I will really appreciate any help. Thanks in advance.
> 
> Please, reply to my e-mail: mpanfilo@syr.edu
> Max.
> 
> ---------------------------------------
> open(GRADES,$grades_file_) || die;
> while(<GRADES>) {
>         ($id, $quiz, $score) = split(/\ /);
>         $j = 0;
>         while ($j < $count) {
>                 if ($netid[$j] eq $id) { last; }
>                 $j++;
>         }
>         $grade[$j][$quiz] = $score;
> }
> close GRADES;
> --------------------------------------


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

Date: 25 Feb 1997 14:09:08 -0500
From: "Brent B. Powers Swaps Programmer x2293" <powers@ml.com>
Subject: Re: upper to lowercase replace
Message-Id: <u02d8toog8b.fsf@ml.com>

mstearns@darkwing.uoregon.edu (Michael Paul Stearns) writes:

 > I am trying to do a search and replace that involves changing an uppercase character to a lowercase.
 > 
 > Right now I have :
 > $text=~ tr^(<a href = \"\#)A-Z(\w+.*?\")^\1a-z\2^s;
 > 
 > But this doesn't work.
 > 
 > Any idea what I am doing wrong?
 > 


Not checking the docs?
$text = lc($text);

-- 
Brent B. Powers               Merrill Lynch              powers@ml.com


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

Date: Tue, 25 Feb 1997 19:51:06 GMT
From: efp@mindspring.com (Eric Palmer)
Subject: Use "use" when and where
Message-Id: <33134120.730029@news.comstar.net>

Where should I place "use module" statements when I have both a
main.pl program and modules that depend on other modules?

Suppose I have this situation where main.pl needs access to
subroutines/methods in these *.pm files

in main.pl
  use lib1;
  use lib2;
  use lib3;

and lib2 and lib3 depends on access to the modules shown

in lib2.pm
  use lib1;



in lib3.pm
  use lib1;
  use lib2;


Where should I place the use commands and if I put them in all of the
above will this cause extra work.  I don't want the use use use ...
to the point of causing extra work.

Thanks In Advance


--
Eric P.
efp@etechinc.com
http://www.etechinc.com/
<*** standard disclaimer ***>


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

Date: Tue, 25 Feb 1997 12:13:31 -0700
From: "Robert A. Goff" <ragoff@sandia.gov>
Subject: Using a variable for mode in chmod and mkdir
Message-Id: <331339DB.446B@sandia.gov>

I need help using a variable for the mode parameter in chmod and mkdir,
e.g.

$dirmode = '0777';
$filemode = '0755';
mkdir("$FORM{'cwd'}/$FORM{'dirname'}", $dirmode);
chmod($filemode, "$FORM{'cwd'}/$FORM{'filename'}");

which results in a file/directory with the wrong mode.  Using the
literal octal numbers gets me the right mode, so I obviously don't know
how to cast a variable to an octal value.  Any help appreciated,
including telling me which part of TFM to R.
-- 
=================================================
Robert Goff             email: ragoff@sandia.gov
Sandia National Labs    Phone: (505)284-3639


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

Date: Tue, 25 Feb 1997 13:37:52 -0500
From: "Douglas L. Cordero, PhD" <dcordero@giss.nasa.gov>
Subject: weird split prob
Message-Id: <3313317F.41C6@giss.nasa.gov>

Hi all:
	This one is making me crazy.  Where am I screwing up?

> cat test.pl

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

$line = "/lastly/I/have.hadit/jkdnkjnvf.89090100";

@fields = split(/./, $line);

print "Here is field 0:",$fields[0],":\n";
print "Here is field 1:",$fields[1],":\n";
print "Here is field 2:",$fields[2],":\n";

RESULTS:

> test.pl

Use of uninitialized value at junk2.pl line 7.
Here is field 0::
Use of uninitialized value at junk2.pl line 8.
Here is field 1::
Use of uninitialized value at junk2.pl line 9.
Here is field 2::


Any help?

 
********************************************************
Doug Cordero
Science Systems and Applications, Inc.
NASA - Goddard Institute for Space Studies
email:   dcordero@giss.nasa.gov
********************************************************


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

Date: 25 Feb 1997 18:52:34 GMT
From: nvp@shore.net (Nathan V. Patwardhan)
Subject: Re: weird split prob
Message-Id: <5evcdi$4m0@fridge-nf0.shore.net>

Douglas L. Cordero, PhD (dcordero@giss.nasa.gov) wrote:
: #!/usr/local/bin/perl -w

: $line = "/lastly/I/have.hadit/jkdnkjnvf.89090100";

: @fields = split(/./, $line);

Do you mean:

$line = "/lastly/I/have.hadit/jkdnkjnvf.89090100";
@fields = split(/\//, $line); ### split on the '/'

foreach $field (@fields) {
  print("Field $i: $field\n");
  $i++;
}

Or, were you trying to split on the '.'?

In which case you'd do:

$line = "/lastly/I/have.hadit/jkdnkjnvf.89090100";
@fields = split(/\./, $line);

foreach $field (@fields) {
  print("Field $i: $field\n");
  $i++;
}

 
--
Nathan V. Patwardhan
nvp@shore.net
"Lane, I've been in high school for
seven years.  I'm no dummy"
	--Charles Demar from _Better Off Dead_


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

Date: 25 Feb 1997 09:53:22 -0800
From: blm@halcyon.com (Brian L. Matthews)
Subject: Re: What happens if you use a -l switch without -[np]?
Message-Id: <5ev8ui$srk$1@halcyon.com>

In article <TOM.97Feb24095518@palver.nospam.eiscat.no>,
Tom Grydeland <tom@palver.nospam.eiscat.no> wrote:
|But that still doesn't explain my mysterious output.

I couldn't duplicate your output. Your script worked as expected on
both systems I tried it on (Ultrix and a Mac).

Brian
-- 
Brian L. Matthews				Illustration Works, Inc.
	For top quality, stock commercial illustration, visit:
		  http://www.halcyon.com/artstock


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

Date: 25 Feb 1997 00:07:43 GMT
From: wyee@sedona.intel.com (Wai Fai Yee~)
Subject: Why do I get a ^\ when doing "multi-dimension" key in associative array ?
Message-Id: <5etagf$kri@chnews.ch.intel.com>



Hi everyone,

     	I checked the Perl5 book and the items listed under "Arrays and Shell 
and External Programs Interaction" and "General Programming, Regexps and I/O" in
the FAQ but did not find answers to my question - so I am going to ask it.

	Following is the program and its output which got me confused. I have
a nested loop and store a value in an associative array using

       $buf{$var1,$var2}++;  where $var1 and $var2 are ordinary variables.

However when I tried to retrieve the value of the associative array using
"$var1"."$var2" as the key, I got a NULL (See output from program). I then 
redirected the output to a file and when I do a "cat" and "more" on the file, 
I got this, 

210> more dummyfile.txt
Key = a^\x    Val = 1
Key = b^\x    Val = 1
Key = a^\y    Val = 1
Key = b^\y    Val = 1

211> cat dummyfile.txt
Key = ax    Val = 1
Key = bx    Val = 1
Key = ay    Val = 1
Key = by    Val = 1

	It seems like Perl put a "^\" between $var1 and $var2 when it
was constructing the key. It is also puzzling to me since this only showed
up in "more" but not "cat". Seems like the only way to retrive the data
is to do $buf{$var1,$var2} and $buf{"$var1"."$var2"} will fail. I am not
questioning the sanity of the way things are being done but I am curious about
the difference. Anyone kind enough to enlighten me as to where and why the 
"^\" came from?. ( I used Perl 5.003).


Thanks in advance

Wai Fai, YEE





# ---------------------- TEST PROGRAM ----------------------------

#!/usr/intel/96r2/bin/perl
@out1 = ("a", "b");
@out2 = ("x", "y");

foreach $var1 (@out1) {
   foreach $var2 (@out2) {
       $buf{$var1,$var2}++;
   };
};

@keys = keys %buf;

print "Print key and Content - just for verifying\n";
foreach $key (@keys) {
    print "Key = $key    Val = $buf{$key}\n";
};


print "\n\nAccess via concatenation\n";
print "This will not work.\n";
foreach $var1 (@out1) {
   foreach $var2 (@out2) {
       $target = $var1.$var2;
       print "Key = $target   Val = $buf{$target}\n";
   };
};

print "\n\nAccess via reconstructing key\n";
print "This will not work either.\n";
foreach $var1 (@out1) {
   foreach $var2 (@out2) {
       $target = $var1."^\\".$var2;
       print "Key = $target   Val = $buf{$target}\n";
   };
};

print "\n\nAccess via comma\n";
print "This works.\n";
foreach $var1 (@out1) {
   foreach $var2 (@out2) {
       print "$buf{$var1,$var2}\n";
   };
};

// ------------------- OUTPUT FROM TEST PROGRAM ---------------------

Print key and Content - just for verifying
Key = ax    Val = 1
Key = bx    Val = 1
Key = ay    Val = 1
Key = by    Val = 1


Access via concatenation
This will not work.
Key = ax   Val = 
Key = ay   Val = 
Key = bx   Val = 
Key = by   Val = 


Access via reconstructing key
This will not work either.
Key = a^\x   Val = 
Key = a^\y   Val = 
Key = b^\x   Val = 
Key = b^\y   Val = 


Access via comma
This works.
1
1
1
1

// --------------------------------------------------------------------







-- 
 Intel, Corp.
 5000 W. Chandler Blvd.
 Chandler, AZ  85226


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

Date: 25 Feb 1997 17:50:16 GMT
From: nvp@shore.net (Nathan V. Patwardhan)
Subject: Re: Writing a subroutine
Message-Id: <5ev8oo$4m0@fridge-nf0.shore.net>

Angel Leyva (airborne@cybernex.net) wrote:

: Basically, I want to strip some characters and replace others. For example, I
                       ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
: want to strip leading and trailing spaces and newlines.
          ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

Aw, c'mon, man... you can't be saying that you didn't find this in the
documentation?!?!  :-)

Please get the FAQ from: http://www.perl.com/CPAN/doc/FAQs/FAQ/FAQ.html.gz
and a good beginner's book like _Learning Perl_ by Randal Schwartz
(published by O'Reilly and Associates).

HTH!

--
Nathan V. Patwardhan
nvp@shore.net
"Lane, I've been in high school for
seven years.  I'm no dummy"
	--Charles Demar from _Better Off Dead_


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

Date: Tue, 25 Feb 1997 12:37:28 -0800
From: Tom Phoenix <rootbeer@teleport.com>
To: Angel Leyva <airborne@cybernex.net>
Subject: Re: Writing a subroutine
Message-Id: <Pine.GSO.3.95q.970225122951.18288Z-100000@kelly.teleport.com>

On Tue, 25 Feb 1997, Angel Leyva wrote:

> I want to write a subroutine that accepts a text string and returns it
> in a new form. 

> I am sure that there are several ways to do this, but the two ways that
> I am interested in are first, have the string that I pass in get the new
> values automatically, like as a global variable. The second way would be
> assign it back to itself as I call the routine, then have the routine
> return the result. I want the result to replace what was passed in.

Hmmm... Which is it? If you write the sub to modify the string "in place",
you can't gain anything by calling it in an assignment. But here's the
kind of thing I think you want. 

    sub strip_spaces (@) {
        # Removes leading and trailing spaces from its arguments
        for (@_) { s/^\s+|\s+$//g }
    }

    $foo = "  I've  got  extra      whitespace\n\n";
    $bar = "  \t\tMe too!\n";
    $baz = "I don't, but who cares?";
    strip_spaces $foo, $bar, $baz;

Hope this helps!

-- Tom Phoenix        http://www.teleport.com/~rootbeer/
rootbeer@teleport.com   PGP  Skribu al mi per Esperanto!
Randal Schwartz Case:     http://www.lightlink.com/fors/



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

Date: 8 Jan 97 21:33:47 GMT (Last modified)
From: Perl-Request@ruby.oce.orst.edu (Perl-Users-Digest Admin) 
Subject: Digest Administrivia (Last modified: 8 Jan 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.

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

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