[19115] in Perl-Users-Digest

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

Perl-Users Digest, Issue: 1310 Volume: 10

daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Mon Jul 16 06:05:41 2001

Date: Mon, 16 Jul 2001 03:05:11 -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: <995277911-v10-i1310@ruby.oce.orst.edu>
Content-Type: text

Perl-Users Digest           Mon, 16 Jul 2001     Volume: 10 Number: 1310

Today's topics:
    Re: Assigning RegEx to variables <monty@primenet.com>
    Re: Can I <!--include files ??? <godzilla@stomp.stomp.tokyo>
    Re: Can I <!--include files ??? (el)
    Re: chomp (derelixir)
    Re: Correct way to open a .jpg image and save? <goldbb2@earthlink.net>
        DAT file text string search and output <genzano@hotmail.com>
    Re: DAT file text string search and output nobull@mail.com
        FAQ: Is there a ctags for Perl? <faq@denver.pm.org>
    Re: file comparison problem (Rafael Garcia-Suarez)
    Re: file comparison problem <andrew@mvt.ie>
    Re: How to delete a block of comment? (Steven Smolinski)
    Re: How to delete a block of comment? <ron@savage.net.au>
    Re: How to delete a block of comment? <andrew@mvt.ie>
    Re: How to run Perl on MS-DOS <jimstad@cyberway.com.sg>
    Re: How to run Perl on MS-DOS (Scott Porter)
    Re: How to run Perl on MS-DOS <bart.lateur@skynet.be>
    Re: How to run Perl on MS-DOS <stumo@bigfoot.com>
    Re: How to stop the scrolling when I open a large text  (Scott Porter)
    Re: How to timeout a socket recv under win32? <goldbb2@earthlink.net>
    Re: How to timeout a socket recv under win32? <skilchen@swissonline.ch>
    Re: Locale error when starting Perl <jean_christian@hotmail.com>
        Looking for the right direction <npeles@bigpond.net.au>
    Re: Looking for Usenet-->HTML script andrew@daviel.org
    Re: Looking for Usenet-->HTML script <wyzelli@yahoo.com>
    Re: problem with @INC (Rafael Garcia-Suarez)
    Re: replace a return with <br> <ron@savage.net.au>
    Re: replace a return with <br> (el)
    Re: simple question <wyzelli@yahoo.com>
    Re: simple question <wyzelli@yahoo.com>
    Re: simple question <wyzelli@yahoo.com>
    Re: Urgent Sendmail problem! (Rafael Garcia-Suarez)
    Re: Urgent Sendmail problem! nobull@mail.com
    Re: Why is socket timeout not working? (Villy Kruse)
        windows script components <Dieter.ollinger@uni-konstanz.de>
        Digest Administrivia (Last modified: 6 Apr 01) (Perl-Users-Digest Admin)

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

Date: 16 Jul 2001 02:36:44 GMT
From: Jim Monty <monty@primenet.com>
Subject: Re: Assigning RegEx to variables
Message-Id: <9itjvs$h8c$1@nnrp2.phx.gblx.net>

Tim Hammerquist <tim@vegeta.ath.cx> wrote:
> Dly <elylyd@hotmail.com> wrote:
> > I'm getting syntax errors when i try to assign a regular expression to
> > a variable.
> >
> > [snip]
>
> Try any of these. Should work:
>     "\.(htm|asp|html)\$"
>     '\.(htm|asp|html)$'
>     qr/\.(htm|asp|html)$/;

And consider this improved regular expression, too:

    qr/\.(?:html?|asp)$/;

-- 
Jim Monty
monty@primenet.com
Tempe, Arizona USA


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

Date: Sun, 15 Jul 2001 23:41:16 -0700
From: "Godzilla!" <godzilla@stomp.stomp.tokyo>
Subject: Re: Can I <!--include files ???
Message-Id: <3B528C8C.9BAE532D@stomp.stomp.tokyo>

Andras Malatinszky wrote:
 
> Godzilla! wrote:
> > Terry wrote:

(snipped)


> Am I making sense?

No.

> Is my writing clear?

No.

> Am I being helpful?

No.

> Have I understood the OP's question?

No.
 
> Am I assuming the OP is an idiot?

You are the OP and yes, you are an idiot.

> Am I being an asshole?

Absolutely. A real screamer, at that.

 
> Only if you can answer 'yes' to the first four questions and
> 'no' to the other two should you post here or anywhere else.

Must be Springtime For Hitler, old and new.


Godzilla!


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

Date: 16 Jul 2001 00:56:17 -0700
From: el@wilmington.net (el)
Subject: Re: Can I <!--include files ???
Message-Id: <58929d2c.0107152356.616f377e@posting.google.com>

"Terry" <dcs@ntlworld.com> wrote in message news:<Lo%37.39930$B56.8361138@news2-win.server.ntlworld.com>...
> Hi,
> 
> All of my 'standard' webpages are *.shtml using SSI. This is great in that I
> can have a standard template file for header, navigation menu and footer of
> my pages by using the
> 
> <!--include file="template.html"-->
> directive.
> I wanted to use the same templates for my cgi pages. Is there any way of
> doing this?
> 
> TIA
> 
> Terry


Terry,
Just call your script with 
<!--#include virtual="pathto/myscript.pl?key=value&key2=value"-->
and make sure the script can parse the information through 'GET'.
No biggie, I do it all over my site.
el


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

Date: 15 Jul 2001 20:34:47 -0700
From: derelixir@my-deja.com (derelixir)
Subject: Re: chomp
Message-Id: <fd50a1dc.0107151934.15fb39f7@posting.google.com>

> Please explain.
> 
> I think it is more likely that the problem is one of these:
> 
> 1) the lines are not terminated by "\n". remember that chomp uses the value
>    of $/.
> 
> 2) there is a print "$city\n" hidden in the '....' part of the loop
> 

Thank you for all the replies but I think  most probably the text file
that I'm reading from
is not terminated by "\n". This is because when I tested the same
script with other text file which looks like this:

A Famosa Golf Resort,MEL,MS,13,31,22,87,14,30,20,87,15,29,21,87,16,29,22,87,17,28,22,87,18,29,21,87^M
A Famosa Water World,MEL,MS,13,31,22,87,14,30,21,87,15,29,19,87,16,29,22,87,17,28,22,87,18,29,21,87^M
Aachen,,DL,13,16,12,69,14,20,12,87,15,17,11,87,16,20,11,87,17,19,10,87,18,17,12,87^M

the chomp works fine and it will print only the "87".
The problem is I'm not sure which character actually terminates my
line in this text file (without the "^M"):

A Famosa Golf Resort,,MS,15,30,21,87,16,29,23,87,17,29,21,87,18,27,21,87,19,29,22,87,20,27,22,87
A Famosa Water World,,MS,15,30,21,87,16,29,23,87,17,29,21,87,18,27,21,87,19,29,22,87,20,28,24,87
Aachen,,DL,15,19,9,87,16,18,9,87,17,21,14,87,18,18,13,87,19,17,14,82,20,20,15,87

I've already tried - $/="\r\n"; but it doesn't chomp as well.
Is there a way I could identify what character is actually used to
terminate line in my text file?
I'm using UNIX and reading the text file also from UNIX.

Thank you very much for your help.

Regards.


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

Date: Mon, 16 Jul 2001 00:52:04 -0400
From: Benjamin Goldberg <goldbb2@earthlink.net>
Subject: Re: Correct way to open a .jpg image and save?
Message-Id: <3B5272F4.F1B9FE71@earthlink.net>

Matt L. wrote:
> 
> Hi!
> 
> On a previous post I was advised not to open an image file like so:-
> 
> $file = param('file');
> open (SAVE, ">../images/$file") || die $!;
> while (<$file>) {
>     print SAVE $_;
> }

This code implies that "file" is from a file upload field.

You should just be able to do:
rename( $file, "../images/$file" ) or die $!;

There is no point in doing anything more complicated.

> But instead, I should use the function read(), I have the Perl
> cookbook which says to use this for fixed length records by doing
> this:-
> 
> until ( eof(FILE) )  {
>         read(FILE, $record, $recordsize) == $RECORDSIZE or die "short read\n";
>       @FIELDS = unpack($TEMPLATE, $record);
> }
> 
> Is this the right way to go about receiving my file from the html form and
> writing it to disk?

If you receive a file from an html form, it will already be written to
disk for you.  The thing you get when you do param('file') is both the
file's name, and it is a filehandle which you can read from.

The above code using read() is most certainly not the way to go about
reading or processing arbitrary-length files -- it's for what it says
it's for, processing data in fixed sized hunks.

> If so can anyone explain the syntax a little?

Ok:
> until ( eof(FILE) )  {

If we're not an the end of the file.

>         read(FILE, $record, $recordsize) == $RECORDSIZE or die "short read\n";

Read into the variable record *exactly* $recordsize bytes -- don't
give us fewer unless we reach the end of the file.  The return value
of read() is the number of bytes we actually got... so if we got
something other than what we asked for (since we're expecting (in this
example) for the file length to be an EXACT multple of $recordsize), we
die.

>       @FIELDS = unpack($TEMPLATE, $record);

Using the given template, turn all of the fields in the record into
values we can use.  $TEMPLATE presumably contains a pack/unpack template
which specifies a fixed length record.

> }

> If it is not the right way, what is?

Either rename (as in my first suggestion) or copy the file.  This can be
done with:

use File::Copy;

copy( $file, "../images/$file" ) or die $!;

Also, since rename() only works for things on the same device (it can't
move things from one disk to another, or one partition to another, etc),
you may want to use move(), also from the File::Copy module (if you do
want to move, not copy it).

Another way of copying the file would be the following:

open (SAVE, ">", "../images/$file") || die $!;
my $buffersize = max( (-s $file), (stat(_))[11] ) || (1<<10);
my $readcount;
while( $readcount = sysread( $file, $_, $buffersize ) ) {
	print SAVE; # default argument to print is $_
}
# if there was no error on reading, $readcount is 0 but defined.
# othewise, it will be undefined.
die $! unless defined $readcount;

In this code you can transparently replace sysread with read -- and
depending on your OS and filesystem, it may produce better or worse
performance.

Another way of doing the above is:
open (SAVE, ">", "../images/$file") || die $!;
local $/ = \ ( max( (-s $file), (stat(_))[11] ) || (1<<10) );
print SAVE while( <$file> );
die $! unless defined $_;

This is like using the example just before this but with read in place
of sysread.  Make sure that this is enclosed by a block, so that local
has a chance to reset $/ to the value it is supposed to have.

-- 
The longer a man is wrong, the surer he is that he's right.


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

Date: Mon, 16 Jul 2001 01:20:15 GMT
From: "CG" <genzano@hotmail.com>
Subject: DAT file text string search and output
Message-Id: <jjr47.8413$O81.3846703@typhoon1.gnilink.net>

I am very new to PERL and am vey interested in it's functionality.

I've seen a friend of mine cull the NT registries of multiple resources and
create a file that lists all the required keys on all servers.

I thought this was a great idea. I'd like to do the same for all servers
that run a particular AnitVirus app. The app has a .dat file that has the
number of the current pattern file in it. Whenever it's updated it changes
to reflect the new pattern #. I thought I'd be able to create a daily e-mail
that would present the Current Virus Definition of each Server Resource.

I want to be able to search every server and it's DEFINFO.DAT file (which is
down several levels from the root) and report back the CurDefs value of all
files which look like:

[DefDates]
CurDefs=20010710.056
LastDefs=20010709.054

Can PERL do all of this? If so i'd appreciate a few pointers.

Thank you so much for your time.

Chris




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

Date: 16 Jul 2001 08:42:18 +0100
From: nobull@mail.com
Subject: Re: DAT file text string search and output
Message-Id: <u97kx9ntpv.fsf@wcl-l.bham.ac.uk>

"CG" <genzano@hotmail.com> writes:

> I've seen a friend of mine cull the NT registries of multiple resources and
> create a file that lists all the required keys on all servers.
> 
> I thought this was a great idea. I'd like to do the same for all servers
> that run a particular AnitVirus app. The app has a .dat file that has the
> number of the current pattern file in it. Whenever it's updated it changes
> to reflect the new pattern #. I thought I'd be able to create a daily e-mail
> that would present the Current Virus Definition of each Server Resource.
> 
> I want to be able to search every server and it's DEFINFO.DAT file (which is
> down several levels from the root) and report back the CurDefs value of all
> files which look like:
> 
> [DefDates]
> CurDefs=20010710.056
> LastDefs=20010709.054
> 
> Can PERL do all of this? If so i'd appreciate a few pointers.

The Win32 modules contain calls to enumerate all servers in an NT
domain.

If you are logged in as a domain admin account you can, usually,
access all systems drives as "//$server/C\$" (or whatever).

The file structure you describe looks like the old windows .INI file
format.  There are modules on CPAN to parse those.

-- 
     \\   ( )
  .  _\\__[oo
 .__/  \\ /\@
 .  l___\\
  # ll  l\\
 ###LL  LL\\


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

Date: Mon, 16 Jul 2001 06:17:02 GMT
From: PerlFAQ Server <faq@denver.pm.org>
Subject: FAQ: Is there a ctags for Perl?
Message-Id: <yFv47.170$T3.191443968@news.frii.net>

This message is one of several periodic postings to comp.lang.perl.misc
intended to make it easier for perl programmers to find answers to
common questions. The core of this message represents an excerpt
from the documentation provided with every Standard Distribution of
Perl.

+
  Is there a ctags for Perl?

    There's a simple one at
    http://www.perl.com/CPAN/authors/id/TOMC/scripts/ptags.gz which may do
    the trick. And if not, it's easy to hack into what you want.

- 

Documents such as this have been called "Answers to Frequently
Asked Questions" or FAQ for short.  They represent an important
part of the Usenet tradition.  They serve to reduce the volume of
redundant traffic on a news group by providing quality answers to
questions that keep coming up.

If you are some how irritated by seeing these postings you are free
to ignore them or add the sender to your killfile.  If you find
errors or other problems with these postings please send corrections
or comments to the posting email address or to the maintainers as
directed in the perlfaq manual page.

Answers to questions about LOTS of stuff, mostly not related to
Perl, can be found by pointing your news client to

    news:news.answers

or to the many thousands of other useful Usenet news groups.

Note that the FAQ text posted by this server may have been modified
from that distributed in the stable Perl release.  It may have been
edited to reflect the additions, changes and corrections provided
by respondents, reviewers, and critics to previous postings of
these FAQ. Complete text of these FAQ are available on request.

The perlfaq manual page contains the following copyright notice.

  AUTHOR AND COPYRIGHT

    Copyright (c) 1997-1999 Tom Christiansen and Nathan
    Torkington.  All rights reserved.

This posting is provided in the hope that it will be useful but
does not represent a commitment or contract of any kind on the part
of the contributers, authors or their agents.

                                                           03.08
-- 
    This space intentionally left blank


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

Date: 16 Jul 2001 09:12:51 GMT
From: rgarciasuarez@free.fr (Rafael Garcia-Suarez)
Subject: Re: file comparison problem
Message-Id: <slrn9l5c1i.lq2.rgarciasuarez@rafael.kazibao.net>

GunneR top-replied in comp.lang.perl.misc:
} Looks like that might do the trick. But i'd like to know how to do it
} without a fancy module :)

Hey, Algorithm::Diff is anything but fancy. It's powerful and uses a
complex algorithm to generate the best report. It's similar to the Unix
program diff. Your algorithm fails when a line has been inserted or
removed in one of the input files. diff does not.

} Ive retooled the code and about half of it works. It prints out the
} lines that matched (yay!) but it doesnt print out the lines that do
} not match... :(
} 
} open(FILE1, "c:/perl/1.txt");
} open(FILE2, "c:/perl/2.txt");

You should check the return value of open(). Always. This should become
automatic.

} foreach $line (<FILE1>) {
} 	while ($line2, <FILE2>) {
} 		if ($line2 = $line) { #this works (prints matched)

Of course this works. This affects $line to $line2 and returns the
value. This will fail only if $line is '' or '0' (and this won't occur
because $line has a \n at the end).

} 		print "Found matching $line in file 2!\n"; 
} 		last;
} 		}
} 		elsif ($line2 != $line) { #doesnt work (never prints
} when lines are different)

!= is a numeric comparison operator.

If you had enabled warnings in your script, perl would have tell you
that : see :
  $ perl -lwe 'print 1 if "ab" == "cd"'
  Argument "cd" isn't numeric in numeric eq (==) at -e line 1.
  Argument "ab" isn't numeric in numeric eq (==) at -e line 1.
  1

To compare strings you should use the eq and ne operators, described in
the perlop manpage.

} 		print "$line not found in file 2\n";
} 		next;
} 		}
} 	}
} }

-- 
Rafael Garcia-Suarez / http://rgarciasuarez.free.fr/


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

Date: Mon, 16 Jul 2001 10:21:38 +0100
From: "Andrew" <andrew@mvt.ie>
Subject: Re: file comparison problem
Message-Id: <9iubnd$uhu$1@kermit.esat.net>

> if ($line2 = $line) { #this works (prints matched)
This is assigning the value of $line to $line2, not comparing them.  Since
it's an assignment, it will always work - and it will always seem to do what
you want, since $line2 will now be equal to $line.
You should use
   if ($line2 eq $line)

> elsif ($line2 != $line) { #doesnt work (never prints
In this case you are comparing $line2 to $line in a numerical context, not
as strings
Try
 if ($line2 ne $line1)

Andrew




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

Date: Mon, 16 Jul 2001 03:53:54 GMT
From: steven.smolinski@sympatico.ca (Steven Smolinski)
Subject: Re: How to delete a block of comment?
Message-Id: <mzt47.9481$304.863763@news20.bellglobal.com>

David Marshall <marshall@chezmarshall.com> wrote:
> 
> Probably the easiest thing to do will be to slurp the file and
> substitute comments with the empty string, such as
> 
> undef $/;
> ($_ = <>) =~ s[/\*.*?\*/][]gs;
> print;

Easy but incorrect.  This doesn't match C-style comments.  What will it
do with the following?

char *foo = "String /* literal"; /* bar */

There are other examples, some more pathological, some less, on which
the simple-minded regex above breaks.

You'd do better to read the FAQ (which discusses the exact regex
suggested above, and explains its deficiencies):

Found in /usr/share/perl/5.6.1/pod/perlfaq6.pod
       How do I use a regular expression to strip C style com-
       ments from a file?

Steve
-- 
Steven Smolinski => http://arbiter.ca/


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

Date: Mon, 16 Jul 2001 14:10:07 +1000
From: "Ron Savage" <ron@savage.net.au>
Subject: Re: How to delete a block of comment?
Message-Id: <yRt47.92368$Rr4.288962@ozemail.com.au>

There is a Perl program which parses  C++ header files. Perhaps it will do?

http://starship.python.net/crew/tbryan/PERCEPS/

--
Cheers
Ron Savage
ron@savage.net.au
http://savage.net.au/index.html





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

Date: Mon, 16 Jul 2001 10:38:20 +0100
From: "Andrew" <andrew@mvt.ie>
Subject: Re: How to delete a block of comment?
Message-Id: <9iucmo$v1u$1@kermit.esat.net>


"Lawrence Zhao" <lawrence_zhao@yahoo.com> wrote in message
news:20010715231101.13964.qmail@web13906.mail.yahoo.com...
> Gurus,
>
> I need your help on this.
>
> Suppose I have a file.
> -------------------------------
> /* I want to delete this line
> *  and this
> *  until this line*/
>
> printf("please help\n");   /* $$$ */
> -------------------------------
>
> I want to delete the comment blocks. However, when I
> see the comment on the same line with the statement, I
> want to just delete the comment and keep the
> statement.
>
If you check the FAQ, section 6 has a section titled "How do I use a regular
expression to strip C style comments from a file?"

Andrew




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

Date: Mon, 16 Jul 2001 09:59:14 +0800
From: "sam" <jimstad@cyberway.com.sg>
Subject: Re: How to run Perl on MS-DOS
Message-Id: <3b525980$1@news.starhub.net.sg>


Bart Lateur <bart.lateur@skynet.be> wrote in message
news:mp13lt0vs0t09v2qdq8fmkhv5tovvi0oou@4ax.com...
> sam wrote:
>
> >I have installed ActivePerl 5.6.1.628 MSI on Windows 98 from
> >http://aspn.activestate.com . After I opened MS-DOS and type in cd
> >C:\Perl.in. , it says invalid directory. Can anyone kindly help me on
this?
>
> So that directory doesn't exist. So where is your perl installed,
> anyway? And why do you want to chdir to there? Since the path to the
> perl binary is included in your path,

My Perl is installed in C:\Perl

> perl -V
>
> will work from within any directory.

When I type in "perl -V", MS-DOS does produce a list of information or
characteristics about my Perl.

> And you'll want to do
>
> perl script.pl

When I type in the above, it simply says "can't open perl script.pl: No such
file or directory". Can you kindly tell me how to run a simple Perl program
from MS-DOS?

Thanks




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

Date: Sun, 15 Jul 2001 21:59:54 GMT
From: scott@nospamthankx.javascript-games.org (Scott Porter)
Subject: Re: How to run Perl on MS-DOS
Message-Id: <3b5211a8.181348984@news.freeserve.co.uk>

On Sun, 15 Jul 2001 18:41:13 +0800, "sam" <jimstad@cyberway.com.sg> wrote:

>I have installed ActivePerl 5.6.1.628 MSI on Windows 98 from
>http://aspn.activestate.com . After I opened MS-DOS and type in cd
>C:\Perl.in. , it says invalid directory. Can anyone kindly help me on this?

This might sound silly, but you do realise you have to use the short (8+3) filenames
when moving between directories with cd? You can see the short names by using

dir /X

I hope this is right anyway - I only use NT5 and Linux, I've forgotten if Win98 is
the same as NT...



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

Date: Mon, 16 Jul 2001 07:55:27 GMT
From: Bart Lateur <bart.lateur@skynet.be>
Subject: Re: How to run Perl on MS-DOS
Message-Id: <bd75lts5tokgd0vd2a81278fgbo4biohcu@4ax.com>

sam wrote:

>> And you'll want to do
>>
>> perl script.pl
>
>When I type in the above, it simply says "can't open perl script.pl: No such
>file or directory". Can you kindly tell me how to run a simple Perl program
>from MS-DOS?

OK. "perl -V" works, so perl works. "script.pl" is the name I gave my
hypothetical script. Either give your script that name, or use the
actual name of the script if you gave it another name. If it contains
spaces, put it between quotes. So, assuming the name of your script is
"first script.pl" (without the quotes), chdir/cd to the directory is in,
and at the DOS prompt, type

	perl "first script.pl"

and it should run.

-- 
	Bart.


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

Date: Mon, 16 Jul 2001 09:40:10 +0100
From: "Stuart Moore" <stumo@bigfoot.com>
Subject: Re: How to run Perl on MS-DOS
Message-Id: <MKx47.48072$B56.10246080@news2-win.server.ntlworld.com>

Scott Porter <scott@nospamthankx.javascript-games.org> wrote in message
news:3b5211a8.181348984@news.freeserve.co.uk...
> This might sound silly, but you do realise you have to use the short (8+3)
filenames
> when moving between directories with cd? You can see the short names by using
>
> dir /X
>
> I hope this is right anyway - I only use NT5 and Linux, I've forgotten if
Win98 is
> the same as NT...

cd "\my documents\" works fine for me in 98




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

Date: Sun, 15 Jul 2001 22:02:01 GMT
From: scott@nospamthankx.javascript-games.org (Scott Porter)
Subject: Re: How to stop the scrolling when I open a large text file
Message-Id: <3b52128c.181577375@news.freeserve.co.uk>

On Mon, 16 Jul 2001 07:08:33 +0000, hzi@uol.com.br wrote:

>Hi-
>
>	I've read perlfaq5, but still don't get it (I didn't think it was clear for a newbie, sorry). 
>	I've also looked at the history of this n/group. I realise this is a common problem, 
>but I couldn't figure it out. I don't know how to use modules yet, maybe that's the problem
> if modules is the *only* soultion. But what about TMTOWTDI?
>	My problem is that I've got this huge word list. Whenever I open it, it scrolls out of sight. 
>I'd like to buffer it, in order to get the equivalent effect as in "ls -a|more" (GNU/Linux)
>	Here's my program:
>
>#! /usr/bin/perl -w
># open_wort
>
>open WORT, "/usr/local/deutsch/wort.txt" or die $!;
>
>my $lineno = 1;
>
>while (<WORT>) {
>        print $lineno++;
>        print ": $_";
>}
>
>print "This is the whole list!\n";
>
>
>	Any help?
>	Thank you very much.
>	Regards,
>	hzi
>

[me@myserver me]$ myPerlProgram | more



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

Date: Mon, 16 Jul 2001 00:08:19 -0400
From: Benjamin Goldberg <goldbb2@earthlink.net>
Subject: Re: How to timeout a socket recv under win32?
Message-Id: <3B5268B3.AA755992@earthlink.net>

Bart Lateur wrote:
> 
> Benjamin Goldberg wrote:
> 
> >IO::Select is probably the easiest way to go.
> 
> >if( $select->can_read( $timeout ) ) {
> >       my $sender = recv SOCKET, my $packet, 256, 0
> >               or die "recv failed: $!";
> 
> So you mean recv().

Umm, what do you mean by that comment?

-- 
The longer a man is wrong, the surer he is that he's right.


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

Date: Mon, 16 Jul 2001 10:17:07 +0200
From: "Samuel Kilchenmann" <skilchen@swissonline.ch>
Subject: Re: How to timeout a socket recv under win32?
Message-Id: <9iu81m$ku5ce$1@ID-13368.news.dfncis.de>

"Bart Lateur" <bart.lateur@skynet.be> schrieb im Newsbeitrag
news:k4r2ltchhp5sk0dd84m1d6j0so5lq7scu6@4ax.com...
> Benjamin Goldberg wrote:
>
> >IO::Select is probably the easiest way to go.
>
> >if( $select->can_read( $timeout ) ) {
> > my $sender = recv SOCKET, my $packet, 256, 0
> > or die "recv failed: $!";
>
> So you mean recv().
>
> So, next question: what's the difference between sysread() and recv()?

Not so long ago it was not uncommon that you had to install a TCP/IP
implementation as an add-on to the OS (e.g. on SysV systems before SysVR4).
In this case there are different systemcalls to read from a filehandle and
to read from a socket. recv() is the systemcall to read from sockets on such
systems. It was always a feature of very high-level languages to hide such
differences from the programmer. This is still true today: it might very
well be that sysread() on sockets is implemented in terms of calls to recv()
on some systems (e.g. Win32 systems).

> What are the similarities? Why are both available in perl?

The most prominent difference between read() and recv() is that recv() takes
an additional flags argument. Most often the recv() flags available are only
MSG_OOB and MSG_PEEK, but some TCP/IP implementations offer more flags (e.g.
to make a single recv() non-blocking (MSG_DONTWAIT) or to ensure that recv()
only returns after it received the requested number of bytes (MSG_WAITALL),
etc.)

The main reason to have both functions in Perl is a different one: Perls
recv() is implemented in terms of recvfrom() and this one can be used to
return information about the sender of a datagram received on an UDP socket.






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

Date: Mon, 16 Jul 2001 10:34:48 +0900
From: root <jean_christian@hotmail.com>
Subject: Re: Locale error when starting Perl
Message-Id: <3B5244B8.60D3C56D@hotmail.com>

Thanks for the reply! I have been posting to various mailing lists and
newsgroups for a few days now but no answer. Either this is a very basic
question and not worthy of an answer (I doubt it) or no one knows.

There is mention of this problem in the perldocs but the solutions offered
don't work.

I tried what you segguested but it didn't help. Here's the output of what I
did. If I misunderstood your solution or did it wrong please let me know.

Jc

[root@dev /root]# unset LANG
[root@dev /root]# echo $LANG

[root@dev /root]# /etc/rc.d/init.d/httpd start
Starting httpd: perl: warning: Setting locale failed.
perl: warning: Please check that your locale settings:
 LANGUAGE = (unset),
 LC_ALL = (unset),
 LANG = "en"
    are supported and installed on your system.
perl: warning: Falling back to the standard locale ("C").
perl: warning: Setting locale failed.
perl: warning: Please check that your locale settings:
 LANGUAGE = (unset),
 LC_ALL = (unset),
 LANG = "en"
    are supported and installed on your system.
perl: warning: Falling back to the standard locale ("C").
                                                           [FAILED]
[root@dev /root]#



>From: "Daniel A. Johnson" <ab496@chebucto.ns.ca>
>To: Jean-Christian Imbeault <jean_christian@hotmail.com>
>Subject: Re: Locale error when starting Perl
>Date: Sun, 15 Jul 2001 21:21:35 -0300 (ADT)
>
>
>Hello,
>
>I came across your posting in the comp.lang.perl.misc newsgroup. One way
>to get rid of the error message is to use command (from command line):
>
>unset LANG
>
>It would be better to fix things with locale yet this technique will get
>rid of the annoying error message when trying to do some work. Each reboot

>you would have to use the unset again.
>
>Sorry I don't have a better fix yet I have not explored locale much deeper

>than that. ;)
>
>- Dan
>
>----------------------------------------------------------------------------

>email     : booner@tkc.bilby.com
>Home Page : http://tkc.bilby.com/~booner/
>
>Voice Line : (902) 455-9677
>-----------------------------------------------------------------------------

>
>On Sun, 15 Jul 2001, Jean-Christian Imbeault wrote:
>
> > I'm trying to get my apache web server up and running but everytime I
> > try I
> > get a perl error about locale settings. I have tried a few things to
get
> > it
> > to work but none effective.
> >
> > I'm using RH7.1, and have setup japanese language support (japanese kb,

> > sometimes I input japanese) with the folowing Apache and Perl versions:

> >
> > Apache/1.3.19 (Unix)  (Red-Hat/Linux)
> >
> > Perl, v5.6.0 built for i386-linux
> >
> > This is the error message I get:
> >
> > [root@dev /root]# /etc/rc.d/init.d/httpd start
> > Starting httpd: perl: warning: Setting locale failed.
> > perl: warning: Please check that your locale settings:
> > LANGUAGE = (unset),
> > LC_ALL = (unset),
> > LANG = "en"
> >   are supported and installed on your system.
> > perl: warning: Falling back to the standard locale ("C").
> > perl: warning: Setting locale failed.
> > perl: warning: Please check that your locale settings:
> > LANGUAGE = (unset),
> > LC_ALL = (unset),
> > LANG = "en"
> >   are supported and installed on your system.
> > perl: warning: Falling back to the standard locale ("C").
> >                                                          [FAILED]
> > [root@dev /root]#
> >
> >
> > Thanks for the help!
> >
> > Jc
> >
> >
> >
>


> I'm trying to get my apache web server up and running but everytime I
> try I
> get a perl error about locale settings. I have tried a few things to get
> it
> to work but none effective.
>
> I'm using RH7.1, and have setup japanese language support (japanese kb,
> sometimes I input japanese) with the folowing Apache and Perl versions:
>
> Apache/1.3.19 (Unix)  (Red-Hat/Linux)
>
> Perl, v5.6.0 built for i386-linux
>
> This is the error message I get:
>
> [root@dev /root]# /etc/rc.d/init.d/httpd start
> Starting httpd: perl: warning: Setting locale failed.
> perl: warning: Please check that your locale settings:
> LANGUAGE = (unset),
> LC_ALL = (unset),
> LANG = "en"
>   are supported and installed on your system.
> perl: warning: Falling back to the standard locale ("C").
> perl: warning: Setting locale failed.
> perl: warning: Please check that your locale settings:
> LANGUAGE = (unset),
> LC_ALL = (unset),
> LANG = "en"
>   are supported and installed on your system.
> perl: warning: Falling back to the standard locale ("C").
>                                                          [FAILED]
> [root@dev /root]#
>
> Thanks for the help!
>
> Jc



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

Date: Mon, 16 Jul 2001 01:26:33 GMT
From: "Ruth" <npeles@bigpond.net.au>
Subject: Looking for the right direction
Message-Id: <dpr47.7550$Xr6.61852@news-server.bigpond.net.au>

I am new at using Tk, and I need to write a program that is basicly a text
editor to do xml-style tagging. I need to be able to open a file (eventually
mulitple files) and then right click and choose from a list of tags,
resulting in that tag being put around the highlighted word.
I have been working on it for a little while, but i feel a little like im
trying to reinvent the wheel on some issues, like general text editor
functions, like opening files and such forth.

Could anyone point me in the right direction, because while i know there are
editors out there like Gedi, that already have everything i need in them,
that i can look at, i am finding it hard to just find the peices i need to
fit together(as well as how to do so), so i can then work out what i need to
write from scratch.

Thanks,
B




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

Date: Mon, 16 Jul 2001 07:23:56 GMT
From: andrew@daviel.org
Subject: Re: Looking for Usenet-->HTML script
Message-Id: <gEw47.709283$166.14725317@news1.rdc1.bc.home.com>

In alt.html dot-comet <cometlinear@yahoo.com> wrote:
: Greetings all,

: I want to be able to include (and interact with) two or three actual
: Usenet newsgroups in my HTML documents.

: Does anyone know of a script that can do this?

This works in Netscape 

<a href="news:alt.html">alt.html</a>

<a href="news:150720011551264964%cometlinear@yahoo.com">30283377</a>
<a href="news://mynewsserver.com/150764%cometlinear@yahoo.com">30377</a>

I have a script that connects to NNTP and builds a message list in HTML
if you are interested; mail me.


-- 
Andrew Daviel      
http://huzizit.com - transferable ID for your stuff



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

Date: Mon, 16 Jul 2001 17:08:14 +0930
From: "Wyzelli" <wyzelli@yahoo.com>
Subject: Re: Looking for Usenet-->HTML script
Message-Id: <6Mw47.47$ER4.1558@vic.nntp.telstra.net>

"dot-comet" <cometlinear@yahoo.com> wrote in message
news:150720011551264964%cometlinear@yahoo.com...
> Greetings all,
>
> I want to be able to include (and interact with) two or three actual
> Usenet newsgroups in my HTML documents.
>
> Does anyone know of a script that can do this?

http://web.stonehenge.com/merlyn/WebTechniques/col62.html

Wyzelli
--
@x='074117115116032097110111116104101114032080101114108032104097099107101114
'=~/(...)/g;
print chr for @x;




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

Date: 16 Jul 2001 07:49:44 GMT
From: rgarciasuarez@free.fr (Rafael Garcia-Suarez)
Subject: Re: problem with @INC
Message-Id: <slrn9l575i.ld5.rgarciasuarez@rafael.kazibao.net>

Les Ander wrote in comp.lang.perl.misc:
} Hi,
} I installed Net:ssh module and unfotunately it decided
} to upgrade my perl from 5.6 to 5.6.1.

You mean, it upgraded perl for you? I won't let a module decide this for
me.

} Now when ever i try to use
} a module that i had previously installed does'nt work anymore.
} For example, if i type perl -e 'use DBI;'
} it says...
} ---[~>> perl -e 'use DBI;'
} Can't locate DBI.pm in @INC (@INC contains:
} /usr/local/lib/perl5/5.6.1/i686-linux /usr/local/lib/perl5/5.6.1
} /usr/local/lib/perl5/site_perl/5.6.1/i686-linux
} /usr/local/lib/perl5/site_perl/5.6.1 /usr/local/lib/perl5/site_perl .) at
} -e line 1.
} BEGIN failed--compilation aborted at -e line 1.
} 
} but
} ---[~>> locate DBI.pm
} /usr/lib/perl5/site_perl/5.6.0/i386-linux/Bundle/DBI.pm
} /usr/lib/perl5/site_perl/5.6.0/i386-linux/DBI.pm
} /usr/lib/perl5/site_perl/DBI.pm
} 
} How can i add the /usr/lib/perl5/site_perl/5.6.0
} into my path? Is there another way to fix this?

One way to add the 5.6.0 lib directories is to define the PERL5LIB
environment variable (described in the perlrun manpage).

Alternatively, when perl 5.6.1 is installed from source, during the
configuration process, it asks you whether the 5.6.0 directories should
be included in the default builtin @INC. You may have missed this.

-- 
Rafael Garcia-Suarez / http://rgarciasuarez.free.fr/


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

Date: Mon, 16 Jul 2001 13:15:27 +1000
From: "Ron Savage" <ron@savage.net.au>
Subject: Re: replace a return with <br>
Message-Id: <j2t47.92354$Rr4.286857@ozemail.com.au>

Daniel

See below.

--
Cheers
Ron Savage
ron@savage.net.au
http://savage.net.au/index.html
AvA <a.v.a@home.nl> wrote in message news:3B5196CB.5AA28CF5@home.nl...
> Daniel van den Oord wrote:
>
> > I made a form with a text box..
> > I know now how to replace an single quote to a \' so it can be stored in a
> > database however I also like to know how an <return> can be replaced by a
> > <br> ?!?
> > Can anybody show me that.. Thanks !!!
>
> This is a commandline method:
>
> perl -p -i -e ' s/\n/<br>/g' somefile.pl

You actually want something a bit more reliable :-)

   if ($$meta_form{$_}{'meta_form_cgi_type'} eq 'textarea')
   {
    $$data{$_} =~ s/\r\n/<br>/g; # DOS aka Windows.
    $$data{$_} =~ s/\r/<br>/g;  # Macintosh.
    $$data{$_} =~ s/\n/<br>/g;  # Unix.
   }





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

Date: 16 Jul 2001 01:07:11 -0700
From: el@wilmington.net (el)
Subject: Re: replace a return with <br>
Message-Id: <58929d2c.0107160007.8662755@posting.google.com>

"Daniel van den Oord" <daniel304@planet.nl> wrote in message news:<9irqdg$130jr$1@reader01.wxs.nl>...
> I made a form with a text box..
> I know now how to replace an single quote to a \' so it can be stored in a
> database however I also like to know how an <return> can be replaced by a
> <br> ?!?
> Can anybody show me that.. Thanks !!!

Try this:
  $content =~ s/\%0D\%0A/<br \/>/g;  #XHTML version = <br />
  $content =~ s/\%0D\%0A/<br>/g;  #HTML version = <br>

Note: You might want to focus on using XHTML calls as HTML will become
obsolete with future browsers.
el


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

Date: Mon, 16 Jul 2001 15:03:01 +0930
From: "Wyzelli" <wyzelli@yahoo.com>
Subject: Re: simple question
Message-Id: <KWu47.39$ER4.1585@vic.nntp.telstra.net>

"James Warpup" <jwarpup1@home.com> wrote in message
news:dgm47.14543$JN6.3060759@news1.rdc1.mi.home.com...
> i need the print command to output "$variable"
>
> i can get it to output the variable, or ""$variable
> but i can't bet "$variable"
>
> here's the specific command I tried
>
> print "\"$variable\""
>
> what am i doing wron?
>

print "\"\$variable\"";

Wyzelli
--
($a,$b,$w,$t)=(' bottle',' of beer',' on the wall','Take one down, pass it
around');
for(reverse(1..100)){$s=($_!=1)?'s':'';$c.="$_$a$s$b$w\n$_$a$s$b\n$t\n";
$_--;$s=($_!=1)?'s':'';$c.="$_$a$s$b$w\n\n";}print"$c*hic*";





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

Date: Mon, 16 Jul 2001 15:04:26 +0930
From: "Wyzelli" <wyzelli@yahoo.com>
Subject: Re: simple question
Message-Id: <6Yu47.40$ER4.1577@vic.nntp.telstra.net>

"Wyzelli" <wyzelli@yahoo.com> wrote in message
news:KWu47.39$ER4.1585@vic.nntp.telstra.net...
> "James Warpup" <jwarpup1@home.com> wrote in message
> news:dgm47.14543$JN6.3060759@news1.rdc1.mi.home.com...
> > i need the print command to output "$variable"
> >
> > i can get it to output the variable, or ""$variable
> > but i can't bet "$variable"
> >
> > here's the specific command I tried
> >
> > print "\"$variable\""
> >
> > what am i doing wron?
> >
>
> print "\"\$variable\"";
>
print qq("\$variable\");

Wyzelli
--
($a,$b,$w,$t)=(' bottle',' of beer',' on the wall','Take one down, pass it
around');
$d='$_$a$s$b$w';$e='$_$a$s$b';sub d{$h=shift;$h=~s/\$(\w+)/${$1}/g;return$h}
sub
e{return(shift!=1)?'s':''}for(reverse(1..100)){$s=e($_);$f=d($d);$g=d($e);
$c.="$f\n$g\n$t\n";$_--;$s=e($_);$e=d($d);$c.="$e\n\n";}print"$c*hic*";





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

Date: Mon, 16 Jul 2001 15:05:43 +0930
From: "Wyzelli" <wyzelli@yahoo.com>
Subject: Re: simple question
Message-Id: <gZu47.41$ER4.1178@vic.nntp.telstra.net>

"Wyzelli" <wyzelli@yahoo.com> wrote in message
news:6Yu47.40$ER4.1577@vic.nntp.telstra.net...
> "Wyzelli" <wyzelli@yahoo.com> wrote in message
> news:KWu47.39$ER4.1585@vic.nntp.telstra.net...
> > "James Warpup" <jwarpup1@home.com> wrote in message
> > news:dgm47.14543$JN6.3060759@news1.rdc1.mi.home.com...
> > > i need the print command to output "$variable"
> > >
> > > i can get it to output the variable, or ""$variable
> > > but i can't bet "$variable"
> > >
> > > here's the specific command I tried
> > >
> > > print "\"$variable\""
> > >
> > > what am i doing wron?
> > >
> >
> > print "\"\$variable\"";
> >
> print qq("\$variable\");

print qq("\$variable");

Doh!

Wyzelli
--
#Modified from the original by Jim Menard
for(reverse(1..100)){$s=($_!=1)? 's':'';print"$_ bottle$s of beer on the
wall,\n";
print"$_ bottle$s of beer,\nTake one down, pass it around,\n";
$_--;$s=($_==1)?'':'s';print"$_ bottle$s of beer on the
wall\n\n";}print'*burp*';





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

Date: 16 Jul 2001 08:14:05 GMT
From: rgarciasuarez@free.fr (Rafael Garcia-Suarez)
Subject: Re: Urgent Sendmail problem!
Message-Id: <slrn9l58it.lhb.rgarciasuarez@rafael.kazibao.net>

Steinhaugs Webdesign wrote in comp.lang.perl.misc:
} Hello, I must ask - are there some error in the way I do this ?
} 
} sub SendMail {
}   #Usage: GUISendMail(ToName, ToNameEmail, FromName, FromNameEmail, Subject,
} Message);
}   ($toname, $tonamemail, $fromname, $fromnameemail, $subject, $message) =
} @_;

You're not using strict ? This is not considered a good habit.

}  open (MAIL, "| $mailprog -t");

You should always check the return value of your system calls.
$mailprog is sendmail, I suppose ? You should also put -oi in the
headers.

}   print MAIL "To: \"$tonamemail\" ($toname)\n";
}   print MAIL "From: \"$fromnamemail\" ($fromname)\n";
}   print MAIL "Subject: $subject\n";
}   print MAIL "Date: $DateAndTime -0700\n";            # Configured date from
} a subroutine
} 
}   print MAIL "MIME-Version: 1.0\n";
}   print MAIL "Content-type: text/html; charset\=\"iso-8859-1\"\n";
}   print MAIL "X-Priority: 3 (Normal)\n";
}   print MAIL "X-MSMail-Priority: Normal\n";
}   print MAIL "Importance: Normal\n";
                                 ^^^^
There's a \n missing here to seperate headers from body.

}   print MAIL "$message";                                            # The
} accual mail, starting with <html>.....</html>
}  close MAIL;

You should check the return value of close when writing to a pipe.

Additionally, check the perl FAQ with "perldoc -q 'send mail'" or by
looking into the perlfaq9 man page "How do I send mail?"

I think also that you should use a specific module, such as MIME::Lite,
to generate MIME mail. MIME::Lite also handles sendmail. It's probably
better than re-implementing the whole process.

-- 
Rafael Garcia-Suarez / http://rgarciasuarez.free.fr/


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

Date: 15 Jul 2001 21:24:18 +0100
From: nobull@mail.com
Subject: Re: Urgent Sendmail problem!
Message-Id: <u9ae25nu8k.fsf@wcl-l.bham.ac.uk>

"Steinhaugs Webdesign" <firma@steinhaug.com> writes:

> Newsgroups: comp.lang.perl.misc
> Subject: Re: Urgent Sendmail problem!

Er... (Perl != Sendmail) => off-topic.
Er... "Urgent" == "Please Ignore" (by convention).
Er... "Problem" == "".

So, your headers will be read as "Please ignore, off-topic".

>                ...there seems to be problems with adressing the
> "to" with the sendmail, since I get the mail sendt
> to the owner of the "directory" of the server,

This is probably a policy enforcement matter to avoid the server being
abused by spammers.  Speak to your sysadmin to find out how, if at all,
you can obtain authorisation to send mail to people other than yourself.

-- 
     \\   ( )
  .  _\\__[oo
 .__/  \\ /\@
 .  l___\\
  # ll  l\\
 ###LL  LL\\


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

Date: 16 Jul 2001 07:48:05 GMT
From: vek@pharmnl.ohout.pharmapartners.nl (Villy Kruse)
Subject: Re: Why is socket timeout not working?
Message-Id: <slrn9l571l.2b7.vek@pharmnl.ohout.pharmapartners.nl>

On 14 Jul 2001 13:42:30 +0100,
    nobull@mail.com <nobull@mail.com> wrote:


>"Haim Lichaa" <haim.lichaa@intel.com> writes:
>
>> I'm using this perl snipit on a Solaris 2.51 box running Perl 5.00403
>> 
>> my($s)=IO::Socket::INET->new(
>>   PeerAddr        => $host,
>>   PeerPort        => $port,
>>   Proto           =>'tcp',
>>   Type            => SOCK_STREAM,
>>   Timeout         => $to);
>> 
>> and any $to value has no affect on the Timeout. It remains constat @ ~4mins.
>> Any body know why and how I can fix it?
>
>I vaguely recall that the version of IO::Socket::INET that shipped
>with 5.00403 didn't implement timouts properly.
>
>Are you sure that it's the socket connect that's timing out not the
>name lookup?
>



On Solaris, this is easy to find out using the truss command.



Villy


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

Date: Mon, 16 Jul 2001 10:59:18 +0200
From: "Dieter Ollinger" <Dieter.ollinger@uni-konstanz.de>
Subject: windows script components
Message-Id: <3b52ad88.0@news.uni-konstanz.de>

I installed perl 5.6.1 from active state (built for MSWin32-x86-multi-thread
(with 1 registered patch))  on  a windows 2000 machine and tried to register
"first.wsc" as discribed in the "readme.txt". As result I get an error
message "[28,9] Der Wert des Attributs is ungueltig. :language". It seems
that perlscript is not an allowed script language on this machine. Can
somebody give me a hint how to configure the system so that I can register
"first.wsc".




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

Date: 6 Apr 2001 21:33:47 GMT (Last modified)
From: Perl-Users-Request@ruby.oce.orst.edu (Perl-Users-Digest Admin) 
Subject: Digest Administrivia (Last modified: 6 Apr 01)
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.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 V10 Issue 1310
***************************************


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