[18246] in Perl-Users-Digest

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

Perl-Users Digest, Issue: 414 Volume: 10

daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Sun Mar 4 18:05:55 2001

Date: Sun, 4 Mar 2001 15:05:13 -0800 (PST)
From: Perl-Users Digest <Perl-Users-Request@ruby.OCE.ORST.EDU>
To: Perl-Users@ruby.OCE.ORST.EDU (Perl-Users Digest)
Message-Id: <983747113-v10-i414@ruby.oce.orst.edu>
Content-Type: text

Perl-Users Digest           Sun, 4 Mar 2001     Volume: 10 Number: 414

Today's topics:
    Re: a beginner i perl- suiciadal <aks_music@hotmail.com>
        Commenting problems <debbie.knight@ntlworld.com>
    Re: Commenting problems <aks_music@hotmail.com>
    Re: Display Delay in Perl? <pne-news-20010304@newton.digitalspace.net>
        Finally, It works. Thank you for your patience. I reall <kalle@tvettsvamp.a.se>
    Re: Finally, It works. Thank you for your patience. I r (Gwyn Judd)
    Re: gif problems!!! <gellyfish@gellyfish.com>
    Re: handling arrows keys <Ardok.f@voila.fr>
        how do you find shortest strings in an array of strings <todd_thal@hotmail.com>
    Re: how do you find shortest strings in an array of str <godzilla@stomp.stomp.tokyo>
    Re: how do you find shortest strings in an array of str <cdh@ala.net>
        How to stop executing (BUCK NAKED1)
    Re: How to stop executing (Gwyn Judd)
    Re: How to stop executing (Tad McClellan)
    Re: Is Perl right for me? <gellyfish@gellyfish.com>
    Re: Is Perl right for me? (Ben Okopnik)
    Re: Is Perl right for me? (Tad McClellan)
    Re: length op <eg344@nyu.edu>
    Re: length op (Tassilo von Parseval)
        Magic Marker <Anonymous_Account>" <remailer@anon.xg.nu>
    Re: Perl, Perl, Perl, don't give your love to URL <parrot0123@yahoo.ca>
        perl-ize and optimize <brondsema@my-deja.com>
    Re: perl-ize and optimize (Gwyn Judd)
    Re: retrieving ip adress <parrot0123@yahoo.ca>
    Re: shell environement variables (BUCK NAKED1)
        sockets again <tfiedler@zen.moldsandwich.com>
    Re: sockets again <carvdawg@patriot.net>
        sorting & matching problem (Monte)
    Re: truncate <s0218327@unix1.cc.ysu.edu>
        unlink problems <Ken.Brown@DIALWRAP.COM>
    Re: Uploading a file (Garry Williams)
    Re: Uploading a file <bart.lateur@skynet.be>
    Re: Uploading a file <flavell@mail.cern.ch>
        Digest Administrivia (Last modified: 16 Sep 99) (Perl-Users-Digest Admin)

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

Date: Sun, 04 Mar 2001 21:53:04 GMT
From: =?iso-8859-1?Q?=D0=2DVolta?= <aks_music@hotmail.com>
Subject: Re: a beginner i perl- suiciadal
Message-Id: <3AA2B8EE.3EA4D1D1@hotmail.com>

Hi Nina:

Here's what I came up with ...
I think this meets the objectives you asked about.  Hope it helps.

#!/usr/local/bin/perl -w
# Ð-Volta PCP'd - aks_music@hotmail.com

use strict;           # a good idea
my %directory;  #declare hash
my $indent  = sub { print "*" x 25 }; # anonymous sub to print a line of 25 *'s

print "\nType the word 'none' or hit the 'Enter' key on your keyboard to
exit.\n\n";
&$indent;print " Please enter a name: ";

while(<>) {
   my $name = $_;
   unless ($name =~ /none|^\s$/) {
      print "Please enter a number: ";
      my $number = <STDIN>;
      redo if ($number =~ m/^\s+$/);   # if the input is empty, ask for the
number again
      $directory{$name} = $number;   #define hash with the input
      &$indent;
      print " Please enter a name: ";
   }
   else {
      &$indent;
      print " Please enter the name of the person whose number you require: ";
      while(<>) {
         my $name = $_;
         exit if ($name =~ /none|^\s$/);
         if (exists($directory{$name})) { print "\nThe number for $name is:
$directory{$name}\n\n" } # if the input matches the hash key then ok
         else { print "\nThe number for $name does not exist in the db\n\n" }
         &$indent;print " Please enter a name: ";last;
        }
     }
}

"nina.ahlberg" wrote:

> Hello! I'm just sttarting to learn how to program in perl...
> and already got stuck. I'm suppose to do a telephone directory, where the
> user is simply inputting names and telephonenumbers until the name is null
> or the word "none" is used for the name, after this the system should ask
> for a name whoes telephonenumber is required and display the correct number
> in case of a match or an error message. if the word "none" is typed or null
> is given the program should terminate. SIMPLE!
> but having problems..... my initial attempts...:
> #!/usr/local/bin/perl
>
> while()
> {
>         print "please enter a name:";
>         chomp ($name=<STDIN>);
>
> if ($name ne "none")
> {
>         print "please enter a number:";
>         chomp ($number =<STDIN>);
>         $directory{name}='$number';
> }
> else
> {
>         print "please enter the name of the person, whoes number you
> require:";
>         chomp ($name=<STDIN>);
>   print "the number of $name is $directory{'name'}";
> }
> }
>
> SIGH!!!!! does not work, if somebody can help me i'm very grateful....
> Nina



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

Date: Sun, 4 Mar 2001 20:11:43 -0000
From: "deborah.knight1" <debbie.knight@ntlworld.com>
Subject: Commenting problems
Message-Id: <Qlxo6.9219$mt.1383445@news2-win.server.ntlworld.com>

Hello,

I've edited a cgi scrpit using notepad, wordpad and ultraedit, using both
the # and /*..*/ for comments but none work, with the comments showing up in
both netscape and IE from home and my server.

This is the code:

#!/usr/local/bin/perl

/*comment see if it works*/
#this perhaps

print "content-type:text/html\n\n";

<HTML><HEAD><TITLE>Hiya there</TITLE></HEAD>
<BODY><H1>Web page</H1></BODY></HTML>


thanks in advance

Debbie




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

Date: Sun, 04 Mar 2001 23:03:59 GMT
From: =?iso-8859-1?Q?=D0=2DVolta?= <aks_music@hotmail.com>
Subject: Re: Commenting problems
Message-Id: <3AA2C98D.49CAFD0B@hotmail.com>

Hi deborah:

When I eval the statement: /*comment see if it works*/
I reveive the following run-time error messge:
/*comment see if it works*/: ?+*{} follows nothing in regexp at (eval 1) line 1.

The defined comment character in perl is the pound sign #

for sections I use:

=finger
any
comments I'd like
=cut

You can also put
__END__
after any required code for your program.  Anything placed below __END__ will
not affect your program.

Your code below will not work regardless.

You need to quote your html structure.
print qq~
<HTML><HEAD><TITLE>Hiya there</TITLE></HEAD>
<BODY><H1>Web page</H1></BODY></HTML>~;



Ð-Volta
I use PCP daily.


"deborah.knight1" wrote:

> Hello,
>
> I've edited a cgi scrpit using notepad, wordpad and ultraedit, using both
> the # and /*..*/ for comments but none work, with the comments showing up in
> both netscape and IE from home and my server.
>
> This is the code:
>
> #!/usr/local/bin/perl
>
> /*comment see if it works*/
> #this perhaps
>
> print "content-type:text/html\n\n";
>
> <HTML><HEAD><TITLE>Hiya there</TITLE></HEAD>
> <BODY><H1>Web page</H1></BODY></HTML>
>
> thanks in advance
>
> Debbie



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

Date: Sun, 04 Mar 2001 20:11:54 +0100
From: Philip Newton <pne-news-20010304@newton.digitalspace.net>
Subject: Re: Display Delay in Perl?
Message-Id: <ka45at89hsk7qum0is3430vhl878o8ju0f@4ax.com>

On 2 Mar 2001 15:17:10 GMT, anno4000@lublin.zrz.tu-berlin.de (Anno Siegel)
wrote:

> Ah... that's it.   $overridable{ $name} = defined prototype "CORE::$name";

ISTR reading (in p5p?) that this equality didn't hold for all functions -- that
there was at least one function that had a prototype but was not overridable
because it was deemed "too confusing to do so". I don't have the reference,
though.

Hm, I thought it was something like pop or push. In 5.005_03, they have an
undefined prototype, but in 5.7.0@8530, all of pop, push, and splice have a
prototype -- and they all return negative keys in toke.c.

Does anyone know what I'm talking about?

Cheers,
Philip
-- 
Philip Newton <nospam.newton@gmx.li>
That really is my address; no need to remove anything to reply.
If you're not part of the solution, you're part of the precipitate.


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

Date: Sun, 04 Mar 2001 19:50:33 GMT
From: "Kalle Anka" <kalle@tvettsvamp.a.se>
Subject: Finally, It works. Thank you for your patience. I really mean that. 
Message-Id: <d0xo6.21610$AH6.3034194@newsc.telia.net>

Is it possible to set the script to only remove the exact letters! If
someone want to unsubscribe .com, every address who ends with .com deletes.
I tryed to run it i Perl builder 2.0, but could not fint out how. Its no
problem if I "use strict;" in Perlbuilder, but on the web it doesnt work



#!/usr/bin/perl -w

use CGI qw(:standard);

$filename = "/home/tvett/www/mail.htm";
$backupfile = "/home/tvettwww/backup.htm";

$q = CGI->new();
$email = $q->param( "email" );

print $q->header();
print $q->start_html('Resultat av kommando');
print $q->h1('Resultat av kommando');
print(&cleanup); # Kjør sub og skriv returnert verdi.
print $q->end_html();

sub cleanup {
    open INFILE, $filename
or return "Couldn't open file for reading";

    @infile = <INFILE>;

    close INFILE;

    open BACKUP, ">$backupfile"
or return "Couldn't make backup of original file";

    if (@infile) { # Sjekk om den er tom
for $line (@infile) {
    print BACKUP $line;
}
    }

    open OUTFILE, ">$filename"
or return "Couldn't open file for writing";

for $line (@infile) {
 print OUTFILE $line unless ($line =~/$email/);
}

    close OUTFILE;

    return "The address has been removed";
}




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

Date: Sun, 04 Mar 2001 22:07:51 GMT
From: tjla@guvfybir.qlaqaf.bet (Gwyn Judd)
Subject: Re: Finally, It works. Thank you for your patience. I really mean that. 
Message-Id: <slrn9a5f5n.lei.tjla@thislove.dyndns.org>

I was shocked! How could Kalle Anka <kalle@tvettsvamp.a.se>
say such a terrible thing:
>Is it possible to set the script to only remove the exact letters! If

> print OUTFILE $line unless ($line =~/$email/);

Change this line to:

  print OUTFILE $line unless ($line =~/^$email$/);

-- 
Gwyn Judd (print `echo 'tjla@guvfybir.qlaqaf.bet' | rot13`)
The best way to predict the future is to invent it.

		-- Alan Kay


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

Date: 4 Mar 2001 19:16:13 -0000
From: Jonathan Stowe <gellyfish@gellyfish.com>
Subject: Re: gif problems!!!
Message-Id: <97u49t$q7e$1@orpheus.gellyfish.com>

On Sat, 3 Mar 2001 14:58:08 +0100 ToDa wrote:
> Why doesn't my gif-images shows? It works when I run the code as html
> document but not as perl code.
> 
> print <<"HTML";
> 
> <body bgcolor="#FFFFFF">
> <img src="img/hr.gif" width="500" height="3">
> </body>
> 

The SRC attribute is relative to the location of the (page|script) that
contains it - you will almost certainly want to use an absolute path
unless img is a subdirectory of the directory where your CGI program
resides.

/J\
-- 
Jonathan Stowe                      |     
<http://www.gellyfish.com>          |      This space for rent
                                    |


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

Date: Sun, 04 Mar 2001 21:26:35 +0100
From: "Ardok" <Ardok.f@voila.fr>
Subject: Re: handling arrows keys
Message-Id: <97u9et$pm9$1@reader1.fr.uu.net>

Dans l'article <slrn9a301u.300.mgjv@martien.heliotrope.home>, "Martien
Verbruggen" <mgjv@tradingpost.com.au> a écrit :
 
> Are you trying to write a pger, like more or less?

It's a little that. 
For the moment, I am trying to write a kind of "mail
viewer" (in order to read my archives)
which may  become a mail customer. So, I need  to divide the mails
(and the previews) in several screens and to  pass from a screen to
another one. 
 
> The Term::ReadKey module can probably help here. If you also use the
> Term::Size module, you may not even need to hardcode screen sizes. ave a
> look at the various Term::* modules on CPAN

Thanks for your answer ! 
I have installed the Term::ReadKey module. 
Now I can  use the  "character" keys, without  users need
to hit enter, but I don't know how to do the same with the
arrows (which would be more pratical).


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

Date: Sun, 4 Mar 2001 11:06:43 -0800
From: "Todd Thal" <todd_thal@hotmail.com>
Subject: how do you find shortest strings in an array of strings??
Message-Id: <3aa29142@news2.mibx.net>

Dear all:

I was given code to find the shortest strings in an array of strings

(names/email addresses)...but can't seem to get it to work...what wrong?

is there a better way??

# process the lines, one at a time.
my $short_name_length = 1000;
my $shortest_name = "";
foreach $name ( @name_list )
{
   if ( length( $name ) < $short_name_length )
   {
      $short_name_length = length( $name );
      $shortest_name = $name;
   }
} # foreach

thanks,

t.




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

Date: Sun, 04 Mar 2001 12:04:15 -0800
From: "Godzilla!" <godzilla@stomp.stomp.tokyo>
Subject: Re: how do you find shortest strings in an array of strings??
Message-Id: <3AA29FBF.9B14079A@stomp.stomp.tokyo>

Todd Thal wrote:

> I was given code to find the shortest strings in an array of strings
 
> (names/email addresses)...

You have failed to indicate how email addresses
are related to your task.


> but can't seem to get it to work...what wrong?

Who knows? You have failed to indicate what is
your error.


> is there a better way??

There are different ways. Better, in this case,
is a matter of personal opinion. A test script
is below my signature.

 
> # process the lines, one at a time.

(snipped remaining code)

You are not processing lines of a file.
You are processing elements of an array.
Your code methodology will fail when you
have two or more elements of the same length.


Godzilla!
--

TEST SCRIPT:
____________

#!perl

print "Content-type: text/plain\n\n";

@Array = qw (eleven ten nine eight seven six five four three two one);

@Array = sort { length ($a) <=> length ($b) } @Array;

foreach $element (@Array)
 {
  if (length ($element) == length ($Array[0]))
   { print "$element\n"; }
 }

exit;


PRINTED RESULTS:
________________

one
ten
six
two


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

Date: Sun, 04 Mar 2001 15:36:57 -0600
From: cdh <cdh@ala.net>
Subject: Re: how do you find shortest strings in an array of strings??
Message-Id: <3AA2B579.2B8A029B@ala.net>

Todd Thal wrote:

> I was given code to find the shortest strings in an array of strings
>
> (names/email addresses)...but can't seem to get it to work...what wrong?
>
> is there a better way??
>
> # process the lines, one at a time.
> my $short_name_length = 1000;
> my $shortest_name = "";
> foreach $name ( @name_list )
> {
>    if ( length( $name ) < $short_name_length )
>    {
>       $short_name_length = length( $name );
>       $shortest_name = $name;
>    }
> } # foreach

First, the above works just fine (unless your shortest string is longer than 1000 characters).
The comment right above it is disturbing though... "#process the lines, one at a time"
doesn't describe the code below it, and perhaps some step was skipped. Have you made sure
you actually have the array @name_list populated?

Second, you stated you are looking for the "shortest strings", which to me implies a list (array)
of results, rather than a singular one. The code below will do that:

@name_list = sort { length($a) <=> length($b) } @name_list; #sort by length

If you intend to process the list in it's entirety from shortest to longest, you need only process
the results of the above in a "for" loop.
If you really need to seperate out a list of the shortest strings to process seperately you can do
the following:

$short_len = length(@name_list[0]);
push @short_list, shift @name_list while length($name_list[0]) == $short_len;

cheers,
Chris Hickman




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

Date: Sun, 4 Mar 2001 13:31:42 -0600 (CST)
From: dennis100@webtv.net (BUCK NAKED1)
Subject: How to stop executing
Message-Id: <11482-3AA2981E-277@storefull-246.iap.bryant.webtv.net>

I have some .txt files that are executing the .html within them on my
webhost. Is there a way to tell the server not to execute any .cgi
or.html files in a certain directory? I want them to print out as text,
regardless of the file extension.

I've been researching Apache for this, but can't figure it out. For
example, can this be done without being root? Does the Apache directive
go in an .htaccess file? Do you need a .htpasswd file too? What is the
syntax for all of this?

UserAuth Basic
addHandler ???... I'm lost!

Thanks,
--Dennis



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

Date: Sun, 04 Mar 2001 21:28:34 GMT
From: tjla@guvfybir.qlaqaf.bet (Gwyn Judd)
Subject: Re: How to stop executing
Message-Id: <slrn9a5cs2.lei.tjla@thislove.dyndns.org>

I was shocked! How could BUCK NAKED1 <dennis100@webtv.net>
say such a terrible thing:
>I have some .txt files that are executing the .html within them on my
>webhost. Is there a way to tell the server not to execute any .cgi
>or.html files in a certain directory? I want them to print out as text,
>regardless of the file extension.

Wrong newsgroup. Ask somewhere with "CGI" and "server" in the title.

-- 
Gwyn Judd (print `echo 'tjla@guvfybir.qlaqaf.bet' | rot13`)
"Hey, Vasquez! Have you ever been mistaken for a man ?"
"No. Have you ?"
	-- Hudson and Vasquez in "ALIENS"


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

Date: Sun, 4 Mar 2001 16:03:56 -0500
From: tadmc@augustmail.com (Tad McClellan)
Subject: Re: How to stop executing
Message-Id: <slrn9a5bds.1qe.tadmc@tadmc26.august.net>

BUCK NAKED1 <dennis100@webtv.net> wrote:

>I have some .txt files that are executing the .html within them on my
>webhost. 


I have no idea what that means.

You have "text files" that "execute"? Most folks do not call such
things "text files". "Executable files" is used for files that execute.


>Is there a way to tell the server not to execute any .cgi
                            ^^^^^^
>or.html files in a certain directory? 


Perl does not have one of those "server" things.

Sounds like you have not partitioned your problem correctly. Your
problem has nothing to do with Perl. It seems to be about web
server setup or something.


>I want them to print out as text,
>regardless of the file extension.


I do not see anything related to Perl in your article posted to
the Perl newsgroup.

Would the answer be different if your CGI programs were written
in Python, awk, shell...? (No, the answer would be the same).

So then, you do not have a language-specific question. This is
a language-specific newsgroup.


>addHandler ???... I'm lost!
                   ^^^^^^^^

Yes, that is apparent. You've wandered into the wrong newsgroup. 
CGI questions are best asked in a newsgroup that has something to 
do with CGI, such as:

      comp.infosystems.www.authoring.cgi
      comp.infosystems.www.servers.mac
      comp.infosystems.www.servers.misc
      comp.infosystems.www.servers.ms-windows
      comp.infosystems.www.servers.unix

Try asking over there.


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


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

Date: 4 Mar 2001 19:13:00 -0000
From: Jonathan Stowe <gellyfish@gellyfish.com>
Subject: Re: Is Perl right for me?
Message-Id: <97u43s$q5k$1@orpheus.gellyfish.com>

On Sun, 04 Mar 2001 13:19:21 GMT Bart Lateur wrote:
> Holly Bortfeld wrote:
> 
>>I can write HTML
>>from scratch without an editor.
> 
> Wow, that is strong. So how do you write HTML? Using a speech
> recognition system?
> 

   copy CON: somefile.html

or

   cp /dev/tty somefile.html

perhaps ?

/J\
-- 
Jonathan Stowe                      |     
<http://www.gellyfish.com>          |      This space for rent
                                    |


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

Date: 4 Mar 2001 20:11:17 GMT
From: ben-fuzzybear@geocities.com (Ben Okopnik)
Subject: Re: Is Perl right for me?
Message-Id: <slrn9a58es.h9v.ben-fuzzybear@Odin.Thor>

The ancient archives of Sun, 04 Mar 2001 13:19:21 GMT showed
Bart Lateur of comp.lang.perl.misc speaking thus:
>Holly Bortfeld wrote:
>
>>I can write HTML
>>from scratch without an editor.
>
>Wow, that is strong. So how do you write HTML? Using a speech
>recognition system?


cat << EOT > index.html
<html><head><title>Holly's Web Page</head><title>
<body>
This page is under construction.<br>
<img src="annoying.jpg">
</body></html>
EOT


HTH. HAND. :)


Ben Okopnik
-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-
"Habits - the only reason they persist is that they are offering some
satisfaction. You allow them to persist by not seeking any other, better
form of satisfying the same needs. Every habit, good or bad, is acquired
and learned in the same way - by finding that it is a means of
satisfaction." -- Juliene Berk 


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

Date: Sun, 4 Mar 2001 15:39:59 -0500
From: tadmc@augustmail.com (Tad McClellan)
Subject: Re: Is Perl right for me?
Message-Id: <slrn9a5a0v.1qe.tadmc@tadmc26.august.net>

Holly Bortfeld <maximom@mindspring.com> wrote:

>I have some more
>research to do, obviously, but can you tell me if there is a newsgroup or
>email-based group for newbies, since I have been emailed by a number of
>people telling me this was off-topic for this group.
                   ^^^^

What "this"?

Questions from Perl newbies are on-topic (if they have followed
standard netiquette of course).

Asking if Perl is the right language for you is on-topic.

Asking if Perl can do what you need done in on-topic.

Asking for help in writing Perl to get your job done is on-topic.

Asking for fully formed programs is off-topic. Use a search engine
for searching. Use a discussion group for discussing.

:-)


[ snip Jeopardy quoted text ]

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


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

Date: Sun, 4 Mar 2001 14:26:37 -0500
From: "Eduard Grinvald" <eg344@nyu.edu>
Subject: Re: length op
Message-Id: <2Dwo6.10$Dq1.246@typhoon.nyu.edu>

Hello, thank you for your replies!
Basically, I have to perform multiple manipulations with a set of strings
(roughly 15 million of them). The exact nature of manipulations is unknown
to my code, i just present the data in an organized fashion and execute
whatever was passed to my module, using my data as arguments.The
manipulations have to be done quickly and on the entire set, but they may
also involve different parts of the set. so i need to keep everything in
ram.
After preprocessing my data, i saw that 104megs of text, when parsed, where
taking up 700megs of ram due to the overhead. I need to know which parts of
my structure (a hash filled with arrays, pointers, scalars, etc) are so
costly, to see where i can sacrifice creature comfort for memory efficiency.

Thank You.

Eduard Grinvald
"Michael Carman" <mjcarman@home.com> wrote in message
news:3AA1A7D6.4C7CD2D3@home.com...
> Eduard Grinvald wrote:
> >
> > Am i correct in assuming that length, given a pointer, only returns
> > the size of the pointer in bytes, an not the actual object
> > referenced?
>
> Bob already answered this quite well, so I won't bother.
>
> > [I]s there any place on the web or is there a book that gives a
> > listing of what the sizes of different data types are (int,strings,
> > arrays, arrayrefs, etc).
>
> Perl has three basic data types: scalar, array, and hash. A scalar is
> any single value be it integer, float, character, string, reference,
> etc. An array is a (named) list of scalars. A hash is an associative
> array with strings for keys and scalars for values. There are no other
> data types (e.g. 'int') at the user level.
>
> Memory allocation is handled behind the scenes; you don't generally
> know, need to know, or care how big something is. A scalar/array/hash is
> as big as it needs to be to hold its data. There is some overhead, of
> course; arrays take more memory than scalars, hashes take more than
> arrays, but that's an implementation detail. As a programmer, you should
> be focused on what the right tool for the job is, not how much space it
> takes in your toolbox.
>
> If you were just asking out of curiousity then that's probably as much
> as you need to know to be a productive Perl programmer. If you're
> targeting a specific problem, then maybe you really do need to know
> more. Without knowing what you're trying to do, though, I can't tell
> which of a half-dozen different directions to send you in. Lest we give
> you bad advice and send you off on a wild goose chase, tell us what it
> is you're trying to do.
>
> -mjc




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

Date: Sun, 04 Mar 2001 21:55:04 GMT
From: Tassilo.Parseval@post.rwth-aachen.de (Tassilo von Parseval)
Subject: Re: length op
Message-Id: <3aa2b86d.15880623@news.rwth-aachen.de>

Hi,

On Sun, 4 Mar 2001 14:26:37 -0500, "Eduard Grinvald" <eg344@nyu.edu>
wrote:

>Hello, thank you for your replies!
>Basically, I have to perform multiple manipulations with a set of strings
>(roughly 15 million of them). The exact nature of manipulations is unknown
>to my code, i just present the data in an organized fashion and execute
>whatever was passed to my module, using my data as arguments.The
>manipulations have to be done quickly and on the entire set, but they may
>also involve different parts of the set. so i need to keep everything in
>ram.
>After preprocessing my data, i saw that 104megs of text, when parsed, where
>taking up 700megs of ram due to the overhead. I need to know which parts of
>my structure (a hash filled with arrays, pointers, scalars, etc) are so
>costly, to see where i can sacrifice creature comfort for memory efficiency.
>

You say you want to put aprox. 104 MB of textual data into hashes?
Well, putting it carefully, I doubt that this is a) a good idea and b)
possible at all. 
In this case you'll have to split up your data into small
portions....and don't try doing these things by holding the date in
your ram. Read them linewise from a file....or if you want to perform
stuff on sentences or anything covering more than a line then split
portions in the desired way and do any manipulation on small amount of
data. I think not even Perl is capable of handling 100 mb in hashes.

Greetings,
Tassilo



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

Date: Sun, 4 Mar 2001 15:50:56 -0600
From: "Public <Anonymous_Account>" <remailer@anon.xg.nu>
Subject: Magic Marker
Message-Id: <bea57531d5a384a6966757d41a34abdd@anon.xg.nu>

I magic marker like fumes huff to.  It cheap is and available trouble without. I high really get, and it my brain has to done nothing even though said the doctor I stop should.  Right now sharpies huff I the time most. Is better there a marker to get high even a?



---
This message did not originate from the Sender address above.
It was posted with the use of anonymizing software at 
http://anon.xg.nu
---




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

Date: Sun, 04 Mar 2001 20:37:21 GMT
From: "Parrot" <parrot0123@yahoo.ca>
Subject: Re: Perl, Perl, Perl, don't give your love to URL
Message-Id: <5Ixo6.365023$JT5.11815129@news20.bellglobal.com>

David Wall <darkon@one.net> wrote in message
news:90519AAC3darkononenet@206.112.192.118...
>
> The subject line is really all I had to say.  But I suppose it could be
> taken as a plea to not equate Perl with CGI programming.
>
It's true enough that Perl is used for more than just CGI programming -
however - Perl is a very popular language when it comes to CGI programming
and I think that must be acknowledged.




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

Date: Sun, 04 Mar 2001 21:09:25 GMT
From: "Dave Brondsema" <brondsema@my-deja.com>
Subject: perl-ize and optimize
Message-Id: <9ayo6.24724$W05.5498696@news1.rdc1.mi.home.com>

Below is a sub that takes a string and "rotates" it a random amount only
allowing the break to be at spaces.

Example:

This is an example sentence. => an example sentence. This is

My question is how can I optimize this and make it more perlish?

sub shuffle
{
    $_ = $_[0];

    # pick a random location
    my $rndloc = int rand length $_;

    # move $rndloc to a space
    my $tmp = substr($_, $rndloc, length($_) - $rndloc);
    $tmp =~ / /g;
    if (pos($tmp))
    {
        $rndloc = $rndloc + pos($tmp);
    }else{
        $rndloc = 0;
    }

    # rearrange
    $_ = substr($_, $rndloc, length($_) - $rndloc) ." ". substr($_, 0,
$rndloc);

    return $_;
}

Thanks,
Dave Brondsema




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

Date: Sun, 04 Mar 2001 21:33:14 GMT
From: tjla@guvfybir.qlaqaf.bet (Gwyn Judd)
Subject: Re: perl-ize and optimize
Message-Id: <slrn9a5d4q.lei.tjla@thislove.dyndns.org>

I was shocked! How could Dave Brondsema <brondsema@my-deja.com>
say such a terrible thing:
>Below is a sub that takes a string and "rotates" it a random amount only
>allowing the break to be at spaces.

Try this, first use split() to get an array with each word in the
string. Then use the method in the FAQ under 'perldoc -q shuffle' to
shuffle the array. Then join the array back together with spaces.

-- 
Gwyn Judd (print `echo 'tjla@guvfybir.qlaqaf.bet' | rot13`)
My life has a superb cast but I can't figure out the plot.
-Ashleigh Brilliant (contributed by Chris Johnston)


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

Date: Sun, 04 Mar 2001 19:16:20 GMT
From: "Parrot" <parrot0123@yahoo.ca>
Subject: Re: retrieving ip adress
Message-Id: <8wwo6.364429$JT5.11807296@news20.bellglobal.com>


Waarddebon <Waarddebon@chello.nl> wrote in message
news:GO2o6.1752434$%C1.22825266@Flipper...
> How can I retrieve the ip adress of a person ?
>

Environment variables, my friend - they can come in handy!  This is the one
that you need:

$ENV{REMOTE_ADDR}

Want more info?  Go to http://hoohoo.ncsa.uiuc.edu/cgi/env.html






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

Date: Sun, 4 Mar 2001 13:24:10 -0600 (CST)
From: dennis100@webtv.net (BUCK NAKED1)
Subject: Re: shell environement variables
Message-Id: <11485-3AA2965A-10@storefull-246.iap.bryant.webtv.net>

passme

Can't you also manipulate environmental variables by using an Apache
directive?

--Dennis



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

Date: Sun, 04 Mar 2001 21:11:36 GMT
From: Ted Fiedler <tfiedler@zen.moldsandwich.com>
Subject: sockets again
Message-Id: <Pine.LNX.4.21.0103041608460.29782-100000@zen.moldsandwich.com>

I am looking to provide two way communication with a port (80 or 23 or
both) anyway I want to use IO::Sockets - first is this the right tool? and
second - I know I need to have two processes a parent and a child and have
them communicate this way - how would I go about doing this? 
im not looking for someone to do this for me just mabey an example or a
pointer or two in the right direction.

thanks in advance

Ted



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

Date: Sun, 04 Mar 2001 16:38:51 -0500
From: H C <carvdawg@patriot.net>
Subject: Re: sockets again
Message-Id: <3AA2B5EB.A8E4ED3F@patriot.net>

> I am looking to provide two way communication with a port (80 or 23 or
> both) anyway I want to use IO::Sockets - first is this the right tool?

Sure.  It's one way.  It's particularly useful if you want to use sockets.

> and
> second - I know I need to have two processes a parent and a child and have
> them communicate this way - how would I go about doing this?

Why would you need that specifically?  You can have the client connect to the
server,
and then pass all communications back and forth using the socket handle that
you have.
That way, it's synchronized...the client "says" something to the server, then
the server
does some processing (maybe), and "says" something back.

> im not looking for someone to do this for me just mabey an example or a
> pointer or two in the right direction.

The examples online at O'Reilly for their Perl books are pretty good.



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

Date: Sun, 04 Mar 2001 20:44:26 GMT
From: montep@about.com (Monte)
Subject: sorting & matching problem
Message-Id: <3aa2a8b7.37391365@news.hal-pc.org>

Rather than post some code which does not work, I have several
variations. ;(  I think it best simply to describe the problem and see
if those more talented than I think it is solvable with perl or
whether I had best hie thee to the xbase dominions.  It can be done
even in old dBaseIII, but the ultimate useage I have for it points
strongly to a perl solution as being the most desirable.

Problem:
Given 6 distinct numeric data which describe an object.
Make a best fit search and sort through a database consisting of ~400
rows and eight columns (the extra columns contain the data that are
the ultimate object of the search). Database can be anything from text
to relational db or spreadsheet, it is not critical.

example:
input:  2.2 3 5 1.4 8 30.12

dbfile:
A Z 3   5.5  2 6. 1   7   31.20
C F 7   4.7  3.3  6.1 1   32.00
K D 5.1 2.1  1.3  5   5.2 30.91
etc 
The object is to find the row which best fits all of the input
criteria.

I have approached this one way by filtering out all columns larger
than each input column.  This yields a partial, but not optimal.
Usually winding up with one column optimized and others further
removed. And several variations on that theme.  It's those additional
variations which are taxing my limited perl talents.

Any clues or hints greatly appreciated.
f your gonna spam.....

admin@loopback, $LOGIN@localhost, $LOGNAME@localhost,
$USER@localhost, $USER@$HOST, -h1024@localhost, root@mailloop.com
root@localhost, postmaster@localhost, admin@localhost, abuse@localhost
Chairman Reed Hundt: rhundt@fcc.gov
Commissioner James Quello: jquello@fcc.gov
Commissioner Susan Ness: sness@fcc.gov
Commissioner Rachelle Chong: rchong@fcc.gov
US Postal Service: customer@email.usps.gov
Fraud Watch: fraudinfo@psinet.com
Pyramid Schemes: pyramid@ftc.gov
Federal Trade Commission: consumerline@ftc.gov
net-abuse@nocs.insp.irs.gov


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

Date: Sun, 4 Mar 2001 15:10:03 -0500
From: NagaPutih <s0218327@unix1.cc.ysu.edu>
Subject: Re: truncate
Message-Id: <Pine.A41.4.20.0103041504060.98230-100000@unix1.cc.ysu.edu>

On Sun, 4 Mar 2001, Bart Lateur wrote:
> It seems like you can skip this whole issue, and truncate the file's
> length to 0 before writing the string.

your solution seems to work, but now i'm confused!
truncating the file to a certain number of bytes
doesn't work due to tainting problem, but how come
truncating it to 0 works without any warnings/errors?

is it the value returned by length() or the fd that
is tainted?
a follow up on this would be much appreciated.

thank you again!



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

Date: Sun, 4 Mar 2001 20:59:11 -0000
From: Ken Brown <Ken.Brown@DIALWRAP.COM>
Subject: unlink problems
Message-Id: <25B11499EC0272449DD9D7BC33FCCB610AB1ED@dw2.dialwrap.com>

It would have worked perfectly had I pushed the right thing in to the
array in the first place.

All works well now - thanks for that.

Is there an easy way to delete an empty directory safely?

-----Original Message-----
From: Bart Lateur [mailto:bart.lateur@skynet.be]
Posted At: 04 March 2001 10:16
Posted To: misc
Conversation: unlink problems
Subject: Re: unlink problems


Ken Brown wrote:

>OK I'm new to this so I took the example from unlink and changed it a
>little bit pp236 seems to work fine until it comes across wild carded
>filenames
>
>I originally had it as you suggested but my *.txt files still failed so
>I went back to the book.

unlink doesn't work with widlcards, so you need to glob explicitely,
yourself. But Tad's code took care of that, so it seems:

	unlink(glob('*.txt'))

That should have worked. The only thing I can imagine to have gone
wrong, is that file globbing doesn't produce the proper results. So
print out the names of the files, instead of directly deleting them.
Don't forget to add separators between the file names, or you won't be
able to see where one name stops, and the next begins. Setting $\ and/or
$, can help.

-- 
	Bart.



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

Date: Sun, 04 Mar 2001 19:07:05 GMT
From: garry@zvolve.com (Garry Williams)
Subject: Re: Uploading a file
Message-Id: <tnwo6.253$mU5.12692@eagle.america.net>

On 4 Mar 2001 16:59:34 GMT, Ilmari Karonen <iltzu@sci.invalid> wrote:
>In article <v7no6.212$mU5.9428@eagle.america.net>, Garry Williams wrote:
>>
>>On a Windows machine:
>>  $ perl -wle 'print map { " " . ord } split //, "test\n"'
>>   116 101 115 116 10
>>
>>On a Unix machine: 
>>  $ perl -wle 'print map { " " . ord } split //, "test\n"'
>>   116 101 115 116 10
>>
>>Hmm.  No difference.  In other words, "\n" is _always_ interpolated as
>>the ASCII newline character no matter what the OS or hardware.  
>
>You didn't test on a Mac, did you?

Don't have one available.  Is it different?  

-- 
Garry Williams


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

Date: Sun, 04 Mar 2001 17:10:39 GMT
From: Bart Lateur <bart.lateur@skynet.be>
Subject: Re: Uploading a file
Message-Id: <jot4at4hio8fkuabtajpi8f794pd521aao@4ax.com>

Garry Williams wrote:

>Question one: What does the string "test\n" contain?  
>
>On a Windows machine:
 ...
>On a Unix machine: 
 ...

>Hmm.  No difference.  In other words, "\n" is _always_ interpolated as
>the ASCII newline character no matter what the OS or hardware.  

Surely you haven't tried it on a Mac. Well, on a Mac, you'd see that
"\n" is "\x0D".

-- 
	Bart.


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

Date: Sun, 4 Mar 2001 20:14:18 +0100
From: "Alan J. Flavell" <flavell@mail.cern.ch>
Subject: Re: Uploading a file
Message-Id: <Pine.LNX.4.30.0103042010590.25392-100000@lxplus003.cern.ch>

On Sun, 4 Mar 2001, Garry Williams wrote:

> >>Hmm.  No difference.  In other words, "\n" is _always_ interpolated as
> >>the ASCII newline character no matter what the OS or hardware.

That on a sample of 2.  Remarkable.

> >You didn't test on a Mac, did you?
>
> Don't have one available.

I don't suppose you have an IBM or Siemens mainframe, or a VAX/VMS
system, available either.  Or a number of other OSes that implement
Perl.   That's why we use the documentation.

>  Is it different?

Is there  perldoc perlport  waiting to be read?

-- 

         This .sig only acknowledges that the message was displayed on
         the recipient's machine. There is no guarantee that the
         content has been read or understood.



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

Date: 16 Sep 99 21:33:47 GMT (Last modified)
From: Perl-Users-Request@ruby.oce.orst.edu (Perl-Users-Digest Admin) 
Subject: Digest Administrivia (Last modified: 16 Sep 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.  

| NOTE: The mail to news gateway, and thus the ability to submit articles
| through this service to the newsgroup, has been removed. I do not have
| time to individually vet each article to make sure that someone isn't
| abusing the service, and I no longer have any desire to waste my time
| dealing with the campus admins when some fool complains to them about an
| article that has come through the gateway instead of complaining
| to the source.

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


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