[18052] in Perl-Users-Digest

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

Perl-Users Digest, Issue: 212 Volume: 10

daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Mon Feb 5 06:05:34 2001

Date: Mon, 5 Feb 2001 03:05:09 -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: <981371108-v10-i212@ruby.oce.orst.edu>
Content-Type: text

Perl-Users Digest           Mon, 5 Feb 2001     Volume: 10 Number: 212

Today's topics:
    Re: "Average of List of Numbers" by Abigail <frido@q-software-solutions.com>
    Re: "Average of List of Numbers" by Abigail <ccx138@coventry.ac.uk>
    Re: 'print' problem (BUCK NAKED1)
    Re: [help] multi-process at the same time?? jimjim123@my-deja.com
    Re: Apologies to Joyce Kilmer, a hack for your enjoymen <wyzelli@yahoo.com>
        Getting the pid of a program launched from perl gelliott@tufts.edu
    Re: Getting the pid of a program launched from perl (Garry Williams)
    Re: Getting the pid of a program launched from perl (Logan Shaw)
    Re: Help! How to print range of array lines? (Mark Jason Dominus)
    Re: Help: Script only runs if ' -w' is on line 1 <ron@savage.net.au>
        Localtime Question <hafateltec@hotmail.com>
    Re: Localtime Question <wyzelli@yahoo.com>
    Re: Localtime Question <hafateltec@hotmail.com>
    Re: Localtime Question <hafateltec@hotmail.com>
    Re: Localtime Question (Mark Jason Dominus)
    Re: Localtime Question <krahnj@acm.org>
    Re: Localtime Question <wyzelli@yahoo.com>
    Re: Out of memory ... (Gwyn Judd)
        Parsing variable <zabaon@my-deja.com>
    Re: Parsing variable (Logan Shaw)
    Re: Passwd and Shadow jimjim123@my-deja.com
    Re: perl LOCALE problem.. (Rafael Garcia-Suarez)
    Re: Possible buggy behavior in File::Find (Ben Okopnik)
    Re: Radical readdir suggestion (Mark Jason Dominus)
    Re: Radical readdir suggestion <iltzu@sci.invalid>
    Re: System call correct? (Gwyn Judd)
    Re: System call correct? (Philip Lees)
    Re: Text::Template Problem (Mark Jason Dominus)
    Re: Text::Template Problem (Mark Jason Dominus)
    Re: This is driving me nuts and I need a guru (Abigail)
        update page <hkamp1@hotmail.com>
        Digest Administrivia (Last modified: 16 Sep 99) (Perl-Users-Digest Admin)

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

Date: 05 Feb 2001 10:11:43 +0100
From: Friedrich Dominicus <frido@q-software-solutions.com>
Subject: Re: "Average of List of Numbers" by Abigail
Message-Id: <87ae81xzn4.fsf@frown.here>

Terrence Brannon <brannon@lnc.usc.edu> writes:

> The Museum of Modern Programming is proud to present its first work:
> 
> "Average of List of Numbers" by Abigail.

What is so striking elegant about that solution. Here some Common Lisp
stuff:

(setf list '(1 2 3 4 5 6 7 8 9 10))
(/ (apply #'+ list) (length list))

Regards
Friedrich


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

Date: Mon, 05 Feb 2001 10:30:14 +0000
From: John Tutchings <ccx138@coventry.ac.uk>
Subject: Re: "Average of List of Numbers" by Abigail
Message-Id: <3A7E80B6.624B714@coventry.ac.uk>

print "5.5\n";

Which is what I would give a program like that for maintainability. :)
(Should I put on my flame proof pants now?)

Terrence Brannon wrote:

> The Museum of Modern Programming is proud to present its first work:
>
> "Average of List of Numbers" by Abigail.
>
> The Museum of Modern Programming: http://www.momp.org
>
> --
> Terrence Brannon
> Carter's Compass:
>  I know I'm on the right track when by deleting code I'm adding functionality.



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

Date: Mon, 5 Feb 2001 00:39:35 -0600 (CST)
From: dennis100@webtv.net (BUCK NAKED1)
Subject: Re: 'print' problem
Message-Id: <15956-3A7E4AA7-83@storefull-245.iap.bryant.webtv.net>

 
b0l4549@cs.tamu.edu (Bin=A0-=A0Lu) 
> I have such a problem: 
> At the beginning of my code I have to 
> use print "content-type: text/html\n\n"; 
> But then I want to use:
> print "Location: $link\n\n";
> exit; 
> which achieves redirection and requires > not to use the first 'print'
line. How can I > 'deactivate' the first 'print' line or change > the
print content type?

Just put it in a scalar before the content header, and call it out later
like so:

$redirect =3D "Location: $link\n\n";

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

print $redirect;

I hope that's right. You may need to change the 1st line to read... 

$redirect =3D print "Location: $link\n\n";

--Dennis

 



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

Date: Mon, 05 Feb 2001 08:42:12 GMT
From: jimjim123@my-deja.com
Subject: Re: [help] multi-process at the same time??
Message-Id: <95lp14$a9f$1@nnrp1.deja.com>

What you are looking for my friend is fork()

However, I have heard that under Win95/98 you can't have too many
processes at once, because of the unreliability of the threading model
in these OS'...  NT is more reliable, and of course, Unix based
variants are the best at this sort of activity...  However, as I said
before this is just something I think I may have read...

Cheers!

Hamish.

In article <95g9jb$suo$1@taliesin.netcom.net.uk>,
  "Tommy Au" <perl@dotexpress.com> wrote:
> my problem is:
> how can i create more than one process at the same time in one script?
> (i am using win98)


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


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

Date: Mon, 5 Feb 2001 15:13:38 +0930
From: "Wyzelli" <wyzelli@yahoo.com>
Subject: Re: Apologies to Joyce Kilmer, a hack for your enjoyment
Message-Id: <tWqf6.28$ym6.4029@vic.nntp.telstra.net>

I just showed this to a few colleagues, and we are all impressed
(understated).

I wanna see it as a JAPH sig now...

Wyzelli
--
($a,$b,$w,$t)=(' bottle',' of beer',' on the wall','Take one down, pass
it around');
for(reverse(1..100)){$s=($_!=1)?'s':'';$c.="$_$a$s$b$w\n$_$a$s$b\n$t\n";
$_--;$s=($_!=1)?'s':'';$c.="$_$a$s$b$w\n\n";}print"$c*hic*";





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

Date: Mon, 05 Feb 2001 06:09:24 GMT
From: gelliott@tufts.edu
Subject: Getting the pid of a program launched from perl
Message-Id: <95lg2i$35i$1@nnrp1.deja.com>

I'm using the system() function to launch an application in the
background for an application launcher I'm writing in perl/tk. Is there
any way I can easily get the pid of the process that I launched? I'd
like to keep track of the process to be able to kill it later, etc.
Thanks!

gary


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


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

Date: Mon, 05 Feb 2001 07:08:22 GMT
From: garry@zvolve.com (Garry Williams)
Subject: Re: Getting the pid of a program launched from perl
Message-Id: <Gjsf6.4481$Sn3.45240@eagle.america.net>

On Mon, 05 Feb 2001 06:09:24 GMT, gelliott@tufts.edu <gelliott@tufts.edu> wrote:
>I'm using the system() function to launch an application in the
>background for an application launcher I'm writing in perl/tk. Is there
>any way I can easily get the pid of the process that I launched? I'd
>like to keep track of the process to be able to kill it later, etc.
>Thanks!

  fork() / exec()

-- 
Garry Williams


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

Date: 5 Feb 2001 01:14:18 -0600
From: logan@cs.utexas.edu (Logan Shaw)
Subject: Re: Getting the pid of a program launched from perl
Message-Id: <95ljsa$kca$1@boomer.cs.utexas.edu>

In article <95lg2i$35i$1@nnrp1.deja.com>,  <gelliott@tufts.edu> wrote:
>I'm using the system() function to launch an application in the
>background for an application launcher I'm writing in perl/tk. Is there
>any way I can easily get the pid of the process that I launched?

system() doesn't launch programs.  It launches them, then waits for
them to exit.  So, when system() has returned, the program you ran has
finished.  So, there is no pid to get.

If you launched a program that itself happened to launch another
program (i.e. if you did 'system ("foo &");'), then there isn't a way
for Perl to know the pid of that process, since it would have to
somehow communicate with the external program and ask it.

If, instead, you want to launch a process and let it run together
your Perl process, you'll want to use a combination of fork() and
exec(), like this:

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

	if ($pid = fork)
		{
		# we're the parent process; do nothing.
		}
	else
		{
		# child process
		exec ("other_program");
		die "failed to exec() because $!\n";
		}

	# stuff happens, and you decide you want to kill the other
	# program, so..

	kill HUP => $pid;

That could stand to have some more error checking, but it's the basic
idea.

  - Logan


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

Date: Mon, 05 Feb 2001 08:28:24 GMT
From: mjd@plover.com (Mark Jason Dominus)
Subject: Re: Help! How to print range of array lines?
Message-Id: <3a7e6428.4cb6$d6@news.op.net>

In article <95k1jb$3qq$1@nnrp1.deja.com>,  <robert_hughes@my-deja.com> wrote:
>I know $. refers to the current line number in
>the last opened <FILE> but what would I use to
>represent the current line number in an array?

How about:

        for $lineno ($current_first .. $current_last) {
          print $array[$lineno];
        }

-- 
@P=split//,".URRUU\c8R";@d=split//,"\nrekcah xinU / lreP rehtona tsuJ";sub p{
@p{"r$p","u$p"}=(P,P);pipe"r$p","u$p";++$p;($q*=2)+=$f=!fork;map{$P=$P[$f^ord
($p{$_})&6];$p{$_}=/ ^$P/ix?$P:close$_}keys%p}p;p;p;p;p;map{$p{$_}=~/^[P.]/&&
close$_}%p;wait until$?;map{/^r/&&<$_>}%p;$_=$d[$q];sleep rand(2)if/\S/;print


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

Date: Mon, 5 Feb 2001 20:59:00 +1100
From: "Ron Savage" <ron@savage.net.au>
Subject: Re: Help: Script only runs if ' -w' is on line 1
Message-Id: <bYtf6.1819$sS4.54587@ozemail.com.au>

As promised:
:135!:33/:47u:117s:115r:114/:47b:98i:105n:110/:47p:112e:101r:114l:108







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

Date: Mon, 5 Feb 2001 17:06:11 +1000
From: "Mike McPherson" <hafateltec@hotmail.com>
Subject: Localtime Question
Message-Id: <95ljg3$9l9$1@brokaw.wa.com>

All list elements are numeric, and come straight out of the C `struct tm'.
$sec, $min, and $hour are the seconds, minutes, and hours of the specified
time. $mday is the day of the month, and $mon is the month itself, in the
range 0..11 with 0 indicating January and 11 indicating December. $year is
the number of years since 1900. That is, $year is 123 in year 2023. $wday is
the day of the week, with 0 indicating Sunday and 3 indicating Wednesday.
$yday is the day of the year, in the range 1..365 (or 1..366 in leap years.)
$isdst is true if the specified time occurs during daylight savings time,
false otherwise.

My question is this.  $yday is supposed to return 1..365 or 1..366 on a leap
year yet when I plug the following code

$local2000 = localtime(978271200);  #Adjusted for system time zone and
leapyears SECONDS Since 1970
print $local2000;
exit;

This returns the correct information
Mon Jan  1 00:00:00 2001

Now this code:

@local2000 = localtime(978271200);
my ($sec,$min,$hour,$mday,$mon,$year,$wday,$yday,$isdst)= @local2000;
print "Please notice the docs say that YearDay is 1 thru 365 or 1 thru
366\n";
print "So therefore YearDay should equal 1\n";
print "My year day is $yday\n";
exit;

This returns incorrect information

Please notice the docs say that YearDay is 1 thru 365 or 1 thru 366
So therefore YearDay should equal 1
My year day is 0

Now you can see my delema.  Can anybody tell me what the problem is? Is it
in my code? Is this a bug? Is this a missprint in the docs?

Thank You,
Mike




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

Date: Mon, 5 Feb 2001 17:57:26 +0930
From: "Wyzelli" <wyzelli@yahoo.com>
Subject: Re: Localtime Question
Message-Id: <2ktf6.4$Hq6.611@vic.nntp.telstra.net>


"Mike McPherson" <hafateltec@hotmail.com> wrote in message
news:95ljg3$9l9$1@brokaw.wa.com...
> $yday is the day of the year, in the range 1..365 (or 1..366 in leap
years.)
> $isdst is true if the specified time occurs during daylight savings
time,
> false otherwise.
>
> My question is this.  $yday is supposed to return 1..365 or 1..366 on
a leap
> year yet when I plug the following code
>

Your docs must be broken cos mine say 0-364 (365 for leap year)

Wyzelli
--
push@x,$_ for(a..z);push@x,' ';
@z='092018192600131419070417261504171126070002100417'=~/(..)/g;
foreach $y(@z){$_.=$x[$y]}y/jp/JP/;print;




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

Date: Mon, 5 Feb 2001 18:21:40 +1000
From: "Mike McPherson" <hafateltec@hotmail.com>
Subject: Re: Localtime Question
Message-Id: <95lntl$d1l$1@brokaw.wa.com>

Just in case anybody asks this is the code I need to find out for.


#!/usr/bin/perl -w
#flush buffer so that output appears immediately
$| = 1;
#-------------------------------------------------------------#
# Written by Michael R. McPherson
# an ongoing exercise in learning how
# to script perl or shoot off my foot
#-------------------------------------------------------------#

#-------------------------------------------------------------#
# There is a bug in this program
# It only works after Feb 29, 2000
# This is due to the correction number from
# &CurrentLineTime for leap year
# I will fix this
#-------------------------------------------------------------#

#-------------------------------------------------------------#
# Problem::: Figure out how many Days in a month of a given year
# and what day each falls on. Then figure out how many Mondays
# Tuesdays ect ...
#-------------------------------------------------------------#
#Command line input for determining the month to be processed
print "Please enter the the year in YYYYMM you would like to process:";
my $indate = <STDIN>;
chomp $indate;
my $cordate = $indate."01000000";
my $inyear = substr($indate,0,4);
my $leap = &leap($inyear);
my @array = localtime(&CurrentLineTime($cordate));
my $month = $array[4];
#Define Days in month and there names.
my %DaysInMonth =
(0,31,1,$leap,2,31,3,30,4,31,5,30,6,31,7,31,8,30,9,31,10,30,11,31);
my %NamesOfMonth = (0 => January, 1 => Febuary,
                    2 => March, 3 => April,
     4 => May, 5 => June,
     6 => July, 7 => August,
     8 => September, 9 => October,
     10 => November, 11 => December);
my %NameOfDay = (0 => Sunday, 1 => Monday,
          2 => Tuedsay, 3 => Wednsday,
     4 => Thursday, 5 => Friday,
     6 => Saturday);
#Return The anme of the month and how many days it has.
my $Month = $NamesOfMonth{$month};
my $TotalDaysInMonth = $DaysInMonth{$month};

print "\nThe month of $Month";
print "\nIn The Year of our LORD $inyear";
print "\nThere are $TotalDaysInMonth days in this month";
if ($DaysInMonth{1} eq "28") {
  print "\nThis is a not a leap year";
} else {
  print "\nThis is a leap year";
}
print "\n";


my $table = {0,0,1,0,2,0,3,0,4,0,5,0,6,0};
my $today;
foreach $today(1..$TotalDaysInMonth) {
print "$today \t";
if ($today == 1 || $today == 2 || $today == 3 || $today == 4 || $today == 5
|| $today == 6 || $today == 7 || $today == 8 || $today == 9){
    @day = localtime(&CurrentLineTime($indate."0".$today."000000"));
 print "@day\t";
} else {
    @day = localtime(&CurrentLineTime($indate.$today."000000"));
 print "@day\t";
}
my $wday = $day[6];
print "$wday\n";
  if ($wday eq 0) {
    $table{0}++;
  }
  if ($wday eq 1) {
    $table{1}++;
  }
  if ($wday eq 2) {
    $table{2}++;
  }
  if ($wday eq 3) {
    $table{3}++;
  }
  if ($wday eq 4) {
    $table{4}++;
  }
  if ($wday eq 5) {
    $table{5}++;
  }
  if ($wday eq 6) {
    $table{6}++;
  }
}

print "\nThere are $table{0} Sundays";
print "\nThere are $table{1} Mondays";
print "\nThere are $table{2} Tuesdays";
print "\nThere are $table{3} Wednsdays";
print "\nThere are $table{4} Thursdays";
print "\nThere are $table{5} Fridays";
print "\nThere are $table{6} Saturdays\n";
exit;
#---------------------------------------------------------------------------
--#
#  usage.pl function - CurrentLineTime
#    Purpose  : Converts the date & time from a cdr entry into number
#  of seconds since Jan 1, 1970
#    Format:YYYYMMDDHHMMSS
#---------------------------------------------------------------------------
--#
sub CurrentLineTime {
    my $time = 0;
    my $date = $_[0];
my $day = substr($date,6,2);
my $month = substr($date,4,2);
my $year = substr($date,0,4);
print "$year.$month.$day\t";
    my %month = ("01", 0,   "02", 31,   "03", 59, "04", 90,
              "05", 120, "06", 151, "07", 181, "08", 212,
     "09", 243, "10", 273, "11", 304, "12", 334);
    $time += (substr($date,0,4) - 1970) * 31536000;
    $time += ($month{substr($date,4,2)} + substr($date,6,2) - 1) * 86400;
    my ($hours, $minutes, $seconds);
 if (substr($date,8,2) eq "  ") {
     $hours = 0;
    } elsif (substr($date,8,1) eq " ") {
        $hours = substr($date,9,1);
    } else {
     $hours = substr($date,8,2);
 }
 if (substr($date,10,2) eq "00" || substr($date,10,2) eq "  "){
        $minutes = 0;
    }elsif (substr($date,10,1) eq "0" || substr($date,10,1) eq " "){
        $minutes = substr($date,11,1);
 } else {
     $minutes = substr($date,10,2);
 }
 if (substr($date,12,2) eq "00" || substr($date,12,2) eq "  "){
     $seconds = 0;
 }elsif (substr($date,12,1) eq "0" || substr($date,12,1) eq " "){
        $seconds = substr($date,13,1);
 } else {
     $seconds = substr($date,12,2);
 }

 $time += ($hours * 3600);
 $time += ($minutes * 60);
    $time += $seconds;

    # Total Correction = (# of leap years) + (System Clock Correction)
    # There have been 8 leap years since 1970.
    # System clock correction is -10 hours for this specific system.
 # Total Correction = 691200 - 10*3600 for this specific system.

 #Need to make dynamic
 #on any given day figure how many leap years since 1970

 $time += 86400 * 8;
 $time -= 36000 ; #Correction for Time Zone
    return $time;
}
#Determin if it is a leep year.
sub leap {
my $inyear = $_[0];
my @leapyear = (2008,2004,2000,1996,1992,1988,1984,1980,1976,1972);
my ($leap, $item);
  foreach $item(@leapyear){
    if ($item eq $inyear) {
     $leap = 29;
 last;
 } elsif ($item ne $inyear) {
     $leap = 28;
 }
  }
  return $leap;
}





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

Date: Mon, 5 Feb 2001 18:29:04 +1000
From: "Mike McPherson" <hafateltec@hotmail.com>
Subject: Re: Localtime Question
Message-Id: <95lobh$d7u$1@brokaw.wa.com>

http://www.perldoc.com/perl5.6/pod/func/localtime.html

This is where I am getting the info from...

"Wyzelli" <wyzelli@yahoo.com> wrote in message
news:2ktf6.4$Hq6.611@vic.nntp.telstra.net...
> Your docs must be broken cos mine say 0-364 (365 for leap year)
>
> Wyzelli
> --
> push@x,$_ for(a..z);push@x,' ';
> @z='092018192600131419070417261504171126070002100417'=~/(..)/g;
> foreach $y(@z){$_.=$x[$y]}y/jp/JP/;print;
>
>




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

Date: Mon, 05 Feb 2001 08:39:23 GMT
From: mjd@plover.com (Mark Jason Dominus)
Subject: Re: Localtime Question
Message-Id: <3a7e66b9.4d06$da@news.op.net>

In article <95ljg3$9l9$1@brokaw.wa.com>,
Mike McPherson <hafateltec@hotmail.com> wrote:
>Now you can see my delema.  Can anybody tell me what the problem is? Is it
>in my code? Is this a bug? Is this a missprint in the docs?

It is an error in the documentation.  $yday is actually 0..364, or
0..365 during leap years.

Please accept my apologies for the error.
-- 
@P=split//,".URRUU\c8R";@d=split//,"\nrekcah xinU / lreP rehtona tsuJ";sub p{
@p{"r$p","u$p"}=(P,P);pipe"r$p","u$p";++$p;($q*=2)+=$f=!fork;map{$P=$P[$f^ord
($p{$_})&6];$p{$_}=/ ^$P/ix?$P:close$_}keys%p}p;p;p;p;p;map{$p{$_}=~/^[P.]/&&
close$_}%p;wait until$?;map{/^r/&&<$_>}%p;$_=$d[$q];sleep rand(2)if/\S/;print


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

Date: Mon, 05 Feb 2001 08:30:25 GMT
From: "John W. Krahn" <krahnj@acm.org>
Subject: Re: Localtime Question
Message-Id: <3A7E65AA.7ADB7103@acm.org>

Mike McPherson wrote:
> 
> All list elements are numeric, and come straight out of the C `struct tm'.
> $sec, $min, and $hour are the seconds, minutes, and hours of the specified
> time. $mday is the day of the month, and $mon is the month itself, in the
> range 0..11 with 0 indicating January and 11 indicating December. $year is
> the number of years since 1900. That is, $year is 123 in year 2023. $wday is
> the day of the week, with 0 indicating Sunday and 3 indicating Wednesday.
> $yday is the day of the year, in the range 1..365 (or 1..366 in leap years.)
> $isdst is true if the specified time occurs during daylight savings time,
> false otherwise.
> 
> My question is this.  $yday is supposed to return 1..365 or 1..366 on a leap
> year yet when I plug the following code


man 3 localtime

       tm_yday
              The number of days since January 1, in the range  0
              to 365.


John


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

Date: Mon, 5 Feb 2001 19:14:32 +0930
From: "Wyzelli" <wyzelli@yahoo.com>
Subject: Re: Localtime Question
Message-Id: <4Cuf6.11$Hq6.938@vic.nntp.telstra.net>

"Mike McPherson" <hafateltec@hotmail.com> wrote in message
news:95lobh$d7u$1@brokaw.wa.com...
> http://www.perldoc.com/perl5.6/pod/func/localtime.html
>
> This is where I am getting the info from...
>

That is different from observed behaviour.  I suggest you report a bug.

Wyzelli
--
#Modified from the original by Jim Menard
for(reverse(1..100)){$s=($_==1)? '':'s';print"$_ bottle$s of beer on the
wall,\n";
print"$_ bottle$s of beer,\nTake one down, pass it around,\n";
$_--;$s=($_==1)?'':'s';print"$_ bottle$s of beer on the
wall\n\n";}print'*burp*';




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

Date: Mon, 05 Feb 2001 09:16:13 GMT
From: tjla@guvfybir.qlaqaf.bet (Gwyn Judd)
Subject: Re: Out of memory ...
Message-Id: <slrn97srqt.5d4.tjla@thislove.dyndns.org>

I was shocked! How could nospam_nomail@usa.net <nospam_nomail@usa.net>
say such a terrible thing:
>If somebody could help ...
>
>Trying to mirror a website on another server with a Perl Script (the Fefe's
>WebMirror), I always got an "Out of memory" error after some files.

I recommend buying more RAM.

-- 
Gwyn Judd (print `echo 'tjla@guvfybir.qlaqaf.bet' | rot13`)
   :semi-infinite: n.  See {infinite}.
From "The New Hackers Dictionary", version 4.2


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

Date: Mon, 05 Feb 2001 07:13:58 GMT
From: James Crolly <zabaon@my-deja.com>
Subject: Parsing variable
Message-Id: <95ljrj$5k8$1@nnrp1.deja.com>

How would i split a variable $ip=127.0.0.1 and divide it by the periods
and put into array 0-3?  I know you use split but i all my attempts
have failed


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


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

Date: 5 Feb 2001 01:27:38 -0600
From: logan@cs.utexas.edu (Logan Shaw)
Subject: Re: Parsing variable
Message-Id: <95lkla$kgm$1@boomer.cs.utexas.edu>

In article <95ljrj$5k8$1@nnrp1.deja.com>,
James Crolly  <zabaon@my-deja.com> wrote:
>How would i split a variable $ip=127.0.0.1 and divide it by the periods
>and put into array 0-3?  I know you use split but i all my attempts
>have failed

You're probably confused about the fact that Perl's split() uses
regular expressions, and those regular expressions use "." to match a
single occurence of any character.  So, to make this work, you
need to escape the period with a backslash, causing it to match
only periods:

	@quad = split (/\./, $ip);

Hope that helps.

  - Logan


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

Date: Mon, 05 Feb 2001 08:36:03 GMT
From: jimjim123@my-deja.com
Subject: Re: Passwd and Shadow
Message-Id: <95lolj$9v3$1@nnrp1.deja.com>

Hmmm, basically, you cannot.  Unless you find some sort of hole in the
unix security model.  You must have the appropriate permissions to
access those files.  passwd may be able to be read by all, but only
written to by root, and shadow should only be able to be read and
written by root.  If permissions are modified, then this creates huge
security issues.  If you run your script as root, then I'd suggest you
do not have people access it via the net.  Basically, if you have a
bug, or leave holes in it, they may be exploited.  I'd suggest looking
at some sort of client/server model for this sort of activity...

Because you are running it as a web application, you could write some
sort of API for system admin tasks, and write some sort of secure corba
authentication objects to allow clients access...  This is the best way
I can think of, plus it's a fairly fun project :-)

Cheers!

Hamish.

In article <kSXe6.13032$LQ2.200981@news2-win.server.ntlworld.com>,
  "Stuart Lowes" <stuart@zerostate.co.uk> wrote:
> Hi
>
> I am writing a web interface for user admin and other things, like
apache on
> a solaris box.  I am learning perl and unix as I go for my final year
degree
> project.
>
> Can anyone suggest good ways of modifying the passwd and shadow files
as
> well as the other obvious admin files.
>
> Obviously I want to avoid running the script as root if possible; but
as the
> script is run from the web I know it doesn't have the permissions to
modify
> the files.
>
> I have found in my research the shadow module, has anyone used it and
is it
> any good and does it get round the permissions problems?
> If people could suggest good ways of approaching these problems,
reading and
> writing to the passwd and shadow or point me towards articles to read
I
> would be grateful.


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


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

Date: Mon, 05 Feb 2001 07:24:17 GMT
From: rgarciasuarez@free.fr (Rafael Garcia-Suarez)
Subject: Re: perl LOCALE problem..
Message-Id: <slrn97slnh.ob.rgarciasuarez@rafael.kazibao.net>

niski wrote in comp.lang.perl.misc:
> Hello, whenever a run a perl script I get:
> 
> [niski@niski niski]$ perl brazil.pl
> perl: warning: Setting locale failed.
> perl: warning: Please check that your locale settings:
>         LANGUAGE = "en_US:en",
>         LC_ALL = "en_US",
>         LC_MESSAGES = "en_US",
>         LC_TIME = "en_US",
>         LC_NUMERIC = "en_US",
>         LC_CTYPE = "en_US",
>         LC_MONETARY = "en_US",
>         LC_COLLATE = "en_US",
>         LANG = "en_US"
>     are supported and installed on your system.
> perl: warning: Falling back to the standard locale ("C").    
> 
> 
> What should I do?

Read the perllocale manpage, esp. the section on Locale Problems.

-- 
Rafael Garcia-Suarez / http://rgarciasuarez.free.fr/


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

Date: 5 Feb 2001 09:36:08 GMT
From: ben-fuzzybear@geocities.com (Ben Okopnik)
Subject: Re: Possible buggy behavior in File::Find
Message-Id: <slrn97st7n.1dt.ben-fuzzybear@Odin.Thor>

The ancient archives of 02 Feb 2001 12:34:44 +0000 showed
nobull@mail.com of comp.lang.perl.misc speaking thus:
>ben-fuzzybear@geocities.com (Ben Okopnik) writes:
>
>> Subject: Re: Possible buggy behavior in File::Find
>
>From perldoc File::Find:
>
>       File::Find assumes that you don't alter the $_ variable.
>       If you do then make sure you return it to its original
>       value before exiting your function.

Yep, saw that...

>Note: it doesn't mention that File::Find also assumes that you don't
>change the CWD.

OK... other than here, is there a place to find out about this type of, 
err, features? Or is this a "watch your program die and learn, grasshoper" 
sort of thing? 

>> #**** Here is the problem! ****
>>         while (<Mod>) {
>
>Correct, the above modifies $_.

Urk. I thought that what it meant was "don't assign a value to $_", like 

$_ = 5;

I didn't realize it also meant implicit assignments like the above. Yeesh. 

>Insert "local $_;" before the above loop.

Got it. Thank you.

>>         foreach $found (<Mod>) {
>> This one generates no errors.
>
>Because it doesn't modify $_.


Ben Okopnik
-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-
You must not lose faith in humanity. Humanity is an ocean; if a few drops
of the ocean are dirty, the ocean does not become dirty.
 -- Mohandas K. Gandhi


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

Date: Mon, 05 Feb 2001 08:32:38 GMT
From: mjd@plover.com (Mark Jason Dominus)
Subject: Re: Radical readdir suggestion
Message-Id: <3a7e6526.4cce$d8@news.op.net>

In article <ldo-BD3CE2.16005405022001@news.wave.co.nz>,
Lawrence DčOliveiro  <ldo@geek-central.gen.new_zealand> wrote:
>What is the use of readdir returning the "." and ".." entries? 

The Principle of Least Surprise.

>Has anybody ever written a Perl script that depended on these entries
>being returned in order to work?

Yes.

>is there any reason why the semantics of readdir should not be 
>changed so it never returns "." and ".."? 

Because if you want that behavior, it is trivial to write a subroutine
that does it the way you want?


-- 
@P=split//,".URRUU\c8R";@d=split//,"\nrekcah xinU / lreP rehtona tsuJ";sub p{
@p{"r$p","u$p"}=(P,P);pipe"r$p","u$p";++$p;($q*=2)+=$f=!fork;map{$P=$P[$f^ord
($p{$_})&6];$p{$_}=/ ^$P/ix?$P:close$_}keys%p}p;p;p;p;p;map{$p{$_}=~/^[P.]/&&
close$_}%p;wait until$?;map{/^r/&&<$_>}%p;$_=$d[$q];sleep rand(2)if/\S/;print


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

Date: 5 Feb 2001 08:46:40 GMT
From: Ilmari Karonen <iltzu@sci.invalid>
Subject: Re: Radical readdir suggestion
Message-Id: <981362473.12660@itz.pp.sci.fi>

In article <3a7e6526.4cce$d8@news.op.net>, Mark Jason Dominus wrote:
>In article <ldo-BD3CE2.16005405022001@news.wave.co.nz>,
>Lawrence DčOliveiro  <ldo@geek-central.gen.new_zealand> wrote:
>
>>is there any reason why the semantics of readdir should not be 
>>changed so it never returns "." and ".."? 
>
>Because if you want that behavior, it is trivial to write a subroutine
>that does it the way you want?

I think he does have a point, though -- such a subroutine would almost
certainly end up doing the Wrong Thing on platforms where ".." is not
special in any way.

-- 
Ilmari Karonen - http://www.sci.fi/~iltzu/
"I just wish the country I lived in had a real name."
              -- John Kensmark in rec.arts.sf.composition about the U.S.

Please ignore Godzilla and its pseudonyms - do not feed the troll.


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

Date: Mon, 05 Feb 2001 09:08:36 GMT
From: tjla@guvfybir.qlaqaf.bet (Gwyn Judd)
Subject: Re: System call correct?
Message-Id: <slrn97src3.5d4.tjla@thislove.dyndns.org>

I was shocked! How could Rudolf Polzer <rpolzer@web.de>
say such a terrible thing:
>Gwyn Judd <tjla@guvfybir.qlaqaf.bet> schrieb Folgendes:
>> system("some-pgogram") = 0
>>     or die "Error: $?";
>
>You assign to the result of system?
>You have a program named some-pgogram? (SCNR)

Come here and say that.

-- 
Gwyn Judd (print `echo 'tjla@guvfybir.qlaqaf.bet' | rot13`)
Fortune's real live weird band names #763:

Waffles Against AIDS [Vafler mot AIDS]


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

Date: Mon, 05 Feb 2001 10:07:28 GMT
From: pjlees@ics.forthcomingevents.gr (Philip Lees)
Subject: Re: System call correct?
Message-Id: <3a7e7ad3.5610026@news.grnet.gr>

On Sun, 04 Feb 2001 01:59:20 GMT, "John Boy Walton"
<johngros.NOSPAM@bigpond.net.au> wrote:

>Could some one tell me if this is a correct system call?
>system ("C:/Program Files/Junker/junk.exe") || die "can't start proxy $!";
>My understanding of the docs is yes but it is not working.

Are you sure that junk.exe is really not executing? It may just be
that junk.exe returns a value that is zero or undef - either would
trigger the die message.

I fell foul of this myself recently. Try:

my $ret = system ...

Then test the value of $ret and modify the code accordingly.

Phil
--
Philip Lees
ICS-FORTH, Heraklion, Crete, Greece
Ignore coming events if you wish to send me e-mail
'The aim of high technology should be to simplify, not complicate' - Hans Christian von Baeyer


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

Date: Mon, 05 Feb 2001 08:26:31 GMT
From: mjd@plover.com (Mark Jason Dominus)
Subject: Re: Text::Template Problem
Message-Id: <3a7e63b7.4ca8$207@news.op.net>

In article <vnmr7tk06hr8l53c21u776sd94jndiqeso@4ax.com>,
Bart Lateur  <bart.lateur@skynet.be> wrote:
>@items and %items is not the same variable.

Thanks, Bart.

I kiboze clpm for Text::Template questions, but I guess I got to this
one before you did.  Thanks for taking care of it for me.


-- 
@P=split//,".URRUU\c8R";@d=split//,"\nrekcah xinU / lreP rehtona tsuJ";sub p{
@p{"r$p","u$p"}=(P,P);pipe"r$p","u$p";++$p;($q*=2)+=$f=!fork;map{$P=$P[$f^ord
($p{$_})&6];$p{$_}=/ ^$P/ix?$P:close$_}keys%p}p;p;p;p;p;map{$p{$_}=~/^[P.]/&&
close$_}%p;wait until$?;map{/^r/&&<$_>}%p;$_=$d[$q];sleep rand(2)if/\S/;print


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

Date: Mon, 05 Feb 2001 08:29:06 GMT
From: mjd@plover.com (Mark Jason Dominus)
Subject: Re: Text::Template Problem
Message-Id: <3a7e6452.4cba$10e@news.op.net>

In article <3a7e63b7.4ca8$207@news.op.net>,
Mark Jason Dominus <mjd@plover.com> wrote:
>I guess I got to this one before you did. 

I meant that the other way around.
-- 
@P=split//,".URRUU\c8R";@d=split//,"\nrekcah xinU / lreP rehtona tsuJ";sub p{
@p{"r$p","u$p"}=(P,P);pipe"r$p","u$p";++$p;($q*=2)+=$f=!fork;map{$P=$P[$f^ord
($p{$_})&6];$p{$_}=/ ^$P/ix?$P:close$_}keys%p}p;p;p;p;p;map{$p{$_}=~/^[P.]/&&
close$_}%p;wait until$?;map{/^r/&&<$_>}%p;$_=$d[$q];sleep rand(2)if/\S/;print


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

Date: 5 Feb 2001 09:08:32 GMT
From: abigail@foad.org (Abigail)
Subject: Re: This is driving me nuts and I need a guru
Message-Id: <slrn97srcg.6au.abigail@tsathoggua.rlyeh.net>

Bart Lateur (bart.lateur@skynet.be) wrote on MMDCCXV September MCMXCIII
in <URL:news:ku0s7tccmv86ommtrvh8u7cve81cj43do3@4ax.com>:
:} Tim Gaverth wrote:
:} 
:} >The problem is, on the production server (E3500 SMP) only, users are
:} >getting http server error messages, and the error log shows "attempt to
:} >initiate sql server operation with results pending". This occurs globally,
:} >on all screens of the app, and it happens sporadically. By that, I mean a
:} >user can click a submit button, get the error, go back, and it works.
:} 
:} Could it be a concurrency problem? Two users using the same database
:} access route at the same time?


Probably not; it looks like Tim is trying to do a query on a
handle that still has results waiting - they should be either
fetched, or discharded. This, however, isn't a Perl problem.



Abigail
-- 
package Just_another_Perl_Hacker; sub print {($_=$_[0])=~ s/_/ /g;
                                      print } sub __PACKAGE__ { &
                                      print (     __PACKAGE__)} &
                                                  __PACKAGE__
                                            (                )


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

Date: Mon, 5 Feb 2001 11:47:52 +0100
From: "Hans" <hkamp1@hotmail.com>
Subject: update page
Message-Id: <95m07d$ifc$1@news.tue.nl>

Problem is following:

Person A visits my page generated with database stuff.

Person B drops some stuff in the database.

When B drops stuff the page by A must be updated.

The solution of refreshing the page every x seconds I know.

From A and B I know how to get their session_id and their ip_address, but I
do not know how, by example the script activated by person B can update the
page by person A.

I do not know this is possible, or has somebody an other solution? May also
in php.

Cyah,

Hans




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

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


Administrivia:

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

	subscribe perl-users
or:
	unsubscribe perl-users

to almanac@ruby.oce.orst.edu.  

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

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

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

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


------------------------------
End of Perl-Users Digest V10 Issue 212
**************************************


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