[16804] in Perl-Users-Digest

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

Perl-Users Digest, Issue: 4216 Volume: 9

daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Sun Sep 3 18:10:49 2000

Date: Sun, 3 Sep 2000 15:10:32 -0700 (PDT)
From: Perl-Users Digest <Perl-Users-Request@ruby.OCE.ORST.EDU>
To: Perl-Users@ruby.OCE.ORST.EDU (Perl-Users Digest)
Message-Id: <968019031-v9-i4216@ruby.oce.orst.edu>
Content-Type: text

Perl-Users Digest           Sun, 3 Sep 2000     Volume: 9 Number: 4216

Today's topics:
    Re: How to truncate file after nth occurrence of string <godzilla@stomp.stomp.tokyo>
    Re: How to truncate file after nth occurrence of string <stephenk@cc.gatech.edu>
    Re: How to truncate file after nth occurrence of string <godzilla@stomp.stomp.tokyo>
        Internationalization: LC_MESSAGES, In Particular (Jim Seymour)
        Looking for Netware NDS Perl Module <quest@powersurfr.com>
    Re: Makefile.PL and PREFIX Part II <gellyfish@gellyfish.com>
        My first Perl Page <tom@webign.co.uk>
    Re: My Perl looks like C! (Jim Seymour)
    Re: no $ENV{REMOTE_USER} ? (Colin Keith)
    Re: Parsing MySQL TEXT field <alesr@siol.net>
        Pattern Matching sfcq2@my-deja.com
    Re: Perl version question <gellyfish@gellyfish.com>
        Relative to Absolute help? ptomsic@my-deja.com
    Re: Relative to Absolute help? <bart.lateur@skynet.be>
    Re: Return-value of open of nonexisting pipe <gellyfish@gellyfish.com>
    Re: Sony Versus Microsoft (Jim Seymour)
    Re: Sony Versus Microsoft <brian+usenet@smithrenaud.com>
        sort numbers based on value paceman97@aol.com
    Re: sort numbers based on value <tony_curtis32@yahoo.com>
    Re: Submitting form twice fails <tony_curtis32@yahoo.com>
    Re: Thinking in Perl jkeen@concentric.net
    Re: Thinking in Perl <gellyfish@gellyfish.com>
    Re: what does @$_ do? (Keith Calvert Ivey)
    Re: Why doesn't this work? HTTP request problem (David Efflandt)
        Digest Administrivia (Last modified: 16 Sep 99) (Perl-Users-Digest Admin)

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

Date: Sun, 03 Sep 2000 13:17:12 -0700
From: "Godzilla!" <godzilla@stomp.stomp.tokyo>
Subject: Re: How to truncate file after nth occurrence of string
Message-Id: <39B2B1C8.22DA1BE1@stomp.stomp.tokyo>

Bryan McAvoy wrote:
 
> Ouch. Well, thanks for setting me straight on how to ask the question.
> I guess what I asked didn't make a lot of sense. Anyway, let's try 
> this again.

Clarity in communication is critical, especially when
engaging an English teacher, such as myself, in dialog.

 
> Here is a snippet of the log file from which I wish to grab
> the 5 most recent products.

> Products are appended to the beginning of the file

Products are "prepended" to the beginning of your log file.

Use of prepend in this context is incorrect grammar.
There is no such word prepend within this context.
Prepend means to consider, premediate, to give
careful thought, as in perpend. An example of
prepend would be to tell a joke with a bit of
malice aforethought intent or malice prepense
intent. Think antecedent or precedent but not 
precedent as in law. Do not confuse prepenial
with these thoughts.


(snipped)

Previously I indicated use of meta characters for delimiters
within a data base is most illogical. It is up to you to
figure out how to remove those meta characters. This is
a price you pay for illogical thinking.

This line:

  $start = $start + length ($param2);

will remove whatever you use for your 'start' input parameter.
If you don't want your start input parameter removed, then
comment out or delete this line shown above.

This script was tested with your actual data provided.
Works just fine. You will notice I added a safety factor
should you request more records than available. I am not
sure what will happen if you request less records than
available.

Consider this a bare bones skeleton script from which
to learn a bit of logic in thinking. You will quickly
note, my actual script, is quite short and sweet compared
to what you where trying to do with your script. I have
tested this well per your input parameters. No failures
within stated parameters.


http://www.hamweather.com/


Godzilla!
-- 
Dr. Kiralynne Schilitubi ¦ Cooling Fan Specialist
UofD: University of Duh! ¦ ENIAC Hard Wiring Pro
BumScrew, South of Egypt ¦ HTML Programming Class


TEST SCRIPT:
____________


#!/usr/local/bin/perl

print "Content-Type: text/plain\n\n";

$data = '# Start log file
BULLETIN-
data set 1
$$
BULLETIN-
data set 2
$$
BULLETIN-
data set 3
$$
BULLETIN-
data set 4
$$
BULLETIN-
data set 5
$$';


print "== Input:\n\n$data\n\n";

print "== Output:";

## user input parameters:

# $param1 is number of records to find
# $param2 is where to start search
# $param3 is record separator


$param1 = 1;
$param2 = '# Start log file';
$param3 = '$$';

&Seek;


$param1 = 3;
$param2 = '# Start log file';
$param3 = '$$';

&Seek;


$param1 = 5;
$param2 = '# Start log file';
$param3 = '$$';

&Seek;

## request more records than available:

$param1 = 7;
$param2 = '# Start log file';
$param3 = '$$';

&Seek;


sub Seek
 {
  ($stop, $start) = index ($data, $param2);
  $start = $start + length ($param2);

  for ($seek = 1; $seek <= $param1; $seek++)
   {
    if (index ($data, $param3, $stop) > -1)
     { $stop = index ($data, $param3, $stop); }
    else
     { last; }
    $stop++;
   }

  $seek--;
  $stop--;

  $new_data = substr ($data, $start, $stop - $start);

  $record = "record";
  if ($param1 > 1)
   { $record = "records"; }

  print "\n\nBoss, you asked for $param1 $record.\n",
        "I found $seek $record:\n\n$new_data";
 }

exit;




PRINTED RESULTS:
________________


== Input:

# Start log file
BULLETIN-
data set 1
$$
BULLETIN-
data set 2
$$
BULLETIN-
data set 3
$$
BULLETIN-
data set 4
$$
BULLETIN-
data set 5
$$

== Output:

Boss, you asked for 1 record.
I found 1 record:


BULLETIN-
data set 1


Boss, you asked for 3 records.
I found 3 records:


BULLETIN-
data set 1
$$
BULLETIN-
data set 2
$$
BULLETIN-
data set 3


Boss, you asked for 5 records.
I found 5 records:


BULLETIN-
data set 1
$$
BULLETIN-
data set 2
$$
BULLETIN-
data set 3
$$
BULLETIN-
data set 4
$$
BULLETIN-
data set 5


Boss, you asked for 7 records.
I found 5 records:


BULLETIN-
data set 1
$$
BULLETIN-
data set 2
$$
BULLETIN-
data set 3
$$
BULLETIN-
data set 4
$$
BULLETIN-
data set 5


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

Date: Sun, 03 Sep 2000 16:49:05 -0400
From: Stephen Kloder <stephenk@cc.gatech.edu>
Subject: Re: How to truncate file after nth occurrence of string
Message-Id: <39B2B940.F06FF1AF@cc.gatech.edu>

Bryan McAvoy wrote:

> Ouch. Well, thanks for setting me straight on how to ask the question. I
> guess what I asked didn't make a lot of sense. Anyway, let's try this again.
>
> Here is a snippet of the log file from which I wish to grab the 5 most
> recent products. Products are appended to the beginning of the file
> (actually, since I'm not at work attm, I just pasted the same warning back
> to back, but this is what the log file looks like:
>

Since you have a set delimeter, you can use $/ to pull full entries out of the
file, instead of single lines:
$/='$$';
Calling <SVRFILE> in list context will return an array of product entries, and
calling it in scalar context will return the next entry in the file.  So
something like:
$/='$$';
print SVROUT scalar <SVRFILE> foreach (1..5);

should do the trick.
Read perlvar for further info.

--
Stephen Kloder               |   "I say what it occurs to me to say.
stephenk@cc.gatech.edu       |      More I cannot say."
Phone 404-874-6584           |   -- The Man in the Shack
ICQ #65153895                |            be :- think.




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

Date: Sun, 03 Sep 2000 14:25:24 -0700
From: "Godzilla!" <godzilla@stomp.stomp.tokyo>
Subject: Re: How to truncate file after nth occurrence of string
Message-Id: <39B2C1C4.1C34F006@stomp.stomp.tokyo>

"Godzilla!" wrote:
 
> Bryan McAvoy wrote:

(snipped ingeniously stunning code of my own)

I have a hunch an obessive Techno-Geekster
will pull a stupefying "what if" bozo stunt
by changing parameters, tugging at his or her
hair while jumping up and down along with 
passing smelly methane gas and screaming,

"WHAT IF! WHAT IF! WHAT IF! WHAT IF!"

If you are curious about my resolution for what-ifs
yet to be blathered by blithering idiots, add these 
two if conditionals to my subroutine as shown between
previously given code snippets for location reference:


sub Seek
 {


  if ((!($data)) || (index ($data, $param3) == -1))
   { print "\n\n You stupid arsehole. There are no records."; exit; }
  if ($param1 < 1)
   { print "\n\n You stupid arsehole. Why are you asking for no records?"; exit;
}


  ($stop, $start) = index ($data, $param2);


Godzilla!
--
@© = (a .. z); @® = qw (7 15 4 26 9 12 12 1 18 15 3 11 19);
srand(time() ^ ($$ + ($$ << 15))); for ($§ = $®[$®[0]]; $§ < $®[0]; $§++)
{ sub G { rand(1000) < 500 ? "\u$1" : "\l$1" ; } foreach $¿ (@®) 
{ $¢ = $©[$¿-1]; $¢ =~ s¡([a-z])¡G($1)¡gie; $Ø = "$Ø$¢"; }
$Ø ="$Ø! "; $ø = substr ($Ø, $®[12] - $®[11], 0, " ");
$Ø =~ s¯(a)(r)¯$1 $2¯i; push (@Ø,$Ø); } foreach $¡ (@Ø)
{ print "$¡\n"; } @¶ = reverse (@Ø); foreach $¶ (@¶)
{ print "$¶\n"; } exit;


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

Date: Sun, 03 Sep 2000 13:19:27 GMT
From: jseymour@LinxNet.com (Jim Seymour)
Subject: Internationalization: LC_MESSAGES, In Particular
Message-Id: <sr4juv8kc5d90@corp.supernews.com>

I have created a logfile analyzer for the Postfix MTA.  Mainly as an
exercise in learning Perl while at the same time creating something
useful.  It turned out to have become pretty popular with users of
Postfix, with the result that now someone has translated its message
strings into Spanish.  He has requested, not unreasonably, that I
consider doing something to make such future translations easier.  It
seems to me the *best* way to do this is to make use of "locale."
Specifically:  LC_MESSAGES.  But I can find no pointers on how to do
this with Perl--not in my Perl library, searching perl.com or
searching Deja.

Can some kind soul here point me in the right direction?


TIA,
Jim
-- 
Jim Seymour                  | PGP Public Key available at:
jseymour@LinxNet.com         | http://www.cam.ac.uk.pgp.net/pgpnet/wwwkeys.html
http://home.msen.com/~jimsun | http://www.trustcenter.de/cgi-bin/SearchCert.cgi


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

Date: Sun, 3 Sep 2000 12:53:50 -0600
From: "Stephane Zanoni" <quest@powersurfr.com>
Subject: Looking for Netware NDS Perl Module
Message-Id: <8ou744$c42$1@dagger.ab.videon.ca>

I'm looking for a Netware Perl Module, it's listed in the CPAN site as:

Netware::
::NDS             cd+O Interface to Novell Directory Services       KTHOMAS
::Bindery         cd+O Interface to Novell Bindery mode calls       KTHOMAS

but it's not availlable for download.  I was just wondering if anyone here
might have it or has seen it somewhere, or can hint me in what direction to
go and find it.

Thanks,
    Stephane




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

Date: 3 Sep 2000 12:56:20 +0100
From: Jonathan Stowe <gellyfish@gellyfish.com>
Subject: Re: Makefile.PL and PREFIX Part II
Message-Id: <8ote94$7b7$1@orpheus.gellyfish.com>

On Sun, 03 Sep 2000 09:40:05 GMT STAT wrote:
>  Greetings, so I'm about to fall asleep when it dawns on me...
> 

You really should have followed up to your previous post rather than
starting a new thread so people will know what you are on about.

> - make
> - make test
> - make install
> 
> Duh...

Ahah, I wish you had tried that before I followed up your previous post.

> 
> my question now is... would it be better to Makefile.PL
> PREFIX=/home/stat
> 
> instead of /home/stat/www/cgi-bin/Lib ??
> 
> I now have Base64.pm in
> /home/stat/www/cgi-bin/Lib/lib/perl5/site_perl/i386-linux-thread/MIME/
> 
> which is a heck of a mouthful... it would still work as good right?
> I just want to know before I install all the other modules that I need
> before I install LWP.pm
> 

Yes,  you will then get the modules installed under :

  /home/stat/lib/perl5/site_perl/

and you will have to use that in your 'use lib'.

>  And, if so, is it alright to simply delete the directory and start
> over, or do I have to do a special uninstall?
> 

Deleting the directory tree is fine.

/J\
-- 
yapc::Europe in assocation with the Institute Of Contemporary Arts
   <http://www.yapc.org/Europe/>   <http://www.ica.org.uk>


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

Date: Sun, 3 Sep 2000 17:28:49 +0100
From: "Tom Fotheringham" <tom@webign.co.uk>
Subject: My first Perl Page
Message-Id: <8otu7n$qv3$1@uranium.btinternet.com>

Just a bit of fun, submit something to make your day brighter.
http://server2038.virtualave.net/tomfoth/theone.pl




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

Date: Sun, 03 Sep 2000 13:40:45 GMT
From: jseymour@LinxNet.com (Jim Seymour)
Subject: Re: My Perl looks like C!
Message-Id: <sr4l6tmpc5d125@corp.supernews.com>

In article <1eg979e.1ito4051h7oeteN@[192.168.88.117]>,
	sumus@aut.dk (Jakob Schmidt) writes:
[snip]
> - don't use parens around parameter lists when you don't have to
[snip]

I kind of regard superfluous parens as like whitespace and indents:
they help clarify the code.  I know that these can sometimes defeat
optimization by C compilers.  Is there any similar down-side to doing
this with Perl?  Other than the fact that they'll apparently make you
look like a newbie :-)?  I don't recall seeing any references to
such.


Regards,
Jim
-- 
Jim Seymour                  | PGP Public Key available at:
jseymour@LinxNet.com         | http://www.cam.ac.uk.pgp.net/pgpnet/wwwkeys.html
http://home.msen.com/~jimsun | http://www.trustcenter.de/cgi-bin/SearchCert.cgi


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

Date: Sun, 03 Sep 2000 13:11:46 GMT
From: newsgroups@ckeith.clara.net (Colin Keith)
Subject: Re: no $ENV{REMOTE_USER} ?
Message-Id: <m6ss5.4062$6A2.393391@nnrp4.clara.net>

In article <39AFEB09.3520@siol.net>, marvin <alesr@siol.net> wrote:
>You need to use CGI and then function remote_user

No you don't. You can query the contents of %ENV directly if you want. It is 
perhaps more uniform to use CGI.pm's interface, but you don't have to use it. 
If its not set its not set. I suspect it might be something more along the 
lines of you not using HTTP authentication to access this script, but ...

>But you must have security to that directory, where Perl is,
>otherwise it will not work, even if HTML is in protected dir.

This is along the right lines.

Col.


---
Colin Keith
Systems Administrator
Network Operations Team
ClaraNET (UK) Ltd. NOC


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

Date: Sun, 03 Sep 2000 15:38:37 +0200
From: marvin <alesr@siol.net>
Subject: Re: Parsing MySQL TEXT field
Message-Id: <39B2545B.23BA@siol.net>

Keith Calvert Ivey wrote:
> 
> Marvin <ales.romaniuk@zag.si> wrote:
> 
> >When I pull this field into variable, and watch its value in DEBUG, I
> >can see this:
> >
> >Line1\cM\cJLine2\cM\JLine3\cM\cJ
> 
> It sounds like you're doing something wrong with translation of
> line-ending characters, starting with data that's using Windows
> (or network) line endings and treating it as if it has Unix line
> endings.
> 
> >which seems to be CR/LF fields.
> >
> >If I watch line by line made by split "\n",@TEXTFIELD), I can see
> >
> >Line1\cM
> >Line2\cM
> >Line3\cM
> >
> >with no \cJ fields.
> 
> No, you don't.  The second argument of split() should be a
> scalar, not an array.  The result of split("\n", @TEXTFIELD)
> would be just 3 in your case.
> 
> >How can I strip TEXT fields and put them into an ARRAY with the split
> >command ?
> 
> You may want something like this:
> 
>     my @lines = split /\cM\cJ/, $TEXTFIELD;
> 
> if you have a scalar, or
> 
>     s/\cM\cJ$// for @TEXTFIELD;
> 
> if you really have an array.
> 
> But it might be better to get your data right in the first
> place.
> 
> >(Also split("\c",@TEXTFIELD) won't work)
> 
> What do you expect it to do?  It's a syntax error, though
> strangely it isn't if you change the quotes to slashes (which is
> a good idea, since the first argument to split() is a regex, not
> a string).
> 
> --
> Keith C. Ivey <kcivey@cpcug.org>
> Washington, DC
Yes, I actually have scalar parameter as a second in split. I only
put wrong in example. But if I use split "\c",$FIELD, I get syntax
error. I thought that \n is equal to CR/LF which is hex 0x0d 0x0a,
but seems its not.
Thanks anyway


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

Date: Sun, 03 Sep 2000 15:36:08 GMT
From: sfcq2@my-deja.com
Subject: Pattern Matching
Message-Id: <8otr57$d0l$1@nnrp1.deja.com>

Hello,

I am creating a htaccess and htpasswd management system, but have hit a
bit of a hurdle.

I can add all names and encrypted passwords to "htpasswd", but I want to
compare the names from the existing file to those in a new file that
will update the site. If a name already exists, the user will not be
sent an email confirming his username and password, because they are
already there.

I am creating the user as follows:

$newline[$a] = $username[$a]. ":" .$newpass[$a];

and this gives an output like:

rob.phillips:a1fZxO.8KssXw

which is added to a temp file. Then, I open htpasswd and search through
it line by line until a match is found like this:

open (PASS, "<htpasswd") || die "Can't open htpasswd: $!\n";
@oldusers = <PASS>;
close (PASS);

for ($a = 1; $a < @oldusers; $a++) {
     $_ = $oldusers[$a];
     if (/$newline[$a]/) {
          DO STUFF
     }
}

A match should be found because I am using the same data source fle each
time, but it never finds the entry in htpasswd. Have I missed something?

Thanks for your help,

Rob.


Sent via Deja.com http://www.deja.com/
Before you buy.


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

Date: 3 Sep 2000 13:00:27 +0100
From: Jonathan Stowe <gellyfish@gellyfish.com>
Subject: Re: Perl version question
Message-Id: <8otegr$7bk$1@orpheus.gellyfish.com>

On Sun, 3 Sep 2000 06:26:55 -0400 Richard Muller wrote:
> Hi All,
> 
> I just downloaded and installed ActiveState Perl 5.6.
> 
> When I run it with the -v switch, it announces version 5.6.0.  But is that
> version # really the "distribution" version, as opposed to the version of
> the underlying Perl interpreter?
> 
> Looking around on NGs, etc., I get the impression that the current Perl
> interpreter version is something like 5.005.
> 
> What's the scoop?
> 

No 5.005 was the previous release (actually 5.005.03) and 5.6.0 is the
current one (note also that the version numbering scheme has been changed).
Activestate have a notion of a build number of which there may be several
for any given release of Perl, I think there current build is 616 for the
5.6.0 release.

/J\
-- 
yapc::Europe in assocation with the Institute Of Contemporary Arts
   <http://www.yapc.org/Europe/>   <http://www.ica.org.uk>


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

Date: Sun, 03 Sep 2000 19:52:53 GMT
From: ptomsic@my-deja.com
Subject: Relative to Absolute help?
Message-Id: <8oua6i$sai$1@nnrp1.deja.com>

Does anyone know of anything currently avail that will transform
relative links to absolute?

I've got a full directory listing of 2400 html files, and I'm searching
for something that will allow me to supply the root directory, and the
URL, and have it transform (inside the HTML files)
a link such as (href=../../file.html) to
(http://sitename.com/dir1/dir2/file.html)

Thanks for any help.

-Paul


Sent via Deja.com http://www.deja.com/
Before you buy.


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

Date: Sun, 03 Sep 2000 20:31:41 GMT
From: Bart Lateur <bart.lateur@skynet.be>
Subject: Re: Relative to Absolute help?
Message-Id: <m6d5rscbsflp466e2thfpevqdma73vfap7@4ax.com>

ptomsic@my-deja.com wrote:

>Does anyone know of anything currently avail that will transform
>relative links to absolute?
>
>I've got a full directory listing of 2400 html files, and I'm searching
>for something that will allow me to supply the root directory, and the
>URL, and have it transform (inside the HTML files)
>a link such as (href=../../file.html) to
>(http://sitename.com/dir1/dir2/file.html)

At least look into the documentation (at CPAN) for HTML::LinkExtor and
URI::URL. Even if HTML::LinkExtor doesn't exactly do what you want (I
think not), then you still can use it's source for inspiration for
creating your own script. The functionality is all there.

-- 
	Bart.


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

Date: 3 Sep 2000 14:12:46 +0100
From: Jonathan Stowe <gellyfish@gellyfish.com>
Subject: Re: Return-value of open of nonexisting pipe
Message-Id: <8otioe$7jb$1@orpheus.gellyfish.com>

On Sun, 3 Sep 2000 01:26:03 -0500 Andrew N. McGuire  wrote:
> On Sun, 3 Sep 2000, Avast quoth:
> 
> ~~ Date: Sun, 03 Sep 2000 03:36:30 GMT
> ~~ From: Avast <avast@hortonsbay.com>
> ~~ Newsgroups: comp.lang.perl.misc
> ~~ Subject: Re: Return-value of open of nonexisting pipe
> ~~ 
> ~~ On 02 Sep 2000 19:19:18 EDT, abigail@foad.org (Abigail) wrote:
> ~~ 
> ~~ >Martin H.Ludwig (Martin.H.Ludwig@ing-buero-ludwig.de) wrote on MMDLIX
> ~~ >September MCMXCIII in <URL:news:20000902.21445100@biggy.ma.net>:
> ~~ >## Hello,
> ~~ >## 
> ~~ >## I want to use the open-command to open a pipe and to test if the program
> ~~ >## exists. Strange to say open results with a defined return-value even if
> ~~ >## the pipe-command does not exists!
> ~~ >## 
> ~~ >## 
> ~~ >## #!/usr/bin/perl
> ~~ >## 
> ~~ >## $Empf="Martin.H.Ludwig\@ing-buero-ludwig.de";
> ~~ >## $mailprog="/usr/sbin/sendmailXX";
> ~~ >## $|=1;
> ~~ >## 
> ~~ >## $xpid = open (MAIL, "| $mailprog $Empf");
> ~~ >## 
> ~~ >## if ( defined( $xpid ) ) {
> ~~ >##   print "Open OK\n";
> ~~ >## } else {
> ~~ >##   print "Open-Error\n";
> ~~ >## }
> ~~ >## 
> ~~ >## 
> ~~ >## 
> ~~ >## results everytime [SCARY CHARACTER]Open OK[SCARY CHARACTER], although /usr/sb
> ~~ >## exist. $xpid is the PID des Perl-program. Whats wrong?
> ~~ >
> ~~ >Your reading ability.
> ~~ 
> ~~ perldoc perlstyle | grep -i nice
> 
> as Abigail said:
> 
> perldoc perldata | perl -wne 'm~@(\w+) = \(\);~ && print "\u$1.\n"'
> 
> Now:
> 
> perldoc perlstyle | perl -wne 's~nice~*plonked*~ && print'
> 

To which I might add :

   perldoc perlstyle | perl -ne '($_)=m%it.d (\w+\s\w+)%;y%b%M%;print'

:)

/J\
-- 
yapc::Europe in assocation with the Institute Of Contemporary Arts
   <http://www.yapc.org/Europe/>   <http://www.ica.org.uk>


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

Date: Sun, 03 Sep 2000 13:27:35 GMT
From: jseymour@LinxNet.com (Jim Seymour)
Subject: Re: Sony Versus Microsoft
Message-Id: <sr4ke7p0c5d150@corp.supernews.com>

In article <8orv3p$gnd$1@nnrp1.deja.com>,
	pohanl@my-deja.com writes:
[snip]
> 
> Now what does this have to do with Perl?  Well, creating games
> in perl is something that needs to be addresed because perl
> is too text based....

Too text-based?  PERL: Practical Extraction and Report Language.

Looks to me like this feeble attempt to tie the post to Perl was
no more than an ploy to avoid getting flamed for posting an off-
topic diatribe to CLPM.


Regards,
Jim
-- 
Jim Seymour                  | PGP Public Key available at:
jseymour@LinxNet.com         | http://www.cam.ac.uk.pgp.net/pgpnet/wwwkeys.html
http://home.msen.com/~jimsun | http://www.trustcenter.de/cgi-bin/SearchCert.cgi


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

Date: Sun, 03 Sep 2000 14:14:25 -0400
From: brian d foy <brian+usenet@smithrenaud.com>
Subject: Re: Sony Versus Microsoft
Message-Id: <brian+usenet-B7531B.14142503092000@news.panix.com>

In article <8orv3p$gnd$1@nnrp1.deja.com>, pohanl@my-deja.com wrote:

> Now what does this have to do with Perl?  Well, creating games
> in perl is something that needs to be addresed because perl
> is too text based....

perhaps you should use another language.  no one said that 
you always have to use Perl.

-- 
brian d foy
Perl Mongers <URL:http://www.perl.org>
CGI Meta FAQ <URL:http://www.smithrenaud.com/public/CGI_MetaFAQ.html>


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

Date: Sun, 03 Sep 2000 13:12:21 -0400
From: paceman97@aol.com
Subject: sort numbers based on value
Message-Id: <39B28675.18CB7467@aol.com>

whats an easy way to sort an array full of numbers and print out the
highest number first.
lets say an array of numbers is like this:

@array=("5","7","4");

thanks in advance



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

Date: 03 Sep 2000 12:24:48 -0500
From: Tony Curtis <tony_curtis32@yahoo.com>
Subject: Re: sort numbers based on value
Message-Id: <8766odl76n.fsf@limey.hpcc.uh.edu>

>> On Sun, 03 Sep 2000 13:12:21 -0400,
>> paceman97@aol.com said:

> whats an easy way to sort an array full of numbers and
> print out the highest number first.  lets say an array
> of numbers is like this:
> @array=("5","7","4");

That's an array of strings.

Strangely, perl has a sort() function.  And there's even
an example of exactly what you want to do in "perldoc -f
sort".  "perldoc perlfaq" also has the solution.

hth
t
-- 
"I'm not easily impressed.  Wow!  A blue car!"
                                               Homer Simpson


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

Date: 03 Sep 2000 10:47:49 -0500
From: Tony Curtis <tony_curtis32@yahoo.com>
Subject: Re: Submitting form twice fails
Message-Id: <87aedpiije.fsf@limey.hpcc.uh.edu>

>> On Sun, 3 Sep 2000 21:29:30 +1000,
>> "James R" <reevehotNOSPAM@hotmail.com> said:

> I have a pretty standard Perl script for converting form
> to mail (using Blat and NT).

> When I submit the form contents once, it works fine, but
> when I submit it again, even with some minor changes, it
> fails to write the temp file and send the email.

> My thoughts are that it may have something to do with
> localised variables carrying over to the second run, or
> the original temp-file not closing.

> Should I reset variables at the end?  Should I "exit",
> rather than leaving the script to end itself?

The program *always* exits after it has been invoked by an
access to the webserver, and open files will then close.
Every time.  So that's not the problem, unless you're
using mod_perl.  Are you?

Without seeing code I don't think anyone can provide you
with any useful or at least on-target information.  I'd
guess that 1 of the following might be the problem, but it
can be only a guess:

1. You're using mod_perl

1.414 You need to close some filehandles properly

2. You need to ensure exclusive access to something
   through locks.

3. There's a typo on line 17.

hth
t
-- 
"I'm not easily impressed.  Wow!  A blue car!"
                                               Homer Simpson


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

Date: Sun, 03 Sep 2000 16:51:54 GMT
From: jkeen@concentric.net
Subject: Re: Thinking in Perl
Message-Id: <8otvj6$hk3$1@nnrp1.deja.com>

In article <8otgi3$2j2$1@nnrp1.deja.com>,
  reg_exp@my-deja.com wrote:
> Hi,
>
> I'm a Perl newbie.... simple question : "How do I think in Perl" ?
>
> By this I mean :
> a) How can I learn to use the Perl idioms better ?
> b) How should I think of OOP in Perl ?
> c) How can I use hashes more effectively ?
> d) Can I reuse the idioms learnt in other languages in Perl, or should
> I discard them ??
>
This topic was (perhaps still is) being hashed over in a thread on this
forum entitled "My Perl Looks Like C!"  But probably the simplest
suggestion is to read Joseph N. Hall with Randal L.
Schwartz, "Effective Perl Programming," published by Addison-Wesley.
Answering your question is its raison d'etre.  "The Perl Cookbook" from
O'Reilly is also useful here.

Jim Keenan/Brooklyn, NY


Sent via Deja.com http://www.deja.com/
Before you buy.


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

Date: 3 Sep 2000 22:15:31 +0100
From: Jonathan Stowe <gellyfish@gellyfish.com>
Subject: Re: Thinking in Perl
Message-Id: <8ouf1j$93e$1@orpheus.gellyfish.com>

On Sun, 03 Sep 2000 12:35:15 GMT reg_exp@my-deja.com wrote:
> Hi,
> 
> I'm a Perl newbie.... simple question : "How do I think in Perl" ?
> 
> By this I mean :
> a) How can I learn to use the Perl idioms better ?

Read this group more frequently.

> b) How should I think of OOP in Perl ?

Read the 'The C++ programming language' by Bjorn Stroustrup and then
'Programming Perl' and then Damien Conway's book - strictly in that order.

> c) How can I use hashes more effectively ?

Understand the structure of your data more effectively in the first place.

> d) Can I reuse the idioms learnt in other languages in Perl, or should
> I discard them ??

The ability to program is a reusable skill indeed,  however you will find
that flexibility of mind is more important than experience in depth of
any other programming language when learning Perl.

/J\
-- 
yapc::Europe in assocation with the Institute Of Contemporary Arts
   <http://www.yapc.org/Europe/>   <http://www.ica.org.uk>


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

Date: Sun, 03 Sep 2000 20:54:48 GMT
From: kcivey@cpcug.org (Keith Calvert Ivey)
Subject: Re: what does @$_ do?
Message-Id: <39b6ba7a.8335830@news.newsguy.com>

"Durk Gardenier" <d.gardenier@iae.nl> wrote:

>@sentence =("as",Ï","drive", "to", "the","junction");

How'd you manage to have "I turned into Ï without also having 
"a turned into ä?

-- 
Keith C. Ivey <kcivey@cpcug.org>
Washington, DC


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

Date: Sun, 3 Sep 2000 21:15:59 +0000 (UTC)
From: efflandt@xnet.com (David Efflandt)
Subject: Re: Why doesn't this work? HTTP request problem
Message-Id: <slrn8r5fse.sc.efflandt@efflandt.xnet.com>

On Sun, 27 Aug 2000 18:21:06 +0200, Seiberdragan <rpolzer@web.de> wrote:
>#!/usr/bin/perl -w
>
>use Socket;
>use Sys::Hostname;
>
>sub GetPage ($, $, $)
>{
> my ($server, $port, $addr) = @_;
> my $ip = inet_aton ($server);
> my $sin = sockaddr_in ($port, $ip);
> my $proto = getprotobyname ("tcp");
> socket (my $MYSOCKET, PF_INET, SOCK_STREAM, $proto)             || die
>"SOC";
> connect ($MYSOCKET, $sin)                                       || die
>"CON";
> print $MYSOCKET "HTTP/1.0 GET $addr\015\012\015\012";
> while (defined ($x = <$MYSOCKET>))
> #here it hangs. Even a simple <$MYSOCKET> or getc($MYSOCKET) hangs.
> {
>  print "recv returned: $x\n";
> }
> close ($MYSOCKET)                                               || die
>"CLO";
>}
>
>&GetPage ("www.microsoft.com", 80, "/");
>
># the error is NOT the website I am trying to retreive (I used 127.0.0.1 for
>testing)

Try 'use strict;'.  Ignoring that $x does not have an explicit package
(which does not matter if not using strict), I fail to see where you
define $MYSOCKET and so does Perl:

Can't use an undefined value as a symbol reference at ./mytest line 12.

If you dump the "$" from MYSOCKET, and unbuffer it, then you find out that
yor request is invalid.  You also need a Host header to access virtual
hosts. Rather than piece through the script, this works:

#!/usr/bin/perl -w
use strict;
use Socket;

sub GetPage ($, $, $) {
    my ($server, $port, $addr) = @_;
    my $ip = inet_aton ($server);
    my $sin = sockaddr_in ($port, $ip);
    my $proto = getprotobyname ("tcp");
    socket (MYSOCKET, PF_INET, SOCK_STREAM, $proto) || die "SOC";
    connect (MYSOCKET, $sin) || die "CON";
    select MYSOCKET; $| = 1; select STDOUT;
    print MYSOCKET "GET $addr HTTP/1.0\015\012",
        "Host: $server\015\012\015\012";
    while (defined ($_ = <MYSOCKET>)) {
        print;
    }
    close (MYSOCKET) || die "CLO";
}

# &GetPage ("www.microsoft.com", 80, "/");
&GetPage ("localhost", 80, "/");


-- 
David Efflandt  efflandt@xnet.com  http://www.de-srv.com/
http://www.autox.chicago.il.us/  http://www.berniesfloral.net/
http://hammer.prohosting.com/~cgi-wiz/  http://cgi-help.virtualave.net/



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

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

| NOTE: The mail to news gateway, and thus the ability to submit articles
| through this service to the newsgroup, has been removed. I do not have
| time to individually vet each article to make sure that someone isn't
| abusing the service, and I no longer have any desire to waste my time
| dealing with the campus admins when some fool complains to them about an
| article that has come through the gateway instead of complaining
| to the source.

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.

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 V9 Issue 4216
**************************************


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