[19113] in Perl-Users-Digest

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

Perl-Users Digest, Issue: 1308 Volume: 10

daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Sun Jul 15 14:05:36 2001

Date: Sun, 15 Jul 2001 11:05:08 -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: <995220308-v10-i1308@ruby.oce.orst.edu>
Content-Type: text

Perl-Users Digest           Sun, 15 Jul 2001     Volume: 10 Number: 1308

Today's topics:
    Re: Can I <!--include files ??? <andras@mortgagestats.com>
    Re: Can I <!--include files ??? <dcs@ntlworld.com>
    Re: chomp <bart.lateur@skynet.be>
    Re: chomp (el)
    Re: chomp (el)
    Re: chomp <gnarinn@hotmail.com>
    Re: chomp (remove the obvious)
        FAQ: How do I profile my Perl programs? <faq@denver.pm.org>
    Re: HELP! - Input text field problems! (el)
    Re: HELP! - Input text field problems! <firma@steinhaug.com>
    Re: HELP! - Input text field problems! <uri@sysarch.com>
        How to run Perl on MS-DOS <jimstad@cyberway.com.sg>
    Re: How to run Perl on MS-DOS <bart.lateur@skynet.be>
    Re: How to timeout a socket recv under win32? <bart.lateur@skynet.be>
    Re: How to timeout a socket recv under win32? nobull@mail.com
        Including flock in code while developing in Windows for <miscellaneousemail@yahoo.com>
    Re: inline average <bigrich318@yahoo.com>
        Locale error when starting Perl <jean_christian@hotmail.com>
    Re: LWP::Protocol::http - what are the hidden Windows r <kevin@vaildc.net>
    Re: pass data from .exe to .perl <jnurick@zdnetonebox.com>
    Re: Perl/Sendmail not sending mail? (el)
    Re: Regex question <stephh@nospam.com>
        replace a return with <br> <daniel304@planet.nl>
    Re: replace a return with <br> <a.v.a@home.nl>
    Re: Setting Return-Path in sendmail from Perl (el)
        Urgent Sendmail problem! <firma@steinhaug.com>
    Re: Using a variable in a regular expression (Pete)
    Re: Using a variable in a regular expression <uri@sysarch.com>
        Digest Administrivia (Last modified: 6 Apr 01) (Perl-Users-Digest Admin)

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

Date: Sun, 15 Jul 2001 13:14:53 -0400
From: Andras Malatinszky <andras@mortgagestats.com>
Subject: Re: Can I <!--include files ???
Message-Id: <3B51CF8D.1828C39A@mortgagestats.com>



"Godzilla!" wrote:

> Terry wrote:
>
> > 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...
>
> This is untrue. You cannot include one file and
> create both a header and a footer with whatever
> included between those two. A Server Side Include
> call opens and prints an entire file. It is quite
> impossible for you to split this SSI called file
> and insert other html, within, much less some
> navigation menu tossed in to boot.

Nonsense, Godzilla! He could, for example define three layers in that
single SSI-called file. The first layer could have his header, the
second layer could have his navigation bar and the third layer could
have his footer. He could position his header, navigation bar and footer
at the top, middle and bottom of his page. Then, any additional HTML
could appear between the header and the footer and around the navigation
bar.

Of course, what the OP was implying is that he has three distinct
included files, but since you so often have difficulty producing legible
English prose in your postings, I am not surprised that you have a hard
time understanding other people's writing.

>
>
>
> > <!--include file="template.html"-->
> > directive.
>
> > I wanted to use the same templates for my cgi pages.
>
> You are now indicating multiple templates where previously
> a single template is indicated. Are you confused?

Apparently, the only one confused here is you.

>
>
> > Is there any way of doing this?
>
> Read about and research open () and print () functions.

What these two functions have to do with the OP's question is beyond me.
Maybe you could explain.

>
>
> What you ask is quite easy.
>
> Godzilla!

Once again, I advise you to read what you have written before you
inflict your nonsensical thoughts on others. Ask yourself these
questions:

Am I making sense?
Is my writing clear?
Am I being helpful?
Have I understood the OP's question?

Also, consider these questions:

Am I assuming the OP is an idiot?
Am I being an asshole?

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





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

Date: Sun, 15 Jul 2001 18:32:17 +0100
From: "Terry" <dcs@ntlworld.com>
Subject: Re: Can I <!--include files ???
Message-Id: <nrk47.33088$WS4.5286481@news6-win.server.ntlworld.com>

Hi Andras

"Andras Malatinszky" <andras@mortgagestats.com> wrote in message
news:3B51CF8D.1828C39A@mortgagestats.com...
>
>
> "Godzilla!" wrote:
>
> > Terry wrote:
> >
> > > 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...
> >
> > This is untrue. You cannot include one file and
> > create both a header and a footer with whatever
> > included between those two. A Server Side Include
> > call opens and prints an entire file. It is quite
> > impossible for you to split this SSI called file
> > and insert other html, within, much less some
> > navigation menu tossed in to boot.
>
> Nonsense, Godzilla! He could, for example define three layers in that
> single SSI-called file. The first layer could have his header, the
> second layer could have his navigation bar and the third layer could
> have his footer. He could position his header, navigation bar and footer
> at the top, middle and bottom of his page. Then, any additional HTML
> could appear between the header and the footer and around the navigation
> bar.
>
> Of course, what the OP was implying is that he has three distinct
> included files, but since you so often have difficulty producing legible
> English prose in your postings, I am not surprised that you have a hard
> time understanding other people's writing.
>

Thanks for that :)
My thoughts exactly :)

> >
> >
> >
> > > <!--include file="template.html"-->
> > > directive.
> >
> > > I wanted to use the same templates for my cgi pages.
> >
> > You are now indicating multiple templates where previously
> > a single template is indicated. Are you confused?
>
> Apparently, the only one confused here is you.
>
> >
> >
> > > Is there any way of doing this?
> >
> > Read about and research open () and print () functions.
>
> What these two functions have to do with the OP's question is beyond me.
> Maybe you could explain.
>

I'm afraid I have to jump to Godzilla's defence here ¿

What he is implying is that I open() the file I want to <include> and then
use a loop to print() the text from the file. Unfortunately, as far as I can
see, this is the only way to get around what I'm trying to do. Which in
effect means that I can't do it, since any variables I wanted to pass to the
include won't be passed when the <include> file is written in this manner :(

> >
> >
> > What you ask is quite easy.
> >
> > Godzilla!
>
> Once again, I advise you to read what you have written before you
> inflict your nonsensical thoughts on others. Ask yourself these
> questions:
>
> Am I making sense?
> Is my writing clear?
> Am I being helpful?
> Have I understood the OP's question?
>
> Also, consider these questions:
>
> Am I assuming the OP is an idiot?
> Am I being an asshole?
>
> Only if you can answer 'yes' to the first four questions and 'no' to the
> other two should you post here or anywhere else.
>

I definately cannot improve on this pearl of wisdom

Thanks

Terry

>
>




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

Date: Sun, 15 Jul 2001 10:09:57 GMT
From: Bart Lateur <bart.lateur@skynet.be>
Subject: Re: chomp
Message-Id: <31r2ltc44a3fp5n0o0c77i5jbp2m35g1vl@4ax.com>

derelixir wrote:

>but the chomp doesnt chomp the new line. The
>'print "$data[23]\n";'
>will print  :
>87
>A Famosa Water World
>
>and not only the value of '87' which is the last element in that
>particular line..
>
>Can someone help me with this problem?

Perhaps your character between lines isn't a newline. Is this a native
file? Or are you reading a Mac file on PC/Unix, or vice versa?

-- 
	Bart.


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

Date: 15 Jul 2001 03:25:58 -0700
From: el@wilmington.net (el)
Subject: Re: chomp
Message-Id: <58929d2c.0107150225.5b5c8a78@posting.google.com>

derelixir@my-deja.com (derelixir) wrote in message news:<fd50a1dc.0107142116.7aac8574@posting.google.com>...
> Hello...
> 
> I have a text file which contains something 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
> 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
> 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
> 
> and I have a code to read the text file that looks like this:
> $/="\n"; 
> open (MY_FILE, "<$MY_FILE") || die "cannot read file $MY_FILE\n";
> 
> # Convert remaining CSV forecast data:
> while (<MY_FILE>) {
>     chomp;
>     ( $city, $state, $country, @data ) = split(/,/); 
>     $location = "$city,$state,$country";
>     print "$data[23]\n";  ## just to check the value
>     ....
>     ....
> 
> but the chomp doesnt chomp the new line. The
> 'print "$data[23]\n";'
> will print  :
> 87
> A Famosa Water World
> 
> and not only the value of '87' which is the last element in that
> particular line..
> 
> Can someone help me with this problem?
> 
> Thank you.
> 
> Regards


I see a couple of problems ... First, the first three elements of your
list do not appear to be "city, state, country" (so $location isn't
going to actually contain these items).  Second, it looks like you
need a "foreach" statement or a "if" condition in order to single out
the record that you are trying to gather data on.  That's why your
chomp doesn't look like it's working.  You are chomping the file, not
the line.  Maybe you could try something like:

 open (MY_FILE, "<$MY_FILE") || die "cannot read file $MY_FILE\n";
 @file = <MY_FILE>);
 close(MY_FILE);
 foreach $item(@file) {
   chomp;
   @data = split(/,/, $item);
   $location = "$data[0], $data[1], $data[2]";
   print "$data[23]\n";
 }
 
or

 open (MY_FILE, "<$MY_FILE") || die "cannot read file $MY_FILE\n";
 while (<MY_FILE>) {
   if (/something/) {
     chomp;
     @data = split(/,/);
     $location = "$data[0], $data[1], $data[2]";
   }
   print "$data[23]\n";
 }
 close(MY_FILE);

Hope that helps,
el


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

Date: 15 Jul 2001 03:29:27 -0700
From: el@wilmington.net (el)
Subject: Re: chomp
Message-Id: <58929d2c.0107150229.7d3f1ad1@posting.google.com>

derelixir@my-deja.com (derelixir) wrote in message news:<fd50a1dc.0107142116.7aac8574@posting.google.com>...

oops - I forgot to change $data[23] to $data[26] in my examples.
el


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

Date: Sun, 15 Jul 2001 15:46:59 +0000
From: gnari <gnarinn@hotmail.com>
Subject: Re: chomp
Message-Id: <995212019.214529905002564.gnarinn@hotmail.com>

In article <58929d2c.0107150225.5b5c8a78@posting.google.com>,
el <el@wilmington.net> wrote:
>derelixir@my-deja.com (derelixir) wrote in message news:<fd50a1dc.0107142116.7aac8574@posting.google.com>...
>> Hello...
>> 
>> I have a text file which contains something 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
>> 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
>> 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
>> 
>> and I have a code to read the text file that looks like this:
>> $/="\n"; 
>> open (MY_FILE, "<$MY_FILE") || die "cannot read file $MY_FILE\n";
>> 
>> # Convert remaining CSV forecast data:
>> while (<MY_FILE>) {
>>     chomp;
>>     ( $city, $state, $country, @data ) = split(/,/); 
>>     $location = "$city,$state,$country";
>>     print "$data[23]\n";  ## just to check the value
>>     ....
>>     ....
>> 
>> but the chomp doesnt chomp the new line. The
>> 'print "$data[23]\n";'
>> will print  :
>> 87
>> A Famosa Water World
>> 
>> and not only the value of '87' which is the last element in that
>> particular line..
>> 
>
> ...  Second, it looks like you
>need a "foreach" statement or a "if" condition in order to single out
>the record that you are trying to gather data on.  That's why your
>chomp doesn't look like it's working.  You are chomping the file, not
>the line.

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

gnari




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

Date: Sun, 15 Jul 2001 17:27:51 GMT
From: "--Rick" <no_trick@my-de(remove the obvious)ja.com>
Subject: Re: chomp
Message-Id: <rok47.37249$C81.3088922@bgtnsc04-news.ops.worldnet.att.net>


"gnari" <gnarinn@hotmail.com> wrote in message
news:995212019.214529905002564.gnarinn@hotmail.com...
| In article <58929d2c.0107150225.5b5c8a78@posting.google.com>,
| el <el@wilmington.net> wrote:
| >derelixir@my-deja.com (derelixir) wrote in message
news:<fd50a1dc.0107142116.7aac8574@posting.google.com>...
| >> Hello...
| >>
| >> I have a text file which contains something 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,8
7,18,29,21,87
| >> 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
| >>
Aachen,,DL,13,16,12,69,14,20,12,87,15,17,11,87,16,20,11,87,17,19,10,87,1
8,17,12,87
| >>
| >> and I have a code to read the text file that looks like this:
| >> $/="\n";
| >> open (MY_FILE, "<$MY_FILE") || die "cannot read file $MY_FILE\n";
| >>
| >> # Convert remaining CSV forecast data:
| >> while (<MY_FILE>) {
| >>     chomp;
| >>     ( $city, $state, $country, @data ) = split(/,/);
| >>     $location = "$city,$state,$country";
| >>     print "$data[23]\n";  ## just to check the value
| >>     ....
| >>     ....
| >>
| >> but the chomp doesnt chomp the new line. The
| >> 'print "$data[23]\n";'

You specify a new line in your print statement, replacing what you
'chomp'ed.  If there was a new line in that element the out put would
have a blank line, like this:

87

A Famosa Water World

| >> will print  :
| >> 87
| >> A Famosa Water World

 ... if I understand what I'm reading correctly.

--
--Rick





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

Date: Sun, 15 Jul 2001 12:17:01 GMT
From: PerlFAQ Server <faq@denver.pm.org>
Subject: FAQ: How do I profile my Perl programs?
Message-Id: <1Rf47.155$T3.188492800@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.

+
  How do I profile my Perl programs?

    You should get the Devel::DProf module from the standard distribution
    (or separately on CPAN) and also use Benchmark.pm from the standard
    distribution. The Benchmark module lets you time specific portions of
    your code, while Devel::DProf gives detailed breakdowns of where your
    code spends its time.

    Here's a sample use of Benchmark:

      use Benchmark;

      @junk = `cat /etc/motd`;
      $count = 10_000;

      timethese($count, {
                'map' => sub { my @a = @junk;
                               map { s/a/b/ } @a;
                               return @a
                             },
                'for' => sub { my @a = @junk;
                               local $_;
                               for (@a) { s/a/b/ };
                               return @a },
               });

    This is what it prints (on one machine--your results will be dependent
    on your hardware, operating system, and the load on your machine):

      Benchmark: timing 10000 iterations of for, map...
             for:  4 secs ( 3.97 usr  0.01 sys =  3.98 cpu)
             map:  6 secs ( 4.97 usr  0.00 sys =  4.97 cpu)

    Be aware that a good benchmark is very hard to write. It only tests the
    data you give it and proves little about the differing complexities of
    contrasting algorithms.

- 

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.05
-- 
    This space intentionally left blank


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

Date: 15 Jul 2001 03:39:46 -0700
From: el@wilmington.net (el)
Subject: Re: HELP! - Input text field problems!
Message-Id: <58929d2c.0107150239.12ae5795@posting.google.com>

"Steinhaugs Webdesign" <firma@steinhaug.com> wrote in message news:<k3347.8916$qR5.1007103@news01.chello.no>...
> ... its supposed
> to be a HTML mail, but after opening the text from
> the file it gets corrupted in some strange way I cant figure.
> 
> ...
> 
> An excerpt from the $message is :
> ----------------------------------
> ...
> Content-Type: text/plain;

I'm not positive, but I think you need to put a 'print "Content-Type:
text/html\n\n";' line between your mail header and body.
el


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

Date: Sun, 15 Jul 2001 12:52:22 GMT
From: "Steinhaugs Webdesign" <firma@steinhaug.com>
Subject: Re: HELP! - Input text field problems!
Message-Id: <amg47.8951$qR5.1014134@news01.chello.no>

Thanks for rour response,
you probably didnt get my question right, but I posted the sollution to my
problem in the followup thread from me.

Thanks for taking the time to look into my problem though.

Kim Steinhaug
kim@steinhaug.com
www.steinhaug.com


"el" <el@wilmington.net> wrote in message
news:58929d2c.0107150239.12ae5795@posting.google.com...
> "Steinhaugs Webdesign" <firma@steinhaug.com> wrote in message
news:<k3347.8916$qR5.1007103@news01.chello.no>...
> > ... its supposed
> > to be a HTML mail, but after opening the text from
> > the file it gets corrupted in some strange way I cant figure.
> >
> > ...
> >
> > An excerpt from the $message is :
> > ----------------------------------
> > ...
> > Content-Type: text/plain;
>
> I'm not positive, but I think you need to put a 'print "Content-Type:
> text/html\n\n";' line between your mail header and body.
> el




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

Date: Sun, 15 Jul 2001 16:15:15 GMT
From: Uri Guttman <uri@sysarch.com>
Subject: Re: HELP! - Input text field problems!
Message-Id: <x7bsmmw4mk.fsf@home.sysarch.com>

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


  SW> open (PROGRESSFILE, "data/message.log");

always check open calls for failure.

  SW>     @messageRAW = <PROGRESSFILE>;

why slurp in the file when you are processing it line by line?
  SW> close (PROGRESSFILE);

  SW> $messagetest = "";
  SW> foreach $line (@messageRAW) {

  SW>  chomp($line); # Remove \n \r \t and other linefeeds

that comment is extremely wrong. perldoc -f chomp will clear that up for
you.


  SW>  $messagetest .= "$line\n";

all you want is to join the lines with newline. much easier ways to do that.
search google for this as it is a common question.

uri

-- 
Uri Guttman  ---------  uri@sysarch.com  ----------  http://www.sysarch.com
SYStems ARCHitecture and Stem Development ------ http://www.stemsystems.com
Learn Advanced Object Oriented Perl from Damian Conway - Boston, July 10-11
Class and Registration info:     http://www.sysarch.com/perl/OOP_class.html


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

Date: Sun, 15 Jul 2001 18:41:13 +0800
From: "sam" <jimstad@cyberway.com.sg>
Subject: How to run Perl on MS-DOS
Message-Id: <3b518258$1@news.starhub.net.sg>

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?

Thanks





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

Date: Sun, 15 Jul 2001 12:07:58 GMT
From: Bart Lateur <bart.lateur@skynet.be>
Subject: Re: How to run Perl on MS-DOS
Message-Id: <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,

	perl -V

will work from within any directory. And you'll want to do

	perl script.pl

from within the directory your *script* is in, not your perl binary.

-- 
	Bart.


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

Date: Sun, 15 Jul 2001 10:13:04 GMT
From: Bart Lateur <bart.lateur@skynet.be>
Subject: Re: How to timeout a socket recv under win32?
Message-Id: <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()?
What are the similarities? Why are both available in perl?

-- 
	Bart.


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

Date: 15 Jul 2001 12:42:18 +0100
From: nobull@mail.com
Subject: Re: How to timeout a socket recv under win32?
Message-Id: <u9itgu1krp.fsf@wcl-l.bham.ac.uk>

Bart Lateur <bart.lateur@skynet.be> writes:

> 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()?

recv() can give you more information when reading from a socket.  For
example on UDP it tells you where the datagram came from.

> What are the similarities?

The simplest use of recv() is equivalent a sysread().

> Why are both available in perl?
 
IIRC recv() can't be used on non-socket file handles. (This is
probably not true of all OS).

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


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

Date: Sun, 15 Jul 2001 18:04:01 GMT
From: Carlos C. Gonzalez <miscellaneousemail@yahoo.com>
Subject: Including flock in code while developing in Windows for Unix??
Message-Id: <MPG.15bb885f37486b489896b4@news.edmonton.telusplanet.net>

Hi everyone,

I was wondering if anyone had any suggestions as to how to include 
flock() function calls in code that will eventually be uploaded to a Unix 
server (on which the flock() function is implemented) while developing 
that code in Windows.

It is kind of a pain to have to remember to change the code every time I 
upload it to Unix.  

Currently I have a parameter flag that I set to either WIN or UNIX and 
within an open file wrapper function I either call flock() or not 
depending on whether the flag is WIN or UNIX.  

But this is still a pain because I have to remember to change the value 
of the parameter when I upload to UNIX.  

My open file wrapper function is called in various files and changing the 
value of the flag is becoming more and more cumbersome.  

Is there no way to call flock() from code in such a way that Perl 
automatically ignores this call if called from Windows and executes it if 
called from Unix??

Thanks.

-- 
Carlos 
www.internetsuccess.ca


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

Date: Sun, 15 Jul 2001 12:59:46 -0500
From: "Rich" <bigrich318@yahoo.com>
Subject: Re: inline average
Message-Id: <tl3mnodq3mb3cd@corp.supernews.com>


"Benjamin Goldberg" <goldbb2@earthlink.net> wrote in message news:3B50A731.1AE46030@earthlink.net...
> Rich wrote:
> >
> > "Benjamin Goldberg" <goldbb2@earthlink.net> wrote in message news:3B4CBAB6.D05F2E6D@earthlink.net...
> > <snip>
> > > Or possibly:
> > > tie $values{average}, "Average", \%values;
> > >
> > > This gives all the benefits of a tied scalar, without having to
> > > create another variable for it... and it's only one value that's
> > > tied, not the whole hash.
> >
> > You mean like in the example I gave on 7/1/01?
>
> Yup, just like that... except I don't see it on my newsserver.
<snip>

Too bad. If you were able to see the rest of the thread, all of your additional "why not" and "what if" questions would have been
answered and you would have seen that all the op wanted was to know if something was possible and his question was answered.

But don't let me stop you from taking simple answers to simple questions and expanding them into full-fledged tutorials if it makes
you feel good and you have that kind of time to waste. Who knows, maybe one or two people were impressed and you'll wind up with a
book deal from O'Reilly , "Pointless Usenet Code Analysis In A Nutshell" or possibly Wrox, "Professional Ego Stroking With Perl".

Good luck!

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

<<note to self: must come up with obtuse sig to show everyone how hip and cool I am>>


Rich






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

Date: Sun, 15 Jul 2001 13:57:28 GMT
From: Jean-Christian Imbeault <jean_christian@hotmail.com>
Subject: Locale error when starting Perl
Message-Id: <3B51A1A7.67749CF6@hotmail.com>

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: Sun, 15 Jul 2001 09:58:19 -0400
From: Kevin Michael Vail <kevin@vaildc.net>
Subject: Re: LWP::Protocol::http - what are the hidden Windows requirements ?
Message-Id: <150720010958192299%kevin@vaildc.net>

In article <5a10590e.0107142039.6eb22ec9@posting.google.com>, Mike
<michael_of_neb@yahoo.com> wrote:

[snip]

> In the process of attempting to install the openssl systems,
> so that I can use perl to open a rather simple httpS page
> and enter some rather simple infformation into its form...
> 
> I have crashed my entire perl engine.  Bummer.
> 
> I have traced the problem down to the line:
> 
>         eval "require $ic";
> 
> where this translates to: 
> 
>     require LWP::Protocol::http
> 
> which immediately gives Windows the system Perl box error 
> with the blue top border and the red circle with the white x in it, 
> and the buttons on the right titled close, debug and details.

The problem *could* be that the import method of LWP::Protocol::http
isn't being called.  Try changing your code to the following and see
what happens:

    eval {
        require LWP::Protocol::http;
        LWP::Protocol::http->import;
    };

and see what happens.  This is basically what happens when you "use" a
module.  If LWP::Protocol::http is a module with C code that has to be
loaded, and you don't load it, you'll get the error you saw.

-- 
Kevin Michael Vail | a billion stars go spinning through the night,
kevin@vaildc.net   | blazing high above your head.
 . . . . . . . . .  | But _in_ you is the presence that
 . . . . . . . . . | will be, when all the stars are dead.  (Rainer Maria Rilke)


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

Date: Sun, 15 Jul 2001 16:37:30 +0100
From: John Nurick <jnurick@zdnetonebox.com>
Subject: Re: pass data from .exe to .perl
Message-Id: <lkf2lt82eqnf21blt04f71jkkjsfu7ncqr@4ax.com>

On Tue, 3 Jul 2001 13:03:21 +0800, "dom" <same@make-it-online.com>
wrote:

>Is there anyway pass a block of data from .exe to .perl without using stdio
>or write to file?

If ".exe" implies Win32, then how about Win32::Clipboard?

--
With best wishes
John

Please reply to the newsgroup and not by e-mail.


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

Date: 15 Jul 2001 05:04:25 -0700
From: el@wilmington.net (el)
Subject: Re: Perl/Sendmail not sending mail?
Message-Id: <58929d2c.0107150404.580dcf14@posting.google.com>

el@wilmington.net (el) wrote in message news:<58929d2c.0107110117.793c7e02@posting.google.com>...

>   open(EMAIL, "|$mailprog $email") || &error("Sendmail error: $!");

It's fixed!  I saw another post suggesting that the user should use:
 open(EMAIL, "|$mailprog -f$me -t") || &error("Sendmail error: $!");
So ... I added the -f flag and,
 print EMAIL ".";
before my close(EMAIL) ...

Not sure which did it or if it was a combination of the two.  All I
know is that it is working.
Thank you (Raphael and Scott) for your help!
el <who's headache is melting away>


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

Date: Sun, 15 Jul 2001 12:45:24 +0200
From: stephh <stephh@nospam.com>
Subject: Re: Regex question
Message-Id: <150720011245241825%stephh@nospam.com>

($match) = substr($s, 8) =~ /(\w+)/;
Cool!
Thanx

In article <3B510C93.3C62943F@earthlink.net>, Benjamin Goldberg
<goldbb2@earthlink.net> wrote:

> ($match) = substr($s, 8) =~ /(\w+)/;


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

Date: Sun, 15 Jul 2001 12:17:21 +0200
From: "Daniel van den Oord" <daniel304@planet.nl>
Subject: replace a return with <br>
Message-Id: <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 !!!




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

Date: Sun, 15 Jul 2001 13:00:58 GMT
From: AvA <a.v.a@home.nl>
Subject: Re: replace a return with <br>
Message-Id: <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



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

Date: 15 Jul 2001 04:56:44 -0700
From: el@wilmington.net (el)
Subject: Re: Setting Return-Path in sendmail from Perl
Message-Id: <58929d2c.0107150356.3ae0d872@posting.google.com>

mallet.I_Kill_Spammers@cluestick.org (Suresh Ramasubramanian) wrote in message news:<9grub8$8vq1t$4@ID-40468.news.dfncis.de>...

> As I said, use sendmail -f in your script to set the envelope from.
> 
> >>> I am hoping to do something like this:
> >>>     open(MAIL,"|$mailprog -t");
> 
> open(MAIL,"|$mailprog -f$bounce_alias -t");
> 
> >>>     print MAIL "Return-Path: $bounce_alias\n";
> 
> 	-suresh

Thank you, thank you, thank you!
If you hadn't spelled out this -f flag I wouldn't have solved my own
sendmail problem!
el


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

Date: Sun, 15 Jul 2001 10:08:50 GMT
From: "Steinhaugs Webdesign" <firma@steinhaug.com>
Subject: Urgent Sendmail problem!
Message-Id: <SYd47.8943$qR5.1012837@news01.chello.no>

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) =
@_;

 open (MAIL, "| $mailprog -t");
  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";
  print MAIL "$message";                                            # The
accual mail, starting with <html>.....</html>
 close MAIL;
}

This is to send HTML mail, but 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, meaning I get the ROOT
defined email.. ???
From what I see there arnt any errors here, but there has to be...

PLEASE HELP!

Kim Steinhaug
kim@steinhaug.com





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

Date: Sun, 15 Jul 2001 10:45:48 GMT
From: Peter@angeltec.fsnetNOTTHIS.co.uk (Pete)
Subject: Re: Using a variable in a regular expression
Message-Id: <3b5170ed.146989885@news.btinternet.com>

Thanks for info,

On Fri, 13 Jul 2001 16:32:22 GMT, Uri Guttman <uri@sysarch.com> wrote:

>  P> This system is perl 4 and says something about qr being a future
>  P> reserved word
>
>that is soemthing you must upgrade immediately. no one supports perl4
>anymore and too many correct answers you will get rely on perl5. you are
>just shooting yourself in the foot using perl4 now.

It's just what's installed here.  I could ask them to upgrade it but
the first question I'm likely to be asked is how it will impact on the
existing scripts - and I don't know at the moment.

Pete



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

Date: Sun, 15 Jul 2001 16:10:55 GMT
From: Uri Guttman <uri@sysarch.com>
Subject: Re: Using a variable in a regular expression
Message-Id: <x7elriw4tt.fsf@home.sysarch.com>

>>>>> "P" == Pete  <Peter@angeltec.fsnetNOTTHIS.co.uk> writes:

  P> On Fri, 13 Jul 2001 16:32:22 GMT, Uri Guttman <uri@sysarch.com> wrote:

  P> This system is perl 4 and says something about qr being a future
  P> reserved word
  >> 
  >> that is soemthing you must upgrade immediately. no one supports perl4
  >> anymore and too many correct answers you will get rely on perl5. you are
  >> just shooting yourself in the foot using perl4 now.

  P> It's just what's installed here.  I could ask them to upgrade it but
  P> the first question I'm likely to be asked is how it will impact on the
  P> existing scripts - and I don't know at the moment.

so who is such a neandethal site that perl4 is the standard? it is 7
years dead already.

there is a perltraps page which (should still) have the list of common
issues of converting perl4 to perl5. there are very few critical ones
and most perl4 programs run cleanly under perl5. those that don't can
usually be corrected quickly. so there is no earthly reason to keep
perl4 around.

uri

-- 
Uri Guttman  ---------  uri@sysarch.com  ----------  http://www.sysarch.com
SYStems ARCHitecture and Stem Development ------ http://www.stemsystems.com
Learn Advanced Object Oriented Perl from Damian Conway - Boston, July 10-11
Class and Registration info:     http://www.sysarch.com/perl/OOP_class.html


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

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


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