[22167] in Perl-Users-Digest
Perl-Users Digest, Issue: 4388 Volume: 10
daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Sun Jan 12 00:05:46 2003
Date: Sat, 11 Jan 2003 21:05:07 -0800 (PST)
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, 11 Jan 2003 Volume: 10 Number: 4388
Today's topics:
Re: 3d Bar charts (reprint from c.l.p.modules <goldbb2@earthlink.net>
Re: 3d Bar charts (reprint from c.l.p.modules <rickraster@hotmail.comDEL>
ANNOUNCE: pmq 0.1.3 <ed@membled.com>
Re: calculate regexp? <spam@oblomov.org>
Re: calculate regexp? <jurgenex@hotmail.com>
CGI - HTML Generation problems with images - scripts et (Stephen Adam)
Re: CGI - HTML Generation problems with images - script <flavell@mail.cern.ch>
Re: CGI - HTML Generation problems with images - script (David Efflandt)
Re: how to print a hash <semaj_levram@worldnet.att.net>
how to split web page contents download variable by lin (R Solberg)
Re: muli-spaced fields and split() <goldbb2@earthlink.net>
my tricky regexp <spam@oblomov.org>
Re: newline "\n" not working <goldbb2@earthlink.net>
Re: newline "\n" not working <flavell@mail.cern.ch>
Re: perl pattern matching woes <foo@var.com>
Re: Red Hat 8 breaking one-liner signature script <flavell@mail.cern.ch>
Re: Regexps - multisymbol negation question <goldbb2@earthlink.net>
Re: removing duplicate values from array not working... <goldbb2@earthlink.net>
Re: Script to read a wordlist and find words in files/d <goldbb2@earthlink.net>
Re: Using tr/// - Am I barking up the wrong tree? <uri@stemsystems.com>
Digest Administrivia (Last modified: 6 Apr 01) (Perl-Users-Digest Admin)
----------------------------------------------------------------------
Date: Sat, 11 Jan 2003 22:07:45 -0500
From: Benjamin Goldberg <goldbb2@earthlink.net>
Subject: Re: 3d Bar charts (reprint from c.l.p.modules
Message-Id: <3E20DC01.5A7D5474@earthlink.net>
RR wrote:
[snip]
> We are currently running our extensive (and relatively complex)
> reports through MS Access (yeah I know - it's a dog), with an Oracle
> backend. Access does however make nice charts, but it's cranky.
> We're also using GD::Graph from M. Verbruggen for our web graphs (2D
> bar vertical bar graphs - pretty neat actually (with drill-down)), so
> I'm familiar with how to use that, although I haven't had a chance to
> do a whole lot of exploring in that direction.
>
> If anyone has any hints or tips I'd love to hear your opinions!
While I know little about making 3d charts, I would suggest that you
might have better efficiency using DBI and DBD::Oracle to fetch the
data, without going through Access at all.
--
$..='(?:(?{local$^C=$^C|'.(1<<$_).'})|)'for+a..4;
$..='(?{print+substr"\n !,$^C,1 if $^C<26})(?!)';
$.=~s'!'haktrsreltanPJ,r coeueh"';BEGIN{${"\cH"}
|=(1<<21)}""=~$.;qw(Just another Perl hacker,\n);
------------------------------
Date: Sun, 12 Jan 2003 04:10:09 GMT
From: RR <rickraster@hotmail.comDEL>
Subject: Re: 3d Bar charts (reprint from c.l.p.modules
Message-Id: <v6q12vgn2p7cptv4h6rlg24ps1p1uu7oos@4ax.com>
On Sat, 11 Jan 2003 22:07:45 -0500, Benjamin Goldberg
<goldbb2@earthlink.net> wrote:
>RR wrote:
>[snip]
[more snipped]
>While I know little about making 3d charts, I would suggest that you
>might have better efficiency using DBI and DBD::Oracle to fetch the
>data, without going through Access at all.
Sorry if I left that impression. To clarify, although somewhat
off-topic: We are running our Oracle databases with a full intranet
system using DBI and DBD::Oracle, among other things. MS Access is
ONLY used to generate our ~65 page reports, since it has the
capability of creating clean, professional charts and graphs, 3d or
otherwise. Many hundreds of man-hours have gone into making these
reports, but the underlying querying is ALL done via Oracle stored
procedures, views, and piped through Access pass-through queries
(nothing to do with Access really). In other words, Access is not
used per se, only it's reporting capability.
If anyone has anything to add about the 3d charts etc (alternative to
Access) I'd STILL love to hear it!!
;-)
Cheers,
Rick
------------------------------
Date: 11 Jan 2003 21:47:31 +0000
From: Ed Avis <ed@membled.com>
Subject: ANNOUNCE: pmq 0.1.3
Message-Id: <3e20cd72$1_2@news.teranews.com>
pmq is intended to be a user-friendly answer to the two FAQs, 'how do
I find what version of a Perl module is installed?' and 'how do I list
all modules installed on the system?'
'pmq Date::Manip' will print the version of the Date::Manip module, or
'(failed)' if the module is not installed, or for some modules which
don't carry version information, '(unknown)'. 'pmq --all' will print
every module found in Perl's include path with its version - and do so
much quicker than the traditional 'perl -MFoo ...'.
The latest release is 0.1.3. This adds a new -f or --with-filename
flag to print the filename of the .pm file used - like which(1) for
Perl.
The home page of pmq is <http://membled.com/work/perl/pmq/>, or
download it from CPAN as $CPAN/authors/id/E/ED/EDAVIS/pmq-0.1.3.tar.gz.
--
Ed Avis <ed@membled.com>
------------------------------
Date: Sun, 12 Jan 2003 03:19:03 +0100
From: oblomov <spam@oblomov.org>
Subject: Re: calculate regexp?
Message-Id: <20030112031903.1ce2b1ce.spam@oblomov.org>
On Sat, 11 Jan 2003 18:01:34 -0800
"2Host.com - Robert" <admin@-NOSPAM-2host.com> wrote:
>
>
> oblomov wrote:
> >
> > is there any software that calculates a regexp based possible
> > matches?
> >
> > example:
> >
> > [string1].string2(string3)]
> > [string1] string2(string3)]
> >
> > karl
>
> I'm not sure what you mean. How many times there's a match for a
> regular expression, or?
My question is quite complex, sorry for the silly way of puttting it. It
was so clear in my mind and amazed when nobody first understood me, as I
also took the issue to an IRC channel.
I'm looking for a software that analzye the diffrences between a set of
strings, resulting with a regexp matching all the strings.
I do not mean "string1 string2(string3)|string1.string2(string3)"
I mean: \[(.+)[\s.](.+)\(\(.+))\]
string1 string2 and string3 are highlighted, marked as constant areas.
It is the changes between string1 string2 and string3 that I want to
see the changes of.
I want to feed this software with a notation, a language I made up, and
then have the software generate my regexpes. I suck with regexpes.
[Class(multipleAttr:String{5}]
[Class (multipleAttr:String{0..5}]
[Class(multipleAttr:String{1..*}]
[Class(multipleAttr:String{*}]
[Class(multipleAttr:String{*..2}]
[Class.(multipleAttr:String{1..5,7,9..*}]
I mark Class, multipleAttr and String as "constant areas", push a button
and the software creates a regexp that will match all these lines, but
no other line.
pseudo regexp:
\[(.+)[.\s]\(((.+):(.+){(really complex)})\)\]
Aha?
Is there such a software? It would be helpfull if it was more
intelligent than described.
karl
------------------------------
Date: Sun, 12 Jan 2003 05:01:33 GMT
From: "Jürgen Exner" <jurgenex@hotmail.com>
Subject: Re: calculate regexp?
Message-Id: <NE6U9.21404$uL2.4921@nwrddc01.gnilink.net>
oblomov wrote:
> On Sat, 11 Jan 2003 18:01:34 -0800
> "2Host.com - Robert" <admin@-NOSPAM-2host.com> wrote:
>> I'm not sure what you mean. How many times there's a match for a
>> regular expression, or?
> I'm looking for a software that analzye the diffrences between a set
> of strings, resulting with a regexp matching all the strings.
The RE
/./
will match any (non-empty) string and thus fullfill your specification.
> I do not mean "string1 string2(string3)|string1.string2(string3)"
>
> I mean: \[(.+)[\s.](.+)\(\(.+))\]
>
> string1 string2 and string3 are highlighted, marked as constant areas.
> It is the changes between string1 string2 and string3 that I want to
> see the changes of.
>
> I want to feed this software with a notation, a language I made up,
> and then have the software generate my regexpes. I suck with regexpes.
While REs can be used for a lot of things, parsing a language is not one the
typical applications.
It might be possible. It may even be understandable for a _very_ simple
language.
But in general you are better off using a parser to parse a language.
If you want to generate your parser based upon some language description
then please have a look at e.g. lexx, bison, yacc, and all the other parser
generators out there.
[...]
> I mark Class, multipleAttr and String as "constant areas", push a
> button and the software creates a regexp that will match all these
> lines, but no other line.
Ah, ok, so you are really not interested in my trivial "/./" :-)
> Is there such a software? It would be helpfull if it was more
> intelligent than described.
As I said before: you may want to check out parser generators. They are the
right tool for your job, not REs.
jue
------------------------------
Date: 11 Jan 2003 18:54:04 -0800
From: 00056312@brookes.ac.uk (Stephen Adam)
Subject: CGI - HTML Generation problems with images - scripts etc
Message-Id: <945bf980.0301111854.1be30e6b@posting.google.com>
Hi guys and girls
I've just figured out how to generate most HTML with a simple perl
script, i've given the code thats giving me problems. I can print out
text fine, its just images and (java)scipts which don't seem to want
to work. I have tried three different approaches to printing an image
and none of them work. What am i doing wrong? Are there extra
considerations with, scripts, images and CSS's?
Thanks
Steve
#!C:\perl\perl.exe -w
print <<END;
<p>This text works fine </p>
<img src="./steve.gif" alt="HOME PAGE HEADER">
<img src="C:\Program Files\sambar41\cgi-bin\steve.gif" alt="HOME PAGE
HEADER">
<img src="http://localhost/cgi-bin/steve.gif" alt="HOME PAGE HEADER">
END
exit(0);
------------------------------
Date: Sun, 12 Jan 2003 04:17:17 +0100
From: "Alan J. Flavell" <flavell@mail.cern.ch>
Subject: Re: CGI - HTML Generation problems with images - scripts etc
Message-Id: <Pine.LNX.4.40.0301120356190.17046-100000@lxplus070.cern.ch>
On Jan 11, Stephen Adam inscribed on the eternal scroll:
> I've just figured out how to generate most HTML with a simple perl
> script, i've given the code thats giving me problems. I can print out
> text fine, its just images and (java)scipts which don't seem to want
> to work.
You have a mental model problem, which would - as far as I can make
out from your posting - be the same problem if you were programming
your CGI scripts in C, tktcl, FORTRAN, COBOL or whatever.
The history of this newsgroup indicates that you'll now bawl me out
for mentioning that. Nevertheless, I reckon it's factually true.
> I have tried three different approaches to printing an image
It doesn't really look that way.
> and none of them work. What am i doing wrong? Are there extra
> considerations with, scripts, images and CSS's?
Not really - they all follow the same CGI programming interworking
specification. The problem seems to be that you aren't familiar
enough with it yet, but that isn't a Perl language problem as such.
> #!C:\perl\perl.exe -w
-w is good, as far as it goes, but where's the rest of the advice you
got from the posting guidelines?
> print <<END;
>
> <p>This text works fine </p>
No, it doesn't, because there's no evidence of you having printed your
CGI response header yet. Perl FAQ part 9 refers (recent versions, for
preference ;-)
> <img src="C:\Program Files\sambar41\cgi-bin\steve.gif" alt="HOME PAGE
> HEADER">
This is crazy. What's the point of referring other people to _your_
C: filepath? Don't you realise they (if they are so misguided as to
use such an OS) already have a C: filepath of their own?
Personal disclaimer: I really hate having to hit people when I can see
they're already at a disadvantage. But the problem here is that I
have no idea where you're starting from - I can see that you're
confused - and that you don't really have a Perl problem - but because
I can't work out what your underlying problem is, I'm not sure where
to send you next. All that I can perceive from your posting
(apologies for being so direct) is that your underlying mental model
somehow isn't working and is in need of serious attention. How about
taking a look at the CGI.pm examples that accompany Lincoln Stein's
CGI programming book? The examples are online, you don't necessarily
have to buy the book (though it could well be a good idea) - google
will find the material, I don't have the URLs at my fingertips.
good luck
------------------------------
Date: Sun, 12 Jan 2003 04:12:53 +0000 (UTC)
From: efflandt@xnet.com (David Efflandt)
Subject: Re: CGI - HTML Generation problems with images - scripts etc
Message-Id: <slrnb21qq4.6s7.efflandt@typhoon.xnet.com>
On 11 Jan 2003 18:54:04 -0800, Stephen Adam <00056312@brookes.ac.uk> wrote:
> Hi guys and girls
>
> I've just figured out how to generate most HTML with a simple perl
> script, i've given the code thats giving me problems. I can print out
> text fine, its just images and (java)scipts which don't seem to want
> to work. I have tried three different approaches to printing an image
> and none of them work. What am i doing wrong? Are there extra
> considerations with, scripts, images and CSS's?
>
>
> Thanks
>
> Steve
I hope that is not your entire CGI script, because you forgot the
"Content-type: text/html\n\n" header and "<html><body> tags, etc (it must
be valid html).
As far as JavaScript, you have to see if it looks right when you "view
source" in your browser.
> #!C:\perl\perl.exe -w
>
>
> print <<END;
>
><p>This text works fine </p>
>
><img src="./steve.gif" alt="HOME PAGE HEADER">
>
><img src="C:\Program Files\sambar41\cgi-bin\steve.gif" alt="HOME PAGE
> HEADER">
>
><img src="http://localhost/cgi-bin/steve.gif" alt="HOME PAGE HEADER">
>
> END
>
> exit(0);
--
David Efflandt - All spam ignored http://www.de-srv.com/
http://www.autox.chicago.il.us/ http://www.berniesfloral.net/
http://cgi-help.virtualave.net/ http://hammer.prohosting.com/~cgi-wiz/
------------------------------
Date: Sun, 12 Jan 2003 03:51:29 GMT
From: "SurfGod" <semaj_levram@worldnet.att.net>
Subject: Re: how to print a hash
Message-Id: <5D5U9.106937$hK4.8676195@bgtnsc05-news.ops.worldnet.att.net>
> Did you happen to notice that the "stuff" was the same for every one?
yes
> By applying "Use Rule 1" from:
> perldoc perlreftut
> print "@array"; # pretend it is a plain array
> print "@{}"; # replace the array _name_ with a
block
> print "@{$records{$record_num}}"; # fill the block with a ref to array
thanks much
> Once you get that fixed, you will discover that you have
> yet another problem.
> Every array will have the same contents!
I guess DBI works some other way, cuz the arrays differed like I needed them
to :)
------------------------------
Date: 11 Jan 2003 20:20:25 -0800
From: flateyjarbok@yahoo.com (R Solberg)
Subject: how to split web page contents download variable by line, without writing to and then reading from file.
Message-Id: <386cc483.0301112020.ecbcfb3@posting.google.com>
Hi,
I need to avoid hard drive i/o frequency when parsing information from
a web site's contents. Currently my pgm. gets the contents and then
outputs to a file (see code block A). Then it opens the file just
output and then reads the lines one by one. I want to take the
variable $contents and split it into line by line just like the file
input i/o function(code block B), but by skipping the harddrive i/o.
What code should I insert in code block B to accomplish this?
Block A
my $req = new HTTP::Request "POST",
"http://www.website.com/Table.asp?ITEM=$sym&ALL=2";
my $u = new LWP::UserAgent;
my $content = $u->request($req)->content;
open(MYOUTFILE, ">" . $folder . "output.out");
print MYOUTFILE $content;
close(MYOUTFILE);
open(MYINPUTFILE, "<" . $folder . "output.out");
my $counter = 1;
while(<MYINPUTFILE>) { here I process the lines one by one}
Block B
my $req = new HTTP::Request "POST",
"http://www.website.com/Table.asp?ITEM=$sym&ALL=2";
my $u = new LWP::UserAgent;
my $content = $u->request($req)->content;
my $counter = 1;
while(<GET NEXT LINE OF $contents>) { here I process the lines one
by one}
------------------------------
Date: Sat, 11 Jan 2003 21:48:51 -0500
From: Benjamin Goldberg <goldbb2@earthlink.net>
Subject: Re: muli-spaced fields and split()
Message-Id: <3E20D793.C966F466@earthlink.net>
bad_knee wrote:
>
> Hello,
>
> I was in the middle of parsing a logfile when I realized some
> fields have 2 spaces instead of one. This of couse screws up
> my field order when i split(/ /, $_) with a 1-space delimiter.
>
> Thu Jan 9 16:00:18 2003 1098 foo.bar.org 3333 bar.txt
> Fri Jan 10 07:16:13 2003 9 foo.bar.org 7662600 foo.txt
>
> note the double spaces between "Jan" and "9". Someone must
> have a favourite way of getting rid of the extra spaces. Please
> share.
use constant localtime_fmt => "a3 x a3 x a2 x a8 x a4";
my ($Ddd, $Mmm, $dd, $hhmmss, $yyyy, $other) =
unpack localtime_fmt()." x a*", $line_from_logfile;
my ($count1, $host, $count2, $filename) = split ' ', $other;
--
$..='(?:(?{local$^C=$^C|'.(1<<$_).'})|)'for+a..4;
$..='(?{print+substr"\n !,$^C,1 if $^C<26})(?!)';
$.=~s'!'haktrsreltanPJ,r coeueh"';BEGIN{${"\cH"}
|=(1<<21)}""=~$.;qw(Just another Perl hacker,\n);
------------------------------
Date: Sun, 12 Jan 2003 03:41:36 +0100
From: oblomov <spam@oblomov.org>
Subject: my tricky regexp
Message-Id: <20030112034136.67785c3f.spam@oblomov.org>
Please have a go at this:
[MyClass staticMethod():returnClass; ( instanceMethod():returnClass; )]
I would like to get these areas:
[<<MyClass>> <<staticMethod():returnClass;>> ( <<instanceMethod():returnClass;>> )]
But it should also match:
[MyClass]
[MyClass staticMethodsOnly():returnClass; ]
It's way to advanced for me.
Thanks,
karl
Some text to try it out at:
[Class]
[Class +publicStaticAttribute:String]
[Class friendlyStaticVoidMethod(inParameter:ParameterClass)]
[Class(#protectedInstanceAttribute:AttributeClass)]
[Class(-privateInstanceMethod():ReturnClass)]
[Class(i:int)]
[Class(i:int,c:char)]
[Class(i:int c:char)]
[Class(i:int;c:char,b:byte)]
[Class(multipleAttr:String{5}]
[Class(multipleAttr:String{0..5}]
[Class(multipleAttr:String{1..*}]
[Class(multipleAttr:String{*}]
[Class(multipleAttr:String{*..2}]
[Class(multipleAttr:String{1..5,7,9..*}]
[Class +method():String]
[Class +method():String{{{ /* source code */ }}}]
[Class +method():String{{{ /* source code {{{ }}} */ }}} (+method(i:int):String)]
[Class +method():String{{{ /* source code }}} */ }}},+method(i:int):String]
[Class +method():String{{{ /* source code */ {{{ }}};(+method(i:int):String)]
[Class (public abstract method(a:A,b:B):C)]
[Class (public abstract method(a:A,b:B):C {{{ code }}} private method(b:B,a:A):C {{{ code }}})]
[Class (public abstract method(a:A,b:B):C {{{ code }}},private method(b:B,a:A):C {{{ code }}})]
[Class (public abstract method(a:A,b:B):C {{{ code }}};private method(b:B,a:A):C {{{ code }}})]
------------------------------
Date: Sat, 11 Jan 2003 21:38:21 -0500
From: Benjamin Goldberg <goldbb2@earthlink.net>
Subject: Re: newline "\n" not working
Message-Id: <3E20D51D.9B69C718@earthlink.net>
Ben Morrow wrote:
>
> mthunter@uiuc.edu wrote:
> >On 10 Jan 2003 14:49:34 -0800, bazzz777 wrote:
> >> In MS Windows all the data appears as one long line.
> >> I can make the javascript web browser readable if I edit in
> >> newlines using a Windows text editor.
> >>
> >> I also tried my CGI with "\r" instead of "\t" but
> >
> >I assume you meant "\n", not "\t", right?
> >
> >Did you try "\r\n"?
>
> Better: "\cM\cJ", as this is more portable.
Perhaps not on EBCDIC :)
--
$..='(?:(?{local$^C=$^C|'.(1<<$_).'})|)'for+a..4;
$..='(?{print+substr"\n !,$^C,1 if $^C<26})(?!)';
$.=~s'!'haktrsreltanPJ,r coeueh"';BEGIN{${"\cH"}
|=(1<<21)}""=~$.;qw(Just another Perl hacker,\n);
------------------------------
Date: Sun, 12 Jan 2003 03:43:57 +0100
From: "Alan J. Flavell" <flavell@mail.cern.ch>
Subject: Re: newline "\n" not working
Message-Id: <Pine.LNX.4.40.0301120339070.17046-100000@lxplus070.cern.ch>
On Jan 11, Benjamin Goldberg inscribed on the eternal scroll:
> Ben Morrow wrote:
> > Better: "\cM\cJ", as this is more portable.
>
> Perhaps not on EBCDIC :)
CGI.pm has a rather sneaky solution to that...
Disclaimer: I used to run IBM VM/CMS mainframes, but I'd already
stopped doing that before I got involved in Perl. So I have no
practical experience of doing Perl CGI in an EBCDIC situation.
(REXX was OK, but Perl is better: I seriously regret the loss of CMS
Pipelines, though)
------------------------------
Date: Sat, 11 Jan 2003 20:05:41 -0600
From: "n" <foo@var.com>
Subject: Re: perl pattern matching woes
Message-Id: <v21ja02f8gv812@corp.supernews.com>
Thanks all!
A case of not seeing the forest for the trees.
Thanks again,
Andrew
"n" <foo@var.com> wrote in message news:v21i62hobabl23@corp.supernews.com...
> I have been using perl for some years without problems, but I am stumped
on
> the problem I having with a simple pattern match.
>
> All I want to do is check to see that $foo consists of exactly 4 digits.
> Sounds simple but I am having problems.
>
> My sample code fails to work properly:
>
> $foo = "12347777";
>
> print "timeout is $foo \n";
> if ($foo =~ /(\d{4})/) { print "Timeout value is 4 digits!\n";}
>
> This should fail but instead it prints the value. If I set $foo to
something
> less than 4 digits it works. But 4 or more and the output improperly says
it
> is 4 digits. Even using {4,4} fails.
>
> What am I doing wrong?
>
> Win2k SP3 perl v5.6.1 build 633
>
> Thanks for any help
>
> Andrew
>
>
>
------------------------------
Date: Sun, 12 Jan 2003 05:05:25 +0100
From: "Alan J. Flavell" <flavell@mail.cern.ch>
Subject: Re: Red Hat 8 breaking one-liner signature script
Message-Id: <Pine.LNX.4.40.0301120456380.30517-100000@lxplus070.cern.ch>
On Jan 10, Benjamin Goldberg inscribed on the eternal scroll:
> Oh, actually, the problem is that perl 5.8 *does* like the unicode
> system-wide settings.
>
> The problems that people have there occur because they think "unix means
> you don't have to binmode() your binary files", and they get bitten by
> the fact this is untrue on redhat8 with perl5.8.
>
> The historical "binary mode == text mode on unix" behavior has induced a
> certain laziness in unix programmers with respect to binmode, causing
> them to leave it out when they should have it in.
You make an excellent point. There's still countless Perl tutorials
around which promote a kind of unix-bigotry, telling programmers not
to use binmode() except on benighted i.e non-unix platforms. Although
some steps were made in recent times to rid the FAQs and other
documentation of such bigotry, readers should be aware (may I presume
that you agree with this?) that such prejudicial attitudes are still
around but should best be avoided.
My mainstream OS nowadays is linux, though my user interface, for some
proportion of the time, is Windoze. But whatever - I rate portable
programming techniques (where feasible) over OS-bigotry whenever there
seems to be a dispute. (Maybe having been a previous user of VM/CMS
and of VAX/VMS has some influence - but whatever the underlying
motive, I support the proposition!).
------------------------------
Date: Sat, 11 Jan 2003 22:16:21 -0500
From: Benjamin Goldberg <goldbb2@earthlink.net>
Subject: Re: Regexps - multisymbol negation question
Message-Id: <3E20DE05.6CDD5291@earthlink.net>
Michael Peuser (h) wrote:
[snip]
> s/(<tr>.*?<\/tr>)/
> index(substr($1,5, length($1)-9),$given_string) < 0 ? $1 : ''
> /egs;
>
> it has become a little bit awkward now.....
Use of a second capturing group helps:
s/(<tr>(.*?)<\/tr>)/index( $2, $given_string ) < 0 ? $1 : ''/egs;
[untested]
--
$..='(?:(?{local$^C=$^C|'.(1<<$_).'})|)'for+a..4;
$..='(?{print+substr"\n !,$^C,1 if $^C<26})(?!)';
$.=~s'!'haktrsreltanPJ,r coeueh"';BEGIN{${"\cH"}
|=(1<<21)}""=~$.;qw(Just another Perl hacker,\n);
------------------------------
Date: Sat, 11 Jan 2003 21:52:05 -0500
From: Benjamin Goldberg <goldbb2@earthlink.net>
Subject: Re: removing duplicate values from array not working...
Message-Id: <3E20D855.6FDB4144@earthlink.net>
eric wrote:
[snip]
> push @tmp,[split/;/];
> }
>
> push @tmpTwo,$_->[4] for @tmp;
That's silly. Why grab all of it, if you're only going to use one
element?
How about:
use strict;
use warnings;
my %seen;
while( <> ) {
my $item = (split /;/)[4];
print $item if ++$seen{$item} == 1;
}
__END__
--
$..='(?:(?{local$^C=$^C|'.(1<<$_).'})|)'for+a..4;
$..='(?{print+substr"\n !,$^C,1 if $^C<26})(?!)';
$.=~s'!'haktrsreltanPJ,r coeueh"';BEGIN{${"\cH"}
|=(1<<21)}""=~$.;qw(Just another Perl hacker,\n);
------------------------------
Date: Sat, 11 Jan 2003 22:27:10 -0500
From: Benjamin Goldberg <goldbb2@earthlink.net>
Subject: Re: Script to read a wordlist and find words in files/dirs.
Message-Id: <3E20E08E.64F914C@earthlink.net>
George wrote:
>
> Has anyone got a script that will take input from a wordlist that
> contains words and strings like:
>
> Banana
> Apple Butter
> Peach
> Strawberry Jam
>
> (you get the idea. real words changed to protect the innocent. :) )
>
> Then the script will use these words and migrate from the
> current directory through it and all the subdirectories
For traversing subdirectories, use File::Find, which is part of the
standard perl distribution.
> looking for files that contain any word or string from the list.
You probably want the index() function, or else a regex anchored at the
beginning and end with \b.
> Some useful output would help like:
>
> File /this/directory/myfile contains Apple Butter.
> File /that/directory/hisfile contains Peach.
>
> I have found a number of scripts that take command line arguments,
> but not wordlist.
use strict;
use warnings;
use File::Find;
use constant WORDLIST => map /(.*)/, <>;
use constant REGEX => map qr/\b($_)\b/,
join "|", map quotemeta, WORDLIST;
find sub {
local @ARGV = $_;
last if $_ =~ REGEX while <>;
return if eof;
print "$File::Find::name contains $1\n";
}, ".";
__END__
[untested]
--
$..='(?:(?{local$^C=$^C|'.(1<<$_).'})|)'for+a..4;
$..='(?{print+substr"\n !,$^C,1 if $^C<26})(?!)';
$.=~s'!'haktrsreltanPJ,r coeueh"';BEGIN{${"\cH"}
|=(1<<21)}""=~$.;qw(Just another Perl hacker,\n);
------------------------------
Date: Sun, 12 Jan 2003 02:11:21 GMT
From: Uri Guttman <uri@stemsystems.com>
Subject: Re: Using tr/// - Am I barking up the wrong tree?
Message-Id: <x7y95rdsmv.fsf@mail.sysarch.com>
>>>>> "J" == Jodyman <Jodyman@hotmail.com> writes:
J> "R. Charles Henry" <trapforcannedmeatproduct@hotmail.com> wrote in message
>> Trying to convert individual letters in a string, to gif image HTML tags:
>> e.g.
>> from: jo@jo.com to <img src="j.gif"><img src="o.gif"><img
J> src="at.gif"><img src="j.gif"> etc.
>> is there an easier way of doing this?
J> my $in = 'jo@jo.com';
J> my @in = split //, $in;
J> foreach (@in) {
J> $html .= "<img src='$_.gif'>";
J> }
J> print $html;
why the split and loop? a simple s/// will do it.
J> BTW, ..gif, @.gif etc are valid filenames so you can use the easier way.
but / is not a valid filename in unix, : is not in macos.
to handle special chars, you make a hash. you also can handle alpha
chars in there.
my %char2file = (
'@' => 'at',
'#' => 'hash',
map { $_ => $_ } 'a' .. 'z' ) ;
my $html = 'jo@jo.com';
$html =~ s/(.)/<img src="$char2hash{$1}.gif">/g ;
uri
--
Uri Guttman ------ uri@stemsystems.com -------- http://www.stemsystems.com
----- Stem and Perl Development, Systems Architecture, Design and Coding ----
Search or Offer Perl Jobs ---------------------------- http://jobs.perl.org
Damian Conway Perl Classes - January 2003 -- http://www.stemsystems.com/class
------------------------------
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 4388
***************************************