[19279] in Perl-Users-Digest
Perl-Users Digest, Issue: 1474 Volume: 10
daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Thu Aug 9 09:05:39 2001
Date: Thu, 9 Aug 2001 06:05:16 -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: <997362316-v10-i1474@ruby.oce.orst.edu>
Content-Type: text
Perl-Users Digest Thu, 9 Aug 2001 Volume: 10 Number: 1474
Today's topics:
Re: Additional questions <iltzu@sci.invalid>
Re: code doesn't work from "learning perl" (Anno Siegel)
Re: COmments appreciated <iltzu@sci.invalid>
Re: export from dbf to csv/text format <bkennedy99@Home.com>
FAQ: How do I define methods for every class/object? <faq@denver.pm.org>
How could chomp the blanks of one sentence? <gokkog@yahoo.com>
Re: How could chomp the blanks of one sentence? <ilya@martynov.org>
Re: How to get Mac and IP address of computers over a n (Helgi Briem)
Re: how to get perlscript <sky@mail.lviv.ua>
Re: how to get perlscript <bart.lateur@skynet.be>
Ignore my last message! But NOT this one <paul@net366.com>
Re: Ignore my last message! But NOT this one <paul@net366.com>
ImageMagick, Tk, and PNG ---- HELP <sky@mail.lviv.ua>
Re: ImageMagick, Tk, and PNG ---- HELP (Martien Verbruggen)
Is it a number? <dcsnospam@ntlworld.com>
Re: Is it a number? <ilya@martynov.org>
Re: mresolv2 and sockets on HP-UX 10.20 (Anno Siegel)
Re: Not matching strings (Grunge Man)
Re: online editing of a text form <m.forsythe@zenithrs.ie>
perl - write text file to server help (Charlie Abbott)
Re: Perl dumps core :-(. <iltzu@sci.invalid>
Perl for VMS - use IO::Socket::INET <steuver@nku.edu>
Re: Perl not releasing lock on file under Windows?? (Anno Siegel)
Re: Perl Search Engine <bart.lateur@skynet.be>
Digest Administrivia (Last modified: 6 Apr 01) (Perl-Users-Digest Admin)
----------------------------------------------------------------------
Date: 9 Aug 2001 12:23:35 GMT
From: Ilmari Karonen <iltzu@sci.invalid>
Subject: Re: Additional questions
Message-Id: <997356675.14210@itz.pp.sci.fi>
In article <Ku_a7.28121$b_3.2282979@news0.telusplanet.net>, Sean Hamilton wrote:
>
>1. How does "print" work, in that it allows an argument to be specified, and
>if one is not, it defaults to $_? How would myprint be written to do this?
>Must I declare two primts, one of which calls the other with $_?
Actually, it works by special internal tricks that allow it to see its
raw argument list. You can get *almost* the same effect with:
sub myprint {
if (@_) {
print @_;
} else {
print $_;
}
}
but it won't match the behavior of print if you pass it an empty array.
Contrary to what has been claimed in other parts of this thread, $_ is
*not* lexically scoped. In fact, not only is it a global variable, but
it isn't even affected by package declarations.
>2. Warns: print (...) interpreted as function.
>
>What else would it be?
A list operator that just happens to be followed by a parenthesized
expression. Like this, maybe:
print ($n or "no"), " $thing", ($n == 1 ? "" : "s"), "\n";
which is supposed to print something like "no apples\n", if $n = 0 and
$thing = "apple", but in fact prints only "no" and throws away the rest.
The correct way to write that would be either:
print(($n or "no"), " $thing", ($n == 1 ? "" : "s"), "\n");
or:
print +($n or "no"), " $thing", ($n == 1 ? "" : "s"), "\n";
>> 1. Having a strong background in C and similar, I am somewhat surprised to
>> find that you cannot do the following in Perl:
>>
>> sub myprint ($text)
>> {
>> print ($text);
>> }
The closest you can get to that syntax would be:
sub myprint {
my ($text, $and, $other, $params) = @_;
print $text;
}
>> Am I just horribly mistaken, or is there some weird syntax involved, or
>> what? Must I use shift? That seems error-prone.
Error-prone how? Because it doesn't assert that the function must take
one argument?
In general, if you don't trust the user to give the right number and
kind of arguments, you should check them explicitly yourself. However,
there *is* one special case -- if you declare your function with a
prototype of ($), Perl will treat it as a unary operator instead of a
list operator. This has various effects, one of them being that the
function will only ever get one argument.
However, for this to work, you'll need to declare the function *before*
you use it, so that the parser will know what its prototype is. Also
note that it's still possible for someone to deliberately pass more than
one argument by prefixing the subroutine call with "&".
>> 2. Is this the best way to mimic a server side include?
>>
>> open (FILE, '<', shift);
>> print while read (FILE, $_, 16384);
>> close (FILE);
For some values of "best" and "server side include", yes. There Is More
Than One Way To Do It. Some of those include:
system('cat', shift); # short, needs external program
and:
{ # localized special variables
local ($/, @ARGV) = (\16384, shift);
print while <>;
}
Also note that whenever you call open(), you should check the return
value -- even if all you're going to do is die if it fails:
open FILE, '<', shift or die $!; # if this fails, panic!
print while read FILE, $_, 16384;
close FILE;
Or you might want to just quietly skip any file that can't be opened:
if (open FILE, '<', shift) {
print while read FILE, $_, 16384;
close FILE;
}
>> 3. How might I go about passing an array to a function? It seems to just
>> get
>> mashed into the argument list. I tried passing a reference to that array,
>> but then couldn't find information on any sort of indirection operator.
References are indeed the right solution. Dereferencing is simple:
my $ref = \@array; # create a reference..
push @$ref, "foo\n"; # ..and use it instead of the array name
print pop @array; # prints: "foo"
$$ref[0]++; # you can access single items the same way..
$ref->[0]++; # ..or use the -> dereferencing operator
print $array[0], "\n"; # prints: "2"
If the reference is more than just a single scalar, you'll have to
enclose it in braces (or parens for the -> operator):
my @refs = \(@a, @b, @c); # magic distributive list reference
push @{shift @refs}, 'this goes to @a';
${$refs[0]}[0] = 'this goes to @b';
(pop @refs)->[0] = 'this goes to @c';
..but the -> operator has the same precedence as indexing, so that this
will work:
$refs[0]->[1] = 'this one goes to @b as well';
and since -> can be omitted between braces and brackets, so will this:
$refs[0][2] = 'yet another string into @b';
Hey! Almost looks like a multidimensional array, doesn't it?
Going back to functions, it's also possible to use the prototypes I
mentioned above to pass arrays implicitly by reference. You'll still
have to dereference them explicitly, however. The feature is there so
that you can emulate builtin functions like push() if you want.
--
Ilmari Karonen -- http://www.sci.fi/~iltzu/
"Get real! This is a discussion group, not a helpdesk. You post something,
we discuss its implications. If the discussion happens to answer a question
you've asked, that's incidental." -- nobull in comp.lang.perl.misc
------------------------------
Date: 9 Aug 2001 12:23:59 GMT
From: anno4000@lublin.zrz.tu-berlin.de (Anno Siegel)
Subject: Re: code doesn't work from "learning perl"
Message-Id: <9ktvcv$9el$2@mamenchi.zrz.TU-Berlin.DE>
According to Tassilo von Parseval <Tassilo.Parseval@post.rwth-aachen.de>:
> Mark Jason Dominus wrote:
> > In article <20010808182321.4bbae64d.david@phobia.ms>,
> > David Hill <david@phobia.ms> wrote:
> >
> >>Hello -
> >> I am reading my "Learning Perl 2nd edition" book by Randal Schwartz.
> In Chapter 3 on page 49, The examples given to not work as they say.
> >>
> >
> > You are correct. This is an error in the book.
> >
> > Accoding to:
> >
> > http://www.oreilly.com/catalog/lperl2/errata/
> >
> > this was fixed in the October 1999 printing.
>
> One should have also fixed the perlop-manpage then:
>
> "Binary ".." is the range operator, which is really two
> different operators depending on the context. In list
> context, it returns an array of values counting (up by
> ones) from the left value to the right value."
>
> There is no reason why it shouldn't be able to count up by one on
> non-integer numbers.
If we did that, rounding errors could influence the length of the
generated list (for a starting value close to an integer). I think
we better leave it alone.
Anno
------------------------------
Date: 9 Aug 2001 10:25:41 GMT
From: Ilmari Karonen <iltzu@sci.invalid>
Subject: Re: COmments appreciated
Message-Id: <997352284.10847@itz.pp.sci.fi>
In article <slrn9mlkk0.15f.tadmc@tadmc26.august.net>, Tad McClellan wrote:
>Markku Hirvonen <markku@huilustudio.fi> wrote:
>>
>>I have a messageboard and i wanted to shorten all the words longer
>>than 20 characters and put 3 dots after them.
>
> $orig_message =~ s/(\w{20})\w+/$1.../g;
One might consider interpreting the original specification slightly
differently, so that the regex becomes:
$orig_message =~ s/(\w{17})\w{4,}/$1.../g;
After all, there's little point in "abbreviating", say, the word
"electroencephalography" to "electroencephalograp...", which is one
character longer than the original.
--
Ilmari Karonen -- http://www.sci.fi/~iltzu/
"Get real! This is a discussion group, not a helpdesk. You post something,
we discuss its implications. If the discussion happens to answer a question
you've asked, that's incidental." -- nobull in comp.lang.perl.misc
------------------------------
Date: Thu, 09 Aug 2001 12:33:04 GMT
From: "Ben Kennedy" <bkennedy99@Home.com>
Subject: Re: export from dbf to csv/text format
Message-Id: <4qvc7.87201$EP6.21028063@news1.rdc2.pa.home.com>
"derelixir" <derelixir@my-deja.com> wrote in message
news:fd50a1dc.0108090049.3f8cbfb7@posting.google.com...
> Hello...
>
> I got a file in .dbf format that contains several fields
> e.g. name, address, age, id
>
> Is there a way I could automatically convert this dbf file to csv/text
format?
See the documentation for DBD::XBase and DBI, if you want to use only perl
and write it yourself. There are plenty of other tools that will so it for
you as well, check google.
--Ben Kennedy
------------------------------
Date: Thu, 09 Aug 2001 12:17:01 GMT
From: PerlFAQ Server <faq@denver.pm.org>
Subject: FAQ: How do I define methods for every class/object?
Message-Id: <1bvc7.17$B2j.170752000@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 define methods for every class/object?
Use the UNIVERSAL class (see the UNIVERSAL manpage).
-
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.72
--
This space intentionally left blank
------------------------------
Date: Thu, 9 Aug 2001 19:51:10 +0800
From: "Wenjie ZHAO" <gokkog@yahoo.com>
Subject: How could chomp the blanks of one sentence?
Message-Id: <9kttcl$c80$1@slbhw0.bln.sel.alcatel.de>
Esp in front of the words, e.g. " Hello ", how
could perl strip it to "Hello"?
Thanks !
--
Best regards,
Wenjie
"If you would be real seeker after truth, it is
necessary that at least once in your life you doubt,
as far as possible, all things."
------------------------------
Date: 09 Aug 2001 16:55:33 +0400
From: Ilya Martynov <ilya@martynov.org>
Subject: Re: How could chomp the blanks of one sentence?
Message-Id: <87y9ot75q2.fsf@abra.ru>
WZ> Esp in front of the words, e.g. " Hello ", how
WZ> could perl strip it to "Hello"?
my $str = " Hello ";
$str =~ s/^\s*//;
$str =~ s/\s*$//;
--
-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-
| 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: Thu, 09 Aug 2001 12:13:37 GMT
From: helgi@NOSPAMdecode.is (Helgi Briem)
Subject: Re: How to get Mac and IP address of computers over a network?
Message-Id: <3b727bba.1481552429@news.isholf.is>
On 8 Aug 2001 10:38:48 -0700, flichtenfels@hotmail.com
(Fred) wrote:
>Thanks for your response Paul. I forgot to mention in my original
>post that I am using Windows NT, not sure if this makes a difference.
>What is this nmap and where and how do you use it?(Is it a perl
>command or something you run from the command line?)
>I typed arp at my command prompt and it displayed my ip address and
>the gateway's ip and mac address, but not my mac address.
>I am a novice and I think your explanation was over my head a little.
>If you could elaborate a little it would be much appreciated.
>
I don't know what nmap is. It does not seem to exist
on my Linux and Solaris systems. The only difference
between NT and UNIX in this respect is the differing
commands used to get this information.
The command ipconfig /all can be used to get network info
on a NT box so you can try:
my @network_info = qx/ipconfig \/all/
or die "Cannot run ipconfig:$?\n";
print @network_info;
Parsing out the info you need I will leave to you.
BTW, Physical address corresponds to MAC address.
Regards,
Helgi Briem
------------------------------
Date: Thu, 09 Aug 2001 13:10:00 +0300
From: Roman Khutkyy <sky@mail.lviv.ua>
Subject: Re: how to get perlscript
Message-Id: <3B726178.C1AAF946@mail.lviv.ua>
How do I configure Microsoft IIS 4.0 to support Perl for Win32?
Microsoft IIS 4.0 ships with Windows NT Server 5.0, and PWS 4.0 ships
with Windows NT Workstation 5.0. Both
IIS and PWS are available as part of the Microsoft Windows NT 4.0 Option
Pack. You can find a link to the
Option Pack at http://www.microsoft.com/iis/
To configure IIS or PWS 4.0 to run Perl scripts:
1.Open the IIS 4.0 Internet Service Manager. This will bring up the
Microsoft Management Console with the
Internet Service Manager snap-in selected.
2.From the tree display on the left, select the level at which to
apply the mappings. You can choose an
entire server, web site, or a given virtual directory.
3.Select Properties from the Action menu.
4.If you chose to administer the properties for the entire server,
the Server Properties dialog will appear.
Select WWW Service from the Master Properties pull-down menu and
click the Edit button under Master
Properties. This opens WWW Service Master Properties. Select the
Home Directory tab and proceed to
step 7.
5.If you chose to administer the properties for an entire web site,
the Web Site Properties sheet appears.
Select the Home Directory tab and proceed to step 7.
6.If you chose to administer the properties for a virtual directory,
the Virtual Directory Properties sheet
appears. Select the Virtual Directory tab and proceed to step 7.
7.Click the Configuration button. This opens the Application
Configuration dialog.
8.Select the App Mappings tab and click the Add button. You see the
Add/Edit Application Extension
Mapping dialog.
9.To run Perl as a CGI application, type the full path to Perl.EXE
followed by %s %s. When a script is
executed, the first %s will be replaced by the full path to the
script, and the second %s will be replaced by
the script parameters.
10.To run Perl for ISAPI, type the full path to PerlIS.DLL. The %s %s
is not required for ISAPI DLLs.
11.In the Extension field, type .pl or .plx (or whatever extension you
want to use).
12.The application mapping is now complete. Click the OK button and
click OK to dismiss any remaining
dialogs/property sheets.
13.Close the IIS 4.0 Internet Service Manager.
Because IIS runs as a service (see What is a Windows NT service?), you
need to take special steps to make
sure that files and environment variables are available to it.
------------------------------
Date: Thu, 09 Aug 2001 12:13:36 GMT
From: Bart Lateur <bart.lateur@skynet.be>
Subject: Re: how to get perlscript
Message-Id: <skv4ntgk66b5qcvhpd7kjeu3k5c66s10uj@4ax.com>
Bell, Leslie wrote:
>I have perl installed on an NT server running IIS, which tells me that
>perlscript is not available (for .asp pages). I don't want to install
>ActiveState perl because you can't choose the directory, and I want it
>to stay in C:\winnt\local\perl\bin. Do you have to use ActiveState to
>get perlscript, or is there another way? And what is that other way, if
>there is one?
No, only ActiveState supplies perlscript. And I could be wrong, but I
was pretty sure the installer asks you nicely where you want to install
perl, in your case in "c:\winnt\local\perl". Just make sure that there
are NO spaces in the path.
--
Bart.
------------------------------
Date: Thu, 9 Aug 2001 13:51:37 +0100
From: "Paul Fortescue" <paul@net366.com>
Subject: Ignore my last message! But NOT this one
Message-Id: <997361421.14994.0.nnrp-08.d4f094e4@news.demon.co.uk>
I do
open (X, "fred")
while ($line=readline(X)) {
#returns nothing
}
but
while ($line=readline(*X)) {
#works
}
What have I missed about a 'typeglob' or something, please?
------------------------------
Date: Thu, 9 Aug 2001 14:00:56 +0100
From: "Paul Fortescue" <paul@net366.com>
Subject: Re: Ignore my last message! But NOT this one
Message-Id: <997361977.15234.0.nnrp-08.d4f094e4@news.demon.co.uk>
Whoops, Bart answered my question already - apologies
"Paul Fortescue" <paul@net366.com> wrote in message
news:997361421.14994.0.nnrp-08.d4f094e4@news.demon.co.uk...
> I do
>
> open (X, "fred")
> while ($line=readline(X)) {
> #returns nothing
> }
>
> but
>
> while ($line=readline(*X)) {
> #works
> }
>
> What have I missed about a 'typeglob' or something, please?
>
>
------------------------------
Date: Thu, 09 Aug 2001 14:02:35 +0300
From: Roman Khutkyy <sky@mail.lviv.ua>
Subject: ImageMagick, Tk, and PNG ---- HELP
Message-Id: <3B726DCB.DBA2CB34@mail.lviv.ua>
I work with ImageMagick.
The PROBLEM is:
i just read any BMP image, get its height and width,
change its type to PNG and save. All is simple.
When i run it without usin Tk - all goes well.
But when i use Tk the program generates PNG file
whith error (it's impossible open it in graphic editor).
I compared two generated files in text editor. In my second
case there is problem whith header (must be %PNG).
In case when i convert BMP to JPG everything is fine
in both programs.
Can anybode say me - what's going on.
------------------------------
Date: Thu, 9 Aug 2001 22:00:44 +1000
From: mgjv@tradingpost.com.au (Martien Verbruggen)
Subject: Re: ImageMagick, Tk, and PNG ---- HELP
Message-Id: <slrn9n4urc.cq.mgjv@martien.heliotrope.home>
On Thu, 09 Aug 2001 14:02:35 +0300,
Roman Khutkyy <sky@mail.lviv.ua> wrote:
> I work with ImageMagick.
> The PROBLEM is:
> i just read any BMP image, get its height and width,
> change its type to PNG and save. All is simple.
> When i run it without usin Tk - all goes well.
> But when i use Tk the program generates PNG file
> whith error (it's impossible open it in graphic editor).
> I compared two generated files in text editor. In my second
> case there is problem whith header (must be %PNG).
And what exactly is the header if it isn't %PNG, and does the rest of
the data look better?
Is there an error message coming out of the Write()?
What happens if you don't save the file, but just call Display() on it?
> In case when i convert BMP to JPG everything is fine
> in both programs.
>
> Can anybode say me - what's going on.
Hmmm... Maybe Tk is linked against a different version of the PNG
library than Image::Magick? Or maybe Tk defines symbols that the PNG
library also defines? Have you checked which shared libraries Magick.so
and Tk.so need and load (ldd on unices)?
Maybe you should recompile ImageMagick, PerlMagick and Tk.
I have no problem at all using the following program:
#!/usr/local/bin/perl
use warnings;
use strict;
use Image::Magick;
use Tk;
my $im = Image::Magick->new();
$im->Read('leopard.tif');
$im->Write('leopard.png');
leopard.png comes out perfectly fine, with or without Tk loaded. I'd say
there's something wromg with your setup.
Martien
--
Martien Verbruggen |
Interactive Media Division | Can't say that it is, 'cause it
Commercial Dynamics Pty. Ltd. | ain't.
NSW, Australia |
------------------------------
Date: Thu, 9 Aug 2001 13:31:07 +0100
From: "Terry" <dcsnospam@ntlworld.com>
Subject: Is it a number?
Message-Id: <Lmvc7.12678$e%3.1512312@news2-win.server.ntlworld.com>
Hello,
I'm just trying to check if a value entered into an input field in a form is
a number.
Is there a function I'm missing?
TIA
Terry
--
remove nospam to reply
------------------------------
Date: 09 Aug 2001 16:56:59 +0400
From: Ilya Martynov <ilya@martynov.org>
Subject: Re: Is it a number?
Message-Id: <87u1zh75no.fsf@abra.ru>
T> Hello,
T> I'm just trying to check if a value entered into an input field in a form is
T> a number.
T> Is there a function I'm missing?
It is in Perl FAQ. Read 'perldoc -q determine'
--
-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-
| 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: 9 Aug 2001 10:56:41 GMT
From: anno4000@lublin.zrz.tu-berlin.de (Anno Siegel)
Subject: Re: mresolv2 and sockets on HP-UX 10.20
Message-Id: <9ktq99$50k$1@mamenchi.zrz.TU-Berlin.DE>
According to Mike <junkeater12@yahoo.com>:
> <originally posted in comp.lang.perl by mistake>
>
> Hello all,
>
> I've been using Perl for a few years, but never sockets (in any
> language) until now. I'm trying to get a script given to me working
> under HP-UX 10.20 and Perl 5.005_02 (our current in-house production
> version - upgrading is not an option right now unless really needed)
> which was based on mresolv2 1.3 (http://www.fuhr.org/~mfuhr/perldns/).
> When the script runs, the socket bind fails with an "Invalid
> argument". So, I thought, since the script is based on mresolv2, let
> me try the original, unchanged mresolv 1.3. I did, and I get the same
> thing, an "Invalid argument", specifically:
>
> can't bind socket: Invalid argument at mresolv2.pl line 58.
[...]
In calls like bind(), Perl only passes things back and forth between
your program and the operating system, so "Invalid argument" is
really a message created by the corresponding system- (or library-)
call. The thing to do at this point is look up the error you get
in the original man page, "man bind". Look for EINVAL under ERRORS.
In my Linux system, there is only one possible cause: "The socket
is already bound to an address", but you should check on HP-UX.
I don't know where this may lead to, but that's the way to get
started.
Anno
------------------------------
Date: 9 Aug 2001 03:34:24 -0700
From: grunge12345@hotmail.com (Grunge Man)
Subject: Re: Not matching strings
Message-Id: <8371f728.0108090234.e2dfff0@posting.google.com>
Thank you all for your replies.
The answer I was looking for was
if ($string =~ /^(?!.*PAT)/) {
print "hi\n";
}
so thanks to nobull and Ren.
The purpose of this is to allow passing of a variety of regular expressions
on the command line to a complex report style program - some RE's are
matching expressions, and some are non-matching.
Hence "ne", "unless", and "!" solutions wouldn't help....
although I could do this by adding some logic to work out whether
!~ or =~ should be used... but having found the last RE in this post in
the Perl Cookbook, I was interested in knowing if there was a direct method.
Efficiency is not a problem for me as only a few hundred matches
need to be done on a v. fast Sun box, late at night, no-one else on
etc, etc.
If there is a solution involving code references, I am interested in
learning about it. I have most major Perl books (not necessarily all
read...) so any book/chapter pointers would be appreciated.
Possibly the guy who had a problem with my initial code:
if ($string =~ /^(?:(?!PAT)|.)*$/) {
print "hi\n";
}
had trailing carriage returns. You can fix this by adding an s qualifier
to the end of the RE as in:
if ($string =~ /^(?:(?!PAT)|.)*$/s) {
print "hi\n";
}
Regards
G
------------------------------
Date: Thu, 9 Aug 2001 12:15:31 +0100
From: "Matthew Forsythe" <m.forsythe@zenithrs.ie>
Subject: Re: online editing of a text form
Message-Id: <3b72754b@ie-news.utvinternet.com>
Why not ftp into the web server and download the txt file; modify it; send
it back?
matt
"Simon Whittaker" <simonNOSPAM@swbh.net> wrote in message
news:HL5B6.5043$Ow3.1086021@news2-win.server.ntlworld.com...
> I would like to be able to edit a file that is stored on my server through
a
> www interface. I can only run cgi files from my cgi-bin and therefore
cannot
> use backpage.cgi because I want to access a directory higher up than the
> cgi-bin. Is there another way around this?
>
> Any help would be gratefully received.
>
> Cheers
>
> Simon
> Sorry I haven't explained myself clearly - any questions email me
> simon@swbh.net
>
>
>
------------------------------
Date: 9 Aug 2001 05:59:26 -0700
From: charlie@disc7.com (Charlie Abbott)
Subject: perl - write text file to server help
Message-Id: <3250787.0108090459.3220c579@posting.google.com>
hi folks,
does anyone know of a free or pay perl script that will write and
update a text file to a server? also it would need a redirect once the
file has been updated.
thanks in advance for your help,
Chas
------------------------------
Date: 9 Aug 2001 10:50:33 GMT
From: Ilmari Karonen <iltzu@sci.invalid>
Subject: Re: Perl dumps core :-(.
Message-Id: <997353193.11587@itz.pp.sci.fi>
In article <9kf02f$65b$2@flood.xnet.com>, Hemant Shah wrote:
>
> The script that scans Java code dies with segmentation fault in some of the
> program. It fails on the different lines in Java programs, but at the same
> point in perl script.
Well, that definitely looks like a bug in perl. You ought to use the
'perlbug' program to report it.
If you wanted to be really helpful, you could test it on the latest perl
release you can find (preferably a development snapshot, read 'perldoc
perlhack' to find out how to get one) compiled with -Doptimize=-g to see
if the bug is still there and to get better debugger output. But just
submitting a bug report should generally be enough.
>Segmentation fault in free_y at 0xd016cf18
>0xd016cf18 (free_y+0x16c) 8107000c lwz r8,0xc(r7)
>(dbx) t
>free_y(??, ??) at 0xd016cf18
>free(??) at 0xd016b0a0
>Perl_safefree(??) at 0x10023e64
>Perl_mg_free(??) at 0x1000fb60
>Perl_leave_scope(??) at 0x1000be8c
>Perl_pop_scope() at 0x100094f0
>Perl_pp_leavesub() at 0x10006d6c
Looks like another scoping bug. One of the easier ways to get segfaults
in perl. I hope perl6 will have something more stable than the current
savestack mess.
One of the side effects of the current implementation is that, depending
on what the exact cause is, you could have trouble reproducing the bug.
The problem is that it's easy for sloppy scope clearing to get swept
under the carpet, where it may or may not stay safely hidden.
--
Ilmari Karonen -- http://www.sci.fi/~iltzu/
"Get real! This is a discussion group, not a helpdesk. You post something,
we discuss its implications. If the discussion happens to answer a question
you've asked, that's incidental." -- nobull in comp.lang.perl.misc
------------------------------
Date: Thu, 9 Aug 2001 08:34:41 -0400
From: "Tom Steuver" <steuver@nku.edu>
Subject: Perl for VMS - use IO::Socket::INET
Message-Id: <tn50stcqrunube@corp.supernews.com>
Is there an equivalent in Perl for VMS for use IO::Socket::INET?
Thanks,
Tom Steuver
Northern Kentucky University
------------------------------
Date: 9 Aug 2001 11:45:28 GMT
From: anno4000@lublin.zrz.tu-berlin.de (Anno Siegel)
Subject: Re: Perl not releasing lock on file under Windows??
Message-Id: <9ktt4o$9el$1@mamenchi.zrz.TU-Berlin.DE>
According to Carlos C. Gonzalez <miscellaneousemail@yahoo.com>:
> In article <3B71BC85.60803@post.rwth-aachen.de>, Tassilo von Parseval at
> Tassilo.Parseval@post.rwth-aachen.de says...
>
> > You should better not define a constant TRUE and FALSE. This is
> > something that comes from other programming languages and might cause
> > problems in Perl. This may work for scalars but matters get more complex
> > under different circumstances, such as lists and hash-elements.
> > I can't give you a definite example now where this might fail....I just
> > remember Randal once giving some code-snippets where a mere TRUE or
> > FALSE would break your script.
>
> Interesting Tassilo. I never thought of that. I will have to check into
> this.
The reason for not using constants TRUE and FALSE is that people will
be tempted to compare results to these constants directly, expecting
"if ( <expr> )" to be the same thing as "if ( <expr> eq TRUE)" and
"unless ( <expr>)" the same as "if ( <expr> eq FALSE)". But the values
that are true or false in boolean context are by no means unique[1], so
these equivalences don't hold in general, no matter which values you
actually assign to TRUE and FALSE.
Anno
[...]
[1] Truth is even system-dependent: On my machine, 1e-323 evaluates
to true and 1e-324 to false. On different hardware this might
be different.
------------------------------
Date: Thu, 09 Aug 2001 12:06:49 GMT
From: Bart Lateur <bart.lateur@skynet.be>
Subject: Re: Perl Search Engine
Message-Id: <qgu4ntg6png8e6ve9urd6900r3fb3d2r3n@4ax.com>
Antoine Hall wrote:
>Yeah, but I have a text extensive website with over 300 pages and I would
>have to search every page....would I need to build some kind of index table
>or file?
Yup. There was an article about this in a DDJ issue once, jan1999, by
Tim Kientzle. The idea is that you extract a list of words from every
file, and that you add a link to that file for each word in the list.
The article isn't online, but the source is:
<http://www.ddj.com/ftp/1999/1999_01/perlsrch.txt> (short listings,
explaining the concept), and
<http://www.ddj.com/ftp/1999/1999_01/perlsrch.zip> (full source)
--
Bart.
------------------------------
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 1474
***************************************