[10848] in Perl-Users-Digest

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

Perl-Users Digest, Issue: 4449 Volume: 8

daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Thu Dec 17 19:17:25 1998

Date: Thu, 17 Dec 98 16:00:23 -0800
From: Perl-Users Digest <Perl-Users-Request@ruby.OCE.ORST.EDU>
To: Perl-Users@ruby.OCE.ORST.EDU (Perl-Users Digest)

Perl-Users Digest           Thu, 17 Dec 1998     Volume: 8 Number: 4449

Today's topics:
    Re: $&, $', and $` and parens.... (Larry Rosler)
    Re: $&, $', and $` and parens.... (Ilya Zakharevich)
        Anyone have a workaround for crippled ActiveState perl  hutchiss@my-dejanews.com
    Re: CGI.pm and fileupload (Bradley K. Farrell)
    Re: CGI.pm and fileupload (Bradley K. Farrell)
        Close and ReOpen File (Bryce Pursley)
    Re: Close and ReOpen File (Groovy94)
    Re: Command line Perl works but IIS Perl doesn't <gellyfish@btinternet.com>
    Re: Help needed! (Mark-Jason Dominus)
    Re: Help needed! ptimmins@netserv.unmc.edu
    Re: hyperlinked tree script??? <gellyfish@btinternet.com>
        Intentionally causing a trap/dump/GPF? chess@watson.ibm.com
        Interesting Forking Problem (Joseph M Carlton)
    Re: Larry Wall sayings (was Re: ($e_mail !~ /\w+[-\w]*\ (I R A Aggie)
        PERL & IIS internals <curt@vphos.net>
    Re: Perl and reading from log files (Marc Haber)
        problem naming a directory with a number <INFO@ARKSON.COM>
        Reference Troubles <bxb121@psu.edu>
        Search Not Working <tim.hicks@iname.com>
    Re: Searching through a 10MB file <uri@ibnets.com>
    Re: sort it ? <jdporter@min.net>
    Re: Still just a quickie <gellyfish@btinternet.com>
    Re: string to float (Larry Rosler)
    Re: Syntax Error...Not able to find. <uri@ibnets.com>
    Re: telnet by perl <gellyfish@btinternet.com>
    Re: telnet by perl (I R A Aggie)
    Re: the perl function split <Bill.Palmer@online.disney.com>
    Re: Use script to send Standard Form Input? <gellyfish@btinternet.com>
        Using Exporter... (Top Changwatchai)
    Re: Why Is Perl not a Language? <kenhirsch@myself.com>
    Re: Writing Perl with Notepad <shameluss plug> <admin@asarian-host.org>
    Re: Writing Perl with Notepad ptimmins@netserv.unmc.edu
        Special: Digest Administrivia (Last modified: 12 Dec 98 (Perl-Users-Digest Admin)

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

Date: Thu, 17 Dec 1998 13:52:46 -0800
From: lr@hpl.hp.com (Larry Rosler)
Subject: Re: $&, $', and $` and parens....
Message-Id: <MPG.10e31d08458e2d059898d6@nntp.hpl.hp.com>

[Posted to comp.lang.perl.misc and a copy mailed.]

In article <75bqhv$o14$1@shell1.ncal.verio.com> on 17 Dec 1998 12:45:51 
-0800, Jim Matzdorff <syran@shell1.ncal.verio.com> says...
> After reading an article here about how using the $ forces all matches to hold those variables
> (thereby slowing down your program), i went to look in the perlfaq.  Finding and reading the
> explanation, I am unclear on one thing.
> 
> Getting those values slows down perl just as much as aquiring any variables in $1...etc.  That
> I got.  But is it saying that using parens slows it down on a case-by-case basis, or it also
> slows down every pattern match?

Case-by-case, because the capture is explicit in the regex.
 
> And what's a good substitute for using the $'s?  Using parens everywhere you need to capture
> pre/match/post match?

Yes.  You *never* need to use $`, $&, $'.

my ($pre_match, $match, $post_match) = /(.*)(...whatever...)(.*)/s;

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


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

Date: 17 Dec 1998 23:50:00 GMT
From: ilya@math.ohio-state.edu (Ilya Zakharevich)
Subject: Re: $&, $', and $` and parens....
Message-Id: <75c5b8$59r$1@mathserv.mps.ohio-state.edu>

[A complimentary Cc of this posting was sent to Larry Rosler
<lr@hpl.hp.com>],
who wrote in article <MPG.10e31d08458e2d059898d6@nntp.hpl.hp.com>:
> Yes.  You *never* need to use $`, $&, $'.
> 
> my ($pre_match, $match, $post_match) = /(.*)(...whatever...)(.*)/s;

I would make it

  m/\A(.*?)(...whatever...)(.*)/s;

Still, it may disable many important optimizations.

Ilya


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

Date: Thu, 17 Dec 1998 21:07:57 GMT
From: hutchiss@my-dejanews.com
Subject: Anyone have a workaround for crippled ActiveState perl -- fork()
Message-Id: <75brrb$bnc$1@nnrp1.dejanews.com>

In the time-honored tradition of not re-inventing the wheel,
I'm looking for hints or examples of ways to get around the
gaping hole in Active State Perl...

$main::whinge=1;
Is there a reason why these guys didn't bother to implement
a feature that NT supports and that even the 16-bit Windows
API had ways to approximate?
$main::whinge=0;

I'm looking at different ways to do a fork equivalent. If I'm
forced to use Tcl to do this part of things it will be high irony.

I'm going to be using perlTk to do the GUI part of the project
and it needs to be able to spawn off a number of different
pieces that have to be able to run concurrently (this app can be
run on Unix or NT) ... without the use of 'fork' I'm not sure
just how I'll be able to do this.

Hints?  Pointers?  Derisive laughter?  Anything?

-----------== Posted via Deja News, The Discussion Network ==----------
http://www.dejanews.com/       Search, Read, Discuss, or Start Your Own    


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

Date: Thu, 17 Dec 1998 21:09:14 GMT
From: bradley@iinet.net.au (Bradley K. Farrell)
Subject: Re: CGI.pm and fileupload
Message-Id: <367d6adc.616689816@news.m.iinet.net.au>

Ernst Christensen <e.christensen@netjob.dk> wrote:
>Hi

er, G'day :)

>I am trying to make a fileupload script with the CGI module.
>But this module creates temporary files in a directory called tmp.
>How can I change this to anothher by my choice, I have looked in the
>docs, and Dejanews -> now(answers)
>
>Quote from the docs:
>
>CGI.pm creates temporary files in either the /usr/tmp or the /tmp
>directory.
>These temporary files have names like CGItemp125421, and should be
>deleted automatically.

And more quotes from the docs :)

What you asked for:

     Alternatively, you can just skip the search entirely and
     force CGI.pm to store its temporary files in some logical
     location. Do this at the top of your script with a line
     like this one: $TempFile::TMPDIRECTORY='/WWW_ROOT';

What *might* be helpful:

     You're encouraged to copy the data into your own file by
     reading from the file handle that CGI.pm provides you with.
     In the future there may be no temporary file at all, just
     a pipe. However, for now, if you really want to get at the
     temp file, you can retrieve its path using the tmpFileName()
     method. Be sure to move the temporary file elsewhere in the
     file system if you don't want it to be automatically deleted
     when CGI.pm exits.


Now, if the second quotation hits the mark, here is how I did it:

** WARNING **
This is the first time I have posted code to clpm.
( Be wary || Be afraid ) && Be gentle   ;)
** WARNING **

pseudo-code
1. get the name of the *temp* file created by CGI.pm
2. specify a path for *our* own (about-to-be-created) copy of that
temp file
3. open the files
4. read each line of the *temp* file and write it to *our* file
5. close the files

Which turned out like this (more or less; I've had to trim out some
other stuff):

===script fragment===

$incoming_file   = param("$name_of_form_field");
$cgipm_temp_file = tmpFileName($incoming_file);
    # combining the above didn't seem to work :-|

$our_file = 'path/to/our/file';

open(TEMPFILE, "<$cgipm_temp_file")
  or die "cannot open TEMPFILE: $!";
open(OURFILE, ">$our_file")
  or die "cannot create OURFILE: $!";

while (<TEMPFILE>) { print OURFILE $_ }

close OURFILE  or die "cannot close interimfile for $div: $!";
close TEMPFILE or die "cannot close tempfile for $div: $!";

===end fragment===


And thus I got my own copy of the uploaded file in the location of my
choice.

Mmmh, well, I hope that helps.
-- 
Bradley K. Farrell
bradley@iinet.net.au


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

Date: Thu, 17 Dec 1998 21:20:57 GMT
From: bradley@iinet.net.au (Bradley K. Farrell)
Subject: Re: CGI.pm and fileupload
Message-Id: <367e749f.619189195@news.m.iinet.net.au>

For shame! I forgot to mention that Brent Michalski got me started:
  http://webreview.com/wr/pub/98/08/14/perl/index.html
All subsequent errors are my own :)

-- 
Bradley K. Farrell
bradley@iinet.net.au


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

Date: Thu, 17 Dec 1998 21:04:37 GMT
From: hbpursle@duke-energy.com (Bryce Pursley)
Subject: Close and ReOpen File
Message-Id: <367970f7.2426407549@news.infoave.net>

Is there any reason I can't close and then immediately reopen a file?
The code doesn't work when I do it in consecutive lines of one program
but if I run a separate perl script that opens the file after the
first script has finished it works just fine.
Bryce Pursley


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

Date: 17 Dec 1998 21:09:43 GMT
From: groovy94@aol.com (Groovy94)
Subject: Re: Close and ReOpen File
Message-Id: <19981217160943.05673.00000689@ng95.aol.com>

I'm not sure what your problem is esactly, but it could be that the script is
still closing it when it tries to reopen. Are you trying to reopen the same
file? It servers no purpose if that is the case. Try adding a sleep statement
in between the code and see if that helps...maybe 0.1 seconds. 
Regards,
GIl Hildebrand, Jr.
Email: groovy94@aol.com
ICQ UIN: 16678754


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

Date: 17 Dec 1998 22:54:34 -0000
From: Jonathan Stowe <gellyfish@btinternet.com>
Subject: Re: Command line Perl works but IIS Perl doesn't
Message-Id: <75c23a$1dg$1@gellyfish.btinternet.com>

On Wed, 09 Dec 1998 19:53:47 GMT rna16s@usa.net wrote:
> Hello All,
> Hello All,
> 

Hello, Hello, Hello

>   I am trying to run a script using the LWP Perl module on IIS 4 NT
> Server. I have installed Active State 5.07 Perl and set up the mapping
> in IIS. The problem I am having is the script I am running (which goes
> out and grabs a URL and the prints out the HTML source) throws an
> error when trying to tun the script through the web browser, but the
> command line works fine. This is the script
> 

<snip script>

> 
> This script returns the html for the url (Yahoo in this case) no
> problem from the command line, but from the browser it throws the
> error condition and prints "Bad Luck this time". I am new to modules
> and Perl/IIS. Any help would be appreciated. Thanks.
> 

This is almost certainly to do with the user rights for the IUSR_<whatever>
and as such is not a Perl problem but a server configuration thing you might
want to ask this question in comp.infosystems.www.servers.ms-windows.


/J\
-- 
Jonathan Stowe <jns@btinternet.com>
Some of your questions answered:
<URL:http://www.btinternet.com/~gellyfish/resources/wwwfaq.htm>
Hastings: <URL:http://www.newhoo.com/Regional/UK/England/East_Sussex/Hastings>


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

Date: 17 Dec 1998 16:17:18 -0500
From: mjd@op.net (Mark-Jason Dominus)
Subject: Re: Help needed!
Message-Id: <75bscu$83f$1@monet.op.net>

In article <Un3NuHgI1diW-pn2-6DyTyh2Dt5fl@aada.dyn.icon.fi>,
Tuomas Angervuori <tumppi@icon.fi> wrote:
>I have a string, for example "> > Blaah blaah". How can I count, how 
>many ">" characters there are in the string?

	$count = $string =~ tr/>//;


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

Date: Thu, 17 Dec 1998 22:15:44 GMT
From: ptimmins@netserv.unmc.edu
Subject: Re: Help needed!
Message-Id: <75bvqd$fg2$1@nnrp1.dejanews.com>

In article <Un3NuHgI1diW-pn2-6DyTyh2Dt5fl@aada.dyn.icon.fi>,
  tumppi@icon.fi (Tuomas Angervuori) wrote:

> I have a string, for example "> > Blaah blaah". How can I count, how
> many ">" characters there are in the string?

perlfaq4 - Data Manipulation:
How can I count the number of occurrences of a substring within a string?

You didn't search on "How can I count" did you?

Patrick Timmins
$monger{Omaha}[0]

-----------== Posted via Deja News, The Discussion Network ==----------
http://www.dejanews.com/       Search, Read, Discuss, or Start Your Own    


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

Date: 17 Dec 1998 19:23:58 -0000
From: Jonathan Stowe <gellyfish@btinternet.com>
Subject: Re: hyperlinked tree script???
Message-Id: <75bloe$1bq$1@gellyfish.btinternet.com>

On Tue, 15 Dec 1998 20:32:08 GMT webboss@tcat.ac.uk wrote:
> Hi...
> 
> A while ago I came accross a useful script that produced a nice HTML
> formated page showing a directory tree representation of all dirs
> below a point passed to it on the command line.The filenames were
> embedded as clickable fully pathed hyperlinked hrefs.
> 
> Yep - you guessed it, now Ive a use for it I cant find the damn thing!
> 
> Ive just spent a couple of hours trying to re-invent the wheel, but my
> results are errrr.... suspect, to say the least!
> 
> Did you write this script???   No, then  can anyone point me in the
> direction of the script, or suggest some suitable starting point...???
> 

I dont think that I wrote the script that you saw ( its that 'nice HTML
formatted page etc .. ' that makes me think that :), however I have written
a program to do something similar (though probably worse by far than what
you want) you can find it at:

<URL:http://www.btinternet.com/~gellyfish/resources/dir2html.htm>

Hope it helps

/J\
-- 
Jonathan Stowe <jns@btinternet.com>
Some of your questions answered:
<URL:http://www.btinternet.com/~gellyfish/resources/wwwfaq.htm>
Hastings: <URL:http://www.newhoo.com/Regional/UK/England/East_Sussex/Hastings>


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

Date: Thu, 17 Dec 1998 20:47:21 GMT
From: chess@watson.ibm.com
Subject: Intentionally causing a trap/dump/GPF?
Message-Id: <75bqko$alh$1@nnrp1.dejanews.com>

Is there some portable way in Perl to cause the current OS's
version of a nasty crash?  (GPF, trap, coredump, whatever?)

I realize that this isn't something one ordinarily wants to do,
but for some automated test stuff, we want to be able to make sure
that our outer environment reacts correctly when the thing that it
calls dies a horrible death...

DC

-----------== Posted via Deja News, The Discussion Network ==----------
http://www.dejanews.com/       Search, Read, Discuss, or Start Your Own    


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

Date: 17 Dec 1998 22:14:04 GMT
From: carltjm@mail.auburn.edu (Joseph M Carlton)
Subject: Interesting Forking Problem
Message-Id: <75bvnc$nfd$1@ultranews.duc.auburn.edu>

I'm having an interesting problem and I could really use some advice.  I 
am working on a cgi perl script that executes another perl script 
called update_user_profile.perl (this one takes a while to run) via a 
fork.  This second perl script executes an expect sript call up_push.sh 
via backquote (this program ftp's a file).  

I can get everything to work properly, except Netscape hangs and waits 
for all of the script's children to finish executing.  To fix this, I 
closed STDIN, STDOUT, and STDERR.  This fixes the Netscape hanging 
problem, and the update_user_profile script is still executed, but the 
up_push.sh program will not run.  (it shows up in ps -ef, but it is just 
dead).  The weird thing is that everything still works fine if I run the 
cgi script from the command line.

So the question is this:  what is it about closing STDIN, STDOUT, and 
STDERR via cgi execution, that causes up_push to not execute?  If you can 
offer any assistance, I would be very grateful.  I've been working on 
this problem for 2 or 3 weeks with no luck.  If more info is needed, 
please let me know.

Here's the code from the cgi program where I do the fork:
sub spawn {
    my $coderef = shift;
    my $pid;

    if (!defined($pid = fork)) {
       return;
    } elsif ($pid) {
       return; # I'm the parent
    }
    # else I'm the child -- go spawn

    close(STDIN);
    close(STDOUT);
    close(STDERR);
    exit &$coderef();
}

Here's where I call subroutine spawn in the cgi program:
   spawn sub {
        `/home/Netscape/cgi-bin/user_profile/update_user_profile.perl`;
   };


Thanks for your help!
Joey Carlton
carltjm@mail.auburn.edu


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

Date: Thu, 17 Dec 1998 18:44:23 -0500
From: fl_aggie@thepentagon.com (I R A Aggie)
Subject: Re: Larry Wall sayings (was Re: ($e_mail !~ /\w+[-\w]*\@\w+[-\w]*\.\w+/)
Message-Id: <fl_aggie-1712981844230001@aggie.coaps.fsu.edu>

In article <l5db57.qao.ln@magna.metronet.com>, tadmc@metronet.com (Tad
McClellan) wrote:

+ In article <1995Nov9.193745.13694@netlabs.com>, lwall@netlabs.com (Larry
+ Wall) wrote: ...
+ 
+ <Larry>  [snip]  I view a programming language as a place to be
+ <Larry>  explored, like Disneyland. You don't need to have a lot of
preparation
+ <Larry>  to explore a theme park.  You do have to go along with the crowd
+ <Larry>  control measures, though.  In a sense, each ride has its own
+ <Larry>  prerequisites--if you cut in line, you risk getting tossed out of the
+ <Larry>  park.
+ <Larry>
+ <Larry>  What we have here in this newsgroup is a failure in crowd control.
+ <Larry>  Reading the FAQ is like staying in line--it's something you should
+ <Larry>  learn in kindergarten.  Usenet needs a better kindergarten.

Larry wrote that in 1995. Good thing he didn't write it in 1998, or someone
would have flamed him for it...

James


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

Date: Thu, 17 Dec 1998 15:21:36 -0800
From: Curt Cranfield <curt@vphos.net>
Subject: PERL & IIS internals
Message-Id: <36799200.22DE6BB7@vphos.net>

Hi Everyone,

I am a die-hard PERL unix programmer but I have been tasked with
programming a script with PERL on NT.

What I am wondering is - has anyone been able to access the internals of
IIS to create such things a virtual servers - without having to do a
system(iisadmin.exe .....) or system(createvirtual.vbs...)?  Using these
little MS programs is not a whole lot of fun!

Ultimately, it would be nice to have a module that could access the
internal files? Something I haven't been able to find at CPAN.

Any help is greatly appreciated.

Cheers,

Curt



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

Date: Thu, 17 Dec 1998 23:08:44 GMT
From: Marc.Haber-usenet@gmx.de (Marc Haber)
Subject: Re: Perl and reading from log files
Message-Id: <75c2ts$sft$1@news.rz.uni-karlsruhe.de>

Marc.Haber-usenet@gmx.de (Marc Haber) wrote:
>Due to the daemon reading always at the end of file, it does not wait
>for the next line to be printed, hence the sleep 5. This is very ugly.
>Is there a more beautiful way to make the program wait until the next
>line has been written to the log?

Well, I am currently reading the bighorn book on the train to work and
I happened to stumble across this exact question in Recipe 8.5. Tom
and Nathan came up with this code (indention style is mine, not
Tom's):

for (;;)
{
  while( <FH> )
  {
	# do something
  }
  sleep $sometime;
  seek( FH, 0, 1 );
}

So this most definetely is the way to do it. I recommend the bighorn
book. I am not through with it, but I already know that it probably
won't leave my desk for some time.

Greetings
Marc

-- 
-------------------------------------- !! No courtesy copies, please !! -----
Marc Haber          |   " Questions are the         | Mailadresse im Header
Karlsruhe, Germany  |     Beginning of Wisdom "     | Fon: *49 721 966 32 15
Nordisch by Nature  | Lt. Worf, TNG "Rightful Heir" | Fax: *49 721 966 31 29


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

Date: Thu, 17 Dec 1998 23:17:13 GMT
From: "Brendan Murphy" <INFO@ARKSON.COM>
Subject: problem naming a directory with a number
Message-Id: <Zhge2.39809$Pk4.21919942@news.inreach.com>

Hello!

I am trying to have a cgi redirect to a page such as
http://www.hello.com/redirect1111

But instead of directing to that page it goes to
http://www.hello.com/redirect111

Please, help.... must be some reason....

Brendan
info@arkson.com




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

Date: Thu, 17 Dec 1998 21:47:34 +0000
From: Brett Borger <bxb121@psu.edu>
To: bxb121@psu.edu
Subject: Reference Troubles
Message-Id: <36797BF6.B8840280@psu.edu>

I've been having real trouble trying to mangle references to work for
me...I've got a handle on symbolic references, but pointer-like
references are troubling me, (mainly syntax, as far as I can tell).

I'm trying to write a script that will read a definitions file, store
the data, and do something with it.  I haven't gotten to step 3 yet....

The definitions file is in the format:
Name: Item1
Value: Bob
Special: Frank
Name: Item2
Special: None

Where:
1) Every item has a list of properties, in key:value pairs.  The only
thing definite about everything is that it has a Name.
2) Comments (Everything after a #) are to be stripped and ignored
3) A value can be multiple lines, as eventually the data may include
perl code to be eval'ed

I intended to store the data so that every list of properties was in an
anonymous hash.   An array in def-file order of references to those
hashes would provide ordinal access to them, and a hash of references
keyed by name would provide selective access.  It doesn't work so
well....

Also:  This is really my first time trying to be good about use string
and perl -w, so any tips there are appreciated.


Here is the script so far:
#!/usr/bin/perl -w
use strict;

my($filename)="gear.dat";
my($line,$key,$i);
my(@items);  #array in order of references to hashes of properties
my(%gear);  #hash by names of hashes of properties
my($notready)=1;
my($thisitem, $thisname, $thiscontent);
my(%list)={};  #Do I need to do this?
open(DATA,$filename);

READIN: while(defined($line=<DATA>)){
        $line=~s/\s*#.*$//;
        next READIN if($line=~/^\s*$/);
          #This is the first descriptor of a new list
        if($line=~/Name:/){
                push @items, \%list unless $notready;
                $gear{$thisname}=\%list unless $notready;
                $notready=0;
                ($thisitem,$thiscontent)=split(/:/,$line);
                $thisitem="Name";
                $thisname=$thiscontent;
                %list={};
          #this is an additional descriptor of the list
        } elsif ($line=~/:/){
                $list{$thisitem}=$thiscontent;
                ($thisitem,$thiscontent)=split(/:/,$line);
          #this is more of the current descriptor
        } else {
                $thiscontent.=$line;
        }
}

for ($i=0;$i<=$#items;$i++){
        print "Item: $i\n";
        foreach $key (keys(%{$items[$i]})){
                print "-$key: ${$items[$i]}{$key}\n";
        }
}
__END__

I get three "Odd number of hash elements" warnings (which I don't
understand) and The output:
Item: 0
-Name: Item2

And that is all.  I'd fight my way through it, but I'm not sure which
end I screwed up, the storage or retreival.  Any help is appreciated,
thanks.

-Brett Borger




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

Date: Thu, 17 Dec 1998 21:43:02 -0000
From: "Tim Hicks" <tim.hicks@iname.com>
Subject: Search Not Working
Message-Id: <vWee2.1512$7M.78@news-reader.bt.net>

Hi all,

I am pretty new to perl, but have read through 'Learning Perl' a couple of
times.
I am now trying to write a simple search script that looks through a small
'|' delimitted text database file.  I have tried to give people the option
of which column they want to search by.  I have made everything run without
any errors, except that it doesn't output what I expect from doing the
process myself.  Here is my script and a sample of my database.

Thanks for your help, if you give any!!

#!/usr/bin/perl -w

open(TOURN2, "tourndata2.txt") || die "cannot open tourndata2.txt for
reading: $!";
open(TEMP, ">temp.txt") || die "cannot open temp.txt for writing: $!";

print "Here is the template for the database...\n\n";
print "Name|Events|Closing_Date|Start_Date|Venue|Region|Ratings\n";
print " 1  |  2   |      3     |     4    |  5  |  6   |   7\n\n";
print "Choose which field to search using the number codes: ";
chomp ($select=<STDIN>);

if ($select == 1) {
 searcher (0);
} elsif ($select == 2) {
 searcher (1);
} elsif ($select == 3) {
 searcher (2);
} elsif ($select == 4) {
 searcher (3);
} elsif ($select == 5) {
 searcher (4);
} elsif ($select == 6) {
 searcher (5);
} elsif ($select == 7) {
 searcher (6);
} else {
 print "You input an unexpected value, please run the search engine again.";
}




sub searcher {
 $col=$_[0];
 print "Enter your search word: ";
 chomp ($word=<STDIN>);

 foreach (<TOURN2>) {
  @record = split(/|/,$_);
  if ($record[$col] =~ /$word/i) {
  print $_;
  }
 }
}

close(TOURN2) || die "cannot close tourndata2.txt: $!";
close(TEMP) || die "cannot close temp.txt: $!";


and the data

Name|Events|Closing_Date|Start_Date|Venue|Region|Ratings
Week 4
Adidas Challenge|GS 11|18/12/1998|30/01/1999|Howdon, Beckenham|SE|NA
County Indoor Matchplay|BS 10|11/01/1999|30/01/1999|Surrey LTA Centre|SE|NA
County Indoor Matchplay|BS 11|11/01/1999|30/01/1999|David Lloyd,
Heston|SE|NA
County Indoor Matchplay|BS 14|11/01/1999|31/01/1999|Aldershot Tennis
Centre|SE|NA





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

Date: 17 Dec 1998 16:08:52 -0500
From: Uri Guttman <uri@ibnets.com>
Subject: Re: Searching through a 10MB file
Message-Id: <39lnk64gt7.fsf@ibnets.com>

>>>>> "CMA" == Christian M Aranda <christian.aranda@iiginc.com> writes:

  CMA> On 17 Dec 1998 14:06:09 -0500, Uri Guttman <uri@ibnets.com> wrote:
  >> i still don't like the loop variables. my version had none but it's your
  >> code. but once you have decided what kind of line it is, why check the
  >> others too? 


  CMA> I don't think I understand your statement.  I'm trying to understand
  CMA> because understanding is learning.

  CMA> I keep searching the lines to make sure it's not the "End:" line.


but if it is the start line, it can't also be the end line! so if you
found a start line, skip the other tests and go get the next line with
next.

anyway, as i said, using a single loop with flags is old
fashioned. learn to use multiple loops. the logic is simpler and it is
faster to boot. my earlier post has most of the code you need for that
design.

uri


-- 
Uri Guttman                             Hacking Perl for Ironbridge Networks
uri@sysarch.com				uri@ironbridgenetworks.com	


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

Date: Thu, 17 Dec 1998 17:03:16 -0500
From: John Porter <jdporter@min.net>
Subject: Re: sort it ?
Message-Id: <36797FA4.A92900C4@min.net>

Micha3 Rutka wrote:
> 
> Alternativly, you can speed up a little bit by using a construction,
> which I invented during problem of sorting IP addresses (look in
> Dejanews for articles from October of this year). Here is the code:
> 
> @vendors = map{ substr($_,9) }
>            sort
>            map{ sprintf("%9.2f",(split " ",$_)[$field]).$_ } @vendors;

I'm as grateful as anyone for Michal pointing out the performance
advantage of using the built-in sort comparison.
However, unlike the ST, this is not an invention but a general
rule-of-thumb: Using the built-in sort comparison (if possible) is usually
much faster than explicit comparison code.

John Porter


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

Date: 17 Dec 1998 21:33:31 -0000
From: Jonathan Stowe <gellyfish@btinternet.com>
Subject: Re: Still just a quickie
Message-Id: <75btbb$1d8$1@gellyfish.btinternet.com>

On Wed, 9 Dec 1998 01:57:44 -0000 Antony <amcnulty@nortel.co.uk> wrote:
> Hey Expert-Type People,
> 

Flattery will get you everywhere.

> I want to finish a small program that I am working on, but have one little
> problem.
> 
> My script needs to be run a subroutine every time the timestamp of a certain
> file is altered.
> 

If you are writing for NT (and you are using NTFS) then you could use the 
Win32::ChangeNotify module (available from CPAN) - I havent tried it myself 
but I think it does what you want.  This functionality is actually built 
into the NTFS filesystem.

/J\
-- 
Jonathan Stowe <jns@btinternet.com>
Some of your questions answered:
<URL:http://www.btinternet.com/~gellyfish/resources/wwwfaq.htm>
Hastings: <URL:http://www.newhoo.com/Regional/UK/England/East_Sussex/Hastings>


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

Date: Thu, 17 Dec 1998 13:40:14 -0800
From: lr@hpl.hp.com (Larry Rosler)
Subject: Re: string to float
Message-Id: <MPG.10e31a1b54f96e769898d5@nntp.hpl.hp.com>

[Posted to comp.lang.perl.misc and a copy mailed.]

In article <36796AD8.C914037@vanderbilt.edu> on Thu, 17 Dec 1998 
14:34:32 -0600, Steven Ford <steven.m.ford@vanderbilt.edu> says...
 ...
> $line = "*99880060288399999999990100000309200104315876"
> 
>  $amount = substr ($line,35,11);  # $line = "0104315876"

(That's only 10 characters in your comment.)  It might be nicer to count 
from the back, if that's what you want:

   $amount = substr ($line, -11);  # $line = "00104315876"

>  $amount =~ s/^0+//; # Strip leading zeros  $line = "104315876"

Why bother with that?  printf doesn't care about leading zeros.

> I need to display $line as:  $1043158.76
> 
> I used printf with %8.2f but it did not place the decimal for me,
> instead it did 104315876.00
> 
> Does anyone have a suggestion on how to display this data?

Yes.  It is an integer, so printf is printing it as an integer.  Divide 
it by 100:

   printf '%8.2f', $amount/100;

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


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

Date: 17 Dec 1998 16:32:13 -0500
From: Uri Guttman <uri@ibnets.com>
Subject: Re: Syntax Error...Not able to find.
Message-Id: <39iufa4fqa.fsf@ibnets.com>

>>>>> "G" == Groovy94  <groovy94@aol.com> writes:

  G> I have been battling with a problem in a reseller/commision program
  G> I am making. My error log gives me a line for the error, but does
  G> not tell me specifics, and I have been debugging for hours..with no
  G> success. I see no apparent errors in the syntax, however, there
  G> must be something wrong. My error is somewhere in this snippet of
  G> code:

  G> While(-f resellers.lock) {
     ^
perl uses lower case keywords

  G> 	$resellers{'reseller$number_resellers'}=$INPUT{'name'},$INPUT{'email'},
                   ^                         ^
this doesn't look right either. it won't interpolate $number_resellers
but instead its gives the literal string 'reseller$number_resellers'

  G> 	unlink (resellers.lock);
                ^^^^^^^^^^^^^^
bareword for a file name. are you using -w?


hth,

uri

-- 
Uri Guttman                             Hacking Perl for Ironbridge Networks
uri@sysarch.com				uri@ironbridgenetworks.com	


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

Date: 17 Dec 1998 19:58:21 -0000
From: Jonathan Stowe <gellyfish@btinternet.com>
Subject: Re: telnet by perl
Message-Id: <75bnot$1ce$1@gellyfish.btinternet.com>

On Thu, 17 Dec 1998 10:27:03 -0800 Sam Curren <samc@empirewest.com> wrote:
> I'm attempting to open a telnet session to a server on a specific port, 
> wait for the init string, then send it one line of text and disconnect.
> 
> All servers being linux.
> 
> Being able to save all the output of the other server would be a plus.
> 
> I can do all the work, but does anyone have a general place to start? I'd 
> rather use a module then a system call, but a system call can be made.
> 

At first reading I nearly just typed Net::Telnet but then I noticccced the
'specific port' bit ...

I think you'll find sufficient examples in the perlipc manpage specifically
the section entitled 'Sockets: Client/Server Communication'.

/J\
-- 
Jonathan Stowe <jns@btinternet.com>
Some of your questions answered:
<URL:http://www.btinternet.com/~gellyfish/resources/wwwfaq.htm>
Hastings: <URL:http://www.newhoo.com/Regional/UK/England/East_Sussex/Hastings>


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

Date: Thu, 17 Dec 1998 18:42:54 -0500
From: fl_aggie@thepentagon.com (I R A Aggie)
Subject: Re: telnet by perl
Message-Id: <fl_aggie-1712981842540001@aggie.coaps.fsu.edu>

In article <75bnot$1ce$1@gellyfish.btinternet.com>, Jonathan Stowe
<gellyfish@btinternet.com> wrote:

+ At first reading I nearly just typed Net::Telnet but then I noticccced the
+ 'specific port' bit ...

Ah, true. Which got me to look at the Net::Telnet docs:

     NAME
          Net::Telnet - interact with TELNET port or other TCP ports

'other TCP ports', eh?

<big snip>
                  $obj = Net::Telnet->new([Binmode    => $mode,]
<medium snip>
                                          [Port       => $port,]

Well, I'll be...

James


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

Date: Thu, 17 Dec 1998 13:26:22 +0000
From: Bill Palmer <Bill.Palmer@online.disney.com>
Subject: Re: the perl function split
Message-Id: <3679067E.DEF@online.disney.com>

Marco Vlemmings wrote:
> 
> Hi,
> 
> I have a problem with the function 'split'.
> I want to split a ascii file.
> Here is the piece of code.
> @rows = split (/\|\n/,$chunks[0]);
> In the array rows will be split by the two caracters pipe and carrage
> return, but it does not split at all.How can i split on a carrage
> return?

@rows = split (/\r/,$chunks[0]);

> 
> Can anybody help me.
> 
> With kind regards
> 
> Marco Vlemmings
> email: marcov@ctrl-v.nl


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

Date: 17 Dec 1998 20:39:28 -0000
From: Jonathan Stowe <gellyfish@btinternet.com>
Subject: Re: Use script to send Standard Form Input?
Message-Id: <75bq60$1d2$1@gellyfish.btinternet.com>

On Tue, 08 Dec 1998 15:22:28 GMT jday@microcal.com wrote:
> I am modifying a script that under certain parameters sends a query
> string to another script. i.e.
> if ($FORM{ad_cat} eq "previous user") {
>     print "Location:
> http://mydomain/getaddress.pl?ad_cat=pr
> evious+user\n\n";
> };
> 
> Unfortunately, this also presents the query string in the address field of
> the users browser. I do not want them to be able to bookmark the address
> and therefore by-pass the series of scripts if they return
> 
> To work around the problem, I would like to use Post rather than Get and
> send the information as standard form input, but I don't know if this is
> possible from script.
> Can anyone tell if it's possible and how it would be done??

You probably want to use the module CGI.pm available from CPAN (if it is not
included with your particular distribution of Perl) - this allows you to use
any request method and is particularly well documented.  There are other
modules that do a similar thing such as CGI::Lite and the CGI::Base and 
CGI::Request.

Using CGI.pm your fragment could be rendered like this:

use CGI qw(:standard);

if (param('ad_cat') eq "previous user") 
  {
     print redirect('http://mydomain/getaddress.pl?ad_cat=previous+user';
  }
else
  {
     # print something appropriate or do whatever
  }

/J\
-- 
Jonathan Stowe <jns@btinternet.com>
Some of your questions answered:
<URL:http://www.btinternet.com/~gellyfish/resources/wwwfaq.htm>
Hastings: <URL:http://www.newhoo.com/Regional/UK/England/East_Sussex/Hastings>


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

Date: 17 Dec 1998 23:35:55 GMT
From: wtc@schultz.io.com (Top Changwatchai)
Subject: Using Exporter...
Message-Id: <75c4gr$kn7$1@hiram.io.com>

I have some questions about using the "Exporter" module with the "strict"
module.

My fundamental goal is that I want to share some variables between packages,
and I want to be able to "use strict" in all packages.

The obvious solution is to use the "Exporter" module, as shown below in the
"mainprog" and "TestMod.pm" listings:

============================= mainprog ====================================
#!/usr/local/bin/perl

use TestMod;
use strict;

$sharevar = "original value";

print "1 - $sharevar\n";
&f1();
print "3 - $sharevar\n";
===========================================================================

============================= TestMod.pm ==================================
package TestMod;
use Exporter ();
@ISA = qw(Exporter);

@EXPORT = qw(
	     $sharevar
	          f1
		       );

use strict;
use vars qw(
        $sharevar
	    );

sub f1 {
    print "2 - $sharevar\n";

    $sharevar = "new value";
}
===========================================================================

This produces the expected output:
$ mainprog
1 - original value
2 - original value
3 - new value

However, as you can see, it seems I have to specifically "use vars" for the
shared variables inside TestMod.  Apparently the Exporter module doesn't do
this for the variables in @EXPORT.  Is this the generally accepted solution?
It could get a bit unwieldy if there's a large list of shared variables which
is frequently updated--this list would have to be updated in both the @EXPORT
list and the "use vars" list.

In order to avoid this duplication, I tried having a common list of shared
variables (@export_list, below), but it doesn't work:

============================= TestMod2.pm =================================
package TestMod2;
use Exporter ();
@ISA = qw(Exporter);

my @export_list = qw(
		     $sharevar
			     );

@EXPORT = @export_list,
    qw(
       f1
       );

use strict;
use vars @export_list;

sub f1 {
    print "2 - $sharevar\n";

    $sharevar = "new value";
}
===========================================================================

If I try to use TestMod2, I get this error:

$ mainprog
Global symbol "sharevar" requires explicit package name at TestMod2.pm line 19.
Compilation failed in require at ./mainprog line 3.
BEGIN failed--compilation aborted at ./mainprog line 3.

Why doesn't TestMod2 work?  What is an elegant way to code this (assuming I do
want to have shared variables)?

Top
-- 
W. Top Changwatchai
wtc@io.com


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

Date: Thu, 17 Dec 1998 15:19:07 -0500
From: "Ken Hirsch" <kenhirsch@myself.com>
Subject: Re: Why Is Perl not a Language?
Message-Id: <75borh$n09$1@fddinewz.oit.unc.edu>


Daniel Grisinger wrote in message ...
>phenix@interpath.com (John Moreno) writes:
[...]
>> For it to be "interactive" then it has to be /able/ to stop at least
>> once.
>
>No, it doesn't.  Unless you are saying that this isn't interactive:
>
>[dgris@moiraine pod]$ grep hash *.pod
><snip lots of results>
>
>[dgris@moiraine pod]$ grep hash perltrap.pod perlvar.pod
><snip lots of results>
>
>[dgris@moiraine pod]$ grep %SIG perlvar.pod
><snip final result set>



The SHELL has an interactive interface, GREP does not.

This isn't really Perl specific anymore, so maybe you should continue this
in another group.  (I've set the "followup" to comp.programming).

>
>Just because it's iterative doesn't mean that it isn't interactive.
>In fact, this is exactly the execution model of an http server (make
>one request, receive one reply, make another request), and I don't
>hear anyone saying that the web isn't interactive.


Notice that an HTTP server _stops_ and waits for a reply.

You can build interactive interfaces with the web. For example,
USER:  types URL
PROGRAM:  responds with form
Then _stops_ and waits for user input
USER: fills out form and hits submit
PROGRAM: processes form data, processes reply

If the program merely did the last step, I wouldn't consider it interactive.

[...]

>No, it's not a terminology problem, and it's not better now.  It's a
>problem with making unsupportable assumptions about what you are
>writing. `user' and `interactive' are completely meaningless terms
>when it comes to interface design.  At any time, your `user' could be
>any or all of a human being, an intelligent agent, or another program
>and you have _no_ mechanism to determine absolutely which of these is
>the case.


Sigh.  The terms "user" and "interactive" are not completely meaningless.
Although you often, even usually, want to make most of your program
functionality independent of the type of "user", the interface varies
tremendously depending on what is going to be on the other side of the
interface.  Things that humans like--such as menus, warnings, interactive
selection--are useless to another program.

Ken Hirsch





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

Date: Thu, 17 Dec 1998 23:55:54 +0100
From: Mark <admin@asarian-host.org>
Subject: Re: Writing Perl with Notepad <shameluss plug>
Message-Id: <199812172256.PAA25628@asarian-host.org>

Bart Lateur wrote in message <367cca97.5567033@news.skynet.be>...
>JT wrote:
>
>>Try Textpad. It is the ultimate windows text editor, everything else
>>is junk.
>>http://www.textpad.com/
>>It's so good that it's scary, I won't even try to explain.
>
>It doesn't load files of over 32k lines.
>
>I sometimes need that, e.g to look at a DXF file.
>
> Bart.


I have recently discovered UltraEdit32; nothing compares to it; it is
Perl-friendly (recognizes the commands, etc,) loads megabytes of content
within mere seconds, it has powerful search & replace capabilities; in
short, it is the very best; dump the rest before you hurt yourself. :)

- Mark

        System Administrator Asarian-host.org







--
For more information about this posting service, contact:

help@asarian-host.org    -- for instant general information about our services
admin@asarian-host.org   -- for the server's administrator
nclark@asarian-host.org  -- for our PR manager
abuse@asarian-host.org   -- for abuse of this posting service

If you wish to get an anonymous email/posting account, visit our sign-up page:

http://asarian-host.org/emailform.html


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

Date: Thu, 17 Dec 1998 22:03:52 GMT
From: ptimmins@netserv.unmc.edu
Subject: Re: Writing Perl with Notepad
Message-Id: <75bv46$eq2$1@nnrp1.dejanews.com>

In article <756q2l$co$1@gellyfish.btinternet.com>,
  Jonathan Stowe <gellyfish@btinternet.com> wrote:

> On Tue, 15 Dec 1998 15:52:02 GMT ptimmins@netserv.unmc.edu wrote:
> > In article <367815c6.2053261@news.skynet.be>,
> >   bart.lateur@skynet.be (Bart Lateur) wrote:
> >
> >> Thomas Brian Holdren wrote:
> >>
> >> >Hate Windows becuase you can't
> >> >"Esc:w" to save a file?
> >>
> >> Now *that* makes sense.
> >>
> >> 	Bart.
> >
> > I currently have to read and post from DejaNews (blech!), and
> > I'm constantly having to backspace and delete out "dw", "dd", "j",
> > "0", etc, that I erroneously type after hitting my escape key ...
> > thinking it will respond properly ... a brain-stem, muscle wisdom
> > sort of thing, I guess.
>
> I have viw (from Watcom) that  is a windows app that is vi ... I figure that
> is alright.

Well, I use vim and like vim (www.vim.org :), which works on Win32. It's
just that to interact with the newsgroup, I currently have to do it through
a web form ... I'll paste stuff back and forth between vim and the textarea
of the form, then when I put it back in the form field and try to make
a few last minute changes, clarifications, etc, I find myself constantly
hitting the escape key, followed by the vi command appropriate for what
I want to do, but not approrpriate in the 'eyes' of my Win32 web browser :(

Patrick Timmins
$monger{Omaha}[0]
:wq

-----------== Posted via Deja News, The Discussion Network ==----------
http://www.dejanews.com/       Search, Read, Discuss, or Start Your Own    


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

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


Administrivia:

Well, after 6 months, here's the answer to the quiz: what do we do about
comp.lang.perl.moderated. Answer: nothing. 

]From: Russ Allbery <rra@stanford.edu>
]Date: 21 Sep 1998 19:53:43 -0700
]Subject: comp.lang.perl.moderated available via e-mail
]
]It is possible to subscribe to comp.lang.perl.moderated as a mailing list.
]To do so, send mail to majordomo@eyrie.org with "subscribe clpm" in the
]body.  Majordomo will then send you instructions on how to confirm your
]subscription.  This is provided as a general service for those people who
]cannot receive the newsgroup for whatever reason or who just prefer to
]receive messages via e-mail.

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

	subscribe perl-users
or:
	unsubscribe perl-users

to almanac@ruby.oce.orst.edu.  

To submit articles to comp.lang.perl.misc (and this Digest), send your
article to perl-users@ruby.oce.orst.edu.

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

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

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

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

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


------------------------------
End of Perl-Users Digest V8 Issue 4449
**************************************

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