[12681] in Perl-Users-Digest

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

Perl-Users Digest, Issue: 90 Volume: 9

daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Fri Jul 9 12:07:15 1999

Date: Fri, 9 Jul 1999 09:05:13 -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, 9 Jul 1999     Volume: 9 Number: 90

Today's topics:
        array stuff.. <marshalc@americasm01.nt.com>
    Re: cgi question, can you help me? <martin@adoma.se>
    Re: CGI woes for newbie <uri@sysarch.com>
    Re: Cookies won't work <tchrist@mox.perl.com>
    Re: Deleting everything after a pattern? (Bart Lateur)
    Re: ftp <ianmorty@nortelnetworks.com>
    Re: Hacker fouls off All-Star site (I R A Aggie)
    Re: Hacker fouls off All-Star site <uri@sysarch.com>
    Re: Hacker fouls off All-Star site (Chris Nandor)
        Help with .pl script execution problem fvultee@my-deja.com
        HELP! how do I run remsh commands from a script? <tsranga@leland.Stanford.EDU>
    Re: Help: how to capture other process's stdin/stdout ? <aisenber@ix.netcom.com>
    Re: how to compare a "string" with /etc/shadow password <paul.mutyambizi@citicorp.quit.spam.com>
        How to read and display a gif file? <joaob@despodata.pt>
    Re: How to read and display a gif file? <tchrist@mox.perl.com>
        howto write to a file stream without creating a file? lmoloch@my-deja.com
    Re: howto write to a file stream without creating a fil <tchrist@mox.perl.com>
        Knowing from which script a sub was called. christian.sylvestre@cetelem.fr
    Re: Knowing from which script a sub was called. <tchrist@mox.perl.com>
        long long in perl? ahornbeck@yahoo.com
    Re: Perl Everywhere : That's what I want (Claudio Calvelli)
    Re: please help regex! <marshalc@americasm01.nt.com>
    Re: please help regex! (Bart Lateur)
    Re: please help regex! (Larry Rosler)
    Re: Program for Easy Writing of Perl Code (Benjamin Franz)
    Re: Question: Good Project? fuddmain@nospam.gdi.net
    Re: Random Numbers <doughera@lafayette.edu>
        re help with read ( ) <bbridges@seark.net>
    Re: Self-referencing hash? Ick? (Bernie Cosell)
        short / long names on Win NT <patrick.renaud@transport.alstom.com>
    Re: single instance log file <sskinner@cloud9.net>
        Strangeness re $#{$test{'foo'}{'bar'}} <trojan@samurai.ruin.org>
    Re: Strangeness re $#{$test{'foo'}{'bar'}} (Larry Rosler)
        Too late for "-T" option at init.cgi line 1. <mikecard@my-deja.com>
    Re: Unbelievably simple question <therobin@nortelnetworks.com>
    Re: Using perlcc to compile a perl prog richardwchin@my-deja.com
        Digest Administrivia (Last modified: 1 Jul 99) (Perl-Users-Digest Admin)

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

Date: Fri, 09 Jul 1999 10:30:46 -0500
From: Marshall Culpepper <marshalc@americasm01.nt.com>
Subject: array stuff..
Message-Id: <378615A6.8736FB08@americasm01.nt.com>

hey kind of an intermediate skill level on perl..
is there any quick function to add a certain string to every element of
an array
i.e;
$str="a";
@test=('0'..'5');
and test would return as ('a0'..'a5')? any help would be greatly
appreciated :)

~marshall



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

Date: Fri, 09 Jul 1999 16:17:30 +0100
From: Martin Quensel <martin@adoma.se>
Subject: Re: cgi question, can you help me?
Message-Id: <3786128A.6DAF1F1A@adoma.se>



Abigail wrote:
> 
> Miroslav (miroslav@gamestats.com) wrote on MMCXXXVI September MCMXCIII in
> <URL:news:3783E8A8.6AA418F8@gamestats.com>:
> () you could
> ()
> () print "Please wait for results...";
> ()
> () [ do your stats thing here ] #it'll wait I think until server finishes
> ()
> () print "Here's your stats...";
> ()
> () Just a thought, I never used anything like this
> 
> And of course, all the buffers between your program and the client
> happily flush on demand.
> 
> I don't think so.
> 

Abigail is right.

You have to do something like this...

print "Content-type: text/html\n\n";
print<<EOHTMLSHIT;
<html><head><title>
waiting (forever?)</title>
Then some html thing that redirects 
the client browser to another page after a couple of seconds.
forexample to www.lala.com/result.html.
EOHTMLSHIT

[do your stats thing here]

open a filehandle to the result.html page
and print in the stats there.

it should work....i havent tried it..never had a need to.
But it should work, aslong as you can do some redirection in HTML or
javascript


Martin Quensel


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

Date: 09 Jul 1999 11:43:37 -0400
From: Uri Guttman <uri@sysarch.com>
Subject: Re: CGI woes for newbie
Message-Id: <x7k8s9suae.fsf@home.sysarch.com>

>>>>> "BL" == Bart Lateur <bart.lateur@skynet.be> writes:

  BL> 	@names = $query->param();
  BL> # version 1
  BL> 	@values = map {	$query->($_) } @names;
                               ^^


  BL> 	print join " | ", @values;
  BL> #version 2
  BL> 	foreach $name (@names) {
  BL> 		my $value = $query->($name);
                                   ^^

  BL> 		print " $name -> $value\n";
  BL> 	}

missing the param method in both cases.

uri

-- 
Uri Guttman  -----------------  SYStems ARCHitecture and Software Engineering
uri@sysarch.com  ---------------------------  Perl, Internet, UNIX Consulting
Have Perl, Will Travel  -----------------------------  http://www.sysarch.com
The Best Search Engine on the Net -------------  http://www.northernlight.com
"F**king Windows 98", said the general in South Park before shooting Bill.


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

Date: 9 Jul 1999 08:11:23 -0700
From: Tom Christiansen <tchrist@mox.perl.com>
Subject: Re: Cookies won't work
Message-Id: <3786030b@cs.colorado.edu>

     [courtesy cc of this posting mailed to cited author]

In comp.lang.perl.misc, backwards.saerdna@srm.hc (Andreas Fehr) writes:
:BTW, wasn't there any discussion whether a signature starts
:with '--' or with '-- '?

Nope.  It starts with "\n-- \n".   No discussion. :-)

--tom
-- 
    [End of diatribe.  We now return you to your regularly scheduled
    programming...]
        --Larry Wall in Configure from the perl distribution


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

Date: Fri, 09 Jul 1999 16:00:07 GMT
From: bart.lateur@skynet.be (Bart Lateur)
Subject: Re: Deleting everything after a pattern?
Message-Id: <37861ba4.31529806@news.skynet.be>

Abigail wrote:

>#!/opt/perl/bin/perl -w
>use strict;
>use Benchmark;
>
>my $text = 'a'. ('x' x 1000) . 'b';
>
>timethese(100000, {
>    GREEDY => sub { $text =~ /a.*b/ },
>    FRUGAL => sub { $text =~ /a.*?b/ },
>});
>
>__END__
>
>Benchmark: timing 100000 iterations of FRUGAL, GREEDY...
>    FRUGAL: 19 secs (17.50 usr  0.00 sys = 17.50 cpu)
>    GREEDY:  1 secs ( 2.33 usr  0.00 sys =  2.33 cpu)

Ouch!

Try

	$text = 'ab' . ('x' x 1000);

and the speed ratio is reversed.

    FRUGAL:  3 wallclock secs ( 4.34 usr +  0.00 sys =  4.34 CPU)
    GREEDY: 14 wallclock secs (13.63 usr +  0.00 sys = 13.63 CPU)

Conclusion? Eh...

	Bart.


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

Date: Fri, 09 Jul 1999 15:39:44 +0100
From: Ian Mortimer <ianmorty@nortelnetworks.com>
Subject: Re: ftp
Message-Id: <378609B0.A317357D@nortelnetworks.com>

Thanks Abigail - but that was already mentioned !

Perhaps you could supply some simple examples of where this has been
used  ????

Ian.

> 
> Ian Mortimer (ianmorty@nortelnetworks.com) wrote on MMCXXXVIII September
> MCMXCIII in <URL:news:3785C004.6F360D15@nortelnetworks.com>:
> ``
> `` Is it possible to run an ftp session using perl ?
> 
> Net::FTP;
> 
> Abigail
> --
> package Just_another_Perl_Hacker; sub print {($_=$_[0])=~ s/_/ /g;
>                                       print } sub __PACKAGE__ { &
>                                       print (     __PACKAGE__)} &
>                                                   __PACKAGE__
>                                             (                )
> 
>   -----------== Posted via Newsfeeds.Com, Uncensored Usenet News ==----------
>    http://www.newsfeeds.com       The Largest Usenet Servers in the World!
> ------== Over 73,000 Newsgroups - Including  Dedicated  Binaries Servers ==-----


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

Date: 9 Jul 1999 13:53:35 GMT
From: fl_aggie@thepentagon.com (I R A Aggie)
Subject: Re: Hacker fouls off All-Star site
Message-Id: <slrn7obvr9.jlu.fl_aggie@thepentagon.com>

On 9 Jul 1999 13:27:33 GMT, John Klassa <klassa@aur.alcatel.com>, in
<7m4tc5$oco$1@aurwww.aur.alcatel.com> wrote:

+ Our very own Chris Nandor?

Yes. Only a Red Sox fan would go by the nick of 'Pudge'. And being a
Red Sox fan myself, I'll be more than happy to help him next season.

James


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

Date: 09 Jul 1999 11:51:27 -0400
From: Uri Guttman <uri@sysarch.com>
Subject: Re: Hacker fouls off All-Star site
Message-Id: <x7hfndstxc.fsf@home.sysarch.com>

>>>>> "JK" == John Klassa <klassa@aur.alcatel.com> writes:

  JK> Our very own Chris Nandor?

yes. he is very infamous now. it made the boston globe, ap wire, local
tv news, slashdot, etc. jon orwant was interviewed about it too.

uri

-- 
Uri Guttman  -----------------  SYStems ARCHitecture and Software Engineering
uri@sysarch.com  ---------------------------  Perl, Internet, UNIX Consulting
Have Perl, Will Travel  -----------------------------  http://www.sysarch.com
The Best Search Engine on the Net -------------  http://www.northernlight.com
"F**king Windows 98", said the general in South Park before shooting Bill.


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

Date: Fri, 09 Jul 1999 16:02:36 GMT
From: pudge@pobox.com (Chris Nandor)
Subject: Re: Hacker fouls off All-Star site
Message-Id: <pudge-0907991202430001@192.168.0.17>

http://pudge.net/tmp/pudge_on_espn.mp3

-- 
Chris Nandor          mailto:pudge@pobox.com         http://pudge.net/
%PGPKey = ('B76E72AD', [1024, '0824090B CE73CA10  1FF77F13 8180B6B6'])


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

Date: Fri, 09 Jul 1999 15:33:25 GMT
From: fvultee@my-deja.com
Subject: Help with .pl script execution problem
Message-Id: <7m54o5$cvm$1@nnrp1.deja.com>

Hi all,

Quick question.  I have a perl script that I found on the net called
mailit.pl.  It used to work in conjunction with my website so people
could automatically subscribe and unsubscribe to a listserv via a
webpage and the script would automatically email the person their
subscription status.  I reinstalled my web software, Sambar Web Server,
and reconfigured it, and now I have the following problem.  Instead of
the webpage calling mailit.pl and processing the listserv request, it
instead displays the text of the script in the browser.  You can see an
example of my problem at:

http://letterman.dynip.com

Just click on subscribe or unsubscribe and click the button.  It should
process the request, but instead displays the text of the .pl script.

Any ideas would be greatly apprecaited!

Forrest


Sent via Deja.com http://www.deja.com/
Share what you know. Learn what you don't.


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

Date: Fri, 9 Jul 1999 08:49:31 -0700
From: Ranganath Sudarshan <tsranga@leland.Stanford.EDU>
Subject: HELP! how do I run remsh commands from a script?
Message-Id: <Pine.GSO.3.96.990709084516.13410A-100000@myth7.Stanford.EDU>

Does anyone know how to run the UNIX command 'remsh' from within a perl
script (like 'remsh bob -l root -n "file1 /file2" ')?

And a more general question -- is there a general way to execute UNIX
commands in Perl(like cp, ls, etc), or do we have to use canned
Perl-specific functions or pre-written modules?

Thanks!



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

Date: Fri, 9 Jul 1999 11:34:47 -0400
From: "Mark Aisenberg" <aisenber@ix.netcom.com>
Subject: Re: Help: how to capture other process's stdin/stdout ?
Message-Id: <1Foh3.3475$kL2.274705@ndnws01.ne.mediaone.net>

You can do it using the Perl "backtick" command.
On my Win32 system, this works fine, e.g.:

    use strict;
    my $result = `dir /on`;
    print $result;

Here, you launch the program (dir) with parameters (/on).
The result (the listing of files) is captured in $result.

Is this what you wanted?

-- Mark Aisenberg




Gump Xu <gump_xu@sc.mcel.mot.com> wrote in message
news:7m1jna$2ig$1@schbbs.mot.com...
> Hi,
>    I am writing a Perl program which will start other
> shell programs and need to send inputs(stdin) to them and
> check their stdout.
>    I don't know how to do it via Perl. Anyone help me?
>
> thanks,
> Gump
>
>




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

Date: Fri, 09 Jul 1999 15:36:09 +0100
From: Paul Mutyambizi <paul.mutyambizi@citicorp.quit.spam.com>
Subject: Re: how to compare a "string" with /etc/shadow password
Message-Id: <378608D8.FC2C7204@citicorp.quit.spam.com>

Have a look at crypt in perlfunc 'man' page it details exactly what you
are asking.

Mike Lin wrote:

> I am just curious if there is a way to compare a user input string
> against
> the encrypted password in /etc/shadow under Solaris.
>
> Thanks

--
*************************************
Opinions expressed are solely my own!
To reply to me, remove 'quit.spam'
from the e-mail address shown above.
*************************************




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

Date: Fri, 09 Jul 1999 16:19:15 +0100
From: =?iso-8859-1?Q?Jo=E3o?= Bonina <joaob@despodata.pt>
Subject: How to read and display a gif file?
Message-Id: <378612F3.224FC9FB@despodata.pt>


	Hi!
	Are there any functions for reading and displaying a GIF or JPG file?


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

Date: 9 Jul 1999 09:46:31 -0700
From: Tom Christiansen <tchrist@mox.perl.com>
Subject: Re: How to read and display a gif file?
Message-Id: <37861957@cs.colorado.edu>

     [courtesy cc of this posting mailed to cited author]

In comp.lang.perl.misc, 
    =?iso-8859-1?Q?Jo=E3o?= Bonina <joaob@despodata.pt> writes:
:	Are there any functions for reading and displaying a GIF or JPG file?

Personally, I usually use:

    system("xv", $file);

or 

    system("netscape", "-remote", "openURL(file://localhost$cwd/$file)");


--tom
-- 
    If I allowed "next $label" then I'd also have to allow "goto $label",
    and I don't think you really want that...  :-) [now works in perl5!]
            --Larry Wall in <1991Mar11.230002.27271@jpl-devvax.jpl.nasa.gov>


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

Date: Fri, 09 Jul 1999 15:28:15 GMT
From: lmoloch@my-deja.com
Subject: howto write to a file stream without creating a file?
Message-Id: <7m54e5$csg$1@nnrp1.deja.com>

I have a function which is passed a string as a parameter. However it
uses the HTML::TokeParser::new() function which requires a stream to be
passed to it.

I cannot create any sort of temporary file and use that as a input file
stream.

So how do I reroute that string to a stream? Also, if I can somehow
output to STDIN and read in STDIN later on... that would be effective
too...


Sent via Deja.com http://www.deja.com/
Share what you know. Learn what you don't.


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

Date: 9 Jul 1999 09:57:51 -0700
From: Tom Christiansen <tchrist@mox.perl.com>
Subject: Re: howto write to a file stream without creating a file?
Message-Id: <37861bff@cs.colorado.edu>

     [courtesy cc of this posting mailed to cited author]

In comp.lang.perl.misc, lmoloch@my-deja.com writes:
:I have a function which is passed a string as a parameter. However it
:uses the HTML::TokeParser::new() function which requires a stream to be
:passed to it.
:
:I cannot create any sort of temporary file and use that as a input file
:stream.
:
:So how do I reroute that string to a stream? Also, if I can somehow
:output to STDIN and read in STDIN later on... that would be effective
:too...

Well, you can try the simple but potentially expensive approach:

    use strict;

    $| = 1;

    sub forksub {
	my($cref, @argv) = @_;
	local *MYSELF;
	my $kidpid = open(MYSELF, "-|");
	die "cannot fork: $!" unless defined $kidpid;
	if ($kidpid == 0) {
	local $| = 1;
	    $cref->(@argv);
	    exit;
	}
	if (wantarray) {
	    my @retlist = <MYSELF>;
	    close MYSELF;
	    return @retlist;
	} 
	local $/;
	my $retval = <MYSELF>;
	close MYSELF;
	return $retval;
    } 

    sub now    { print scalar localtime }
    sub whoami { system("who am i") } 

    sub square { print $_[0] ** 2 }
    sub pwent  { print map { "$_\n" } getpwuid($>) }

    printf "%-10s %s\n", 'now', forksub \&now;
    printf "%-10s %s\n", 'whoami', forksub \&whoami;

    printf "%-10s %s\n", 'square', forksub \&square, -3;
    printf "%-10s %s\n", 'pwent', scalar(forksub \&pwent);

    exit;

    my @lines = forksub \&pwent;
    for (my $i = 0; $i < @lines; $i++) {
	printf "%-10s %d: %s\n", 'pwent', $i, $lines[$i];
    }

Or you can use the IO::String module from CPAN.

    NAME
	IO::String - Emulate IO::File interface for in-core strings

    SYNOPSIS
	 use IO::String;
	 $io = IO::String->new;
	 $io = IO::String->new($var);
	 tie *IO, 'IO::String';

	 # read data
	 <$io>;
	 $io->getline;
	 read($io, $buf, 100);

	 # write data
	 print $io "string\n";
	 $io->print(@data);
	 syswrite($io, $buf, 100);

	 select $io;
	 printf "Some text %s\n", $str;

	 # seek
	 $pos = $io->getpos;
	 $io->setpos(0);        # rewind
	 $io->seek(-30, -1);

    DESCRIPTION
	The `IO::String' module provide the `IO::File' interface for in-
	core strings. An `IO::String' object can be attached to a
	string, and will make it possible to use the normal file
	operations for reading or writing data, as well as seeking to
	various locations of the string. The main reason you might want
	to do this, is if you have some other library module that only
	provide an interface to file handles, and you want to keep all
	the stuff in memory.

	The `IO::String' module provide an interface compatible with
	`IO::File' as distributed with IO-1.20, but the following
	methods are not available; new_from_fd, fdopen, format_write,
	format_page_number, format_lines_per_page, format_lines_left,
	format_name, format_top_name.

	The following methods are specific for the `IO::String' class:

	$io = IO::String->new( [$string] )
	    The constructor returns a newly created `IO::String' object.
	    It takes an optional argument which is the string to read
	    from or write into. If no $string argument is given, then an
	    internal buffer (initially empty) is allocated.

	    The `IO::String' object returned will be tied to itself.
	    This means that you can use most perl IO builtins on it too;
	    readline, <>, getc, print, printf, syswrite, sysread, close.

	$io->open( [$string] )
	    Attach an existing IO::String object to some other $string,
	    or allocate a new internal buffer (if no argument is given).
	    The position is reset back to 0.

	$io->string_ref
	    This method will return a reference to the string that is
	    attached to the `IO::String' object. Most useful when you
	    let the `IO::String' create an internal buffer to write
	    into.

	$io->pad( [$char] )
	    The pad() method makes it possible to specify the padding to
	    use if the string is extended by either the seek() or
	    truncate() methods. It is a single character and defaults to
	    "\0".

	$io->pos( [$newpos] )
	    Yet another interface for reading and setting the current
	    read/write position within the string (the normal
	    getpos/setpos/tell/seek methods are also available). The
	    pos() method will always return the old position, and if you
	    pass it an argument it will set the new position.

	    There is (deliberately) a difference between the setpos()
	    and seek() methods in that seek() will extend the string
	    (with the specified padding) if you go to a location past
	    the end, while setpos() will just snap back to the end. If
	    truncate() is used to extend the string, then it works as
	    seek().

	One more difference compared to IO::Handle, is that the write()
	and syswrite() methods allow the length argument to be left out.

    BUGS
	The perl TIEHANDLE interface is still not complete. There are
	quite a few file operations that will not yet invoke any method
	on the tied object. See the perltie manpage for details.

    SEE ALSO
	the IO::File manpage, the IO::Stringy manpage

    COPYRIGHT
	Copyright 1998-1999 Gisle Aas.

	This library is free software; you can redistribute it and/or
	modify it under the same terms as Perl itself.

-- 
    "Just because you're into control doesn't mean you're in control."
    	--Larry Wall


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

Date: Fri, 09 Jul 1999 15:41:19 GMT
From: christian.sylvestre@cetelem.fr
Subject: Knowing from which script a sub was called.
Message-Id: <7m556t$d64$1@nnrp1.deja.com>

I have a problem with a subroutine in one of my script. THis subroutine
is called very often from other module (scripts) and I was wondering if
there is a simple way to know in which script called a subroutine (from
inside the subroutine).

Thanx

Christian Sylvestre
-------------------
R & D, UNIX
Cetelem, Paris, France


Sent via Deja.com http://www.deja.com/
Share what you know. Learn what you don't.


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

Date: 9 Jul 1999 10:02:41 -0700
From: Tom Christiansen <tchrist@mox.perl.com>
Subject: Re: Knowing from which script a sub was called.
Message-Id: <37861d21@cs.colorado.edu>

     [courtesy cc of this posting mailed to cited author]

In comp.lang.perl.misc, christian.sylvestre@cetelem.fr writes:
:I have a problem with a subroutine in one of my script. THis subroutine
:is called very often from other module (scripts) and I was wondering if
:there is a simple way to know in which script called a subroutine (from
:inside the subroutine).

That's somewhat confusingly worded, because I don't consider "module" to be the
same as "script", but I think what you're looking for is simple the $0
variable.  Or maybe you need to walk back your stack frames with
caller($i).  Depends on what all you mean.

--tom
-- 
If you want your program to be readable, consider supplying the argument.
            --Larry Wall in the perl man page 


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

Date: Fri, 09 Jul 1999 15:40:28 GMT
From: ahornbeck@yahoo.com
Subject: long long in perl?
Message-Id: <7m555a$d5p$1@nnrp1.deja.com>

Is there an 8-byte integer type in perl?  Or a package that supports it?

Thanks,

-Ash


Sent via Deja.com http://www.deja.com/
Share what you know. Learn what you don't.


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

Date: Fri, 09 Jul 1999 14:24:54 GMT
From: nospam@assurdo.com (Claudio Calvelli)
Subject: Re: Perl Everywhere : That's what I want
Message-Id: <nospam.1426583728@assurdo.com>

On Thu, 08 Jul 1999 16:58:44 GMT, Philip 'Yes, that's my address' Newton
<nospam.newton@gmx.net> wrote:
> The Perl filesystem is at http://www.assurdo.com/perlfs/

Well, the Perl Filesystem is just a proof of concept. It can be done.
It works. It's fun. The initial idea was to be able to write generic
kernel modules in Perl (e.g. "insmod Driver.pm" or maybe even "insmod
HW::Drivers::Serial") but the reactions I've had from people ranged
from "this is obscene" to "you are insane" so I decided to settle for
something simple and see if it worked.

One of these days I'll find the time to write an OS in Perl (or maybe
in INTERCAL or dd/sh). Shouldn't be *that* difficult. Well, maybe it is.
I am currently studying the problem to see how many problems I'm likely
to run into (that's going to be a long list).

I have to stop now: the man with the white coat wants me to wear the
shirt with very long sleeves again.

-- 
Claudio Calvelli - Resident Lunatic - Assurdo Technologies INTERCAL Project
To send email replace the "nospam" with "lunatic" in "nospam@assurdo.com"
Disclaimer: This article reflects Assurdo Technologies' Official Position and
should not be taken as my personal opinion.


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

Date: Fri, 09 Jul 1999 09:47:56 -0500
From: Marshall Culpepper <marshalc@americasm01.nt.com>
Subject: Re: please help regex!
Message-Id: <37860B9B.7158F433@americasm01.nt.com>

hamed53@my-deja.com wrote:

> hi
> i was wondering if any of you could help me with this:
> i have a string i want to reverse the words containing olny these chars
> (more than or equal 128, less than 176 or, more than or equal 224, less
> than 255) :)
> (ord($mychar) >= 128 && ord($mychar) < 176) or (ord($mychar) >= 224 &&
> ord($mychar) < 255)
> for example i have this string:
> my $string = "hello this is test for £¦©¢ and ©¤£¢??~";
> the output would be:
> hello this is test for ¢©¦£ and ~??¢£¤©
> actually those words are farsi words in diffrent language!
> so i want to only reverse the farsi words! not english ones!
> any help would be appreciated
> thanks
> hamed
>
> Sent via Deja.com http://www.deja.com/
> Share what you know. Learn what you don't.

well...here's what i would do but i'm crappy at perl ;)
@sepspace=split(/\s/,$string);
@toreverse=grep(/\W/,@sepspace);
 foreach $one (@toreverse){
    split(//,$one);
    reverse(@_);
    $one=join(@_,//);
}

I think that should do it but i'm always wrong about these kinds of
things....that searches for a non-alphanumeric so i hope your little farsi
language doesn't contain /[a-z][A-Z][0-9]/ :P
~marshall



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

Date: Fri, 09 Jul 1999 15:28:35 GMT
From: bart.lateur@skynet.be (Bart Lateur)
Subject: Re: please help regex!
Message-Id: <378612ea.29295731@news.skynet.be>

hamed53@my-deja.com wrote:

>i have a string i want to reverse the words containing olny these chars

>(ord($mychar) >= 128 && ord($mychar) < 176) or (ord($mychar) >= 224 &&
>ord($mychar) < 255)

Ugh. That looks like "C".

>for example i have this string:
>my $string = "hello this is test for £¦©¢ and ©¤£¢’‘~";
>the output would be:
>hello this is test for ¢©¦£ and ~‘’¢£¤©
>actually those words are farsi words in diffrent language!
>so i want to only reverse the farsi words! not english ones!

Ah. Fun one. Try matching a sequence of those characters (use a
character class) and use the function reverse() on it.

	s/([\x80-\xAF\xE0-\xFE]+)/reverse $1/ge;

Ain't Perl nice? :-)

BTW I've tested it, and it doesn't include the "~" in the sequence.
You'd better check that.

	Bart.


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

Date: Fri, 9 Jul 1999 08:14:13 -0700
From: lr@hpl.hp.com (Larry Rosler)
Subject: Re: please help regex!
Message-Id: <MPG.11efb1809256bce3989c7c@nntp.hpl.hp.com>

[Posted and a courtesy copy sent.]

In article <7m4sgm$9u7$1@nnrp1.deja.com> on Fri, 09 Jul 1999 13:13:03 
GMT, hamed53@my-deja.com <hamed53@my-deja.com> says...
 ...
> i have a string i want to reverse the words containing olny these chars
> (more than or equal 128, less than 176 or, more than or equal 224, less
> than 255) :)
> (ord($mychar) >= 128 && ord($mychar) < 176) or (ord($mychar) >= 224 &&
> ord($mychar) < 255)
> for example i have this string:
> my $string = "hello this is test for £¦©¢ and ©¤£¢’‘~";
> the output would be:
> hello this is test for ¢©¦£ and ~‘’¢£¤©
> actually those words are farsi words in diffrent language!
> so i want to only reverse the farsi words! not english ones!

#!/usr/local/bin/perl -w
use strict;

$_ = "hello this is test for £¦©¢ and ©¤£¢’‘~\n";

print;

s/([\x80-\xaf\xe0-\xfe]+)/reverse $1/eg;

print;

-- 
(Just Another Larry) Rosler
Hewlett-Packard Laboratories
http://www.hpl.hp.com/personal/Larry_Rosler/
lr@hpl.hp.com


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

Date: Fri, 09 Jul 1999 14:06:40 GMT
From: snowhare@long-lake.nihongo.org (Benjamin Franz)
Subject: Re: Program for Easy Writing of Perl Code
Message-Id: <Qlnh3.2745$3v.154898@typhoon-sf.snfc21.pbi.net>

In article <7m4rvv$9nt$1@nnrp1.deja.com>,
mike cardeiro  <mikecard@my-deja.com> wrote:
>In article <3785e4bc@cs.colorado.edu>,
>  tchrist@mox.perl.com (Tom Christiansen) wrote:
>>
>> f u cn rd ths, u cn gt a gd jb n cmptr prgrmmng.
>>
>...why?

Many older languages and operating systems have/had 
very low name length limits. The result was many variable,
routine and program names that were abbreviated to 
absurd lengths. Newer languages and OSes don't have
those limits and tend to use longer, more readable, 
names for variables, routines and programmers...er
progams. 

-- 
Benjamin Franz 


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

Date: Fri, 09 Jul 1999 14:51:25 GMT
From: fuddmain@nospam.gdi.net
Subject: Re: Question: Good Project?
Message-Id: <37860a33.90015685@news.supernews.com>

On Wed, 7 Jul 1999 13:45:37 -0000, "MacInnes" <magoo10@prodigy.net>
wrote:

>Hello All,
>            I've been trying to teach myself the basics of perl through the
>book Learning Perl. I've read the first 6 chapters or so and before going
>any further I want to make sure I completely understand all that has been
>taught so far. There is no better way to learn how to program than to
>actually program, right :) ? So my question is what do you guys think would
>be a good project for me to undertake? I've done the exercises at the end of
>the chapters, but they only focus on that chapters material. So far I have
>learned about the following:
>
>scalar variables
>arrays
>hashes
>sub routines
>regular expressions
>and control structures
>
>Any ideas? Id like a project where I might be able to incorporate everything
>I know.
>
>Thanks in advance for any contributions..
>
>Jason
>Perl Newbie
>
>
I'm about 5 months into learning Perl.  I found the best way to
continue learning is to use Perl for projects that are relevant to you
in some way, whether for work or play (they say neccesity is the
mother of invention).  When a new project crops up at work I try to
determine if Perl would be the appropriate tool to use.  If it is then
I proceed to figure out how to get it done.  That approach has lead me
to learn how to use modules, references, etc.

If you haven't already done so, I suggest you pick up the Perl
Cookbook and the Camel book.

Good Luck.

Brian Goodwin


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

Date: Fri, 9 Jul 1999 11:02:23 -0400
From: Andy Dougherty <doughera@lafayette.edu>
Subject: Re: Random Numbers
Message-Id: <Pine.GSU.4.05.9907091044120.13592-100000@newton.phys>

On Fri, 9 Jul 1999, Watcher wrote:

> In article <MPG.11ee921a92212f97989c75@nntp.hpl.hp.com>,

> Yep, Tom Phoenix (in PerlFAQ4) had another similar program that show
> with a randbits=15, when generating 1e6 numbers, there are about 30+
> repeats!.  This, however is not Perl's fault.  Instead, it is due to
> the rand() in stdlib that Perl has been compiled with.

The following snippet from 5.005_02's INSTALL file explains how to change
the random number generater used by perl:

    For example, you can replace the rand() and srand() functions in the
    perl source by any other random number generator by a trick such as the
    following (this should all be on one line):

        sh Configure -Dccflags='-Dmy_rand=random -Dmy_srand=srandom' \
                -Drandbits=31

    or you can use the drand48 family of functions with

        sh Configure -Dccflags='-Dmy_rand=lrand48 -Dmy_srand=srand48' \
                -Drandbits=31

    or by adding the -D flags to your ccflags at the appropriate Configure
    prompt.  (Read pp.c to see how this works.)

In the current development track, Configure will select the first
available generator out of the sequence drand48(), random(), rand().

-- 
    Andy Dougherty		doughera@lafayette.edu
    Dept. of Physics
    Lafayette College, Easton PA 18042



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

Date: 9 Jul 1999 15:23:51 GMT
From: "Bob Bridges" <bbridges@seark.net>
Subject: re help with read ( )
Message-Id: <01beca1d$b68e6440$5564f5d0@bbridges.seark.net>

Don't start a flamewar.


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

Date: Fri, 09 Jul 1999 15:34:23 GMT
From: bernie@fantasyfarm.com (Bernie Cosell)
Subject: Re: Self-referencing hash? Ick?
Message-Id: <379215be.516784720@news.supernews.com>

lglenn <larry@ldis.com> wrote:

} In a script I'm writing, I'd kind of like to do something
} like this:
} 
} my %map;
} %map = ( foo => \%map, bar => 'hi' );
} 
} My question is, is this undefined behavior, or is it OK?

Not clear what you mean by "undefined".  I believe that it is 100% legal
and will work exactly as you expect... EXCEPT: perl will have a devil of a
time ever garbage collecting that hash, so if you expect it to be temporary
you oughta go read through the stuff about garbage collection and do what
you need to to make sure it'll be collected when you're done with it.  If
the hash is permanent [or just not large enough to worry about], then
forget about it, and all should be well.

[as for apologetic, no need for such with some of us: I'm a very old-line
Lisp hacker and cross referenced lists and circular lists and other strange
and anomalous structures are pretty common [and useful].  It is pretty easy
to see cases where you might have hash a with refs to hash b in it, and
hash b having refs back to hash a in it, and it all will work fine [but
give the garbage collector an ulcer... :o)

  /Bernie\
-- 
Bernie Cosell                     Fantasy Farm Fibers
bernie@fantasyfarm.com            Pearisburg, VA
    -->  Too many people, too few sheep  <--          


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

Date: Fri, 09 Jul 1999 16:26:45 +0200
From: Patrick RENAUD <patrick.renaud@transport.alstom.com>
Subject: short / long names on Win NT
Message-Id: <378606A4.92BF66E7@transport.alstom.com>

Hi all,

I'm using Perl on Windows NT.

Is it a module for converting long file names to short (DOS 8.3) and
short to long ?

Thanks for your help.

--
Patrick RENAUD
ALSTOM Transport EES, France
mailto:patrick.renaud@transport.alstom.com




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

Date: Fri, 09 Jul 1999 15:23:56 GMT
From: <sskinner@cloud9.net>
Subject: Re: single instance log file
Message-Id: <931533836.911.50@news.remarQ.com>

Anno Siegel <anno4000@lublin.zrz.tu-berlin.de> wrote:

>>#!/usr/local/bin/perl
> Where's the -w?

Not necessary for posting purposes.

>>open (FILEHANDLE, "+>> $myPath"); # read/append mode
> Where's the check for success?

I'm an optimist.

>>flock (FILEHANDLE, 2); # one thread at a time!
> Where's the check for success?

See above.

>>seek (FILEHANDLE, 0, 0); # start from the beginning
> Why open for append and then seek to the beginning?

Actually, I have opened in "read/append" mode, as indicated by the "+>>".
What you are thinking of is "append" mode, which is merely ">>". Since I
am in read/append mode, and I want to read the entire contents first, and
then append to the end later, I must first point to the beginning of the
file.

>>@items = <FILEHANDLE>; # read the entire file;
>>if (not ??? ) { # does the file contain an occurance of this
> See perldoc -q contains

Thank you for this clever suggestion! Actually, I have tried various
incarnations of =~ and !~ to no avail. If you have some solution in mind,
just say it. No need to be shy here.

One problem seems to be in comparing scalars to arrays. I'm thinking along
the lines of...

if ("@items" !~ chomp ($ENV{'HTTP_USER_AGENT'}) ) {

or something to that effect.

-S



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

Date: Fri, 9 Jul 1999 10:36:06 +0000
From: Adam Trojanowski <trojan@samurai.ruin.org>
Subject: Strangeness re $#{$test{'foo'}{'bar'}}
Message-Id: <Pine.BSF.4.10.9907091024330.15372-100000@samurai.ruin.org>

Hello all,

Was wondering if anyone else has noticed that an 'empty' array on a hash
of hash of array shows up with a record count of -1 instead of 0.  Also
seems like even when it's not empty, the record count is off by -1.

Is it just me?  I realize that this prose makes little sense, so I've
included a short (otherwise useless) script demonstrating my confusion in
action.

Can anyone give me a kick in the right direction?  Or perhaps constructive
heckling?

Thanks much,
Adam

*Script Follows*

#!/bin/perl
use strict;

my (%test,$x,@test,$y);

# what is number of elements of 'empty' hashs of hashes of arrays
$y = $#{$test{'foo'}{'bar'}};
print $y."\n\n";

# put some data in
push @{$test{'foo'}{'bar'}}, "The quick brown fox\n";
push @{$test{'foo'}{'bar'}}, "jumped over the lazy\n";
push @{$test{'foo'}{'bar'}}, "dog.\n";

# print data using indices
$y = $#{$test{'foo'}{'bar'}};
foreach $x ( 0 .. $y ) {
        print $test{'foo'}{'bar'}[$x];
}

#print number of elements
print $y."\n\n";

# control using 'standard' array
$y = @test;
print $y."\n\n";

push @test, "The quick brown fox\n";
push @test, "jumped over the lazy\n";
push @test, "dog.\n";

$y = @test;
foreach $x ( 0 .. @test ) {
        print $test[$x];
}
print $y;

*Script Ends*

-- 
"Tell me your dreams, and I'll crush them."  -Rebecca B. Gray
"doe not call up Any that you can not put downe."  -H.P. Lovecraft
Charter member, Federation of Silly Buggers



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

Date: Fri, 9 Jul 1999 08:30:16 -0700
From: lr@hpl.hp.com (Larry Rosler)
Subject: Re: Strangeness re $#{$test{'foo'}{'bar'}}
Message-Id: <MPG.11efb55cfb465217989c7d@nntp.hpl.hp.com>

[Posted and a courtesy copy sent.]

In article <Pine.BSF.4.10.9907091024330.15372-100000@samurai.ruin.org> 
on Fri, 9 Jul 1999 10:36:06 +0000, Adam Trojanowski 
<trojan@samurai.ruin.org> says...
> Was wondering if anyone else has noticed that an 'empty' array on a hash
> of hash of array shows up with a record count of -1 instead of 0.  Also
> seems like even when it's not empty, the record count is off by -1.

No, no one else has noticed such a thing.

> Is it just me?  I realize that this prose makes little sense, so I've
> included a short (otherwise useless) script demonstrating my confusion in
> action.

Yes, it is just you.

> Can anyone give me a kick in the right direction?  Or perhaps constructive
> heckling?

The issue isn't a kick in the right direction, it's a kick where.

 ...
> # what is number of elements of 'empty' hashs of hashes of arrays
> $y = $#{$test{'foo'}{'bar'}};

That is the last index (assuming, of course, $[ = 0, pedants!).

 ... 
> # control using 'standard' array
> $y = @test;

That is the number of elements.

Replace $# by @ and all will be well.  Consider kick to have been 
applied posteriorly.

-- 
(Just Another Larry) Rosler
Hewlett-Packard Laboratories
http://www.hpl.hp.com/personal/Larry_Rosler/
lr@hpl.hp.com


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

Date: Fri, 09 Jul 1999 15:49:45 GMT
From: mike cardeiro <mikecard@my-deja.com>
Subject: Too late for "-T" option at init.cgi line 1.
Message-Id: <7m55mk$dbh$1@nnrp1.deja.com>

i am making a program that will create and use data files.  i am a
little worried about users being able to rewrite these data files
outside of the perl script and wreaking havoc on my site (if thats
possible) so i searched low and high and someone suggested the taint
option, but when i try to invoke it i get:
     Too late for "-T" option at init.cgi line 1.

why is it too late and am i barking up the wrong tree by using taint

mike cardeiro


Sent via Deja.com http://www.deja.com/
Share what you know. Learn what you don't.


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

Date: Fri, 09 Jul 1999 11:02:01 -0400
From: Robin Senior <therobin@nortelnetworks.com>
To: Tony Lloyd <rtlloyd@easynet.co.uk>
Subject: Re: Unbelievably simple question
Message-Id: <37860EE9.B68DF0DC@nortelnetworks.com>

I'm not positive, but you should have a '\' before the @ symbol in your
email address, and you left off the right quotation mark. Change it to
this:

print MAIL "Cc: rtlloyd\@easynet.co.uk\n";

I don't know if Cc: is the correct syntax, but try my suggestions first.
If it still doesn't work, you can just do this:

open(MAIL,"|$mailprog -t");
print MAIL "To: $FORM{'recipient'}, rtlloyd\@easynet.co.uk\n";

It won't Cc:'d to you though, it'll just act as thought the message had
multiple recipients. I'm too lazy to see if Cc: is the correct syntax
:^)

-robin


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

Date: Fri, 09 Jul 1999 13:57:10 GMT
From: richardwchin@my-deja.com
Subject: Re: Using perlcc to compile a perl prog
Message-Id: <7m4v3g$att$1@nnrp1.deja.com>

In article <3785e39b@cs.colorado.edu>,
  tchrist@mox.perl.com (Tom Christiansen) wrote:
>      [courtesy cc of this posting mailed to cited author]
>
> In comp.lang.perl.misc,
>     richardwchin@my-deja.com writes:
> :I want to create a single executable rather
> :than a script that some users might be tempted to edit.
>
> "tempted"?  And what's your problem with that?
>
> --tom

I should tell you that I am asking for someone else so I don't know all
the details but he has a logon script that somebody has played around
with. In some cases he might get the blame for a problem that someone
else has caused.

Thinking about it perl may not be the best thing for him to use anyway.

In any case the FAQ says:
"In general, the compiler will do nothing to make a Perl program
smaller, faster, more portable, or more secure. In fact, it will
usually hurt all of those."
His main concern is security and if the compiler makes it less secure
the whole exercise is pointless.

Richard


Sent via Deja.com http://www.deja.com/
Share what you know. Learn what you don't.


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

Date: 1 Jul 99 21:33:47 GMT (Last modified)
From: Perl-Users-Request@ruby.oce.orst.edu (Perl-Users-Digest Admin) 
Subject: Digest Administrivia (Last modified: 1 Jul 99)
Message-Id: <null>


Administrivia:

The Perl-Users Digest is a retransmission of the USENET newsgroup
comp.lang.perl.misc.  For subscription or unsubscription requests, send
the single line:

	subscribe perl-users
or:
	unsubscribe perl-users

to almanac@ruby.oce.orst.edu.  

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 V9 Issue 90
************************************


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