[21787] in Perl-Users-Digest
Perl-Users Digest, Issue: 3991 Volume: 10
daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Fri Oct 18 00:06:04 2002
Date: Thu, 17 Oct 2002 21: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)
Perl-Users Digest Thu, 17 Oct 2002 Volume: 10 Number: 3991
Today's topics:
Re: can't terminate the script? <jackkon@ms29.url.com.tw>
Re: Capitalizing letters in the middle of "word" <nobody@dev.null>
Re: Convert Perl script to C program (and Why was this <Cpt.Fredo@S.S.No.Spam>
Re: Convert Perl script to C program (and Why was this <Cpt.Fredo@S.S.No.Spam>
Re: expanding variables in text strings (Jason Quek)
MLDBM and DB_BTREE <nobody@dev.null>
Re: NDBM_File <bwalton@rochester.rr.com>
Re: Newbie help extracting strings <wksmith@optonline.net>
Re: Newbie help extracting strings (LeshPhilling)
Re: PCL and PERL?? <mgjv@tradingpost.com.au>
Re: Perl and Word (SynonymInfo) (Jay Tilton)
problem with binmode(main::STDIN) in rare cases <rlogsdon@io.com>
Re: Random Character Picker <bernard.el-hagin@DODGE_THISlido-tech.net>
REGEXP probolem (Mark Healey)
Re: REGEXP probolem <mgjv@tradingpost.com.au>
Re: REGEXP probolem <ak@freeshell.org.REMOVE>
Re: REGEXP probolem ctcgag@hotmail.com
Re: REGEXP probolem (Mark Healey)
Re: REGEXP probolem <ak@freeshell.org.REMOVE>
Re: REGEXP probolem ctcgag@hotmail.com
Re: Switching from Python to Perl <derek@wedgetail.com>
Re: Switching from Python to Perl <derek@wedgetail.com>
Thank you for you guys' help (kit)
using regexp to add spaces (Cosmic Cruizer)
Digest Administrivia (Last modified: 6 Apr 01) (Perl-Users-Digest Admin)
----------------------------------------------------------------------
Date: Fri, 18 Oct 2002 10:24:35 +0800
From: "jackkon" <jackkon@ms29.url.com.tw>
Subject: Re: can't terminate the script?
Message-Id: <aonr0f$5ep@netnews.hinet.net>
"Brian McCauley" <nobull@mail.com> ¼¶¼g©ó¶l¥ó
news:u9y98xmd4e.fsf@wcl-l.bham.ac.uk...
> "jackkon" <jackkon@ms29.url.com.tw> writes:
>
> What is probably wrong is your interpretation of what you are
> observing. It has nothing whatever to do with Perl.
>
> You've not told us what you are observing only how you interpreted it.
>
> If your OS is Linux then see the Linux FAQ: "Why Is Free Memory as
> Reported by free Shrinking?".
>
> If your OS is not Linux then see the Linux FAQ anyhow as the concept
> is much the same for most Unix-like OSs.
My OS is linux Mandrake 8.2
but I use the ActivePerl, not the native perl while install
When the script named rpm-qlp.pl prints "Execute Over",
I use the "top" command to watch the process,
and I find the data below.
PID USER PRI NI SIZE RSS SHARE STAT %CPU %MEM TIME COMMAND
1867 root 15 0 6220 1108 368 R 3.9 1.7 24:04 X
2379 jck1 12 0 2200 732 568 S 1.9 1.1 13:15 kdeinit
7136 jck1 19 19 2724 1416 1008 S N 1.9 2.2 17:33 krozat.kss
7425 jck1 17 0 668 512 340 R 1.7 0.8 0:01 top
5 root 10 0 0 0 0 SW 1.5 0.0 0:11 kswapd
7397 root 10 0 63508 46M 42768 R 0.5 77.2 0:31 rpm-qlp.pl
It seems a little strange.
But I don't know why.
------------------------------
Date: Fri, 18 Oct 2002 01:26:23 GMT
From: Andras Malatinszky <nobody@dev.null>
Subject: Re: Capitalizing letters in the middle of "word"
Message-Id: <3DAF637B.2080605@dev.null>
Bill Smith wrote:
> "Dan Skadra" <dskadra@yahoo.com> wrote in message
> news:c1bd7661.0210161027.5ce00f3e@posting.google.com...
>
>>I'm trying to reformat a list of user names in the form 'smith_bob'
>>where the first leters of the fist and last names are sometimes
>>capitalized, sometimes not. What I'd like to do is find a way to
>>capitalize those letters if they aren't already. So, I'd like it to
>>look like 'Smith_Bob', no matter how it is capitalized.
>>
>
>
> Correct capitalization of some names (e.g. surnames beginning with the
> prefix 'Mc') requires more complex rules.
>
If that is a concern you might want to investigate Lingua::EN::NameParse
or Lingua::EN::NameCase; both available from CPAN.
------------------------------
Date: Fri, 18 Oct 2002 01:04:25 GMT
From: "Fredo" <Cpt.Fredo@S.S.No.Spam>
Subject: Re: Convert Perl script to C program (and Why was this group's name changed?)
Message-Id: <t6Jr9.5611$ay1.352187676@newssvr21.news.prodigy.com>
"Joe Schaefer" <joe+usenet@sunstarsys.com> wrote in message
news:m3ptu8u9us.fsf@mumonkan.sunstarsys.com...
> "Alan J. Flavell" <flavell@mail.cern.ch> writes:
>
> > On Oct 17, Jilla Villa inscribed on the eternal scroll:
You still don't get it. This isn't about me. Once again, either address
the issue or don't reply. Simple as that.
------------------------------
Date: Fri, 18 Oct 2002 01:07:35 GMT
From: "Fredo" <Cpt.Fredo@S.S.No.Spam>
Subject: Re: Convert Perl script to C program (and Why was this group's name changed?)
Message-Id: <r9Jr9.5612$sA1.352337070@newssvr21.news.prodigy.com>
"Tad McClellan" <tadmc@augustmail.com> wrote in message
news:slrnaqtvjl.3bg.tadmc@magna.augustmail.com...
> Jilla Villa <jillavilla@otakumail.com> wrote:
>
> > Point taken, but this definately goes both ways. I sincerly hope you
> > don't think people like Tom Christianson, Tad, et al, have been good
> > rolemodels of this preaching? A great example of socially
unexceptable
> > behavoir is the thread titled "HARASSMENT -- Monthly Autoemail".
>
>
> I did not participate in that thread.
>
> Do you have an example of where _I_ was rude?
>
> You keep claiming that I frequently am, so it shouldn't be hard
> to find one to cite.
Oh I've seen plenty of yours. Just go to groups.google.com and enter:
tad rude
That gives all the proof one needs. The "HARASSMENT -- Monthly
Autoemail" was used to show just how far some of the regulars have gone,
and the depressing fact was that he (Tom C) was the author of one of
some of the most used Perl literature. Of course, why would expect you
to understand the problem you have taken part in augmenting?
------------------------------
Date: Fri, 18 Oct 2002 02:45:36 GMT
From: jason@generationterrorists.com (Jason Quek)
Subject: Re: expanding variables in text strings
Message-Id: <3db075c2.1878711@news.starhub.net.sg>
Andreas Kähäri <ak@freeshell.org.REMOVE> wrote:
>Submitted by "Jason Quek" to comp.lang.perl.misc:
>> Hi,
>>
>> The following works:
>>
>> # -----------------------------------------------------------------
>> $one = 'John';
>> $two = 'Doe';
>> $three = 'name';
>>
>> $string = '$one$two is my $three';
>> $string =~ s/(\$\w+)/$1/eeg;
>>
>> print $string; # yields 'JohnDoe is my name'
>> # -----------------------------------------------------------------
>>
>>
>> However, if I have this:
>>
>> # -----------------------------------------------------------------
>> $FORM{'one'} = 'John';
>> $FORM{'two'} = 'Doe';
>> $FORM{'three'} = 'name';
>>
>> $string = '$FORM{\'one\'}$FORM{\'two\'} is my $FORM{\'three\'}';
>> # -----------------------------------------------------------------
>>
>> What is the regular expression I should use to match $FORM{'xxx'}?
>>
>> Any help would be appreciated.
>> Thank you.
>>
>>
>>
>> Jason Q.
>
>
>If you use double quotes, the variables will be interpolated as
>you assign to $string.
>
>$a = 'aaa';
>$b = 'bbb';
>$c = '$a$b hello';
>print $c, "\n";
>
>outputs
>
>$a$b hello
>
>While
>
>$a = 'aaa';
>$b = 'bbb';
>$c = "$a$b hello";
>print $c, "\n";
>
>results in
>
>aaabbb hello
Thank you for your post. Unfortunately, I need to use single quote
marks in this case.
Thanks and regards,
Jason Q.
------------------------------
Date: Fri, 18 Oct 2002 02:25:48 GMT
From: Andras Malatinszky <nobody@dev.null>
Subject: MLDBM and DB_BTREE
Message-Id: <3DAF7168.20506@dev.null>
I've been using the MLDBM module with DB_File as the underlying DBM to
store multi-level hashes, kind of like this:
use strict;
use MLDBM 'DB_File';
tie my %db, 'MLDBM', 'food.db' or die "Trouble opening DB: $!";
my %DB=(apple => {color=>'red', shape=>'round'},
pizza=> {color=>'dont ask', shape=>'flat'},
sausage=> {color=>'brown', shape=>'oblong'}
);
%db=%DB;
untie %db;
# Later...
tie my %food, 'MLDBM', 'food.db' or die "Trouble opening DB: $!";
print join "\n", keys %food;
Of course these stored multi-level hashes don't retain any sort of
order, so when I run the program, I get
apple
sausage
pizza
which has nothing to do with the original order.
Now I'm reading that it is possible to use DB_File with the DB_BTREE
option to store a single-level hash and get the keys back in order:
use strict;
use DB_File;
tie my %db, "DB_File", "sorted_food", O_RDWR|O_CREAT, 0640, $DB_BTREE or
die "Trouble opening DB: $!";
my %DB=(apple => 'healthy',
pizza => 'OK',
pbjelly => 'who knows'
);
%db=%DB;
untie %db;
# Later...
tie my %food, "DB_File", "sorted_food", O_RDWR|O_CREAT, 0640, $DB_BTREE
or die "Trouble opening DB: $!";
print join "\n", keys %food;
So when I run this I get
apple
pbjelly
pizza
i.e., the keys come back in alpha order (or any other order I specify
when I create the database).
What I'd like to do is to combine the two: somehow use MLDBM to store
multi-level structures in a B-tree so the keys always come back sorted.
Of course I could just get the keys in the random order that they come
back in and sort them myself, but since my actual application involves a
50 MB database, this is pretty costly in terms of resources.
So how can I (can I?) combine DB_File's DB-BTREE option and MLDBM?
------------------------------
Date: Fri, 18 Oct 2002 01:24:42 GMT
From: Bob Walton <bwalton@rochester.rr.com>
Subject: Re: NDBM_File
Message-Id: <3DAF62BE.2000407@rochester.rr.com>
Dan Borlovan wrote:
>>can I download this module? Or how else can I tie a ash to a file in
>>NDBM-format?
>>
...
Hmmmm...if your OS supports ndbm files, NDBM_File should probably
already be there. But note that only the finer OS'es support ndbm.
Also, one word of caution: If you have existing ndbm files you would
like to open, you may be out of luck. The exact format of a given ndbm
file is dependent upon the OS it was written under, and maybe the
filesystem, and/or the option configuration when ndbm was compiled. So
a given ndbm file may or may not be readable on a different OS, or even
on a different computer using the same OS. You should not count on
"dbm"-type files of any persuasion for binary portability.
--
Bob Walton
------------------------------
Date: Thu, 17 Oct 2002 22:30:27 GMT
From: "Bill Smith" <wksmith@optonline.net>
Subject: Re: Newbie help extracting strings
Message-Id: <7SGr9.3010$eW3.1997@news4.srv.hcvlny.cv.net>
"Brian McCauley" <nobull@mail.com> wrote in message
news:u9n0pdm31l.fsf@wcl-l.bham.ac.uk...
> "Bill Smith" <wksmith@optonline.net> writes:
>
> > ... the code after my signature.
>
> You should probably avoid using the favorite catch-phrases of people who
> have made themselves deeply unpopular least you pick up some of their
> unpopularity by association.
>
> BTW: By convention a signature in a text/plain internet message starts
> at "\n-- \n" and ends at EOF. There was, in the conventional sense,
> no signature in your message, and if there had been there could have
> been nothing after it.
>
> --
> \\ ( )
> . _\\__[oo
> .__/ \\ /\@
> . l___\\
> # ll l\\
> ###LL LL\\
Thanks for your comments. The format sure seemed reasonable to me.
Bill
------------------------------
Date: 17 Oct 2002 16:54:58 -0700
From: lesh_philling@hotmail.com (LeshPhilling)
Subject: Re: Newbie help extracting strings
Message-Id: <efebfff9.0210171554.37af264@posting.google.com>
tadmc@augustmail.com (Tad McClellan) wrote in message news:<slrnaqtpcg.308.tadmc@magna.augustmail.com>...
> Bob Dover <dover@nortelnetworks.com> wrote:
> > "LeshPhilling" wrote...
> >>
> >> It seems like it should be simple to strip out everything but the
> >> actual URL. I know that the LWP module would make things much easier,
> >> but I wanted to do this as pattern matching exercise. Is what I'm
> >> trying to do that hard, or am I just a thickie?
> >
> > Its not hard.
>
>
> Processing arbitrary HTML _is_ hard.
>
>
>
> > Try perldoc perlre.
>
>
> Doing it with pattern matching is more like "impossible" than "hard".
>
> See:
>
> perldoc -q HTML
>
> "How do I remove HTML from a string?"
>
> for some "hard" examples.
Thanks for the assistance. I seem to get stuck like this a lot when
programming (shell, C, Java, Perl, whatever)--I know what I want done
and I have just enough information to make it seem like I should be
able to do this, but I can't. Maybe that's part of learning to
program, eh?
I am aware of the LWP and other HTML extraction modules (I'm reading
Perl & LWP at the moment), but I wanted to use this example to
practice my regexp skills. I can process the file easily enough and
search every line, I just thought it would be a matter of dropping
everything except what's in between the " (quotes) and I couldn't come
up with a way to do it.
Thanks again for the help. I was unaware of 'perldoc perlre' which
I'm studying now. That should give me more to chew on.
LP
------------------------------
Date: Fri, 18 Oct 2002 09:02:48 +1000
From: Martien Verbruggen <mgjv@tradingpost.com.au>
Subject: Re: PCL and PERL??
Message-Id: <slrnaqugco.q36.mgjv@martien.heliotrope.home>
On Thu, 17 Oct 2002 15:38:50 -0500,
Justin D <justind2@ussonet.net> wrote:
> I'm working on a project that requires printing of documents on
> different sizes of paper and some in simplex while others in duplex.
>
> I can make the decisions of what tray to print out of (for the size of
> paper) and whether or not to print duplex by the name of the files.
>
> This printer uses pcl (doesn't use postscript though).
The only module, that I can find on CPAN is PCL::Simple, and that's very
immature. You could have found out yourself by doing a search on
search.cpan.org.
\begin{offtopic}
This is a printer that can print duplex and has multiple trays, but it
doesn't have a PostScript interpreter? How very strange.
> This script would be running on a linux box for ease of use/programming.
Then I would set up a printer queue that accepts PostScript and speaks
to the printer in its native language. Most linux distributions (if not
all) come with print queue configuration tools that allow you to do
this, normally by utilising ghostscript. As long as Ghostscript has a
native driver you should pick that, otherwise, there should be a generic
PCL driver.
If you need to be able to do duplex printing and stuff, you sould be
able to use the -Z option to lpr(1), or -o to lp(1), or you could use
the Net::LPR module, or you could set up several queue with different
behaviour.
I have been very successful on Solaris and various flavours of linux
setting up PostScript queues for printers that don't know about
PostScript.
\end{offtopic}
Martien
--
|
Martien Verbruggen | You can't have everything, where would you
| put it?
|
------------------------------
Date: Fri, 18 Oct 2002 03:29:02 GMT
From: tiltonj@erols.com (Jay Tilton)
Subject: Re: Perl and Word (SynonymInfo)
Message-Id: <3daf7c53.88053113@news.erols.com>
Sascha Moellering <SaschaMoe@web.de> wrote:
| I want to look up synonyms in Word using Perl and Win32::OLE. My code is:
[Comments on the code are interspersed. A rewrite is hanging out at
the end of this post.]
use strict;
use warnings;
| use OLE;
Use Win32::OLE instead.
And make it chirp about errors instead of silently failing.
Win32::OLE->Option(Warn => 2);
| $application = CreateObject OLE 'Word.Application' || die $!;
| print $ARGV[0];
| $document = $ARGV[0];
| my $language=$application->{wdEnglishUS};
I don't know the correct syntax to get the value of a constant (short
of dredging up Win32::OLE::Const), but that's not it. Specifying the
language should not be necessary unless Word's default is not US
English.
| $application->Documents->Add();
Unless you really need to create a document, don't bother with that.
| $application->{'Visible'} = 0;
Or that.
| open(FILE, $document);
Always check the return value on open().
open(FILE, $document) or die "Cannot open '$document': $!";
| @lines = <FILE>;
| foreach $line (@lines)
Don't do that.
while( <FILE> )
| {
| print $line;
| $synlist = $application->SynonymInfo({Word => $line, LanguageID =>
| $language})->SynonymList;
And there's the show stopper. That silently fails unless the program
is reporting OLE errors. SynonymList requires a parameter.
... ->SynonymList( 1 );
The param tells it which of several meanings for the word you have in
mind. E.g. "too" can mean either "also" or "extremely," and those
have very different lists of synonyms. MeaningList() gives a list of
a word's possible meanings.
| foreach $syn (@synlist)
SynonymList()'s return (an array reference) was correctly assigned to
a scalar, but that is iterating across an array that has nothing to do
with it.
foreach $syn (@$synlist)
"use strict;" would have caught the inconsistency.
| {
| print $syn;
| }
| }
| $application->Quit();
Summing up, Perl and OLE can tell you a lot about what's going wrong,
but you have to ask them to speak up.
| But this doesnot work,
What should the program be doing that it is not doing?
What is the program doing that it should not be doing?
If the program does nothing at all, say just that.
Even that little bit carries more information than "does not work."
#!perl -l
use warnings;
use strict;
use Win32::OLE;
Win32::OLE->Option(Warn => 2); # Carp::carp on error
my $app = Win32::OLE->new('Word.Application')
or die "Could not create OLE object";
my $language = 1033; # wdEnglishUS (Looked it up)
my $doc = $ARGV[0];
print $doc;
open(FILE, '<', $doc)
or $app->Quit(), die "Cannot open '$doc' for read: $!";
while(<FILE>) {
chomp;
my $synonymizer =
$app->SynonymInfo({Word => $_, LanguageID => $language});
print("No synonyms were found for '$_'."), next
unless $synonymizer->Found;
print "Word:$_";
for my $meaning ( @{$synonymizer->MeaningList} ) {
print "\tMeaning:$meaning";
print "\t\tSynonym:$_"
for @{$synonymizer->SynonymList($meaning)};
}
}
close(FILE);
$app->Quit();
__END__
------------------------------
Date: Thu, 17 Oct 2002 22:22:58 -0500
From: Reuben Logsdon <rlogsdon@io.com>
Subject: problem with binmode(main::STDIN) in rare cases
Message-Id: <Pine.LNX.4.44.0210172148140.16570-100000@fnord.io.com>
Hello folks,
One of my Perl CGI scripts starts off by setting binmode on STDIN and
STDOUT. I've found that STDIN needs to be binary to properly handle HTTP
file uploads, and STDOUT as binary works a better when streaming text in a
<pre> tag.
Anyway, the code I use for this is:
unless (binmode(main::STDIN)) {
$err = "unable to set binmode on main::STDIN - $! - $^E";
next Err;
}
and similar for STDOUT, STDERR. This works great for about 2,000
customers on various platforms. I've had 3 customers, all on Windows,
who've complained that this kicks out the error:
"unable to set binmode on main::STDIN - Bad file descriptor - An operation
was attempted on something that is not a socket"
So $! is "Bad file descriptor" which I've seen before but shouldn't apply
here, and then $^E is "An operation was attempted on something that is not
a socket" which ????. Who knows. Does anyone know what is going on here?
I can comment out my binmode calls and then the remainder of the script
works fine, with all of its interaction with STDIN and STDOUT, and so I
know those are valid filehandles. Commenting out my binmode calls is not
a solution though because in general, they're needed on Windows.
Given my 3 problem reports, probably 10-15 customers have had this problem
but only a few reported.
One of these customers gave me access to his system. Environment is
Windows 2000 with Perl 5.006001 but he is a web hosting customer and not
an administrator so details beyond that are not known. My local comp is
also Win2000 w/ P5.006001, but I can't repro his error. On his system, I
have confirmed that STDIN and STDOUT work normally by those base names and
also by main::STDIN and main::SDTOUT, at least for reading and writing. I
have tried the extended call where you pass ':raw' as the second param to
binmode, but behavior is the same. I have confirmed that binmode works
okay if I just open a file and set binmode on the handle. I have
confirmed that STDIN and STDOUT are in binary mode by default, whereas
those handles default to text mode on *my* Windows test systems (hence the
need to add those calls in general).
The behavior is such that I could just call binmode() straight and ignore
the error codes. But I hate to ignore these things. I'd rather tell my
customers with these stupid systems to just not use my software, but I
can't do that in good faith until I've investigated the problem and seen
whether it is legal or common for binmode(STDIN) to fail sometimes.
Anyway, if anyone has an experience with this behavior or suggestions on
how to deal with it, I would be grateful.
Regards,
Reuben
------------------------------
Date: Thu, 17 Oct 2002 12:30:23 +0000 (UTC)
From: Bernard El-Hagin <bernard.el-hagin@DODGE_THISlido-tech.net>
Subject: Re: Random Character Picker
Message-Id: <aomagv$89h$1@korweta.task.gda.pl>
In article <LTxr9.831$XsJ4.25034938@news2.randori.com>, PinkPuppy
wrote:
> Here's what I ended up doing. It's simpler than some of the excellent
> suggestions, but it works...
>
> my @c = ("a","b","c","d","e","f","g","h","i","j","k",
> "l","m","n","o","p","q","r","s","t","u","v","w","x",
> "y","z","A","B","C","D","E","F","G","H","I","J",
> "K","L","M","N","O","P","Q","R","S","T","U","V",
> "W","X","Y","Z","0","1","2","3","4","5","6","7","8","9" );
If you really have to do it that way you can make it easier on the
eyes:
my @c = ('a' .. 'z', 'A' .. 'Z', 0 .. 9);
Cheers,
Bernard
--
echo 42|perl -pe '$#="Just another Perl hacker,"'
------------------------------
Date: 17 Oct 2002 22:57:44 GMT
From: admin@hotmail.com (Mark Healey)
Subject: REGEXP probolem
Message-Id: <dxKndd8YehcW-pn2-sCJrU7LM2dPr@adsl-63-207-135-60.dsl.sndg02.pacbell.net>
Why doesn't /reviews\.gif/ match "reviews.gif"?
Mark Healey
marknews(the 'at' thing)healeyonline.com
------------------------------
Date: Fri, 18 Oct 2002 09:15:00 +1000
From: Martien Verbruggen <mgjv@tradingpost.com.au>
Subject: Re: REGEXP probolem
Message-Id: <slrnaquh3k.q36.mgjv@martien.heliotrope.home>
On 17 Oct 2002 22:57:44 GMT,
Mark Healey <admin@hotmail.com> wrote:
> Why doesn't /reviews\.gif/ match "reviews.gif"?
What makes you say that it doesn't?
$ perl -wl
print "matches" if "reviews.gif" =~ /reviews\.gif/;
__END__
matches
Martien
--
|
Martien Verbruggen | The world is complex; sendmail.cf reflects
| this.
|
------------------------------
Date: Thu, 17 Oct 2002 23:17:14 -0000
From: Andreas =?iso-8859-1?Q?K=E4h=E4ri?= <ak@freeshell.org.REMOVE>
Subject: Re: REGEXP probolem
Message-Id: <slrnaquh7i.ip5.ak@otaku.freeshell.org>
Submitted by "Mark Healey" to comp.lang.perl.misc:
> Why doesn't /reviews\.gif/ match "reviews.gif"?
>
>
> Mark Healey
> marknews(the 'at' thing)healeyonline.com
According to this little program, it matches without a problem:
if ("reviews.gif" =~ /reviews\.gif/) {
print "it matches\n";
} else {
print "it matches not\n";
}
I can't see why it shouldn't.
--
Andreas Kähäri @ New Zealand +------ Have a Unix: netbsd.org
-----------------------------+------ This post ends with :wq
------------------------------
Date: 17 Oct 2002 23:51:45 GMT
From: ctcgag@hotmail.com
Subject: Re: REGEXP probolem
Message-Id: <20021017195145.401$Oy@newsreader.com>
admin@hotmail.com (Mark Healey) wrote:
> Why doesn't /reviews\.gif/ match "reviews.gif"?
In what piece of code?
Xho
--
-------------------- http://NewsReader.Com/ --------------------
Usenet Newsgroup Service
------------------------------
Date: 18 Oct 2002 02:09:07 GMT
From: admin@hotmail.com (Mark Healey)
Subject: Re: REGEXP probolem
Message-Id: <dxKndd8YehcW-pn2-Ddq823NqFumO@adsl-63-207-135-60.dsl.sndg02.pacbell.net>
On Thu, 17 Oct 2002 23:51:45, ctcgag@hotmail.com wrote:
> admin@hotmail.com (Mark Healey) wrote:
> > Why doesn't /reviews\.gif/ match "reviews.gif"?
foreach (@BNContent)
{
...
if (/reviews.gif/)
{
$bnHash{"rate"}="This should be acted upon"; #We'll replace this
with real code when I figure out why it isn't being reached
}
...
}
Mark Healey
marknews(the 'at' thing)healeyonline.com
------------------------------
Date: Fri, 18 Oct 2002 02:23:17 -0000
From: Andreas =?iso-8859-1?Q?K=E4h=E4ri?= <ak@freeshell.org.REMOVE>
Subject: Re: REGEXP probolem
Message-Id: <slrnaqus4c.ip5.ak@otaku.freeshell.org>
Submitted by "Mark Healey" to comp.lang.perl.misc:
> On Thu, 17 Oct 2002 23:51:45, ctcgag@hotmail.com wrote:
>
>> admin@hotmail.com (Mark Healey) wrote:
>> > Why doesn't /reviews\.gif/ match "reviews.gif"?
>
> foreach (@BNContent)
Does @BNContent in fact contain an element which contains the
text string "reviews.gif"?
> {
> ...
$_ doesn't get set to something else here (above), does it?
> if (/reviews.gif/)
> {
> $bnHash{"rate"}="This should be acted upon"; #We'll replace this
> with real code when I figure out why it isn't being reached
> }
> ...
> }
>
> Mark Healey
> marknews(the 'at' thing)healeyonline.com
--
( )
) Andreas Kähäri (
( )
------------------------------
Date: 18 Oct 2002 02:45:14 GMT
From: ctcgag@hotmail.com
Subject: Re: REGEXP probolem
Message-Id: <20021017224514.483$CC@newsreader.com>
admin@hotmail.com (Mark Healey) wrote:
> On Thu, 17 Oct 2002 23:51:45, ctcgag@hotmail.com wrote:
>
> > admin@hotmail.com (Mark Healey) wrote:
> > > Why doesn't /reviews\.gif/ match "reviews.gif"?
>
> foreach (@BNContent)
> {
> ...
> if (/reviews.gif/)
> {
> $bnHash{"rate"}="This should be acted upon"; #We'll
> replace this with real code when I figure out why it isn't being reached
> }
> ...
> }
I would say your problem is that the code doesn't compile. I ran it
and it gave me syntax errors. :)
'...' means something precise in perl, use '# stuff here' to mark
where you elided code.
the following codes works fine:
foreach ("reviews.gif")
{
#...
if (/reviews\.gif/)
{
warn "I'm acting upon it" ; #
}
#...
}
__END__
I'm acting upon it at test.pl line 6.
I would say the devil is in the elipses. Are you implicitly changing
$_ in there?
As a general rule, if you need to elide code (in 3 different places) inside
a loop in order to make it small enough to post, you should probably give
the loop a named iterator.
Xho
--
-------------------- http://NewsReader.Com/ --------------------
Usenet Newsgroup Service
------------------------------
Date: Thu, 17 Oct 2002 01:24:04 GMT
From: Derek Thomson <derek@wedgetail.com>
Subject: Re: Switching from Python to Perl
Message-Id: <Uior9.463$i84.54882@news.optus.net.au>
Benjamin Goldberg wrote:
> Derek Thomson wrote:
>
>>Derek Thomson wrote:
>>
>>>Benjamin Goldberg wrote:
>>>
>>>
>>>>Derek Thomson wrote:
>>>>[snip]
>>>>
>>>>
>>>>>So, Java. Perl really can't win here, as Python has the amazing
>>>>>Jython.
>>>>
>>>>How does Jython compare to JPL, "Java Perl Lingo"?
>>>
>>[snip list of ways Jython beats out JPL]
>>
>>I thought of one other major advantage in favor of Jython. You can
>>actually produce Java bytecode from your Python code, or your
>>Python/Java hybrid, and then ship it as you would any other Java
>>application.
>
>
> Hmm...
>
> Currently, there exists a java->perl6 translator. (Well, it actually
> runs javap on a .class file to get java assembler, then turns it into
> parrot assembler.)
>
> Perhaps in the future, a perl6->java translator will come to be?
>
> Or rather, a parrot bytecode->java bytecode translator :)
Perhaps, in the future. But I need a scripting language that runs on a
JVM *now*.
But yes, if the core language is kept simple enough, someone might do
perl6->java.
parrot bytecode -> java bytecode will also work.
>
> Does python have any kind of "eval" operator, which takes a string and
> parses and executes it as python code?
>
> If so, I don't see how you could omit Jython from any code which uses
> eval.
I had to investigate this. It turns out you can tell Jython to include
enough of the Jython interpreter as bytecodes to allow this, then it
works just fine.
It does mean about 400K extra in your jar file, though. Which isn't
really all that bad. And it's all invisible to the end user ie. it's
just self contained in the jar file, so they don't need to set paths,
alter their JVM, install anything, and so on. Nice!
>
> It's unlikely for perl5, yes. But perl6 will probably be able to be
> compiled down to java bytecode.
Like I said, that doesn't help at the moment. At this point in time,
Python is the clear winner for Java scripting.
>
> And even for perl5, someone with sufficient tuits might decide to try
> and write a B::Java class.
That's possible, but probably the simplest bit. You then have to
implement the Perl runtime libraries (like the regex engine) in Java,
and then all the standard modules.
Jython's already done all this WRT Python over the last few years. It
didn't start out anywhere near as complete as it is at the moment. So,
if someone started this right now, you can expect to wait two years at
an absolute minimum. I guess I'd expect a similar kind of timeframe even
for perl6, unless perl6 itself is going to be written in perl6 so that
the bytecode translater can do the porting of *everything* to the JVM
for us.
So, is perl6 going to be written in perl6?
--
D.
------------------------------
Date: Thu, 17 Oct 2002 01:28:45 GMT
From: Derek Thomson <derek@wedgetail.com>
Subject: Re: Switching from Python to Perl
Message-Id: <hnor9.464$i84.54916@news.optus.net.au>
Hi Josef,
Josef Drexler wrote:
>
> Would Parrot be able to output Java bytecode? Is Perl5 going to be ported
> to Parrot?
>
> My guesses are "yes" and "maybe", so that could be a way of linking Perl
> and Java more closely if you need to.
>
No, it'll be a way of linking Perl and Java *in the future*. As I
explained in my reply to Benjamin Goldberg, I'd expect at least a 2
man-year effort even after perl6 appears on the scene, as you will have
to rewrite all of the perl6 runtime and the standard modules for a JVM.
*Unless* perl6 is going to be implemented in perl6. Then the work can be
done by a parrot bytecode to java bytecode converter.
But even in that case, we have to wait for perl6! At this point in time,
for scripting with Java, Python beats Perl hands down. I like Perl as
much as anyone, but there's simply no doubt about it.
--
D.
------------------------------
Date: 17 Oct 2002 19:55:58 -0700
From: manutd_kit@yahoo.com (kit)
Subject: Thank you for you guys' help
Message-Id: <1751b2b5.0210171855.6126e934@posting.google.com>
I will read carefully for the links and do the proper things in the future...
again ......... Thanks !! =)
Peace,
Kit
------------------------------
Date: Fri, 18 Oct 2002 02:44:41 GMT
From: XcosmicX.XcruizerX@sbcglobal.com (Cosmic Cruizer)
Subject: using regexp to add spaces
Message-Id: <Xns92AAC8C6E909Eccruizermydejacom@64.164.98.29>
The first part is what I can do, but the second part is what I need to
accomplish.
$str = "good to you";
$str =~ s/\good/g o o d/g;
$str =~ s/(\d)/$1 /g;
print "$str";
output is... g o o d to you
But this requires me to manually enter the spaces between the word. I would
like to be able to automatically have the spaces done without having to do
it manually.
This leads to the second part of my problem... "good" may only be the first
part of the word.
For instance, what I would like to do is take the following:
$str = "goodmorning to you";
$str =~ /\good*/; (I don't know what do to here)
print "$str";
and have the output say: g o o d m o r n i n g to you
Any suggestions? Thanks.
------------------------------
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 3991
***************************************