[6880] in Perl-Users-Digest

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

Perl-Users Digest, Issue: 505 Volume: 8

daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Tue May 20 23:05:41 1997

Date: Tue, 20 May 97 20:00:28 -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, 20 May 1997     Volume: 8 Number: 505

Today's topics:
     avoiding "Use of uninitialized value..." warning <tkeitt@santafe.edu>
     Re: AWKer needs Perl help (Mike Stok)
     Re: AWKer needs Perl help <bryan@eai.com>
     Re: CGI.pm (Randy J. Ray)
     Re: convert functions in perl... (Chipmunk)
     Re: Del/Sort Flat Text File - Advice Requested (Chipmunk)
     Re: Getting Week Number (Bart Lateur)
     Help in Removing lines with duplicate Field Ones (Guest Account)
     Re: How to output special characters with PERL <usenet-tag@qz.little-neck.ny.us>
     Installing GD library <maartenn@vademecum.be>
     Re: Installing GD library (Nathan V. Patwardhan)
     Re: MIME using PERL on NT4 <maartenn@vademecum.be>
     Re: MIME using PERL on NT4 (Nathan V. Patwardhan)
     Re: mode results from stat() (Jeremy T. Elston)
     Re: MUST GO THERE <gm@mgm-net.de>
     Re: News::NNTPCLient trouble with NEWNEWS <terry@spcuna.spc.edu>
     Re: Newsreader in Perl (I R A Aggie)
     next line from a while (Eric Finley)
     Re: next line from a while (Craig Berry)
     Re: open and redirect <rra@stanford.edu>
     Re: oraperl and perl5.003 <mwinter@nrel.gov>
     Re: passing argument to system command (Chipmunk)
     PERL SCRIPT FOR PASSOWRD <Michael.C.Lammon@mci.com>
     Re: Problem: File uploading (Raul Almquist)
     Questions of version (Jeff Yoak)
     Regular expression problem <houde@fox.cisti.nrc.ca>
     Re: Regular expression problem <usenet-tag@qz.little-neck.ny.us>
     Script needed: paying oppertunity (John Thomas Mosey)
     SSL in Perl <tommiih@cism.bus.utexas.edu>
     syntax for subroutine reference with sort <tbird@caldera.com>
     Re: syntax for subroutine reference with sort <gm@mgm-net.de>
     The why a include file name of C++ has been disappeared <O.C.Kwon@durham.ac.uk>
     Time stamping with perl <nickh@wind-river.com>
     Re: Time stamping with perl <gm@mgm-net.de>
     timelocal.pl ? (Raul Almquist)
     Re: While loops starting with "1"? (Chipmunk)
     Digest Administrivia (Last modified: 8 Mar 97) (Perl-Users-Digest Admin)

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

Date: Tue, 20 May 1997 16:53:00 -0600
From: "Timothy H. Keitt" <tkeitt@santafe.edu>
Subject: avoiding "Use of uninitialized value..." warning
Message-Id: <33822B4C.2677@santafe.edu>

I commonly write perl scripts that accumulate sums over several
variables.  In general, I don't know a priori how large the hash or
array of sums will be (it depends on the input data file).  For example,

#!/opt/bin/perl5 -w
while ( <> ) {
	chomp;
	($a, $b) = split;
	$sum{$a} += $b;
# -- or --
	$sum[$a] += $b;
}

Perl is great for this because I don't need to know much about the data;
the hash (or array) grows as needed.  The problem is that when I use the
"-w" switch I get lots of "Use of uninitialized value" warnings.  I'm
looking for a somewhat more elegant solution than adding a check inside
the while-loop, e.g., "$sum{$x} = 0 unless exists $sum{$n};" or
"$sum[$x] = 0 unless defined $sum[$x];".  I'd either like to suppress
the warning or find a way to initialize my hashes and arrays outside my
main loop.  Anyone know of a solution?

Thanks,
Tim


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

Date: 20 May 1997 19:46:07 GMT
From: mike@stok.co.uk (Mike Stok)
Subject: Re: AWKer needs Perl help
Message-Id: <5lsv1v$egv@news-central.tiac.net>

In article <ehughesEAHss1.HFs@netcom.com>,
Elton Hughes <ehughes@netcom.com> wrote:

>001Z220A,64,59,0,0,0,27,32,0,32,0,,0,0,0,0,56,,0
>001Z220B,1,1,0,0,0,0,1,0,1,0,,0,0,0,0,1,,0
>001Z220E,17,11,9,8,0,0,0,0,0,2,15.0556,2,0,9,0,12,8.35,0
>001Z220J,4,2,2,2,0,0,0,0,0,0,11.215,0,0,2,0,3,6,0
>011E220E,45,21,16,11,0,0,0,0,0,5,13.2494,0,0,16,0,35,7,0 
>
>In awk $1 would be a contract number, $2 the number of enrollments
>and so on. There are 19 fields overall, sometimes fields are left
>blank. In Perl they would be undef. This is acceptable, given the
>nature of the contracts.
>
>I need to be able to extract the data from a single line. Using awk,
>that is very simple. I have finished 86 pages of the llama book, but
>have not yet found that magic bit of code that puts it all together
>in a neat little package that I can use, modify, and learn from. 

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

$line = 3;

while (<DATA>) {
  next unless $. == $line;
  @fields = split /,/;

  print "contract is $fields[0], field 4 is $fields[3]\n";
  last;
}

__END__
001Z220A,64,59,0,0,0,27,32,0,32,0,,0,0,0,0,56,,0
001Z220B,1,1,0,0,0,0,1,0,1,0,,0,0,0,0,1,,0
001Z220E,17,11,9,8,0,0,0,0,0,2,15.0556,2,0,9,0,12,8.35,0
001Z220J,4,2,2,2,0,0,0,0,0,0,11.215,0,0,2,0,3,6,0
011E220E,45,21,16,11,0,0,0,0,0,5,13.2494,0,0,16,0,35,7,0

The use of <DATA> just slurps lines from after the __END__ token one at a
time, you might use <STDIN> for reading from stdin or the <> form as
described in the Llama.

$. is the variable which lets you count lines read from the most recently
read from file handle, and remember that in perl arrays start at 0.

This isn't the only way to do it...

Hope this helps,

Mike


-- 
mike@stok.co.uk                    |           The "`Stok' disclaimers" apply.
http://www.stok.co.uk/~mike/       |   PGP fingerprint FE 56 4D 7D 42 1A 4A 9C
http://www.tiac.net/users/stok/    |                   65 F3 3F 1D 27 22 B7 41
stok@psa.pencom.com                |      Pencom Systems Administration (work)


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

Date: Tue, 20 May 1997 17:30:04 -0500
From: Bryan Hart <bryan@eai.com>
To: Elton Hughes <ehughes@netcom.com>
Subject: Re: AWKer needs Perl help
Message-Id: <338225EC.3DB8@eai.com>

Elton Hughes wrote:
> 
> Hello All,
> 
> I have a problem that I hope someone can help me with. I have a
> text file, that is approximately 200 lines long. Each line represents
> a single recond, fields are seperated by commas. here is a snippet of
> what the text file and records look like:
> 
> 001Z220A,64,59,0,0,0,27,32,0,32,0,,0,0,0,0,56,,0
> 001Z220B,1,1,0,0,0,0,1,0,1,0,,0,0,0,0,1,,0
> 001Z220E,17,11,9,8,0,0,0,0,0,2,15.0556,2,0,9,0,12,8.35,0
> 001Z220J,4,2,2,2,0,0,0,0,0,0,11.215,0,0,2,0,3,6,0
> 011E220E,45,21,16,11,0,0,0,0,0,5,13.2494,0,0,16,0,35,7,0
> 
> In awk $1 would be a contract number, $2 the number of enrollments
> and so on. There are 19 fields overall, sometimes fields are left
> blank. In Perl they would be undef. This is acceptable, given the
> nature of the contracts.
> 
> I need to be able to extract the data from a single line. Using awk,
> that is very simple. I have finished 86 pages of the llama book, but
> have not yet found that magic bit of code that puts it all together
> in a neat little package that I can use, modify, and learn from.
> 
> BTW, after extract the data, I need to format it for display. I am
> assuming that printf should handle most of my needs in that respect.
> 
> If you have a solution, please let me know. I am finding Perl to be
> almost overwhelming in its capabilities. But it is a fun sort of
> overwhelming!
> 
> Thank you for your time,
> 
> Elton Hughes
> IT Specialist
> NOVA Private Industry Council
> 
> ehughes@novapic.org

_____________begin example perl_______________________

#!/your/perl/here/perl -w
#

open(DATA, "/your/data/file") or do {
	print "Couldn't open data file!";
	exit;
	};
my @data=<DATA>;
close(DATA);

# $contract is the contract number you are searching for
# this puts all the field elements from a record match on $contract
# into an array called @record

my @record=split(/,/, grep(/^$contract,/, @data));

____________end sample perl____________________________

$record[0] is the contract number, $record[1] is # of enrollments, etc
up to $record[18]. 

Bryan

-- 
-------------------------------
|  Bryan Hart                 
|  Network Products Engineer  
|  Engineering Animation Inc. 
|  Phone: (515) 296-5979
|  Fax: (515) 296-7025
|  Email: bryan@eai.com              
|  Web: http://www.eai.com/                          
-------------------------------
"A conclusion is simply the place where you got tired of thinking"


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

Date: 20 May 1997 11:51:42 -0600
From: rjray@tremere.ecte.uswc.uswest.com (Randy J. Ray)
Subject: Re: CGI.pm
Message-Id: <uowsozi58wh.fsf@tremere.ecte.uswc.uswest.com>

drheeder@bcs.co.za (Dirk Rheeder) writes:
> How do I insert logic in the middle of a table when using CGI.pm.
> 
> Here's what I mean, in the middle of this table I want to do an if check, 
> but I get an error when I insert code there.  Is there another way of 
> doing this ?  I have tried a couple of different approuches and can't 
> figure out how to do it.  I also had a look at the code samples, but 
> couldn't find anything that did this.

This isn't a problem with CGI.pm, this is badly-structured perl.

> print $cgi->table({-width=>'500',
> 	      	     -border=>'3',
> 		     -cellspacing=>'0',
> 		     -cellpadding=>'5',
> 		     -bgcolor=>'#C0C0C0'},
> 						 
> 		     $cgi->Tr(
>                    $cgi->td({-colspan=>'4' -align=>'center'},"data")),
> 	
> 		     $cgi->Tr(
> 		     $cgi->td('Course No.'),
> 		     $cgi->td('Course'),
> 		     $cgi->td({-align=>'center'},'Symbol'),
> 		     $cgi->td({-align=>'center'},'Mark')),
> 
>                    if ($test = test)                 #This won't work.
> 		     {                                 #If I take the if 
> 		         print $cgi->Tr(               # out then works 
> 			        $cgi->td('Dirk'));      # fine.
> 		     }
>
> 	);

You are calling a method (table()) with a list of arguments, the returned
values from the Tr() methods. But at the end, you try to evaluate an if-
conditional, and you just can't do that at the point you are trying to. You
need to either pre-compute your list of rows:

@rows = [some operation(s)];

print $cgi->table(@rows);

-or-

You can use the ?: conditional, which I think matches the asthetic you were
aiming for here:

print $cgi->table(...,
                  $cgi->Tr(),
                  (($test eq 'test') ? $cgi->Tr($cgi->td('Dirk')) : () )
                 );

Randy
-- 
===============================================================================
Randy J. Ray -- U S WEST Technologies IAD/CSS/DPDS         Phone: (303)595-2869
                Denver, CO                                     rjray@uswest.com
"It's not denial. I'm just very selective about the reality I accept." --Calvin


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

Date: 20 May 1997 23:59:53 GMT
From: Ronald.J.Kimball@dartmouth.edu (Chipmunk)
Subject: Re: convert functions in perl...
Message-Id: <5ltdtp$erg$1@dartvax.dartmouth.edu>

In article <01bc6497$7d9e58e0$0c83f6c8@afxtd-02>
"Sergio Stateri Jr" <serginho@usa.net> writes:

> Hi! How can I do to convert a decimal value to a hex value in Perl ? I
> thought that hex function did it, but it converts the hex value to a
> decimal value...It's the oposite of the other languages :))

This is from the description of the hex() function in Camel 1.

To do the inverse function, use:

sprintf("%lx", $number);

Chipmunk


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

Date: 21 May 1997 00:51:24 GMT
From: Ronald.J.Kimball@dartmouth.edu (Chipmunk)
Subject: Re: Del/Sort Flat Text File - Advice Requested
Message-Id: <5ltguc$m02$1@dartvax.dartmouth.edu>

In article <864070702.4666.0.nnrp-4.c2de345e@news.demon.co.uk>
tkolsen@bosox.demon.co.uk (Tony K. Olsen) writes:

>      I have created an HTML form that I use to delete a part
> number from the flat file but I was wondering is there a simple
> method of deleting a 'record' other than:
> 
> $form_part_id = $FORM{part_id}; # etc.
> 
> # open files etc.
> 
> while (<IN>) {
>   chop;
>   ($field1,$field2,$field3,$field4,$field5,$field6,$field7) = split(/;/);
>   if ($field1 ne $form_part_id) {
>     print OP "$field1,$field2..$field7"; # etc.
>   }
> }
> 
> # close files etc.
> # rename IN to IN.bak
> # rename OP to IN

Well, since you only need to check the first field, this is slightly
simpler:

   ($field1, $rest) = split(/;/, $_, 2);
   if($field1 ne $form_part_id) {
     print OP "$field1,$rest";
   }

(You said it was semi-colon delimited.  I assume your actual code
outputs semi-colons instead of commas?)

You probably want something simpler than that, though.
How large is your file?  You could slurp in the whole thing and then
use grep:

@file = <IN>;
print OP grep(split(/;/, $_)[0] ne $form_part_id, @file);
or
print OP grep(!/^$form_part_id;/, @file);
  # watch out if $form_part_id contains metacharacters

>      Any advice greatly appreciated.  Also is there a way in perl
> to sort this file on the first field without relying on the unix
> system sort?

There sure is!  The FAQ has lots and lots of information about sorting!

Here's one possibility:
sub sort_by_field {
  (split/;/, $a)[0] cmp (split/;/, $b)[0];
}
sort sort_by_field @file;

Chipmunk


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

Date: Tue, 20 May 1997 21:03:02 GMT
From: bart.mediamind@tornado.be (Bart Lateur)
Subject: Re: Getting Week Number
Message-Id: <33821111.1902492@news.tornado.be>

ebohlman@netcom.com (Eric Bohlman) wrote:

>bjorn.w.nilsson@edt.ericsson.se (BjrnNilsson) wrote:

>: I want to create a subfunction (or similar) that computes the week number
>: given a date.

>Use timelocal() from the Time::Local module (part of the standard 
>distribution) to convert the date into a time integer and then use 
>localtime() from the standard library to get the day within the year; 
>divide it by seven and use int() on it to get the week number (which will 
>be zero-based; add 1 if you count your weeks starting with 1).

The length of the first week depends on what weekday jan 1st was. You
ought to correct for that.

Gent (Ghent, Gand),
Belgium, 
Europe,
3rd planet from the sun.


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

Date: 20 May 1997 22:28:08 GMT
From: guest@blueline.east.sun.com (Guest Account)
Subject: Help in Removing lines with duplicate Field Ones
Message-Id: <5lt8ho$gq2@eastnews1.East.Sun.COM>
Keywords: Duplicate

Input file has fixed length, 132 byte records, each with 8 fields.

Purpose:   Keep only those records in the file which have a UNIQUE
	   field #1.

	   Duplicates may occur on more than two lines (i.e., field
	   one of record 6 may match field one of record 21, 98, 2110,
	   and 65535.  Regardless of the number of duplications, ALL
	   duplicate lines must be cleaned from the file. 

Field 1:   Alternates between numeric only, alpha only, or alpha-numeric
	   values.  

I have ended up doing this in C because I couldn't figure out if perl could
handle it.  Can someone tell me a Perl solution?  I sincerly appreciate it.

Jason.






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

Date: 20 May 1997 17:54:21 GMT
From: Eli the Bearded <usenet-tag@qz.little-neck.ny.us>
Subject: Re: How to output special characters with PERL
Message-Id: <5lsogd$n5i$1@news.netusa.net>

Bek Oberin <gosamer@tertius.net.au> wrote:
>Tom Phoenix wrote:
>>On Tue, 20 May 1997, Dico Reyers wrote:
>>> I am writing a script in PERL that outputs special characters like  "
>>> and   '  to the HTML page.  For example...
>>> print "<a href="./blabla.html">\n";

(I'm guessing Tom went over q and qq, if not, look them up.)

>>Or you can represent the quote mark in other ways.
>>    $doublequote = '"';
>>    print "<a href=$quote./blabla.html$quote>\n";
>Or, even better:
>    $quote = '"';
>    print "<a href=$quote./blabla.html$quote>\n";

'-w' would have caught that anyhow.

     print "<a href=\x22./blabla.html\x22>\n";

And just tell people \x is perl's version of HTTP's %. (Not that I expect
cgi programmers to know anything about %, but maybe it will provoke them
to ask questions in a different group.)

>Reading this newsgroup, I get the general impression that
>I'm the only person left in the galaxy who uses Perl for
>stuff that isn't CGI scripting ...  (Or, more likely, that
>those who use it for more stuff are just smart enough to
>RTFM and so post 95% less :))

My money is on that second alternative.

Elijah
------
#!/usr/bin/perl -w
$_="<j!y~f^v* >h.g=c+m\@q[p;r} ?x/t|d:l# )e\\p.d-s]p{c<,\n";$j=0;while(
s:[^\w\s,](.*):($u=$1,$u=~s;(\w);(($s=ord($1)-97),chr((($s+$j++)%26)+97
));gex,$u):ex){}exit !print;#18/5/97:etb


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

Date: Tue, 20 May 1997 09:45:26 +0200
From: "Maarten" <maartenn@vademecum.be>
Subject: Installing GD library
Message-Id: <5lsupg$qgf@news2.Belgium.EU.net>

Hi all,

first time I write to this newsgroup.  I would need your help on the
following issue: installing and running the GD library.

I have downloaded the GD library and in the readme file, I found following
instructions:

INSTALLING GD IN YOUR HOME DIRECTORY
IF YOU DON'T HAVE PRIVILEGES TO INSTALL GD.pm in your system's main
Perl library directory, don't despair. You can install it into your
home directory using the following trick:
cd ~
mkdir lib
mkdir lib/perl
mv GD-1.10/blib/* lib/perl

However this does not work since uncompressing the zipped library results
in a set of directories but no trace of a directory named blib.  The only
directory I got is libgd.

Can someone help me out... Please...

Thanks


Maarten







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

Date: 20 May 1997 20:33:11 GMT
From: nvp@shore.net (Nathan V. Patwardhan)
Subject: Re: Installing GD library
Message-Id: <5lt1q7$ksp@fridge-nf0.shore.net>

Maarten (maartenn@vademecum.be) wrote:

: However this does not work since uncompressing the zipped library results
: in a set of directories but no trace of a directory named blib.  The only
: directory I got is libgd.

Hint: Unless I've mis-read your question, you've got to build gd before
you install it. :-)  Hope this helps!

--
Nathan V. Patwardhan
nvp@shore.net



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

Date: Tue, 20 May 1997 11:08:06 +0200
From: "Maarten" <maartenn@vademecum.be>
Subject: Re: MIME using PERL on NT4
Message-Id: <5lt3kj$s1h@news2.Belgium.EU.net>

As far as I know attachements can not be send by PERL.  However someone
knows please tell me because me too I am looking for such a solution.

Thanks
 James Kenny wrote in article <01bc657d$7dc57060$cb015790@itbl12038>...
>I want to send an HTML form as an attachment to an e-mail generated by
>perl running on NT4.  I cannot find any examples on the WEB.
>
>James Kenny
> 




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

Date: 20 May 1997 21:41:32 GMT
From: nvp@shore.net (Nathan V. Patwardhan)
Subject: Re: MIME using PERL on NT4
Message-Id: <5lt5qc$p3t@fridge-nf0.shore.net>

Maarten (maartenn@vademecum.be) wrote:
: As far as I know attachements can not be send by PERL.  However someone
: knows please tell me because me too I am looking for such a solution.

What you talkin' about Willis?  Yes, they can.  I'm not sure if the
MIME modules (from CPAN) work on NT, but one could certainly write
something that does Base64 encoding if the existing Base64 modules
fail to work on NT.

--
Nathan V. Patwardhan
nvp@shore.net



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

Date: Tue, 20 May 1997 20:04:13 GMT
From: Magius@Greenwood.net (Jeremy T. Elston)
Subject: Re: mode results from stat()
Message-Id: <5lt083$evl$1@bigdog.ais-gwd.com>

        Thanks for all the responses.  I appreciate the help!  :-)


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

Date: Wed, 21 May 1997 00:38:42 +0200
From: Georg Moritz <gm@mgm-net.de>
Subject: Re: MUST GO THERE
Message-Id: <338227F2.6AF95780@mgm-net.de>

FREEMONEY wrote:
> 
> http://www.freedomstarr.com/?TR7654321
> 
> **********************************************************************
> This message has been sent using DYNAMIC MAIL.  For more Information
> and Free Demo: http://www.freeyellow.com/members/concorde/index.html
> **********************************************************************

be off. cetero censeo www.freedomstarr.com esse delendam.
(et ms esse delendam.)

--gm


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

Date: Tue, 20 May 1997 20:05:47 GMT
From: Terry Kennedy <terry@spcuna.spc.edu>
Subject: Re: News::NNTPCLient trouble with NEWNEWS
Message-Id: <EAHx5n.5IB@spcuna.spc.edu>

Danny Aldham <danny@hendrix.postino.com> writes:
> I have just started using the News::NNTPCLient module, and have tried
> the example out of the man page as below:
> This gives me an error: NNTPERROR: 500 "NEWNEWS" not implemented; try "help".
> I am running Inn1.5.1 , and do have a test newsgroup. 

  Anything that depends on NEWNEWS is evil and should be exterminated 8-)

  Seriously, NEWNEWS is a huge performance drain on the server and there
are other ways to get the same functionality. If the author of the module
wants to discuss them, let's move over to news.software.nntp.

	Terry Kennedy		  Operations Manager, Academic Computing
	terry@spcvxa.spc.edu	  St. Peter's College, Jersey City, NJ USA
        +1 201 915 9381 (voice)   +1 201 435-3662 (FAX)


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

Date: Tue, 20 May 1997 17:39:23 -0500
From: fl_aggie@hotmail.com (I R A Aggie)
Subject: Re: Newsreader in Perl
Message-Id: <fl_aggie-ya02408000R2005971739230001@news.fsu.edu>

In article <5lsgp3$2vk@fridge-nf0.shore.net>, nvp@shore.net (Nathan V.
Patwardhan) wrote:

+ Kurt Koller (kk@minimalist.com) wrote:
+ : Anyone have a code fragment or more of a basic NNTP newsreader in perl? 
+ : Nothing fancy.  Anyone know?
+ 
+ You can roll-yer-own using News::NNTPClient.

Wasn't Larry Wall working on something like that?

James - ;)

-- 
Consulting Minister for Consultants, DNRC
Support the anti-Spam amendment <url:http://www.cauce.org/>
To cure your perl CGI problems, please look at:
<url:http://www.perl.com/perl/faq/idiots-guide.html>


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

Date: 20 May 1997 21:15:27 GMT
From: ez041407@boris.ucdavis.edu (Eric Finley)
Subject: next line from a while
Message-Id: <5lt49f$enr$1@mark.ucdavis.edu>

I need to get the next line from a file while I am in a while loop.  The
code looks like:
while(<FILE>) {
    if (/foo/) {
	print;
    }
    if (/bar/) {
	print;
	print next line;
    }
}

Any help would be appreciated.
Thanks,
Eric Finley




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

Date: 20 May 1997 23:00:09 GMT
From: cberry@cinenet.net (Craig Berry)
Subject: Re: next line from a while
Message-Id: <5ltadp$8f3$4@marina.cinenet.net>

Eric Finley (ez041407@boris.ucdavis.edu) wrote:
: I need to get the next line from a file while I am in a while loop.  The
: code looks like:
: while(<FILE>) {
:     if (/foo/) {
: 	print;
:     }
:     if (/bar/) {
: 	print;
: 	print next line;
:     }
: }
: 
: Any help would be appreciated.

Replace 'print next line;' above with 'print scalar <FILE>;'.  The 
'scalar' is required to stop the list context of print from gobbling up 
the entire remainder of the file.

---------------------------------------------------------------------
   |   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: 20 May 1997 19:09:41 -0700
From: Russ Allbery <rra@stanford.edu>
To: Deyoung Hong <hong@taligent.com>
Subject: Re: open and redirect
Message-Id: <m34tbx1spm.fsf@windlord.Stanford.EDU>

[ Posted and mailed. ]

Deyoung Hong <hong@taligent.com> writes:

> How do I use open to pipe STDOUT to one file and STDERR to another?  For
> example, I can pipe a command output as open(FH, "/bin/ls |"), how about
> its error output?

open (FH, "/bin/ls 2>&1 |")

-- 
Russ Allbery (rra@stanford.edu)         <URL:http://www.eyrie.org/~eagle/>


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

Date: Tue, 20 May 1997 15:26:49 -0600
From: Mark Winter <mwinter@nrel.gov>
Subject: Re: oraperl and perl5.003
Message-Id: <33821719.3910@nrel.gov>

You need to get two programs:  DBI and DBD::ORACLE.
look at www.hermetica.com/technologia/DBI/
download and untar the DBI first then the oracle module.  It installs
easy.  You have to have perl5.003.  

The original oraperl was written for perl 4.036 only.

Hope this helps but I don`t think this is a linux problem, The last
I knew oracle doesn't have a linux port.

Mark Winter
mwinter@nrel.gov


nir@global.co.za wrote:
> 
> I'm trying to get oraperl to run with very little luck:
> It complains about not being able to find uperl.o (I proceeded to rename
> perl.o to uperl.o). After that, it complains about not finding
> (blah)/usub/mus. This led me to attempt to use perl 4.036.
>  Is there a way of using perl 5.003 together with oraperl?
> Another complication is that I am attempting to do this all on a Linux
> box.
> Thanks for any help
> Nir Oren
> 
> -------------------==== Posted via Deja News ====-----------------------
>       http://www.dejanews.com/     Search, Read, Post to Usenet


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

Date: 21 May 1997 00:32:52 GMT
From: Ronald.J.Kimball@dartmouth.edu (Chipmunk)
Subject: Re: passing argument to system command
Message-Id: <5ltfrk$i7r$2@dartvax.dartmouth.edu>

In article <5lre0t$ruv@ustsu10.ust.hk>
mecks@uxmail.ust.hk (Chim Kin Sang) writes:

> system('mt -f /dev/nrtape fsf $i')
> 
> The problem is that the $i isnot the one that I set before the system call.

When you use '' in Perl, variables aren't replaced with their values. 
So, $i stays as $i.
I think what you want to do is system("mt -f /dev/nrtape fsf $i"),
which will replace $i with the value of $i.

Chipmunk


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

Date: Tue, 20 May 1997 19:23:50 -0400
From: Michael Lammon <Michael.C.Lammon@mci.com>
Subject: PERL SCRIPT FOR PASSOWRD
Message-Id: <33823286.1F1@mci.com>

All,

	Does anyone have a PERL program which will call the User Name:
Password:
feature for a Netscape Browser or IE? and upon correct password that
will allow
a user to go to the html file??

Thanks

Mike


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

Date: Tue, 20 May 1997 16:08:18 -0600
From: strider@ShadowMAC.org (Raul Almquist)
Subject: Re: Problem: File uploading
Message-Id: <strider-ya02408000R2005971608180001@news.winternet.com>

> Here's another problem of mine:
> I need to be able to upload a file to the server from the client side.
> That is: the user gives a filename in a directory accessable to him
> to a form which will upload the given file to the server where it will
> be checked and processed.
> The purpose is to enable the user to upload HTML files and images
> without having to resort to FTP directly - this way the files can be
> checked at once, catching the user in an Q&A loop and letting him
> go only if all data is verified ...
> (with FTP this is a procedure with several steps involving the
> webmaster directly in most cases)
> 
> How can it be done ?
> (there is/was a netscape HTML feature for this which doesn't work
> satisfying since it brings the serverside formbuffer to overflow
> sooner or later ...)

Try using CGI_Lite.pm, it has working examples of both the html and pl/cgi
inside the itself which you can copy to files and modify as needed.  It
works quite well.  As to overflowing any buffers, well I have uploaded
files exceeding 9mbs with it with no problem.  Currently there are v1.70 as
the latest, and v1.62 available, the full release of v1.8 should be in
about a month to 6 weeks.


> What security problems do occur with this solution ?

  Make sure to use HTTP_REFERER as a check, to see that the pl/cgi is only
called from the html form authorized to use that cgi script, as well as the
usual safeties to perform.


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

Date: Tue, 20 May 1997 17:51:02 GMT
From: jeff@yoak.com (Jeff Yoak)
Subject: Questions of version
Message-Id: <5lt2qm$7ov@sjx-ixn6.ix.netcom.com>

perl -v reports that This is perl, version 5.003_07 and then some
information about copyright and a suidperl patch.  (At least, it does
this on my system.  :)  Does the _07 refer to a build or patch number
or perhaps some beta?  Is this version substantially out of date?  The
announcement of 5.004 recently may end up making this question
pointless, but someone who is trying to support some software on this
system is claiming the reason things aren't working is that we are
using an "old developer's release of Perl."

I appreciate your (collective) time.

Cheers,
Jeff

Jeff Yoak  jeff@yoak.com  http://yoak.com/



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

Date: Tue, 20 May 1997 14:59:13 -0400
From: Pascal Houde <houde@fox.cisti.nrc.ca>
Subject: Regular expression problem
Message-Id: <3381F481.2F464A7F@fox.cisti.nrc.ca>

Can you complete the following reg expression?
$input =~ s/(A\sHREF|\sSRC\sACTION)="\/*([^"]+)"/$1="myPgm?$2"/gis;

Basically I want to take whatever inside the quotes and precede a
program name to it.
EXCEPTED that I don't want to do the search & replace if there's a
"mailto:" or a "http:..." inside the HREF (or ACTION).

So <A HREF="relative_link"> will become <A HREF="myPgm?relative_link">
but <A HREF="mailto:josblo"> will stay the same.

$input contains a small html page with some \n inside.  That's why I use
the 's' flag.

Can this be done by negating a class using [^something] or this is
reserved for a character only or a group like [^a-z]?

I'm using Perl5

I hope I was clear in my problem description!
Any help very appreciated!!!
Thanks. Please email me a copy of your response.
--PH--



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

Date: 20 May 1997 22:30:39 GMT
From: Eli the Bearded <usenet-tag@qz.little-neck.ny.us>
Subject: Re: Regular expression problem
Message-Id: <5lt8mf$fk$1@news.netusa.net>

Pascal Houde  <houde@fox.cisti.nrc.ca> wrote:
>Can you complete the following reg expression?
>$input =~ s/(A\sHREF|\sSRC\sACTION)="\/*([^"]+)"/$1="myPgm?$2"/gis;
>
>Basically I want to take whatever inside the quotes and precede a
>program name to it.
>EXCEPTED that I don't want to do the search & replace if there's a
>"mailto:" or a "http:..." inside the HREF (or ACTION).
>
>So <A HREF="relative_link"> will become <A HREF="myPgm?relative_link">
>but <A HREF="mailto:josblo"> will stay the same.

$input =~ s,                # comma instead of / for clarity
            (A\sHREF|\sSRC\sACTION)=" # stuff we must match
            /*                        # zero or more slashes (why?)
            (?!mailto:)               # lookahead for no mailto:
            (?!http:)                 # lookahead for no http:
            ([^"]+)                   # grab this
            "                         # ending match text
           ,                # begin substitution part
            $1="myPgm?$2"             # the new text
           ,gsix;           # Global, Single-line, Ignore case, eXtended

>Can this be done by negating a class using [^something] or this is
>reserved for a character only or a group like [^a-z]?

The [...] structure matches exactly one character. It is not correct/
useful here, even in negation.

>I'm using Perl5

Hopefully something like 5.02 or higher to use the regexp I provided.

>I hope I was clear in my problem description!

I am curious about the /* bit.

>Thanks. Please email me a copy of your response.

Posted and mailed.

Elijah
------
#!/usr/bin/perl -w
$_="<j!y~f^v* >h.g=c+m\@q[p;r} ?x/t|d:l# )e\\p.d-s]p{c<,\n";$j=0;while(
s:[^\w\s,](.*):($u=$1,$u=~s;(\w);(($s=ord($1)-97),chr((($s+$j++)%26)+97
));gex,$u):ex){}exit !print;#18/5/97:etb


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

Date: 20 May 1997 19:54:28 GMT
From: mosey@alpha2.csd.uwm.edu (John Thomas Mosey)
Subject: Script needed: paying oppertunity
Message-Id: <5lsvhk$dve@uwm.edu>

I need someone to write what's basically a glorifed guestbook. I run a 
site (www.mosey.com) that has a group of people reporting to me. I then 
take those reports and post them on the web. I'd like to take the 
middleman (ME) pretty much out of it. 

What I need is a script that takes in: the reporters name, reporters 
email a standard 
password (no db needed), the team they are reporting for, and the entry 
(update).

It then: posts the update on the correct page, mails me a copy, mails 
them a copy, with the date and time reported on all three and lastly (I 
think), updates a page with all the pages listed so I can check one place 
to see when each team has been updated last.

I know a little perl, but not enough to do this, and I need it rather 
quickly. One "extra" requirement is that it be choked full of comments 
since I'll probably need to play with it from time to time and I need to 
know what I'm fixing.

Email me your price for this project and a time frame. I'll take the best 
looking offer and start discussing the details.

Thanks,

John Mosey
mosey@mosey.com


-- 


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

Date: Tue, 20 May 1997 15:46:45 -0500
From: Tommi Hakala <tommiih@cism.bus.utexas.edu>
Subject: SSL in Perl
Message-Id: <33820DB5.4382@cism.bus.utexas.edu>

I need to get the certificate information(user name, etc) in Perl.
Is this possible with envirionment variables, or what do I have to do?

-- 

Tommi Hakala				    email:  tommiih@cism.bus.utexas.edu

 One Time..  One Chance..  The Life..


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

Date: Tue, 20 May 1997 14:08:33 -0600
From: Tim Bird <tbird@caldera.com>
Subject: syntax for subroutine reference with sort
Message-Id: <338204C1.789D2F77@caldera.com>

The sort routine can take the a subroutine as its first
argument.  According to one perl book I have, you can give
this subroutine parameter by one of a couple of ways:
1) as a block
2) as a subroutine name
3) as a scalar whose value is a subroutine name
4) as a scalar whose value is a subroutine reference

I can't figure out how to get the 4th option working.  I have
tried numerous syntaxes, to no avail.  I have successfully
gotten option 3 to work, but I would have preferred 4.
Does someone know how to do this?

Here's some code:

sub enum_compare {
	$enumOrder{$a} <=> $enumOrder{$b};
}

# 2) works ok
foreach $item (sort enum_compare keys(%records)) {...}

# 3) works ok
$sortFunc = "enum_compare";
foreach $item (sort $sortFunc keys(%records)); {...}

# 4) this doesn't work - what am I doing wrong?
$sortFunc = \&enum_compare;
foreach $item (sort $sortFunc keys(%records)); {...}

# 4) nor does this work
$sortFunc = \&enum_compare;
foreach $item (sort &$sortFunc keys(%records)); {...}

Any advice is appreciated.

Tim Bird


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

Date: Wed, 21 May 1997 00:25:18 +0200
From: Georg Moritz <gm@mgm-net.de>
Subject: Re: syntax for subroutine reference with sort
Message-Id: <338224CE.67C5EEB3@mgm-net.de>

Tim Bird wrote:
> 
(...)
> # 4) this doesn't work - what am I doing wrong?
> $sortFunc = \&enum_compare;
> foreach $item (sort $sortFunc keys(%records)); {...}
                              wrong -----------^ 
> # 4) nor does this work
> $sortFunc = \&enum_compare;
> foreach $item (sort &$sortFunc keys(%records)); {...}

  foreach $item (sort{&$sortFunc}keys(%records)) {...}
e.g:
host% perl -
%records = (
    item1 => 2,  
    item2 => 4,
    item3 => 3,
    item4 => 1,
);
%enumOrder = %records;
sub enum_compare {
        $enumOrder{$a} <=> $enumOrder{$b};
}
$sortFunc = \&enum_compare;
print "\n";         # I want to see ^D
foreach $item (sort{&$sortFunc}keys(%records)) { print "item: $item\n" }
^D
item: item4
item: item1
item: item3
item: item2
host%

> Any advice is appreciated.

hth,

> Tim Bird

-- gm

------------------------------------------------------------------------
host% perl -V
Summary of my perl5 (5.0 patchlevel 4 subversion 0) configuration:
  Platform:
    osname=linux, osvers=2.0.29, archname=i686-linux
    uname='linux cepheus.mgm-net.de 2.0.29 #6 fri apr 25 11:55:10 met
dst 1997 i686 '
    hint=recommended, useposix=true, d_sigaction=define
    bincompat3=y useperlio= d_sfio=
  Compiler:
    cc='gcc', optimize='-O2', gccversion=2.7.2
    cppflags='-Dbool=char -DHAS_BOOL -DDEBUGGING'
    ccflags ='-Dbool=char -DHAS_BOOL -DDEBUGGING'
    stdchar='char', d_stdstdio=define, usevfork=false
    voidflags=15, castflags=0, d_casti32=define, d_castneg=define
    intsize=4, alignbytes=4, usemymalloc=n, randbits=31
  Linker and Libraries:
    ld='gcc', ldflags =' -L/usr/local/lib'
    libpth=/usr/local/lib /lib /usr/lib
    libs=-lndbm -lgdbm -ldb -ldl -lm -lc
    libc=/lib/libc.so.5.3.12, so=so
    useshrplib=false, libperl=libperl.a
  Dynamic Linking:
    dlsrc=dl_dlopen.xs, dlext=so, d_dlsymun=, ccdlflags='-rdynamic'
    cccdlflags='-fpic', lddlflags='-shared -L/usr/local/lib'


Characteristics of this binary (from libperl): 
  Compile-time options: DEBUGGING
  Built under linux
  Compiled at May 18 1997 11:18:19
  @INC:
    /opt/perl/lib/i686-linux2.0.29/5.004
    /opt/perl/lib
    /opt/perl/lib/site_perl/i686-linux2.0.29
    /opt/perl/lib/site_perl
    .
------------------------------------------------------------------------


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

Date: 20 May 1997 19:38:01 GMT
From: O C Kwon <O.C.Kwon@durham.ac.uk>
Subject: The why a include file name of C++ has been disappeared
Message-Id: <5lsuip$pnr@mercury.dur.ac.uk>
Keywords: perl, system command

Hi ALL,

I've been fighting to fix the problem with disappearing a file name 
of the C++ include statement such as <new.h> when I run a system command
as follows.

-----
@output=`/user7/bin/co -p$ver_no[1] /user7/public_html/src/$file_name[1]`

N.B. This is a sort of RCS commands.
-----

When a perl script was run and the program source was displayed, a file
name with <> was disappeared.  If I run the above command in a Unix
prompt then it works ok.

-------
#include               // This should be #include <new.h>
#include "aosearch.h"

N.B. Other parts of this source is correct.
-------

I would be grateful if you could give me a clue.
Please send me email at o.c.kwon@durham.ac.uk


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

Date: Tue, 20 May 1997 13:59:25 -0700
From: Nicholas Hardgrove <nickh@wind-river.com>
Subject: Time stamping with perl
Message-Id: <338210AD.5920@wind-river.com>

Can anyone tell me how to get a time stamp from the system so that I can
add it into database info that I am working on?

Thank you very much,

Nick


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

Date: Wed, 21 May 1997 00:29:56 +0200
From: Georg Moritz <gm@mgm-net.de>
Subject: Re: Time stamping with perl
Message-Id: <338225E4.41C7029C@mgm-net.de>

Nicholas Hardgrove wrote:
> 
> Can anyone tell me how to get a time stamp from the system so that I can
> add it into database info that I am working on?
> 
> Thank you very much,
> 
> Nick

there is stat() :
($dev,$ino,$mode,$nlink,$uid,$gid,$rdev,$size,$atime,$mtime,$ctime,$blksize,$blocks)
        = stat($file);

hth,

--gm


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

Date: Tue, 20 May 1997 15:58:08 -0600
From: strider@ShadowMAC.org (Raul Almquist)
Subject: timelocal.pl ?
Message-Id: <strider-ya02408000R2005971558080001@news.winternet.com>

  I am using perl 5.003 on a Sun Sparc with Solaris OS.

  I have been trying to utilize perl's time and date capabilities, but so
far I can't get it to function as it states in Programming Perl states it
should function, below is my little test script


>>
#!/usr/local/bin/perl5

use Time::Local;

$time = timelocal($sec,$min,$hours,$mday,$mon,$year);

print $time
<<


and below is what I get when I run the script...

"Day out of range 1..31 in timelocal.pl at testing.pl line 5"


  What the heck is going on here?!?  how could it be out of range?

  All I need is to get localtime and local date into a related pair of
variables for another script...

$Ldate    (in yyyy-mm-dd format)
$Ltime    (in 24 hour hh:mm:ss format)

but, if I can't get that little bit of a test script to work with
localtime.pl properly, then something has to be wrong somewhere...

Email please.


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

Date: 21 May 1997 00:26:35 GMT
From: Ronald.J.Kimball@dartmouth.edu (Chipmunk)
Subject: Re: While loops starting with "1"?
Message-Id: <5ltffr$i7r$1@dartvax.dartmouth.edu>

In article <8frql5.9l4.ln@localhost>
tadmc@flash.net (Tad McClellan) writes:

> : Any help would be appreciated, also on what code around this
> : to read from and write back the substitution to a file 
> : might look like.
> 
> Probably because a 'substitution' is a verb (an action) and you 
> usually read/write nouns (things, like lines, characters...)

Um, what?
'Substitution' is a noun.  'Substitute' is a verb.

> Do you mean:
> 
> "what code around this to read the string and write it again after
> the substitution is done"?

If 'substitution' is a verb, why do you put 'the' before it?

Chipmunk


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

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

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