[8480] in Perl-Users-Digest

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

Perl-Users Digest, Issue: 2097 Volume: 8

daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Sat Mar 14 05:07:14 1998

Date: Sat, 14 Mar 98 02:00:29 -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           Sat, 14 Mar 1998     Volume: 8 Number: 2097

Today's topics:
    Re: Bad free() <dformosa@st.nepean.uws.edu.au>
    Re: Bad free() <jhi@alpha.hut.fi>
        daemon problem - signals (LONG) <gollywobble@worldnet.att.net>
        Getting Remote File Size <jesse@savalas.com>
    Re: Is there a "Newsgroup" for Newbies to Perl? <stackhou@execpc.com>
    Re: Is there a "Newsgroup" for Newbies to Perl? <cberry@cinenet.net>
    Re: lower case fails on strings with newlines?? (John Moreno)
    Re: newbie's 1st question <kose@cae.wisc.edu>
    Re: newbie's 1st question (Anders Thelemyr)
    Re: newbie's 1st question (Anders Thelemyr)
        Ordering Numbers <jesse@savalas.com>
    Re: Ordering Numbers <ajohnson@gpu.srv.ualberta.ca>
    Re: Ordering Numbers <jesse@savalas.com>
    Re: Ordering Numbers (Abigail)
    Re: Password protected twod@not.valid
    Re: Perl4 vs Perl 5 <rjk@coos.dartmouth.edu>
    Re: Perl4 vs Perl 5 (Abigail)
    Re: Read one line of a file <uri@sysarch.com>
        Redirect to another url <wongkl@singnet.com.sg>
    Re: Redirecting to a script on another server. <G.S.Cooper@iti.salford.ac.uk>
        Trying to look in different db-files [in simple txt.for (R.H.C. Ragas)
    Re: Using regex to initial cap a name (Craig Berry)
    Re: Using regex to initial cap a name (David Oswald)
    Re: Way of testing whether a variable is blessed (Ilya Zakharevich)
        Digest Administrivia (Last modified: 8 Mar 97) (Perl-Users-Digest Admin)

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

Date: 14 Mar 1998 06:29:54 GMT
From: ? the platypus {aka David Formosa} <dformosa@st.nepean.uws.edu.au>
Subject: Re: Bad free()
Message-Id: <889856994.836973@cabal>

In <3509B7F1.7ED01CDE@unival.com> Mike Hitchcock <mike@unival.com> writes:

[...]

>   Bad free() ignored at /usr/local/httpd/cgi-bin/app.mh line 287.

>I have three questions: what does this mean, what is the severity,
>and how do I fix it?

By reading man perldiag and searching for Bad Free.


--
Please excuse my spelling as I suffer from agraphia see the url in my header. 
Never trust a country with more peaple then sheep. 
Support NoCeM http://www.cm.org/                   
I'm sorry but I just don't consider 'because its yucky' a convincing argument


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

Date: 14 Mar 1998 10:27:22 +0200
From: Jarkko Hietaniemi <jhi@alpha.hut.fi>
Subject: Re: Bad free()
Message-Id: <oeeogz9oexh.fsf@alpha.hut.fi>


Mike Hitchcock <mike@unival.com> writes:
>    Bad free() ignored at /usr/local/httpd/cgi-bin/app.mh line 287.
> 
> Line 287 is one of the above variants.
> 
> I have three questions: what does this mean,

man perldiag

> what is the severity,

Not fatal ("ignored") but bad enough.

> and how do I fix it?

Try upgrading to 5.004_04.

-- 
$jhi++; # http://www.iki.fi/~jhi/
        # There is this special biologist word we use for 'stable'.
        # It is 'dead'. -- Jack Cohen


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

Date: Fri, 13 Mar 1998 23:59:39 -0700
From: Axel Elfner <gollywobble@worldnet.att.net>
Subject: daemon problem - signals (LONG)
Message-Id: <6eda56$8l7@bgtnsc02.worldnet.att.net>

Environment:
   Perl 5.003 & 5.004
   AIX 4.1.4 & 4.2.1

I have a script which is used to generate notifications (page/email) for

events monitored by applications such as Netview/Tivoli.  It essentially

acts as a lookup mechanism, mapping people to systems, so when an alert
is processed for a particular system, the correct people get notified.

Until recently, this script was called for each alert.  It did the
lookup, notification, logging, etc. and quit.  Since our control files
have grown larger, however, coupled with our intention to consolidate
this process from several servers to one, I decided it would not only be

inefficient to read the control files for each alert, but may not even
be
viable from a processing volume standpoint.  As such, I turned the
script
into a daemon.  It preloads all the config file info into a few hashes,
and goes to sleep.  Other scripts place work on a queue file (alert to
process, reload changed config files, etc), and signal the daemon (with
a
USR1(30) signal).  The daemon wakes up, process the work queue, and goes

back to sleep.  Signals for terminated child processes are handled by
the REAPER routine discussed in the Perl documentation (no explicit fork

system calls are made, but back tic commands, etc. do generate these
signals).

Everything can run fine for hours or even days, and then things happen
which I cannot explain.  I have seen the daemon core dump (sometimes
when
I think it was in a sleep() call) due to receiving either SEGV or ABRT
signals.  The AIX errpt shows entries such as these in the Additional
Information sections:

malloc_y 448         OR     raise 20
malloc_y 380                ??
malloc 104                  abort 34
_findbuf 58                 realloc_y D9C
__filbuf 24                 realloc 3C
??                          ??
??                          ??

I presume these are routines internal to Perl.

If I send one of these signals from the console, I receive a message
"Attempt to free unreferenced scalar".

A regular "ps v" of the process shows it using 0.0% of the CPU (as it is

usually sleeping), and never more than 1.0% of the Memory (so I have
ruled
out a leak).

I have also added a signal handler for the SEGV/ABRT which does a
"system" call to restart the daemon and then exits.  This works, but not

against the newly started daemon, even though the signal handler is
reinstalled.  I don't understand this.  Obviously, I am missing
something.

Prior to posting here, I spent some time at dejanews reviewing posts on
daemons, signal handling, and such.  The exchanges between Chip and Tom
on Perl signal handling were especially intriguing.  Though Tom's
daemons
enjoy long life, I will never be the programmer he is, and fear I have
chosen a poor design for this program.  I thought I could avoid wasting
the
CPU cycles of a brief polling loop (where the daemon inspects the work
queue
file for additions) by having it signaled when there was work to be
done.  From the discussions, however, it is beginning to look as if
my signal model is the cause of my grief.

I would very much appreciate if anyone could shed some light on how I
might either resolve my signal issues or elegantly avoid them
altogether.

Thanks.

Axel Elfner
elfner@us.ibm.com



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

Date: Fri, 13 Mar 1998 22:06:33 -0800
From: Jesse Rosenberger <jesse@savalas.com>
Subject: Getting Remote File Size
Message-Id: <6ed6l8$e2f@bgtnsc02.worldnet.att.net>

How would you go about writing a perl script that would open a remote
image (from a url: ex. http://www.yourdomain.com/myimage.gif) and and
get a local perl script to get the file size (in bytes) and print it out

to the browser?  If someone could provide an example of how to do
this...it would be greatly appreciated.  Thanks in advance.

Thanx,
Jesse Rosenberger
Webmaster - Savalas Productions, Inc.
http://www.savalas.com
webmaster@savalas.com



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

Date: Fri, 13 Mar 1998 22:47:57 -0600
From: Mark Stackhouse <stackhou@execpc.com>
Subject: Re: Is there a "Newsgroup" for Newbies to Perl?
Message-Id: <6ed2dn$rda@newsops.execpc.com>



I R A Aggie wrote:

> In article <3508c605.180930773@news.xmission.com>, doswald@xmission.com wrote:
>
> + A newbie newsgroup would indeed be a nightmare; a zillion questions
> + (not unlike this group's current state of affairs) and a half zillion
> + wrong answers.
>
> Worse than that, tho. The newbies would avoid such a newsgroup and
> go looking for the perl wizards newsgroup.
>

Are you being facetious here, or do you really stand behind this statement?
Newbies and intermediates would eventually get things hashed out (pun intended)...
and learn along the way.

> Say...instead of clp.mod, why not create clp.newbie and clp.wizards.
> All the newbies would ask their questions in wizards, and leave newbie
> alone...
>
> James
>
> --
> Consulting Minister for Consultants, DNRC
> The Bill of Rights is paid in Responsibilities - Jean McGuire
> To cure your perl CGI problems, please look at:
> <url:http://www.perl.com/CPAN-local/doc/FAQs/cgi/idiots-guide.html>







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

Date: Sat, 14 Mar 1998 00:16:04 -0800
From: Craig Berry <cberry@cinenet.net>
Subject: Re: Is there a "Newsgroup" for Newbies to Perl?
Message-Id: <Pine.GSO.3.95.980314001513.2503C-100000@hollywood.cinenet.net>

Josh Carter (josh@removethis.spies.com) wrote:
: I'm not arguing in favor of not using the docs when they answer the
: question -- I personally find almost all the answers I need on the
: various O'Reilly books -- but if someone finds the something confusing,
: I don't think he/she should be flamed for asking about it. If people
: here don't like answering "easy questions" (easy to them, that is), then
: maybe a new group should be created with a no-flames, no-attitude
: charter.

I've never once seen anyone flamed on clpm for posting "I read about
non-greedy matching in the Camel, and it confused me," or "I don't
understand the perldoc on 'split'."  Questions like that get polite,
respectful, and helpful answers; Perl gurus are happy to answer them. 
It's when someone asks a question which is practically word-for-word a
FAQ, or is such a basic item of language syntax that reading the first 40
pages of the Llama would answer it, that the flamethrowers come out. 

: Above all, I think posters to any comp.lang.* newsgroup should receive
: some minimum baseline of respect, since programming isn't an easy thing

I categorically refuse to respect an individual who would rather waste the
time of thousands of people than do five minutes of reading.  It seems
others on this group agree with me.  No, programming is not an easy thing;
I think part of the problem is that people *expect* it to be easy, expect
to be able to approach it as one would a (say) Windows word processor --
playing with it to learn, rather than reading a single word of the doc
(on- or offline).  This simply will not work, and those who expect it to
need an awakening, rude or otherwise. 

: to everyone. I've coached plenty of people through various programming
: tasks I consider trivially easy, and I admit it takes a conscious effort
: on my part to remember they are very intelligent people; they just don't
: have the background or "programmer's mindset" that I've aquired through
: many years of hacking around and asking trivially easy questions myself.

Yes, but I'm sure you tried to use the non-human resources available to 
you to learn, saving your questions to humans for those cases when you 
needed explanation, not information.

---------------------------------------------------------------------
   |   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: Thu, 12 Mar 1998 11:48:29 -0500
From: phenix@interpath.com (John Moreno)
Subject: Re: lower case fails on strings with newlines??
Message-Id: <1d5s0mb.l1uexg1kir4uvN@roxboro0-003.dyn.interpath.net>

Tony Curtis <Tony.Curtis+usenet@vcpc.univie.ac.at> wrote:

> kevin <kevin@cmhcsys.com> said:
> 
> kevin> $string = lc($string);
> 
> kevin> now, i'm reading in my data with $/ = "" and a line
> kevin> like $string = <INFILE>.  my problems start when i
> kevin> read in something that's more than one line long.
> 
> kevin> in either of these cases where i've got multiline
> kevin> data, lc returns zip.  it's not that it doesn't do
> kevin> lower-casing--- rather, $string now holds "".
> 
> Possibly something else is going wrong?  The following
> (horrible, hacked-up) script prints itself out in l.c. as
> expected:
> 
>     open(C, "$0");      # unchecked open
>     {
>         local $/ = "";
>         $str = <C>;     # THIS COMment wiLL all be LOWER case
>     }
>     close C;
>     print lc $str;

I'd look for something else also, the below works just fine for me

$test = "THIS\nIS\nA\nTEST\nIN ALL CAPS\n";

print lc $test;

-- 
John Moreno
I am trying to convince the author of YA-NewsWatcher that the latest
version should be released to the public.  He doesn't think there's much
interest in a new version.  Help me prove him wrong.  To do so, send me
mail <mailto:phenix@interpath.com> with a Subject of New YA.  Comments
on what you like/dislike in the current version will be appreciated.


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

Date: Sat, 14 Mar 1998 01:49:56 -0600
From: Sadi Kose <kose@cae.wisc.edu>
Subject: Re: newbie's 1st question
Message-Id: <350A36A3.552A4D2F@cae.wisc.edu>

Here is the code that does just what you want.
enjoy it! (please aknowledge R. Niles and J. Dwight)

#!/usr/bin/perl
# simplecount 1.0
# count.pl

$doc = $ENV{'DOCUMENT_URI'};
$countfile = "count";

print "Content-type: text/html\n\n";

open(COUNT, "+<$countfile") || do{print "Can't open count file"; die; };
flock(COUNT, 2);

while (<COUNT>) {
        chop;
        ($file, $count) = split(/:/, $_);
        $counts{$file} = $count;
}

$counts{$doc}++;

seek(COUNT, 0, 0);

foreach $file (keys %counts) {
       print COUNT $file, ":", $counts{$file}, "\n";
    }


close(COUNT);

print $counts{$doc};

exit;





John Hibscher wrote:

> Hello,
>         Is there any recommended code to simulate a web page counter out there?
> I'm trying to use the counter to generate unique file names. I've been
> looking at the man pages for perl and it seems I may need to go buy a book
> to understand perl functions.
>         My approach would be to have a file containing the current count. Then
> each time the page is accessed, the count would be incremented and
> re-written back to the file. It seems like no problem, but I'm lost in
> syntax. Any help is greatly appreciated.
> Thanks,
>
> John Hibscher
> john@hibs.com





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

Date: Sat, 14 Mar 1998 08:51:40 GMT
From: anderst@_NO_UCE_OR_SPAM_algonet.se (Anders Thelemyr)
Subject: Re: newbie's 1st question
Message-Id: <350b448c.39130266@news.algonet.se>

cberry@cinenet.net (Craig Berry) said:
>You definitely should buy a book -- two, in fact.  _Learning Perl_ to 
>learn the language, _Programming Perl_ for reference and to get into more 
>esoteric topics.

Does anyone know if these books have been translated into Swedish?
I read and and write English fairly well but it could get quite tiresome to
try to learn a programming/scripting language in English especially if
you're (like me) new to programming...

______________________________________________________________
http://www.swehockey.se/boden/
http://www.algonet.se/~anderst/hockeyforum/


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

Date: Sat, 14 Mar 1998 08:58:10 GMT
From: anderst@_NO_UCE_OR_SPAM_algonet.se (Anders Thelemyr)
Subject: Re: newbie's 1st question
Message-Id: <350c469f.39660774@news.algonet.se>

cberry@cinenet.net (Craig Berry) said:
>You definitely should buy a book -- two, in fact.  _Learning Perl_ to 
>learn the language, _Programming Perl_ for reference and to get into more 
>esoteric topics.

Does anyone know if these books have been translated into Swedish?
I read and and write English fairly well but it could get quite tiresome to
try to learn a programming/scripting language in English especially if
you're (like me) new to programming...

______________________________________________________________
http://www.swehockey.se/boden/
http://www.algonet.se/~anderst/hockeyforum/


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

Date: Fri, 13 Mar 1998 22:07:33 -0800
From: Jesse Rosenberger <jesse@savalas.com>
Subject: Ordering Numbers
Message-Id: <6ed6n4$e2f@bgtnsc02.worldnet.att.net>

How could you have perl take a set of numbers (1,2,3,4) and put them
into a random order???

Thanx,
Jesse Rosenberger
Webmaster - Savalas Productions, Inc.
http://www.savalas.com
webmaster@savalas.com



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

Date: Sat, 14 Mar 1998 01:17:21 -0600
From: Andrew Johnson <ajohnson@gpu.srv.ualberta.ca>
Subject: Re: Ordering Numbers
Message-Id: <350A2F01.266A8B29@gpu.srv.ualberta.ca>

Jesse Rosenberger wrote:
> 
> How could you have perl take a set of numbers (1,2,3,4) and put them
> into a random order???
> 

@array=qw(1 2 3 4);
print "@array[1,3,2,0]\n";

I've checked this against other possible random orderings
of these numbers, and this ordering is at least as random as
any of the other possible ones. The benefit of this one being
that it begins with the number 2, which is my favorite random
number less than 42.

However, if you doubt the randomness of this sequence and would
like to produce others, perhaps something in the faq's might
be of interest:

[danger:ajohnson:~]$ faqgrep random
perlfaq4.pod:=head2 Why aren't my random numbers random?
perlfaq4.pod:=head2 How do I shuffle an array randomly?
perlfaq4.pod:=head2 How do I select a random element from an array?
perlfaq5.pod:=head2 How do I randomly update a binary file?
perlfaq5.pod:=head2 How do I select a random line from a file?

item two looks particularly promising.

regards
andrew
;-/


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

Date: Fri, 13 Mar 1998 23:57:20 -0800
From: Jesse Rosenberger <jesse@savalas.com>
Subject: Re: Ordering Numbers
Message-Id: <6edd54$kp8@bgtnsc02.worldnet.att.net>

The problem I notice with doing this is it always outputs "2 4 3 1",
nothing else.  Another question: How would you go about setting this
value as a variable instead of printing it out?  And one more question:
where can I get this "faq"???

Andrew Johnson wrote:

> Jesse Rosenberger wrote:
> >
> > How could you have perl take a set of numbers (1,2,3,4) and put them
>
> > into a random order???
> >
>
> @array=qw(1 2 3 4);
> print "@array[1,3,2,0]\n";
>
> I've checked this against other possible random orderings
> of these numbers, and this ordering is at least as random as
> any of the other possible ones. The benefit of this one being
> that it begins with the number 2, which is my favorite random
> number less than 42.
>
> However, if you doubt the randomness of this sequence and would
> like to produce others, perhaps something in the faq's might
> be of interest:
>
> [danger:ajohnson:~]$ faqgrep random
> perlfaq4.pod:=head2 Why aren't my random numbers random?
> perlfaq4.pod:=head2 How do I shuffle an array randomly?
> perlfaq4.pod:=head2 How do I select a random element from an array?
> perlfaq5.pod:=head2 How do I randomly update a binary file?
> perlfaq5.pod:=head2 How do I select a random line from a file?
>
> item two looks particularly promising.
>
> regards
> andrew
> ;-/





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

Date: 14 Mar 1998 08:49:20 GMT
From: abigail@fnx.com (Abigail)
Subject: Re: Ordering Numbers
Message-Id: <6edgag$nhc$1@client3.news.psi.net>

Jesse Rosenberger (jesse@savalas.com) wrote on 1656 September 1993 in
<URL: news:6ed6n4$e2f@bgtnsc02.worldnet.att.net>:
++ How could you have perl take a set of numbers (1,2,3,4) and put them
++ into a random order???


Well, we had a long discussion about that only, uhm, 3 days ago?


my @arr = (1, 2, 3, 4);

my ($r, $i);
for ($i = @arr; $i; $r = rand $i --, @arr [$r, $i] = @arr [$i, $r]) {}


Of course, if you need to shuffle (1, 2, 3, 4) many times,
you may want to use:

my $a = [[1, 2, 3, 4], [1, 2, 4, 3],
         [1, 3, 2, 4], [1, 3, 4, 2],
         [1, 4, 2, 3], [1, 4, 3, 2],
         [2, 1, 3, 4], [2, 1, 4, 3],
         [2, 3, 1, 4], [2, 3, 4, 1],
         [2, 4, 1, 3], [2, 4, 3, 1],
         [3, 1, 2, 4], [3, 1, 4, 2],
         [3, 2, 1, 4], [3, 2, 4, 1],
         [3, 4, 1, 2], [3, 4, 2, 1],
         [4, 1, 2, 3], [4, 1, 3, 2],
         [4, 2, 1, 3], [4, 2, 3, 1],
         [4, 3, 1, 2], [4, 3, 2, 1]];

sub shuffle {@{$a -> [rand 24]}}



Abigail
-- 
perl -wle 'print "Prime" if ("m" x shift) !~ m m^\m?$|^(\m\m+?)\1+$mm'


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

Date: 14 Mar 1998 07:09:55 GMT
From: twod@not.valid
Subject: Re: Password protected
Message-Id: <6edag3$m7r$2@vnetnews.value.net>

zero (zero@sg-online.com) wrote:
: How can I create a password protected directory, Where different userID
: (and password) will get them to view, upload, download files from
: "their" own directory only?

Err, what OS, what protocol and what are you trying to do ?

We need more details otherwise it's impossible to help you. A solution for
ftp under NT will differ greatly from a solution for http under Unix.

Information, we need information !

IAP


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

Date: Sat, 14 Mar 1998 01:14:52 -0500
From: Ronald J Kimball <rjk@coos.dartmouth.edu>
Subject: Re: Perl4 vs Perl 5
Message-Id: <350A2060.37678D51@coos.dartmouth.edu>

[I hope 'you@somehost.somedomain (User)' didn't expect an email response.]

User wrote:
> 
> I am currently working on a project, my team say that we should be
> programming in Perl 5, another Team Perl 4.
> 
> Can suggest any reasons not to go with Perl 4, specific cases of code
> not working, or any pointers to such info would be great.

I'd be interested in hearing what reasons the other team could possibly come
up with for why you *should* go with Perl 4.

(And I don't mean reasons like, "We enjoy pain.")

Perl4 is several years old and is no longer supported.  Perl4 can't do hard
references, tied variables, or lookahead assertions.  Many bugs present in
Perl4 have been fixed in Perl5.  Perl5 includes other useful features, such as
chomp, my, and use.  Perl5 is better.

Convinced yet?

-- 
 _ / '  _      /         - aka -             rjk@coos.dartmouth.edu
( /)//)//)(//)/(    Ronald J. Kimball           chipmunk@m-net.arbornet.org
    /                                   http://www.ziplink.net/~rjk/
        "It's funny 'cause it's true ... and vice versa."


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

Date: 14 Mar 1998 09:02:00 GMT
From: abigail@fnx.com (Abigail)
Subject: Re: Perl4 vs Perl 5
Message-Id: <6edh28$nl1$1@client3.news.psi.net>

Ronald J Kimball (rjk@coos.dartmouth.edu) wrote on 1656 September 1993 in
<URL: news:350A2060.37678D51@coos.dartmouth.edu>:
++ [I hope 'you@somehost.somedomain (User)' didn't expect an email response.]
++ 
++ User wrote:
++ > 
++ > I am currently working on a project, my team say that we should be
++ > programming in Perl 5, another Team Perl 4.
++ > 
++ > Can suggest any reasons not to go with Perl 4, specific cases of code
++ > not working, or any pointers to such info would be great.

No, don't try to argue.

Gladly go for perl 4. Also, insist everyone one the team gets 80x24
monitor with the keyboard fixed to it. Insist on much memory, 64k at
least. Insist on backing up on punch cards, as you don't trust the modern
magnetic reels.

Put a lava lamp on your desk. Play the Beatles all the time.  Smoke
pot. Insists other do that as well. Tell stories how you and Alan [1]
were roommates. That John [2] has those wild new ideas. And that Graces
[3] work promises things for the future. Gossip about JFK and MM.



[1] Turing
[2] Von Neumann
[3] Hopper


Abigail
-- 
perl -we '%_ = map {local $_ = $_; y/a-z/n-za-m/; ($_, $_)} @_ = map {lc} <>;
          print grep {$_{$_}} @_' < /usr/dict/words


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

Date: 14 Mar 1998 01:56:33 -0500
From: Uri Guttman <uri@sysarch.com>
Subject: Re: Read one line of a file
Message-Id: <x7iuphyd3y.fsf@sysarch.com>

harrison@pixi.com (Robert F. Harrison) writes:

> ARGH!!!! This simply can't go on much longer. 
> 
> [NOTE: How I would read a line of a text file and do something to each
> line in turn would be by reading the documentation that came with
> whatever language I was trying to do it in first. Then I might not
> need to ask questions like this.]
> 
> Perl Program: Overkill :-)
> 
> #!/path/to/perl -w
> $somefile = "somefile";
> -f $somefile or die "check $somefile: $!\n";
> -T $somefile or die "$somefile isn't a text file\n";
> open(FIN,$somefile) or die "Can't open $somefile: $!\n";
> while (defined($line=<FIN>)) {
> 	chomp $line;
>     # do something
> }
> close(FIN);

underkill:

#!/path/to/perl -wn
                  ^   -n loops over all input lines setting $_
                      -p like -n but prints $_ at end of loop
do something

for more info:

perldoc perlrun



uri


-- 
Uri Guttman                     SYStems ARCHitecture and Software Engineering
uri@sysarch.com                                          Have Perl, Will Hack
http://www.sysarch.com                (781) 643-7504 x*2  FAX: (781) 643-2710
Try the Best Search Engine on the Net -------->  http://www.northernlight.com


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

Date: 14 Mar 1998 09:03:43 GMT
From: "wongkl" <wongkl@singnet.com.sg>
Subject: Redirect to another url
Message-Id: <01bd4f27$6177c540$a4ac15a5@jwtech>

To:comp.lang.perl.misc
I learning how to use Perl redirect cgi can anyone help me ,
how to use Perl redirect script that can redir you to another url like
http://www.Domain.com/cgi-bin/redir.cgi?Link=Page_html


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

Date: Sat, 14 Mar 1998 09:11:40 +0000
From: Grahame S Cooper <G.S.Cooper@iti.salford.ac.uk>
Subject: Re: Redirecting to a script on another server.
Message-Id: <350A49CC.4F7DAC97@iti.salford.ac.uk>

Sorry for posting off topic, and thanks for offering to help
anyway.

The bit that does the call to another script is below:

    $MAINSCRIPT     =
'http://146.87.83.39/cgi-bin/MasterScript.pl';
    # Transfer to the main script for deletion of the
temporary files
    # and to send an acknowledgement to the user.
    print "location:
$MAINSCRIPT&action=cleanup&identity=$identity&return_page=$returnpage\n\n";

I have also tried:

    print "location:
$MAINSCRIPT\&action=cleanup\&identity=$identity\&return_page=$returnpage\n\n";

If you have an answer, I will compose a posting for one of the
CGI FAQs.

Cheers,

Grahame


Sneex wrote:

> Off topic, see CGI-related ng:
>
> However, I have several security scripts
> which like to play tennis with each other; so
> if you could post some code of how you
> are trying this maybe we could point
> out something.
>
> The short answer is it works for me,
> what are you doing wrong or otherwise?
>
> Could be a firewall issue, or any number of
> other things...
>
> HTH,
> Sneex :)
>
> Grahame S Cooper wrote:
>
> > This could be a Perl question or a CGI question.
> > Apologies if it is off topic.
> >
> > I want to redirect from a Perl CGI script to another one
> > on a different server.
> >
> > I have tried using the Location: directive, but it
> > doesn't seem to work for this purpose, and I can't see
> > how I would specify whether to use PUT or GET, etc.
> >
> > Has anyone done this themselves and have a quick answer?
> >
> > Cheers
> >
> > --
> > --------------------------------------------------
> > Dr Grahame S Cooper
> > Director
> > Information Technology Institute
> > University of Salford
> > Salford, M5 4WT, ENGLAND
> >
> > (Remove the anti spam field to EMail me.)
> > ==================================================



--
--------------------------------------------------
Dr Grahame S Cooper
Director
Information Technology Institute
University of Salford
Salford, M5 4WT, ENGLAND

(Remove the anti spam field to EMail me.)
==================================================




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

Date: 14 Mar 1998 09:01:12 GMT
From: rragas@Jaywalk.kobua.nl (R.H.C. Ragas)
Subject: Trying to look in different db-files [in simple txt.format]
Message-Id: <slrn6gkhjr.38h.rragas@Jaywalk.kobua.nl>

The following doesn't work, could anyone please tell me why?
I can't make much of the log.

-----------------------------------------------------------snip
#!/usr/bin/perl -w
use diagnostics;
use strict;
print "In what database do you want to seek? \n";
# The following is Dutch, don't use ispell
print "________________________________________________ \n";
print "(a) adressen\n";
print "(b) bibliofiel drukwerk\n";
print "(c) cd-collectie\n";
print "(d) boeken gelezen tot en met 1995\n";
print "(e) boeken gelezen vanaf 1996\n";
print "(f) cv drama\n";
print "(g) cv film\n";
print "(h) films\n";
print "_________________________________________________\n";
print "Choose by typing the corresponding letter: \n";
chomp($letter = <STDIN>);
print "What's the word you want to look for? (case-sensitive!)\n";
chomp($woord = <STDIN>);
if ($letter =~ /^[Aa]/) {
  open(DATABASE,"/home/rragas/database/adres") || die;
  chomp(@database=<DATABASE>);
  close(DATABASE);
  foreach $line (@database) {
    if ($line=~/$woord/) {
      print("$line\n");
    }
  }
}
if ($letter =~ /^[Bb]/) {
  open(DATABASE,"/home/rragas/database/biblio") || die;

#&c. &c. &c.
---------------------------------------------------------------<<<SNIP>>>

~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Roef Ragas  .   The Jaywalk Centre  .   Amsterdam   .  The Netherlands
rragas@xs4all.nl                .         http://www.xs4all.nl/~rragas
 ......................................................................


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

Date: 14 Mar 1998 08:07:03 GMT
From: cberry@cinenet.net (Craig Berry)
Subject: Re: Using regex to initial cap a name
Message-Id: <6eddr7$4k0$1@marina.cinenet.net>

David Oswald (doswald@xmission.com) wrote:
: On Mon, 09 Mar 1998 19:48:37 -0800, Franco Finstad <ffinstad@best.com>
: wrote:
: 
: >I need to translate the string:
: >    lastname, firstname
: >into:
: >    Lastname, Firstname
: >I know this can be done elegantly using tr///; and s///; but I haven't
: >found a way.
: 
: How about this?
: 
: $string =~ s/(\b)(\w+)/$1\u\L$2/g;
: 
: Here is my logic.  I hope it's not flawed......
: Use the substitution operator, s///
: 
: Match a word.  Be sure that the word begins with a word boundry,
: capture the boundry, 

Capturing a boundary makes no sense; boundaries are zero-width 
assertions.  Capturing one will always get you a zero-length string.

A simpler way (incorporating your "force to all lowercase, then initial 
cap" feature) is:

  s/(\w+)/\u\L$1/g;

No need to explicitly check for boundaries, since \w+ will pull out 
bounded words by its very nature.

If you remove the force to lowercase feature, you can do

  s/\b(\w)/\u$1/g;

which will uppercase any word char immediately following a boundary -- 
and hence the first letter of each word.

HTH...

---------------------------------------------------------------------
   |   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: Sat, 14 Mar 1998 09:09:55 GMT
From: doswald@xmission.com (David Oswald)
Subject: Re: Using regex to initial cap a name
Message-Id: <350a4787.5208931@news.xmission.com>

On 14 Mar 1998 08:07:03 GMT, cberry@cinenet.net (Craig Berry) wrote:

>David Oswald (doswald@xmission.com) wrote:
>: On Mon, 09 Mar 1998 19:48:37 -0800, Franco Finstad <ffinstad@best.com>
>: wrote:
>: 

>: $string =~ s/(\b)(\w+)/$1\u\L$2/g;
>: 
>
>Capturing a boundary makes no sense; boundaries are zero-width 
>assertions.  Capturing one will always get you a zero-length string.

Yeah, I caught that mistake just after pushing "send".

>A simpler way (incorporating your "force to all lowercase, then initial 
>cap" feature) is:
>
>  s/(\w+)/\u\L$1/g;
>
>No need to explicitly check for boundaries, since \w+ will pull out 
>bounded words by its very nature.

That looks a lot like the example I posted in a followup to my
previous post except that I still anchored to a preceeding \b.  You're
right though, \w+ will pull in the entire word; there's no reason that
it would skip a few characters and then start midway through a word or
something.  \b is unnecessary.

>If you remove the force to lowercase feature, you can do
>
>  s/\b(\w)/\u$1/g;
>
>which will uppercase any word char immediately following a boundary -- 
>and hence the first letter of each word.
>

You could further simplify the preceeding examples by removing the
parenthesis and replacing the $1 with $&

s/\w+/\u\L$&/g;

or

s/\b\w/\u$&/g;

Still, I kind of like the force-to-lower.  It catches people with the
caps lock on, or even people who have the caps lock on and hit shift
for the first character, ie.  dAVID oSWALD.



 ... I once read a piece of Usenet philosophy that said, "If you want
to learn something on Usenet, don't ask a question.  Simply post the
wrong answer and soon you'll see posts from all over the world with
the correct answer."

Thanks for clarifying though.

Dave


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

Date: 14 Mar 1998 06:43:57 GMT
From: ilya@math.ohio-state.edu (Ilya Zakharevich)
Subject: Re: Way of testing whether a variable is blessed
Message-Id: <6ed8vd$8g5$1@mathserv.mps.ohio-state.edu>

[A complimentary Cc of this posting was sent to Ronald J Kimball 
<rjk@coos.dartmouth.edu>],
who wrote in article <350A1A06.F3DF9D61@coos.dartmouth.edu>:
> [posted and mailed]
> 
> Allen Choy wrote:
> > 
> > Is there a standard way of testing whether a variable is blessed or not?
> 
> Don't know, but...
> 
> > The only way I can think of is testing whether a reference has an '='
> > sign.
> 
> That sounds good to me.
> 
> print "Blessed.\n" if (ref $var and $var =~ /=/);

Will not work.  You need to or() with overload::Overloaded($var) in between.

Ilya


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

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

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