[19162] in Perl-Users-Digest

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

Perl-Users Digest, Issue: 1357 Volume: 10

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

Date: Mon, 23 Jul 2001 03:05:10 -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: <995882710-v10-i1357@ruby.oce.orst.edu>
Content-Type: text

Perl-Users Digest           Mon, 23 Jul 2001     Volume: 10 Number: 1357

Today's topics:
        cant perl get better??? <patelnavin@icenet.net>
        cant perl get better??? <patelnavin@icenet.net>
        converting numeric-string to integer doesn't work for m <benghua@NOSPAM.cyberworks.net.sg>
    Re: creating another file <andras@mortgagestats.com>
    Re: Deciphering Carp::carp message <andras@mortgagestats.com>
    Re: Deciphering Carp::carp message <nospam-abuse@ilyaz.org>
        FAQ: How do I convert bits into ints? <faq@denver.pm.org>
        getting users ip <cmicallef@playground.net>
    Re: Hashes tutorila <nowhere@dot.com>
        How to redirect a user ? <cvule@eunet.yu>
    Re: How to timeout a socket recv under win32? <goldbb2@earthlink.net>
    Re: I found sprintf - is there a sscanf? <uri@sysarch.com>
    Re: I found sprintf - is there a sscanf? (Villy Kruse)
    Re: Including a perl file into another perl file??? <nowhere@dot.com>
    Re: Including a perl file into another perl file??? (Eric Bohlman)
    Re: Including a perl file into another perl file??? <peb@bms.umist.ac.uk>
    Re: Including one perl file into another??? <andras@mortgagestats.com>
    Re: Including one perl file into another??? (Eric Bohlman)
        Newbie:Sometimes it works and sometimes it won't <J.B.O.M.Engbers@dlg.agro.nl>
    Re: perl regular expression grammar (Alan Oursland)
    Re: perl regular expression grammar <usenet11522@itz.pp.sci.fi>
        Remote updating of my website (Simon Marshall - SMA)
    Re: Removing .coms (David Combs)
    Re: Trouble extracting strings - help needed <goldbb2@earthlink.net>
    Re: use attributes; subs : lvalue { return $this->{anyv <ilya@martynov.org>
    Re: use attributes; subs : lvalue { return $this->{anyv <murat.uenalan@gmx.de>
    Re: Use Perl and Visual Basic together <pne-news-20010723@newton.digitalspace.net>
    Re: Use Perl and Visual Basic together <bart.lateur@skynet.be>
    Re: Use Perl and Visual Basic together <hafner-usenet@ze.tu-muenchen.de>
    Re: where is the "standard library" <pne-news-20010723@newton.digitalspace.net>
    Re: Who can help me about the confused (..) operator? <bart.lateur@skynet.be>
    Re: Yet another Perl Web Server <shashanka.sj@in.bosch.com>
        Digest Administrivia (Last modified: 6 Apr 01) (Perl-Users-Digest Admin)

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

Date: Mon, 23 Jul 2001 11:33:08 +0530
From: "Aman Patel" <patelnavin@icenet.net>
Subject: cant perl get better???
Message-Id: <9jgejk$nl08u$1@ID-93885.news.dfncis.de>

I was wanting the following features/capabilities in perl.

For CGI Environment:
- A totally re-defined lifecycle, somewhat like Fast::CGI but without any
limitations and seemless integration to exisiting source code. CGI Programme
doesnt loose any persistant data, just like java servlets.
- In-built capability of dealing with hash-file databases (use DB_File), but
no external module requirements. This is because some environments dont have
such modules. And its very hard to supply modules with your software (esp.
if your software is expected to run without any dependencies).

the first feature is what i want most, i dont know why i came up with the
2nd one, cause there are already plenty of modules out there.

But let me know what do you guys think, any let me know if such perl or
modules exist out there.




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

Date: Mon, 23 Jul 2001 11:33:08 +0530
From: "Aman Patel" <patelnavin@icenet.net>
Subject: cant perl get better???
Message-Id: <9jgek9$njvev$1@ID-93885.news.dfncis.de>

I was wanting the following features/capabilities in perl.

For CGI Environment:
- A totally re-defined lifecycle, somewhat like Fast::CGI but without any
limitations and seemless integration to exisiting source code. CGI Programme
doesnt loose any persistant data, just like java servlets.
- In-built capability of dealing with hash-file databases (use DB_File), but
no external module requirements. This is because some environments dont have
such modules. And its very hard to supply modules with your software (esp.
if your software is expected to run without any dependencies).

the first feature is what i want most, i dont know why i came up with the
2nd one, cause there are already plenty of modules out there.

But let me know what do you guys think, any let me know if such perl or
modules exist out there.




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

Date: Mon, 23 Jul 2001 14:33:33 +0800
From: "Beng" <benghua@NOSPAM.cyberworks.net.sg>
Subject: converting numeric-string to integer doesn't work for me... help!
Message-Id: <3b5bc55a@news>

Hi guys,

I am trying to write a perl script to crunch a series of BIG numbers from an
array, and then perform arithmetic operations on them. Those BIG numbers are
actually numeric-strings, and I need to convert these strings to integers
first before I do the summing operation.

Here's how my array (last 3 entries) looks like.... strings separated by a
space :

                    9908 10075 77039256.797 5454961145466
                    9914 17547 468315.61 7006666186844
                    9975 17547 1782359.41 26710406712277

I'm trying to convert the 3rd and 4th elements to integer. In my script, I
have the following :

                    for $newlist (@newlist) {
                            ($src_as, $des_as, $pkts, $bytes) = split(/
/,$newlist);
                            $pkts = int($pkts);
                            $bytes= int($bytes);
                            print"pkts = $pkts, bytes = $bytes\n";
                    }

Ad the output from the script is :

                    pkts = 77039, bytes = 5454961
                    pkts = 4683, bytes = 7006666
                    pkts = 17823, bytes = 26710406

Notice how the result got truncated??

Initially I thought it was because my numbers were too big. So I wrote the
following testing script :

                    $str = "17424473464653.72765";
                    $y = int($str);
                    print "Y = $y \n";
                    print "Y * 9999 = $y*9999 \n";

And the result was :

                    Y = 17424473464653
                    Y * 9999 = 17424473464653*9999

Running perfectly fine on the testing script.... something which I don't
understand why. Been thinking for days but still couldn't figure out what's
wrong.

Can anyone help me with this?? Or just give me some pointers to look into?

Sorry for the long posting.

Thanks for reading...




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

Date: Mon, 23 Jul 2001 01:36:02 -0400
From: Andras Malatinszky <andras@mortgagestats.com>
Subject: Re: creating another file
Message-Id: <3B5BB7C2.F8F6870A@mortgagestats.com>



Devon Perez wrote:

> how do i have perl create another file? i want it to create an html file...
> i use this code:
> open (FILEA,">$idnum.html");
> print FILEA "$test";
> close(FILEA);
>
> but it does not work, it doesnt create a new html file... please help

Is it possible your script  doesn't have the right permissions to create a
file? Do you have enough disk space?  At any rate, you'd know more if you had
checked the return value of the open. Do something like


open (FILEA,">$idnum.html") or print "Trouble: $!";

to see what goes wrong.



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

Date: Mon, 23 Jul 2001 01:45:40 -0400
From: Andras Malatinszky <andras@mortgagestats.com>
Subject: Re: Deciphering Carp::carp message
Message-Id: <3B5BBA04.396A9ACB@mortgagestats.com>



kj0 wrote:

> Carp::carp is giving me the error
>
>   myscript: Use of uninitialized value at (eval 13) line 17.
>
> even though myscript has no line 17.  What does this mean?  What does
> "(eval 13)" mean?
>
> Thanks,
>
> KJ

This would be a lot easier if you shared your script with us :-)



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

Date: Mon, 23 Jul 2001 05:57:52 +0000 (UTC)
From: Ilya Zakharevich <nospam-abuse@ilyaz.org>
Subject: Re: Deciphering Carp::carp message
Message-Id: <9jged0$1gmi$1@agate.berkeley.edu>

[A complimentary Cc of this posting was sent to
kj0 
<kj0@mailcity.com>], who wrote in article <9jfkt1$5nl$1@panix3.panix.com>:
> Carp::carp is giving me the error
> 
>   myscript: Use of uninitialized value at (eval 13) line 17.

Use croak() instead.  If this is not your code, there is a way to
globally up grade each carp() to a croak().

Ilya


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

Date: Mon, 23 Jul 2001 06:16:56 GMT
From: PerlFAQ Server <faq@denver.pm.org>
Subject: FAQ: How do I convert bits into ints?
Message-Id: <sjP67.35$T3.171417600@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 convert bits into ints?

    To turn a string of 1s and 0s like "10110110" into a scalar containing
    its binary value, use the pack() and unpack() functions (documented in
    the section on "pack" in the perlfunc manpage and the section on
    "unpack" in the perlfunc manpage):

        $decimal = unpack('c', pack('B8', '10110110'));

    This packs the string "10110110" into an eight bit binary structure.
    This is then unpacked as a character, which returns its ordinal value.

    This does the same thing:

        $decimal = ord(pack('B8', '10110110'));

    Here's an example of going the other way:

        $binary_string = unpack('B*', "\x29");

- 

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.

                                                           04.04
-- 
    This space intentionally left blank


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

Date: Sun, 22 Jul 2001 23:24:38 -0400
From: Chris Micallef <cmicallef@playground.net>
Subject: getting users ip
Message-Id: <3B5B98F6.21D02821@playground.net>

I am using perl to write cgi scripts for a web page.

Can some one explain to me how and why the following code successfully
obtains users ip.

$RemoteHost = (gethostbyaddr(pack('C4',$1,$2,$3,$4),2))[0] ||
$ENV{'REMOTE_ADDR'};





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

Date: Mon, 23 Jul 2001 18:53:04 +1000
From: "Ned Ludd" <nowhere@dot.com>
Subject: Re: Hashes tutorila
Message-Id: <RmR67.12272$a04.39549@newsfeeds.bigpond.com>

"Jaouad El Bahraoui" <jaouad16@home.com> wrote in message
news:STH67.241662$%i7.135022103@news1.rdc1.sfba.home.com...
> Hi guys,
>
> I am looking for a beginner hashes tutorial, what I want to do is
> calculating the average of the "values" in the hashe and store them in
> another hashe, there is any simple way to do it?
>
> thanks
>
> jeb
>

http://www.cpan.org/doc/FMTEYEWTK/pdsc/index.html





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

Date: Mon, 23 Jul 2001 09:23:46 +0200
From: "Ciric Vukasin" <cvule@eunet.yu>
Subject: How to redirect a user ?
Message-Id: <9jgjbc$rsj$1@news.eunet.yu>

How to redirect user to another page ?

Thanks in adv.




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

Date: Mon, 23 Jul 2001 01:45:21 -0400
From: Benjamin Goldberg <goldbb2@earthlink.net>
Subject: Re: How to timeout a socket recv under win32?
Message-Id: <3B5BB9F1.3ADB7C60@earthlink.net>

Bart Lateur wrote:
> 
> Benjamin Goldberg wrote:
> 
> >> So you mean recv().
> >
> >Umm, what do you mean by that comment?
> 
> Oops, I have ben mixing threads. I cconfused this with another current
> thread, where the OP asked how you can know how many bytes there are
> currently available for reading.
> 
> It all boils down to this: how do you receive all the data that the
> other side is sending to you, without waiting for more that won't
> come?
> How do you know that, for the moment, the transmission is complete?

Either you use fixed-length packets, or use a delimiter (like CRLF).

> <S>, read, sysread, recv are similar yet different. I guess that only
> read() is not usable. select() or IO::Select can tell you that
> something is available, but not how much. I have the feeling that
> there isn't a real generic solution, that the sender somehow HAS to
> indicate how long the transmission will be. Otherwise, the receiver
> can stop receiving too soon, or wait for something that won't come.

If you're dealing with a tcp stream, not a udp socket, then you probably
don't need/want to be using recv.  <>, read, and sysread are all useful.

If you know that data is sent in packets of a fixed size, and you aren't
afraid of DOS attacks, then you can simply use select or IO::Select
to get to a point when you know that there is *some* data on the stream,
and then *assume* [here's where a DOS attack could come in] that one
whole packet will then be available, and do a blocking read (either
with read(), or with $/ = \recordlength and <>) for that many bytes.

my $sel = IO::Select->new($socket);
while( $sel->can_read(0) ) {
	my $packet;
	my $got = read( $socket, $packet, 40 );
	$got == 40 or die "read: $!";
	push @packets, $packet;
}

or:
my $sel = IO::Select->new($socket);
while( $sel->can_read(0) ) {
	local $/ = \40;
	my $packet = <$socket>;
	length($packet) == 40 or die "read: $!";
	push @packets, $packet;
}

Similarly, if you know that data will be sent in complete packets with
some particular delimiter, you can block until *something* is there,
and then read with <> (and $/ = delimiter) until you get the entire
packet.

my $sel = IO::Select->new($socket);
while( $sel->can_read(0) ) {
	local $/ = CRLF;
	chomp( my $packet = <$socket> ) or die "read: $!";
	push @packets, $packet;
}

With either of these, the only problem that can occur if the other end
decides to stop/pause right in the middle of a packet; if you are
willing to ignore such problems, then you're all set.

Otherwise, read on.

If you want to *try* to use normal buffered io (read or <>), but set a
timeout... read the faq.  You would probably use %SIG, eval BLOCK, and
alarm in combination to abort the read if it takes too long to complete.
Since the buffers for the file will then be in some undeterminable
state, and some data may even have been lost, all you can now do is
print out a message and close the stream (and maybe abort your program,
depending on the application).

Elsewise, use unbuffered io, using the sysread function.

The sysread function reads without requiring that a complete record
(packet) is there before returning... it does block until *some* data
has been gotten, but once it has that, it will return with what it has.

my $sel = IO::Select->new($socket);
while( $sel->can_read(0) ) {
	my $gotabit;
	sysread( $socket, $gotabit, 1<<10 )
		or die "sysread: $!";
	$buffer .= $gotabit;
}

This will append to $buffer as many bytes as can be read without
blocking.  It will read *up to* 1024 bytes, but won't try to wait until
there are that many available.

Normally, one would have a hash mapping sockets to 'buffer' objects of
some sort, do select on all the sockets, then for each 'buffer' objects
which has a readable socket, have it read in all it can without
blocking, then, if enough has been read to do something, substr that
text off of the front of the buffer and process it:

	while( length( $self->{buffer} ) >= $len ) {
		$to_process = substr($self->{buffer}, 0, $len, "");
		$self->process_input($to_process);
	}

-- 
I need more taglines. This one is getting old.


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

Date: Mon, 23 Jul 2001 08:10:41 GMT
From: Uri Guttman <uri@sysarch.com>
Subject: Re: I found sprintf - is there a sscanf?
Message-Id: <x7y9pgjcam.fsf@home.sysarch.com>

>>>>> "JAG" == John A Grant <jazrant@zsc.nrcan.zc.ca> writes:

  JAG> I found sprintf(). Now I'm looking for an equivalent of sscanf().
  JAG> Is there one?

as someone showed you, there are multiple ways to parse a line without a
sscanf equiv. in fact perl's ways are so much better than sscanf, that i
am glad larry didn't include it. sscanf is a painful function. regexes
or split are much better.

uri

-- 
Uri Guttman  ---------  uri@sysarch.com  ----------  http://www.sysarch.com
SYStems ARCHitecture and Stem Development ------ http://www.stemsystems.com
Search or Offer Perl Jobs  --------------------------  http://jobs.perl.org


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

Date: 23 Jul 2001 09:30:25 GMT
From: vek@pharmnl.ohout.pharmapartners.nl (Villy Kruse)
Subject: Re: I found sprintf - is there a sscanf?
Message-Id: <slrn9lnrlg.9rq.vek@pharmnl.ohout.pharmapartners.nl>

On Mon, 23 Jul 2001 08:10:41 GMT,
    Uri Guttman <uri@sysarch.com> wrote:


>>>>>> "JAG" == John A Grant <jazrant@zsc.nrcan.zc.ca> writes:
>
>  JAG> I found sprintf(). Now I'm looking for an equivalent of sscanf().
>  JAG> Is there one?
>
>as someone showed you, there are multiple ways to parse a line without a
>sscanf equiv. in fact perl's ways are so much better than sscanf, that i
>am glad larry didn't include it. sscanf is a painful function. regexes
>or split are much better.
>


plus an occasional oct or hex for the %x and %o formats.



Villy


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

Date: Mon, 23 Jul 2001 17:06:21 +1000
From: "Ned Ludd" <nowhere@dot.com>
Subject: Re: Including a perl file into another perl file???
Message-Id: <POP67.12214$a04.39500@newsfeeds.bigpond.com>

"Bob Rock" <nospam.yet_another_apprentice@hotmail.com> wrote in message
news:9jfbr2$ntj4c$2@ID-98646.news.dfncis.de...
> Hello,
> is there a function that lets you include a perl file inside another like
> the #include statement available in asp?
> Thank you.
>
>
> Regards,
> Bob Rock
>
>
You probably need "require".


The subroutine below recursively expands #include and returns a list of
expanded lines.


sub include {
        my($i,$filename,$includefile,@list,@includelist);
        @list=();
        foreach $i (@_) {
                if ($i =~ m/#include/) {
                        open(includefile,substr($i,9));
                        @includelist=<includefile>;
                        close(includefile);
                        push(@list,include(@includelist));
                } else {push(@list,$i);}
        }
        return(@list);
}

G Toomey




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

Date: 23 Jul 2001 07:36:03 GMT
From: ebohlman@omsdev.com (Eric Bohlman)
Subject: Re: Including a perl file into another perl file???
Message-Id: <9jgk53$c0h$1@bob.news.rcn.net>

Ned Ludd <nowhere@dot.com> wrote:
> The subroutine below recursively expands #include and returns a list of
> expanded lines.


> sub include {
>         my($i,$filename,$includefile,@list,@includelist);
>         @list=();
>         foreach $i (@_) {
>                 if ($i =~ m/#include/) {

This should be anchored to match only at the beginning of a line.

>                         open(includefile,substr($i,9));
>                         @includelist=<includefile>;
>                         close(includefile);
>                         push(@list,include(@includelist));
>                 } else {push(@list,$i);}
>         }
>         return(@list);
> }

Fixing that, adding some error checking and using some Perl idioms:

 sub include {
     my @list=();
     foreach (@_) {
         if (/^#include\s+(.*)$/) {
             if (open(INCLUDEFILE,"<$1")) {
                 my @includelist=<INCLUDEFILE>;
                 close(INCLUDEFILE);
                 push(@list,include(@includelist));
             }
             else {
                 warn "Couldn't open $1: $!\n";
             }
         }
         else {
             push(@list,$_);
         }
     }
     return(@list);
 }




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

Date: Mon, 23 Jul 2001 10:51:42 +0100
From: Paul Boardman <peb@bms.umist.ac.uk>
Subject: Re: Including a perl file into another perl file???
Message-Id: <3B5BF3AE.A5206E2C@bms.umist.ac.uk>

Bob Rock wrote:
> 
> Hello,
> is there a function that lets you include a perl file inside another like
> the #include statement available in asp?
> Thank you.
> 

have a look at the require function. 'perldoc -f require'.

If you have a load of subroutines that you want to make available to a
set of programs, then you can put all the subs into one file (say
subs.pl) and then just "require 'subs.pl'" in the main program file.
This will make these subrotines available to your main script.

Paul


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

Date: Mon, 23 Jul 2001 01:28:08 -0400
From: Andras Malatinszky <andras@mortgagestats.com>
Subject: Re: Including one perl file into another???
Message-Id: <3B5BB5E8.2C3774C@mortgagestats.com>



Racso wrote:

[snip]
 Since most here are likely too "l337" to answer such a question, I'll
[snip]

Just out of curiosity: what doeas "1337" mean (in this context)?




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

Date: 23 Jul 2001 06:01:10 GMT
From: ebohlman@omsdev.com (Eric Bohlman)
Subject: Re: Including one perl file into another???
Message-Id: <9jgej6$mps$1@bob.news.rcn.net>

In comp.lang.perl.misc Andras Malatinszky <andras@mortgagestats.com> wrote:
> Racso wrote:

> [snip]
>  Since most here are likely too "l337" to answer such a question, I'll
> [snip]

> Just out of curiosity: what doeas "1337" mean (in this context)?

Should be "31337" which is script-kiddiese for "elite" (it looks like 
"ELEET").



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

Date: Mon, 23 Jul 2001 10:42:27 +0200
From: Ben Engbers <J.B.O.M.Engbers@dlg.agro.nl>
Subject: Newbie:Sometimes it works and sometimes it won't
Message-Id: <3B5BE373.9B10EB50@dlg.agro.nl>

I have installed the latest version of activeperl on both the test- and
the productionserver. Both servers are used to serve the intranetsite
and we run Win NT 4.0 and IIS.
All changes to the intranetsite are copied to the productionserver so as
far as I know, the webenvironments are identical. The only difference is
that the testserver is a dedicated server while the productionserver is
also used for other processes.

The problem on the production server is that sometimes normal users
cant't access (find) the Perlmodules while some seconds later, there are
no problems. As administrator, I never have any problems at all.
I have never worked with Perl so I don't have any indication where to
find the solution.
Where should I start looking?

Thanks,
Ben Engbers



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

Date: 23 Jul 2001 02:18:02 -0400
From: alan@oursland.net (Alan Oursland)
Subject: Re: perl regular expression grammar
Message-Id: <01-07-107@comp.compilers>
Keywords: parse

Thank you for the feedback. It is very helpful.

On 18 Jul 2001 20:02:27 -0400, abigail@foad.org (Abigail) wrote:
>(why are "+", "&", "`" and "'" mentioned in <backoctal>?)

Octal codes are sometimes interpreted as back-references. I didn't know how to
separate octal codes from the back-references in the grammar since it seems to
be context sensitive, so I combined them into one production. The extra
characters are other ways of referring to back-references.

Alan


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

Date: 23 Jul 2001 02:23:47 -0400
From: Ilmari Karonen <usenet11522@itz.pp.sci.fi>
Subject: Re: perl regular expression grammar
Message-Id: <01-07-117@comp.compilers>
Keywords: parse

Alan Oursland wrote:
>
>Here is the grammar:

Here are some comments:

><term>		::= "."			| "$"		| "^"		| <char>			| <set>

The "$" is handled as a special case by the regex parser.  It's a tail
anchor only when followed by "(", ")", "|", the end of the regex, or a
whitespace character.  Otherwise it's assumed to start a variable that
should be interpolated.

I may be remembering the exact dirty details wrong.  I suggest you see
the code in toke.c -- look for the string "tail anchor", and note that
as far as I can remember the code and the comments disagree on certain
minor details.


><char>		::= <non-meta>	| "\"<escaped>
><non-meta>	::= any non-meta char
><escaped>	::= <meta>|<control>|<special>|<assert>

You might want to take advantage of the fact that "\" followed by any
non-word character always represents that literal character.  This is
guaranteed, as is the fact that no non-backslashed word character can
ever be a metacharacter.  (This is how quotemeta() can work.)

Use the source.  It will help you, assuming it won't make you give up
the task in disgust.

--
Ilmari Karonen -- http://www.sci.fi/~iltzu/


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

Date: Mon, 23 Jul 2001 07:47:39 +0000 (UTC)
From: SMarshall@bluedisc.com (Simon Marshall - SMA)
Subject: Remote updating of my website
Message-Id: <3F8CBF7D9D43D4119E8100508B6CB0FDF2E76F@redstripe>

Hi all

I have a website http://www.narrowboat-havana.co.uk
which is all about the
boat I live on in London.

I'm going to be going for a year long cruise around
the waterways of England
and I want to be able to update the site daily with a
cruise log for the
day.

Someone tells me that some perl script on my site
would enable me to update
it via email, i.e. send an email to
simon.marshall@clara.net with a subject
line CRUISE LOG and it'll create a new entry on a page
on my site. I know nothing about perl though.

Before you suggest linking a mobile to a laptop and
doing it via html & ftp,
what I want to do is send the emails from my mobile
phone and keep it
simple.

Any ideas? My service provider is clara.net if that's
of any help.

Thanks

Simon Marshall



-- 
Posted from mail.london-2.starlabs.net [212.125.75.4] 
via Mailgate.ORG Server - http://www.Mailgate.ORG


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

Date: 23 Jul 2001 09:49:38 GMT
From: dkcombs@panix.com (David Combs)
Subject: Re: Removing .coms
Message-Id: <9jgrvi$i8o$1@news.panix.com>

In article <20010718173402.19164.00000083@ng-fb1.aol.com>,
Blstone77 <blstone77@aol.com> wrote:
>>
>>     ^ ^  ^      embedded within a domain name.
>>     ^ ^  ^Should be backslashed.
>>     ^ ^Matches anything including space. This is what's removing too much.
>>     ^Needs backslash.
>
>
>Thanks much, I'll learn this thing yet  ;)

No, you won't.  Nor will I.  Nor will anyone else,
save maybe for a guy named "Ilya".

David



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

Date: Mon, 23 Jul 2001 01:07:47 -0400
From: Benjamin Goldberg <goldbb2@earthlink.net>
Subject: Re: Trouble extracting strings - help needed
Message-Id: <3B5BB123.8DC5470B@earthlink.net>

Mark Smith wrote:
> 
> I have a perl script that reads in a file.  The contents of this file
> may vary but at several points it contains a filename between double
> quotes.  I need to extract every instance of the filename in quotes as
> I need to then process each of these files.
> 
> The file would roughly be in this kind of format.
> 
> files {
> "somefile.mst",
> "Anotherfile.mst",
> "further-file.mst"
> }
> config {
> 
> }

my $qs = qr/"[^"]*"/;
my $strings = qr/(?:$qs\s*,\s*)*$qs?/;
my $group = qr/(\w+)\s*{\s*($strings)\s*}/;

my $data = do { local $/; <$filehandle> };

while( $data =~ /$group/g ) {
	my $section = $1;
	my @strings = $2 =~ /"([^"]*)"/g;
	$configuration{$section} = \@strings;
}

> Can anyone help as I can't seem to devise a working method to get just
> the filenames? 

print join(", ", map qq("$_"}, @{$configuration{"files"}}), "\n";

> Also if possible could you mail me directly and
> explain what your method is doing so I will have an understanding.

Sorry, if you ask it here, your response is here, but I can explain what
it's doing...

$qs is a Regex object which contains an expression which matches a
quoted string.  $strings is a Regex object which matches a comma
seperated list of $qs things, with whitespace allowed before and after
the comma.  $group is a Regex object which matches a word, a "{", a
$strings, and a "}", and [due to the placement of parenthesis], causes
the word and the text matched by $strings to be placed in $1 and $2.
$data is the entire file, slurped into one string.  The while loop
repeatedly matches $group objects.  @strings is all of the quoted
strings in $2, but without the quotes.  Then I store a reference to
@strings (it's a my variable declared inside the loop, so this is ok),
into the %configuration hash.  After, I get $configuration{files},
dereference the arrayref, use map to put "" around each item, then join
the results with ", ", and then print all that, and a newline.  Got it?

> Once again this file could contains lots of information and I don't
> know the filenames in advance so I need something that will not just
> work with the above but would extract whatever lies between the two
> quotes.

You mean between each pair of quotes.
To turn one quoted string into an unquoted string, use this:
	($unquoted) = $quoted =~ /"([^"]*)"/;
To turn a bunch of quoted strings into a list of unquoted ones, use
this:
	@unquoted = $quoted =~ /"([^"]*)"/g;

-- 
I need more taglines. This one is getting old.


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

Date: 23 Jul 2001 08:51:09 +0400
From: Ilya Martynov <ilya@martynov.org>
Subject: Re: use attributes; subs : lvalue { return $this->{anyvar} } question
Message-Id: <87r8v8xn7m.fsf@abra.ru>


MU> I want to create attribute handlers which could be written like:
MU> $this->name = 'Murat';

MU> The perlsub.pod states i can "use attributes" with attribute : lvalue for
MU> this:

MU> __START__

MU> package Foo;

MU> sub name : lvalue
MU> {
MU>    my $this = shift;

MU> return @_ ? $this->{name} = shift : $this->{name};
    ^^^^^^

Remove 'return'. I've not idea why it helps but it does helps.

MU> };

MU> sub new { bless { name => 'somebody else' } }

MU> package main;

MU>     my $obj = new Foo;

MU>     $obj->name = 'Murat';

MU>     print "You are: ", $obj->name;

MU> __END__

-- 
 -=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-
| Ilya Martynov (http://martynov.org/)                                    |
| GnuPG 1024D/323BDEE6 D7F7 561E 4C1D 8A15 8E80  E4AE BE1A 53EB 323B DEE6 |
| AGAVA Software Company (http://www.agava.com/)                          |
 -=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-


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

Date: Mon, 23 Jul 2001 09:52:34 +0200
From: "Murat Uenalan" <murat.uenalan@gmx.de>
Subject: Re: use attributes; subs : lvalue { return $this->{anyvar} } question
Message-Id: <9jgkv7$o65me$1@ID-71895.news.dfncis.de>

Fantastic ! This was it...

But this detail should be definitivly added to the perlsub manpage, because
there is not even a word about that..

Many many thx Ilya,
Murat

"Ilya Martynov" <ilya@martynov.org> schrieb im Newsbeitrag
news:87r8v8xn7m.fsf@abra.ru...
>
> MU> I want to create attribute handlers which could be written like:
> MU> $this->name = 'Murat';
>
> MU> The perlsub.pod states i can "use attributes" with attribute : lvalue
for
> MU> this:
>
> MU> __START__
>
> MU> package Foo;
>
> MU> sub name : lvalue
> MU> {
> MU>    my $this = shift;
>
> MU> return @_ ? $this->{name} = shift : $this->{name};
>     ^^^^^^
>
> Remove 'return'. I've not idea why it helps but it does helps.
>
> MU> };
>
> MU> sub new { bless { name => 'somebody else' } }
>
> MU> package main;
>
> MU>     my $obj = new Foo;
>
> MU>     $obj->name = 'Murat';
>
> MU>     print "You are: ", $obj->name;
>
> MU> __END__
>
> --
>  -=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-
> | Ilya Martynov (http://martynov.org/)
|
> | GnuPG 1024D/323BDEE6 D7F7 561E 4C1D 8A15 8E80  E4AE BE1A 53EB 323B DEE6
|
> | AGAVA Software Company (http://www.agava.com/)
|
>  -=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-




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

Date: Mon, 23 Jul 2001 06:39:45 +0200
From: Philip Newton <pne-news-20010723@newton.digitalspace.net>
Subject: Re: Use Perl and Visual Basic together
Message-Id: <0fanlt493urc3hi2hfi0ofr1t9dhdrkpk3@4ax.com>

[Please don't top-post. Please trim your quotes appropriately. Please
don't quote signatures unless you're commenting on them. If you read
German, then http://learn.to/quote .]

On Sun, 22 Jul 2001 21:50:15 +0200, "Olivier Salzgeber"
<reciever@tiscalinet.ch> wrote:

> But is there also a way to start a visual basic
> program from a perl program ?

If it's an executable file, you should be able to start it with
system(), just like any other program, and give it command-line
arguments.

> Example: I want to write some Values into an Excel-Sheet. I believe that it
> is simpler to program this in VB than in PERL.

Probably because most of the OLE examples around use Visual Basic as
their demonstration language.

> (Or is there an easy Way to write to MSExcel with PERL)

You could use Win32::OLE to remove-control Excel from Perl and write
values into a sheet. I've done so in the past.

Cheers,
Philip
-- 
Philip Newton <nospam.newton@gmx.li>
That really is my address; no need to remove anything to reply.
If you're not part of the solution, you're part of the precipitate.


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

Date: Mon, 23 Jul 2001 09:16:26 GMT
From: Bart Lateur <bart.lateur@skynet.be>
Subject: Re: Use Perl and Visual Basic together
Message-Id: <clqnltogrkrvi1i6dn78dmji8qmdjvtnmf@4ax.com>

Olivier Salzgeber wrote:

>Example: I want to write some Values into an Excel-Sheet. I believe that it
>is simpler to program this in VB than in PERL. (Or is there an easy Way to
>write to MSExcel with PERL)

Win32::OLE. See the FAQ (perlwin32faq12) at:
<http://aspn.activestate.com/ASPN/Reference/Products/ActivePerl/faq/Windows/ActivePerl-Winfaq12.html>

-- 
	Bart.


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

Date: 23 Jul 2001 11:38:43 +0200
From: Walter Hafner <hafner-usenet@ze.tu-muenchen.de>
Subject: Re: Use Perl and Visual Basic together
Message-Id: <srjofqcyogs.fsf@w3proj1.ze.tu-muenchen.de>

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

> Olivier Salzgeber wrote:
> 
> >Example: I want to write some Values into an Excel-Sheet. I believe that it
> >is simpler to program this in VB than in PERL. (Or is there an easy Way to
> >write to MSExcel with PERL)
> 
> Win32::OLE. See the FAQ (perlwin32faq12) at:
> <http://aspn.activestate.com/ASPN/Reference/Products/ActivePerl/faq/Windows/ActivePerl-Winfaq12.html>

I use Spreadsheet::WriteExcel to write Excel binary files on Unix.

The module can write simple sheets (text and number cells) without the
need for Windows and Excel.

If that's enough for you ...

-Walter


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

Date: Mon, 23 Jul 2001 06:39:47 +0200
From: Philip Newton <pne-news-20010723@newton.digitalspace.net>
Subject: Re: where is the "standard library"
Message-Id: <77anlt04216qkm904uleko90nq1nf3tm8a@4ax.com>

On 22 Jul 2001 20:57:08 GMT, ebohlman@omsdev.com (Eric Bohlman) wrote:

> It only searches the libraries when it's processing a use(), require()
> or do {}

Er, I'd make that do "" rather than do {} -- the second for me sounds
like

    $foo = do {
             my $bar = pop @zip;
             $bar =~ s/blurfle/flirble/g;
             substr($bar, 21. 17);
           };

, which is a different type of do. You're looking for the

    do "blurfle.pl";

(or, as perlfunc calls it, do EXPR rather than do BLOCK).

Cheers,
Philip
-- 
Philip Newton <nospam.newton@gmx.li>
That really is my address; no need to remove anything to reply.
If you're not part of the solution, you're part of the precipitate.


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

Date: Mon, 23 Jul 2001 08:58:19 GMT
From: Bart Lateur <bart.lateur@skynet.be>
Subject: Re: Who can help me about the confused (..) operator?
Message-Id: <88onltkjd3pgj80h53krvcvsaaeehpunes@4ax.com>

MMX166+2.1G HD wrote:

>Terrible range operator (..) which in the scalar context...I had read
>the perldoc many times, but I can't understand it at all.

In scalar context, it's not a range operator. It's an entirely different
operator which just happens to be written the same. A homonym.

In scalar context, it's called the flip-flop operator, which won't mean
much to you unless you're into digital electronics.

It's an operator with built-in (1 bit) memory. Every time it's
evaluated, its memory may change (between true and false). Initially,
it's set to false. In that case, the left hand side gets tested. If it's
true, the memory is set to true, and the value it returns is true too.
Otherwise, memory remains false and value returned is false.

When memory is true, the right hand side gets tested. If it's true, the
memory is turned off to false, the value returned is true (for the last
time). Otherwise, memory remains true, value is true.

Thus: it is true from the time when the LHS is true up to and including
when the RHS is true.

p.s. Actually, the value returned is not a boolean but a number, a
counter, with a special "last time" indicator: an appended "E0" which
doesn't change the boolean or numerical value.

	for my $i (1..10) {
	    if(my $test = ($i==5 .. $i==8)) {
	        # from when $i is 5 up to when $i is 8
	        print "$i -> $test\n";
	    }
	}
-->
	5 -> 1
	6 -> 2
	7 -> 3
	8 -> 4E0

-- 
	Bart.


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

Date: Mon, 23 Jul 2001 12:54:43 +0530
From: Emmanuel E <shashanka.sj@in.bosch.com>
Subject: Re: Yet another Perl Web Server
Message-Id: <3B5BD13B.829ED5FA@in.bosch.com>

hi
how does ur server work if u arent forking? how do u manage threads? are
u using non blocking I/O ? and some timer signals to manage threads? is
it stable on the windoze platform on active perl? i'd love to hear from
u.

thanks
Emmanuel

John Holdsworth wrote:

> Hi,
>
> I've developed a perhaps rather excentric
> Perl Web Server if it is of interest.
>
> It has some rather unusual features:
>
> No configuration file (c.f. Apache!)
> Virtual hosting by creating multiple document directories.
> Able to proxy a symbolic link through to another server.
> Can run CGI scripts without forking for each request.
> Embeddeds perl in a Web page (PSP)
> Robust.
>
> Unfortunately documentation has not been my priority
> but it is reasonably easy to run. Download the server
> from http://www.openpsp.org/download.html, uncompress
> and untar the results then run "server.pl" in the
> resulting directory and browse to http://<yourhost>:9090/
>
> Any suggestions/bug reports appreciated.
>
> Cheers
>
> John.
> coldwave@thunder.it



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

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


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