[9346] in Perl-Users-Digest

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

Perl-Users Digest, Issue: 2941 Volume: 8

daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Tue Jun 23 01:07:13 1998

Date: Mon, 22 Jun 98 22:00:26 -0700
From: Perl-Users Digest <Perl-Users-Request@ruby.OCE.ORST.EDU>
To: Perl-Users@ruby.OCE.ORST.EDU (Perl-Users Digest)

Perl-Users Digest           Mon, 22 Jun 1998     Volume: 8 Number: 2941

Today's topics:
    Re: after 5 hrs, the beginner beats the s/// (Martien Verbruggen)
    Re: after 5 hrs, the beginner beats the s/// <REPLY_TO_damonbrent@earthlink.net>
    Re: Corrected post (trying to avoid looping through the <tkent@pdq.net>
    Re: Flames.... <rootbeer@teleport.com>
    Re: Flames.... (Chris Nandor)
    Re: Flames.... (Patrick Timmins)
    Re: Help with guestbook PLEASE <bterbeek@ameritech.net>
        how do I get directory structure disk space used? <admin@bwsd.com>
    Re: More Complete Delete Example <luckys@geocities.com>
        Newbie Question - Please HELP!!!   :-) johnsand@usa.net
    Re: Newbie Question - Please HELP!!!   :-) (T. Ames)
    Re: Newbie Question - Please HELP!!!   :-) (Martien Verbruggen)
    Re: Pat space doesn't change in nested whiles (Martien Verbruggen)
        PERL CGI library path <dnp@ams.org>
    Re: print and the . operator ?? <eschult.NOSPAM@squonk.net>
    Re: print and the . operator ?? <eschult.NOSPAM@squonk.net>
    Re: print and the . operator ?? <eschult.NOSPAM@squonk.net>
    Re: print and the . operator ?? <eschult.NOSPAM@squonk.net>
    Re: print and the . operator ?? (Eric Schult)
        Reminder: Randal Schwartz in Chicago, June 27th (Jim Allenspach)
    Re: Sending file with Perl Script luong@my-dejanews.com
        To be BIG or to be small ... that's my question <azman@bnex.com>
    Re: To be BIG or to be small ... that's my question (Martien Verbruggen)
    Re: Warnings from environment variables under -w <steph@hotkey.net.au>
    Re: Warnings from environment variables under -w (Martien Verbruggen)
    Re: What "mini" database (text?) to use? <bakke@earthlink.net>
        Digest Administrivia (Last modified: 8 Mar 97) (Perl-Users-Digest Admin)

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

Date: 23 Jun 1998 03:04:31 GMT
From: mgjv@comdyn.com.au (Martien Verbruggen)
To: "Brent Verner" <REPLY_TO_damonbrent@earthlink.net>
Subject: Re: after 5 hrs, the beginner beats the s///
Message-Id: <6mn5vv$log$2@comdyn.comdyn.com.au>

[Posted and Mailed]

In article <6mmu8h$jhn$1@ecuador.it.earthlink.net>,
	"Brent Verner" <REPLY_TO_damonbrent@earthlink.net> writes:
> This is a multi-part message in MIME format.
> 
> ------=_NextPart_000_0044_01BD9E1F.9D5F86A0
> Content-Type: text/plain;
> 	charset="iso-8859-1"
> Content-Transfer-Encoding: quoted-printable
> 
> sorry for wasting the space and time, but i had to celebrate my victory =

Was it really necessary to post two messages bloated with HTML and
MIME stuff just for this?

I understand that you're happy that you've solved a problem you were
wrestling with, but please, be happy in private. Imagine what would
happen if everyone would post their messages like this to this
newsgroup? 

It would have been enough to just post the below message:

[edited]

> I need to get rid of any \s  characters at the beginning and end of
> a $line which needed  \s chars in the middle.
>
> I tried:
>
> $line = s/^\s+(?=\S*) | *\s*$//g;
>
> But I'd like to know if there are better way


But before posting this message, you should have checked the FAQ,
which answers this question:

# perldoc perlfaq4
/How do I strip blank space from the beginning/end of a string?

And you should have checked dejanews, because this question comes up
every few weeks in this group.

In short, the answer is:

         $line =~ s/^\s+//;
         $line =~ s/\s+$//;

Please, in the future, try a few of the suggestions I mentioned.

Martien
-- 
Martien Verbruggen                  | 
Webmaster www.tradingpost.com.au    | In a world without fences, who needs
Commercial Dynamics Pty. Ltd.       | Gates?
NSW, Australia                      | 


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

Date: Mon, 22 Jun 1998 23:46:47 -0400
From: "Brent Verner" <REPLY_TO_damonbrent@earthlink.net>
Subject: Re: after 5 hrs, the beginner beats the s///
Message-Id: <6mn8g0$8rh$1@ecuador.it.earthlink.net>

right on !!

brent


Martien Verbruggen wrote in message <6mn5vv$log$2@comdyn.comdyn.com.au>...
>[Posted and Mailed]
>
>In article <6mmu8h$jhn$1@ecuador.it.earthlink.net>,
> "Brent Verner" <REPLY_TO_damonbrent@earthlink.net> writes:
>> This is a multi-part message in MIME format.
>>
>> ------=_NextPart_000_0044_01BD9E1F.9D5F86A0
>> Content-Type: text/plain;
>> charset="iso-8859-1"
>> Content-Transfer-Encoding: quoted-printable
>>
>> sorry for wasting the space and time, but i had to celebrate my victory =
>
>Was it really necessary to post two messages bloated with HTML and
>MIME stuff just for this?
>
>I understand that you're happy that you've solved a problem you were
>wrestling with, but please, be happy in private. Imagine what would
>happen if everyone would post their messages like this to this
>newsgroup?
>
>It would have been enough to just post the below message:
>
>[edited]
>
>> I need to get rid of any \s  characters at the beginning and end of
>> a $line which needed  \s chars in the middle.
>>
>> I tried:
>>
>> $line = s/^\s+(?=\S*) | *\s*$//g;
>>
>> But I'd like to know if there are better way
>
>
>But before posting this message, you should have checked the FAQ,
>which answers this question:
>
># perldoc perlfaq4
>/How do I strip blank space from the beginning/end of a string?
>
>And you should have checked dejanews, because this question comes up
>every few weeks in this group.
>
>In short, the answer is:
>
>         $line =~ s/^\s+//;
>         $line =~ s/\s+$//;
>
>Please, in the future, try a few of the suggestions I mentioned.
>
>Martien
>--
>Martien Verbruggen                  |
>Webmaster www.tradingpost.com.au    | In a world without fences, who needs
>Commercial Dynamics Pty. Ltd.       | Gates?
>NSW, Australia                      |




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

Date: Mon, 22 Jun 1998 22:18:06 -0500
From: Tom Kent <tkent@pdq.net>
Subject: Re: Corrected post (trying to avoid looping through the entire hash)
Message-Id: <358F1E6E.FB4@pdq.net>

Tom Kent wrote:
 
  Corrected Post:


 This script snippet allows me to parse a web server log and tell me
how> many times   each site was hit. However, I am unable to capture
just the
 top ten. Instead, I am only able to go through the entire hash. I've
 tried counters and for loops in various places with no luck...Any
ideas?
 Thanks very much in advance.
 

sub occurrences {
  $count{$a} <=> $count{$b};
 }



 @array = <SOMEFILE>;
 
 foreach $thisline (@array) {
        ($Fld1) = split (' ',$thisline);
        push @words, ($Fld1);
          }
 
 foreach $word (@words) {
   $count{$word} = $count{$word} + 1;
  }
 
      foreach $word (reverse sort occurrences keys %count) {
        print "$count{$word}        $word\n";
  }


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

Date: Tue, 23 Jun 1998 02:28:03 GMT
From: Tom Phoenix <rootbeer@teleport.com>
Subject: Re: Flames....
Message-Id: <Pine.GSO.3.96.980622192239.3398T-100000@user2.teleport.com>

On 22 Jun 1998, Lloyd Zusman wrote:

> Given that c.l.p.misc is a public, non-moderated newsgroup, I do not
> believe that anyone has the right to say that it's *their* house.

If I see someone tossing litter onto the grounds of the city park, I may
scold them even though it's not *my* park. If I see someone cluttering
this newsgroup with off-topic messages, I may scold them even though it's
not *my* newsgroup. 

Let's all help to keep this newsgroup a valuable resource. Don't let
people get away with littering.

-- 
Tom Phoenix       Perl Training and Hacking       Esperanto
Randal Schwartz Case:     http://www.rahul.net/jeffrey/ovs/



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

Date: Tue, 23 Jun 1998 03:35:52 GMT
From: pudge@pobox.com (Chris Nandor)
Subject: Re: Flames....
Message-Id: <pudge-2206982333060001@dynamic52.ply.adelphia.net>

In article <ltvhpsub8e.fsf@asfast.com>, Lloyd Zusman <ljz@asfast.com> wrote:

# Given that c.l.p.misc is a public, non-moderated newsgroup, I do not
# believe that anyone has the right to say that it's *their* house.  And

Sure we do.  People who follow the rules of the newsgroup can say it
belongs to them.  Else you are saying alt.furry.rabbits people can
reasonably claim this group as their own, too, which simply is not the
case.


# furthermore, given that the "newbies" who come here are human beings
# like everyone else, I also take strong issue with the insulting
# characterization of them as "flies".

Be offended.  Go right ahead.  But realize it is not "newbies" who are
flies, it is "clueless newbies who would rather waste someone else's time
than their own."

# (1)  ... use killfiles, the 'n', key, etc.  In other words,
#      ignore it.

I often do just that.

# (2)  ... accept that things have changed and give it no further
#      thought.

How fatalistic.  Not in my nature.

# (3)  ... politely and respectfully try to explain the established
#      patterns to the newcomers, and (still politely and
#      respectfully) try to persuade them to continue to adhere
#      to these conventions if they don't initially do that.

And if you are so offended by the impolite remarks, why not just follow
your own hypocritical advice in 1 and 2 above?  Hm?

-- 
Chris Nandor          mailto:pudge@pobox.com         http://pudge.net/
%PGPKey = ('B76E72AD', [1024, '0824090B CE73CA10  1FF77F13 8180B6B6'])


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

Date: Tue, 23 Jun 1998 04:36:19 GMT
From: ptimmins@netserv.unmc.edu (Patrick Timmins)
Subject: Re: Flames....
Message-Id: <6mnbc4$r73$1@nnrp1.dejanews.com>

In article <6mmngs$fca$1@chick.ldgo.columbia.edu>,
  stewartw@ldeo.columbia.edu (stewart wills) wrote:
[snip]
> inane "newbie needs help" query.  Now here's the ironic part:  *I will
probably
> never post a question on this newsgroup.*  That's not because I'm so smart
that
> I'll never need the help, and not because the docs are so good that I'll never
> come up with a question they don't answer.  It's because I have no desire to
> have one of the sharp-tongued gurus here tell me what a dumbass I am if the
> answer *does* happen to be buried in a man page somewhere.
[snip]

So you're arguing that the sharp-tongued responses do have an impact on
reducing the number of questions asked where the answer is in the
documentation?

> to go unasked.  Let's face it; nobody particularly enjoys public humiliation
> (well, nobody I know, anyway).

So you're arguing that the sharp-tongued responses do have an impact on
reducing the number of questions asked where the answer is in the
documentation?

>I haven't noticed that all the flames have
> reduced the number of faqs or off-topic posts, but they may have persuaded at

How do you measure what hasn't happened? That's like the gun control nuts who
argue that being armed doesn't reduce your chances of being robbed,
assaulted, killed, etc. Common sense says that this is not true. If the
number of "criminals" increases 100% in a 1 year period, but the crime rate
only increases 20%, then you've had a very significant impact on the overall
"criminal activity", even though crime has increased.

You're argument is inconsistent, and it goes against common sense (to me,
anyway).

Patrick Timmins
U. Nebraska Medical Center

-----== Posted via Deja News, The Leader in Internet Discussion ==-----
http://www.dejanews.com/   Now offering spam-free web-based newsreading


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

Date: Mon, 22 Jun 1998 23:43:49 -0400
From: Brian TerBeek <bterbeek@ameritech.net>
Subject: Re: Help with guestbook PLEASE
Message-Id: <358F2474.179982EE@ameritech.net>

The problem can be two fold. First try the command at the command line.
Perl
will give good information back if in fact there is a problem with the
script. Second
if your sever does not know how to execute the file then this error will
also occur.
Check your server documentation. This error is generic and most servers
will not
give you the stdout of the Perl error. The error could be in a log but it
might be
buried in along with alot of other information. Try a simple "hello.pl"
script first.
See Netscapes Support Site for some tips.

Bill wrote:

> Hi, I am trying to make a guestbook perl file work.  I keep getting an
> error and I narrowed it down to the following lines.  This is where
> the error occurs.  ($guestbookreal is pointed to the right address.)
>
> ##start##
> # Begin the Editing of the Guestbook File
> open (FILE,"$guestbookreal") || die "Can't Open $guestbookreal:
> #$#$!\n";
> @LINES=<FILE>;
> close(FILE);
> $SIZE=@LINES;
> ##end##
>
> The line that the error occurs at is the open statement.  The error it
> gives me is:
>
> Internal Server Error
>
> The server encountered an internal error or misconfiguration and was
> unable to complete your request.
>
> Please contact the server administrator, webmaster@insync.net and
> inform them of the time the error occurred, and anything
> you might have done that may have caused the error.
>
> What am I doing wrong?  Any help please?
>
> you can reply via email at:  jsadek@bayou.uh.edu





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

Date: Mon, 22 Jun 1998 23:54:54 -0500
From: Beck Web Servers & Design <admin@bwsd.com>
Subject: how do I get directory structure disk space used?
Message-Id: <358F351E.55F8EEB3@bwsd.com>

Hi:

I'm trying to a directory structure -> disk space used script.  I
haven't the foggiest where to start.  I can do stuff with files, but
have never attempted directories.  I know what I need...just don't know
how....read directory and all directories under and get running total of
bytes in the directories...I know there must be an easy way to do this.

Any help would be appreciated.  Thanks.

-- 
Eric Beck, BWSD
http://web-design.net/index.shtml
mailto:erbeck@web-design.net
Phone: 905 436 6814   Fax:  905 725 4023
============================================================
Internet Call Manager - Get Your Calls While Online!
http://internetcallmanager/agents/bwsd
============================================================
BECK WEB SERVERS & DESIGN - WHERE SUPPORT AND SERVICE ARE #1
============================================================


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

Date: Mon, 22 Jun 1998 23:52:42 -0400
From: Luckys <luckys@geocities.com>
Subject: Re: More Complete Delete Example
Message-Id: <358F268A.4435@geocities.com>

What I specificly want to know is how does one DELETE() from a DMB file
with regards to associative arrays?

I just want to delete data from a DMB file and it to not be there
anymore.

Thank you for the previous suggestions, but after checking and changing
those portions of my code as previously suggested: I am able to print
from the DBM file but can't delete the same data.  Why?


Luckys wrote:
> 
> I'm sorry if my previous example was a bit inaccurate.  I didn't me for
> it to be a working example.  I was more interest in the use of the
> delete function.
> 
> Below is a better, working example of what I'm attempting to do.  I
> don't understand why it won't delete the key, value pairs from the DMB
> file.
> 
> #!/usr/bin/perl
> 
> $key1 = "name1";
> $value1 = "name1:\0:street_address:\0:etc";
> 
> $key2 = "name2";
> $value2 = "name2:\0:street_address:\0:etc";
> 
> dbmopen(%delete, "delete", 0766);
> 
> $delete{$key1} = "$value1";
> $delete{$key2} = "$value2";
> 
> dbmclose(%index);
> 
> &DEL;
> 
> # Open DBM file and delete key, value pair.
> 
> sub DEL {
> dbmopen(%delete, "delete", 0766);
> 
> foreach (keys %delete) {
> 
>    delete $delete{$_};
> 
> }
> 
> dbmclose(%index);
> }


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

Date: Tue, 23 Jun 1998 03:34:17 GMT
From: johnsand@usa.net
Subject: Newbie Question - Please HELP!!!   :-)
Message-Id: <358f1f3f.10036663@news6.bellatlantic.net>

    I am very new to PERL and CGI Scripts.   What I would like to do
is the following:

	A user fills out a form with the following information:

	Minimum Test Value  (Option list   2,3,4,5,6)
	Test String (option list string1, string2, string3)
	Test Range  (option list 0-1000, 1001-2000, 2001-3000)

	Then I would like to search through the local Web Pages and
find the values which are a constant format such as:

	Test : 3
	Test String : string2
	Average : 2049

	First...   How do I parse the information out so it is usable?

	Second...  How do I test for a minimum value as well as all
values greater than the minimum.  (See Minimum Test Value Above, I
would like to find every match that is <user selected value> and
greater)

	Third...  How would I parse out the range in the last
parameter so I could find if the range on the page was within the
range the user entered?  2049 would fall within the range 2001-3000

	Sorry if this is too much to post an answer to, but if you
could at least give me some examples of the criteria parsing, then I
think I could work the rest out....

	If you want to post to answer here, Fine, but could you please
E-Mail me at  johnsand@bellatlantic.net also. I don't get all the
messages from my provider (idiots at Bellatlantic only have some of
the messages and very few of the groups)




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

Date: Tue, 23 Jun 1998 04:09:49 GMT
From: ames0009@tc.umn.edu (T. Ames)
Subject: Re: Newbie Question - Please HELP!!!   :-)
Message-Id: <358f2821.7755768@news.tc.umn.edu>

On Tue, 23 Jun 1998 03:34:17 GMT, johnsand@usa.net wrote:

>    I am very new to PERL and CGI Scripts.  

The first thing that you should do is examine the FAQs.  You will find
the answers to your questions there.  Here is the address of two
Perl/CGI FAQs that will help you:

http://www.eprotect.com/stas/TULARC/webmaster/myfaq.html
and
http://language.perl.com/CPAN/doc/FAQs/cgi/idiots-guide.html

If you want to learn Perl, begin by looking at the FAQ:

http://language.perl.com/faq/


If, on the other hand, you do not wish to learn Perl but are looking
for someone to configure a CGI script for you, try 
comp.infosystems.www.authoring.cgi.  

The Perl/CGI FAQs should answer most of your questions.  Also check
out www.perl.com for tutorials, book reviews, etc.

Hope that helps,

T. Ames


>>>>>>>>>>>>>>>>>>>
Todd C. Ames
ames0009@tc.umn.edu
University of Minnesota


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

Date: 23 Jun 1998 04:33:45 GMT
From: mgjv@comdyn.com.au (Martien Verbruggen)
Subject: Re: Newbie Question - Please HELP!!!   :-)
Message-Id: <6mnb79$m7a$2@comdyn.comdyn.com.au>

In article <358f1f3f.10036663@news6.bellatlantic.net>,
	johnsand@usa.net writes:
>     I am very new to PERL and CGI Scripts.   What I would like to do
> is the following:

They really haven't got that much to do with each other. You can write
a CGI application in Perl, yes, but you can also write it in lots of
other languages.

> 	A user fills out a form with the following information:
> 
> 	Minimum Test Value  (Option list   2,3,4,5,6)
> 	Test String (option list string1, string2, string3)
> 	Test Range  (option list 0-1000, 1001-2000, 2001-3000)
> 
> 	Then I would like to search through the local Web Pages and
> find the values which are a constant format such as:
> 
> 	Test : 3
> 	Test String : string2
> 	Average : 2049
> 
> 	First...   How do I parse the information out so it is usable?

use CGI.pm

> 	Second...  How do I test for a minimum value as well as all
> values greater than the minimum.  (See Minimum Test Value Above, I
> would like to find every match that is <user selected value> and
> greater)

What do you mean? I'm sorry, but I can't really grok what you're
saying here. Do you mean you want to search your file for all numbers
that are larger than the minimum value?

> 	Third...  How would I parse out the range in the last
> parameter so I could find if the range on the page was within the
> range the user entered?  2049 would fall within the range 2001-3000

Same question.


Are you saying that you want to search through HTML files to find all
occurences of numbers that are larger than the minimum value, but are
also in the range? or do you have some sort of database for this?

You will really have to be a lot clearer in what you want if you need
help. You should also _first_ try it yourself. Read some
documentation, write some test code. If you run into problems with
that, please, by all means, post here, and we'll try to help. or do
you expect us to write a complete program for you?

Try:

# perldoc perl
# perldoc perldoc
# perldoc perlsyn
# perldoc CGI

If you're a beginner, you might also want to buy a good book. Go to
http://language.perl.com/info/documentation.html, and look at the list
of books there.

> 	Sorry if this is too much to post an answer to, but if you
> could at least give me some examples of the criteria parsing, then I
> think I could work the rest out....

Perl can match text and numbers in many ways. They're all explained in

# perldoc perlop
# perldoc perlre

Martien
-- 
Martien Verbruggen                  | 
Webmaster www.tradingpost.com.au    | If it isn't broken, it doesn't have
Commercial Dynamics Pty. Ltd.       | enough features yet.
NSW, Australia                      | 


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

Date: 23 Jun 1998 02:57:12 GMT
From: mgjv@comdyn.com.au (Martien Verbruggen)
Subject: Re: Pat space doesn't change in nested whiles
Message-Id: <6mn5i8$log$1@comdyn.comdyn.com.au>

In article <6mmqjt$6l0@milo.vcn.bc.ca>,
	def456@vcn.bc.ca (John Yates) writes:
> I'm having a problem with the pattern space in nested whiles.  The
> pattern space does not change when a second while <> reads in records.
> If I run this program:
> ---------------------
>     #!/usr/bin/perl
>     while (<>) {
>         print "In 1st while, \$_ = $_";
>             while(<> && !m/bb/) {

	This doesn't do what you expect it to do. Change it to

	while(<>) {
		last if /bb/;
		print "    In 2nd while, \$_ = $_";
	} 

or

	while(defined($line = <>) && $line !~ /bb/)

or if you want to be slightly perverse:

	while(defined($_ = <>) && ! /bb/)


Have a read of perlop to understand why:

# perldoc perlop

Especially the section 'I/O Operators', where it says:

	Evaluating a filehandle in angle brackets yields the next
	line from that file (newline, if any, included), or undef at
	end of file.  Ordinarily you must assign that value to a
	variable, but there is one situation where an automatic
	assignment happens.  If and ONLY if the input symbol is the
	only thing inside the conditional of a while or for(;;)
	loop, the value is automatically assigned to the variable
    $_.

Notice 'If and ONLY if' and 'only thing' in this piece of information.

Martien
-- 
Martien Verbruggen                  | 
Webmaster www.tradingpost.com.au    | If it isn't broken, it doesn't have
Commercial Dynamics Pty. Ltd.       | enough features yet.
NSW, Australia                      | 


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

Date: Mon, 22 Jun 1998 16:21:40 -0400
From: Dan Pelton <dnp@ams.org>
Subject: PERL CGI library path
Message-Id: <358EBCD4.4E064040@ams.org>

I have a perl cgi which calls perl module or reads a text files.  Now I
would 
like to run a copy of the exact same HTML and perl scripts in a test
area
at the same time and on the same machine as the development area.  We
are
thinking of using a different port number to access the html pages in
the
test area (example: www.mysite.com:99). 

My problem is that the perl load path is the same for the scripts
in both areas.  I would like to change the load path for perl packages
in the test area to a different directory without modifying the code.
The PERL5LIB environment variable would work except that there is no
way to set it when using perl as a cgi.

I have similar problem for text files which are read in.  I need a way
to determine at run time which area (directory) to the read the file
from.  Once again an environment variable would have been perfect.

thanks,

Dan Pelton
dnp@ams.org


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

Date: Mon, 22 Jun 1998 23:47:51 -0400
From: "Eschult" <eschult.NOSPAM@squonk.net>
Subject: Re: print and the . operator ??
Message-Id: <6mn8i4$4sa$1@duke.squonk.net>

$line includes the line termination character, which you are appending to
$grades{student}.  The print is printing it, yielding the extra blanks in
your output.

Try adding 'chop $line;' as your first line after the 'while ($line......)
{' line.

As to why '.=' behaves like '=', in your sample data there are no duplicates
of student names.  If there were '.=' would append the grades, whereas "="
would replace the 1st grade with the 2nd.

Which is 'right' depends on what you're trying to accomplish.


Seo Choi wrote in message ...
>#!/usr/bin/perl
>
>open(GRADES, "grades") || die "Can't open grades: $!\n";
>while($line = <GRADES>) {
>  ($student, $grade) = split(" ", $line);
>  $grades{$student} .= $grade . " ";
>  $gList{$student} = $grade . " ";
>}
>
>foreach $student (%grades) {
>  print "$grades{$student}\n";
>}
>
>print "-" x 25, "\n";
>foreach $student (%gList) {
>  print "$grades{$student}\n";
>}
>
>from the code above I have two questions. the first is why in the line
> $grades{$student} .=
>behaves the same way as
> $grades{$student} = without the dot
>
>
>the second question is why I have the output when using the attachment as
>the input file as:
>3
>
>5
>
>4
>
>1
>
>2
>
>-------------------------
>3
>
>5
>
>4
>
>1
>
>2
>
>because when i take the "\n" from the two foreach loops the out pout is
>only two lines long??




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

Date: Mon, 22 Jun 1998 23:57:14 -0400
From: "Eschult" <eschult.NOSPAM@squonk.net>
Subject: Re: print and the . operator ??
Message-Id: <6mn935$4tj$1@duke.squonk.net>

$line includes the line termination character, which you are appending to
$grades{student}.  The print is printing it, yielding the extra blanks in
your output.

Try adding 'chop $line;' as your first line after the 'while ($line......)
{' line.

As to why '.=' behaves like '=', in your sample data there are no duplicates
of student names.  If there were '.=' would append the grades, whereas "="
would replace the 1st grade with the 2nd.

Which is 'right' depends on what you're trying to accomplish.


Seo Choi wrote in message ...
>#!/usr/bin/perl
>
>open(GRADES, "grades") || die "Can't open grades: $!\n";
>while($line = <GRADES>) {
>  ($student, $grade) = split(" ", $line);
>  $grades{$student} .= $grade . " ";
>  $gList{$student} = $grade . " ";
>}
>
>foreach $student (%grades) {
>  print "$grades{$student}\n";
>}
>
>print "-" x 25, "\n";
>foreach $student (%gList) {
>  print "$grades{$student}\n";
>}
>
>from the code above I have two questions. the first is why in the line
> $grades{$student} .=
>behaves the same way as
> $grades{$student} = without the dot
>
>
>the second question is why I have the output when using the attachment as
>the input file as:
>3
>
>5
>
>4
>
>1
>
>2
>
>-------------------------
>3
>
>5
>
>4
>
>1
>
>2
>
>because when i take the "\n" from the two foreach loops the out pout is
>only two lines long??






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

Date: Mon, 22 Jun 1998 23:57:14 -0400
From: "Eschult" <eschult.NOSPAM@squonk.net>
Subject: Re: print and the . operator ??
Message-Id: <6mna45$5lv$1@duke.squonk.net>

$line includes the line termination character, which you are appending to
$grades{student}.  The print is printing it, yielding the extra blanks in
your output.

Try adding 'chop $line;' as your first line after the 'while ($line......)
{' line.

As to why '.=' behaves like '=', in your sample data there are no duplicates
of student names.  If there were '.=' would append the grades, whereas "="
would replace the 1st grade with the 2nd.

Which is 'right' depends on what you're trying to accomplish.


Seo Choi wrote in message ...
>#!/usr/bin/perl
>
>open(GRADES, "grades") || die "Can't open grades: $!\n";
>while($line = <GRADES>) {
>  ($student, $grade) = split(" ", $line);
>  $grades{$student} .= $grade . " ";
>  $gList{$student} = $grade . " ";
>}
>
>foreach $student (%grades) {
>  print "$grades{$student}\n";
>}
>
>print "-" x 25, "\n";
>foreach $student (%gList) {
>  print "$grades{$student}\n";
>}
>
>from the code above I have two questions. the first is why in the line
> $grades{$student} .=
>behaves the same way as
> $grades{$student} = without the dot
>
>
>the second question is why I have the output when using the attachment as
>the input file as:
>3
>
>5
>
>4
>
>1
>
>2
>
>-------------------------
>3
>
>5
>
>4
>
>1
>
>2
>
>because when i take the "\n" from the two foreach loops the out pout is
>only two lines long??






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

Date: Mon, 22 Jun 1998 23:57:14 -0400
From: "Eschult" <eschult.NOSPAM@squonk.net>
Subject: Re: print and the . operator ??
Message-Id: <6mnb5r$5n2$1@duke.squonk.net>

$line includes the line termination character, which you are appending to
$grades{student}.  The print is printing it, yielding the extra blanks in
your output.

Try adding 'chop $line;' as your first line after the 'while ($line......)
{' line.

As to why '.=' behaves like '=', in your sample data there are no duplicates
of student names.  If there were '.=' would append the grades, whereas "="
would replace the 1st grade with the 2nd.

Which is 'right' depends on what you're trying to accomplish.


Seo Choi wrote in message ...
>#!/usr/bin/perl
>
>open(GRADES, "grades") || die "Can't open grades: $!\n";
>while($line = <GRADES>) {
>  ($student, $grade) = split(" ", $line);
>  $grades{$student} .= $grade . " ";
>  $gList{$student} = $grade . " ";
>}
>
>foreach $student (%grades) {
>  print "$grades{$student}\n";
>}
>
>print "-" x 25, "\n";
>foreach $student (%gList) {
>  print "$grades{$student}\n";
>}
>
>from the code above I have two questions. the first is why in the line
> $grades{$student} .=
>behaves the same way as
> $grades{$student} = without the dot
>
>
>the second question is why I have the output when using the attachment as
>the input file as:
>3
>
>5
>
>4
>
>1
>
>2
>
>-------------------------
>3
>
>5
>
>4
>
>1
>
>2
>
>because when i take the "\n" from the two foreach loops the out pout is
>only two lines long??






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

Date: 23 Jun 1998 00:48:03 -0400
From: eschult@domino.squonk.net (Eric Schult)
To: Seo Choi <swc4@acpub.duke.edu>
Subject: Re: print and the . operator ??
Message-Id: <nfg1gwu3kq.fsf@domino.squonk.net>


Without a description of the purpose of the script, its hard to give
sound advice, but it appears as if you meant to say:

	'foreach $student (keys %gList'
	                   ^^^^
and
	'foreach $student (keys %gList)

By putting the entire list in the foreach statement you were assigning
$student to the student name then to the grade for that student
(causing the blanks, btw!) then the next student name, then that
student's grade, etc etc.

You seem to want to process each student NAME, one per foreach
loop...hence the 'keys' keyword mentioned above.

Hope this helps.

-- 
Eric 
<eschult.NOJUNK@squonk.net>
Remove the NOJUNK for replies (UCE and SPAM not welcome)





In article <Pine.SOL.3.91.980622123822.10113A-200000@teer2.acpub.duke.edu> Seo Choi <swc4@acpub.duke.edu> writes:

   #!/usr/bin/perl

   open(GRADES, "grades") || die "Can't open grades: $!\n";
   while($line = <GRADES>) {
     ($student, $grade) = split(" ", $line);
     $grades{$student} .= $grade . " ";
     $gList{$student} = $grade . " ";
   }

   foreach $student (%grades) {
     print "$grades{$student}\n";
   }

   print "-" x 25, "\n";
   foreach $student (%gList) {
     print "$grades{$student}\n";
   }

   from the code above I have two questions. the first is why in the line
	   $grades{$student} .=
   behaves the same way as 
	   $grades{$student} =	without the dot


   the second question is why I have the output when using the attachment as 
   the input file as:
   3

   5

   4

   1

   2

   -------------------------
   3

   5

   4

   1

   2

   because when i take the "\n" from the two foreach loops the out pout is 
   only two lines long??


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

Date: 22 Jun 1998 22:48:34 -0500
From: jima@MCS.COM (Jim Allenspach)
Subject: Reminder: Randal Schwartz in Chicago, June 27th
Message-Id: <6mn8ii$r0c@Venus.mcs.net>
Keywords: randal,chicago,jacph

	Randal Schwartz will be in Chicago on Saturday the 27th, delivering
his "Just Another Convicted Perl Hacker" speech. This event is sponsored by
Chicago Perl Mongers. For the full info, check out the Chi.PM Website at
http://chicago.pm.org/ .

jma



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

Date: Tue, 23 Jun 1998 04:45:29 GMT
From: luong@my-dejanews.com
Subject: Re: Sending file with Perl Script
Message-Id: <6mnbta$s09$1@nnrp1.dejanews.com>

In article <358bd2c2.1167344@news.alt.net>,
  mark-lists@webstylists.com (Mark Thompson) wrote:

 Hi,
 After processing the input information, your program should response as
 usual by printing the content-type header:

print STDOUT<<OEM;
Content-Type: text/html

<HTML>
<HEAD>
<TITLE></TITLE>
    <SCRIPT LANGUAGE="JavaScript">
    <!--
     function LoadPage() {
         self.location.href="URL_of_the_file";
     }
    //-->
    </SCRIPT>
</HEAD>
<!--then the most important line goes here//-->
<BODY onLoad="LoadPage()">
OEM

Browser of the users will switch to this URL, and base on the content-type
of that file, it will decide whether to open, to launch the appropriate
application or to prompt them to save that file.

Good luck
Pham Thuc Truong Luong
-----------
> I have a file that I want to send users but only if they fill out a form
> first.  Basically, since there's disclaimers about the program that we need
> to make sure that they read, we need it set up so that they can't just follow
> a link to get the file directly.
>
> My guess is that the best way would be to have the form processing software
> return the file as output if the form is filled out correctly but I don't
> really know how to do this.

-----== Posted via Deja News, The Leader in Internet Discussion ==-----
http://www.dejanews.com/   Now offering spam-free web-based newsreading


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

Date: Mon, 22 Jun 1998 11:25:50 +0800
From: Azman Shariff <azman@bnex.com>
Subject: To be BIG or to be small ... that's my question
Message-Id: <358DCEBE.1EDC2AAF@bnex.com>

Hi!

Okay here goes m silly question, and I hope i only get solving replies
:)

I am writing a search function and done with it.. but then the prob is
say you type "Sea" it will search the exact case whcih i don't want it
to be so. I wish to write an expression or a search module or function
that will check and return ANY string that matches that be it in small
case or anything.

i used the below function :

-------------code------------------

      open(SEARCHFILE,"$classadspath/search.index") || die "Could not
read $classadspath/search.index: $!\n";
      while(<SEARCHFILE>){
         ($Sheader, $Scname, $Sidno) = split(/:/,$_,3);
         #betcha a million that you don't know the line below removes
all '\n' characters!
         $Sidno =~ s/^\n+|\n+$//g;
         if ($Scname eq $classadsname) { #aha! let's hope it is the
correct catogery
            #so since it enters here then it must be!
            #time to do some soul searching! Umm i mean string searching

            if (grep (/$searchstring/, $Sheader)){
               #oh heck! why do we always count our chicks before the
hatch?
               $searchcounter = $searchcounter + 1;
               if ($printheader eq "1"){ #so here we are to print or not
to print that is the question
                  print "<B>Classified Section -
$classadsdesc</B><BR>\n";
                  print "<UL>\n";
                  $printheader ="0";
               }
               print "<LI><A
HREF=$classadsname.html#$Sidno>$Sheader</A>\n";

            }
         }
      }
      print "</UL>\n";
      close( SEARCHFILE ); #all good searches must definitely come to an
end somehow rite?

-----------snip snip---------------

i used if (grep ( )) blah blah blah... so i would like to write i so
that it will check for any kind o upper or lower case.... hmmm

hope you guys understand wha i mean.... hmmmm thank you!! :)

Azman Shariff



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

Date: 23 Jun 1998 04:26:13 GMT
From: mgjv@comdyn.com.au (Martien Verbruggen)
Subject: Re: To be BIG or to be small ... that's my question
Message-Id: <6mnap5$m7a$1@comdyn.comdyn.com.au>

In article <358DCEBE.1EDC2AAF@bnex.com>,
	Azman Shariff <azman@bnex.com> writes:
> Hi!
> 
> Okay here goes m silly question, and I hope i only get solving replies
>:)

see my answer to your other post with a different subject and body,
but basically the same question. i'm too lazy to look for it now.

> -------------code------------------

[Reformat]

open(SEARCHFILE,"$classadspath/search.index") || 
	die "Could not read $classadspath/search.index: $!\n";

while(<SEARCHFILE>)
{
	# - ($Sheader, $Scname, $Sidno) = split(/:/,$_,3);
	# - $Sidno =~ s/^\n+|\n+$//g;
	chomp;
	($Sheader, $Scname, $Sidno) = split /:/;

	if ($Scname eq $classadsname) 
	{
		# I suppose the line below is the one you're having a problem
		# with?
		# - if (grep (/$searchstring/, $Sheader))
		if ($Sheader =~ /$searchstring/i)
		{
			$searchcounter = $searchcounter + 1;
			if ($printheader eq "1")
			{
				print "<B>Classified Section -
				$classadsdesc</B><BR>\n";
				print "<UL>\n";
				$printheader ="0";
			}
			print "<LI><A HREF=$classadsname.html#$Sidno>$Sheader</A>\n";

		}
	}
}
print "</UL>\n";
close( SEARCHFILE );

Again: See my other post for possibly better solutions. I'm not going
to type them again.

Martien

PS. For future reference: Please don't post message twice. 
-- 
Martien Verbruggen                  | 
Webmaster www.tradingpost.com.au    | Unix is user friendly. It's just
Commercial Dynamics Pty. Ltd.       | selective about it's friends.
NSW, Australia                      | 


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

Date: Tue, 23 Jun 1998 11:45:09 +1000
From: Stephan Carydakis <steph@hotkey.net.au>
Subject: Re: Warnings from environment variables under -w
Message-Id: <358F08A5.60A4@hotkey.net.au>

Tom Phoenix wrote:

> Hope this helps!
> 
> --
> Tom Phoenix       Perl Training and Hacking       Esperanto
> Randal Schwartz Case:     http://www.rahul.net/jeffrey/ovs/

Thanks for your advice and time Tom.

I thought I might just show you the culprit:

sub check_referer
{
  my ($test_referer,$passed_referer);

  if ($ENV{'HTTP_REFERER'}) {
     foreach $test_referer (@referer) {
       if ($ENV{'HTTP_REFERER'} =~ /$test_referer/i) {
          $passed_referer = "yes";
          last;
       } else {
          $passed_referer = "no";
       }
     }
  }

  if ($passed_referer eq "no" || !$ENV{'HTTP_REFERER'}) {
     &error('Bad Referer','Make Sure You Have Access To This Script');
  }
}

The warning is raised in by the !ENV{'HTTP_REFERER'} in the last if
statement.
If I remove that occurance of the variable, other warnings sudenly
pop-up further on in my program, again by references to environment
variables???

What I find odd is that there is a reference to the same environment
variable just a few lines earlier, which doesn't raise a warning?? Is it
the ! making it negative, or opposite?(I'm fishing) that makes the last
occurance raise a warning? 

Anyways, thanks again Tom, and to anyone else who answers this post.

______________________________________________
Stephan Carydakis        steph@hotkey.net.au
______________________________________________
"Fa Fa-Fa Fa-Fa Fa Fa Fa" - Maceo Parker


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

Date: 23 Jun 1998 04:10:51 GMT
From: mgjv@comdyn.com.au (Martien Verbruggen)
Subject: Re: Warnings from environment variables under -w
Message-Id: <6mn9sb$m2d$1@comdyn.comdyn.com.au>

In article <358F08A5.60A4@hotkey.net.au>,
	Stephan Carydakis <steph@hotkey.net.au> writes:

>   if ($passed_referer eq "no" || !$ENV{'HTTP_REFERER'}) {
>      &error('Bad Referer','Make Sure You Have Access To This Script');
>   }
> }
> The warning is raised in by the !ENV{'HTTP_REFERER'} in the last if
> statement.

Are you sure?

#!/usr/local/bin/perl -w
use strict;
my %hash;
print $hash{some_key} ? "got it\n" : "haven't got it\n";
$hash{some_key} = undef;
print $hash{some_key} ? "got it\n" : "haven't got it\n";

No warnings, no errors. And there should be none. undef is just a
false value.

I think that your warning might be coming from the $passed_referer in
the same condition.

See the next one:

#!/usr/local/bin/perl -w
use strict;
my %hash;
my $thing = undef;
print STDOUT ($hash{some_key}) ? "got it\n" : "haven't got it\n";
$hash{some_key} = undef;
print STDOUT ($hash{some_key}) ? "got it\n" : "haven't got it\n";

print STDOUT 
    ($thing eq 'no' || $hash{some_key}) ? "got it\n" : "haven't got it\n";

Gives me:

haven't got it
haven't got it
Use of uninitialized value at ./tt.pl line 9.
haven't got it

Hmmmm...

Martien
-- 
Martien Verbruggen                  | 
Webmaster www.tradingpost.com.au    | 75% of the people make up 3/4 of the
Commercial Dynamics Pty. Ltd.       | population.
NSW, Australia                      | 


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

Date: Mon, 22 Jun 1998 22:33:19 -0400
From: "Jonathan Bakke" <bakke@earthlink.net>
Subject: Re: What "mini" database (text?) to use?
Message-Id: <6mn4kf$lqg$1@argentina.it.earthlink.net>

Kay

I am using MySQL which runs on a few different Unix platforms (and
WindowsNT).  You can get it at www.mysql.com.  It comes with perl modules
for connecting to the DB that require Perl 5.003 (you should use 5.004+).  I
have a database with over 300,000 records and I get fairly good performance.
I had an easy time installing it on RedHat Linux, just make sure you have
current versions of the OS and Perl.  Good Luck.

/jpb
--
-----
Jonathan Bakke
(703) 754-7034 [Voice]
(703) 753-9343 [Fax - Call First]
-----
Zenin wrote in message <898493888.707321@thrush.omix.com>...
>Kay Molkenthin <molkiheg@sp.zrz.tu-berlin.de> wrote:
>: I just started with perl and wrote an adress book for my webserver.
>: Because I want to learn more about perl I like to store the datas in a
>: database, now I store them in a text file.
>:
>: For this project I only need a small database application. I heared of a
>: text based perl database. What is the name and what do I need?
>
> Information on DBM style databases can be found via
> perldoc AnyDBM_File
>
> If you want a text style database system with SQL style access,
> check out the DBI system and the DBD::CSV driver, or the Sprite
> module.  All available at CPAN.
>
>--
>-Zenin
> zenin@archive.rhps.org




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

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

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