[17734] in Perl-Users-Digest

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

Perl-Users Digest, Issue: 5154 Volume: 9

daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Tue Dec 19 21:05:32 2000

Date: Tue, 19 Dec 2000 18:05:10 -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: <977277910-v9-i5154@ruby.oce.orst.edu>
Content-Type: text

Perl-Users Digest           Tue, 19 Dec 2000     Volume: 9 Number: 5154

Today's topics:
        [HD] Re: I will pay for it Re: How to put each line of  jvwright@my-deja.com
        access a shared drive stong123@my-deja.com
    Re: access a shared drive <harrisr@bignet.net>
        Apache + mod_perl + JSP <victor@ubiquity.co.nz>
    Re: Apache <johngros@Spam.bigpond.net.au>
    Re: backslah as a normal char <abe@ztreet.demon.nl>
        Boolean context in grep <matt@cipherdesign.com>
        Complete URL with perl? <gorgano@altavista.com>
    Re: Complete URL with perl? <tony_curtis32@yahoo.com>
    Re: Free servers with Perl support? <brondsem@my-deja.com>
        I need your help ! <getonme@ntlworld.com>
    Re: Perl substitution problem (David Efflandt)
    Re: Perl substitution problem <bart.lateur@skynet.be>
    Re: Perl to TCP/IP Connection & Overall Direction Neede <eric@hilding.com>
    Re: Perl to TCP/IP Connection & Overall Direction Neede <eric@hilding.com>
    Re: Perl to TCP/IP Connection & Overall Direction Neede <eric@hilding.com>
    Re: Perl's time function <mjcarman@home.com>
    Re: PPM question <johngros@Spam.bigpond.net.au>
    Re: problems with "sort" in NT <Petri_member@newsguy.com>
        Remote system monitoring <richard.flemming@virgine.net>
    Re: Remote system monitoring (Abigail)
    Re: splitting key/value pairs into a hash <tinamue@zedat.fu-berlin.de>
        testing if $_ is equal to some string? alazarev1981@my-deja.com
    Re: testing if $_ is equal to some string? <brondsem@my-deja.com>
    Re: testing if $_ is equal to some string? (Jerome O'Neil)
    Re: Upload Image don't refresh <brondsem@my-deja.com>
        Digest Administrivia (Last modified: 16 Sep 99) (Perl-Users-Digest Admin)

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

Date: Wed, 20 Dec 2000 00:52:05 GMT
From: jvwright@my-deja.com
Subject: [HD] Re: I will pay for it Re: How to put each line of a text area into a field
Message-Id: <91ovrj$t11$1@nnrp1.deja.com>

Hi Perry,

Another resource might consider trying for your Perl integration
questions is HotDispatch.

HotDispatch is a marketplace for programmer expertise where questions
often receive responses in less than an hour, and small programming
projects are often completed in less than 24 hours.   Prices can be
fixed, negotiable, or by bid.  As on auction services such as eBay,
participants who fail to meet their obligations risk their reputations
and their eligibility to participate.

HotDispatch includes an escrow service that takes care of the
accounting, so that you can pay for speedy solutions and tip for
heroic answers, without the overhead of getting physical addresses,
writing out a check, addressing an envelope, and finding a mailbox ---
all the things no one has time for during a time crunch.

  HotDispatch: the Market for Technical Expertise
  http://www.hotdispatch.com/home?aff=32819422

http://www.hotdispatch.com/listings/tasks/hotdispatch/katz211/desctime/t
asks-1.html?aff=32819422
  HotDispatch Corporate Accounts
  http://www.hotdispatch.com/epo1?aff=32819422

(...to solve problems quickly, offer quick rewards in return...:)

-- jvwright


Sent via Deja.com
http://www.deja.com/


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

Date: Tue, 19 Dec 2000 23:07:36 GMT
From: stong123@my-deja.com
Subject: access a shared drive
Message-Id: <91opnj$nqd$1@nnrp1.deja.com>

I have been trying to write a perl script to access a shared network
drive. The server is a NT 4 server and the client I am going to run the
script is a NT workstation. Both are in different domain. I tried
opendir(DIR, $shareddir) while $shareddir = "\\server\shareddirectory";
But I am pretty sure I can't use "\\".

I am running Active Perl.

TIA


Sent via Deja.com
http://www.deja.com/


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

Date: Tue, 19 Dec 2000 20:41:47 -0500
From: "Randy Harris" <harrisr@bignet.net>
Subject: Re: access a shared drive
Message-Id: <t403ho1dun70c5@corp.supernews.com>

<stong123@my-deja.com> wrote in message
news:91opnj$nqd$1@nnrp1.deja.com...
> I have been trying to write a perl script to access a shared network
> drive. The server is a NT 4 server and the client I am going to run
the
> script is a NT workstation. Both are in different domain. I tried
> opendir(DIR, $shareddir) while $shareddir =
"\\server\shareddirectory";
> But I am pretty sure I can't use "\\".
>
> I am running Active Perl.
>
> TIA

I'm still struggling to learn proper Perl style, but this works well for
me:

  $data_root = "\\\\server\\share";
  $map=`net use * $data_root /persistent:no`;
  if ($map !~ /^Drive/) {
   print "\n\nQuitting, unable to map data drive\n";
   exit;
  }
  $map =~ /(.:)/;

If successful, $map will contain the drive letter.

HTH
Randy Harris




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

Date: Wed, 20 Dec 2000 14:25:04 +1300
From: "Victor Chou" <victor@ubiquity.co.nz>
Subject: Apache + mod_perl + JSP
Message-Id: <2KT%5.502$RJV.30015677@news.xtra.co.nz>

I have an upcoming project involving setting up an Extranet. The site will
have security requirement listed below:

Each user will have an username/password pair, and on top of that will only
be allowed from a specific IP/range of IP (potentially different for each
user).

The problem is, none of the standard authentication modules on Apache will
support this (as far as I can tell) so I'm think about writing a custom
authentication module that checks the username/password/IP set against a
database.

The thing is the contents of the site will be partially developed in JSP, so
does mod_perl work as I imagine it to, and can be used to do this:

1. Joe user sends an HTTP request (with basic auth)
2. Apache gets the request, uses the custom mod_perl access control program
to verify it
3. If okay, gives ther use the resource, which happens to be in JSP so gets
thrown to the JServ(?) module

Reason not to just put the access control in JSP: there might be static
pages that need to be protected in that matter. My job is to make sure the
mechanism work regardless of who writes the JSP/other stuff.

There isn't enough time and I'm too much of a wimp to write an apache access
control module in C ;)




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

Date: Wed, 20 Dec 2000 00:40:08 GMT
From: "John Boy Walton" <johngros@Spam.bigpond.net.au>
Subject: Re: Apache
Message-Id: <IdT%5.25629$xW4.199034@news-server.bigpond.net.au>


> file. But when I press the submitbutton the stupid browser wants to
download
> the cgi-file instead of executing the script I called for.
>
> Why??
Could be the directory is not authorised as cgi-exec or your perl.exe is not
set to handle the script. Both problems are handled in http.conf in the conf
directory.
Look for the add handler directives, and the <directory> tag for your
cgi-bin add an option exec-cgi line.




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

Date: Wed, 20 Dec 2000 02:05:00 +0100
From: Abe Timmerman <abe@ztreet.demon.nl>
Subject: Re: backslah as a normal char
Message-Id: <b7104t0i0ncs65f3g54mvc4qomg26shmdg@4ax.com>

On 19 Dec 2000 09:19:55 GMT, lalot@univ-aix.fr (Lalot Dominique) wrote:

 ...
> I am trying to substitute NT registries with double \\ in the path
> and even \\\\ It's quite awfull to use 8 backslash..

You could have a look at

	Win32::TieRegistry

it seems to what you want.

-- 
Good luck,
Abe
perl -wle '$_=q@Just\@another\@Perl\@hacker@;print qq@\@{[split/\@/]}@'


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

Date: Wed, 20 Dec 2000 00:51:08 +0000
From: Matt Venn <matt@cipherdesign.com>
Subject: Boolean context in grep
Message-Id: <spvo19.8s1.ln@server.localnet>

Hey all,

So far:

$result = grep{ ( $temp ) = $text =~ /some(pattern)/; $c =~ /$_/ } @list;

Is the only way I can get grep to compare 'pattern' to $_ completely
within grep's {BLOCK}.

I _wanted_ to write something like this:

$result = grep{ $text=~/some(pattern)/ =~ /$_/ } @list;

but grep evaluates in a boolean context, so this doesn't work. (At least
I think thats why it doesn't work.

I know that its probably better to set $temp outside grep to make things
clearer. But is there a way around this?

Thanks,
Matt


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

Date: Wed, 20 Dec 2000 00:44:43 GMT
From: Jason Hurst <gorgano@altavista.com>
Subject: Complete URL with perl?
Message-Id: <91ovdq$skd$1@nnrp1.deja.com>

I’m sure this is a simple question to answer, or at least I hope it is,
but I just can’t seam to find one..  I’m trying to access the complete
url of a cgi program.  See I have a url like the following:

http://www.someware.com/foo.exe/stuff?foo=bar

Now I know how to access the ‘http://www.someware.com/foo.exe’ part and
I know how to access the ‘foo=bar’ part, but I can’t get the ‘stuff’
part.  I’d be surprised if there isn’t something in the %ENV hash, but
for the life of me I just can’t find it.  Any help would be greatly
appreciated!!

thanks in advance
-jason JAPH


Sent via Deja.com
http://www.deja.com/


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

Date: 19 Dec 2000 18:52:00 -0600
From: Tony Curtis <tony_curtis32@yahoo.com>
Subject: Re: Complete URL with perl?
Message-Id: <874rzz29u7.fsf@limey.hpcc.uh.edu>

>> On Wed, 20 Dec 2000 00:44:43 GMT,
>> Jason Hurst <gorgano@altavista.com> said:

> I’m sure this is a simple question to answer, or at least I hope it
> is, but I just can’t seam to find one..  I’m trying to access the
> complete url of a cgi program.  See I have a url like the following:

> http://www.someware.com/foo.exe/stuff?foo=bar

> Now I know how to access the ‘http://www.someware.com/foo.exe’ part
> and I know how to access the ‘foo=bar’ part, but I can’t get the
> ‘stuff’ part.

perldoc CGI

    path_info()

Also see

perldoc URI

about how to construct URLs.

hth
t
-- 
Eih bennek, eih blavek.


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

Date: Tue, 19 Dec 2000 23:49:48 GMT
From: Dave Brondsema <brondsem@my-deja.com>
Subject: Re: Free servers with Perl support?
Message-Id: <91os6p$q2f$1@nnrp1.deja.com>

In article <91nq2k$lm3$1@titan.bt.es>,
  "Navcomp" <qbertREMOVE@THISusuarios.retecal.es> wrote:
> Hello. I'm looking for a free UNIX-Linux server where I can put my
CGIs
> written in Perl while I learn the language (just for learning
purposes). I
> would need Telnet access and FTP too. Is there any server offering
this?
> Thank you.
>
> Navcomp.
>
>

I don't know about telnet access, but here are a few:

No ads (!):
www.f2s.com
www.portland.co.uk

Ads (but probably better service/support):
www.webprovider.com
www.virtualave.net

There are many sites that have databases of free hosts and the
different services they provide.  I'd suggest looking for one of these
if you want more information.


--
Dave Brondsema


Sent via Deja.com
http://www.deja.com/


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

Date: Wed, 20 Dec 2000 00:36:39 -0000
From: "getonme" <getonme@ntlworld.com>
Subject: I need your help !
Message-Id: <VbT%5.16440$T%5.275947@news6-win.server.ntlworld.com>



--
Please Help ! I am a newbie to the internet and have my own Web site " Big
Deal i here you say " Well it is to me, I need help setting up a perl script
called ilink from iweb, The script is installed on my site, however I cant
get the admin page to appear only a 500 error , I realise that some of the
files may need to be chmodded but dont want to make matters worse as i
havent got a clue, is there any one out there willing to setup this script
for me , in return i would be willing to place a link on every one of the
ilinks pages , please let me know Micheal .








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

Date: Tue, 19 Dec 2000 23:46:05 +0000 (UTC)
From: efflandt@xnet.com (David Efflandt)
Subject: Re: Perl substitution problem
Message-Id: <slrn93vspo.hbh.efflandt@efflandt.xnet.com>

On Tue, 19 Dec 2000 19:32:24 +0100, ofuuzo <ofuuzo@ub.uit.no> wrote:
>When I  fill a html  form for "Name"  with the following (for example):
>
> . Social Science
>      .  History
>      .  Economics
> . Science
>    . Mathematics
>    . Computer Science
>
>It appears exactly like that on the database.   I would like before the
>same data is displayed on the browser to undergo substitution. After the
>substitution, it would be converted to html tags:
>
><ul><li>Social Science</li>  <br>
><ul><li>History</li> <br>
><li>Economics</li></ul> <br>
><li>Science</li>
><ul><li>Mathematics</li><br>
><li>Computer Science</li>
></ul>
>
>I have tried ($row  =~ s/\n/<BR>/g; ......; but I could not get the
>correct subsitution.  I have read perl regular exp. and pattern
>matching, but no help. Can anyone help?

The textarea of a form is typically returned with carriage return,
linefeed pairs (regardless of browser OS), but "\n" on your system may be
something different.  So maybe you want to subtitute something for
\015\012, or something more universal that would catch any line ending is
(\015\012|[\015\012]).

-- 
David Efflandt  efflandt@xnet.com  http://www.de-srv.com/
http://www.autox.chicago.il.us/  http://www.berniesfloral.net/
http://cgi-help.virtualave.net/  http://hammer.prohosting.com/~cgi-wiz/


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

Date: Tue, 19 Dec 2000 23:50:25 GMT
From: Bart Lateur <bart.lateur@skynet.be>
Subject: Re: Perl substitution problem
Message-Id: <8srv3t45rgopnbtctsciathigg6uo8hf2i@4ax.com>

ofuuzo wrote:

>When I  fill a html  form for "Name"  with the following (for example):
>
> . Social Science
>      .  History
>      .  Economics
> . Science
>    . Mathematics
>    . Computer Science


>After the
>substitution, it would be converted to html tags:
>
><ul><li>Social Science</li>  <br>
><ul><li>History</li> <br>
><li>Economics</li></ul> <br>
><li>Science</li>
><ul><li>Mathematics</li><br>
><li>Computer Science</li>
></ul>

You realize, I hope, that your indentation is not constant? Whatever.
Let's just not depend on the exact count of spaces on the left, but on
the relative amount of spaces.

my %escape = ( '&' => '&amp;', '<' => '&lt;', '>' => '&gt;');
my @indent = 0;
print "<UL>\n";
while(<DATA>) {
    chomp;
    s/^( *)\. *//;
    if(length $1 > $indent[-1]) {
        push @indent, length $1;
        print "<UL>\n";
    } else {
        while(length $1 < $indent[-1]) {
            pop @indent;
            print "</UL>\n";
        }
    }
    s/(<>&)/$escape{$1}/g;
    print "<LI>$_\n";
}
print "</UL>\n" for 1 .. scalar @indent;
__DATA__
 . Social Science
     .  History
     .  Economics
 . Science
   . Mathematics
      . Algebra
      . Numerical Analysis
   . Computer Science

-- 
	Bart.


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

Date: Tue, 19 Dec 2000 15:15:11 -0800
From: Eric Hilding <eric@hilding.com>
Subject: Re: Perl to TCP/IP Connection & Overall Direction Needed
Message-Id: <3A3FEBFF.C49EEC20@hilding.com>

> In article <x7zohtdjo5.fsf@home.sysarch.com>, Uri Guttman
> <uri@sysarch.com> wrote:
 
>  | hire a perl programmer.

I may have to do this for part if I can't cut the mustard.  Please don't
cut me off at the knees until I've seen how far I can go with perhaps a
bit of assistance.  You have a very "Arrogant" attitude.  You must be
a real Perl "Guru" ???

>  |   EH> 5. E-mail a copy of the "New Info" data & also save it to an ASCII
>  |   .csv
>  |   EH>    flat file. I CAN DO THIS.

Umh, I've done many of these and plan to modify one of my existing
scripts.
Perhaps I *should* have said: "I have ALREADY done this before, and
should
be able to simply modify one of my existing VERY DETAILED scripts.

>  |
>  | are you sure? that is about the same difficulty as the first #5.
>  |
>  |   EH> 6. Perform the next "search" while still logged in to the remote
>  |   EH> system.
>  |   EH>    Hmmm... I THINK I CAN DO THIS.

>  | think harder.

Well, you certainly do have a way with words, Uri.  You must be one,
lean,
mean, super Perl programming stud wherever you are on the planet. With
that
kind of "Customer Service" attitude, you must be raking in the dough
from
consulting or something.  I do not every recall seeing such "arrogance"
on this newsgroup before...but all things change, I guess over the
years.

>  |
>  |   EH> 7. Log Off the remote database when all searches are done.  I CAN
>  |   DO
>  |   EH> THIS !!!

You apparently do NOT have a sense of humour.  I encourage you to find
one...
someplace!

>  |
>  | exit() ;
>  |
>  | uri
>


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

Date: Tue, 19 Dec 2000 15:21:45 -0800
From: Eric Hilding <eric@hilding.com>
Subject: Re: Perl to TCP/IP Connection & Overall Direction Needed
Message-Id: <3A3FED89.6F44A816@hilding.com>

Uri Guttman wrote:
>   EH> 1. Connect via Perl with TCP/IP to a remote database.  Is there
> 
> use IO::Socket
> 
Thank you very much for the info.

>   EH> 2. Issue a USER ID & Password to get in with appropriate "Pauses"
> 
> use Expect

Thank you very much again.

>   EH> 3. Based upon remote system "prompts", plug-in various search 
>
> again, expect should be fine for that

Great...there is light at the end of the tunnel it appears.
> 
>   EH> 4. Parse the "found" data.  I CAN DO THIS.
> 
> given your lack of other perl skills, i wonder about it.

Huh?  Where on earth did this comment come from?  I've already admitted
that I am somewhat clueless here, but willing to learn & invest in some
more instructinoal materials.
> 
>   EH> 5. Compare certain components of the "found" data to previously 

> hire a perl programmer.

I may have to end up doing that at some point...even if out of
frustration :-)

Hmmm...I've already responded to a copy of the rest of this in what I
saw
before the whole thing.  I do thank you for the "Helpful" comments, but
some of the rest of them really sucked, IMHO.


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

Date: Tue, 19 Dec 2000 15:36:30 -0800
From: Eric Hilding <eric@hilding.com>
Subject: Re: Perl to TCP/IP Connection & Overall Direction Needed
Message-Id: <3A3FF0FE.F25E90C7@hilding.com>

Monte Phillips wrote:
> 
> >1. Connect via Perl with TCP/IP to a remote database.  Is there already
> >some
> >   kind of module? I AM CLUELESS ON HOW TO APPROACH THIS.
> 
> What is your platform?  What is the remote servers platform?  What
> access security level do you have on each?  Do you have port 80 access
> to the remote?

Thanks for the reply, Monte:  What I've been able to determine at this
point is it's also a Unix system, and to port 23 via Telnet.  I'm 
waiting on a call back from someone who can clarify other info for me,
and to confirm the file format of the database output is Tab Delimited.

I can get anything I need out of it using HyperTerminal, but
Gheeezzzz...
it's such a Manual pain that I would like to automate as much as
possible.


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

Date: Tue, 19 Dec 2000 16:49:58 -0600
From: Michael Carman <mjcarman@home.com>
Subject: Re: Perl's time function
Message-Id: <3A3FE616.76B600@home.com>

charles_z@my-deja.com wrote:
> 
> I'm using Perl's time() function, and the output is always 
> 7 hours ahead of when I type 'date' on an x-term.  Where does 
> Perl get the current time?

The 7 hour difference is probably your offset from GMT. You can use the
localtime() function to covert this for your time zone.

-mjc


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

Date: Tue, 19 Dec 2000 23:32:14 GMT
From: "John Boy Walton" <johngros@Spam.bigpond.net.au>
Subject: Re: PPM question
Message-Id: <2eS%5.25574$xW4.196561@news-server.bigpond.net.au>


"Sven Franke" <snefsite@hotmail.com> wrote in message
news:91nb8b$9lm$1@enterprise.cistron.net...
> Hi,
> And which repositories do you use?
http://jenda.mcann.cz/perl/
http://www.roth.net/perl/packages/
http://rto.dk/packages/
http://www.xray.mpe.mpg.de/~ach/ptk/ppm
http://www.fastnetltd.ndirect.co.uk/Perl/zips/
http://www.ActiveState.com/PPMPackages/5.6






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

Date: 19 Dec 2000 14:29:11 -0800
From: Petri Oksanen <Petri_member@newsguy.com>
Subject: Re: problems with "sort" in NT
Message-Id: <91onfn01u65@edrn.newsguy.com>

In article <91okiq$jbu$1@nnrp1.deja.com>, estelnet@my-deja.com says...
> system "sort", "$dircgi/archive.dat", "-n", "-o",
> "$dircgi/archive2.dat";

> In Unix, it works... but in NT no...whats the porblem?

Why don't you just check what the correct syntax for 'sort' on NT is?
Try 'sort /?' to see what it says.


Petri Oksanen



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

Date: Tue, 19 Dec 2000 23:29:29 +0000
From: Richard Parrott <richard.flemming@virgine.net>
Subject: Remote system monitoring
Message-Id: <3A3FEF59.74B49A9F@virgine.net>

I would like to monitor the following on remote networked computers:

Monitor CPU load, how much resources the most cpu intensive
programmes use, and also monitor files produces by a programme i.e. data
files.

Please could someone point me in the right direction for any of the
above?

Many thanks in advance.

Regards,

Richard



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

Date: 20 Dec 2000 00:48:36 GMT
From: abigail@foad.org (Abigail)
Subject: Re: Remote system monitoring
Message-Id: <slrn9400f4.hf6.abigail@tsathoggua.rlyeh.net>

Richard Parrott (richard.flemming@virgine.net) wrote on MMDCLXVII
September MCMXCIII in <URL:news:3A3FEF59.74B49A9F@virgine.net>:
?? I would like to monitor the following on remote networked computers:
?? 
?? Monitor CPU load, how much resources the most cpu intensive
?? programmes use, and also monitor files produces by a programme i.e. data
?? files.
?? 
?? Please could someone point me in the right direction for any of the
?? above?


What the best way is depends on what's available on the remote system.
SNMP, rsh, ssh, client/server via sockets, emailing results, use of
NFS. I've done it all, but none of it is really Perl specific. You'd
face the same questions if you'd use any other language.



Abigail
-- 
my $qr = /^.+?(;).+?\1|;Just another Perl Hacker;|;.+$/;
   $qr =~ s/$qr//g;
print $qr, "\n";


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

Date: 20 Dec 2000 00:49:40 GMT
From: Tina Mueller <tinamue@zedat.fu-berlin.de>
Subject: Re: splitting key/value pairs into a hash
Message-Id: <91ovn4$4nc7p$2@fu-berlin.de>

hi,
Wolfgang S. <w-s@gmx.de> wrote:

> I'm trying to build a hash from a comma-seperated key/value list,
> eg. $string  = "0, foo, 1, bar, 2, baz"

how about that:
eval "%hash=($string)";

but be careful with eval(), the other suggestios
are probably a lot more safe
=)
TIMTOWTDI

tina


-- 
http://tinita.de    \  enter__| |__the___ _ _ ___
tina's moviedatabase \     / _` / _ \/ _ \ '_(_-< of
search & add comments \    \ _,_\ __/\ __/_| /__/ perception
please don't email unless offtopic or followup is set. thanx


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

Date: Tue, 19 Dec 2000 23:31:43 GMT
From: alazarev1981@my-deja.com
Subject: testing if $_ is equal to some string?
Message-Id: <91or4v$p5d$1@nnrp1.deja.com>

I'll make this as simple as possible.
My file name is "blah.xml". It consists of the following lines:

<?xml version="1.0"?>
<Junk>
xxx
</Junk>

I want to read each line of blah.xml into an array (@xmlFileArray) and
then test to see when I get to that line and put stuff in the line
before it. I'm trying to do it like this:

Here I put the file into the array:
open(XMLFILE, "<blah.xml");
$i=0;
while(<XMLFILE>) {
  @xmlFileArray[$i] = $_;
  $i++;
}
close(XMLFILE);

Here I add to the file:
open(XMLFILE, ">blah.xml");
$i=0;
foreach(@xmlFileArray) {
  if($_ eq "xxx") {
    print XMLFILE "Adding stuff to blah.xml!!!\n";
  }
  print XMLFILE "@xmlFileArray[$i]";
  $i++;
}
close(XMLFILE);

For some reason the line if($_ eq "xxx") does not ever result in
true!??? I tried using =~ /xxx/ but I don't want to replace, just add.

Anyone have any idea what I'm doing wrong. I've looked at my books and
everything, I can't figure it out. I think I'm making some really
stupid typo cause I thought I did this yesterday and it worked.

Thanks in advance,
Alex Lazarevich
alazarev@itg.uiuc.edu


Sent via Deja.com
http://www.deja.com/


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

Date: Tue, 19 Dec 2000 23:44:06 GMT
From: Dave Brondsema <brondsem@my-deja.com>
Subject: Re: testing if $_ is equal to some string?
Message-Id: <91ors4$plo$1@nnrp1.deja.com>

In article <91or4v$p5d$1@nnrp1.deja.com>,
  alazarev1981@my-deja.com wrote:
> I'll make this as simple as possible.
> My file name is "blah.xml". It consists of the following lines:
>
> <?xml version="1.0"?>
> <Junk>
> xxx
> </Junk>
>
> I want to read each line of blah.xml into an array (@xmlFileArray) and
> then test to see when I get to that line and put stuff in the line
> before it. I'm trying to do it like this:
>
> Here I put the file into the array:
> open(XMLFILE, "<blah.xml");
> $i=0;
> while(<XMLFILE>) {
>   @xmlFileArray[$i] = $_;
>   $i++;
> }
> close(XMLFILE);
>
> Here I add to the file:
> open(XMLFILE, ">blah.xml");
> $i=0;
> foreach(@xmlFileArray) {
>   if($_ eq "xxx") {
>     print XMLFILE "Adding stuff to blah.xml!!!\n";
>   }
>   print XMLFILE "@xmlFileArray[$i]";
>   $i++;
> }
> close(XMLFILE);
>
> For some reason the line if($_ eq "xxx") does not ever result in
> true!??? I tried using =~ /xxx/ but I don't want to replace, just add.

This should just match xxx, not replace it.  s/// replaces stuff.
Without trying, I'm pretty sure that you have a newline/carraige return
(I can never remember what the "correct" term is) after "xxx".  Use the
chomp function to remove it:

chomp(@xmlFileArray[$i] = $_);

or

chomp;
@xmlFileArray[$i] = $_;


You can test this by print'ing "|", $_, "|";
Then look to see if it returns exactly "|xxx|".


>
> Anyone have any idea what I'm doing wrong. I've looked at my books and
> everything, I can't figure it out. I think I'm making some really
> stupid typo cause I thought I did this yesterday and it worked.
>
> Thanks in advance,
> Alex Lazarevich
> alazarev@itg.uiuc.edu
>
> Sent via Deja.com
> http://www.deja.com/
>

--
Dave Brondsema


Sent via Deja.com
http://www.deja.com/


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

Date: Tue, 19 Dec 2000 23:54:05 GMT
From: jerome@activeindexing.com (Jerome O'Neil)
Subject: Re: testing if $_ is equal to some string?
Message-Id: <xyS%5.1944$Nn1.379447@news.uswest.net>

alazarev1981@my-deja.com elucidates:
> I'll make this as simple as possible.

I'll make it even simpler.


> I want to read each line of blah.xml into an array (@xmlFileArray) and

> Here I put the file into the array:
> open(XMLFILE, "<blah.xml");
> $i=0;
> while(<XMLFILE>) {
>   @xmlFileArray[$i] = $_;
>   $i++;
> }
> close(XMLFILE);

Is $i needed here?  How about something realy easy like

@xmlFileArray = <XMLFILE>;  # Whats with the StuDlyCaps?

Much easier, don't you think?

> Here I add to the file:
> open(XMLFILE, ">blah.xml");
> $i=0;
> foreach(@xmlFileArray) {
>   if($_ eq "xxx") {

There are no lines in your array that equal "xxx."  How do you suppose
your terminal is able to display the next line of your XML file?

You need to either remove all your line feeds when you read the file, or
check for them explicitly when you compare.

chomp(@xmlFileArray = <XMLFILE>); # My preference

Or

if($_ eq "xxx\n"){ # Foo! }


> For some reason the line if($_ eq "xxx") does not ever result in
> true!??? I tried using =~ /xxx/ but I don't want to replace, just add.

If it were to ever evaluate true, something would be wrong.  You aren't
checking for the newline at the end of your string.

And why would using a regular expression result in replacement?

> Anyone have any idea what I'm doing wrong. I've looked at my books and
> everything, I can't figure it out. I think I'm making some really
> stupid typo cause I thought I did this yesterday and it worked.

HTH!

-- 
If men could learn from history, what lessons it might teach us!  But
passion and party blind our eyes, and the light which experience gives
is a lantern on the stern, which shines only on the waves behind us.
				--Samuel Taylor Coleridge, "Recollections"


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

Date: Tue, 19 Dec 2000 23:54:53 GMT
From: Dave Brondsema <brondsem@my-deja.com>
Subject: Re: Upload Image don't refresh
Message-Id: <91osga$q86$1@nnrp1.deja.com>

In article <91mhto$su8$1@nnrp1.deja.com>,
  martinnitram@my-deja.com wrote:
> ..deleted.
> You could try pragma no cache on your page.
>
> I had tried to expires the page like that:
> 1. use CGI.pm->header,
>     print $query->header(   -type=>'text/html',
>                         -expires=>'-1d',
>                         -charset=>$charset
>                 );
> 2. use HTTP meta tab,
>     <meta http-equiv="Expires" content="Fri, 01 Jan 1983 00:00:00
GMT">
>     <META HTTP-EQUIV="Pragma" CONTENT="no-cache">
>
> 3. use the other reply (thx first), using cgi header:
>     print<<EXPIRE;
>     Pragma: no-cache
>     Expires: Fri, 01 Jan 1983 00:00:00 GMT
>
>     EXPIRE
>  But still no effect... Any other idea(rather than write another cgi
to
> read image)? This make me gone crazy...
>
>  P.S. I found that it maybe only happened in IE5.0/5.5 and NS 4.7
under
> Win98/Win98SE, as i use IE4.0 under NTServer4.0(SP5), every thing go
> well.

I think this is simply the browser cache-ing the image.  That would be
why it works differently for different browsers.  If you set the
browser to check for new version every visit, it'll work.  Or if you
press ctrl and click the refresh button it'll force a complete reload.
(this is IE, I'm not sure about netscape).

However, if this is a program that is offered to the public, you will
have to tell them to do this.  Or, as another poster suggested, use a
random number on the url.  If the url is different, the browser will
not load it from memory.

HTH,

--
Dave Brondsema


Sent via Deja.com
http://www.deja.com/


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

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


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