[7758] in Perl-Users-Digest

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

Perl-Users Digest, Issue: 1383 Volume: 8

daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Fri Nov 28 03:07:25 1997

Date: Fri, 28 Nov 97 00:00:48 -0800
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, 28 Nov 1997     Volume: 8 Number: 1383

Today's topics:
     Re: A difficult problem (Hans Juergen von Lengerke)
     Re: A difficult problem (Tushar Samant)
     ACK! What am I doing wrong??!! <sk@iessoft.com>
     Re: Being strict with filehandles! (William R. Ward)
     Re: Conditional compilation? <rootbeer@teleport.com>
     Re: Cookies and Perl 5 (Martien Verbruggen)
     Re: For the pro's ? repost: Leaving HTML tags alone (Tushar Samant)
     Re: form results to both email and text file <rootbeer@teleport.com>
     Re: form results to both email and text file <rpsavage@ozemail.com.au>
     Help! unexpected token (Ryuji Yokoyama)
     Re: How to directly call a POST method <jaydee@worsdall.demon.co.uk>
     Re: How to directly call a POST method <flavell@mail.cern.ch>
     Re: How To Test if number is ODD or EVEN? (Martien Verbruggen)
     Re: Html - > Unix <rootbeer@teleport.com>
     Re: Html - > Unix (Martien Verbruggen)
     Re: last element in an array? <rootbeer@teleport.com>
     Re: Leaving HTML-Tags alone=solved. (Tad McClellan)
     Re: libwww - LWP::UserAgent (Tushar Samant)
     Re: PERL Hourly Rates (Tushar Samant)
     Perl outputting REVERSE video  text (William Wei Liong Young)
     Re: Perl outputting REVERSE video  text (Tushar Samant)
     perl shorter than csh challenge!! (William Wei Liong Young)
     Re: Print out array! <$_=qq!fearless\@NOSPAMio.com!;y/A-Z//d;print>
     Re: Re: Removing Files older than 14 days (sysadmin)
     Re: Removing HTML tag <gordon.leslie.mcdorman@sap-ag.de>
     Re: script refuses to print variables to file but happi <rootbeer@teleport.com>
     Re: script refuses to print variables to file but happi (Martien Verbruggen)
     Re: Strange 'print Location:' problem with Perl <rootbeer@teleport.com>
     Re: SUID + Linux <rootbeer@teleport.com>
     Re: sytem command test <rootbeer@teleport.com>
     Re: sytem command test (Tushar Samant)
     Re: tail -f cmd (again) <rjk@coos.dartmouth.edu>
     Re: Theory behind perl (Steven W McDougall)
     Re: TK port for win32????????/ (sysadmin)
     VERY strange perl problem... (Steve McNabb)
     Re: Windows 95 flock problem (hapless newbie question) (Martien Verbruggen)
     Digest Administrivia (Last modified: 8 Mar 97) (Perl-Users-Digest Admin)

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

Date: Thu, 27 Nov 1997 20:49:50 GMT
From: lenkerWEEDS@dircon.co.uk (Hans Juergen von Lengerke)
Subject: Re: A difficult problem
Message-Id: <347edc95.11401774@news.dircon.co.uk>

Hemant Mallapur wrote:

>     foreach $key ( keys  %read) {
                     ^^^^
AFAIK, you can't use 'keys' with a complex data structure. See the
Camel book for an explanation.

Hans

--
To mail me, just pull the WEEDS!


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

Date: 27 Nov 1997 15:50:15 -0600
From: scribble@shoga.wwa.com (Tushar Samant)
Subject: Re: A difficult problem
Message-Id: <65kpun$ofr@shoga.wwa.com>

hemant@synopsys.com writes:
>To show it pictorially this is the idea :
>Table
>|-->  pad1---> this----> (0.1, 0.2 ...)
>|        |---> that----> (1.1, 1.2 ...)
>|        |---> him-----> (2.1, 2.2 ...)
>|        |---> her ----> (3.1, 3.2 ...)
>|
>|-->  pad2----> this .... (4.1, 4.2, ...)
>|        |---->....
>.... 

It's easier for me to write the code ab ovo than finding where
your error is... Complex data structures are extremely easy --
most of the time, they are "WYSIWIG" -- but it might take some
time to get used to that. Here's the code:

    @names = qw(this that him her);
    @padnames = qw(pad1 pad2 pad3 pad4);
    @data  = (0.1, 0.2, 0.3, 0.4);
    %table = ();

    for $name (@names) {
        for $padname (@padnames) {
            $table{$name}{$padname} = [@data];
            for (@data) {$_++};
        }
    }

That will do it. By the way, trying to print out the structure on
your own sort of defeats the purpose if you were unsure about how
to handle it in the first place. Install Data::Dumper and add the
two lines below:

    use Data::Dumper;
    print Dumper(\%table);

The hash keys will of course not come out in order, but the output
is very readable.



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

Date: Thu, 27 Nov 1997 19:12:22 -0500
From: "Shafayat Kamal" <sk@iessoft.com>
Subject: ACK! What am I doing wrong??!!
Message-Id: <65l2h2$d6r@world1.bawave.com>

 Hi all!

I have a little problem sending an email attachment that's base64 encoded.
Please remember that I'm still a novice Perl programmer (but I can get
around in it). The problem is when I encode the file, the file ends up being
9.12kb when the original file size is 9.11kb. Eudora also tells me that
there were errors converting the attachment. If I put in a Chop; just before
I go around encoding it the file size drops to 9.09kb and no matter what I
do I still get errors from Eudora when converting attachment.

Please reply to sk@iessoft.com if possible!


open(MAIL,"|$mailprog -t");

         print MAIL "To: $email ($realname)\n";
         print MAIL "From: $fromaddr ($fromname)\n";
         if ($organization) {
            print MAIL "Organization: $organization\n";
         }
         else {
            print MAIL "Organization: Auto sent file\n";
         }
  print MAIL "MIME-Version: 1.0\n";
  print MAIL "Subject: $file\n";
         print MAIL "Content-Type: multipart/mixed;
boundary=iessoftabcdefghklopqz\n";
         print MAIL "Content-Type: application/octet-stream;
name=azp1090.zip\n";
   print MAIL "Content-Transfer-Encoding: base64\n";
         open(INPUT,"$filebase/$file")||&error;
         while (<INPUT>) {
            $base64_string = &base64'b64encode($_); ## Should I put in a
Chop? If I do, the file becomes ## 9.09kb and Eudora still gives me errors
when trying to decode the attachment
            print MAIL $base64_string;
         }
         close (INPUT);
         close (MAIL);

Regards,
Shafayat Kamal
http://www.iessoft.com/scripts/index.shtml






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

Date: 27 Nov 1997 13:19:11 -0800
From: hermit@cats.ucsc.edu (William R. Ward)
Subject: Re: Being strict with filehandles!
Message-Id: <waaiutef31s.fsf@ese.UCSC.EDU>

Russ Allbery <rra@stanford.edu> writes:
> If there is, then you can wrap this code as such:
>         no strict 'refs';
>         $main::Handle = \*{$main::Symbol};
>         use strict 'refs';

Why not just use:

{
   no strict qw(refs);
   $main::Handle = \*{$main::Symbol};
}

The block restricts the effect of 'no strict' within that area, and
for some reason qw() seems to be the preferred style for 'use' and
'no' lists.

--Bill.

-- 
William R Ward          Bay View Consulting   http://www.bayview.com/~hermit/
hermit@bayview.com     1803 Mission St. #339        voicemail +1 408/479-4072
hermit@cats.ucsc.edu  Santa Cruz CA 95060 USA           pager +1 408/458-8862


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

Date: Thu, 27 Nov 1997 10:05:16 -0800
From: Tom Phoenix <rootbeer@teleport.com>
To: Jason Gloudon <jgloudon@bbn.remove.com>
Subject: Re: Conditional compilation?
Message-Id: <Pine.GSO.3.96.971127100433.6576C-100000@usertest.teleport.com>

On 26 Nov 1997, Jason Gloudon wrote:

> Thilo Goetz (goetz@watson.ibm.com) wrote:

> : So here it goes.  I wrote a lengthy perl script that uses some features
> : of perl5, so it won't compile under perl4.  If somebody tries to run
> : this script with an older version of perl, I'd like a controlled death

> Put it in a BEGIN block :
> 
> BEGIN { 
> 	if ($] < 5.0) { die "$0 error: needs perl v. 5 or better, aborting.\n"
> }

BEGIN blocks don't work in Perl 4. Nice try! :-)

-- 
Tom Phoenix           http://www.teleport.com/~rootbeer/
rootbeer@teleport.com  PGP   Skribu al mi per Esperanto!
Randal Schwartz Case:  http://www.rahul.net/jeffrey/ovs/
              Ask me about Perl trainings!



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

Date: 28 Nov 1997 01:31:31 GMT
From: mgjv@comdyn.com.au (Martien Verbruggen)
Subject: Re: Cookies and Perl 5
Message-Id: <65l6tj$pi$4@comdyn.comdyn.com.au>

In article <01bcfb4b$86a7e3c0$af2e56d1@keithlol.com>,
	"Keith" <keithlol@nospammindspring.com> writes:
> print "Set-Cookie: $usersn=$userpw; expires=$expDate;
> path=$path;domain=$domain; secure\n";
> print "Content-type: text/html\n\n";                                     

Since you don't post your complete code, it's hard to comment. The
above should work, IF you are on a secure server.

If a cookie is marked secure, it will only be transmitted if the
communications channel with the host is a secure one. Currently this
means that secure cookies will only be sent to HTTPS (HTTP over SSL)
servers.

IE might just be doing the wrong thing here.

Why am I amswering this? This has no bearing on perl whatsoever.

Just use CGI.pm

There, there's the perl angle :)

Martien
-- 
Martien Verbruggen                  | 
Webmaster www.tradingpost.com.au    | I'm desperately trying to figure out
Commercial Dynamics Pty. Ltd.       | why kamikaze pilots wore helmets - Dave
NSW, Australia                      | Edison 


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

Date: 27 Nov 1997 14:05:22 -0600
From: scribble@shoga.wwa.com (Tushar Samant)
Subject: Re: For the pro's ? repost: Leaving HTML tags alone
Message-Id: <65kjq2$95p@shoga.wwa.com>

noemail@use.net writes:
>scribble@shoga.wwa.com (Tushar Samant) wrote:
>>1. Download striphtml from "Tom's Kickass Scripts":
>>2. Take the first two patterns in it (comments and tags), stick a
>>   "|" between them and parentheses around them, split the HTML on
>>   the pattern, apply your substitution to every even-indexed element,
>>   join 'em up with "".
>
>Ok, i am no perl wizard

You too? Let's be friends.

> s/(<(?:[^>])+)$seek/$1$replace/ig;

I don't understand this specific thing -- what are $seek and $replace?

See: possibly you can do this with one s///e, with another s%%% nested
in the replace part. But you wanted a quick and easy solution, and I
don't know any quicker way than stealing someone's code. I wasn't
talking about examining the pattern -- I was talking about bodily
lifting it and wrapping it in m{()}. Secondly, there is no sin in
splitting into an array ... you can make it cleverer later.

A tag is NOT something which matches /<.*?>/. That's the whole point
of complicated pattern-matches which are not "one-liners".

BTW you can turn a lot of programs into one-liners by defining "line"
to mean file. Perl is flexible enough that it allows such redefinitions.

FINALLY: If you are going to do this kind of thing often you should use
the HTML parsing modules of Gisle Aas. Then later on, when your needs
increase, and you want to apply your substitutions not just to text but
to "alt"s of image tags, "value"s of submit buttons, etc etc, you will
only have to add a condition here and there.  



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

Date: Thu, 27 Nov 1997 10:17:37 -0800
From: Tom Phoenix <rootbeer@teleport.com>
To: dwexler@zeusnet.com
Subject: Re: form results to both email and text file
Message-Id: <Pine.GSO.3.96.971127101712.6576F-100000@usertest.teleport.com>

On Wed, 26 Nov 1997 dwexler@zeusnet.com wrote:

> I am looking for a script that can send form results to both a comma
> delimited text file and to an email address.  

You could write one in Perl. Let us know if you get stuck. Good luck!

-- 
Tom Phoenix           http://www.teleport.com/~rootbeer/
rootbeer@teleport.com  PGP   Skribu al mi per Esperanto!
Randal Schwartz Case:  http://www.rahul.net/jeffrey/ovs/
              Ask me about Perl trainings!



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

Date: Fri, 28 Nov 1997 09:13:41 +1000
From: Ron Savage <rpsavage@ozemail.com.au>
Subject: Re: form results to both email and text file
Message-Id: <347DFEA5.4770@ozemail.com.au>

dwexler@zeusnet.com wrote:
> 
> I am looking for a script that can send form results to both a comma
> delimited text file and to an email address.  This is for a UNIX server.
> Any suggestions?
> 
> -------------------==== Posted via Deja News ====-----------------------
>       http://www.dejanews.com/     Search, Read, Post to Usenet# Send mail to indicate successful installation.

Herewith a guide (tested on IRIX):

# A few lines snipped...
my($installDir) = '/dir/subdir/';
my($version)    = '1.23';
# A few hundred lines snipped...
my($success)    = "eJunk V $version successfully installed";

print "$success\n";

my($recipient)	= 'Savage.Ron.RS@bhp.com.au';
my($sendmail)	= `which sendmail`;
$sendmail	= '/usr/lib/sendmail' if ($sendmail =~ /^sendmail not in/);

my(@mailMsg);
push(@mailMsg, "Host:		$ENV{'HOST'}");
push(@mailMsg, "User:		$ENV{'USER'}");
push(@mailMsg, "Version:	$version");
push(@mailMsg, "Directory:	$installDir");

die("Can't find sendmail program\nPlease email $recipient thus:\n", join("\n", @mailMsg), "\n")
	if (! -x $sendmail);

open(MAIL,"| $sendmail -t");

print MAIL "To: Savage.Ron.RS\@bhp.com.au\n";
print MAIL "From: Savage.Ron.RS\@bhp.com.au\n";
print MAIL "Subject: $success\n";
print MAIL "\n";
print MAIL join("\n", @mailMsg), "\n";

close (MAIL);

# Success.
exit(0);

Thanks to Eryq (eryq@zeegee.com) for the idea I followed.
-- 
Cheers,
Ron Savage
Office: savage.ron.rs@bhp.com.au
Home (preferred): rpsavage@ozemail.com.au


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

Date: Fri, 28 Nov 1997 01:39:15 GMT
From: rqy1319@is4.nyu.edu (Ryuji Yokoyama)
Subject: Help! unexpected token
Message-Id: <347e1dd2.92788@netnews.nyu.edu>

Hello All!

I have encountered really strange thing.  I declared the same array in
two different program, which is following.
@files = qw(
                     aug.txt
                     dec.txt
              );

It works nicely in one program;however, I got an error message at the
other program.

 ./search2.pl:syntax error near unexpected token 'qw('
 .search2.pl:./search2.pl:line 4 @files = qw('

I totally don't understand why I got this error message even it works
another program.  I wrote both program the same enviroment(Emacs for
linux).  Please somebody tell me the reason why this thing happen.

Thanks! I appreciate any advice.

Ryuji


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

Date: Thu, 27 Nov 1997 23:09:51 +0000
From: Mark Worsdall <jaydee@worsdall.demon.co.uk>
Subject: Re: How to directly call a POST method
Message-Id: <T5H5OFB$2ff0Ewh1@worsdall.demon.co.uk>

In article <65je7d$116@bgtnsc03.worldnet.att.net>, brian d foy
<comdog@computerdog.com> writes
>
>the referer is easy to hack (dare i say "trivial" again?).  no sense
>bothering with that. :)
>
Have you managed yet to hack into my site and codes:-) 

How does one hack the referer?
-- 
Mark Worsdall - Oh no, I've run out of underpants :(
Home:- jaydeeATworsdall.demon.co.uk  WEB site:- http://www.worsdall.demon.co.uk
Shadow:- webmasterATshadow.org.uk    WEB site:- http://www.shadow.org.uk


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

Date: Fri, 28 Nov 1997 01:13:33 +0100
From: "Alan J. Flavell" <flavell@mail.cern.ch>
Subject: Re: How to directly call a POST method
Message-Id: <Pine.A41.3.95a.971128011104.24184C-100000@sp066>

On Thu, 27 Nov 1997, Mark Worsdall wrote:

> How does one hack the referer?

telnet www.foo.bar 80
GET /some/thing.html HTTP/1.0
Referer: http://www.some.bogus.host/some/bogus/path.cgi
(two newlines)

What was the question again?



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

Date: 28 Nov 1997 01:03:03 GMT
From: mgjv@comdyn.com.au (Martien Verbruggen)
Subject: Re: How To Test if number is ODD or EVEN?
Message-Id: <65l587$pi$1@comdyn.comdyn.com.au>

In article <65f5pv$kj$1@dismay.ucs.indiana.edu>,
	bdwheele@indiana.edu (Brian Wheeler) writes:
> In article <comdog-ya02408000R2411971501330001@news.panix.com>,
> 	comdog@computerdog.com (brian d foy) writes:
>> In article <01bcf675$0ea174c0$c82da8c0@akilles.ittek.org>, "Robert Friberg" <robert.friberg@your_clothes.eductus-vast.com> wrote:
>> 
>>>print $number && 1 ? 'Odd!': 'Even!', "\n";
>> 
>> i guess you didn't bother to test this.  thanks for posting crap.
> 	Nice manners.  Probably a typo, because 
> 
> print $number & 1 ? 'Odd!' : 'Even!', "\n"; 
> 
> 	works as advertised.

That is NOT what the poster submitted though. What the poster
submitted was not correct, even if it was CLOSE.

> && is shortcut AND.  It would only show up as Even if $number was undefined
> or 0.  & is logical AND.

&& is logical and (with higher precedence than the keyword and)
& is bitwise and

what is 'shortcut and'?

> Before go and criticize people's __FREELY GIVEN HELP__, why don't you try to

Something being free is no reason for it being incorrect. It takes about
three seconds to test something like that, so why not do that?

> figure it out on your own?  odd/even is probably the most trivial problem
> there is.  Sorry if I'm ragging, but it really irks me when people get shitty
> with free advice.

It might be trivial, but the original poster obviously didn't know how
to do it, so the original poster probably also wouldn't have been able
to figure out that the answer was wrong, and why it was wrong.

Martien
-- 
Martien Verbruggen                  | 
Webmaster www.tradingpost.com.au    | The gene pool could use a little
Commercial Dynamics Pty. Ltd.       | chlorine.
NSW, Australia                      | 


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

Date: Thu, 27 Nov 1997 10:38:49 -0800
From: Tom Phoenix <rootbeer@teleport.com>
To: hkstar <modular@hkstar.com>
Subject: Re: Html - > Unix
Message-Id: <Pine.GSO.3.96.971127103800.6576I-100000@usertest.teleport.com>

On Thu, 27 Nov 1997, hkstar wrote:

> Is there any way to send Unix commands to www server by means of html?

Whether there is or not, the question has nothing to do with Perl. Do you
want a browser to do this? Maybe you should check with a browser
newsgroup. Good luck!

-- 
Tom Phoenix           http://www.teleport.com/~rootbeer/
rootbeer@teleport.com  PGP   Skribu al mi per Esperanto!
Randal Schwartz Case:  http://www.rahul.net/jeffrey/ovs/
              Ask me about Perl trainings!



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

Date: 28 Nov 1997 01:19:16 GMT
From: mgjv@comdyn.com.au (Martien Verbruggen)
Subject: Re: Html - > Unix
Message-Id: <65l66k$pi$3@comdyn.comdyn.com.au>

In article <65jvn2$nrf1@lyra.hkstar.com>,
	"hkstar" <modular@hkstar.com> writes:
> Hello,
> I am new to Perl!
> Is there any way to send Unix commands to www server by means of html?

Where does perl come in?

There are several methods to get 'unix commands' executed on a web
server (nothing to do with HTML though). 

you might want to learn a bit about CGI programming first. Have a look
at www.cgi-resources.com

Martien
-- 
Martien Verbruggen                  | 
Webmaster www.tradingpost.com.au    | Little girls, like butterflies, need no
Commercial Dynamics Pty. Ltd.       | excuse - Lazarus Long
NSW, Australia                      | 


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

Date: Thu, 27 Nov 1997 14:41:08 -0800
From: Tom Phoenix <rootbeer@teleport.com>
To: Bill Parker <bill@penumbra.co.uk>
Subject: Re: last element in an array?
Message-Id: <Pine.GSO.3.96.971127143839.11067B-100000@usertest.teleport.com>

On 27 Nov 1997, Bill Parker wrote:

> Tom Phoenix <rootbeer@teleport.com> wrote 
> > On Tue, 25 Nov 1997, it was written:
> > 
> > > how do I reference the last element of @matches? 
> > 
> > That would be $matches[-1]. Hope this helps!

> Hmmm... why does that work then?

Because perl behaves according to the documentation, mostly. :-)

-- 
Tom Phoenix           http://www.teleport.com/~rootbeer/
rootbeer@teleport.com  PGP   Skribu al mi per Esperanto!
Randal Schwartz Case:  http://www.rahul.net/jeffrey/ovs/
              Ask me about Perl trainings!



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

Date: Thu, 27 Nov 1997 14:42:28 -0600
From: tadmc@metronet.com (Tad McClellan)
Subject: Re: Leaving HTML-Tags alone=solved.
Message-Id: <kvlk56.st2.ln@localhost>


Patrick (Venice@euronet.nl) wrote:

: Subject: Re: Leaving HTML-Tags alone=solved.
                                       ^^^^^^
                                       ^^^^^^  ??


: Problem was to replace text outside HTML tags, so the HTML will not be
: replaced accidentally.
: Here the answer,


I don't think you have "the" answer yet...


: Thought i post it for they who are interested and they who replied to
: me.
: s/$search(?=(?:[^>])*(?:[<\n]))/$replace/ig;


You don't need all of those parenthesis there. I (at least) do not
eschew obfuscation  ;-)

This should work identically, and be a whole lot easier to read:

   s/$search(?=[^>]*[<\n])/$replace/ig;

(although working identically is Not So Good in this case  ;-)



: If i forgot something.. you tell me.


Sure will  ;-)


: This does not exclude Multi-line HTML tags...

Nor does it work on all Multi-line HTML tags...


: Thanx for the tips you perl people !!


See my followup from earlier this morning for one that will at
least work somewhat better.


Your solution will (sometimes):

1) Do the replacement inside of a tag

2) NOT do the replacement outside of a tag


---------------------
#!/usr/bin/perl -w

$search='http';
$replace='HyperText Transfer Protocol';


# replaces where it should not:
$_ = '<a href="http://www.com"
>
http
</a>';

s/$search(?=[^>]*[<\n])/$replace/ig;
print "$_\n\n";


# does not replace where it should:
$_ = '<a href="http://www.com"
>
http ==> the protocol
</a>';

s/$search(?=[^>]*[<\n])/$replace/ig;
print "$_\n\n";
---------------------


it needs a litte more work, methinks  ;-)


--
    Tad McClellan                          SGML Consulting
    tadmc@metronet.com                     Perl programming
    Fort Worth, Texas


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

Date: 27 Nov 1997 14:32:56 -0600
From: scribble@shoga.wwa.com (Tushar Samant)
Subject: Re: libwww - LWP::UserAgent
Message-Id: <65kldo$cso@shoga.wwa.com>

rv33100@glaxowellcome.co.uk writes:
>I'm using libwww version 5.16. Now I tried to simulate a HTML-Form with
>the LWP::UserAgent. I send my request to the server, nearly everything
>worked right, nearly !!! Filling the Request in
>$request->content("Query") I don't succeed to get at the server the
>Query_String.

The content() method has to do with the body of the request not the
query string. The query string is part of the URL.

Very likely you are constructing $request by yourself -- in that case
the safest thing to do is construct a URI::URL first, add your query
string to it with equery(), and when that is ready construct $request
with something like new HTTP::Request GET => $url;

Alternatively you can just stick the query string to your URL with a
"?", but you are responsible for encoding ("escaping") it.

Finally, that might not be the only thing that is wrong. You need to
be sure what your CGI program is dumping.



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

Date: 27 Nov 1997 15:57:17 -0600
From: scribble@shoga.wwa.com (Tushar Samant)
Subject: Re: PERL Hourly Rates
Message-Id: <65kqbt$pb6@shoga.wwa.com>

fearless@io.com writes:
>I think about the old FORTRAN code I used to write. I took one programming
>class the first time through college -- Introductory FORTRAN, I believe it
>was called -- and got a D+. Of course, there WAS this girl . . .

That's the difference between Fortran and Perl I think -- I got *better*
at Perl because of the girl.

>(Well, there still is this girl, but a different girl now -- several, in
>fact, if you count daughters and granddaughters, and in the meantime Perl
>was invented. :D)

Now I am wondering what a granddaughter language of Perl will look like.



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

Date: 27 Nov 1997 18:57:42 GMT
From: i0l1@ugrad.cs.ubc.ca (William Wei Liong Young)
Subject: Perl outputting REVERSE video  text
Message-Id: <65kfr6$ae6$1@nnrp.cs.ubc.ca>

Greetings,

I'm working on a unix box and I would like my perl program to output
key lines of output in reverse video ( ie. if your xterm is normally
white background, black text...i want a line of text black background,
white text ).

I remeber hearing something about needing to embed certain control 
charaters (or similar )in your -> print "command".

sorry if this is more a unix question than a perl question...

mucho thanks,
Will


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

Date: 27 Nov 1997 15:18:13 -0600
From: scribble@shoga.wwa.com (Tushar Samant)
Subject: Re: Perl outputting REVERSE video  text
Message-Id: <65ko2m$jok@shoga.wwa.com>

i0l1@ugrad.cs.ubc.ca writes:
>I'm working on a unix box and I would like my perl program to output
>key lines of output in reverse video [...]

One way is to use the Term::Cap module. This might be overkill if all
you want is non-portable output for xterm only. You can use Term::Cap
once to find out the "escape sequences". But more easily, just look at
/etc/termcap or wherever, find the entry for xterm and the sequences
which will turn reverse video on and off. The man page for termcap(5)
tells you how to read this file.

If you don't have termcap I have no suggestion.



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

Date: 27 Nov 1997 22:20:52 GMT
From: i0l1@ugrad.cs.ubc.ca (William Wei Liong Young)
Subject: perl shorter than csh challenge!!
Message-Id: <65kro4$br7$1@nnrp.cs.ubc.ca>

okay...maybe the subject was a bit overdramtic :)

my limited yet growing experience in perl has shown me that pretty
much anything done in a csh shell script can be done in fewer or the
same lines of code in a perl script ( fewer lines...not speed, efficiency, 
blah, blah).  but i think i have come across  two lines of csh code which 
I can't seem to write in 2 lines of perl code (using currently 'built-in'
perl, not extra modules).

Here is situation:

We have a text file with arbitrary number of lines:

a = 1
b = 2
c = 3
d = 4
 .
 .
 .

In a csh script, to get the value of c (assuming all the values on the left
side of the equal sign are unique):

set str = `grep c filename`
set cvalue = $str[ 3 ]

Can anyone do the same in perl using only 2 lines (and that includes opening
any filehandles)?

just thought I would throw this quite unimportant, rather insignificant
question to the group.  obviously, using back ticks in your perl code
doesn't count :), and the more confusing the two lines the better ;)

thanks,
Will


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

Date: Thu, 27 Nov 1997 11:24:01 -0800
From: "Creede Lambard" <$_=qq!fearless\@NOSPAMio.com!;y/A-Z//d;print>
Subject: Re: Print out array!
Message-Id: <65kh9v$qhp@mtinsc02.worldnet.att.net>

I'm not sure why this isn't doing what you expect. Try working around the
problem:

           @strarray = split (/:/,$target);
           while(@strarray) {
               print "The string is ";
               print shift;
               shift;
               print "\n";
                }

--- Creede Lambard
Minister of Irregular Expressions
Programming Republic of Perl

Ryujiy wrote in message <19971127164101.LAA24197@ladder01.news.aol.com>...
>Hello All !
>
>This is a part of my program.    This program is supposed to print out even
>number of element of the array(@starray[0,2,4, ...so on]), but it prints
put
>odd number of element of the array(@starray[1,3,5...so on]).  I don't
>understand the reason.  Could someone explain me?
>
>Thanks!
>
>Ryuji Yokoyama
>ryujiy@aol.com
>
>
>@files =

>                   aug.txt
>                   dec.txt );
>
>string = "Hello World";
>$count1 = 0;
>$numfile = $#files;
>while ($files[$count1]){
>          $target = `grep -i $string $files[$count1]`;
>           @starray = split (/:/,$target); #The result of grep is divided
and
>stored as an element of array
>           $numarray = $#starray;       #Get number of array element
>
>                     if ($target ne '')

>                                            for ($count2 = 0; $count2 <=
>$numarray; $count2+=2) {
>                        print "The string is\n" ;
>                                                    print
>"$starray[$count2]\n\n";
>                                                  }




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

Date: 27 Nov 1997 21:45:19 GMT
From: nobody@nowhere.com (sysadmin)
Subject: Re: Re: Removing Files older than 14 days
Message-Id: <65kplf$st4@newsserver.trl.OZ.AU>

>>#!/bin/sh
>>
>>TOP_DIR=/home/hugh/temp_files
>>
>>find $TOP_DIR -name '*.ABC' -mtime +14 -print | perl -nle 'unlink;'
>>
>>

In response, why use perl at all (other than this is a perl newsgroup). 
 Replace the -print, etc with -exec rm {} \;

Actually, you can drive in screws with a hammer.  I've tried it both
 figuratively in perl and literally in the workshed :-).

AllanC.


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

Date: Thu, 27 Nov 1997 10:18:59 GMT
From: Gordon McDorman <gordon.leslie.mcdorman@sap-ag.de>
Subject: Re: Removing HTML tag
Message-Id: <uwwhu4p2k.fsf@sap-ag.de>

>>>>> "sf" == stephen farrell <sfarrell+usenet@farrell.org> writes:

sf> ryujiy@aol.com (Ryujiy) writes:
[...]
>> I can easily remove "</A>" using chop() function, but I cannot
>> figure out the way to remove "<A NAME ="label"> part.
[...]
sf> I imagine something like s/<.*>//gs would be a good first
                             ^^^^^^^^^^

Perhaps s/<.*?>//gs; might be a little bit safer?

-- 
-------------------------------------------------------------- 
The opinions expressed above are mine, not my employer's.
      
gordon.leslie.mcdorman@sap-ag.de                               


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

Date: Thu, 27 Nov 1997 10:35:53 -0800
From: Tom Phoenix <rootbeer@teleport.com>
To: Hel's Synic <jelly&ham_abuse@omen.net.au>
Subject: Re: script refuses to print variables to file but happily does to screen
Message-Id: <Pine.GSO.3.96.971127103243.6576H-100000@usertest.teleport.com>

On Thu, 27 Nov 1997, Hel's Synic wrote:

> #!/usr/bin/perl 

Why no -w option? If your script isn't doing what you want, Perl may be
able to tell you why. 

> # Get the input
> read(STDIN, $buffer, $ENV{'CONTENT_LENGTH'});
> 
> # Split the name-value pairs
> @pairs = split(/&/, $buffer);

It's not only simpler to have a module (like CGI.pm) to do this...

> foreach $pair (@pairs) {
>    ($name, $value) = split(/=/, $pair);
> 
>    $value =~ tr/+/ /;
>    $value =~ s/%([a-fA-F0-9][a-fA-F0-9])/pack("C", hex($1))/eg;
>    $value =~ s/<([^>]|\n)*>//g;
>    $value =~ s/<//g;
>    $value =~ s/>//g;
>    $FORM{$name} = $value;
> }

 ...but also, CGI.pm does it correctly. :-)

> open (SESAME, ">>/home/synic/public_html/scripts/test.html"); 

Even when your script is "just an example" (and perhaps especially in that
case!) you should _always_ check the return value after opening a file.
Since you seem to be having troubles writing to a file, this is even more
important.

Good luck!

-- 
Tom Phoenix           http://www.teleport.com/~rootbeer/
rootbeer@teleport.com  PGP   Skribu al mi per Esperanto!
Randal Schwartz Case:  http://www.rahul.net/jeffrey/ovs/
              Ask me about Perl trainings!



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

Date: 28 Nov 1997 01:35:11 GMT
From: mgjv@comdyn.com.au (Martien Verbruggen)
Subject: Re: script refuses to print variables to file but happily does to screen
Message-Id: <65l74f$pi$5@comdyn.comdyn.com.au>

In article <65is65$l6v$1@demeter.omen.com.au>,
	jelly&ham_abuse@omen.net.au (Hel's Synic) writes:

[Lots of SNIP]
> open (SESAME, ">>/home/synic/public_html/scripts/test.html"); 

Try 

open (SESAME, ">>/home/synic/public_html/scripts/test.html") 
	or die "Cannot open file for appending: $!";

And see if it maybe gives you an error message?

Martien
-- 
Martien Verbruggen                  | 
Webmaster www.tradingpost.com.au    | I'm just very selective about what I
Commercial Dynamics Pty. Ltd.       | accept as reality - Calvin
NSW, Australia                      | 


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

Date: Thu, 27 Nov 1997 10:14:46 -0800
From: Tom Phoenix <rootbeer@teleport.com>
To: Tim Gilman <tdgilman@DELETETHISbest.com>
Subject: Re: Strange 'print Location:' problem with Perl
Message-Id: <Pine.GSO.3.96.971127101305.6576D-100000@usertest.teleport.com>

On Wed, 26 Nov 1997, Tim Gilman wrote:

> What I found out is that this problem only seems to exist with IE4.0. 

Then it's not a Perl problem. If you're not following the standards,
there's your problem. If you're following the standards and IE4.0 doesn't,
then it's a bug in IE4.0. If you're not sure what the standards say, you
should check them out. If you still aren't sure, then you should ask in a
newsgroup about them. Good luck! 

-- 
Tom Phoenix           http://www.teleport.com/~rootbeer/
rootbeer@teleport.com  PGP   Skribu al mi per Esperanto!
Randal Schwartz Case:  http://www.rahul.net/jeffrey/ovs/
              Ask me about Perl trainings!



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

Date: Thu, 27 Nov 1997 10:30:28 -0800
From: Tom Phoenix <rootbeer@teleport.com>
To: Helmut Jarausch <jarausch@numa1.igpm.rwth-aachen.de>
Subject: Re: SUID + Linux
Message-Id: <Pine.GSO.3.96.971127101759.6576G-100000@usertest.teleport.com>

On 25 Nov 1997, Helmut Jarausch wrote:

> I have a problem when using an SUID perl script on Linux (suidperl exists).
> The effective and real UID is zero but still I cannot do
> system("/bin/mount" ....)
> 
> since the kernel still claims "only root may use mount".
> How can I become "really" root?

Maybe you're doing something wrong. For example, maybe the real UID isn't
zero, or /bin/mount doesn't exist, or /bin/mount is setuid. Perhaps
/bin/mount isn't executable, or maybe you're passing it the wrong
arguments, or it could be a bug in /bin/mount. For starters, try printing
some debugging information before running system, to make sure that
everything is as you expect. For example: 

    $prog = '/bin/mount';
    die "The  uid is $<, not zero" if $<;
    die "The euid is $>, not zero" if $>;
    $mode = (stat $prog)[2];
    die "Can't stat $prog: $!" unless defined $mode;
    $short_mode = sprintf "%03o", ($mode & 0777);
    warn "The primary mode of $prog is $short_mode";

If you still can't find the problem, try posting a short example script
here. It should be fewer than ten lines or so. Good luck!

-- 
Tom Phoenix           http://www.teleport.com/~rootbeer/
rootbeer@teleport.com  PGP   Skribu al mi per Esperanto!
Randal Schwartz Case:  http://www.rahul.net/jeffrey/ovs/
              Ask me about Perl trainings!



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

Date: Thu, 27 Nov 1997 10:16:56 -0800
From: Tom Phoenix <rootbeer@teleport.com>
To: brian d foy <comdog@computerdog.com>
Subject: Re: sytem command test
Message-Id: <Pine.GSO.3.96.971127101615.6576E-100000@usertest.teleport.com>

On Wed, 26 Nov 1997, brian d foy wrote:

>    $status = system '/bin/pwd', '> /tmp/pwd';

I don't think that does what you might think it does. :-)

-- 
Tom Phoenix           http://www.teleport.com/~rootbeer/
rootbeer@teleport.com  PGP   Skribu al mi per Esperanto!
Randal Schwartz Case:  http://www.rahul.net/jeffrey/ovs/
              Ask me about Perl trainings!



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

Date: 27 Nov 1997 14:50:17 -0600
From: scribble@shoga.wwa.com (Tushar Samant)
Subject: Re: sytem command test
Message-Id: <65kme9$fm6@shoga.wwa.com>

comdog@computerdog.com writes:
>you can do something like:
>
>   $status = system '/bin/pwd', '> /tmp/pwd';

That should be a period, not a comma.



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

Date: Thu, 27 Nov 1997 01:57:37 -0500
From: Chipmunk <rjk@coos.dartmouth.edu>
Subject: Re: tail -f cmd (again)
Message-Id: <347D19E0.7E8@coos.dartmouth.edu>

Anthony Licciardi wrote:
> 
> Firstly, I would like to thank those of you who took the time to give me
> some feedback to this tail -f cmd. Now I have another dilemma with this.
> When tail -f monitors a file, what is written into this file are
> multiple lines - not one.
> For eg. tail -f file - monitors 'file'.
> The output will be appended to the file1.
> The output will overwrite to the file2. - so file2 will always have the
> latest that the tail -f file had.
> More explanation: testfile contains the following lines:
> this is line one
> this is line two
> If I cat testfile >> file, file1 will be the same as file as it is
> appending. Whereas file2 will have only the latest output. In the
> suggestions I have had what happens is that 'this is line two' is only
> written to file2 - not the 'this is line one' as well.

Presumably, both lines are being written to file2, but your script
doesn't know to keep the filehandle open between printing the two
lines.  So, 'line 1' is being clobbered.

The question is, how does the script know that those two lines go
together?  tail -f just prints the lines as they come in, so there's no
simple way for your script to realize that 'line 1' and 'line 2' should
be printed together, and the next 'line 1' and 'line 2' should be
printed together, but separate from the first pair.


Possible solutions:

If the lines are *always* printed to the monitored file in pairs, your
script can read lines two at a time.  Kind of a hack though.

If there is a blank line between the groups of lines, you can set $/ to
"\n\n".  Then your script will read in a group of lines all at once.


Basically, you need a way for your script to know when a new group of
lines has started.  Could you provide more information about the format
of the file being monitored?  Also, where are the lines in the monitored
file coming from?

Chipmunk


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

Date: Thu, 27 Nov 1997 19:14:22 GMT
From: swmcd@world.std.com (Steven W McDougall)
Subject: Re: Theory behind perl
Message-Id: <EKBK3y.49I@world.std.com>

Sameer Kamruddin Merchant <sampav@cc.gatech.edu> writes:

>I'm looking for some information about perl as a programming languages -

Larry wall has written on this.

He posted an article to comp.lang.perl.misc discussing linguistic
aspects of Perl. See
http://world.std.com/~swmcd/steven/perl/linguistics.html for a copy of
the article.

He wrote an article in the first issue of The Perl Journal discussing
artistic aspects of Perl. See http://tpj.com to order back issues.

- SWM


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

Date: 27 Nov 1997 21:39:53 GMT
From: nobody@nowhere.com (sysadmin)
Subject: Re: TK port for win32????????/
Message-Id: <65kpb9$spv@newsserver.trl.OZ.AU>

www.windows95.com has a lot of *ix ports for win32 and I beleive I got my
 copy of TCL/Tk from there.

AllanC.

>>I understand that there is now  TK port for win32 does anyone use it or
 know
>>where I can get it from??
>>
>>Cheers
>>Jon Tracey
>>jon.tracey@earthling.net
>>
>>


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

Date: 27 Nov 1997 17:54:05 GMT
From: smcnabb@interlog.com (Steve McNabb)
Subject: VERY strange perl problem...
Message-Id: <65kc3t$dqi$1@nntp1.uunet.ca>

Hi..

I am having a very confusing problem with a perl app that I'm working on.

(NT 4.0 , Guramy Suth. port of perl 5.004_02)

The symptoms:  

I have two core perl scripts :  start.cgi and main.cgi

(user has already been authenticated)


start.cgi just sets up some background stuff on the server and then asks the 
user to click to continue.

main.cgi -- this is where the problem begins -- I open main.cgi from start.cgi 
in a child window via a Javascript function (there is a good reason for this -- 
honest ;-)  BUT if I log in as myself (an administrator) I can occasionally get 
the scripts to run correctly.  BUT, if I log in as anything else, I get a 
http:1.0/500 (that directory name is invalid) error.....

The script directory has proper permissions set on it (I even bumped it up to 
"full control" but no dice) and the directory that holds the files that 
main.cgi reads and writes has "full control" set on it too...  (I don't plan to 
roll it out with full control on, just trying to track down this problem :)

This is rather confusing....it works fine without authent. but when I introduce  
the security auth. (through NT user manager and ntfs file permissions) it 
seems to behave strangely.  I could understand if BOTH perl scripts failed, but 
why the heck would start.cgi run fine and main.cgi fail?   Is it the file 
access?  Does perl.exe have to masquerade as a user?  (if so, a tip on where to 
look for info on how to do this would be appreciated ;-)  


Any help would be greatly appreciated



Thanks!!!!


Steve McNabb






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

Date: 28 Nov 1997 01:14:15 GMT
From: mgjv@comdyn.com.au (Martien Verbruggen)
Subject: Re: Windows 95 flock problem (hapless newbie question)
Message-Id: <65l5t7$pi$2@comdyn.comdyn.com.au>

In article <65hllc$r83@mtinsc02.worldnet.att.net>,
	"Benjamin Geer" <benjamin.geer@worldnet.att.net> writes:
> I'm really stumped.  The program is so small that I'm attaching it.

> begin 666 message3.pl
> M(R!M97-S86=E,RYP; T*(R!B>2!"96YJ86UI;B!'965R#0HC(#(U+4YO=BTY

Please don't 'attach' it. Just include it in your message body. Most
people don't want to have to decode what you post just to be able to
read it.

Martien
-- 
Martien Verbruggen                  | 
Webmaster www.tradingpost.com.au    | You can't have everything, where would
Commercial Dynamics Pty. Ltd.       | you put it?
NSW, Australia                      | 


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

Date: 8 Mar 97 21:33:47 GMT (Last modified)
From: Perl-Request@ruby.oce.orst.edu (Perl-Users-Digest Admin) 
Subject: Digest Administrivia (Last modified: 8 Mar 97)
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.misc (and this Digest), send your
article to perl-users@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.

The Meta-FAQ, an article containing information about the FAQ, is
available by requesting "send perl-users meta-faq". The real FAQ, as it
appeared last in the newsgroup, can be retrieved with the request "send
perl-users FAQ". Due to their sizes, neither the Meta-FAQ nor the FAQ
are included in the digest.

The "mini-FAQ", which is an updated version of the Meta-FAQ, is
available by requesting "send perl-users mini-faq". It appears twice
weekly in the group, but is not distributed in the digest.

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 V8 Issue 1383
**************************************

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