[12837] in Perl-Users-Digest
Perl-Users Digest, Issue: 247 Volume: 9
daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Sat Jul 24 23:07:18 1999
Date: Sat, 24 Jul 1999 20:05:07 -0700 (PDT)
From: Perl-Users Digest <Perl-Users-Request@ruby.OCE.ORST.EDU>
To: Perl-Users@ruby.OCE.ORST.EDU (Perl-Users Digest)
Perl-Users Digest Sat, 24 Jul 1999 Volume: 9 Number: 247
Today's topics:
Re: Amateur (Neko)
Re: Amateur (Larry Rosler)
another mail question <NOSPAMebin111@yahoo.com>
Re: Best Perl book? (brian d foy)
command line input <doyleed@sprynet.com>
Re: FAQ 9.19: How do I send mail? (Michael Wang)
Re: Geekspeak Programming Contest (Anno Siegel)
Re: Geekspeak Programming Contest (Alan Stewart)
Globs and such (RPJOSE82)
Re: help using GET to pul down an HTML document (David Efflandt)
Re: its 1.30am and time to ask for help - eval (brian d foy)
LWP won't compile into freestanding exe <dgreer@connectnet.com>
Re: Odd Behavior (Garth Sainio)
Re: Odd Behavior (Larry Rosler)
Re: Odd Behavior (Michael Rubenstein)
Re: Odd Behavior (Abigail)
Re: output of print map ( { unless (/^#/) {} } ("#") ); (Anno Siegel)
Re: perl-DBI-mysql (brian d foy)
problem for autoforwarding <kenny@autoemail.net>
Re: Reading Data from a file to a variable? (Larry Rosler)
Realsysytem and perl <jfrey@bon.net>
Re: regex mathcing (Anno Siegel)
Re: Regex Problem - I think (r j huntington)
Re: regexp help (Larry Rosler)
Re: the number of fields in a form (David Efflandt)
Re: Variables in Regx? (Abigail)
Where all of the quotes come from (was Re: Perl Cookbo (Michael Wang)
Which group is appropriate? <kejoki@netdoor.com>
Digest Administrivia (Last modified: 1 Jul 99) (Perl-Users-Digest Admin)
----------------------------------------------------------------------
Date: 25 Jul 1999 01:16:00 GMT
From: tgy@chocobo.org (Neko)
Subject: Re: Amateur
Message-Id: <7ndogg$s12$0@216.39.141.200>
On Sat, 24 Jul 1999 16:19:00 -0700, lr@hpl.hp.com (Larry Rosler) wrote:
>In article <7nd9vq$p5c$1@216.39.141.200> on 24 Jul 1999 21:08:10 GMT,
>Neko <tgy@chocobo.org> says...
>...
>> Perhaps perl optimizes this to read only two lines and seek to the end of the
>> file (I do not know this to be true):
>>
>> ($wordline, $locks) = <CONFI>;
>
>How could it? Some absolute dumbhead might want to know the total
>number of lines in the file.
>
> $count = ($wordline, $locks) = <CONFI>;
I suspect perl could optimize the former and not the latter. I also suspect
perl does neither but would like to proved wrong.
>[This is provoked by another current thread about transferring the count
>from the far right through a list assignment to a scalar.]
It's not such a bad idiom if the list isn't empty. One line versus four:
$count = ($one, $two) = <>;
$count = 2;
$one = <>;
$two = <>;
$count++ while <>;
--
Neko | tgy@chocobo.org | Will hack Perl for a moogle stuffy! =^.^=
------------------------------
Date: Sat, 24 Jul 1999 19:15:56 -0700
From: lr@hpl.hp.com (Larry Rosler)
Subject: Re: Amateur
Message-Id: <MPG.1204133327ca957b989d40@nntp.hpl.hp.com>
In article <7ndogg$s12$0@216.39.141.200> on 25 Jul 1999 01:16:00 GMT,
Neko <tgy@chocobo.org> says...
> On Sat, 24 Jul 1999 16:19:00 -0700, lr@hpl.hp.com (Larry Rosler) wrote:
> >In article <7nd9vq$p5c$1@216.39.141.200> on 24 Jul 1999 21:08:10 GMT,
> >Neko <tgy@chocobo.org> says...
> >...
> >> Perhaps perl optimizes this to read only two lines and seek to the end of the
> >> file (I do not know this to be true):
> >>
> >> ($wordline, $locks) = <CONFI>;
> >
> >How could it? Some absolute dumbhead might want to know the total
> >number of lines in the file.
> >
> > $count = ($wordline, $locks) = <CONFI>;
>
> I suspect perl could optimize the former and not the latter. I also suspect
> perl does neither but would like to proved wrong.
That's easy to test.
#!/usr/local/bin/perl -w
use strict;
my ($x, $y) = <DATA>;
print "\$. = $.\n";
__END__
foo
bar
baz
quux
Output:
$. = 4
And of course if there is a scalar count stored also.
> >[This is provoked by another current thread about transferring the count
> >from the far right through a list assignment to a scalar.]
>
> It's not such a bad idiom if the list isn't empty. One line versus four:
>
> $count = ($one, $two) = <>;
>
> $count = 2;
> $one = <>;
> $two = <>;
> $count++ while <>;
Sure. The horror is the null list -- one line vs two, but at what cost!
--
(Just Another Larry) Rosler
Hewlett-Packard Laboratories
http://www.hpl.hp.com/personal/Larry_Rosler/
lr@hpl.hp.com
------------------------------
Date: Sat, 24 Jul 1999 17:31:31 -0700
From: "e-bin" <NOSPAMebin111@yahoo.com>
Subject: another mail question
Message-Id: <J_sm3.341$Iy.21635@typhoon-sf.snfc21.pbi.net>
Thank you once again for the previous help regarding this question, now I am
stuck on the Mail::Mailer module. I have downloaded and followed the
directions to install Mailtools 13 as stated in the directions. (Something
like "perl makefile.pl dmake, dmake test, and then dmake install"). After
that I went ahead and tried to test a sample script stated here:
---------------------------------------------------------------------
use Mail::Mailer;
$from_address="bob\@concentric.net";
$to_address="jkuhnert\@pacbell.net";
$subject="Just a TEST!!!";
$mailer=Mail::Mailer->new();
$mailer->open({ From => $from_address,
To => $to_address,
Subject => $subject,
})
or die "Can't open: $!\n";
print $mailer $body;
$mailer->close();
---------------------------------------------------------------------
And at the DOS prompt I am getting the message: "No mailer type specified
(and no default available)., thus cannot find executable program at mail.pl
line 8.
The documentation specified that this might be a good alternative to using
"sendmail", but from what the error status said, it almost sounds like it
still wants some type of mail server.. Am I missing something here?
Note: This is my first time installing, running, anything with modules as of
yet..
George
------------------------------
Date: Sat, 24 Jul 1999 21:48:01 -0400
From: brian@pm.org (brian d foy)
Subject: Re: Best Perl book?
Message-Id: <brian-ya02408000R2407992148010001@news.panix.com>
In article <7ndbdj$r9v$1@plonk.apk.net>, "Jody Fedor" <JFedor@datacom-css.com> posted:
> Unigni wrote in message ...
> >I have a little programming experience, and want to start learning Perl,
> >probably for CGI use on the Web... Can anybody suggest what would be the
> >best book(s) to get?
> CGI/Perl Cookbook - Wiley - Patchett & Wright
that book is only good for developing bad habits. don't beleive the
celebrity endorsements.
--
brian d foy
CGI Meta FAQ <URL:http://www.smithrenaud.com/public/CGI_MetaFAQ.html>
Perl Monger Hats! <URL:http://www.pm.org/clothing.shtml>
------------------------------
Date: Sat, 24 Jul 1999 22:51:21 -0400
From: "Ed Doyle" <doyleed@sprynet.com>
Subject: command line input
Message-Id: <7ndtt9$1j7$1@nntp2.atl.mindspring.net>
Hi,
In DOS, I can write a batch file to take arguments on the command line and
process them inside the batch file. For example I might have a file called
hello.bat and it might have a line like type %1 and if I call this file from
a dos window like this
hello Ed
I would expect it to type Ed
Can I do a similar thing with Perl.
More speciffically, from the command line I want to pass in the names of
some input files and have them assigned to variables inside the perl
program.
Thanks for any help.
Ed
ps - I am on a windows 95 machine if that matters.
------------------------------
Date: 25 Jul 1999 02:40:59 GMT
From: mwang@tech.cicg.ml.com (Michael Wang)
Subject: Re: FAQ 9.19: How do I send mail?
Message-Id: <7ndtfr$mfb$1@news.ml.com>
Tom Christiansen <perlfaq-suggestions@perl.com> wrote:
> open(SENDMAIL, "|/usr/lib/sendmail -oi -t -odq")
> or die "Can't fork for sendmail: $!\n";
> print SENDMAIL <<"EOF";
> From: User Originating Mail <me\@host>
> To: Final Destination <you\@otherhost>
> Subject: A relevant subject line
>
> Body of the message goes here after the blank line
> in as many lines as you like.
> EOF
> close(SENDMAIL) or warn "sendmail didn't close nicely";
>
If I want to send mail to more than one address, what is the
"best" way? Use "Final Destination1 <you1\@otherhost>, Final
Destination2 <you2\@otherhost>" or fork sendmail multiple times?
Thanks.
--
Michael Wang
http://www.mindspring.com/~mwang
------------------------------
Date: 25 Jul 1999 01:47:06 -0000
From: anno4000@lublin.zrz.tu-berlin.de (Anno Siegel)
Subject: Re: Geekspeak Programming Contest
Message-Id: <7ndqaq$4f2$1@lublin.zrz.tu-berlin.de>
Tom Christiansen <tchrist@mox.perl.com> wrote in comp.lang.perl.misc:
> [courtesy cc of this posting mailed to cited author]
>
>In comp.lang.perl.misc,
> rjk@linguist.dartmouth.edu (Ronald J Kimball) writes:
>:> * Microsoft's mistakes = virii
>:Tsk tsk... I know you know better than that, Tom. ;)
>
>Users say "Microsoft design flaws". Lusers say "virii".
>
> one of them = virus
> two of them = virii
> three of them = viriii
> four of them = viriv
> five of them = virv
> six of them = virvi
Does that mean that no virus = vir?
Oh, and I have an ancient 6502 cpu. Yes, really ancient, it says
"Made in us".
Anno
------------------------------
Date: Sun, 25 Jul 1999 02:17:35 GMT
From: astewart@spawar.navy.mil (Alan Stewart)
Subject: Re: Geekspeak Programming Contest
Message-Id: <379a72f7.1321700494@news.pwy1.sdca.home.com>
I am inspired to post long off topic OS/language-bashing messages and
then justify them in this group by wrapping them with a bit of Perl
code.
However, I am not well known, so few will jump on my bandwagon.
On Sat, 24 Jul 1999 15:25:13 -0700, lr@hpl.hp.com (Larry Rosler)
wrote:
>[Posted and a courtesy copy sent.]
>
>In article <379a3095@cs.colorado.edu> on 24 Jul 1999 15:31:01 -0700, Tom
>Christiansen <tchrist@mox.perl.com> says...
>> This is for inspiration.
>>
>> --tom
>>
>> #!/usr/bin/perl
>> #
>> # geekspeak correspondence lister
>> # tchrist@perl.com
>...
>
>I am inspired to post code without '-w' and 'use strict;' in the future.
>:-)
>
>--
>(Just Another Larry) Rosler
>Hewlett-Packard Laboratories
>http://www.hpl.hp.com/personal/Larry_Rosler/
>lr@hpl.hp.com
------------------------------
Date: 25 Jul 1999 02:14:22 GMT
From: rpjose82@aol.com (RPJOSE82)
Subject: Globs and such
Message-Id: <19990724221422.28685.00001070@ng-cg1.aol.com>
I am reading the "Camel" book, and it is talking about references and globs.
Although it seems to give a pretty good explanation, I still find myself
confused. Could anyone help me with what exactly these are and how they are
used? Thanks!
R.Joseph
------------------------------
Date: 25 Jul 1999 00:47:34 GMT
From: efflandt@xnet.com (David Efflandt)
Subject: Re: help using GET to pul down an HTML document
Message-Id: <slrn7pknsm.ir.efflandt@efflandt.xnet.com>
On Thu, 22 Jul 1999 11:50:11 -0700, Jason Gabriel <<nospam> wrote:
>This works great on servers that are not using HTTP 1.1 redirection. The
>page is there but the server returns "Not Found" because my hosting service
>has multiple domains on 1 ip address using HTTP 1.1 redirection with IIS 4.
>So what happens is that www.intrasonic.com/main.htm is there but this code
>below will not find it because of the redirection.
That is actually referred to as virtual hosting, not redirection. You
need to send a Host: header to the server, so it knows which one you are
referring to.
>Pleeasss help me! I would really appreciate any help.
>
>
>use IO::Socket;
>$browser = IO::Socket::INET->new(
> Proto => "tcp",
> PeerAddr => "www.intrasonic.com",
> PeerPort => "http(80)",
>);
>$browser->autoflush(1);
>print $browser "GET /main.htm HTTP/1.0\n\n";
Instead try:
print $browser "GET /main.htm HTTP/1.0\nHost: www.intersonic.com\n\n";
>print "Content-type: text/html\n\n";
>while (<$browser>) {
> print;
>}
>close $browser;
>
>
>
>
--
David Efflandt efflandt@xnet.com http://www.xnet.com/~efflandt/
http://www.de-srv.com/ http://cgi-help.virtualave.net/
------------------------------
Date: Sat, 24 Jul 1999 21:38:39 -0400
From: brian@pm.org (brian d foy)
Subject: Re: its 1.30am and time to ask for help - eval
Message-Id: <brian-ya02408000R2407992138390001@news.panix.com>
In article <slrn7pkj6t.8hn.eric@plum.fruitcom.com>, eric@fruitcom.com posted:
> I am not winning trying to get eval to do what I want.
>
> Here is my effort
>
> #!/usr/bin/perl -w
> $one="print";
> $two="'Hello World'";
> print "@ARGV \n";
> print "print \"";
> for $i (0..$#ARGV){
> if ($i == $#ARGV) {$array .= "/$ARGV[$i]/\"\;"} else
> {$array .= "/$ARGV[$i]/ and "}
>
>
> }
$array = join( ' and ', map { "/\\Q$_/" } @ARGV);
make sure you get the \Q in there unless you want regex metacharacters
to be interpreted as such. you're also going to need to watch out for
the / character in the input so your string comes out syntactically
correct.
> print $array;
> eval $array;
> eval $one . $two;
what are you trying to do? that is, what behaviour are you trying
to get? if you are trying to match against something in $_, then
you need something in $_ for it to succeed. what's supposed to be
in @ARGV?
--
brian d foy
CGI Meta FAQ <URL:http://www.smithrenaud.com/public/CGI_MetaFAQ.html>
Perl Monger Hats! <URL:http://www.pm.org/clothing.shtml>
------------------------------
Date: Sat, 24 Jul 1999 17:55:59 -0700
From: David Greer <dgreer@connectnet.com>
Subject: LWP won't compile into freestanding exe
Message-Id: <379A609F.170F1FA3@connectnet.com>
When I compile a script using ActiveCorp's PDK PerlApp script into a
freestanding exe it compiles fine, but when run gives the following
error:
Can't locate LWP in @INC (@INC contains: . C:\TEMP\crunch) at (eval 1)
line 109, <FILECHUNK> chunk 1.
crunch is the name of the script and FILECHUNK is a file handle used
within the script. LWP is used in the script. Anybody run into any
thing of this sort?
David Greer
------------------------------
Date: Sat, 24 Jul 1999 20:11:35 -0400
From: modred@shore.net (Garth Sainio)
Subject: Re: Odd Behavior
Message-Id: <modred-2407992011350001@gniqncy-s03-155.port.shore.net>
In article <btd18vpd.fsf@wind.localdomain>, llornkcor
<llornkcor@llornkcor.com> wrote:
!! Why does this line
!! print "<a href=\"$file\">$file</a><BR>";
!!
!! give an output of
!!
!! <a href="myfile
!! ">myfile
!! </a><BR>
!!
!! Is there anyway to get this to output without the magical new lines?
There is an embedded newline in $file. Try putting the line chomp($file);
before the print.
Garth
--
Garth Sainio "Finishing second just means you were the
modred@shore.net first to lose" - anonymous
------------------------------
Date: Sat, 24 Jul 1999 17:20:53 -0700
From: lr@hpl.hp.com (Larry Rosler)
Subject: Re: Odd Behavior
Message-Id: <MPG.1203f8411a654e7c989d3f@nntp.hpl.hp.com>
[Posted and a courtesy copy sent.]
In article <btd18vpd.fsf@wind.localdomain> on 24 Jul 1999 17:38:38 -
0600, llornkcor <llornkcor@llornkcor.com> says...
> Why does this line
> print "<a href=\"$file\">$file</a><BR>";
>
> give an output of
>
> <a href="myfile
> ">myfile
> </a><BR>
Because the value of $file is "myfile\n". You probably read it in as a
line from a file.
> Is there anyway to get this to output without the magical new lines?
perldoc -f chomp
--
(Just Another Larry) Rosler
Hewlett-Packard Laboratories
http://www.hpl.hp.com/personal/Larry_Rosler/
lr@hpl.hp.com
------------------------------
Date: Sun, 25 Jul 1999 00:32:45 GMT
From: miker3@ix.netcom.com (Michael Rubenstein)
Subject: Re: Odd Behavior
Message-Id: <379a5a93.19377092@nntp.ix.netcom.com>
On 24 Jul 1999 17:38:38 -0600, llornkcor
<llornkcor@llornkcor.com> wrote:
>
>Why does this line
>print "<a href=\"$file\">$file</a><BR>";
>
>give an output of
>
><a href="myfile
>">myfile
></a><BR>
>
>Is there anyway to get this to output without the magical new lines?
They're not magical. $file contains a newline character and
print is printing it. My guess is that you derived $file from
input and forgot to chomp it.
------------------------------
Date: 24 Jul 1999 19:39:54 -0500
From: abigail@delanet.com (Abigail)
Subject: Re: Odd Behavior
Message-Id: <slrn7pkn5i.43e.abigail@alexandra.delanet.com>
llornkcor (llornkcor@llornkcor.com) wrote on MMCLIII September MCMXCIII
in <URL:news:btd18vpd.fsf@wind.localdomain>:
||
|| Why does this line
|| print "<a href=\"$file\">$file</a><BR>";
||
|| give an output of
||
|| <a href="myfile
|| ">myfile
|| </a><BR>
It would if $file ends in a newline.
|| Is there anyway to get this to output without the magical new lines?
Of course. There are many ways. chomp, chop, substr, s///, y///.
Abigail
--
sub f{sprintf$_[0],$_[1],$_[2]}print f('%c%s',74,f('%c%s',117,f('%c%s',115,f(
'%c%s',116,f('%c%s',32,f('%c%s',97,f('%c%s',0x6e,f('%c%s',111,f('%c%s',116,f(
'%c%s',104,f('%c%s',0x65,f('%c%s',114,f('%c%s',32,f('%c%s',80,f('%c%s',101,f(
'%c%s',114,f('%c%s',0x6c,f('%c%s',32,f('%c%s',0x48,f('%c%s',97,f('%c%s',99,f(
'%c%s',107,f('%c%s',101,f('%c%s',114,f('%c%s',10,)))))))))))))))))))))))))
-----------== Posted via Newsfeeds.Com, Uncensored Usenet News ==----------
http://www.newsfeeds.com The Largest Usenet Servers in the World!
------== Over 73,000 Newsgroups - Including Dedicated Binaries Servers ==-----
------------------------------
Date: 25 Jul 1999 01:28:01 -0000
From: anno4000@lublin.zrz.tu-berlin.de (Anno Siegel)
Subject: Re: output of print map ( { unless (/^#/) {} } ("#") );
Message-Id: <7ndp71$4e8$1@lublin.zrz.tu-berlin.de>
Michael Wang <mwang@tech.cicg.ml.com> wrote in comp.lang.perl.misc:
>Anno Siegel <anno4000@lublin.zrz.tu-berlin.de> wrote:
>>
>>This group is meant to be a place to talk about Perl issues. If
>>you don't like it, don't go there. Your generalization is as
>>unwarranted as your exasperation.
>
>First of all, thank you for the post.
>
>I do like to go here and talk about some Perl issues. Try to save people's
>time, I trimmed down my program to one line just to demonstarte a "problem",
>but this causes "wiredness".
The weirdness is still there, though from the context it is easier
to guess what you are getting at.
What I want to do is to create a hash from
>a file of two columns, but it may have empty lines /^\s*$/, comment lines
>/^#/, or comment s:#.*::. So I came up with the following:
>
>%assoc= map({
> if (/^#/ || /^\s*$/) {
> ;
> } else {
> s:#.*::;
> split;
> }
> } <README>);
Woah there. Density of almost Abigailesque proportions. (Of code, that
is, not coder.)
And it's almost correct too. Unlike the overly condensed previous
statement of your problem led me to believe, there is something
you can do about the unwanted return value of the if statement.
Just give it an empty list to return, that is replace the first ";"
with "()". This will interpolate nothingness into the list map
generates, which is what you want.
You should be aware that you rely on split's habit of deleting
trailing null fields when not given a limit. That is, a line
like
name value # this is a comment
interpolates only two fields.
The fact that leading whitespace is stripped with split on the
default pattern may also come into play, depending on your data.
Anno
------------------------------
Date: Sat, 24 Jul 1999 21:46:20 -0400
From: brian@pm.org (brian d foy)
Subject: Re: perl-DBI-mysql
Message-Id: <brian-ya02408000R2407992146200001@news.panix.com>
In article <3799FC57.F544C3BC@gmx.at>, Klaus Oberecker <klaus.oberecker@gmx.at> posted:
> Marten Lehmann wrote:
> >
> > > DBD::mysql::st execute failed: You have an error in your SQL syntax
> > > near
> >
> > the only thing I would suspect is that the string to save the sign '
> > contains. So quote such signs try to use $line=~s/\'/\\\'/g; In the
> > Mysql-Modul there is a function for this: $data=$dbh->quote($data);
> thanks!!! - now it works! - I´ve just quoted the variable $picture ...
>
>
> [...]VALUES (0,'Prename','Surename',0,'$picture')"; [...]
it works or you didn't get any errors? what actually showed up in
your database?
--
brian d foy
CGI Meta FAQ <URL:http://www.smithrenaud.com/public/CGI_MetaFAQ.html>
Perl Monger Hats! <URL:http://www.pm.org/clothing.shtml>
------------------------------
Date: Sat, 24 Jul 1999 22:19:52 -0400
From: kenny <kenny@autoemail.net>
Subject: problem for autoforwarding
Message-Id: <379A7446.9ADFBDED@autoemail.net>
Hi everyone:
How can i autoforward an email with perl?
can i get the RCPT TO: from the envelope ? because RCPT TO is the real
recipent.
thaks in advance!
------------------------------
Date: Sat, 24 Jul 1999 19:48:51 -0700
From: lr@hpl.hp.com (Larry Rosler)
Subject: Re: Reading Data from a file to a variable?
Message-Id: <MPG.12041ae28abd3399989d42@nntp.hpl.hp.com>
[Posted and a courtesy copy sent.]
In article <932842296.132.52@news.remarQ.com> on Sat, 24 Jul 1999
14:45:40 -0400, Scot Gardner <Scot@Cyber-Shopper.com> says...
> I have a script that contains the following
>
> %prices = (
> 'item1','25.99',
> 'item2','21.99',
> 'item3','29.99',
> );
>
> etc.etc.
>
> I want to have this list in a seperate delimited data file, lets say
> products.db then read the data into the %prices
> instead of having them inbeded in the script.
>
> Can someone tell me how to go about this??
> I am new to perl, do I use grep?? to get my data??
#!/usr/local/bin/perl -w
use strict;
my %prices;
# Details of opening the real data file are omitted.
# open FILE, $file or die "Couldn't open '$file'. $!\n";
while (<DATA>) {
chomp; # Because there is a newline on every line.
my ($key, $value) = split ' ', $_, 2;
$prices{$key} = $value;
}
# The following is a bit much for a new Perl programmer, but
# what the hell. I've been 'good' so far.
print map "$_: $prices{$_}\n" => sort keys %prices;
__END__
item1 25.99
item2 21.99
item3 29.99
> Thanks
You're welcome. Now read some good Perl books, starting with 'Learning
Perl'.
> To Your Success
To yours. (NB: *Not* Up ... :-)
--
(Just Another Larry) Rosler
Hewlett-Packard Laboratories
http://www.hpl.hp.com/personal/Larry_Rosler/
lr@hpl.hp.com
------------------------------
Date: Sat, 24 Jul 1999 22:45:10 -0400
From: Joe Frey <jfrey@bon.net>
Subject: Realsysytem and perl
Message-Id: <379A7A34.AEA258C2@bon.net>
Guys and Gals, I'm running a realserver on an NT machine. Hence, I want
to use perl on the NT machine to poll a directory for a file's creation
date down to the second. If the creation date has changed, I want to run
an application with this file. Is this possible? TIA. Joe Frey.
------------------------------
Date: 25 Jul 1999 02:01:58 -0000
From: anno4000@lublin.zrz.tu-berlin.de (Anno Siegel)
Subject: Re: regex mathcing
Message-Id: <7ndr6m$4gp$1@lublin.zrz.tu-berlin.de>
Larry Rosler <lr@hpl.hp.com> wrote in comp.lang.perl.misc:
>In article <7nbqlf$3ba$1@lublin.zrz.tu-berlin.de> on 24 Jul 1999
>07:40:31 -0000, Anno Siegel <anno4000@lublin.zrz.tu-berlin.de> says...
>> Larry Rosler <lr@hpl.hp.com> wrote in comp.lang.perl.misc:
>> >In article <x3yvhba3hsm.fsf@tigre.matrox.com> on Fri, 23 Jul 1999
>> >22:25:45 -0400, Ala Qumsieh <aqumsieh@matrox.com> says...
>> >> pozman@my-deja.com writes:
>> >> > If I have a string and want to know how many occurance there are of
>> >> > another particular string within the first one, is there a regular
>> >> > expression to do that.
>> >>
>> >> $string = 'this is his cat';
>> >> $search = 'is';
>> >>
>> >> $count = () = $string =~ /$search/g;
>> >>
>> >> If this looks cryptic, then you should have a good look at perlre for
>> >> more information of Perl's regexps.
>> >
>> >We discussed this at length a couple of weeks ago.
>> ><URL:http://x30.deja.com/[ST_rn=ps]/getdoc.xp?AN=498727524&search=thread
>> >
>> >In addition to being cryptic (which doesn't bother me a bit :-), this
>>
>> It bothers me, because I don't understand how it works. () provides
[snip detailed question]
>Short answer: That's the way it's implemented.
Ahh, so it's special-cased. Reassuring to know.
[snip enlightening discussion]
Anno
------------------------------
Date: 25 Jul 1999 00:16:18 GMT
From: wolph@merlin.albany.net (r j huntington)
Subject: Re: Regex Problem - I think
Message-Id: <7ndl0i$q93$1@news.monmouth.com>
Jordan Hiller (hiller@email.com) wrote:
: How about this:
: # UNTESTED
:
: $string =~ s#/.*##;
Hi, thanks, Jordan, but I get:
"Can't modify division in scalar assignment..."
However, I think I see where you're going with this and I
will try some things. Am I correct that the .* means
"and everything following" ??? Thanks again, Ralph
------------------------------
Date: Sat, 24 Jul 1999 19:31:00 -0700
From: lr@hpl.hp.com (Larry Rosler)
Subject: Re: regexp help
Message-Id: <MPG.120416bff6ec9e97989d41@nntp.hpl.hp.com>
[Posted and a courtesy copy sent.]
In article <7ncti8$gb0$1@nnrp1.deja.com> on Sat, 24 Jul 1999 17:36:08
GMT, satishc@my-deja.com <satishc@my-deja.com> says...
> I would like to create a regular expression that matches the first of
> the following entries in a log file:
>
> blank (new line)
> some text of varying length
> some text of varying length
> some text of varying length
> some text of varying length
> depending on the entry another line of text
> blank (new line)
> some text of varying length
> some text of varying length
> some text of varying length
> some text of varying length
> depending on the entry another line of text
> blank (new line)
>
> etc..
>
> I'm using:
> @ARGV = ("textfile.txt");
> while (<>) {
> if ([m/(^(\n\s {1}).*\s{1}^(\n\s {1}))/]) {
> print $_;
>
> }
> }
>
> However it returns the entire set of records not just the first one.
> Could someone please help me figure out what I'm doing wrong?
Well, no one has responded so far because your phrasing of the question
isn't the clearest possible and your code is formatted horribly. But
let me give it some guesses.
First of all, your 'if' statement is testing for the truth value of a
reference to an anonymous array which contains one element, the truth
value of a match of a grossly wrong regex. The regex never matches, but
the anonymous array is always created. So this condition is 'true' and
every line prints.
I think you want to read a record at a time in 'paragraph mode'. Read
this section in perlvar, and all will be clear. You will get one record
at a time into $_.
$INPUT_RECORD_SEPARATOR
$RS
$/
> I'd also like to be able to have a user parse by an entry on the second
> line of a record, but have the entire entry returned, not just the
> second line. At this point it seems that I should have the individual
> entries fed as elements into an array and then perform some type of
> search operation on each array element returning only those that match
> the criteria specified by the user. Any ideas if this is this remotely
> correct?
Now that you have the entire record in $_, you can split it on newlines,
or use a regex with the /m modifier, or whatever seems appropriate. I
can't guess any further than that.
So we finally got to possible uses of a regex. Pretty far afield from
your Subject. :-)
--
(Just Another Larry) Rosler
Hewlett-Packard Laboratories
http://www.hpl.hp.com/personal/Larry_Rosler/
lr@hpl.hp.com
------------------------------
Date: 25 Jul 1999 01:19:40 GMT
From: efflandt@xnet.com (David Efflandt)
Subject: Re: the number of fields in a form
Message-Id: <slrn7pkpor.ir.efflandt@efflandt.xnet.com>
On Sat, 24 Jul 1999 12:02:00 +0300, Kaimar <kaimar@ut.ee> wrote:
>hey,
>
>is the number of fields in the form limited?
>i encountered a situation, where the first 16 values are passed to the
>script, but all the others are ignored. what might be the reason for
>that?
>
>hope you can help,
>
>--
>Regards,
>
>Kaimar
Totally irrevelant to this newsgroup, but if you are using GET, that does
have a size limitation. Try using POST.
--
David Efflandt efflandt@xnet.com http://www.xnet.com/~efflandt/
http://www.de-srv.com/ http://cgi-help.virtualave.net/
------------------------------
Date: 24 Jul 1999 19:37:21 -0500
From: abigail@delanet.com (Abigail)
Subject: Re: Variables in Regx?
Message-Id: <slrn7pkn0p.43e.abigail@alexandra.delanet.com>
Larry Rosler (lr@hpl.hp.com) wrote on MMCLIII September MCMXCIII in
<URL:news:MPG.1203e794ea00b135989d3a@nntp.hpl.hp.com>:
** In article <slrn7pk3ss.3ja.abigail@alexandra.delanet.com> on 24 Jul 1999
** 14:11:00 -0500, Abigail <abigail@delanet.com> says...
** > Argouarch (argouarc@idiom.com) wrote on MMCLIII September MCMXCIII in
** > <URL:news:argouarc-2407991048240001@argouarc.dial.idiom.com>:
** > == Here's the problem, I have a dictionary flat file with 30 000 lines, I
** > == want to bold every instance of the defined word in each definition so my
** > == regular expresion has to change for each line (sure dont want to do this
** > == by hand, and was'nt PERL designed just for this crap :=)?.
** > == I also want the html tags inserted in the file itself so I wrote a simpl
** > == utility script to change the file.
**
** > == ($key,$translation)=split(/:/);
** > ==
** > == s/(${$key})/<b>$1<\/b>/g;
** > == }
** > ==
** > == would not work... although I am forcing dereferencing of $key, (I also
** > == tried dereferencing on both side and naively a /$key/<b>$key<\/b>/). It
** > == seems that perl allows variables only on the left side like with the
** > == modifiers e and ee ?!?
** > == Am I missing something here?
** >
** > Why are you trying to dereference $key? What goes wrong with
** >
** > s{$key}{<b>$key</b>}g;
**
** A lot goes wrong if $key contains regex metacharacters. And this has to
** compile a regex for each line. And the /g modifier is superfluous. And
** the split is unnecessary.
Uhm, he said: "I want to bold every instance of the defined word in each
definition". The keyword here being "every". I think the split is useful
and the /g necessary. You are right about the regex metacharacters, but
I was assuming the data was such that it wouldn't have those characters.
If there might be regex metacharacters, a leading \Q would fix that.
** while (<FILE>) {
** s|([^:]+):|<b>$1</b>:|;
** print OUTFILE;
** }
That would bold the keyword. That wouldn't bold the keyword in the
definition.
Abigail
--
sub _'_{$_'_=~s/$a/$_/}map{$$_=$Z++}Y,a..z,A..X;*{($_::_=sprintf+q=%X==>"$A$Y".
"$b$r$T$u")=~s~0~O~g;map+_::_,U=>T=>L=>$Z;$_::_}=*_;sub _{print+/.*::(.*)/s}
*_'_=*{chr($b*$e)};*__=*{chr(1<<$e)};
_::_(r(e(k(c(a(H(__(l(r(e(P(__(r(e(h(t(o(n(a(__(t(us(J())))))))))))))))))))))))
-----------== Posted via Newsfeeds.Com, Uncensored Usenet News ==----------
http://www.newsfeeds.com The Largest Usenet Servers in the World!
------== Over 73,000 Newsgroups - Including Dedicated Binaries Servers ==-----
------------------------------
Date: 25 Jul 1999 02:25:10 GMT
From: mwang@tech.cicg.ml.com (Michael Wang)
Subject: Where all of the quotes come from (was Re: Perl Cookbook 2nd Ed. ?)
Message-Id: <7ndsi6$maf$1@news.ml.com>
Tom Christiansen <tchrist@mox.perl.com> wrote:
>--
>Pointers are sharp tools, and like any such tool, used well they can
>be delightfully productive, but used badly they can do great damage
>(I sunk a wood chisel into my thumb a few days before writing this).
> --Rob Pike
Where do all the quotes come from? Do not seem to come from BSD fortune.
Thanks.
--
Michael Wang
http://www.mindspring.com/~mwang
------------------------------
Date: Sat, 24 Jul 1999 21:49:07 -0500
From: Kevin Kinnell <kejoki@netdoor.com>
Subject: Which group is appropriate?
Message-Id: <379A7B23.237A5761@netdoor.com>
My server gets the following (english) Perl groups:
alt.perl.sockets
comp.lang.perl
comp.lang.perl.announce
comp.lang.perl.misc
comp.lang.perl.modules
comp.lang.perl.tk
perl.porters-gw
Out of these, only c.l.p and c.l.p.misc aren't specific.
Recent posts make it seem that c.l.p will be a defunct group
soon.
Is there a group where Perl novices--who don't have all of
the faqs memorized and are just exploring how to get things
done--should be posting so that they may figure things out
together instead of pestering the experts and exposing them-
selves to the inevitable ridicule that attends learning how
to fit into a new culture?
--
Kevin Kinnell <kejoki@netdoor.com>
------------------------------
Date: 1 Jul 99 21:33:47 GMT (Last modified)
From: Perl-Users-Request@ruby.oce.orst.edu (Perl-Users-Digest Admin)
Subject: Digest Administrivia (Last modified: 1 Jul 99)
Message-Id: <null>
Administrivia:
The Perl-Users Digest is a retransmission of the USENET newsgroup
comp.lang.perl.misc. For subscription or unsubscription requests, send
the single line:
subscribe perl-users
or:
unsubscribe perl-users
to almanac@ruby.oce.orst.edu.
To submit articles to comp.lang.perl.misc (and this Digest), send your
article to perl-users@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.
The Meta-FAQ, an article containing information about the FAQ, is
available by requesting "send perl-users meta-faq". The real FAQ, as it
appeared last in the newsgroup, can be retrieved with the request "send
perl-users FAQ". Due to their sizes, neither the Meta-FAQ nor the FAQ
are included in the digest.
The "mini-FAQ", which is an updated version of the Meta-FAQ, is
available by requesting "send perl-users mini-faq". It appears twice
weekly in the group, but is not distributed in the digest.
For other requests pertaining to the digest, send mail to
perl-users-request@ruby.oce.orst.edu. Do not waste your time or mine
sending perl questions to the -request address, I don't have time to
answer them even if I did know the answer.
------------------------------
End of Perl-Users Digest V9 Issue 247
*************************************