[16674] in Perl-Users-Digest
Perl-Users Digest, Issue: 4086 Volume: 9
daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Mon Aug 21 18:15:56 2000
Date: Mon, 21 Aug 2000 15:15:43 -0700 (PDT)
From: Perl-Users Digest <Perl-Users-Request@ruby.OCE.ORST.EDU>
To: Perl-Users@ruby.OCE.ORST.EDU (Perl-Users Digest)
Message-Id: <966896143-v9-i4086@ruby.oce.orst.edu>
Content-Type: text
Perl-Users Digest Mon, 21 Aug 2000 Volume: 9 Number: 4086
Today's topics:
Re: Output to printer in Win NT <gellyfish@gellyfish.com>
Param function question for cgi.pm eqguy6@my-deja.com
Re: Param function question for cgi.pm (Eric Bohlman)
Re: Param function question for cgi.pm eqguy6@my-deja.com
Re: Perl guestbook hacking (with HTML enabled) (Abigail)
Re: Pop Ups <no@return.com>
Re: Pop Ups <lauren_smith13@hotmail.com>
Re: Problem with hash initialization using list nobull@mail.com
Re: Problems with CPAN.pm <gellyfish@gellyfish.com>
Re: Procmail vs Perl. (Yiorgos Adamopoulos)
Re: Procmail vs Perl. <uri@sysarch.com>
Re: regex question <alan.zaitchik@mindspring.com>
Regex <thutchings@hoteldiscounts.com>
Re: Regex (Eric Bohlman)
Re: Regex (Jakob Schmidt)
Re: Regex (Jakob Schmidt)
Re: Regex <lr@hpl.hp.com>
Re: Regex: finding location in (?{}) (Teodor Zlatanov)
Re: regexing html-like tags <godzilla@stomp.stomp.tokyo>
Re: regexing html-like tags <blair@geo-NOSPAM-soft.org>
Re: regexing html-like tags <lr@hpl.hp.com>
Re: sending mail with mailx (Eric Bohlman)
Re: sending mail with mailx jon_nixon@my-deja.com
Re: sending mail with mailx (Teodor Zlatanov)
Sending things to mailx and lp <nospam@mail.org>
Sorting by a subfield (WAS: Re: This is my last questio <lr@hpl.hp.com>
Re: Sorting is very slow <gellyfish@gellyfish.com>
Digest Administrivia (Last modified: 16 Sep 99) (Perl-Users-Digest Admin)
----------------------------------------------------------------------
Date: 21 Aug 2000 20:52:45 +0100
From: Jonathan Stowe <gellyfish@gellyfish.com>
Subject: Re: Output to printer in Win NT
Message-Id: <8ns1ad$1hp$1@orpheus.gellyfish.com>
On Fri, 18 Aug 2000 09:02:57 GMT jason wrote:
> Jonathan Stowe wrote ..
>>On Thu, 17 Aug 2000 15:13:38 GMT hiroshiishii@my-deja.com wrote:
>>> Hi All:
>>>
>>> Would someone give an advice on how to print an ASCII string, "Hello
>>> world," to LaserJet4, which is on local parallel port (LPT1:), from
>>> WinNT or 98?
>>>
>>
>>open(PRINTER,'>LPT1:') || die "Can't open printer - $!\n";
>>print "Hello, World\n";
>>
>>print "\f"; # Some printers will require this line feed before producing
>> # a page
>>
>>close PRINTER;
>>
>>On shared printers you can use the UNC name of the printer (\\server\printer).
>
> of course - Jonathan meant to write
>
> print PRINTER "Hello, World\n";
> print PRINTER "\f";
>
> or maybe a select disappeared from my newsfeed ;)
>
It was before eight in the morning I didnt have enough energy to hold the
shift key down for another fourteen characters at that point :)
/J\
--
yapc::Europe in assocation with the Institute Of Contemporary Arts
<http://www.yapc.org/Europe/> <http://www.ica.org.uk>
------------------------------
Date: Mon, 21 Aug 2000 19:27:33 GMT
From: eqguy6@my-deja.com
Subject: Param function question for cgi.pm
Message-Id: <8nrvqb$4h8$1@nnrp1.deja.com>
I have a feeling I'm missing something obvious here, but reading the
cgi.pm documentation didn't seem to help much (yes, I did read it :P ).
I have a multipart form where on one "page" I am creating a table of
parameters to be altered by the user. Each row in the table contains 8
elements with unique names, but each column has the same name, but
different values. The snippet of code to create the table looks
something like this:
$i=0;
while (<FILE>) {
print "<TR><TD>popup_menu(-name=>"ELEMENT1.$i",
-values=>['a','b','c']),"</TD>";
print "<TD>",popup_menu(-name=>"ELEMENT2.$i",
-values=>['d','e','f']),"</TD></TR>";
$i++;
}
And so on for an 8 column table. This results in the parameters
being passed as ELEMENT1.0, ELEMENT2.0, ELEMENT1.1, ELEMENT2.1, etc
back to the script. The number of elements (or value of $i) will vary
frequently.
The crux of the problem is that I cannot get something like
$varname=param(ELEMENT1.$i)
to work, it seems I don't know how to make
the variable interpolation work within the param function (assuming
it's possible of course.)
Any suggestions? I'd happily consider a better method for creating the
table of parameters as well, I know it's pretty kludgy. Regardless I
need to be able to pass a bunch of parameters of the same name (or
almost the same name but with a distinct identifier as in the example
above) to the script for further processing.
Thanks in advance!
Sent via Deja.com http://www.deja.com/
Before you buy.
------------------------------
Date: 21 Aug 2000 19:55:04 GMT
From: ebohlman@netcom.com (Eric Bohlman)
Subject: Re: Param function question for cgi.pm
Message-Id: <8ns1eo$8sm$5@slb7.atl.mindspring.net>
eqguy6@my-deja.com wrote:
: The crux of the problem is that I cannot get something like
:
: $varname=param(ELEMENT1.$i)
:
: to work, it seems I don't know how to make
: the variable interpolation work within the param function (assuming
: it's possible of course.)
Just stick double quotes around the argument to param().
------------------------------
Date: Mon, 21 Aug 2000 20:42:08 GMT
From: eqguy6@my-deja.com
Subject: Re: Param function question for cgi.pm
Message-Id: <8ns46s$9o9$1@nnrp1.deja.com>
In article <8ns1eo$8sm$5@slb7.atl.mindspring.net>,
ebohlman@netcom.com (Eric Bohlman) wrote:
> eqguy6@my-deja.com wrote:
> : The crux of the problem is that I cannot get something like
> :
> : $varname=param(ELEMENT1.$i)
> :
> : to work, it seems I don't know how to make
> : the variable interpolation work within the param function (assuming
> : it's possible of course.)
>
> Just stick double quotes around the argument to param().
>
>
As it turns out (to my disgust if not my surprise) I had an error
somewhere else in the code that was preventing me from pulling each of
the ELEMENT1.$i 's out via param, it interpolated the variable name
just fine once I fixed it...
I'd still be interested in a more elegant solution to creating the
table however, since I'm pretty firmly convinced my code is inefficient
at best and downright ugly at worst...heh.
Thanks for the response though, I appreciate it.
Sent via Deja.com http://www.deja.com/
Before you buy.
------------------------------
Date: 21 Aug 2000 18:07:00 GMT
From: abigail@foad.org (Abigail)
Subject: Re: Perl guestbook hacking (with HTML enabled)
Message-Id: <slrn8q2rsr.tj3.abigail@alexandra.foad.org>
Sandra (sandra@siliconrack.com) wrote on MMDXLIV September MCMXCIII in
<URL:news:bRjMNlKIyaRCv5FEiOYI8cnLJWDg@4ax.com>:
||
|| We have a simple Perl guestbook based on Matt W.'s guestbook,
|| we have HTML enabled. Server is redhat 6.1
||
|| Question:
||
|| 1. I read somewhere it's easy to hack servers using
|| HTML-enabled perl guestbooks. Is this true? which procedure?
A program is as safe as it is. Just because it's written in Perl doesn't
mean it's more or less safe then when it would have been written in Ada.
Except that due to taintness, it might be easier to write a safe program
in Perl than in Ada.
|| 2. How to protect an HTML-enabled guestbook?
|| I have a function to strip <script></script> <object>, etc, etc
|| but I don't know if this is enough protection.
Huh? I think you have absolutely no clue what you are talking about.
How is stripping substrings that might be HTML tags (stripping from
where?) going to protect your servers?
What has this to do with Perl anyway?
Abigail
--
$_ = "\nrekcaH lreP rehtona tsuJ"; my $chop; $chop = sub {print chop; $chop};
$chop -> () -> () -> () -> () -> () -> () -> () -> () -> () -> () -> () -> ()
-> () -> () -> () -> () -> () -> () -> () -> () -> () -> () -> () -> () -> ()
------------------------------
Date: Mon, 21 Aug 2000 16:07:55 -0500
From: "Tim" <no@return.com>
Subject: Re: Pop Ups
Message-Id: <8ns5nb$b6u$1@schbbs.mot.com>
Etienne Laverdiere <info@digitaltango.com> wrote in message
news:9lUk5.5738$K5.189971@news20.bellglobal.com...
> <script language='javascript'>
> window.alert('Message');
> </script>
or even better, put the curser in the bad field:
<script language='javascript'>
window.alert('Message');
document.formName.badFormElementName.focus();
</script>
Tim
------------------------------
Date: Mon, 21 Aug 2000 14:43:55 -0700
From: "Lauren Smith" <lauren_smith13@hotmail.com>
Subject: Re: Pop Ups
Message-Id: <8ns7mr$5mu$1@brokaw.wa.com>
Tim <no@return.com> wrote in message news:8ns5nb$b6u$1@schbbs.mot.com...
>
> Etienne Laverdiere <info@digitaltango.com> wrote in message
> news:9lUk5.5738$K5.189971@news20.bellglobal.com...
> > <script language='javascript'>
> > window.alert('Message');
> > </script>
>
> or even better, put the curser in the bad field:
>
> <script language='javascript'>
> window.alert('Message');
> document.formName.badFormElementName.focus();
> </script>
Even better than that, post a link to a better place to ask this type of
question.
comp.lang.javascript
comp.infosystems.www.authoring.html
As a bonus, you could also remove comp.lang.perl from the newsgroups posted
to. :-)
Lauren
--
print grep ord $_,map{y/a-z//d;$x.="+ $_";chr(eval $x)}
'J74u43-s2tA1-84n33o45th1er5-12-P3e13-82r48l21H13-a6-76
c40k25er2wx8-y6z13-81'=~m#([^!\n]{3})#g#tr/-0-9//d;print
------------------------------
Date: 21 Aug 2000 19:26:34 +0100
From: nobull@mail.com
Subject: Re: Problem with hash initialization using list
Message-Id: <u9u2cebhd1.fsf@wcl-l.bham.ac.uk>
Larry Rosler <lr@hpl.hp.com> writes:
> In article <u9hf8iqnvl.fsf@wcl-l.bham.ac.uk> on 18 Aug 2000 22:07:42
> +0100, nobull@mail.com <nobull@mail.com> says...
>
> That shows that you didn't learn C first. In C, the comma operator is
> like the Perl comma operator in scalar context -- evaluate the left
> expression, then evaluate the right expression. In that context, the
> ultra-low precedence of the comma operator makes eminent sense.
Actually I did learn C before I learnt Perl (but _after_ I learnt
C++). I always considered this use of the comma to be obfuscation even
in C. In Perl I consider it highly affected.
In Perl I'd always write:
do { foo; bar }
Not:
foo, bar
> In Perl's list context, the precence of assignment above comma makes
> less sense, as you imply, but it's better the precedences be the same
> independent of context, and history wins.
History wins, we loose.
--
\\ ( )
. _\\__[oo
.__/ \\ /\@
. l___\\
# ll l\\
###LL LL\\
------------------------------
Date: 21 Aug 2000 19:31:31 +0100
From: Jonathan Stowe <gellyfish@gellyfish.com>
Subject: Re: Problems with CPAN.pm
Message-Id: <8nrsi3$10d$1@orpheus.gellyfish.com>
On Thu, 17 Aug 2000 15:00:01 -0700 Bruce W. Mohler wrote:
> I'm running Perl 5.00503 on a Compaq Alpha Server under Compaq Tru64
> UNIX 4.0. I'm trying to get to get the CPAN module to install
> Bundle::libnet.
>
> I started Perl as "perl -MCPAN -eshell" and went through the initial
> config
> process and selected about 4 sites as archive sites. It wrote the
> Config.pm
> file. I then tried "install Bundle::libnet" and saw
<snip>
>
> Can't install Bundle::libnet, don't have an associated bundle file. :-(
>
> The initial configuration found the ftp client program and so should be
> able
> to retrieve files. I specified 4 URLs.
>
> Anyone have any suggestions on what I should look at to fix this?
>
It is possible that the ftp client on your machine does not behave in the
way that the CPAN module thinks that it should and I would suggest that
in the first instance you download and install libnet manually so that
CPAN can use Net::FTP then use CPAN to install Bundle::CPAN - beware that
if you have an old Perl it might just decide to install the latest release
for you :)
/J\
--
yapc::Europe in assocation with the Institute Of Contemporary Arts
<http://www.yapc.org/Europe/> <http://www.ica.org.uk>
------------------------------
Date: 21 Aug 2000 18:42:22 GMT
From: adamo@dblab.ece.ntua.gr (Yiorgos Adamopoulos)
Subject: Re: Procmail vs Perl.
Message-Id: <slrn8q2u0e.pj9.adamo@city.dbnet.ece.ntua.gr>
In article <1efdoez.7o5j3nfazjb8N%tony@svanstrom.com>, Tony L. Svanstrom wrote:
>I've now started working on a Perl-based solution; so far I've only got
>a few lines that split up the headers and separate them from the body,
>but I'm getting there. Altough I haven't focused too much on it so far
>I'm doing my best to keep it nice to the system.
Take care that whatever line is inputed in your script is not evaluated
like a valid Perl expression and then executed. That could lead to nasty
things happening from your account.
--adamo
------------------------------
Date: Mon, 21 Aug 2000 18:52:40 GMT
From: Uri Guttman <uri@sysarch.com>
Subject: Re: Procmail vs Perl.
Message-Id: <x766ouv43t.fsf@home.sysarch.com>
>>>>> "TLS" == Tony L Svanstrom <tony@svanstrom.com> writes:
TLS> Tony L. Svanstrom <tony@svanstrom.com> wrote:
>> A simple question: Why would I want to learn how to use procmail when I
>> already know Perl, wouldn't it be easier, as well as potentially a lot
>> more powerful, to simply use Perl for the mailfiltering?
TLS> I've now started working on a Perl-based solution; so far I've
TLS> only got a few lines that split up the headers and separate them
TLS> from the body, but I'm getting there. Altough I haven't focused
TLS> too much on it so far I'm doing my best to keep it nice to the
TLS> system.
too late.
check out Mail::Procmail and Mail::Audit. both do what you want with
different methods (one stole ideas from the other). i have checked them
out and am starting to use the procmail one. both are very easy to use
and allow you to check with perl code which place to deliver the
message. no need to use plain procmail again. now we can have readable
perl code splitting our mail.
Mail::Procmail comes with a good example file which handles mailing
lists, and many other mail types including spam.
uri
--
Uri Guttman --------- uri@sysarch.com ---------- http://www.sysarch.com
SYStems ARCHitecture, Software Engineering, Perl, Internet, UNIX Consulting
The Perl Books Page ----------- http://www.sysarch.com/cgi-bin/perl_books
The Best Search Engine on the Net ---------- http://www.northernlight.com
------------------------------
Date: Mon, 21 Aug 2000 16:19:41 -0400
From: "Alan Zaitchik" <alan.zaitchik@mindspring.com>
Subject: Re: regex question
Message-Id: <8ns2n3$71v$1@slb6.atl.mindspring.net>
Well I solved my immediate problem using PATH_TRANSLATED and split() but I
am still curious how this could have been done more generically with regex,
if someone cares to explain.
"Alan Zaitchik" <alan.zaitchik@mindspring.com> wrote in message
news:8nicpe$h37$1@slb7.atl.mindspring.net...
> Please excuse if this is very obvious.
> I am trying to have a perl CGI script create a file in response to a form
> submission. The perl script is in a sibling directory of where the file is
> supposed to be created. This is on an NT system, so if the perl code is in
> C:\InetPub\wwwroot\myvirtualroot\scripts\myscript.pl, the file would have
to
> be created in C:\InetPub\wwwroot\myvirtualroot\users. The name of the file
> depends on the value of $UID, so what I would like to do is something like
> $newfile = "..\\users\\" . $UID . ".html" ;
> or
> $newfile = "../users/" . $UID . ".html" ;
> followed by
> open FILEOUT, ">$newfile";
> etc. -- except that neither of these works. Why is that? I would have
> thought that either the physical or the virtual path would make sense to
the
> open statement, no? Neither seems to.
> Anyway, if I get
> $physPath = $ENV{'PATH_TRANSLATED'};
> how would I use regular expressions to create the desired file name? I
have
> tried various combinatiopns to no avail, but I think my problem is that I
> find regular expressions very arcane. What I want is to substitute
> everything from "scripts" to the end with "users\$UID.html". It should be
> straightforward but I cannot get it right.
> Any help most appreciated!
> Alan
>
> $newfile = "C:\\inetpub\\wwwroot\\testpilot\\users\\".$UID."_main.html";
>
>
>
------------------------------
Date: Mon, 21 Aug 2000 14:51:48 -0500
From: "Thomas Hutchings" <thutchings@hoteldiscounts.com>
Subject: Regex
Message-Id: <CD6AD42A5174FC81.781043264E064B40.69AB91331C384D14@lp.airnews.net>
Hello all,
Please refer me to the FAQ entry I missed if there is one...
I'm looking at some [admittedly] poor code like the following:
foreach (split /\n/, $buffer)
{
if (/^START/) {
print "Starting buffer line\n";
}
next if //;
..... # more processing
}
My question concerns the "next if //" line. As I read it, this should
always match, rendering the remainder of the loop code useless. In
practice, though, it does not. I assume the author intended "next if /^$/",
which isn't equivalent, right?
Any help appreciated.
--
_________
|homas
------------------------------
Date: 21 Aug 2000 20:19:54 GMT
From: ebohlman@netcom.com (Eric Bohlman)
Subject: Re: Regex
Message-Id: <8ns2ta$8sm$7@slb7.atl.mindspring.net>
Thomas Hutchings (thutchings@hoteldiscounts.com) wrote:
: Please refer me to the FAQ entry I missed if there is one...
Actually, you need the entry for m// in perlop.
: I'm looking at some [admittedly] poor code like the following:
:
: foreach (split /\n/, $buffer)
: {
: if (/^START/) {
: print "Starting buffer line\n";
: }
: next if //;
: ..... # more processing
: }
:
: My question concerns the "next if //" line. As I read it, this should
: always match, rendering the remainder of the loop code useless. In
: practice, though, it does not. I assume the author intended "next if /^$/",
: which isn't equivalent, right?
As perlop indicates, an empty match pattern matches the last thing that
was successfully matched, so in this case the "next" will be executed if
$_ matches "^START", i.e. if the previous "if" succeeded. I suspect that
the original programmer mistakenly thought that putting the "next"
statement inside the "if" block wouldn't properly break out of the loop,
so he used an awkward kludge instead.
------------------------------
Date: Mon, 21 Aug 2000 22:21:44 +0200
From: sumus@aut.dk (Jakob Schmidt)
Subject: Re: Regex
Message-Id: <1efqjay.1dlgbrj14sriyoN@[192.168.88.117]>
Thomas Hutchings <thutchings@hoteldiscounts.com> wrote:
> As I read it, this should
> always match
It does.
> In
> practice, though, it does not.
Really? Under which circumstances?
> I assume the author intended "next if /^$/",
> which isn't equivalent, right?
Right. That only matches the empty string (and the undefined value).
--
Jakob
------------------------------
Date: Mon, 21 Aug 2000 22:23:40 +0200
From: sumus@aut.dk (Jakob Schmidt)
Subject: Re: Regex
Message-Id: <1efqjid.mv2wv3wezj7iN@[192.168.88.117]>
Jakob Schmidt <sumus@aut.dk> wrote:
> Thomas Hutchings <thutchings@hoteldiscounts.com> wrote:
>
> > As I read it, this should
> > always match
>
> It does.
>
> > In
> > practice, though, it does not.
>
> Really? Under which circumstances?
Ooops - Eric knew better :-(
Sorry
--
Jakob
------------------------------
Date: Mon, 21 Aug 2000 13:47:38 -0700
From: Larry Rosler <lr@hpl.hp.com>
Subject: Re: Regex
Message-Id: <MPG.140b35454f0720dc98acb0@nntp.hpl.hp.com>
In article
<CD6AD42A5174FC81.781043264E064B40.69AB91331C384D14@lp.airnews.net> on
Mon, 21 Aug 2000 14:51:48 -0500, Thomas Hutchings
<thutchings@hoteldiscounts.com> says...
...
> Please refer me to the FAQ entry I missed if there is one...
None that I can think of. But it's nice of you to ask, anyway. :-)
> I'm looking at some [admittedly] poor code like the following:
>
> foreach (split /\n/, $buffer)
> {
> if (/^START/) {
> print "Starting buffer line\n";
> }
> next if //;
> ..... # more processing
> }
>
> My question concerns the "next if //" line. As I read it, this should
> always match, rendering the remainder of the loop code useless. In
> practice, though, it does not. I assume the author intended "next if /^$/",
> which isn't equivalent, right?
No. Through old-fashined historical juju (I trace this back to 'vi', if
not earlier), the empty regex is interpreted as being the same regex as
that of the previous successful match. (Caution -- this isn't true for
the regex in split(), though.)
From perlop:
If the PATTERN evaluates to the empty string, the last successfully
matched regular expression is used instead.
The sounder way to write this loop is just to put 'next;' as the
statement after the print(), so the match doesn't have to be performed
again.
--
(Just Another Larry) Rosler
Hewlett-Packard Laboratories
http://www.hpl.hp.com/personal/Larry_Rosler/
lr@hpl.hp.com
------------------------------
Date: 21 Aug 2000 15:02:17 -0500
From: tzz@iglou.com (Teodor Zlatanov)
Subject: Re: Regex: finding location in (?{})
Message-Id: <39a17cb9$1_1@news.iglou.com>
<8nj5bf$j62$1@lux.doc.ic.ac.uk>:Adrian Taylor (at99@active22.doc.ic.ac.uk):comp.lang.perl.misc:18 Aug 2000 11:06:23 GMT:quote:
: I have a regular expression with (?{}) in it. The code inside that
: calls a function to check whether the last match was a noun, a verb
: or something else. For instance:
: ...
: I could extract the word using () and then check it afterwards,
: using the length of $' or something, but I'm extracting various
: other things from the sentences and it would be *much* easier to
: check it in-line.
I would strongly recommend looking at the Parse::RecDescent module for
context-sensitive parsing. Doing it yourself may be unnecessary, or at
least easier if you use Parse::RecDescent. I think it would do well with
the sort of task you need, and will be almost definitely faster to write,
with less bugs.
--
Teodor Zlatanov <tzz@iglou.com>
"Brevis oratio penetrat colos, longa potatio evacuat ciphos." -Rabelais
------------------------------
Date: Mon, 21 Aug 2000 12:20:39 -0700
From: "Godzilla!" <godzilla@stomp.stomp.tokyo>
Subject: Re: regexing html-like tags
Message-Id: <39A18107.E0EF7113@stomp.stomp.tokyo>
Blair Heuer wrote:
> I am trying to write a regular expression that is able to parse a
> variable for "tags" and return the tag attributes and values.
(snipped)
Reads to me you are making this as difficult as possible.
Your wording is so unclear, it is impossible to ascertain
what you want to do, with any confidence.
Nonetheless, this very simple skeleton test script below can
be modified to do whatever it is you want to do, which you
are apparently unable to explain clearly and concisely.
Godzilla!
TEST SCRIPT:
____________
#!/usr/local/bin/perl
print "Content-Type: text/plain\n\n";
$string = '<html>Gobbly Gook<name=test1 value=test1> Gibberish
<NAME="TEST2" VALUE="TEST2">Techno-Geekster Gobbly Gibberish<name=
"test3" value="test3">Kira Is Brilliant<IMG SRC="Kira_Naked.gif">
Mule Manure Here</html>';
$string =~ s/\n//g;
$string =~ s/>/>¦/g;
@Array = split (/¦/, $string);
$counter = 1;
foreach $element (@Array)
{
if ($element =~ /(<[^>]+>)/)
{
print "Line $counter has this tag: $1\n";
$counter++;
}
}
exit;
PRINTED RESULTS:
________________
Line 1 has this tag: <html>
Line 2 has this tag: <name=test1 value=test1>
Line 3 has this tag: <NAME="TEST2" VALUE="TEST2">
Line 4 has this tag: <name="test3" value="test3">
Line 5 has this tag: <IMG SRC="Kira_Naked.gif">
Line 6 has this tag: </html>
------------------------------
Date: Mon, 21 Aug 2000 20:42:11 GMT
From: "Blair Heuer" <blair@geo-NOSPAM-soft.org>
Subject: Re: regexing html-like tags
Message-Id: <Dugo5.140$vA6.1539@newsread2.prod.itd.earthlink.net>
> > I am trying to write a regular expression that is able to parse a
> > variable for "tags" and return the tag attributes and values.
>
> (snipped)
>
>
> Reads to me you are making this as difficult as possible.
> Your wording is so unclear, it is impossible to ascertain
> what you want to do, with any confidence.
>
> Nonetheless, this very simple skeleton test script below can
> be modified to do whatever it is you want to do, which you
> are apparently unable to explain clearly and concisely.
Sheesh, its either one end of the spectrum or the other on this newsgroup:
"not enough information", "too little information."
That skeleton in no way does anything what I need. I will shorten my query
with the hopes of making it easier to understand (if you say too little
information, I will kill you :) ).
Say I have:
$template = "[out name=bob age="44" comment="This is my comment!"]; #
Just a random tag using possible syntax
What should I do to put the name/value pairs of that tag (name: bob, age:
44, comment: This is my comment! ) into a hash.
Thats as simple and "clear" as I can put it.
-Blair
------------------------------
Date: Mon, 21 Aug 2000 14:49:11 -0700
From: Larry Rosler <lr@hpl.hp.com>
Subject: Re: regexing html-like tags
Message-Id: <MPG.140b43b337a9c90898acb2@nntp.hpl.hp.com>
In article <Dugo5.140$vA6.1539@newsread2.prod.itd.earthlink.net> on Mon,
21 Aug 2000 20:42:11 GMT, Blair Heuer <blair@geo-NOSPAM-soft.org>
says...
> > > I am trying to write a regular expression that is able to parse a
> > > variable for "tags" and return the tag attributes and values.
> >
> > (snipped)
[Attribution to our favorite troll omitted.]
> > Reads to me you are making this as difficult as possible.
> > Your wording is so unclear, it is impossible to ascertain
> > what you want to do, with any confidence.
> >
> > Nonetheless, this very simple skeleton test script below can
> > be modified to do whatever it is you want to do, which you
> > are apparently unable to explain clearly and concisely.
>
> Sheesh, its either one end of the spectrum or the other on this newsgroup:
> "not enough information", "too little information."
>
> That skeleton in no way does anything what I need. I will shorten my query
> with the hopes of making it easier to understand (if you say too little
> information, I will kill you :) ).
>
> Say I have:
> $template = "[out name=bob age="44" comment="This is my comment!"]; #
> Just a random tag using possible syntax
It would have been more helpful to use valid Perl syntax. I've repaired
this below.
> What should I do to put the name/value pairs of that tag (name: bob, age:
> 44, comment: This is my comment! ) into a hash.
>
> Thats as simple and "clear" as I can put it.
It was pretty clear along, for those who chose to read.
Here is a regex that handles the cases you've shown. The only
interesting part is that which looks for the ends of the values, which
is rather ad hoc. Poorly formatted or erroneous data can mess this up
mightily. I'm sure there is a module that does it better.
#!/usr/bin/perl -w
use strict;
$_ = '"[out name=bob age="44" comment="This is my comment!"]';
my %h;
$h{$1} = $3 while /(\w+)=("?)(.+?)\2(?=\s+\w+=|]|$)/g;
print map "$_ => $h{$_}\n" => sort keys %h;
__END__
Output:
age => 44
comment => This is my comment!
name => bob
--
(Just Another Larry) Rosler
Hewlett-Packard Laboratories
http://www.hpl.hp.com/personal/Larry_Rosler/
lr@hpl.hp.com
------------------------------
Date: 21 Aug 2000 19:26:58 GMT
From: ebohlman@netcom.com (Eric Bohlman)
Subject: Re: sending mail with mailx
Message-Id: <8nrvq2$8sm$4@slb7.atl.mindspring.net>
tequila (cgibert@tequila-rapido.fr) wrote:
: I have a problem with mailx.
: I must use this program on solaris with perl and It doesn't work (mail
: is not sent although the syntax I use works for sendmail on Unix)
That last clause can't possibly be true.
: Do you know what's wrong with it...
Yes, but instead of telling you, I'm going to show you how to find it.
Include $! in your error message so you can see *why* your open command
is failing.
------------------------------
Date: Mon, 21 Aug 2000 19:24:51 GMT
From: jon_nixon@my-deja.com
Subject: Re: sending mail with mailx
Message-Id: <8nrvla$479$1@nnrp1.deja.com>
You've missed the "|" symbol from your open statement, so you're not
piping your print data to the mailx program. You need...
if (open (MAIL, "| /usr/bin/mailx -t"))
- Jon
In article <39A13193.F08AF511@tequila-rapido.fr>,
tequila <cgibert@tequila-rapido.fr> wrote:
<snip>
> if (open (MAIL, "/usr/bin/mailx -t"))
<snip>
Sent via Deja.com http://www.deja.com/
Before you buy.
------------------------------
Date: 21 Aug 2000 15:33:08 -0500
From: tzz@iglou.com (Teodor Zlatanov)
Subject: Re: sending mail with mailx
Message-Id: <39a183f4_1@news.iglou.com>
<39A13193.F08AF511@tequila-rapido.fr>:tequila (cgibert@tequila-rapido.fr):comp.lang.perl.misc:Mon, 21 Aug 2000 15:41:39 +0200:quote:
: I must use this program on solaris with perl and It doesn't work (mail
: is not sent although the syntax I use works for sendmail on Unix)
: Do you know what's wrong with it...
:
: sub send_email
: {
: local ($from,$to,$subject,$contenu)=@_;
: if (open (MAIL, "/usr/bin/mailx -t"))
: {
...
: }
: else
: {
: &message("Sorry \! <br>Mail could not been sent.");
: }
: 1;
: }
: With this classical syntax, I always obtain a "Mail could not been
: sent"...
Look at the $! (error returned from last OS call) variable. It may be that
your open() is failing. Also, why not use something like MIME::Lite, which
is much nicer for sending mail?
--
Teodor Zlatanov <tzz@iglou.com>
"Brevis oratio penetrat colos, longa potatio evacuat ciphos." -Rabelais
------------------------------
Date: Mon, 21 Aug 2000 14:58:59 -0400
From: "Daniel Racine" <nospam@mail.org>
Subject: Sending things to mailx and lp
Message-Id: <%Zeo5.3639$SH3.56711@wagner.videotron.net>
Hi,
I have a foo() function that prints things. I'd like to send the results
by e-mail and print them also. What should i do ?
1)
open the first pipe : "| mailx -s title my.friend"
call the foo() function
close the first pipe
open the second pipe : "| lp -d myprinter"
call the foo() function
close the second pipe
or
2)
open both the first and the second pipes
&foo()
close both pipes
or
3)
any other idea that would be even better ? thanx for your help!
------------------------------
Date: Mon, 21 Aug 2000 13:27:26 -0700
From: Larry Rosler <lr@hpl.hp.com>
Subject: Sorting by a subfield (WAS: Re: This is my last question, I swear!!!!!!!!!!)
Message-Id: <MPG.140b3086cf77ae4d98acaf@nntp.hpl.hp.com>
[This is a followup to an existing thread. You shouldn't start a new
thread for it. Also, your Subject tells more about you than about your
problem. I have changed it.]
In article <8nruvu$36o$1@nnrp1.deja.com> on Mon, 21 Aug 2000 19:13:22
GMT, pape_98@my-deja.com <pape_98@my-deja.com> says...
> here is my database,
>
> NIH,10B-410,01 36,13 5 26,15 43,1 5 2 5 2 4
> NIH,6B-4,01 36,13 5 26,15 43,1 5 2 5 2 4
> Suburban,6C-258,52 51,5256,15 13,152
> Suburban,ACardiology,52 51,5256,15 13,152
> NIH,9B-4,01 36,13 5 26,15 43,1 5 2 5 2 4
> NIH,15-410,01 36,13 5 26,15 43,1 5 2 5 2 4
> NIH,60B-410,01 36,13 5 26,15 43,1 5 2 5 2 4
> NIH,B1D-416,52,135 6,1513,52 hi,
> NIH,B1D-43,01 36,13 5 26,15 43,1 5 2 5 2 4
> Suburban,10C-58,52 51,5256,15 13,152
> Suburban,1B-29,52 51,5256,15 13,152
> NIH,B1D-403,01 36,13 5 26,15 43,1 5 2 5 2 4
> NIH,B1D-410,52 51 36,135 256,15413,1512
> Suburban,6B-281,52 51,5256,15 13,152
> Suburban,Office,52 51,5256,15 13,152
>
> here is my script,
>
> #!/usr/bin/perl
You forgot the '-w' flag on that line.
> use strict;
>
> use vars qw(@unsorted @sorted @new $a $b $c);
You have declared @unsorted as a global variable.
> open (SORTER,"/applications/apache/cgi-bin/pape/box") or die "Can't
> open file: $!\n";
>
> chomp(my @unsorted = <SORTER>);
Here you declare @unsorted as a lexical variable, which is better.
Drop the 'use vars' statement and use 'my' wherever needed. $a and $b
needn't be declared (perldoc -f sort), and $c is just wrong -- see
below.
> @sorted = map "${\ (unpack 'na*', $_)[-1] }" => sort map pack
> ('na*', /B1D-(\d+),/?$1:0, $_ ) => @unsorted;
You have added data which makes the above sortkey extraction inadequate.
You should be able to fix it yourself by changing the regex.
> @sorted = sort { $a cmp $b } @unsorted;
This line overwrites the careful numerical sort from the previous
statement with a lexicographic sort.
> @new = sort { $b <=> $c } @sorted;
Surely you meant '$a', not '$c'. But why do this? The'-w' flag would
have shown you the folly of this statement.
...
> now my question is, what do I have to change in my script to get the
> output in that format but have the numbers sorted out in order (i.e
> 1,2,10,12,14,22, etc...)
See above.
> Please help me. I'm new to perl and have no idea what to do here. I've
> even tried combining the different sorting techniques.
Yes, without complete understanding.
You are doing a lot of copying and pasting, without stopping to grasp
fully what is being given by members of this newsgroup. Take a few deep
breaths, stop typing, and start reading the code for understanding.
The sorting technique you are using is described in detail in the
following:
http://www.hpl.hp.com/personal/Larry_Rosler/sort/
--
(Just Another Larry) Rosler
Hewlett-Packard Laboratories
http://www.hpl.hp.com/personal/Larry_Rosler/
lr@hpl.hp.com
------------------------------
Date: 21 Aug 2000 21:59:52 +0100
From: Jonathan Stowe <gellyfish@gellyfish.com>
Subject: Re: Sorting is very slow
Message-Id: <8ns588$1u4$1@orpheus.gellyfish.com>
On Thu, 17 Aug 2000 14:27:50 -0700 "Jürgen Exner wrote:
> Donald E. Knuth "The Art of Programming" (sorry, don't remember the volume)
Volume 3, 'Sorting and Searching'.
/J\
--
yapc::Europe in assocation with the Institute Of Contemporary Arts
<http://www.yapc.org/Europe/> <http://www.ica.org.uk>
------------------------------
Date: 16 Sep 99 21:33:47 GMT (Last modified)
From: Perl-Users-Request@ruby.oce.orst.edu (Perl-Users-Digest Admin)
Subject: Digest Administrivia (Last modified: 16 Sep 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.
| NOTE: The mail to news gateway, and thus the ability to submit articles
| through this service to the newsgroup, has been removed. I do not have
| time to individually vet each article to make sure that someone isn't
| abusing the service, and I no longer have any desire to waste my time
| dealing with the campus admins when some fool complains to them about an
| article that has come through the gateway instead of complaining
| to the source.
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 V9 Issue 4086
**************************************