[19293] in Perl-Users-Digest

home help back first fref pref prev next nref lref last post

Perl-Users Digest, Issue: 1488 Volume: 10

daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Fri Aug 10 14:06:12 2001

Date: Fri, 10 Aug 2001 11:05:15 -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: <997466715-v10-i1488@ruby.oce.orst.edu>
Content-Type: text

Perl-Users Digest           Fri, 10 Aug 2001     Volume: 10 Number: 1488

Today's topics:
    Re: A Simple Regular Expression !! <samneric@tigerriverOMIT-THIS.com>
    Re: A Simple Regular Expression !! <ren@tivoli.com>
    Re: Coercing list context onto pair of regexps in a com (Anno Siegel)
    Re: Coercing list context onto pair of regexps in a com (Anno Siegel)
    Re: Coercing list context onto pair of regexps in a com (Anno Siegel)
        DBI:CSV SQL 'order by' problem <neisius@earthlink.net>
    Re: Email +Perl <yanoff@yahoo.com>
        How can I get variables interpeted in qw// ? (Stan Brown)
    Re: How can I get variables interpeted in qw// ? (Tad McClellan)
    Re: How can I get variables interpeted in qw// ? (Malcolm Dew-Jones)
    Re: How could chomp the blanks of one sentence? <lukasz@hard.at.work>
        HOW: convert a string into an integer <trullock@yahoo.com>
    Re: HOW: convert a string into an integer (E.Chang)
    Re: HOW: convert a string into an integer (Eric Bohlman)
        ipc::open3 and select (Jason Kawaja)
    Re: Is an element in a table ? <tinamue@zedat.fu-berlin.de>
    Re: Is this a Perl bug? <ren@tivoli.com>
    Re: Is this a Perl bug? <ren@tivoli.com>
    Re: Learning Perl, 2nd Edition <lmoran@wtsg.com>
    Re: mySQL - More records or longer records - Speed? (Mark Deibert)
        Need PERL exp to t-shoot ad rotationa (Aceweb45)
        Need PERL exp to t-shoot ad rotational (Aceweb45)
        new to Perl <honghsu@bellatlantic.net>
    Re: new to Perl nobull@mail.com
    Re: new to Perl (Tad McClellan)
    Re: Newsletter Script <Thomas@Baetzler.de>
    Re: Newsletter Script <lmoran@wtsg.com>
    Re: Newsletter Script <bcaligari@fireforged.com>
        Digest Administrivia (Last modified: 6 Apr 01) (Perl-Users-Digest Admin)

----------------------------------------------------------------------

Date: Fri, 10 Aug 2001 12:48:02 -0400
From: Samneric <samneric@tigerriverOMIT-THIS.com>
Subject: Re: A Simple Regular Expression !!
Message-Id: <3B741042.45698548@tigerriverOMIT-THIS.com>

Henry Butowsky wrote:
> I need to see if two strings are equal have tried
> e.g $country = "BIAFRA(HELLO)"
> 
> .eg if(  $test =~ /^$country$/ ){ .... }
> 
> But the expression doen't work when there are brackets in the string,

Simply using "eq" to compare the strings is the direct way. But if your
question is meant to find out how to do this with a regex, then either
use "quotemeta" when assigning a value to $country:

$country = quotemeta "country<{[()]}>string";
if ($test =~ /^$country$/)...

Or - even easier - DON'T use quotemeta on the assignment, but turning it
on and off in the pattern instead:

if ($test =~ /^\Q$country\E$/)...


------------------------------

Date: 10 Aug 2001 10:02:29 -0500
From: Ren Maddox <ren@tivoli.com>
Subject: Re: A Simple Regular Expression !!
Message-Id: <m3d764arga.fsf@dhcp9-161.support.tivoli.com>

On Fri, 10 Aug 2001, henryb@ntlworld.com wrote:

> I need to see if two strings are equal have tried
> e.g $country = "BIAFRA(HELLO)"

As has been mentioned, "eq" is for string equality tests.

> .eg if(  $test =~ /^$country$/ ){ .... }
> 
> But the expression doen't work when there are brackets in the
> string, Anybody got any ideas what I can do ?

You need to quotemeta() the expression to protect any special
characters:

  /^\Q$country\E$/

but "eq" is the real answer.

-- 
Ren Maddox
ren@tivoli.com


------------------------------

Date: 10 Aug 2001 15:37:09 GMT
From: anno4000@lublin.zrz.tu-berlin.de (Anno Siegel)
Subject: Re: Coercing list context onto pair of regexps in a comparison
Message-Id: <9l0v35$ql$2@mamenchi.zrz.TU-Berlin.DE>

According to Brent Dax <brentdax1@earthlink.net>:
> "pt" <mnemotronic@yahoo.com> wrote in message
> news:da662010.0108091512.75f7c4d3@posting.google.com...
> > I would like to force a pair of regular expressions to be evaluted in
> > list context, so that they return $1.
> >
> > next unless ("\L$A" =~ /.*\.(.+)$/) eq ("\L$B" =~ m#.*/(.*)$#) ;
> >             -----------------------    -----------------------
> >
> >   The goal is to compare the file extension portion of $A (after the
> > '.') with the filename portion of $B (after the last '/' delimiter),
> > and do something if equal/not equal.  List context for each regexp
> > portion (underlined) will force each to return the grouped expression
> > ($1) for the string comparison.
> 
> What's wrong with just using m{(?<=\.).*$} and m{(?<=/).*$} ?
 
Nothing is wrong, but unless I'm dense I don't see how it solves
the problem.  We want to know if what the first .* matches is the
same thing (modulo upper/lower case) the second .* matches.

> m{
>     (?<=    #backreference

That's a lookbehind.  In regex parlance, a backreference is the usage
of partial matches in other parts of a regex (what we do with \1 and
friends).

[...]

Anno


------------------------------

Date: 10 Aug 2001 15:46:26 GMT
From: anno4000@lublin.zrz.tu-berlin.de (Anno Siegel)
Subject: Re: Coercing list context onto pair of regexps in a comparison
Message-Id: <9l0vki$ql$3@mamenchi.zrz.TU-Berlin.DE>

According to Tina Mueller  <news@tinita.de>:
> Tina Mueller <tinamue@zedat.fu-berlin.de> wrote:
> > pt <mnemotronic@yahoo.com> wrote:
> >> I would like to force a pair of regular expressions to be evaluted in
> >> list context, so that they return $1.
> 
> >> next unless ("\L$A" =~ /.*\.(.+)$/) eq ("\L$B" =~ m#.*/(.*)$#) ;
> >>             -----------------------    -----------------------
> > next unless (($x) = "\L$A" =~ /.*\.(.+)$/g) eq (($y)="\L$B" =~ m#.*/(.*)$#g) ;
> 
> oops. just saw uri's posting that comes without the extra-variables...

Yes, but Uri's works because the single match is the first one and
your's because it's the last one.

> i should go to bed.

Perl Zen.  Maybe I should too.

Anno


------------------------------

Date: 10 Aug 2001 16:06:15 GMT
From: anno4000@lublin.zrz.tu-berlin.de (Anno Siegel)
Subject: Re: Coercing list context onto pair of regexps in a comparison
Message-Id: <9l10pn$ql$4@mamenchi.zrz.TU-Berlin.DE>

According to Uri Guttman  <uri@sysarch.com>:
> >>>>> "EB" == Eric Bohlman <ebohlman@omsdev.com> writes:
> 
>   EB> pt <mnemotronic@yahoo.com> wrote:
>   >> I would like to force a pair of regular expressions to be evaluted in
>   >> list context, so that they return $1.
> 
>   >> next unless ("\L$A" =~ /.*\.(.+)$/) eq ("\L$B" =~ m#.*/(.*)$#) ;
>   >> -----------------------    -----------------------
>   >> 
>   >> The goal is to compare the file extension portion of $A (after the
>   >> '.') with the filename portion of $B (after the last '/' delimiter),
>   >> and do something if equal/not equal.  List context for each regexp
>   >> portion (underlined) will force each to return the grouped expression
>   >> ($1) for the string comparison.
> 
>   EB> I think you've got an XY problem.  You can't compare two lists,
>   EB> even single-element ones, with a single operator, so there's no
>   EB> point in trying to get the matches into list contexts.  But with a
>   EB> little creativity, and back-references, you can get the whole
>   EB> thing into one regex:
> 
> you can compare a single element of a list to another single
> element. just do this:
> 
> 	("\L$A" =~ /.*\.(.+)$/)[0] eq ("\L$B" =~ m#.*/(.*)$#)[0]
> 
> now,he may have an XY problem as well, but his request can be done easily.

Actually, I like it.  It's pretty readable.  The more straightforward

    $A =~ m!([^.]*)$! && $B =~ m!/($1)$!i

costs a runtime regex and isn't any clearer.

>   EB> next unless "\L$A;$B" =~ /.*\.(.+);.*/\1$/;
> 
>   EB> I'm assuming that the filenames can't contain semicolons; if they
>   EB> can, replace the semicolon with some character that can't occur in
>   EB> the filenames.
> 
> that is a poor hack. never use optimistic data assumptions or they will
> byte you in the ass one day.

You could do without a separator and use a lookahead for all of $B in
the concatenation to know where $A ends.  I'm not going there... :)

Anno



------------------------------

Date: Fri, 10 Aug 2001 16:31:01 GMT
From: "Bill Neisius" <neisius@earthlink.net>
Subject: DBI:CSV SQL 'order by' problem
Message-Id: <9%Tc7.267$Kl2.15463@newsread1.prod.itd.earthlink.net>

I've got a CSV file with a field containing 'paragraph' numbers which look
something like this:

    para,descr...
    5.13.1,"C description"...
    5.13.2,"A description"...
    5.13.3,"B description"...

The SQL select from this table:

    select para, descr from paragraph order by para, descr

return the rows in this order:
    5.13.2,"A description"
    5.13.3,"B description"
    5.13.1,"C description"

If I prefix the paragraph numbers with a letter, the 'order by' works and
returns
the paragraphs in the proper order...

Evidently, since the paragraph number starts with a number, Perl assumes
that
I want a numeric sort?  which works fine till it gets to the second decimal
point...
and throws away the rest of the field as non-numeric?

Any way to get Perl (actually the SQL statement package) to ONLY do an
alpha sort here?  Looks like a bug in Statement.pm: I guess I could change
it
there, but maybe there's a better way?




Bill Neisius
neisius@earthlink.net








------------------------------

Date: Fri, 10 Aug 2001 10:13:32 -0500
From: Scott Yanoff <yanoff@yahoo.com>
To: Ryan Gralinski <ryan@bong.net>
Subject: Re: Email +Perl
Message-Id: <3B73FA1C.E257ECB3@yahoo.com>

Ryan Gralinski wrote:
> 
> I'm writing a webmail program, and i got to the point where to display the
> messages from a POP3 server..
> Is there a special module to help display the message
> , for instance this is a sample message from the pop3 server., i need to
> know if theres a module allready written to display the text/html portion.

Have you tried CPAN?
I see a few when doing a search on "POP3":
http://search.cpan.org/search?mode=module&query=POP3

Good luck,
-- 
-Scott
yanoff@yahoo.com | http://www.yanoff.org | AOL IM: SAY KJY


------------------------------

Date: 10 Aug 2001 11:53:23 -0400
From: stanb@panix.com (Stan Brown)
Subject: How can I get variables interpeted in qw// ?
Message-Id: <9l101j$5i8$1@panix3.panix.com>

How can I get a variable inetpeted in a qw// sequence?




------------------------------

Date: Fri, 10 Aug 2001 11:45:39 -0400
From: tadmc@augustmail.com (Tad McClellan)
Subject: Re: How can I get variables interpeted in qw// ?
Message-Id: <slrn9n80d3.18o.tadmc@tadmc26.august.net>

Stan Brown <stanb@panix.com> wrote:

>How can I get a variable inetpeted in a qw// sequence?
                          ^^^^^^^^^
                          ^^^^^^^^^ interpolated, I assume?


You can't.

That suggests that you choose some other form of quoting.

Can't offer more help than that, because you haven't told us
what it is that you really need to accomplish.

You can always do:

   my @stuff = qw/zero one two/, $var, qw/four five six/;


-- 
    Tad McClellan                          SGML consulting
    tadmc@augustmail.com                   Perl programming
    Fort Worth, Texas


------------------------------

Date: 10 Aug 2001 10:02:41 -0800
From: yf110@vtn1.victoria.tc.ca (Malcolm Dew-Jones)
Subject: Re: How can I get variables interpeted in qw// ?
Message-Id: <3b7413b1@news.victoria.tc.ca>

Stan Brown (stanb@panix.com) wrote:
: How can I get a variable inetpeted in a qw// sequence?

You can't, that's the whole point.

However, since qw// provides a list, you can include it in a longer list,
which can do the same thing.

@my_things = ( qw/ one two three / ,
		"four and three quarters" , 
		$the_next_item , 
		@more_things ,
	       qw/ the last words in the list / );



--
Want to access the command line of your CGI account?  Need to debug your
installed CGI scripts?  Transfer and edit files right from your browser? 

What you need is "ispy.cgi" - visit http://nisoftware.com/ispy.cgi


------------------------------

Date: Fri, 10 Aug 2001 18:52:33 +0200
From: Lukasz Wiechec <lukasz@hard.at.work>
Subject: Re: How could chomp the blanks of one sentence?
Message-Id: <3B741151.8486E174@hard.at.work>

From "Perl Cookbook" by Tom Christiansen & Nathan Torkington:

sub trim
{                                                                  my
@out = @_;                                                            
for (@out)
{                                                               
s/^\s+//;                                                                
s/\s+$//;                                                             
 
}                                                                       
  return wantarray ? @out :
$out[0];                                      
}                                                                               
This strips leading and terminating whitespaces.

Luke

Wenjie ZHAO wrote:
> 
> Esp in front of the words, e.g. "    Hello    ", how
> could perl strip it to "Hello"?
> 
> Thanks !
> 
> --
> 
> Best regards,
> Wenjie
> 
> "If you would be real seeker after truth, it is
> necessary that at least once in your life you doubt,
> as far as possible, all things."


------------------------------

Date: Fri, 10 Aug 2001 17:44:06 +0100
From: "Trull" <trullock@yahoo.com>
Subject: HOW: convert a string into an integer
Message-Id: <N8Uc7.24161$e%3.2686102@news2-win.server.ntlworld.com>

i need to convert a string of "123" into an integer, so i can add it to
another integer.


whats the command?


cheers


--
']['rull




------------------------------

Date: Fri, 10 Aug 2001 17:00:49 GMT
From: echang@netstorm.net (E.Chang)
Subject: Re: HOW: convert a string into an integer
Message-Id: <Xns90F984F1CB43Fechangnetstormnet@207.106.93.86>

"Trull" <trullock@yahoo.com> wrote in
<N8Uc7.24161$e%3.2686102@news2-win.server.ntlworld.com>: 

> i need to convert a string of "123" into an integer, so i can add
> it to another integer.
> 
> 
> whats the command?

No special command.  Perl will convert as needed and appropriate,  For 
example

   print "123" + "456";

output:
   
   579

-- 
EBC


------------------------------

Date: 10 Aug 2001 17:01:00 GMT
From: ebohlman@omsdev.com (Eric Bohlman)
Subject: Re: HOW: convert a string into an integer
Message-Id: <9l140c$jos$2@bob.news.rcn.net>

Trull <trullock@yahoo.com> wrote:
> i need to convert a string of "123" into an integer, so i can add it to
> another integer.


> whats the command?

There isn't one.  perl will automatically do the conversion:

perl -e "print '123'+4"
127

(reverse the single and double quotes for Unix)



------------------------------

Date: Fri, 10 Aug 2001 16:22:34 +0000 (UTC)
From: kawaja@ece.ufl.edu (Jason Kawaja)
Subject: ipc::open3 and select
Message-Id: <slrn9n82jv.658.kawaja@kawaja.ece.ufl.edu>

i am attempting to 'capture' stdout and stderr of an externally called 
program from within a perl script.

here is what i have:

use strict;
use IPC::Open3;

# -----------------------------
# test sub
#
# CAUTION : infinite while loop
# -----------------------------

sub test {
 package test;
 our $prg  = $_[0];
 our $args = $_[1];
 our $data = '';
 our $wb   = '';
 local *O3IN;
 local *O3OUT;
 &::open3(\*O3IN, \*O3OUT, \*O3OUT, "$prg", "$args") ||
  die("fatal: unable to open3 $prg\'s handles - $!\n");;
 vec($wb,fileno(O3OUT),1) = 1;
 while (select(undef, $wb, undef, 0.25) == 1) {
  sysread(O3OUT, $data, 1);
  print(STDOUT "-->$data<--);
 }
 print(STDOUT 'free at last', "\n");
 close(O3IN);
 close(O3OUT);
}

&test('/tmp/run', '');
__END__  

/tmp/run ->

#!/sbin/bash
echo hello
echo goodbye
echo to
echo all
echo !

the '/tmp/run' script runs and its output is seen, however an infinite loop is
generated. 

my guess is that i am not using select correctly, not sure.

any ideas?  tia.

-- 

/* Regards,
   Jason Kawaja, UF-ECE Sys Admin */



------------------------------

Date: 10 Aug 2001 17:19:10 GMT
From: Tina Mueller <tinamue@zedat.fu-berlin.de>
Subject: Re: Is an element in a table ?
Message-Id: <9l152e$6pvkt$1@fu-berlin.de>

Anno Siegel <anno4000@lublin.zrz.tu-berlin.de> wrote:
> According to Tina Mueller  <news@tinita.de>:
>> Philippe PERRIN <philippe.perrin@sxb.bsf.alcatel.fr> wrote:

> Using --$seen is an ingenious technique to secure that each element in
> $b is counted only once, even if many are present.  That wasn't specified,
> I think, but I like it.  If you don't mind the obfuscation, the loop
> can be compacted:

>     $n += ! --$seen{ $_} for @b;

phew, that's a nice one! i like perl =)

-- 
http://www.tinita.de \  enter__| |__the___ _ _ ___
tina's moviedatabase  \     / _` / _ \/ _ \ '_(_-< of
search & add comments  \    \ _,_\ __/\ __/_| /__/ perception
---   Warning: content of homepage hopelessly out-dated   ---


------------------------------

Date: 10 Aug 2001 10:29:58 -0500
From: Ren Maddox <ren@tivoli.com>
Subject: Re: Is this a Perl bug?
Message-Id: <m34rrgaq6h.fsf@dhcp9-161.support.tivoli.com>

On Fri, 10 Aug 2001, flamencoman@earthlink.net wrote:

> I've written a short perl script that goes through an HTML file and
> strips out the <HEAD>...</HEAD> components except for
> <TITLE>...</TITLE>. I came across an HTML file where it was
> stripping out a section of the HTML file that was approximately 1867
> characters long before a line feed. I inserted a line feed about the
> middle of this by opening the HTML file in notepad and then pressing
> "Enter" at the keyboard. Then, the script ran fine.
> 
> I don't get it. Why does Perl balk when it sees this long
> string. I've included both the perl script and the html file as
> attachments. I have run this on Windows98, Windows2000, and UNIX
> with the same result.
> 
> To run the script, place the script in its own directory and place
> the html file in a subdirectory.
> 
> Any one have a clue?

Your script includes:

  if($curr =~ /<!-- \$MVD\$/i){next;}

And your data includes that sequence in the long line, so the long
line is skipped.  Adding a carraige return anywhere besides in the
middle of this construct would not fix the problem -- but it would
reduce the amount of data that is deleted.

The code does not in any way restrict the removals to the
<HEAD>...</HEAD> section as you stated above.

-- 
Ren Maddox
ren@tivoli.com


------------------------------

Date: 10 Aug 2001 10:30:06 -0500
From: Ren Maddox <ren@tivoli.com>
Subject: Re: Is this a Perl bug?
Message-Id: <m31ymkaq69.fsf@dhcp9-161.support.tivoli.com>

On Fri, 10 Aug 2001, flamencoman@earthlink.net wrote:

> I've written a short perl script that goes through an HTML file and
> strips out the <HEAD>...</HEAD> components except for
> <TITLE>...</TITLE>. I came across an HTML file where it was
> stripping out a section of the HTML file that was approximately 1867
> characters long before a line feed. I inserted a line feed about the
> middle of this by opening the HTML file in notepad and then pressing
> "Enter" at the keyboard. Then, the script ran fine.
> 
> I don't get it. Why does Perl balk when it sees this long
> string. I've included both the perl script and the html file as
> attachments. I have run this on Windows98, Windows2000, and UNIX
> with the same result.
> 
> To run the script, place the script in its own directory and place
> the html file in a subdirectory.
> 
> Any one have a clue?

Your script includes:

  if($curr =~ /<!-- \$MVD\$/i){next;}

And your data includes that sequence in the long line, so the long
line is skipped.  Adding a carriage return anywhere besides in the
middle of this construct would not fix the problem -- but it would
reduce the amount of data that is deleted.

The code does not in any way restrict the removals to the
<HEAD>...</HEAD> section as you stated above.

-- 
Ren Maddox
ren@tivoli.com


------------------------------

Date: Fri, 10 Aug 2001 12:09:22 -0400
From: Lou Moran <lmoran@wtsg.com>
Subject: Re: Learning Perl, 2nd Edition
Message-Id: <9o18nt4p0lv952tl0etar17d9s8bhbb53t@4ax.com>

On 10 Aug 2001 05:23:55 -0700, merlyn@stonehenge.com (Randal L.
Schwartz) wrote wonderful things about sparkplugs:

>>>>>> "Haakon" == Haakon Riiser <hakonrk@fys.uio.no> writes:
>
>Haakon> I recently bought this book, and discovered shortly after that
>Haakon> it had been obsoleted by the 3rd edition.  Are the changes in
>Haakon> the 3rd edition significant?  I am thinking about returning
>Haakon> the book, but I won't make a decision until I know if the
>Haakon> changes are relevant to me.
>
>Hmm.  I can argue for both.  The new third-edition llama is derived
>from our current Stonehenge courseware, and our courseware was derived
>from the first edition of the llama (with about a dozen major
>revisions over the past seven years).  There's no cut-n-paste between
>the two books, because it lept media instead.  We've learned from
>watching students reactions how to talk about certain difficult
>subjects, like regular expressions and why it's not @a[3], and that's
>reflected in the new book organization and content.  So, while the
>first edition llama has recieved much praise for being easy to read,
>I'd say this third edition stands head and shoulders above that.


Listen.  I like your stuff.  But the OP asked which one.  Are you
saying go get the 3rd edition or not?


------------------------------

Date: 10 Aug 2001 09:25:55 -0700
From: area31@mail.com (Mark Deibert)
Subject: Re: mySQL - More records or longer records - Speed?
Message-Id: <20f405bf.0108100825.c9fa6c5@posting.google.com>

Thanks for your input guys. Yes, I am using Perl DBI. That's why I
posted here. You may be right though, I probably should post in a
mySQL group. I'll do that now.

Thanks again for your replies,

Mark Deibert


logan@cs.utexas.edu (Logan Shaw) wrote in message news:<9kurm4$o1$1@charity.cs.utexas.edu>...
> In article <20f405bf.0108081725.317cbb9b@posting.google.com>,
> Mark Deibert <area31@mail.com> wrote:
> >What would be faster in mySQL (or any really), creating a table that
> >will store 1000 records with 4 fields in each record, or 4 records
> >with 1000 fields in each record?
> 
> You've asked about creating the table.  Creating the table
> will probably not be a significant performance problem.
> 
> If you want to access it after it's created, that's a
> different story.  The answer probably depends on lots of
> things, like whether there are indices on certain columns,
> whether or not there are any variable-length records (and
> whether you access them much), and how big the fields are.
> 
> In other words, this question is sort of like asking, "Which data
> structure is faster -- a binary search tree, or an unsorted array?"
> The answer is, it depends on what you want to accomplish with it.
> 
>   - Logan


------------------------------

Date: 10 Aug 2001 17:25:16 GMT
From: aceweb45@aol.com (Aceweb45)
Subject: Need PERL exp to t-shoot ad rotationa
Message-Id: <20010810132516.00778.00000119@mb-fx.aol.com>


Need PERL exp to t-shoot ad rotational

I run TravelGolf.com and 24 regional golf publications. We run multiple PERL ad
server rotationals using this script. On each site, we have ad spots that
rotate with many other advertisements.

PERL is frequently crashing on us and causing UGL SSI errors. Can the script be
altered or fixed or do I need to go to another software solution? If someone
could diagnose the problem, I would love to hire them for PERL troubleshooting.
Thanks
Robert




------------------------------

Date: 10 Aug 2001 17:21:44 GMT
From: aceweb45@aol.com (Aceweb45)
Subject: Need PERL exp to t-shoot ad rotational
Message-Id: <20010810132144.00809.00000063@mb-fx.aol.com>

Need PERL exp to t-shoot ad rotational

I run TravelGolf.com and 24 regional golf publications. We run multiple PERL ad
server rotationals using this script. On each site, we have ad spots that
rotate with many other advertisements.

PERL is frequently crashing on us and causing UGL SSI errors. Can the script be
altered or fixed or do I need to go to another software solution? If someone
could diagnose the problem, I would love to hire them for PERL troubleshooting.
Thanks
Robert


------------------------------

Date: Fri, 10 Aug 2001 16:03:09 GMT
From: Hong Hsu <honghsu@bellatlantic.net>
Subject: new to Perl
Message-Id: <3B740658.8050005@bellatlantic.net>


Hi,

I am writing my first Perl script. I wonder someone can point out what 
is wrong with my script. I like to cd to a particular directory, get 5th 
column of "ls -l", add them together (size of files). and then print it 
out.  My questions are: how to get output from system() so that I can 
use awk.  How to add value together.

Thanks in advance,
-Hong
honghsu@bellatlantic.net

#!/usr/bin/perl -w

(@ARGV == 0 || @ARGV == 1)
   or die "Usage: fsize.pl [directory to be tested]           ";

my $dir = $ARGV[0];
chdir("$dir") ? print "It works.\n" : print "It doesn't work.\n";
my $result = system("/bin/bash", "-c", "ls -l");
$? and die "oops2";

system("/bin/bash", "-c", "awk '{ $5 }'");
$? and die "oops3";



------------------------------

Date: 10 Aug 2001 17:31:32 +0100
From: nobull@mail.com
Subject: Re: new to Perl
Message-Id: <u94rrf7u6z.fsf@wcl-l.bham.ac.uk>

Hong Hsu <honghsu@bellatlantic.net> writes:

> Subject: new to Perl

Please use the subject of you post to tell us the subject of your post
not about yourself.

> My questions are: how to get output from system()

FAQ: "Why can't I get the output of a command with
system()?"

You are supposed to consult the FAQ _before_ you post.

Alternatively see the manual entry for the system() function.  Pay
particular note to the bit where it says: "This is not what you want
to use to capture the output from a command, for that you should...".

Please do not treat Usenet as an alternative to manuals.

> How to add value together.

Please be less vague.

The numeric addition operator in Perl is the plus sign.

The string concatenation operator is the period.

The list concatenation operator is the comma (when used in a list
context).

-- 
     \\   ( )
  .  _\\__[oo
 .__/  \\ /\@
 .  l___\\
  # ll  l\\
 ###LL  LL\\


------------------------------

Date: Fri, 10 Aug 2001 11:52:58 -0400
From: tadmc@augustmail.com (Tad McClellan)
Subject: Re: new to Perl
Message-Id: <slrn9n80qq.18o.tadmc@tadmc26.august.net>

Hong Hsu <honghsu@bellatlantic.net> wrote:
>
>
>I am writing my first Perl script. I wonder someone can point out what 
>is wrong with my script. 


You should read the documentation for the functions that you use.

   perldoc -f system

      "This is not what you want to use to capture the output from a 
       command, for that you should use..."


>I like to cd to a particular directory, 


Seems you have that down, but the idiomatic Perl way is:

   chdir($dir) or die "could not cd to '$dir'  $!";


>get 5th 
>column of "ls -l", add them together (size of files). 


You can find the size of the file with native Perl, no need for 'ls':

   perldoc -f -s


>and then print it 
>out.  My questions are: how to get output from system() so that I can 


Read the description for system(), then use what it says to use.


>use awk.  


Perl is a superset of awk, do your processing in Perl not awk.

There is also the "a2p" (awk to perl) translator program that
ships along with perl itself.


>How to add value together.


+ is the binary addition operator.



>#!/usr/bin/perl -w
>
>(@ARGV == 0 || @ARGV == 1)
>   or die "Usage: fsize.pl [directory to be tested]           ";


More idiomatically:

   die "Usage: fsize.pl [directory to be tested]\n" if @ARGV > 1;


>my $dir = $ARGV[0];
>chdir("$dir") ? print "It works.\n" : print "It doesn't work.\n";
       ^    ^
       ^    ^
Those double quotes do not do anything, so they should not be there.


-- 
    Tad McClellan                          SGML consulting
    tadmc@augustmail.com                   Perl programming
    Fort Worth, Texas


------------------------------

Date: Fri, 10 Aug 2001 17:31:48 +0200
From: =?ISO-8859-1?Q?Thomas_B=E4tzler?= <Thomas@Baetzler.de>
Subject: Re: Newsletter Script
Message-Id: <f4v7ntonih534qmtc0p48t2auas2d0asjd@4ax.com>

Hi,

On Fri, 10 Aug 2001, "Sgluarb" <ommadawn@club-internet.fr> wrote:

>> Something tells me that about 10 000 people will be very happy if
>> there's no answer to this question.
>
>No, no that's not a spam list... 8-|
>
>That's just a newletter for who subscribe for tit.

Ah, that's why you need to be able to handle attachments :-)

>It already exist but i've made it in PHP / MySQL. I want to make it in perl
>or python and i'm searching for sources that inspire me.

Maybe this'll get you started:

--------8<----( cut here )----8<--------
#!/usr/bin/perl -w

use strict;
use MIME::Lite;
use Net::SMTP;

# some MIME type definitions
my %mimetype = ( 'gif'  => 'image/gif',
                 'jpg'  => 'image/jpeg',
                 'jpeg' => 'image/jpeg',
                 'bmp'  => 'image/bmp',
                 'html' => 'text/html',
                 'png'  => 'image/png',
                 'txt'  => 'text/plain' );

# some files, supposedly in the current dir
my @files = ('bla.html', 'foo.gif', 'bar.jpg');

my $text = "some plain text as the message body";

my $Mail = MIME::Lite->build(
                 From    => 'List Admin <not-for-mail@foo.bar>',
                 To      => 'List Recipients <not-for-mail@foo.bar>',
                 Subject => "A List Mail",
                 Type    => 'TEXT',
                 Data    => "$text"
                 ) or die "MIME::Lite->new: $!\n";


foreach my $file ( @files ){
  $file =~ m/^.*\.(.*?)$/;
  $Mail->attach( Path     => $file,
                        Type     => $mimetype{$1},
                      );
}

my $smtp = Net::SMTP->new("your.mail.relay",
                          Timeout => 60,
                          Debug   => 0,
                         ) or die "[$date] SMTP: $! \n";

$smtp->mail('valid.sender@ddr.es');
$smtp->to('recipient@ddr.es', 'other.email@ddr.es' );
$smtp->data;
$smtp->datasend($Mail->as_string);
$smtp->dataend;
$smtp->quit;
--------8<----( cut here )----8<--------

HTH,
-- 
Thomas Baetzler - http://baetzler.de/ - Clan LoL - http://lavabackflips.de/
I am the "ILOVEGNU" signature virus. Just copy me to your signature.
This post was infected under the terms of the GNU General Public License.


------------------------------

Date: Fri, 10 Aug 2001 12:32:51 -0400
From: Lou Moran <lmoran@wtsg.com>
Subject: Re: Newsletter Script
Message-Id: <a438ntkn0b2lv489had32kngvid5l500e2@4ax.com>

On Fri, 10 Aug 2001 14:07:48 +0100, "Sgluarb"
<ommadawn@club-internet.fr> wrote wonderful things about sparkplugs:

>That's just a newletter for who subscribe for tit.

I find your comments engaging and insightful; how do I subscribe to
this newsletter?



------------------------------

Date: Fri, 10 Aug 2001 18:13:00 +0200
From: "B. Caligari" <bcaligari@fireforged.com>
Subject: Re: Newsletter Script
Message-Id: <9l110n02vkn@enews4.newsguy.com>


"Thomas Bätzler" <Thomas@Baetzler.de> wrote in message
news:f4v7ntonih534qmtc0p48t2auas2d0asjd@4ax.com...
> Hi,
>
>   $Mail->attach( Path     => $file,
>                         Type     => $mimetype{$1},
>                       );
> }
>
> my $smtp = Net::SMTP->new("your.mail.relay",
>                           Timeout => 60,
>                           Debug   => 0,
>                          ) or die "[$date] SMTP: $! \n";

Hmmmm....
 ...although I have a feeling it's going to be "somebody.elses.relay"

B




------------------------------

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 1488
***************************************


home help back first fref pref prev next nref lref last post