[23895] in Perl-Users-Digest

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

Perl-Users Digest, Issue: 6097 Volume: 10

daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Mon Feb 9 09:05:45 2004

Date: Mon, 9 Feb 2004 06:05:07 -0800 (PST)
From: Perl-Users Digest <Perl-Users-Request@ruby.OCE.ORST.EDU>
To: Perl-Users@ruby.OCE.ORST.EDU (Perl-Users Digest)

Perl-Users Digest           Mon, 9 Feb 2004     Volume: 10 Number: 6097

Today's topics:
    Re: A Grep and a couple Awks <and a lot of Tassilo help <gnari@simnet.is>
    Re: A Grep and a couple Awks <and a lot of Tassilo help (Agrapha)
    Re: A Grep and a couple Awks <and a lot of Tassilo help (Agrapha)
    Re: A Grep and a couple Awks <and a lot of Tassilo help (Agrapha)
    Re: Array size <gnari@simnet.is>
        CGI.pm & multipart <chatiman@free.fr>
    Re: converting scalar to an array of elements <krahnj@acm.org>
        Does anybody know... (Ondra)
    Re: Does anybody know... <peter@semantico.com>
    Re: Does anybody know... <peter@semantico.com>
    Re: Does anybody know... <bernard.el-haginDODGE_THIS@lido-tech.net>
        glob in perl <andreas@andiboehm.de>
        IO::Socket::INET Problem (Hobbit HK)
    Re: need help with this little perl script <gnari@simnet.is>
    Re: need help with this little perl script <noreply@gunnar.cc>
        Pearl "Print Statement" Question (Information)
    Re: Pearl "Print Statement" Question <bernard.el-haginDODGE_THIS@lido-tech.net>
    Re: Perl project update <edgrsprj@ix.netcom.com>
    Re: problem with regex <Paul.Johnston@umist.ac.uk>
    Re: Req.for Advice: Learning Perl (Randal L. Schwartz)
        script working like daemon (murph)
        Shared variables along threads <jengelh@linux01.gwdg.de>
        Digest Administrivia (Last modified: 6 Apr 01) (Perl-Users-Digest Admin)

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

Date: Mon, 9 Feb 2004 08:49:45 -0000
From: "gnari" <gnari@simnet.is>
Subject: Re: A Grep and a couple Awks <and a lot of Tassilo help>
Message-Id: <c07hhg$un4$1@news.simnet.is>

"Joe Smith" <Joe.Smith@inwap.com> wrote in message
news:rNGVb.209351$nt4.987931@attbi_s51...
>
> unix% perldoc perl # Unix (Linux) command line

and if perldoc is not installed, usually
  man perl
  man perlfunc
  etc ...

>
> C:\>perldoc perl # MS-DOS command window
>
> Start -> Programs -> ActiveState ActivePerl 5.8 -> Documentation
>
> http://www.perldoc.com/perl5.8.0/bin/perldoc.html


gnari





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

Date: 9 Feb 2004 01:33:00 -0800
From: brian@box201.com (Agrapha)
Subject: Re: A Grep and a couple Awks <and a lot of Tassilo help>
Message-Id: <11aabb15.0402090133.51eaa98d@posting.google.com>

"Tassilo v. Parseval" <tassilo.parseval@rwth-aachen.de> wrote in message news:<bvkubd$7ko$1@nets3.rz.RWTH-Aachen.DE>...
> > my @selected=`zgrep $ARGV[0]
> > ./radiuslog/$ARGV[1]/server.$ARGV[2].Detail.$ARGV[1].gz`;
> > my @badcalls= grep /,0 /, @selected;
> 
> Maybe a pipe-open is more appropriate here:
> 
>     open ZGREP, "|", "zgrep $ARGV[0] ./radiuslog/..."
>         or die "Could not spawn zgrep: $!";
>     my (@badcalls, $total);
>     while (<ZGREP>) {
>         $total++;
>         push @badcalls, $_ if /,0 /;
>     }
>     close ZGREP;
> 
> This needs less memory and gets rid of @selected altogether. 
> 

I think this section is giving me a hard time. 
 open ZGREP, "|", "zgrep $ARGV[0] ./radiuslog/..." gives me an error.
specifically "Unknown open() mode '|' at ./triag.pl line 54."
if I change the line to 
open ZGREP, "| zgrep $ARGV[0] ./radiuslog/..." then it works but sends
all the data to the screen and doesn't push into a variable or count
$total


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

Date: 9 Feb 2004 02:02:58 -0800
From: brian@box201.com (Agrapha)
Subject: Re: A Grep and a couple Awks <and a lot of Tassilo help>
Message-Id: <11aabb15.0402090202.4a9e9260@posting.google.com>

Uri Guttman <uri@stemsystems.com> wrote in message news:<x7wu6wiurd.fsf@mail.sysarch.com>...
> >>>>> "A" == Agrapha  <brian@box201.com> writes:
> 
>   A> whew, ok Uri you just went over my head. This whole section is very
>   A> difficult for me to understand. Where can I find some good information
>   A> on how to understand a hash of hashes. ?
> 
> perldoc perlreftut
> perldoc perllol
> perldoc perldsc
> 
NICE! I read all the posts helping me use and get around perldoc.
Thats a vital piece of info I didn't know. Thank you all.


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

Date: 9 Feb 2004 02:34:04 -0800
From: brian@box201.com (Agrapha)
Subject: Re: A Grep and a couple Awks <and a lot of Tassilo help>
Message-Id: <11aabb15.0402090234.5faa30a2@posting.google.com>

"Tassilo v. Parseval" <tassilo.parseval@rwth-aachen.de> wrote in message news:<bvkubd$7ko$1@nets3.rz.RWTH-Aachen.DE>...
> Also sprach Agrapha:
> > my @selected=`zgrep $ARGV[0]
> > ./radiuslog/$ARGV[1]/server.$ARGV[2].Detail.$ARGV[1].gz`;
> > my @badcalls= grep /,0 /, @selected;
> 
> Maybe a pipe-open is more appropriate here:
> 
>     open ZGREP, "|", "zgrep $ARGV[0] ./radiuslog/..."
>         or die "Could not spawn zgrep: $!";
>     my (@badcalls, $total);
>     while (<ZGREP>) {
>         $total++;
>         push @badcalls, $_ if /,0 /;
>     }
>     close ZGREP;
> 
> This needs less memory and gets rid of @selected altogether. 

my epitaph will be "he persevered" the "perldoc -f open" helped me
here. The pipe was giving me an error. I changed just 1 thing...no
doubt left for me to dig a little as well. The open I think should
look like -| opening inbound to us.

 open ZGREP, '-|', "zgrep $ARGV[0] ./radiuslog/..."  

and quick!!! I thought it was broke it went so quick. 8, 5meg files in
about 3 to 5 seconds. thats brilliant. Let me clean this script up a
bit and I'll post a better copy. I need to incorporate a few ideas yet
from Uri and a couple others.


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

Date: Mon, 9 Feb 2004 07:36:45 -0000
From: "gnari" <gnari@simnet.is>
Subject: Re: Array size
Message-Id: <c07d8l$u97$1@news.simnet.is>

"David Dyer-Bennet" <dd-b@dd-b.net> wrote in message
news:m2vfmgd7y8.fsf@gw.dd-b.net...
> I know $#foo is the max subscript of @foo.
>
> What's the max subscript of $f = [5, 4, 5, 4, 9]?  (Yeah, I know, it's
> 4).
>
> That is, if I have an array ref, how do I get the max subscript of
> that array, without copying the whole thing to a temporary array?

did you try $#$f ?

gnari






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

Date: Mon, 9 Feb 2004 10:55:05 +0100
From: "chatiman" <chatiman@free.fr>
Subject: CGI.pm & multipart
Message-Id: <402758f7$0$28746$626a14ce@news.free.fr>

CGI.pm stops at initialisation with the error:
Malformed multipart POST: data truncated

I'm using CGI.pm V 3.01

What's wrong ?




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

Date: Mon, 09 Feb 2004 12:03:42 GMT
From: "John W. Krahn" <krahnj@acm.org>
Subject: Re: converting scalar to an array of elements
Message-Id: <40277717.7E28A226@acm.org>

"David H. Adler" wrote:
> 
> In article <40257AAB.4FBEC5FA@acm.org>, John W. Krahn wrote:
> > Chuckb wrote:
> >>
> >> I should know this but, what is the quickest way to convert a scalar value
> >> into an array?
> >> Ex: $name="Fred";
> >>     so that
> >> $arrayname[0]="F";
> >> $arrayname[1]="r";
> >> $arrayname[2]="e";
> >> $arrayname[3]="d";
> >
> > I don't know which is the quickest, you'll have to use Benchmark for that.
> 
> [snip various methods]
> 
> While we're having fun, how about...
> 
> unshift @arrayname, chop $string_containing_Fred while $string_containing_Fred;
> 
> ...although I have a feeling that may not scale well.

You are going to be a character short in @arrayname if the first
character in $string_containing_Fred is '0'.  :-)


John
-- 
use Perl;
program
fulfillment


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

Date: 9 Feb 2004 03:36:09 -0800
From: neufingero@quick.cz (Ondra)
Subject: Does anybody know...
Message-Id: <9dd8be90.0402090336.a0bf722@posting.google.com>

Hello,
  does anybody know what is this:
  
  my $tag
  $line =~ /<(\S+)[^>]*?>/;
    $tag = $1 || "";  /*****exactly this***/


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

Date: Mon, 09 Feb 2004 11:45:45 +0000
From: Peter Hickman <peter@semantico.com>
Subject: Re: Does anybody know...
Message-Id: <402772e9$0$29816$afc38c87@news.easynet.co.uk>

Ondra wrote:
> Hello,
>   does anybody know what is this:
>   
>   my $tag
>   $line =~ /<(\S+)[^>]*?>/;
>     $tag = $1 || "";  /*****exactly this***/

Looks like a regex to match htlp tags and extract the body of the tag.


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

Date: Mon, 09 Feb 2004 11:48:47 +0000
From: Peter Hickman <peter@semantico.com>
Subject: Re: Does anybody know...
Message-Id: <4027739f$0$29816$afc38c87@news.easynet.co.uk>

Peter Hickman wrote:

> Ondra wrote:
> 
>> Hello,
>>   does anybody know what is this:
>>     my $tag
>>   $line =~ /<(\S+)[^>]*?>/;
>>     $tag = $1 || "";  /*****exactly this***/
> 
> 
> Looks like a regex to match htlp tags and extract the body of the tag.

Or even HTML! My fingers are cold this morning


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

Date: Mon, 9 Feb 2004 12:55:42 +0100
From: Bernard El-Hagin <bernard.el-haginDODGE_THIS@lido-tech.net>
Subject: Re: Does anybody know...
Message-Id: <slrnc2et42.jh.bernard.el-haginDODGE_THIS@gdndev25.lido-tech>

On 2004-02-09, Peter Hickman <peter@semantico.com> wrote:
> Ondra wrote:
>> Hello,
>>   does anybody know what is this:
>>   
>>   my $tag
>>   $line =~ /<(\S+)[^>]*?>/;
>>     $tag = $1 || "";  /*****exactly this***/
>
> Looks like a regex to match htlp tags and extract the body of the tag.


That doesn't answer the OP's question.


  $tag = $1 || "";


means "set $tag to the value of $1 if the value of $1 is true, otherwise
set $tag to the empty string".


-- 
Cheers,
Bernard


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

Date: Mon, 09 Feb 2004 15:02:59 +0100
From: Andreas Boehm <andreas@andiboehm.de>
Subject: glob in perl
Message-Id: <c083uj$13o9jq$1@uni-berlin.de>

Hello,

I found the following behavior of perls built-in glob, but do not know 
if this is correct.
in debug and in normal mode globbing does the folling thing:

  DB<1> @a=glob("/home/sunny/share/User/Joerg/rho- SAX tryp/*");
  DB<3> x @a
0  '/home/sunny/share/User/Joerg/rho-'
1  'SAX'
  DB<4>

Is this correct?

And does there exist a solution that correctly globs folders containing 
spaces in their names?

viele Gruesse
Andreas



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

Date: 9 Feb 2004 05:47:44 -0800
From: hobbit_hk@hotmail.com (Hobbit HK)
Subject: IO::Socket::INET Problem
Message-Id: <22ee5d47.0402090547.1f8299e0@posting.google.com>

I'm using WinXP (although I also have RH Linux and there's no
difference) and I want to write a script which uses sockets... Now, my
main problem is when there's  nothing else to read from the socket...
That's where my script stucks... My guess is that because it keeps on
waiting for something (it can still get data)... Is there some way to
bypass this?
Will Blocking=>0 in IO::Socket::INET's new() help?

BTW
I'm using $line=<$sock> to read from the socket.


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

Date: Mon, 9 Feb 2004 08:45:27 -0000
From: "gnari" <gnari@simnet.is>
Subject: Re: need help with this little perl script
Message-Id: <c07h9f$umf$1@news.simnet.is>

"Danny" <dannywork5@hotmail.com> wrote in message
news:5NGVb.51406$WY4.13092252@news4.srv.hcvlny.cv.net...
> this originally used the FLY executable to generate a graphical counter
> which used to be ok but my server disabled the executiuon of binaries, so
> now I just want the script to do what it does (update the counter.txt) and
> not do any FLY stuff.  I just need something returned to the calling
 .html,
> I guess a blank graphic would do.  But how do you do the below, so the
html
> will call the counter script and have something returned.
> This part of the script doesnt work
>
> # $output = `$flyprog -i $fly_temp`;
> #$output = `blank.gif`';
> print "Content-type: image/gif\n\n";
> print "<img src=\"images\/blank.jpg\">";

this is not a HTML newsgroup but i can tell you that images do not contain
HTML tags

>
> original code was:
> $output = `$flyprog -i $fly_temp`;

just replace this line with some code that reads the blank
graphic into $output. if any graphics libraries like Image::Magick
are installed, you could generate your own image here.

> print "Content-type: image/gif\n\n";
> print "$output";







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

Date: Mon, 09 Feb 2004 10:59:40 +0100
From: Gunnar Hjalmarsson <noreply@gunnar.cc>
Subject: Re: need help with this little perl script
Message-Id: <c07llu$13f9tu$1@ID-184292.news.uni-berlin.de>

Danny wrote:
> this originally used the FLY executable to generate a graphical
> counter which used to be ok but my server disabled the executiuon
> of binaries, so now I just want the script to do what it does
> (update the counter.txt) and not do any FLY stuff.  I just need
> something returned to the calling .html, I guess a blank graphic
> would do.  But how do you do the below, so the html will call the
> counter script and have something returned. This part of the script
> doesnt work
> 
> # $output = `$flyprog -i $fly_temp`;
> #$output = `blank.gif`';
> print "Content-type: image/gif\n\n";
> print "<img src=\"images\/blank.jpg\">";
> 
> original code was:
> $output = `$flyprog -i $fly_temp`;
> print "Content-type: image/gif\n\n";
> print "$output";

If what you want is running the script without displaying anything,
you don't need to bother with a blank image, but you can just do:

     print "Status: 204 No Content\n\n";

Or if you want to convert the script to a text based counter, you can do:

     print "Content-type: text/html\n\n";
     print $count;

(or whatever the name of the variable is that contains the hits).

HTH

-- 
Gunnar Hjalmarsson
Email: http://www.gunnar.cc/cgi-bin/contact.pl



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

Date: 9 Feb 2004 03:11:28 -0800
From: vpnavy@yahoo.com (Information)
Subject: Pearl "Print Statement" Question
Message-Id: <6652ec03.0402090311.6cc70881@posting.google.com>

I have a statement that displays on a response screen.

print "Your entry will be added...\n";

Is there a way of changing the "white" background to a particular
color from within the print statement?  I would love to be able to
display graphics, etc. above the text display.

I've search for "print" parameters but can't seem to find any.

Thanks for your time.


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

Date: Mon, 9 Feb 2004 12:25:18 +0100
From: Bernard El-Hagin <bernard.el-haginDODGE_THIS@lido-tech.net>
Subject: Re: Pearl "Print Statement" Question
Message-Id: <slrnc2erb2.jh.bernard.el-haginDODGE_THIS@gdndev25.lido-tech>

On 2004-02-09, Information <vpnavy@yahoo.com> wrote:
> I have a statement that displays on a response screen.
>
> print "Your entry will be added...\n";
>
> Is there a way of changing the "white" background to a particular
> color from within the print statement?  I would love to be able to
> display graphics, etc. above the text display.
>
> I've search for "print" parameters but can't seem to find any.


perldoc -q 'color'


-- 
Cheers,
Bernard


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

Date: Mon, 09 Feb 2004 13:23:12 GMT
From: "edgrsprj" <edgrsprj@ix.netcom.com>
Subject: Re: Perl project update
Message-Id: <4RLVb.17416$jH6.7004@newsread1.news.atl.earthlink.net>

"Keith Keller" <kkeller-usenet@wombat.san-francisco.ca.us> wrote in message
news:7d960c.k0d.ln@goaway.wombat.san-francisco.ca.us...

> On 2004-02-08, edgrsprj <edgrsprj@ix.netcom.com> wrote:
> > For example, if a Windows Notepad text file window was being displayed
>> the program would need to be able to read information from and write
>> information to that screen.
>
> That's amazingly silly.  Why Notepad?  Why not just take a filename as
> input and output to another file and/or STDOUT?  Something like
>


The following is one of the most important reasons for developing this
technology.  And I am afraid that if you are not constantly involved with
this type of work you really won't understand and appreciate its
significance.  These are personal opinions.

With a good percentage of the projects that I work on either as a
professional or on my own, a mistaken number generated through calculations
or moved from one location to another can in my opinion have fatal
consequences, at times for sizeable numbers of people.  And since a certain
amount of this work involves some of the most advanced research being done
anywhere I often have no backup.  There are no other people who can check
the work in the time which is available.  On occasion that time period may
be and actually has been just a few hours.

For example, on January 26, 2001 (UTC) I concluded that my earthquake
precursor data were indicating that a destructive earthquake could be about
to occur somewhere.  And I began discussing them with my international
contacts.  After only about 5 hours a tremendously powerful earthquake in
India claimed something like 10,000 lives.  In that case there was not
enough time for me to even circulate my data to the necessary groups around
the world much less time to have anyone check them.

When you deal with large amounts of technical data, especially seeming
endless list of numbers it is virtually impossible to do numerous
calculations by hand or to copy numbers manually from one place to another
without making an error.

One of the most important reasons for developing this technology is the fact
that it makes it possible to have a computer program perform routine number
generation and transfer operations.  And now that I have that computer
interface developed, if I have a report which contains a list of numbers in
the middle of a report and I want to perform some calculation on them and
store them in another column to the right of the first one I can write a
simple Perl program which will read the number in the first column and print
the new number in the second column.  That is just one example.

It is true that spreadsheet programs and some word processing programs can
be used to do things like that.  But this approach is easier and faster.
And I feel that in many cases it produces better results.  For example, you
can watch as the numbers are generated and make immediate changes if that is
necessary.  When you do file to file transfers that might not be possible.

As I said, unless you have applications such as that one which are important
to you then you will probably not appreciate how valuable this type of
technology can be.





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

Date: Mon, 09 Feb 2004 11:06:46 +0000
From: Paul Johnston <Paul.Johnston@umist.ac.uk>
Subject: Re: problem with regex
Message-Id: <b2qe20h5t32qe5b6167cnng2mrdootdpeq@4ax.com>

On Fri, 6 Feb 2004 15:45:44 +0000 (UTC), Ben Morrow
<usenet@morrow.me.uk> wrote:

>
>Paul Lall <ittyspam@yahoo.com> wrote:
>> On Fri, 6 Feb 2004, Paul Johnston wrote:
>> 
>> > I have a file encoded using unicode (utf-8) on a Redhat 9 system and
>> > using Perl 5.8.0
>> > It contains mixed estonian and English like below:
>> >
>> > <ee> Kaks vana sõpra </ee>
>> > <en> Two old friends </en>
>> > <ee> Tere Piret ! </ee>
>> > <en> Hello Piret ! </en>
>> > <ee> Tere Tõnu ! </ee>
>> > <en> Hello Tõnu ! </en>
>> >
>> > I need to do some processing but the expression
>> > (/õ/) will not match with the õ in any line
>> > The perl script and the file I wish to process were both created using
>> > the same editor (kedit) so I assume they are encoding using the same
>> > scheme.
>> > Any ideas why I cannot for example extract all lines which contain
>> > this symbol "õ"
>> 
>> 
>> Without having seen your code, my guess would be that your locale is not
>> correctly set up.  See perldoc perllocale and perldoc locale
>
>NO! Don't mix locales and unicode with 5.8. It doesn't work.
>
>If you wish to use utf8 literals in your source, you have to 'use
>utf8;' at the top.
>
>Ben

Just as a follow up I have discover the script works i.e matches õ on
Solaris 5.8 Perl version 5.005 
However adding 
use utf8; to the script on the Redhat machine also works so my
problems have been solved (for now  at least :-)  )
Many thanks
Paul


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

Date: Mon, 09 Feb 2004 13:25:52 GMT
From: merlyn@stonehenge.com (Randal L. Schwartz)
Subject: Re: Req.for Advice: Learning Perl
Message-Id: <502e7fe54a485b7a9b9c8b9ddfeb5d1b@news.teranews.com>

>>>>> "darren" == darren uk <none@hotmail.com> writes:

darren> I own "Learning Perl" but find that I personally am better at looking at
darren> simple (and not so simple) examples, and probably moving onto more complex
darren> examples.

If you want lots and lots of examples (188 at last count),
check out my columns at

        http://www.stonehenge.com/merlyn/WebTechniques/
        http://www.stonehenge.com/merlyn/LinuxMag/
        http://www.stonehenge.com/merlyn/UnixReview/
        http://www.stonehenge.com/merlyn/PerlJournal/

The knowledge level varies.... the UnixReview series is probably the
easiest sequence because I don't have as much space to say things
there.

print "Just another guy who has had his name in print over 20 million times",

-- 
Randal L. Schwartz - Stonehenge Consulting Services, Inc. - +1 503 777 0095
<merlyn@stonehenge.com> <URL:http://www.stonehenge.com/merlyn/>
Perl/Unix/security consulting, Technical writing, Comedy, etc. etc.
See PerlTraining.Stonehenge.com for onsite and open-enrollment Perl training!


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

Date: 9 Feb 2004 04:52:21 -0800
From: vangelob@in.tum.de (murph)
Subject: script working like daemon
Message-Id: <240dc32a.0402090452.36921da5@posting.google.com>

Hi ,
i should write a script which sends a mail whenever a new user is
trying to login to the system(linux) as a root. As much as i know that
script should work like daemon(i think that i can write it ) , but i
don't know what exactly should the script do ?
How can i understand when someone try to login to the computer ?
Any ideas ?

thank you


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

Date: Mon, 9 Feb 2004 14:35:12 +0100
From: Jan Engelhardt <jengelh@linux01.gwdg.de>
Subject: Shared variables along threads
Message-Id: <Pine.LNX.4.53.0402091433560.19555@yvahk01.tjqt.qr>

Hi,


as in threads::shared(3pm) I read that one must use
  &share([]);
to make a new array available to all threads. How well does this
work with deeper arrays, i.e. does creating a new array using []
within an already-shared array make that one also shared?



Jan Engelhardt
--


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

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


Administrivia:

#The Perl-Users Digest is a retransmission of the USENET newsgroup
#comp.lang.perl.misc.  For subscription or unsubscription requests, send
#the single line:
#
#	subscribe perl-users
#or:
#	unsubscribe perl-users
#
#to almanac@ruby.oce.orst.edu.  

NOTE: due to the current flood of worm email banging on ruby, the smtp
server on ruby has been shut off until further notice. 

To submit articles to comp.lang.perl.announce, send your article to
clpa@perl.com.

#To request back copies (available for a week or so), send your request
#to almanac@ruby.oce.orst.edu with the command "send perl-users x.y",
#where x is the volume number and y is the issue number.

#For other requests pertaining to the digest, send mail to
#perl-users-request@ruby.oce.orst.edu. Do not waste your time or mine
#sending perl questions to the -request address, I don't have time to
#answer them even if I did know the answer.


------------------------------
End of Perl-Users Digest V10 Issue 6097
***************************************


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