[15477] in Perl-Users-Digest

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

Perl-Users Digest, Issue: 2887 Volume: 9

daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Fri Apr 28 06:05:36 2000

Date: Fri, 28 Apr 2000 03:05:20 -0700 (PDT)
From: Perl-Users Digest <Perl-Users-Request@ruby.OCE.ORST.EDU>
To: Perl-Users@ruby.OCE.ORST.EDU (Perl-Users Digest)
Message-Id: <956916320-v9-i2887@ruby.oce.orst.edu>
Content-Type: text

Perl-Users Digest           Fri, 28 Apr 2000     Volume: 9 Number: 2887

Today's topics:
        "tailing" to a filehandle <support@nidlink.com>
    Re: "tailing" to a filehandle <rhomberg@ife.ee.ethz.ch>
    Re: [REGEXP] Extremely important please read! <gellyfish@gellyfish.com>
        Bijeenkomst Amsterdam Perl Mongers, Dinsdag 2 Mei 2000 johnpc@xs4all.nl
    Re: changing first character of string to upper case <gellyfish@gellyfish.com>
    Re: changing first character of string to upper case <gellyfish@gellyfish.com>
    Re: changing first character of string to upper case (Bart Lateur)
    Re: deleting a record in a TEXT database? <jeff@vpservices.com>
    Re: Disk Space <gellyfish@gellyfish.com>
    Re: DLL attributes <gellyfish@gellyfish.com>
    Re: DLL Dilemma <ppi@searchy.net>
        RE: File Parsing scarey_man@my-deja.com
        filehandles, forking, and alpha-dec_osf nwhite210@my-deja.com
    Re: Getting start with perl anursalim@my-deja.com
    Re: Getting start with perl (Bart Lateur)
    Re: Help with Linux & Perl command line <gellyfish@gellyfish.com>
        How could I control session with perl? <ya_hsiung@ms2.url.com.tw>
        initialize hash to empty? <schan_ca@geocities.com>
    Re: initialize hash to empty? <Frederic.Aussedat@Alcatel.fr>
    Re: initialize hash to empty? <rhomberg@ife.ee.ethz.ch>
    Re: initialize hash to empty? <rhomberg@ife.ee.ethz.ch>
    Re: Installing Perl <gellyfish@gellyfish.com>
    Re: JARQ (Just Another Regex Question) <uri@sysarch.com>
    Re: JARQ (Just Another Regex Question) jlamport@calarts.edu
        Need Help!! CGI (Perl) Problem?!! <k2_1999@hotmail.com>
    Re: Need Help!! CGI (Perl) Problem?!! <borg@aborg.com>
        order of (keys %foo) eq order of (values %foo) ? <paulboldra@my-deja.com>
    Re: order of (keys %foo) eq order of (values %foo) ? (Douglas Wilson)
    Re: order of (keys %foo) eq order of (values %foo) ? <lr@hpl.hp.com>
    Re: order of (keys %foo) eq order of (values %foo) ? <paulboldra@my-deja.com>
        Digest Administrivia (Last modified: 16 Sep 99) (Perl-Users-Digest Admin)

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

Date: Thu, 27 Apr 2000 12:14:21 -0700
From: "jim" <support@nidlink.com>
Subject: "tailing" to a filehandle
Message-Id: <8ea7sq$pbk$1@faile.nidlink.com>

Hi all,
    I'm trying to tail a log file and access that info using a filehandle
for proccessing, but I can't get it to work.  The basic idea I'm hung up on
is this:

$output=`tail -F /usr/local/logfile`;
open(IN, "$output");
while(<IN>){
print STDOUT;
#parse the stuff here as it comes in
}

When I run this, I see "tail -F /usr/local/logfile" in the proccess list,
but I get no output.
What am I doing wrong?

Any help or suggestions would be greatly appreciated, whether following my
current path or otherwise.

Thanx,
    Jim




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

Date: Fri, 28 Apr 2000 11:04:09 +0200
From: Alex Rhomberg <rhomberg@ife.ee.ethz.ch>
Subject: Re: "tailing" to a filehandle
Message-Id: <39095409.E87C6739@ife.ee.ethz.ch>

jim wrote:
> 
> Hi all,
>     I'm trying to tail a log file and access that info using a filehandle
> for proccessing, but I can't get it to work.  The basic idea I'm hung up on
> is this:
> 
> $output=`tail -F /usr/local/logfile`;

Let me count the ways why this is wrong... buffer overflow
it's tail -f, not -F on the Linux, Solaris and IRIX boxen I have access
to

with the backticks, you are catching the output of the command in
$output. Assuming that tail -F is supposed to do what tail -f does on
unix, the command will never return, as backticks wait for the
completion of the command.

And where the hell do you put your logfiles?

> open(IN, "$output");
If the script would ever reach this place, $output would contain some
parts of your logfile. You try to use that as filename to open it??

Following your current path, you can

open IN,"tail -f /var/log/logfile |" or die "bye: $!";

while(<IN>) {


You could also roll your own in perl:

open LOGF, '/var/log/logfile' or die $!;
seek(LOGF, somewhere near the end to get tail effect)

while(1) {
  if(defined($_ = <LOGF>)) {
    do your processing
  } else {
    select() to wait for new data in logfile, see perldoc -f select
  }
}


Thirdly, you could pipe the tail output to your perlscript and read from
<> in the script:

tail -f /var/log/logfile|perl -pe's/2000/19100/'

- Alex


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

Date: 28 Apr 2000 07:26:02 +0100
From: Jonathan Stowe <gellyfish@gellyfish.com>
Subject: Re: [REGEXP] Extremely important please read!
Message-Id: <8ebatq$pc$1@orpheus.gellyfish.com>

On Wed, 26 Apr 2000 21:18:01 +0200 Charles Henry wrote:
>
> That was done on purpose. I never type all caps so as not to be filtered.
> 

Maybe we should just filter all your posts regardless then.

/J\
-- 
Yes, honey...Just squeeze your rage up into a bitter little ball and
release it at an appropriate time, like that day I hit the referee with
the whiskey bottle.
-- 
fortune oscar homer


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

Date: 28 Apr 2000 00:49:41 +0200
From: johnpc@xs4all.nl
Subject: Bijeenkomst Amsterdam Perl Mongers, Dinsdag 2 Mei 2000
Message-Id: <8eag65$5to$1@xs4.xs4all.nl>
Keywords: Amsterdam.pm meeting 2 mei xxLINK

[English version follows the dutch text]  

Amsterdam.pm staat voor de "Amsterdamse Perl Mongers", een groep van
gebruikers van Perl. In tegenstelling tot wat de naam suggereert is
Amsterdam.pm niet beperkt tot alleen Amsterdam, maar functioneert, tot
er meer gebruikersgroepen in Nederland zijn, als Nederlandse
gebruikersgroep.

Amsterdam.pm organiseert informele bijeenkomsten waar Perl gebruikers
kunnen samenkomen en informatie en gebruikservaringen met betrekking
tot Perl kunnen uitwisselen. Deze bijeenkomsten vinden normaliter
plaats op elke eerste dinsdag van de maand. De voertaal binnen
Amsterdam.pm is in pricipe Nederlands, maar indien nodig zal Engels
worden gebruikt, b.v. om te communiceren met niet-Nederlandssprekende
aanwezigen.

De eerstvolgende bijeenkomst vindt plaats op dinsdag 2 mei 2000 van
20:00 tot 22:00 uur op het kantoor van xxLINK, Nieuwezijdsvoorburgwal 68-70.
Voor meer details, waaronder een routebeschrijving, zie
http://www.amsterdam.pm.org/Meetings/next_meeting.html

Liefhebbers van een etentje vooraf kunnen tussen 17:45 en 18:15
verzamelen bij café Maximiliaan. Om 18:15 (écht om 18:15!) zoeken we een
restaurantje in de buurt om een hapje te eten.

Bezoek onze Web site http://www.Amsterdam.pm.org voor meer details.

[English version]

Amsterdam.pm stands for the Amsterdam Perl Mongers. We're basically a
Perl user group. Despite its name, it is not local to the Amsterdam
environment, but it welcomes Perl mongers from all over the
Netherlands.

Amsterdam.pm organises informal meetings where Perl users can meet,
and exchange information and experiences with regard to using Perl.  
The meetings are normally held every first Tuesday of the month.
Although the preferred language for communication is Dutch, English
will be spoken if necessary.

Our next meeting is Tuesday May 2nd, 2000, from 20:00 till 22:00
at the office of xxLINK, Nieuwezijdsvoorburgwal 68-70.
See http://www.amsterdam.pm.org/Meetings/next_meeting.html for
more detail and the directions to the xxLINK office.

Should you want to join some of us for dinner, please gather between
17:45 and 18:15 at café Maximiliaan. At 18:15 sharp we'll leave for a
restaurant somewhere nearby for dinner.

See http://www.Amsterdam.pm.org for more details.


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

Date: 28 Apr 2000 07:08:57 +0100
From: Jonathan Stowe <gellyfish@gellyfish.com>
Subject: Re: changing first character of string to upper case
Message-Id: <8eb9tp$t9j$1@orpheus.gellyfish.com>

On Thu, 27 Apr 2000 12:10:21 GMT exhacker@my-deja.com wrote:
> 
>> AHEM for any guru's reading this ... why doesn't the obvious work
>> ?
>> $string =~ tr/a-z/A-Z/;  # this should give you all caps ok...
> 
> this does mean increment and change case...
> read the man on tr (unix)
> % man tr
> 

I am not sure what reading the manpage for (an albeit similarly named)
unix utility is going to help with a Perl operator.

/J\
-- 
I'm glad you asked, son. Being popular is the most important thing in
the world.
-- 
fortune oscar homer


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

Date: 28 Apr 2000 07:19:31 +0100
From: Jonathan Stowe <gellyfish@gellyfish.com>
Subject: Re: changing first character of string to upper case
Message-Id: <8ebahj$v8f$1@orpheus.gellyfish.com>

On Thu, 27 Apr 2000 04:30:46 -0700 jb wrote:
> Tony <anthony@nexus.uk.com> wrote in message
> news:V%TN4.25$u4.613@news.enterprise.net...
>> Hi all,
>>
>>
>> I want to change the first character to Upper case but I can't seem to get
>> it.
>>
>
> It's rather amusing and frustrating that the obvious doesn't work in this
> situation...   cut and paste the following and you can see... the last is
> correct.   AHEM for any guru's reading this ... why doesn't the obvious work
> ?
> 

The obvious.  right.

> #!/usr/bin/perl
> 
> $string = "tony";
> 
> print " 1 $string\n";
> 
> $string =~ tr/a-z/A-Z/;  # this should give you all caps ok...
> 

Yes.  But most people would use the uc() function.

> print "$string\n";
> 
> $string = "markanthony";
> 
> print " 1.1 $string\n";
> 
> $string =~ tr/^[a-z]/[A-Z]/;  # this should give you first letter capped...
> but no
> # it actually increments the letters by one value then capitalizes all of
> them... ???

Er yes.  As one who had read the documentation would expect it to.  You
seem to be confusing the translation operator with something else.

You are translating ^ to [, [ to A, b to A etc etc ...  The left hand part
of the tr/// oeprator is *not* a regular expression and all characters
found there are taken as literals and converted to the one in the
equivalent position in the right hand part.

Use the ucfirst function.

/J\
-- 
What is abnormal in Life stands in normal relations to Art. It is the
only thing in Life that stands in normal relations to Art.
-- 
fortune oscar homer


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

Date: Fri, 28 Apr 2000 09:49:18 GMT
From: bart.lateur@skynet.be (Bart Lateur)
Subject: Re: changing first character of string to upper case
Message-Id: <390d5d95.5921738@news.skynet.be>

Tony wrote:

>I need to get a word from a strig and use it twice:
>
>I use the orginal all lower case version for something else, and I duplicate
>it into another $string for browser display.

You could, using ucfirst($string). But you don't have to. put "\u" in
your ready-for-interpolation string, and you've got what you want.

$string = "books";
print<<"EOT";
Here's what you've got: \u$string.
EOT

-- 
	Bart.


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

Date: Thu, 27 Apr 2000 21:40:21 -0700
From: Jeff Zucker <jeff@vpservices.com>
Subject: Re: deleting a record in a TEXT database?
Message-Id: <39091635.B8058C74@vpservices.com>

Mindunwind Sales Department wrote:
> 
> any idea how to do this?  Thanks a bunch for tthe help

Let's imagine that your text database is stored in file_FRUMP, in
format_FOO (which could be comma separated, or tab "delimited", or pipe
"delimited", or fixed record, or ??? who knows since you haven't given
us any clues), and that you want to delete records where column_BAR is
equal to value_BAZ (e.g. lastname is equal to 'Smith'), then you could
install DBI and DBD::RAM and do this, replacing those made up things
with the real values:

#!perl -w
use strict;
use DBI;
my $dbh=DBI->connect('DBI:RAM:',,,{RaiseError=>1});
$dbh->func([['table1','format_FOO','file_FRUMP']],'catalog');
$dbh->do(qq{DELETE FROM table1 WHERE column_BAR = 'value_BAZ'});
__END__

This can be used with a number of text database formats (including all I
mentioned above and others) and can work to delete a single record or a
group of records using a simple search like this one, or any number of
more complicated selection criteria.  If that doesn't work for you, come
back and share some specifics of what format your data is in and what
criteria you want to use to delete things.

-- 
Jeff


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

Date: 28 Apr 2000 07:00:43 +0100
From: Jonathan Stowe <gellyfish@gellyfish.com>
Subject: Re: Disk Space
Message-Id: <8eb9eb$roa$1@orpheus.gellyfish.com>

On Thu, 27 Apr 2000 09:19:02 -0700 Peter wrote:
> In article <864n5g$sd7$1@bob.news.rcn.net>, "Chaos"
> <Chaos@foo.com> wrote:
>>Does anyone know how to do either of the following in Win32:
>>
>> 1. Get the free disk space
>> 2. A DIR equivalent command within Perl
>> 3. Redirect a system call like SYSTEM("DIR") to perl without using a tmp
>> file so I can manipulate the output of the call.
>>
>
> 1. I also searched newsgroup for this and could not find a
> solution for my problem, so I made the following code, it's
> perhaps not "Art-of-perl" but it's working.
> 
> foreach $_ (`dir c:`){s/ //g;if (/bytesfree/) {$space=$`;}}
> 
> $space contain then a value like : 165,863,424
> 
> This is based on a classic nt 4 ntfs directory layout.
> Pay attention,  `  is a backquote.
> 

There is also the module Win32::DriveInfo which might help.

> 2. Perl come with a lot of directory function, like opendir(),
> closedir(), readdir().  But I prefer to use DirHandle method,
> check you documentation.
> 

Yes. Check the documentation :

       The only objective benefit to using `DirHandle' is that it
       avoids namespace pollution by creating globs to hold
       directory handles.

;-}

You might want to consider IO::Dir (also part of the standard distribution)
if you want to use a module to do this.

> 3. I think it's not possible to redirect system() and exec() to a
> perl variable, but you can use the following method :
> 
> @var=`dir c:`;
> 
> Here backquotes are also used.  The result of DIR C: is send to
> @var.
> 

You might want to look at the perlipc manpage for other alternatives.
These include but are not limited to 'piped open' and IPC::Open2.

/J\
-- 
Ah, good ol' trustworthy beer. My love for you will never die.
-- 
fortune oscar homer


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

Date: 28 Apr 2000 07:50:44 +0100
From: Jonathan Stowe <gellyfish@gellyfish.com>
Subject: Re: DLL attributes
Message-Id: <8ebcc4$5d2$1@orpheus.gellyfish.com>

On Wed, 26 Apr 2000 15:01:42 -0400 David Stiff wrote:
> Is there a way in Perl I can get the Company Name of a DLL? (The equivalent
> of checking the Properties of the DLL in Windows).

If this possible then there will almost certainly be some Win32::* module
that will help you do it.  Otherwise you will need to find the 
specification of the Windows DLL EXE header from say microsofts site or
a group that discusses windows programming and then use a regular
expression, unpack, substr or some other Perl facility to get at the
information. If there is no module to do this and you end up doing it
yourself please consider creating a module and submitting it to CPAN
so others might benefit.

/J\
-- 
It's not easy to juggle a pregnant wife and a troubled child, but somehow
I managed to squeeze in 8 hours of TV a day.
-- 
fortune oscar homer


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

Date: Fri, 28 Apr 2000 10:46:06 +0200
From: Penpal International <ppi@searchy.net>
Subject: Re: DLL Dilemma
Message-Id: <39094FCE.1566EE5@searchy.net>

Use linux... You won't have any DLL Dilemma's anymore :-)

ICP wrote:
> 
> Hi,
> 
> I am using active perl with WinNT and I am searching for a tool, that
> lists me all versions of all installed DLLs and writes it into a file.
> Has someone written a script to do this or is there a library, which can
> do that? Or how can I read the version numbers calling the Windows API?
> 
> (Sorry, if You read this twice, but I couldn't see this in the newsgroup
> ...)
> 
> Thanks,
> 
> Ralf
> 
> --
> Ralf Peine
> Siemens AG (ICM CD DP D 4): Bluetooth Products
> ralf.peine@bch.siemens.de
> http://www.jupiter-programs.de

-- 
Penpal International
http://ppi.searchy.net/
ppi@searchy.net


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

Date: Fri, 28 Apr 2000 09:54:06 GMT
From: scarey_man@my-deja.com
Subject: RE: File Parsing
Message-Id: <8ebn3q$c51$1@nnrp1.deja.com>


> >If I have a file with the following line:
> >aaaa    bbbb  cccc       dddd
> >how can I read the line into an array using split, even though the
> >field separators are different lengths each time e.g. 4 spaces, and
> >then 2 spaces?
>

Thanks to all who replied but here is my solution and it works
(using $_)
        $/ = "\w";
        @items =split;

Thanks again.


Sent via Deja.com http://www.deja.com/
Before you buy.


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

Date: Fri, 28 Apr 2000 04:07:55 GMT
From: nwhite210@my-deja.com
Subject: filehandles, forking, and alpha-dec_osf
Message-Id: <8eb2qj$mbc$1@nnrp1.deja.com>



I'm having some difficulty using fork with open filehandles
on alpha machines.  It seems that a fork() on an alpha machine
confuses the state of any open filehandles in the parent
process.  I've written a little program that illustrates
the problem:

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

open( FILE, "file" ) or die "Couldn't open file\n";

while( <FILE> ){
    chomp $_;
    if ( $pid = fork() ){
        # PARENT PROCESS
        print STDERR "reading line $. = $_\n";
    }
    elsif ( defined $pid ){
        # CHILD PROCESS
        close FILE or die "Couldn't close FILE\n";
        exit( 0 );
    }
    else{
       die "Couldn't fork\n";
    }
}

where "file" is
line1
line2
line3
line4

Now, on a linux machine running perl 5.005_03 for i386-linux, the
results are as expected:
reading line 1 = line1
reading line 2 = line2
reading line 3 = line3
reading line 4 = line4

On an OSF1 v4.0 1229 alpha running perl 5.005_03 for alpha-dec_osf,
I get:
reading line 1 = line1
reading line 2 = line2
reading line 3 = line3
reading line 4 = line4
reading line 5 = line1
reading line 6 = line2
reading line 7 = line3
reading line 8 = line4
reading line 9 = line1
reading line 10 = line2
reading line 11 = line3
reading line 12 = line4
 ...
(infinite loop)

This program illustrates how the filehandle gets confused
but does not illustrate intermittent data corruption from
the open filehandle, which I've experienced.

Is this a bug with 5.005_03 for alpha-dec_osf?

My apologizes if this question has been answered recently.
My search for a similar post yielded 1 hit with no reply:
http://x44.deja.com/[ST_rn=ps]/getdoc.xp?AN=477485997&CONTEXT=956886684.
385089536&hitnum=75

Regards,
Neill


Sent via Deja.com http://www.deja.com/
Before you buy.


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

Date: Fri, 28 Apr 2000 08:26:52 GMT
From: anursalim@my-deja.com
Subject: Re: Getting start with perl
Message-Id: <8ebi02$70m$1@nnrp1.deja.com>

In article <390909B8.637B2732@ti.com>,
  norazman@ti.com wrote:
> Hi,
>
> Sorry but I have to ask this question.
>
> I downloaded Perl from ActiveState.
> While reading perl, I understand to connect to database I have to use
DBI/DBD
> module.
> So I download it from DBI site.
>
> I have once  create cgi with vb but vb is gui so any module can
easily get
> integrated.
> Can anybody explain to how to do with perl (integrating new module so
that it
> can be use
> by my exixting perl)
>
> My perl is inside C:\perl
> After download DBI, it was in .tar compressed format, but i've
extract it to
> C:\DBD
> Now how can I intergrate this 2 together.
>
> Thanks.

Put the DBI module under correct directory eg : perl/lib/ or include it
in your @INC.
To call the module : use DBI; (inside your perl script)


Sent via Deja.com http://www.deja.com/
Before you buy.


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

Date: Fri, 28 Apr 2000 09:38:40 GMT
From: bart.lateur@skynet.be (Bart Lateur)
Subject: Re: Getting start with perl
Message-Id: <390b5a1f.5035524@news.skynet.be>

Norazman Abu Sahir wrote:

>I downloaded Perl from ActiveState.
>While reading perl, I understand to connect to database I have to use DBI/DBD
>module.
>So I download it from DBI site.

>Can anybody explain to how to do with perl (integrating new module so that it
>can be use by my exixting perl)

You may have downloaded it from the wrong site. Have you got it from
<http://www.activestate.com/ppmpackages/>? Please do, download the
appropriate ZIP file(s), and use the installer mechanism that comes with
Activestate Perl (PPM). It's uses a Perl script as a "make" tool for
modules; it will install the modules for you. Instructions are simple,
and included. Unpack the ZIP, including original folders, but don't
unpack the .tar.gzip file. the installer does that for you.

You need a DBD module specific for the database binary you intend to
use.

   HTH,
   Bart.


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

Date: 28 Apr 2000 07:59:41 +0100
From: Jonathan Stowe <gellyfish@gellyfish.com>
Subject: Re: Help with Linux & Perl command line
Message-Id: <8ebcst$71a$1@orpheus.gellyfish.com>

On Wed, 26 Apr 2000 16:10:52 -0400 Tad McClellan wrote:
> On Wed, 26 Apr 2000 13:13:04 -0600, Dave Klingler <davidk@excitehome.net> wrote:
>>I am trying to figure out how to write a one line Perl script which will
>>loop until a file is present on the system.  I don't know enough about Perl
>>to know how to write this line.  Does anyone have any ideas?
> 
> 
>    perl -we '1 until -e "some.file"'
> 


  PID USER     PRI  NI  SIZE  RSS SHARE STAT  LIB %CPU %MEM   TIME COMMAND
 6686 gellyfis  19   0  1020 1020   868 R       0 96.0  1.6   0:33 perl

;-}

/J\
-- 
There you go again, always taking someone else's side. Flanders, the
water department, God...
-- 
fortune oscar homer


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

Date: Fri, 28 Apr 2000 15:45:42 +0800
From: "netnews" <ya_hsiung@ms2.url.com.tw>
Subject: How could I control session with perl?
Message-Id: <8ebfg8$i33@netnews.hinet.net>

as title. Could somebody tell me commonly how to control session in perl
script?
Beside using form hidden field, how could I do it?




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

Date: Fri, 28 Apr 2000 08:18:49 GMT
From: steve <schan_ca@geocities.com>
Subject: initialize hash to empty?
Message-Id: <39094AB5.E4AE767F@geocities.com>

Hello:

How do I initialize a hash to empty?

For an array, I do:

    @array = ();

but how for a hash

    %hash = ();

???

Thanks
Steve





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

Date: Fri, 28 Apr 2000 10:31:42 +0200
From: Frederic Aussedat <Frederic.Aussedat@Alcatel.fr>
Subject: Re: initialize hash to empty?
Message-Id: <39094C6E.8D086C63@Alcatel.fr>

do

%hash={};

regards
Frederic

steve a écrit:
> 
> Hello:
> 
> How do I initialize a hash to empty?
> 
> For an array, I do:
> 
>     @array = ();
> 
> but how for a hash
> 
>     %hash = ();
> 
> ???
> 
> Thanks
> Steve


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

Date: Fri, 28 Apr 2000 11:06:05 +0200
From: Alex Rhomberg <rhomberg@ife.ee.ethz.ch>
Subject: Re: initialize hash to empty?
Message-Id: <3909547D.4E443AE8@ife.ee.ethz.ch>

steve wrote:

> How do I initialize a hash to empty?

> but how for a hash
> 
>     %hash = ();

What was the result when you tried it?

Tip:
perldoc Data::Dumper to find out how to examine data structures.

- Alex


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

Date: Fri, 28 Apr 2000 11:10:08 +0200
From: Alex Rhomberg <rhomberg@ife.ee.ethz.ch>
Subject: Re: initialize hash to empty?
Message-Id: <39095570.7ED9368C@ife.ee.ethz.ch>

Frederic Aussedat wrote:
> 
> do
> 
> %hash={};

The number of things you did wring in this short post is amazing:

- You answered jeopardy style
- You didn't test it
- It is plain wrong
- It gives a warning when used with -w

- Alex


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

Date: 28 Apr 2000 08:02:39 +0100
From: Jonathan Stowe <gellyfish@gellyfish.com>
Subject: Re: Installing Perl
Message-Id: <8ebd2f$7j6$1@orpheus.gellyfish.com>

On Wed, 26 Apr 2000 21:30:23 GMT Marcus wrote:
>     I have a dedicated server with Red Hat Linux 6.1 and I need to install
> perl to work with my /home/httpd/cgi-bin directory. I have no idea where to
> start.... Is perl a free program? I have only previously edited scripts and
> uploaded them to a cgi-bin. Any help would be very appreciated.

You have Perl installed.  You will want to ask in the groups :

   comp.infosystems.www.servers.unix
   comp.infosystems.www.authoring.cgi

about any other issues you may have.

/J\
-- 
Well, let's just call them, uh, Mr. X and Mrs. Y. So anyway, Mr.X would
say, 'Marge, if this doesn't get your motor running, my name isn't Homer
J. Simpson.'
-- 
fortune oscar homer


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

Date: Fri, 28 Apr 2000 04:15:17 GMT
From: Uri Guttman <uri@sysarch.com>
Subject: Re: JARQ (Just Another Regex Question)
Message-Id: <x7vh122758.fsf@home.sysarch.com>

>>>>> "MS" == Matthew Stoker <matt.stoker@motorola.com> writes:

  MS> I need to search through a file for the first occurance of the phrase
  MS> "NUMBER OF COWS", however if the matching phrase is preceded by a ! on
  MS> the same line, it is a comment and should not match. Can this be done
  MS> with a single regex?

  MS> After running the desired value of $line would be:

  MS> BIG NUMBER OF COWS ! LARGE NUMBER OF COWS

use lookahead.

this only matches if there is not a ! between the start of the line and
the phrase. also i used a while loop so i can prime $line with a line of
text. you can invert to an until loop if you want

while( $line = <DATA> ) {
	last if $line =~ /^[^!]*(?=NUMBER OF COWS)/ ;
}

or a single line with until:

$line = <DATA> until $line =~ /^[^!]*(?=NUMBER OF COWS)/ ;


print $line ;

__END__
SOME JUNK
! THIS IS A COMMENT
COUNT BESSY'S ! NUMBER OF COWS
! NUMBER OF COWS ! NUMBER OF COWS
! COUNT THE NUMBER OF COWS
MORE JUNK
BIG NUMBER OF COWS ! LARGE NUMBER OF COWS
SMALL NUMBER OF COWS
FINAL JUNK

prints:
BIG NUMBER OF COWS ! LARGE NUMBER OF COWS

uri

-- 
Uri Guttman  ---------  uri@sysarch.com  ----------  http://www.sysarch.com
SYStems ARCHitecture, Software Engineering, Perl, Internet, UNIX Consulting
The Perl Books Page  -----------  http://www.sysarch.com/cgi-bin/perl_books
The Best Search Engine on the Net  ----------  http://www.northernlight.com


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

Date: Fri, 28 Apr 2000 07:47:46 GMT
From: jlamport@calarts.edu
Subject: Re: JARQ (Just Another Regex Question)
Message-Id: <8ebfmv$4l9$1@nnrp1.deja.com>

In article <x7vh122758.fsf@home.sysarch.com>,
  Uri Guttman <uri@sysarch.com> wrote:
> >>>>> "MS" == Matthew Stoker <matt.stoker@motorola.com> writes:
>
>   MS> I need to search through a file for the first occurance of the phrase
>   MS> "NUMBER OF COWS", however if the matching phrase is preceded by a ! on
>   MS> the same line, it is a comment and should not match. Can this be done
>   MS> with a single regex?
>
>   MS> After running the desired value of $line would be:
>
>   MS> BIG NUMBER OF COWS ! LARGE NUMBER OF COWS
>
> use lookahead.
>
> this only matches if there is not a ! between the start of the line and
> the phrase. also i used a while loop so i can prime $line with a line of
> text. you can invert to an until loop if you want
>
> while( $line = <DATA> ) {
> 	last if $line =~ /^[^!]*(?=NUMBER OF COWS)/ ;
> }
>
> or a single line with until:
>
> $line = <DATA> until $line =~ /^[^!]*(?=NUMBER OF COWS)/ ;

What's the purpose of the lookahead?  It seems to me that

$line=<FILEHANDLE> until ($line =~ /^[^!]*NUMBER OF COWS/);

will do exactly what the OP wanted, without the extra clutter.  Or am I
missing something?

-jason


Sent via Deja.com http://www.deja.com/
Before you buy.


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

Date: Fri, 28 Apr 2000 05:45:34 GMT
From: "Kelvin" <k2_1999@hotmail.com>
Subject: Need Help!! CGI (Perl) Problem?!!
Message-Id: <2A9O4.867$%u6.52490@news1.telusplanet.net>

I'm new to cgi but very interesting to learn.
I wrote a cgi script today and upload it to my rent server.(CI HOST)
And after I uploaded and chmod it to 755.
I tried run it in the browser, but the script is not running.
Instead, the browser shows a pop-up windows and ask me to download the cgi
file!!

Why is that??
Here is the script, and u can see the problem!!
http://63.249.232.250/cgi-bin/k2.cgi

Thanks very much
Kelvin
kelvinsun@hotmail.com





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

Date: Fri, 28 Apr 2000 06:26:40 GMT
From: borg <borg@aborg.com>
Subject: Re: Need Help!! CGI (Perl) Problem?!!
Message-Id: <39092F3E.EADD3608@aborg.com>

Check with the host what extension they use. ie.  .cgi or .pl  and make sure
it is in the cgi-bin, or the web server will not know what to do with a .cgi

hope that helps :-)
Peter

___________________

Kelvin wrote:

> I'm new to cgi but very interesting to learn.
> I wrote a cgi script today and upload it to my rent server.(CI HOST)
> And after I uploaded and chmod it to 755.
> I tried run it in the browser, but the script is not running.
> Instead, the browser shows a pop-up windows and ask me to download the cgi
> file!!
>
> Why is that??
> Here is the script, and u can see the problem!!
> http://63.249.232.250/cgi-bin/k2.cgi
>
> Thanks very much
> Kelvin
> kelvinsun@hotmail.com



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

Date: Fri, 28 Apr 2000 04:06:44 GMT
From: bruno <paulboldra@my-deja.com>
Subject: order of (keys %foo) eq order of (values %foo) ?
Message-Id: <8eb2oc$map$1@nnrp1.deja.com>

Pretty straightforward question:
is the order of keys returned by (keys %foo) the same as the order of
values returned by (values %foo) ?

eg, does the following script ever die:

@vals = (values %foo);
foreach(keys %foo) {
  ($foo{$_} eq $vals[$i]) || die("Different order!\n");
  $i++;
}

Thanks



Sent via Deja.com http://www.deja.com/
Before you buy.


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

Date: Fri, 28 Apr 2000 05:29:45 GMT
From: dwilson@gtemail.net (Douglas Wilson)
Subject: Re: order of (keys %foo) eq order of (values %foo) ?
Message-Id: <39091dd4.3261185@news>

On Fri, 28 Apr 2000 04:06:44 GMT, bruno <paulboldra@my-deja.com> wrote:

>Pretty straightforward question:
>is the order of keys returned by (keys %foo) the same as the order of
>values returned by (values %foo) ?

RTFM
perldoc -f keys
perldoc -f values

HTH,
Douglas Wilson


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

Date: Thu, 27 Apr 2000 22:30:05 -0700
From: Larry Rosler <lr@hpl.hp.com>
Subject: Re: order of (keys %foo) eq order of (values %foo) ?
Message-Id: <MPG.1372c1b013d5911998a99d@nntp.hpl.hp.com>

In article <8eb2oc$map$1@nnrp1.deja.com> on Fri, 28 Apr 2000 04:06:44 
GMT, bruno <paulboldra@my-deja.com> says...
> Pretty straightforward question:
> is the order of keys returned by (keys %foo) the same as the order of
> values returned by (values %foo) ?

Pretty strightforward answer:
read the documentation for either of these functions.

perldoc -f keys
perldoc -f values

Or do you think the purpose of Usenet is to help you find someone to 
read the documentation to you?

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


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

Date: Fri, 28 Apr 2000 06:18:31 GMT
From: bruno <paulboldra@my-deja.com>
Subject: Re: order of (keys %foo) eq order of (values %foo) ?
Message-Id: <8ebaff$u8g$1@nnrp1.deja.com>

In article <MPG.1372c1b013d5911998a99d@nntp.hpl.hp.com>,
  Larry Rosler <lr@hpl.hp.com> wrote:
> In article <8eb2oc$map$1@nnrp1.deja.com> on Fri, 28 Apr 2000 04:06:44
> GMT, bruno <paulboldra@my-deja.com> says...
> > Pretty straightforward question:
> > is the order of keys returned by (keys %foo) the same as the order
of
> > values returned by (values %foo) ?
>
> Pretty strightforward answer:
> read the documentation for either of these functions.
>
> perldoc -f keys
> perldoc -f values
>
> Or do you think the purpose of Usenet is to help you find someone to
> read the documentation to you?
>
No, I think its purpose is to give kind souls the opportunity to point
lost coders in the right direction.  Works well too.

Thanks for your help.



Sent via Deja.com http://www.deja.com/
Before you buy.


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

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


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