[24524] in Perl-Users-Digest
Perl-Users Digest, Issue: 6704 Volume: 10
daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Fri Jun 18 11:05:56 2004
Date: Fri, 18 Jun 2004 08:05:06 -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 Fri, 18 Jun 2004 Volume: 10 Number: 6704
Today's topics:
"antispam" perl mods? (bad_knee)
Re: "antispam" perl mods? <josef.moellers@fujitsu-siemens.com>
Re: $NF for perl <remorse@partners.org>
Re: A neat trick to serialize arrays and hashes (J. Romano)
Re: Can't locate package AutoLoader for @File::List::IS <kalinaubears@iinet.net.au>
Encoding question <kruger@math.fu-berlin.de>
Re: Encoding question <usenet@morrow.me.uk>
Error when using XML::Simple with XML::LibXML (Leif Wessman)
Getting Values from Hashes <georgekinley@hotmail.com>
Re: Getting Values from Hashes <noreply@gunnar.cc>
Re: Getting Values from Hashes <ittyspam@yahoo.com>
Re: Getting Values from Hashes <georgekinley@hotmail.com>
Re: Getting Values from Hashes <ittyspam@yahoo.com>
Keypress automation? (Asmo)
Re: Keypress automation? <usenet@morrow.me.uk>
Re: Need help with column printing <Lynn.Watts@ugs.com>
Re: Need help with column printing (Anno Siegel)
Re: pattern match problem <matthew.garrish@sympatico.ca>
Re: Perl and Sun Grid Engine (SGE) (Peter Scott)
Re: random underslashes and single regex <pinyaj@rpi.edu>
Re: Why won't this split file script work? <bik.mido@tiscalinet.it>
Digest Administrivia (Last modified: 6 Apr 01) (Perl-Users-Digest Admin)
----------------------------------------------------------------------
Date: 18 Jun 2004 04:35:24 -0700
From: bl8n8r@yahoo.com (bad_knee)
Subject: "antispam" perl mods?
Message-Id: <e817ca4d.0406180335.1ed2d26e@posting.google.com>
I'm looking for a way to check mail on a pop3 server against something
like a Spamcop (http://www.spamcop.net/bl.shtml> blacklist before I
download it.
Anyone have some simple ideas?
I tried building Spamassassin on solaris 9 sparc yesterday and make
test produced
a lot of errors about versions. Upgraded to perl5.8 and of course now
have to download/rebuild all the extra modules added in 5.6. I bet
there is an easier way to do this?
Thanks for your time
bl8n8r
------------------------------
Date: Fri, 18 Jun 2004 15:30:21 +0200
From: Josef Moellers <josef.moellers@fujitsu-siemens.com>
Subject: Re: "antispam" perl mods?
Message-Id: <cauqhc$qt8$1@nntp.fujitsu-siemens.com>
bad_knee wrote:
> I'm looking for a way to check mail on a pop3 server against something
> like a Spamcop (http://www.spamcop.net/bl.shtml> blacklist before I
> download it.
> Anyone have some simple ideas? =20
I did an antispam program in perl that checked the host which handed=20
over the mail into our company network ("Received: "). I had a list of=20
host names and networks that originated spam. I also had some means to=20
check for From: and Subject: patterns.
It was based on IMAP, though.
--=20
Josef M=F6llers (Pinguinpfleger bei FSC)
If failure had no penalty success would not be a prize
-- T. Pratchett
------------------------------
Date: Fri, 18 Jun 2004 10:18:31 -0400
From: Richard Morse <remorse@partners.org>
Subject: Re: $NF for perl
Message-Id: <remorse-63F10E.10183118062004@plato.harvard.edu>
In article <Pine.A41.4.58.0406051847200.7498@ginger.libs.uga.edu>,
Brad Baxter <bmb@ginger.libs.uga.edu> wrote:
> And the assignment to $n... provides the scalar context, so scalar() isn't
> needed. There are good reasons not to use scalar() when it isn't needed.
What would such reasons be? I often use it for clarity's sake even when
it isn't strictly necessary -- what side effects does it have that might
be invidious? `perldoc -f scalar` and `perldoc -q scalar` don't seem to
note any deleterious side effects...
Ricky
------------------------------
Date: 18 Jun 2004 05:12:54 -0700
From: jl_post@hotmail.com (J. Romano)
Subject: Re: A neat trick to serialize arrays and hashes
Message-Id: <b893f5d4.0406180412.6a1e08bd@posting.google.com>
"Matt Garrish" <matthew.garrish@sympatico.ca> wrote in message news:<tFtAc.36736$nY.1164005@news20.bellglobal.com>...
>
> Sorry to rain on your parade, but with
> all the caveats don't you think it
> would be better just to use the Storable
> module, especially since it's part
> of the core distribution? Better
> techniques are worth noting for the simple
> reason that they're better...
I remember learning about Storable a while back, but I didn't think
it was part of the core distribution. When I run:
perl -e "use Storable"
I get: Can't locate Storable.pm in @INC (...)
In case you're wondering, the first line of my "perl -v" output is:
This is perl, v5.6.1 built for i386-linux
It could be that I'm using an old version of Perl. So for those
who are using a version too old to have the Storable module (and, for
some reason, are unable to install that module), they can still use
the "(w/a*)*" serialization trick in a pinch.
-- Jean-Luc
------------------------------
Date: Fri, 18 Jun 2004 21:51:51 +1000
From: Sisyphus <kalinaubears@iinet.net.au>
Subject: Re: Can't locate package AutoLoader for @File::List::ISA at...
Message-Id: <40d2d88a$0$28944$5a62ac22@per-qv1-newsreader-01.iinet.net.au>
Shahriar wrote:
> Hi Folks,
>
> I just installed *FILE-LIST* from ASP. I am running ASP (see below for
> version information)
> does any one know about this error:
>
> This is perl, v5.8.3 built for MSWin32-x86-multi-thread
> (with 8 registered patches, see perl -V for more detail)
>
> Copyright 1987-2003, Larry Wall
>
> Binary build 809 provided by ActiveState Corp. http://www.ActiveState.com
> ActiveState is a division of Sophos.
> Built Feb 3 2004 00:28:51
>
> Regards,
>
> -shahriar
>
>
The version of ActiveState perl that you're running probably has nothing
to do with the error you're getting.
What are you doing that's producing the error (ie what code are you
running) ?
Cheers,
Rob
--
To reply by email u have to take out the u in kalinaubears.
------------------------------
Date: Fri, 18 Jun 2004 14:39:05 +0200
From: Michael Krueger <kruger@math.fu-berlin.de>
Subject: Encoding question
Message-Id: <Pine.LNX.4.44.0406181427290.25603-100000@vader.inf.fu-berlin.de>
Hi,
I have a text based application and want to draw some kind of frame, on
the screen. OS is Debian/Linux using Perl 5.6
I'm using this code:
-- snip ---
my $top = chr(201);
my $bottom = chr(200);
for (my $i = 0; $i < ($termCols-2); $i++)
{
$top .= chr(205);
$bottom .= chr(205);
}
$top .= chr(187);
$bottom .= chr(188);
$term->Tgoto('cm', 0, 0, *STDOUT);
print $top;
for (my $i = 1; $i < ($termRows-1); $i++)
{
$term->Tgoto('cm', 0, $i, *STDOUT);
print chr(186);
$term->Tgoto('cm', $termCols-1, $i, *STDOUT);
print chr(186);
}
$term->Tgoto('cm', 0, $termRows-2, *STDOUT);
print $bottom;
-- snip --
Where $termCols and $termRows are the current terminal lines and columns.
Problem:
Due to the encoding to latin-1 charset I didn't get the expected
frame-symbols but some other accentuated(?) chars.
How can I change the encoding that I can use the extended ASCII set, which
is referred often as the most common e.g. on www.asciitable.com, which
contains these frame-symbols?
I'm aware of 'use encoding "..";' but I just can't find the correct table. :(
michael
------------------------------
Date: Fri, 18 Jun 2004 12:59:05 +0000 (UTC)
From: Ben Morrow <usenet@morrow.me.uk>
Subject: Re: Encoding question
Message-Id: <cauoup$942$1@wisteria.csv.warwick.ac.uk>
Quoth Michael Krueger <kruger@math.fu-berlin.de>:
> Hi,
> I have a text based application and want to draw some kind of frame, on
> the screen. OS is Debian/Linux using Perl 5.6
>
> I'm using this code:
>
> -- snip ---
> my $top = chr(201);
> my $bottom = chr(200);
> for (my $i = 0; $i < ($termCols-2); $i++)
for my $i (0 .. ($termCols-2)) {
is much more Perlish...
> {
> $top .= chr(205);
> $bottom .= chr(205);
> }
> $top .= chr(187);
> $bottom .= chr(188);
...but even more so would be
my $top = chr(201) . (chr(205) x ($termCols - 2)) . chr(187);
> $term->Tgoto('cm', 0, 0, *STDOUT);
I'm not sure which class these methods are from, but you might consider
using Term::ANSIScreen instead...
> print $top;
> for (my $i = 1; $i < ($termRows-1); $i++)
> {
> $term->Tgoto('cm', 0, $i, *STDOUT);
> print chr(186);
> $term->Tgoto('cm', $termCols-1, $i, *STDOUT);
> print chr(186);
> }
> $term->Tgoto('cm', 0, $termRows-2, *STDOUT);
> print $bottom;
> -- snip --
>
> Where $termCols and $termRows are the current terminal lines and columns.
>
> Problem:
> Due to the encoding to latin-1 charset I didn't get the expected
> frame-symbols but some other accentuated(?) chars.
The first thing to say is that if you want to mess with encodings,
upgrade to perl 5.8. 5.8 supports Unicode properly, and through that all
other encodings. The encoding pragma you mention only works in 5.8 (and
doesn't do what I think you think it does: it changes the encoding your
*program source* is considered to be in: i.e. the encoding of string
literals in the source).
There are, potentially, three encodings in use here: the one perl uses
to convert the numbers in your source into characters, the one perl uses
to convert the characters back to numbers again to send to the terminal,
and the one the terminal uses to decide which glyph to draw.
An easy and straightforward way to get rid of the first is the use
"\N{...}" instead of chr, and look up the correct characters in the Big
Ol' Unicode Character List <http://www.unicode.org/charts/>. You control
the second using the :encoding layer on filehandles: see perldoc -f
binmode, perldoc PerlIO::encoding.
The third is I think your problem here: your terminal is expecting
Latin-1 (entirely usual in the Unix world) and there are no box drawing
characters in Latin-1. Your best answer is to persuade your terminal to
want utf8 instead (unicode_start on the console, xterm -u8, most other
terminal emulators will support it with an option); then you can call
binmode STDOUT, ':utf8' and use the Unicode box-drawing characters.
Ben
--
$.=1;*g=sub{print@_};sub r($$\$){my($w,$x,$y)=@_;for(keys%$x){/main/&&next;*p=$
$x{$_};/(\w)::$/&&(r($w.$1,$x.$_,$y),next);$y eq\$p&&&g("$w$_")}};sub t{for(@_)
{$f&&($_||&g(" "));$f=1;r"","::",$_;$_&&&g(chr(0012))}};t # ben@morrow.me.uk
$J::u::s::t, $a::n::o::t::h::e::r, $P::e::r::l, $h::a::c::k::e::r, $.
------------------------------
Date: 18 Jun 2004 06:01:27 -0700
From: leifwessman@hotmail.com (Leif Wessman)
Subject: Error when using XML::Simple with XML::LibXML
Message-Id: <64beeaad.0406180501.1728ea95@posting.google.com>
I've successfully installed XML::Simple and XML::LibXML.
the following code gives me an error:
----
#!/usr/local/bin/perl
...
use XML::Simple;
$XML::Simple::PREFERRED_PARSER = 'XML::LibXML';
my $xs1 = XML::Simple->new();
my $doc = $xs1->XMLin($input, forcearray=>1);
----
The error is:
Can't locate object method "xml_decl" via package "XML::Simple" at
/home/leif/perl/lib/perl5/site_perl/5.8.0/i386-linux/XML/LibXML.pm
line 369.
at /home/leif/perl/lib/perl5/site_perl/5.8.0/XML/Simple.pm line 295
What have I done wrong?
Leif
------------------------------
Date: Fri, 18 Jun 2004 10:07:51 GMT
From: "George Kinley" <georgekinley@hotmail.com>
Subject: Getting Values from Hashes
Message-Id: <X9zAc.19356$g4.372870@news2.nokia.com>
Hi
I have an hash as $Hash{Name}{NickName}
Where Name is String
NickName Array
I can get All NickName in an array as
@AllNN=values @{$$Hash{Name}}
my query is Why I cant get the same result with
@AllNN=values %{$Hash{Name}}
or
@AllNN=values $Hash{Name}
--
------------------------------
Date: Fri, 18 Jun 2004 12:56:17 +0200
From: Gunnar Hjalmarsson <noreply@gunnar.cc>
Subject: Re: Getting Values from Hashes
Message-Id: <2jg02oF111f3sU1@uni-berlin.de>
George Kinley wrote:
> I have an hash as $Hash{Name}{NickName}
> Where Name is String
> NickName Array
> I can get All NickName in an array as
>
> @AllNN=values @{$$Hash{Name}}
I find that hard to believe. Please post a short but complete program
that people can copy and run, and that illustrates what you have.
--
Gunnar Hjalmarsson
Email: http://www.gunnar.cc/cgi-bin/contact.pl
------------------------------
Date: Fri, 18 Jun 2004 06:58:01 -0400
From: Paul Lalli <ittyspam@yahoo.com>
Subject: Re: Getting Values from Hashes
Message-Id: <20040618064316.I20623@dishwasher.cs.rpi.edu>
On Fri, 18 Jun 2004, George Kinley wrote:
> Hi
> I have an hash as $Hash{Name}{NickName}
> Where Name is String
> NickName Array
> I can get All NickName in an array as
>
> @AllNN=values @{$$Hash{Name}}
>
> my query is Why I cant get the same result with
> @AllNN=values %{$Hash{Name}}
> or
> @AllNN=values $Hash{Name}
>
Analize your datastructure. It looks something like this, yes?
%Hash = (
'Robert' => ['Bob', 'Rob'],
'William' => ['Will', 'Billy'],
);
Now analize the code you were trying to use.
values %{$Hash{'Robert'}}
$Hash{'Robert'} is an array reference. It references an array containing
Bob and Rob. You cannot derefernce this as a hash because it is not a
hash reference.
values $Hash{'Robert'}
$Hash{'Robert'} is an array reference. You cannot use values on an array
reference. The argument to values() must be a hash.
I don't quite understand your claim that values @{$$Hash{Name}} works like
you want it. Even if I have misunderstood your datastructure, you cannot
pass an array to values(). This is a syntax error.
Using the datastructure I typed above, you would get all the nicknames for
a particular name like this:
@nicks = @{$Hash{'Robert'}};
If you want *all* nicknames, you could use something like this:
@all_nicks = map { @{$Hash{$_}} } keys %Hash;
If you need further assistance (if, for example, I have not understood
your description of your datastructure), please post a short but complete
program demonstrating your issue.
Thank you,
Paul Lalli
------------------------------
Date: Fri, 18 Jun 2004 11:18:24 GMT
From: "George Kinley" <georgekinley@hotmail.com>
Subject: Re: Getting Values from Hashes
Message-Id: <4cAAc.19363$g4.373148@news2.nokia.com>
Paul Lalli wrote:
> On Fri, 18 Jun 2004, George Kinley wrote:
>
> > Hi
> > I have an hash as $Hash{Name}{NickName}
> > Where Name is String
> > NickName Array
> > I can get All NickName in an array as
> >
> > @AllNN=values @{$$Hash{Name}}
> >
> > my query is Why I cant get the same result with
> > @AllNN=values %{$Hash{Name}}
> > or
> > @AllNN=values $Hash{Name}
> >
>
> Analize your datastructure. It looks something like this, yes?
>
> %Hash = (
> 'Robert' => ['Bob', 'Rob'],
> 'William' => ['Will', 'Billy'],
> );
>
>
> Now analize the code you were trying to use.
>
> values %{$Hash{'Robert'}}
>
> $Hash{'Robert'} is an array reference. It references an array
> containing Bob and Rob. You cannot derefernce this as a hash because
> it is not a hash reference.
>
> values $Hash{'Robert'}
>
> $Hash{'Robert'} is an array reference. You cannot use values on an
> array reference. The argument to values() must be a hash.
>
> I don't quite understand your claim that values @{$$Hash{Name}} works
> like you want it. Even if I have misunderstood your datastructure,
> you cannot pass an array to values(). This is a syntax error.
>
> Using the datastructure I typed above, you would get all the
> nicknames for a particular name like this:
> @nicks = @{$Hash{'Robert'}};
>
> If you want all nicknames, you could use something like this:
>
> @all_nicks = map { @{$Hash{$_}} } keys %Hash;
>
>
>
> If you need further assistance (if, for example, I have not understood
> your description of your datastructure), please post a short but
> complete program demonstrating your issue.
>
> Thank you,
> Paul Lalli
I believe its my mistake that I did not mentioned that I was getting
this HASH as reference from another procedure, so that is the reason I
need to dereference it by double "$"
--
------------------------------
Date: Fri, 18 Jun 2004 07:39:10 -0400
From: Paul Lalli <ittyspam@yahoo.com>
Subject: Re: Getting Values from Hashes
Message-Id: <20040618073734.E20623@dishwasher.cs.rpi.edu>
On Fri, 18 Jun 2004, George Kinley wrote:
> Paul Lalli wrote:
>
> > On Fri, 18 Jun 2004, George Kinley wrote:
> >
> > > Hi
> > > I have an hash as $Hash{Name}{NickName}
> > > Where Name is String
> > > NickName Array
> > > I can get All NickName in an array as
> > >
> > > @AllNN=values @{$$Hash{Name}}
> > >
> > > my query is Why I cant get the same result with
> > > @AllNN=values %{$Hash{Name}}
> > > or
> > > @AllNN=values $Hash{Name}
> > >
> >
> > I don't quite understand your claim that values @{$$Hash{Name}} works
> > like you want it. Even if I have misunderstood your datastructure,
> > you cannot pass an array to values(). This is a syntax error.
> >
>
> I believe its my mistake that I did not mentioned that I was getting
> this HASH as reference from another procedure, so that is the reason I
> need to dereference it by double "$"
This is not at all the issue. You're claiming that you're passing an
array (something that starts with '@') to the values() function. This
doesn't work. It's a syntax error. It doesn't matter how many levels of
dereferencing are involved.
Post a short but complete program that illustrates your problem if you're
still having one.
Paul Lalli
------------------------------
Date: 18 Jun 2004 05:53:10 -0700
From: sap6210@rit.edu (Asmo)
Subject: Keypress automation?
Message-Id: <cf6bc6e2.0406180453.273b2a54@posting.google.com>
Hi, I'm trying to write some scripts that open up other programs, then
send keypresses to them. I'm trying to use this report generation
software, and hopefully automate the report generation process, but it
prompts for start and end dates for the report, and if I could manage
to automate that, it would simplify my life immensely.
Is there a module I should look for, or something?
Thanks guys.
Steve
------------------------------
Date: Fri, 18 Jun 2004 13:02:51 +0000 (UTC)
From: Ben Morrow <usenet@morrow.me.uk>
Subject: Re: Keypress automation?
Message-Id: <caup5r$942$2@wisteria.csv.warwick.ac.uk>
Quoth sap6210@rit.edu (Asmo):
> Hi, I'm trying to write some scripts that open up other programs, then
> send keypresses to them. I'm trying to use this report generation
> software, and hopefully automate the report generation process, but it
> prompts for start and end dates for the report, and if I could manage
> to automate that, it would simplify my life immensely.
>
> Is there a module I should look for, or something?
What sort of program is it, and what OS?
If it's a GUI program, you're out of luck. If it's a a text-mode
program, and you're on a Unixish OS, then you want Expect.pm. If you're
not, then you still want Expect.pm but it probably doesn't work on your
platform... :(
Ben
--
"If a book is worth reading when you are six, * ben@morrow.me.uk
it is worth reading when you are sixty." - C.S.Lewis
------------------------------
Date: Fri, 18 Jun 2004 05:53:31 -0700
From: "Lynn" <Lynn.Watts@ugs.com>
Subject: Re: Need help with column printing
Message-Id: <40d2e81c$1@usenet.ugs.com>
Anno Siegel wrote:
> Lynn <Lynn.Watts@ugs.com> wrote in comp.lang.perl.misc:
>> Hi All,
>>
>
> First off, thanks for supplying runnable code that shows the problem.
> That makes my job a lot easier. (This is "my job" because I happen to
> be the author of Text::Table.)
Anything I can do to get an answer I will do. Doesn't evernone do that?
after all I do want to get a reply to my question :-)
>
> The alignment is messed up where you build the @percent array. See my
> comment in the code.
>
[snipped]
>> use vars qw(@by_family $TOTAL $BLOG $HP $IBM $SGI $SUN $WIN $OTH);
>
> Why are you using package variables here? From the posted code, there
> is no reason why these couldn't be lexicals like other variables.
Because I was getting the "Global symbol "whatever" requires explicit
package name errors.
It was the only way I knew how to get rid of the warnings.
>
>> my @stuff = qw(TOTAL BLOG HP IBM SGI SUN WIN OTH);
>
> Putting the keys into a sequence is a good idea, but you're not making
> good use of the list.
Ok
>
[snipped]
>
> If you *want* undef to be treated as zero, that's a good time to say
>
> no warnings 'uninitialized';
>
> and let Perl handle it.
>
I was unaware of this. When ever I start to develop a script I use the
use warnings line and leave warnings alone.
>> push ( @by_family, $TOTAL, $BLOG, $HP, $IBM, $SGI, $SUN, $WIN, $OTH
>> );
>
> Why the push()? @by_family is empty, so an assignment would be
> clearer.
>
> @by_family = ( $TOTAL, $BLOG, $HP, $IBM, $SGI, $SUN, $WIN, $OTH );
Ok, I understand.
>
>> my @percent = ();
>>
>> push ( @percent, sprintf( '%2d', ( 100 * $by_family[2] /
>> $by_family[0] ) ) ) unless !( defined( $by_family[2] ) or '0' );
>
> "unless !" is better written as "if". Also, "or '0'" does nothing to
> the boolean value of the expression. The whole condition could be
> written
>
> if defined $by_family[ 2];
yes, that would be cleaner
>
> ...but it is wrong anyway. If a column isn't defined, you should push
> a 0, or a "", or a "-", or anything onto the array. Otherwise the
> *next* column will slip into its place. That's what messes up the
> alignment.
Ok, here is where I made my mistake.
>
[snipped incorrect code]
>
> You have made it unnecessary hard to get the alignment right. For the
> "TOTAL" and "PERCENT TOTAL" lines you are using arrays, whiled you use
> a hash for the fundamental data structure.
>
> Build the "total" and "percent" structures after the model of your
> basic structure, as hashes keyed on @stuff. Then it will be much
> easier to
> keep things aligned. After the setup of %people, this is how I would
> continue:
>
[snipped]
> The percent data is calculated for two cases that aren't needed
> (TOTAL and BLOG). It would have been more difficult to exclude them.
> Instead, we
> exclude them using only @stuff[ 2 .. $#stuff]. Add two 'N/A's, skip
> two items in @stuff... the columns clearly stay aligned.
yep! This makes sense :-)
I would like to thank you for taking the time to respond.
It's nice to know that newbies to perl/programming have a place
to go for help.
Lynn
------------------------------
Date: 18 Jun 2004 13:43:41 GMT
From: anno4000@lublin.zrz.tu-berlin.de (Anno Siegel)
Subject: Re: Need help with column printing
Message-Id: <caurid$hmn$1@mamenchi.zrz.TU-Berlin.DE>
thundergnat <thundergnat@hotmail.com> wrote in comp.lang.perl.misc:
> Lynn wrote:
> > Hi All,
> >
> > I am having problems generating a report (Columns) from data
> > that is in the form of associative arrays of associative arrays.
> >
> > I have provided an example of what I am trying to do. I the problem
> > is I am unable to align the percent column. Any advise as
> > how to fix this?
> >
> > Thanks
> >
> > Lynn
> >
>
> The misalignment is due to the different handling of numbers and
> strings. Your counts are all numbers but your percentages are strings.
> If you make your percentages numbers too, they all line up.
That is not the reason. Text::Table (and Text::Aligner) treat all
data as strings. The problem was that the percentage line didn't
*have* data for all columns.
Anno
------------------------------
Date: Fri, 18 Jun 2004 09:24:55 -0400
From: "Matt Garrish" <matthew.garrish@sympatico.ca>
Subject: Re: pattern match problem
Message-Id: <F2CAc.39052$nY.1219018@news20.bellglobal.com>
"Joe Smith" <Joe.Smith@inwap.com> wrote in message
news:v1xAc.62123$eu.27793@attbi_s02...
> Matt Garrish wrote:
>
> > "Michal Wojciechowski" <odyniec-usenet@odyniec.net> wrote in message
> > news:87wu262hhf.fsf@odyniec.odyniec.net...
> >
> >>"Lex" <nospam@peng.nl> writes:
> >>
> >>[...]
> >>
> >>
> >>>look for <pre> and </pre> and erase all the <br> that you find
> >>>within it, no matter what you find. However: leave the rest! (
> >>>linebreaks etc.)
> >>
> >>[...]
> >>
> >>
> >>>$rec{'Text'} =~ s%<pre>(.*?)<br>(.*?)</pre>%<pre>$1 $2</pre>%gim;
> >>
> >>The above would work, if it could match overlapping occurrences. One
> >>solution is to use it in a loop, like:
> >>
> >> while (s!<pre>(.*?)<br>(.*?)</pre>!<pre>$1 $2</pre>!sig) {}
> >
> > Two quick things: you want foreach not while, and pre and break tags can
> > include style definitions etc., so best to check for <br[^>]*>.
>
> No, foreach() will remove only the first <br>, not all of them.
>
Ugh, that was just bad on my part, especially since I knew he wanted
multiple passes to clear them out. I ran it with <br /> tags before
modifying the expression, which is why it looked like it wasn't working (I
was just going to make mention of the html formatting, because there's even
less of a point in using a regex if you aren't going to make sure you
capture as many oddities as you can).
Matt
------------------------------
Date: Fri, 18 Jun 2004 12:36:41 GMT
From: peter@PSDT.com (Peter Scott)
Subject: Re: Perl and Sun Grid Engine (SGE)
Message-Id: <tlBAc.796851$oR5.352847@pd7tw3no>
In article <25606b19.0406171355.1067d340@posting.google.com>,
lxh4info@yahoo.com (Leo) writes:
>I'm writing code to run on a cluster machine. Basically I need to run
>a Perl program 200 times and each time generate a line of the output.
>I use a C-shell script to call the perl progam and distribute it
>through Sun Grid Engine(SGE) to the nodes of the cluster (because SGE
>only takes shell script).
You may want to read this:
http://www.faqs.org/faqs/unix-faq/shell/csh-whynot/
One hopes that SGE at least has Bourne as an alternative...
--
Peter Scott
http://www.perldebugged.com/
*** NEW *** http://www.perlmedic.com/
------------------------------
Date: Fri, 18 Jun 2004 10:58:25 -0400
From: Jeff 'japhy' Pinyan <pinyaj@rpi.edu>
Subject: Re: random underslashes and single regex
Message-Id: <Pine.SGI.3.96.1040618105810.333682A-100000@vcmr-64.server.rpi.edu>
On Thu, 17 Jun 2004, Jeff 'japhy' Pinyan wrote:
> sub in3 {
> @_=(our$i=\$_[2],@_);$_[1]=~m{\A(?>\z|(?{"\Q@{[substr$_[2
> ],0,1,'']}"})((??{"[^$^R]*$^R"}))(?{''ne$1&&chop($$i.=$1)
> })(?(?{$_[2]eq''})(?{$$i.=$'}).*))+(?(?{$_[2]ne''}).^)}xs
> }
It turns out this one is broken. :(
--
Jeff Pinyan RPI Acacia Brother #734 RPI Acacia Corp Secretary
"And I vos head of Gestapo for ten | Michael Palin (as Heinrich Bimmler)
years. Ah! Five years! Nein! No! | in: The North Minehead Bye-Election
Oh. Was NOT head of Gestapo AT ALL!" | (Monty Python's Flying Circus)
------------------------------
Date: Fri, 18 Jun 2004 15:04:52 +0200
From: Michele Dondi <bik.mido@tiscalinet.it>
Subject: Re: Why won't this split file script work?
Message-Id: <tro5d05o185ja6h98m72r8ap32n4uum617@4ax.com>
On Thu, 17 Jun 2004 18:49:54 GMT, "Max" <max@NOSPAMkipness.com> wrote:
>I can't seem to figure out what I'm doing wrong, or maybe I'm just rushing
>as I need to split a 15000 line file into chunks.
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
BTW: but this is *not* what your script below is supposed to do!
>This script is supposed to work by giving the line number you want to start
>at and the line number you want to stop at. It should copy all lines in
>between the start and stop number to a file called $file-split. But it
>doesn't seem to work. If someone has a few minutes, can you tell me what
>I'm doing wrong.
Others already told you. This is how I would do it (just printing to
STDOUT and generalized to more -or no- files on the cmd line):
#!/usr/bin/perl
use strict;
use warnings;
die "Usage: $0 <start> <stop> [<file(s)>]\n" unless @ARGV>=2;
my ($start,$stop)=(shift,shift);
while (<>) {
print if $. == $start .. ($. == $stop and close ARGV);
}
__END__
HTH,
Michele
--
you'll see that it shouldn't be so. AND, the writting as usuall is
fantastic incompetent. To illustrate, i quote:
- Xah Lee trolling on clpmisc,
"perl bug File::Basename and Perl's nature"
------------------------------
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.
NOTE: due to the current flood of worm email banging on ruby, the smtp
server on ruby has been shut off until further notice.
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 6704
***************************************