[16071] in Perl-Users-Digest
Perl-Users Digest, Issue: 3483 Volume: 9
daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Mon Jun 26 18:05:49 2000
Date: Mon, 26 Jun 2000 15:05:29 -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: <962057129-v9-i3483@ruby.oce.orst.edu>
Content-Type: text
Perl-Users Digest Mon, 26 Jun 2000 Volume: 9 Number: 3483
Today's topics:
Are you a shifter ? (was Re: (Q) meaning of &which("ja <gellyfish@gellyfish.com>
ASCII progress meter <poliver@nospam.elrancho.com>
ASCII progress meter <poliver@nospam.elrancho.com>
Re: ASCII progress meter <memmett@fraser.sfu.ca>
Re: Cgi counter script problem (Clinton A. Pierce)
cgi handling of accents and special chars nathanday@my-deja.com
Re: Changing case in a file! <renenyffenegger@my-deja.com>
Re: Creating a cause from information. <smerr612@mailandnews.com>
Re: Creating a cause from information. <sumus@aut.dk>
forming sums bernd1615@my-deja.com
Re: forming sums <tina@streetmail.com>
Re: forming sums <abe@ztreet.demon.nl>
Re: forming sums <aqumsieh@hyperchip.com>
Re: Golf (Was: Re: HELP ME PLEASE !!!!) <sumus@aut.dk>
Help With A String Hack <skpurcell@hotmail.com>
Re: Help With A String Hack <tina@streetmail.com>
Re: Help With A String Hack (Garrett Casey)
Re: Help With A String Hack <renenyffenegger@my-deja.com>
Re: How is a unique sort done? Like unix "sort -u" <sumus@aut.dk>
http_referer...halp <bob@cbslsoftech.com>
Re: http_referer...halp <alager@csuchico.edu>
Re: indentifying country origin using perl?? (Abigail)
Re: indentifying country origin using perl?? <peter.sundstrom@eds.com>
Re: Is SymLink broken? It won't take scalars (Clinton A. Pierce)
iteration # with foreach (Philip Taylor)
Re: iteration # with foreach <tina@streetmail.com>
Re: iteration # with foreach (Clinton A. Pierce)
Re: iteration # with foreach <aqumsieh@hyperchip.com>
Re: iteration # with foreach <lauren_smith13@hotmail.com>
Digest Administrivia (Last modified: 16 Sep 99) (Perl-Users-Digest Admin)
----------------------------------------------------------------------
Date: 26 Jun 2000 20:55:06 +0100
From: Jonathan Stowe <gellyfish@gellyfish.com>
Subject: Are you a shifter ? (was Re: (Q) meaning of &which("java"))
Message-Id: <8j8ceq$5dp$1@orpheus.gellyfish.com>
On 16 Jun 2000 11:36:26 -0000 Anno Siegel wrote:
I know its a week and a half ago but I only just read it and I feel it might
merit some more discussion ?
>
> By the same token, a widespread idiom ought to be challenged. We
> often see
>
> sub i_want_one_parameter {
> my $param = shift;
> # ...
> }
>
> Now, shift() has changed @_ which *should* indicate that the programmer
> intends to use it further.
Or might have intended to at some point in the programs history or might
have foreseen the possibility that it might be used in the future.
> You will have to check all of the code in
> the sub to find that this is (often) not the case.
Of course in reality we all properly document our code with descriptions
of subroutines that list the arguments they take so this isnt necessary ;-}
> By the rule that
> you don't invoke a function you don't need, the correct way to access
> a single parameter should be "my ( $param) = @_" or my "$param = $_[ 0]".
For myself I do tend to use 'shift' for a single argument and list assignment
from @_ for multiple arguments - largely out of habit though. If nothing
else the list assignment might make for easier maintenance as one can add
extra arguments by simply putting a new $variable on the LHS and if you
have the variables on the LHS on separate lines this is makes life even
easier.
If you use shift and you want to use an extra argument then you will need
to create a whole new line of code or completely change the existing one
to be a list assignment.
/J\
--
** This space reserved for venue sponsor for yapc::Europe **
<http://www.yapc.org/Europe/>
--
** This space reserved for venue sponsor for yapc::Europe **
<http://www.yapc.org/Europe/>
------------------------------
Date: Mon, 26 Jun 2000 16:19:14 -0500
From: Paul Oliver <poliver@nospam.elrancho.com>
Subject: ASCII progress meter
Message-Id: <3957C8D2.7BE959AB@nospam.elrancho.com>
Hey everyone,
I'm trying to print an ASCII progress bar/meter on stdout to show, well,
progress, of course. The progress bar will look like:
[################################### ]
and will fill up with hash symbols as it progresses. The problem is I only
know how to append text to STDOUT, not replace the last line, so I get:
[################################### ]
[################################### ]
[#################################### ]
[#################################### ]
[##################################### ]
I've tried the following:
sub updateProgress {
my ( $current, $total ) = @_;
print " [" . "#" x int(($current/$total) *
50) . " " x (49 - int(($current/$total) * 50)) . "]\n";
#previous lines are all on one line
}
So, how do you force Perl to write to the current line of STDOUT over and
over again (no appending)?
Thanks,
Paul
--
/*\
\ / ASCII RIBBON CAMPAIGN
x AGAINST HTML MAIL
/ \
== P A U L O L I V E R == poliver AT elrancho DOT com ==
------------------------------
Date: Mon, 26 Jun 2000 16:19:52 -0500
From: Paul Oliver <poliver@nospam.elrancho.com>
Subject: ASCII progress meter
Message-Id: <3957C8F8.C1FAA4E3@nospam.elrancho.com>
Hey everyone,
I'm trying to print an ASCII progress bar/meter on stdout to show, well,
progress, of course. The progress bar will look like:
[################################### ]
and will fill up with hash symbols as it progresses. The problem is I only
know how to append text to STDOUT, not replace the last line, so I get:
[################################### ]
[################################### ]
[#################################### ]
[#################################### ]
[##################################### ]
I've tried the following:
sub updateProgress {
my ( $current, $total ) = @_;
print " [" . "#" x int(($current/$total) *
50) . " " x (49 - int(($current/$total) * 50)) . "]\n";
#previous lines are all on one line
}
So, how do you force Perl to write to the current line of STDOUT over and
over again (no appending)?
Thanks,
Paul
--
/*\
\ / ASCII RIBBON CAMPAIGN
x AGAINST HTML MAIL
/ \
== P A U L O L I V E R == poliver AT elrancho DOT com ==
------------------------------
Date: 26 Jun 2000 14:33:30 -0700
From: Matt Emmett <memmett@fraser.sfu.ca>
Subject: Re: ASCII progress meter
Message-Id: <yvw9d7l4qg9h.fsf@fraser.sfu.ca>
Paul Oliver <poliver@nospam.elrancho.com> writes:
> I'm trying to print an ASCII progress bar/meter on stdout to show,
> well, progress, of course. The progress bar will look like:
>
> [################################### ]
>
> and will fill up with hash symbols as it progresses.
Instead of finishing your print statements with \n (\n = newline =
form feed + carriage return), finish them with \r (\r = carriage
return only).
Matt
------------------------------
Date: Mon, 26 Jun 2000 19:52:06 GMT
From: clintp@geeksalad.org (Clinton A. Pierce)
Subject: Re: Cgi counter script problem
Message-Id: <GvO55.11276$fR2.134013@news1.rdc1.mi.home.com>
[Posted and mailed]
In article <8j80vk$icn$1@nnrp1.deja.com>,
g1574@my-deja.com writes:
> I wrote a cgi script in perl to track access to pages on my a website I
> run. It usually works fine, but for no apparent reason, the counter
> file regularly gets cleared, about every 200-300 hits on the main page
> (once every week or two).
Smells like file locking.
> Innitially I didn't
> have file locking so I thought that that was the problem, but when I
> added it, the problem continued. Any ideas as to the nature of the
> problem?
Oh goodm, you tried that. But didn't quite get it right.
> [...code deleted...]
> #open the file for output and dump the arrays to it
> if(open(COUNT, ">./data/count.dat")) {
> flock(COUNT, 2);
Your problem is right there. You're wiping the file out BEFORE
you have a lock on it. (And you're using flock() with numeric
values instead of the constants. UGH!)
Read through this for an alternate solution to your problem:
http://www.plover.com/~mjd/perl/TPC/1998/Hardware-notes.html#Semaphore_Files
--
Clinton A. Pierce Teach Yourself Perl in 24 Hours!
clintp@geeksalad.org for details see http://www.geeksalad.org
"If you rush a Miracle Man,
you get rotten Miracles." --Miracle Max, The Princess Bride
------------------------------
Date: Mon, 26 Jun 2000 18:03:54 GMT
From: nathanday@my-deja.com
Subject: cgi handling of accents and special chars
Message-Id: <8j85tu$mag$1@nnrp1.deja.com>
Hello,
Wondering if there's a quick & easy way to convert cgi submissions
containing special characters (accents, umlauts, etc) to HTML.
Thanks!
Nathan
Sent via Deja.com http://www.deja.com/
Before you buy.
------------------------------
Date: Mon, 26 Jun 2000 20:59:39 GMT
From: Rene Nyffenegger <renenyffenegger@my-deja.com>
Subject: Re: Changing case in a file!
Message-Id: <8j8g7f$us7$1@nnrp1.deja.com>
> URLs are by definition case sensitive. Aside from the degenerate case
> of a URL that doesn't contain any case-sensitive characters, there are
> various heroic measures that can be adopted (and often are adopted,
> specifically by PoBs) to hide the case-sensitivity, but none of them
> is without deleterious consequences.
What is or who are PoBs?
Rene
Sent via Deja.com http://www.deja.com/
Before you buy.
------------------------------
Date: Mon, 26 Jun 2000 18:30:35 GMT
From: Steven Merritt <smerr612@mailandnews.com>
Subject: Re: Creating a cause from information.
Message-Id: <8j87gb$nke$1@nnrp1.deja.com>
In article <slrn8lem3a.7fu.tadmc@magna.metronet.com>,
tadmc@metronet.com (Tad McClellan) wrote:
> You can "do something with it" without "putting it somewhere"
(assignment):
>
> if ( <IN> =~ /^yes\b/i ) {
> print "you answered: Yes\n";
> }
>
> foreach ( split /\s+/, <IN> ) {
> print "a word: $_\n";
> }
Grr, for some reason I backspaced the little caevat I had to my original
assertion that a read without an assignemnt is pretty much useless.
Chalk it up to lack of sleep when I posted last night. The original
caevat was pretty much "Execpting reads which are used for or like peeks
to do something before actually grabbing the data."
Steven
--
King of Casual Play
The One and Only Defender of Cards That Blow
My newsreader limits sigs to four lines, but I cleverly bypassed this by
Sent via Deja.com http://www.deja.com/
Before you buy.
------------------------------
Date: 26 Jun 2000 23:07:53 +0200
From: Jakob Schmidt <sumus@aut.dk>
Subject: Re: Creating a cause from information.
Message-Id: <hfagp2vq.fsf@macforce.sumus.dk>
malverian@my-deja.com writes:
> So using $_ = <DATA>; does absolutely nothing to help me >.<
> Thanks for clerifying. (Spelling, it's late..)
It does if you need to run a lot of regex's on the data. The're much pretter
if the data is in $_.
And as I recall, you do?
--
Jakob
------------------------------
Date: Mon, 26 Jun 2000 17:57:04 GMT
From: bernd1615@my-deja.com
Subject: forming sums
Message-Id: <8j85h7$m5u$1@nnrp1.deja.com>
Dear Readers,
I have an array of elements. Each Element consists of numbers and
a corresponding letter, separated by a comma like:
a,50
a,32
a,12
b,17
b,9
c,12
I want to transform this array into a new one, which returns the sum
for each corresponding letter:
a,94
b,26
c,12
I've tried several things, however they failed. I do need a mental
impetus.
Many thanks for your consideration and your suggestions.
Markus
Sent via Deja.com http://www.deja.com/
Before you buy.
------------------------------
Date: 26 Jun 2000 18:36:02 GMT
From: Tina Mueller <tina@streetmail.com>
Subject: Re: forming sums
Message-Id: <8j87qh$13s$8@ID-24002.news.cis.dfn.de>
hi,
bernd1615@my-deja.com wrote:
> Dear Readers,
> I have an array of elements. Each Element consists of numbers and
> a corresponding letter, separated by a comma like:
> a,50
> a,32
> a,12
> b,17
> b,9
> c,12
> I want to transform this array into a new one, which returns the sum
> for each corresponding letter:
> a,94
> b,26
> c,12
> I've tried several things, however they failed. I do need a mental
> impetus.
what did you try? and why didn't it work? which
error messages did you get?
have you tried hashes?
foreach (@array) {
($char,$value) = split /,/;
$hash{$char} += $value;
}
tina
--
http://tinita.de \ enter__| |__the___ _ _ ___
tina's moviedatabase \ / _` / _ \/ _ \ '_(_-< of
search & add comments \ \ _,_\ __/\ __/_| /__/ perception
"The Software required Win98 or better, so I installed Linux."
------------------------------
Date: Mon, 26 Jun 2000 20:42:10 +0200
From: Abe Timmerman <abe@ztreet.demon.nl>
Subject: Re: forming sums
Message-Id: <tm8flsc2sa4u0lhuhcnie1jv9b2up7cqii@4ax.com>
On Mon, 26 Jun 2000 17:57:04 GMT, bernd1615@my-deja.com wrote:
> Dear Readers,
hi,
>
> I have an array of elements. Each Element consists of numbers and
> a corresponding letter, separated by a comma like:
>
... DATA ...
>
> I want to transform this array into a new one, which returns the sum
> for each corresponding letter:
>
> a,94
> b,26
> c,12
>
> I've tried several things, however they failed. I do need a mental
> impetus.
It would have been nice if you had shown what you have tried.
Oh well, this is one way:
#!/usr/bin/perl -w
use strict;
my %sums;
while ( <DATA> ) {
my($letter, $value) = split /,/;
$sums{$letter} += $value;
}
print "$_,$sums{$_}\n" for sort keys %sums;
__DATA__
a,50
a,32
a,12
b,17
b,9
c,12
--
Good luck,
Abe
------------------------------
Date: Mon, 26 Jun 2000 19:02:18 GMT
From: Ala Qumsieh <aqumsieh@hyperchip.com>
Subject: Re: forming sums
Message-Id: <7asnu0e05f.fsf@merlin.hyperchip.com>
bernd1615@my-deja.com writes:
> Dear Readers,
>
> I have an array of elements. Each Element consists of numbers and
> a corresponding letter, separated by a comma like:
>
> a,50
> a,32
> a,12
> b,17
> b,9
> c,12
>
> I want to transform this array into a new one, which returns the sum
> for each corresponding letter:
>
> a,94
> b,26
> c,12
my %hash;
for my $element (@array) {
my ($letter, $number) = split /,/, $element;
$hash{$letter} += $number;
}
@array = map { join ',' => $_, $hash{$_} } keys %hash;
--Ala
------------------------------
Date: 26 Jun 2000 23:38:50 +0200
From: Jakob Schmidt <sumus@aut.dk>
Subject: Re: Golf (Was: Re: HELP ME PLEASE !!!!)
Message-Id: <em5kp1g5.fsf@macforce.sumus.dk>
"Lee Millard" <chez@bigfoot.com> writes:
> All of these variants seem to work but none of them do the new line bit.....
What newline bit? If we're actually talking CGI here you may mean that
the newlines are missing in the browser. Then you'll need <BR> tags.
I'll tell you how in a sec.
> Also I need to be able add characters before and after each directory
> name.....
>
> ???? can you assist ???
Yes. The other snippets were just my attempt to make a very short and nifty
solution to the precice problem you mentioned. In "real" code I think
you should stick with something more easily understood for a number of good
reasons:
opendir DIR, '.' or print "Couldn't open my own directory :-( $!\n";
# normally you die() when an open fails but if you're not using
# the right "use"s that may not give you a decent error message in
# the browser - assuming as I am that you're making a CGI program
while ( $_ = readdir DIR ) { -d $_ and print $_, "\n" }
What you want is to print something more than just the names. So you must
change the part that says print $_, "\n".
You want
print "stuff before the dirname $_ and some after\n"
in stead. And if you need HTML newlines - just put them in there too:
print "stuff before the dirname $_ and some after<BR>\n"
As for the golf - you can ignore it for now :-)
--
Jakob
------------------------------
Date: Mon, 26 Jun 2000 14:34:01 -0500
From: "spurcell" <skpurcell@hotmail.com>
Subject: Help With A String Hack
Message-Id: <3957b075$0$1993@wodc7nh1.news.uu.net>
Hello
I have the following string and need to remove everything AFTER the
SSPPLLIITT and replace with nothing.
have the following
my $teststring = "REJ 6/22/100-12:33 pm one REJ 6/22/100-12:33 pm two REJ
6/22/100-12:33 pm Three SSPPLLIITT after the split";
want
my $teststring = "REJ 6/22/100-12:33 pm one REJ 6/22/100-12:33 pm two REJ
6/22/100-12:33 pm Three SSPPLLIITT";
I have tried a regular expression, but had no luck.
$teststring =~ s/^(.*SSPPLLIITT).*/$1/;
but it did not work. What is the best way to do this?
Thanks
Scott
------------------------------
Date: 26 Jun 2000 20:14:25 GMT
From: Tina Mueller <tina@streetmail.com>
Subject: Re: Help With A String Hack
Message-Id: <8j8dj1$13s$11@ID-24002.news.cis.dfn.de>
hi,
spurcell <skpurcell@hotmail.com> wrote:
> Hello
> I have the following string and need to remove everything AFTER the
> SSPPLLIITT and replace with nothing.
> have the following
> my $teststring = "REJ 6/22/100-12:33 pm one REJ 6/22/100-12:33 pm two REJ
> 6/22/100-12:33 pm Three SSPPLLIITT after the split";
> want
> my $teststring = "REJ 6/22/100-12:33 pm one REJ 6/22/100-12:33 pm two REJ
> 6/22/100-12:33 pm Three SSPPLLIITT";
> I have tried a regular expression, but had no luck.
> $teststring =~ s/^(.*SSPPLLIITT).*/$1/;
worked for me.
do you really have this one string in $teststring and
no newlines? or should that be a real newline?
than add the option /s for matching "." and "\n"
tina
--
http://tinita.de \ enter__| |__the___ _ _ ___
tina's moviedatabase \ / _` / _ \/ _ \ '_(_-< of
search & add comments \ \ _,_\ __/\ __/_| /__/ perception
"The Software required Win98 or better, so I installed Linux."
------------------------------
Date: Mon, 26 Jun 2000 20:45:54 GMT
From: remove_this_prefix_adms1@cts.com (Garrett Casey)
Subject: Re: Help With A String Hack
Message-Id: <3957bdf4.13116981@nntp.cts.com>
Scott, use the index() function in conjunction with substr().
Maybe something like:
my $string = "some cool string that needs to be chopped before this";
my $lookfor = "chopped";
if ( (my $pos = index ($string, $lookfor)) > 0 ) {
$string = substr($string, 0, ($pos + length($lookfor)));
}
-garrett
On Mon, 26 Jun 2000 14:34:01 -0500, "spurcell" <skpurcell@hotmail.com>
wrote:
>Hello
>I have the following string and need to remove everything AFTER the
>SSPPLLIITT and replace with nothing.
>
>have the following
>my $teststring = "REJ 6/22/100-12:33 pm one REJ 6/22/100-12:33 pm two REJ
>6/22/100-12:33 pm Three SSPPLLIITT after the split";
>
>want
>my $teststring = "REJ 6/22/100-12:33 pm one REJ 6/22/100-12:33 pm two REJ
>6/22/100-12:33 pm Three SSPPLLIITT";
>
>I have tried a regular expression, but had no luck.
>$teststring =~ s/^(.*SSPPLLIITT).*/$1/;
>but it did not work. What is the best way to do this?
>
>Thanks
>Scott
>
>
>
------------------------------
Date: Mon, 26 Jun 2000 21:11:02 GMT
From: Rene Nyffenegger <renenyffenegger@my-deja.com>
Subject: Re: Help With A String Hack
Message-Id: <8j8gsm$vd4$1@nnrp1.deja.com>
> Hello
> I have the following string and need to remove everything AFTER the
> SSPPLLIITT and replace with nothing.
>
> have the following
> my $teststring = "REJ 6/22/100-12:33 pm one REJ 6/22/100-12:33 pm two REJ
> 6/22/100-12:33 pm Three SSPPLLIITT after the split";
>
> want
> my $teststring = "REJ 6/22/100-12:33 pm one REJ 6/22/100-12:33 pm two REJ
> 6/22/100-12:33 pm Three SSPPLLIITT";
>
> I have tried a regular expression, but had no luck.
> $teststring =~ s/^(.*SSPPLLIITT).*/$1/;
> but it did not work. What is the best way to do this?
Surprise, it workes at 11.12 PM on my machine....
Rene
Sent via Deja.com http://www.deja.com/
Before you buy.
------------------------------
Date: 26 Jun 2000 23:17:06 +0200
From: Jakob Schmidt <sumus@aut.dk>
Subject: Re: How is a unique sort done? Like unix "sort -u"
Message-Id: <g0q0p2gd.fsf@macforce.sumus.dk>
Ala Qumsieh <aqumsieh@hyperchip.com> writes:
> Jakob Schmidt <sumus@aut.dk> writes:
>
> > This is a FAQ item:
[...]
> > perldoc -q unique
[...]
> > - but actually I think I have a better answer than (my local version of)
> > the
> > FAQ for this case:
[...]
>
> Nope. It's in the FAQ (since at least 5.004): [...]
Well blimey - mine is 5.005 and it sure as h... wait, maybe I should check
again....
Oh, eh, ... sorry about that. I must have overlooked it the first time round.
It is there alright - like it should be being a standard technique. Thanks
for not believing :-)
--
Jakob
------------------------------
Date: Mon, 26 Jun 2000 21:36:09 +0100
From: "Bob H" <bob@cbslsoftech.com>
Subject: http_referer...halp
Message-Id: <3957bfca$1@news.jakinternet.co.uk>
Hi,
Thanks to all who helped me out with the htaccess files I thought I needed
earlier!
It seems that all I need is a 'simple' http_referrer file to do the job that
I need. My problem is, what is a http_referrer file, how do I write one,
where do I park it, am I capable of making it work?
Should I employ someone with a brain to do it?
Sorry to be a pain, guys, I didn't want the job anymore that the guy next
door did!
------------------------------
Date: Mon, 26 Jun 2000 14:24:30 -0700
From: Aaron <alager@csuchico.edu>
Subject: Re: http_referer...halp
Message-Id: <3957CA0D.93590500@csuchico.edu>
Bob H wrote:
> Hi,
>
> Thanks to all who helped me out with the htaccess files I thought I needed
> earlier!
>
> It seems that all I need is a 'simple' http_referrer file to do the job that
> I need. My problem is, what is a http_referrer file, how do I write one,
> where do I park it, am I capable of making it work?
>
> Should I employ someone with a brain to do it?
>
> Sorry to be a pain, guys, I didn't want the job anymore that the guy next
> door did!
Depending on your web server you can have it create a file that contains the
http_referer data. Apache will allow you to do this.
Aaron
------------------------------
Date: 26 Jun 2000 15:20:39 EDT
From: abigail@delanet.com (Abigail)
Subject: Re: indentifying country origin using perl??
Message-Id: <slrn8lfca4.ka1.abigail@alexandra.delanet.com>
Abigail (abigail@delanet.com) wrote on MMCDXCI September MCMXCIII in
<URL:news:slrn8lf6s9.ka1.abigail@alexandra.delanet.com>:
&& dagolfmasta (janneNOjaSPAM@funplanet.com.invalid) wrote on MMCDXCI
&& September MCMXCIII in <URL:news:0146ce5a.6fe64e71@usw-ex0108-062.remarq.com>:
&& }} Is it possible to determine the origin of somebody browsing
&& }} my pages?
&&
&& No. But that's on a Perl issue.
^ insert "not" here.
Abigail
--
srand 123456;$-=rand$_--=>@[[$-,$_]=@[[$_,$-]for(reverse+1..(@[=split
//=>"IGrACVGQ\x02GJCWVhP\x02PL\x02jNMP"));print+(map{$_^q^"^}@[),"\n"
------------------------------
Date: Tue, 27 Jun 2000 09:19:28 +1200
From: "Peter Sundstrom" <peter.sundstrom@eds.com>
Subject: Re: indentifying country origin using perl??
Message-Id: <8j8hgn$pbj$1@hermes.nz.eds.com>
dagolfmasta wrote in message
<0146ce5a.6fe64e71@usw-ex0108-062.remarq.com>...
>Is it possible to determine the origin of somebody browsing
>my pages?
Not with any degree of accuracy.
>How can I access the IP-adress of the html-page that is
>calling my scripts? Through the IP-adress I could determine
>country origin because I have different sites for different
>countries.
Look up the CGI environment variables available to you.
------------------------------
Date: Mon, 26 Jun 2000 19:41:39 GMT
From: clintp@geeksalad.org (Clinton A. Pierce)
Subject: Re: Is SymLink broken? It won't take scalars
Message-Id: <TlO55.11273$fR2.134013@news1.rdc1.mi.home.com>
[Posted and mailed]
In article <8j84p5$vkc$1@nnrp2.deja.com>,
raincloudstudios@my-deja.com writes:
> however if I try to pass it a couple of scalars
> such as...
>
> $oldfile
> = "/u/web/raincl/hidden/special/image.gif";
> $newfile = "/u/web/raincl/1234-
> 12345678/image.gif";
I hope that carriage-return after "1234-" is just an artifact
of USENET posting. That'll cause problems in your Perl symlink
otherwise.
> my $results = symlink($oldfile,$newfile);
>
> Results gives me a 0 and the $! is No such file
> or directory.
>
> Baffling! Is there a workaround? My solution
> requires passing scalars as the files will not be
> known ahead of time.
symlink takes two scalar values. Whether they're literal strings,
or scalar variables it doesn't matter. Clearly Something Else is
wrong. You're not putting the right values into the variables,
you're mixing them up...something.
--
Clinton A. Pierce Teach Yourself Perl in 24 Hours!
clintp@geeksalad.org for details see http://www.geeksalad.org
"If you rush a Miracle Man,
you get rotten Miracles." --Miracle Max, The Princess Bride
------------------------------
Date: Mon, 26 Jun 2000 18:57:36 GMT
From: phil.taylor@bigfoot.com (Philip Taylor)
Subject: iteration # with foreach
Message-Id: <3957a6bc.3572261@news.demon.co.uk>
Is there a tidy way to establish the iteration number within a foreach
loop without having to create a variable and increment it manually. ie
to avoid this:-
my $i=0;
foreach (@myArray) {
$i++;
print $i, $_
}
and do this:-
foreach (@myArray) {
print $someSpecialInternalThingy, $_;
}
------------------------------
Date: 26 Jun 2000 19:29:51 GMT
From: Tina Mueller <tina@streetmail.com>
Subject: Re: iteration # with foreach
Message-Id: <8j8avf$13s$10@ID-24002.news.cis.dfn.de>
hi,
Philip Taylor <phil.taylor@bigfoot.com> wrote:
> Is there a tidy way to establish the iteration number within a foreach
> loop without having to create a variable and increment it manually. ie
> to avoid this:-
> my $i=0;
> foreach (@myArray) {
> $i++;
> print $i, $_
> }
> and do this:-
> foreach (@myArray) {
> print $someSpecialInternalThingy, $_;
> }
you could do:
for (0..$#MyArray) {
print $_,$MyArray[$_],"\n";
}
tina
--
http://tinita.de \ enter__| |__the___ _ _ ___
tina's moviedatabase \ / _` / _ \/ _ \ '_(_-< of
search & add comments \ \ _,_\ __/\ __/_| /__/ perception
"The Software required Win98 or better, so I installed Linux."
------------------------------
Date: Mon, 26 Jun 2000 19:34:38 GMT
From: clintp@geeksalad.org (Clinton A. Pierce)
Subject: Re: iteration # with foreach
Message-Id: <ifO55.11271$fR2.134013@news1.rdc1.mi.home.com>
[Posted and mailed]
In article <3957a6bc.3572261@news.demon.co.uk>,
phil.taylor@bigfoot.com (Philip Taylor) writes:
> Is there a tidy way to establish the iteration number within a foreach
> loop without having to create a variable and increment it manually. ie
> to avoid this:-
>
> my $i=0;
> foreach (@myArray) { $i++; print $i, $_ }
>
> and do this:-
>
> foreach (@myArray) { print $someSpecialInternalThingy, $_; }
The short answer is no. The long answer is also no. The ugly answer
is:
# $i is the index, $v is the current value
# and @e is the original array
foreach(my($i,$v)=0; $v=$e[$i],$i<@e; $i++) {
print "$i $v";
}
Normally though, I find that I either want the offset or the value.
Hardly ever both.
--
Clinton A. Pierce Teach Yourself Perl in 24 Hours!
clintp@geeksalad.org for details see http://www.geeksalad.org
"If you rush a Miracle Man,
you get rotten Miracles." --Miracle Max, The Princess Bride
------------------------------
Date: Mon, 26 Jun 2000 20:07:47 GMT
From: Ala Qumsieh <aqumsieh@hyperchip.com>
Subject: Re: iteration # with foreach
Message-Id: <7apup4dx4a.fsf@merlin.hyperchip.com>
Chris Sorensen <csorensen@uptimeresources.net> writes:
> yes - here's a sample .. it uses $_ as the loop variable
[snip rest of jeopardy quote]
Did you even read the question?
--Ala
------------------------------
Date: Mon, 26 Jun 2000 13:07:20 -0700
From: "Lauren Smith" <lauren_smith13@hotmail.com>
Subject: Re: iteration # with foreach
Message-Id: <8j8d5i$hjn$1@brokaw.wa.com>
Philip Taylor <phil.taylor@bigfoot.com> wrote in message
news:3957a6bc.3572261@news.demon.co.uk...
> Is there a tidy way to establish the iteration number within a foreach
> loop without having to create a variable and increment it manually. ie
> to avoid this:-
>
> my $i=0;
> foreach (@myArray) {
> $i++;
> print $i, $_
> }
>
> and do this:-
>
> foreach (@myArray) {
> print $someSpecialInternalThingy, $_;
> }
for (0..$#myArray) {
$something = $myArray[$_];
print $someSpecialInternalThingy, $_;
}
Or, if you have a yen for C
for ($i=0; $i < @myArray; $i++) {
$something = $myArray[$_];
print $someSpecialInternalThingy, $_;
}
Lauren
------------------------------
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 3483
**************************************