[24946] in Perl-Users-Digest

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

Perl-Users Digest, Issue: 7196 Volume: 10

daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Thu Sep 30 11:06:55 2004

Date: Thu, 30 Sep 2004 08:05:12 -0700 (PDT)
From: Perl-Users Digest <Perl-Users-Request@ruby.OCE.ORST.EDU>
To: Perl-Users@ruby.OCE.ORST.EDU (Perl-Users Digest)

Perl-Users Digest           Thu, 30 Sep 2004     Volume: 10 Number: 7196

Today's topics:
        "su -" in CGI script ? <robert.nilsson@monet.no>
    Re: "su -" in CGI script ? <robert.nilsson@monet.no>
    Re: "su -" in CGI script ? <nospam@bigpond.com>
    Re: "su -" in CGI script ? chris-usenet@roaima.co.uk
    Re: #define-like feature in Perl <Joe.Smith@inwap.com>
        $SIG{CHLD} and system (Heinrich Mislik)
    Re: assign a left hand variable to a variable <tadmc@augustmail.com>
    Re: help with eval - BEGIN{} CHECK{} INIT{} END{} <Joe.Smith@inwap.com>
    Re: help with eval <Joe.Smith@inwap.com>
    Re: help with eval <nobull@mail.com>
    Re: How to check size of harddisk? <Joe.Smith@inwap.com>
    Re: Odd sort() problem <tadmc@augustmail.com>
    Re: Odd sort() problem <mritty@gmail.com>
    Re: Odd sort() problem (Randal L. Schwartz)
    Re: Potential bug ? (kspecial@linuxmail.org)
    Re: Precedence of exponentiation <jluis@agujero-negro.escomposlinux.org>
    Re: Precedence of exponentiation (Hunter Johnson)
    Re: process control <tadmc@augustmail.com>
    Re: Sample perl code does not work (from Perl cookbook, <tadmc@augustmail.com>
    Re: Syntax appears inconsistent - why is this? <Joe.Smith@inwap.com>
    Re: tr problem <Joe.Smith@inwap.com>
    Re: tr problem <tadmc@augustmail.com>
    Re: tr problem <thepoet_nospam@arcor.de>
    Re: tr problem <jurgenex@hotmail.com>
    Re: Trailing Spaces -- Format Perl <Joe.Smith@inwap.com>
    Re: use warnings, was Re: problem with rand on OSX <dformosa@zeta.org.au>
    Re: What is this error? <Joe.Smith@inwap.com>
    Re: Write filename w/ scalar and bareword (mt35)
        Digest Administrivia (Last modified: 6 Apr 01) (Perl-Users-Digest Admin)

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

Date: Thu, 30 Sep 2004 14:54:32 +0200
From: "Robert Nilsson" <robert.nilsson@monet.no>
Subject: "su -" in CGI script ?
Message-Id: <cjgvm8$2e6$1@services.kq.no>

Hello

I'm trying to execute a specific command from a CGI script written in PERL.
I have to be a special user so I've tried to use "su -" but it doesn't work.
The CGI script is running as the user apache on the server, right? Is that
the problem? Is there any other way to execute something with "system" as
someone else within perl?


Robert




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

Date: Thu, 30 Sep 2004 15:12:13 +0200
From: "Robert Nilsson" <robert.nilsson@monet.no>
Subject: Re: "su -" in CGI script ?
Message-Id: <cjh0ne$a6h$1@services.kq.no>

for example:

system "su - surf -c /home/surf/bin/vnc start SV_STALOVN";



/ Robert




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

Date: Thu, 30 Sep 2004 23:32:06 +1000
From: Gregory Toomey <nospam@bigpond.com>
Subject: Re: "su -" in CGI script ?
Message-Id: <2s2g6mF1fgj9iU1@uni-berlin.de>

Robert Nilsson wrote:

> Hello
> 
> I'm trying to execute a specific command from a CGI script written in
> PERL. I have to be a special user so I've tried to use "su -" but it
> doesn't work. The CGI script is running as the user apache on the server,
> right? 
We dont know, you're telling the story.

> Is that the problem? Is there any other way to execute something 
> with "system" as someone else within perl?
> 
> 
> Robert

Try a setuid wrapper, to run as the user you want.
http://httpd.apache.org/docs/suexec.html

gtoomey


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

Date: Thu, 30 Sep 2004 14:38:36 +0100
From: chris-usenet@roaima.co.uk
Subject: Re: "su -" in CGI script ?
Message-Id: <sret22-fmj.ln1@moldev.cmagroup.co.uk>

Robert Nilsson <robert.nilsson@monet.no> wrote:
> I'm trying to execute a specific command from a CGI script written in PERL.
> I have to be a special user so I've tried to use "su -" but it doesn't work.
> The CGI script is running as the user apache on the server, right? Is that
> the problem? Is there any other way to execute something with "system" as
> someone else within perl?

This is an OS question (UNIX) not a perl one. "su" requires a password. If
you're running a CGI script there's no terminal from which it can get
the password. Read "man su" for details.

I don't understand what you mean by << executing something with "system" >>,
though.

Chris


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

Date: Thu, 30 Sep 2004 11:27:37 GMT
From: Joe Smith <Joe.Smith@inwap.com>
Subject: Re: #define-like feature in Perl
Message-Id: <J4S6d.80225$wV.24107@attbi_s54>

A. Sinan Unur wrote:

> my @order = qw(var1, field2, a3, b4);

use warnings;
my @order = qw(var1 field2 a3 b4);

	-Joe


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

Date: 30 Sep 2004 12:41:04 GMT
From: Heinrich.Mislik@univie.ac.at (Heinrich Mislik)
Subject: $SIG{CHLD} and system
Message-Id: <415bfee0$0$12646$3b214f66@usenet.univie.ac.at>

perl -e '$SIG{CHLD} = "IGNORE";system("date") and die'

gives me

Thu Sep 30 14:34:22 MSZ 2004
Died at -e line 1.

I can understand, why this happens. But is it documented? Shouldn't system
set up it's own signalhandlers? The function system in C does so. Does this mean, that perl does not call this function?

Any thoughts


Cheers

-- 
Heinrich Mislik
Zentraler Informatikdienst der Universitaet Wien
A-1010 Wien, Universitaetsstrasse 7
Tel.: (+43 1) 4277-14056, Fax: (+43 1) 4277-9140



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

Date: Thu, 30 Sep 2004 07:51:13 -0500
From: Tad McClellan <tadmc@augustmail.com>
Subject: Re: assign a left hand variable to a variable
Message-Id: <slrnclo0a1.lbb.tadmc@magna.augustmail.com>

justme <eight02645999@yahoo.com> wrote:

> how do i assign a left hand side variable to a variable.
                                   ^^^^^^^^

   perldoc -q variable

      How can I use a variable as a variable name?


-- 
    Tad McClellan                          SGML consulting
    tadmc@augustmail.com                   Perl programming
    Fort Worth, Texas


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

Date: Thu, 30 Sep 2004 11:18:48 GMT
From: Joe Smith <Joe.Smith@inwap.com>
Subject: Re: help with eval - BEGIN{} CHECK{} INIT{} END{}
Message-Id: <sYR6d.139333$MQ5.53154@attbi_s52>

Alex Lee wrote:

> Does anyone know how I can silence this error from eval?

Simply redirect STDERR to a string in a BEGIN block.

linux% cat eval.pl
use strict; use warnings;
BEGIN { our $err = ''; close STDERR; open STDERR,'>',\$err; }
CHECK { our $err;      print "Compile: $err" if $err;       }
INIT  { our $err = ''; close STDERR; open STDERR,'>',\$err; }
END   { our $err;      print "Runtime: $err" if $err;       }

$_ = "abc" + 3;
$a = "xyz"; $b = 3; $_ = $a + $b;

# Uncomment the next line to watch a fatal compilation error get caught.
# $_ = "myname@example.com";

linux% perl eval.pl
Compile: Argument "abc" isn't numeric in addition (+) at eval.pl line 7.
Runtime: Argument "xyz" isn't numeric in addition (+) at eval.pl line 8.

	-Joe


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

Date: Thu, 30 Sep 2004 11:21:23 GMT
From: Joe Smith <Joe.Smith@inwap.com>
Subject: Re: help with eval
Message-Id: <T_R6d.145943$D%.65358@attbi_s51>

Brian McCauley wrote:

>   open my $e_fh, '>', \$stderr or die $!;
>   # The orginal STDERR filehandle is special and
>   # cannot be redirected to a scalar

The original STDERR filehandle is special.
In order to redirect STDERR to a scalar, it must be closed first,
as documented in 'perldoc -f open'.
	-Joe


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

Date: Thu, 30 Sep 2004 13:04:46 +0100
From: Brian McCauley <nobull@mail.com>
Subject: Re: help with eval
Message-Id: <cjgsgi$53b$1@sun3.bham.ac.uk>



Joe Smith wrote:
> Brian McCauley wrote:
> 
>>   open my $e_fh, '>', \$stderr or die $!;
>>   # The orginal STDERR filehandle is special and
>>   # cannot be redirected to a scalar
> 
> The original STDERR filehandle is special.
> In order to redirect STDERR to a scalar, it must be closed first,
> as documented in 'perldoc -f open'.

OK my statement was a simplification.  Since as a general rule one does 
not want STDERR to left without its specialness after a temporary 
redirection it is simplest just to leave the original STDERR handle 
untouched and temporarily associate the *STDERR GLOB with an ordinary 
"capture to scalar" file handle.



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

Date: Thu, 30 Sep 2004 10:31:15 GMT
From: Joe Smith <Joe.Smith@inwap.com>
Subject: Re: How to check size of harddisk?
Message-Id: <TfR6d.139101$MQ5.51368@attbi_s52>

Jason Quek wrote:

> How can I use Perl to check the size of the harddisk and the amount of
> space left?

If the OS is Linux, Solaris or SunOS, you could use this:
    http://www.inwap.com/mybin/miscunix/?disk-parts

linux# ./disk-parts
partition     Megs   start    cyls  use  mountpoint
---------    ------  -----   -----  ---  ----------
hda1            101      1      13  30%  /boot
hda2         20,002     14    2550  56%  /
hda3            509   2564      65    -  Linux swap
hda4        132,010   2629   16829    -  Win95 Ext'd (LBA)
hda5        132,010   2629   16829  19%  /home
hdd1        238,472      1   30401    -  Linux raid autodetect
md0         234,729    ---     ---  23%  /bkup

solaris# ./disk-parts
partition     Megs   start    cyls  use  mountpoint
---------    ------  -----   -----  ---  ----------
c0t1d0s2      8,759      0   14340  83%  /export/bkup
c0t3d0s0      2,000      0    2560  81%  /
c0t3d0s7      6,233   3216    7979  80%  /export/home


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

Date: Thu, 30 Sep 2004 07:22:44 -0500
From: Tad McClellan <tadmc@augustmail.com>
Subject: Re: Odd sort() problem
Message-Id: <slrnclnukk.kf2.tadmc@magna.augustmail.com>

Paul Lalli <mritty@gmail.com> wrote:


>> Actually lc{ } should be seen as a named block, according to PerlDoc.


I am unaware of this "named block" feature in Perl.

Where exactly could I read up on it?


-- 
    Tad McClellan                          SGML consulting
    tadmc@augustmail.com                   Perl programming
    Fort Worth, Texas


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

Date: Thu, 30 Sep 2004 12:35:52 GMT
From: "Paul Lalli" <mritty@gmail.com>
Subject: Re: Odd sort() problem
Message-Id: <I4T6d.4184$6f.511@trndny02>


"Tad McClellan" <tadmc@augustmail.com> wrote in message
news:slrnclnukk.kf2.tadmc@magna.augustmail.com...
> Paul Lalli <mritty@gmail.com> DID NOT write:
>
> >> Actually lc{ } should be seen as a named block, according to
PerlDoc.
>
> I am unaware of this "named block" feature in Perl.
>
> Where exactly could I read up on it?
>

Please keep track of your attributions.  Putting words in my mouth isn't
nice.

Paul Lalli




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

Date: 30 Sep 2004 05:56:10 -0700
From: merlyn@stonehenge.com (Randal L. Schwartz)
Subject: Re: Odd sort() problem
Message-Id: <1096549416.sPq51dY0m4GNLdU7p2p//A@teranews>

>>>>> "Paul" == Paul Lalli <mritty@gmail.com> writes:

Paul> Please keep track of your attributions.  Putting words in my mouth isn't
Paul> nice.

Please notice the number of chevrons.  He's quoting that you quoted
it.  That's accurate, correct?  That's all he claimed.  He didn't
claim you *said* it.

print "Just another Perl hacker,"; # the original!

-- 
Randal L. Schwartz - Stonehenge Consulting Services, Inc. - +1 503 777 0095
<merlyn@stonehenge.com> <URL:http://www.stonehenge.com/merlyn/>
Perl/Unix/security consulting, Technical writing, Comedy, etc. etc.
See PerlTraining.Stonehenge.com for onsite and open-enrollment Perl training!


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

Date: 30 Sep 2004 07:34:07 -0700
From: kspecial@linuxmail.org (kspecial@linuxmail.org)
Subject: Re: Potential bug ?
Message-Id: <365f784f.0409300634.66c389b7@posting.google.com>

Eric Bohlman <ebohlman@omsdev.com> wrote in message news:<Xns9573D6B6B4488ebohlmanomsdevcom@130.133.1.4>...
> kspecial@linuxmail.org (kspecial@linuxmail.org) wrote in 
> news:365f784f.0409291708.37da61d7@posting.google.com:
> 
> > Hey, i've got some code here that i've been having problems with, I
> > have crunched my brain and have resorted to this very place. For some
> > reason the variable @logins in the following code is being undefined
> > when there is absolutely nothing that is using @logins in such a way
> > that it would be undefined, the two functions are out of a lot longer
> 
> Actually, there is.
> 
> > @logins = ('K-sPecial perl.freak o (kspecial)');
> > 
> > logout_user(\@logins, "K-sPecial",
> > "d41d8cd98f00b204e9800998ecf8427e");
> > 
> > sub logout_user {
> >         my ($logins, $name, $pass) = @_;
> >         print "Logins ($logins) in logout_user: @$logins\r\n";
> >         foreach (@$logins) {
> 
> Throughout this loop $_ will be an *alias* to the appropriate element of 
> @logins.  That means, _inter alia_, that any assignment to $_ within 
> the loop will change the corresponding element of @logins.
> 
> >                 if (m/^\s*$name\s+/i) {
> >                         #my $rname = get_rname($logins, "$name", ' ',
> > 1);
> >                         my $md5 = ub_value ("$rname", 1);
> >                         print "Now logins ($logins) in logout_user:
> > @$logins\r\n";
> >                         print "Got $rname and $name then $md5 and
> > $pass\r\n";
> >                         if ("$pass" eq "$md5") {
> >                                 #my $return = del_login($logins,
> > "$name");
> >                                 return ($return);
> >                         }
> >                 }
> >                 return(0);
> >         }
> 
> So far we haven't seen anything *directly* affecting $_, but there were a 
> bunch of sub calls...
> 
> > }
> > 
> > sub ub_value {
> >         my ($user, @values) = @_;
> >         #$user = rem_re($user);
> >         my $userline;
> >         open (FH, "<fool.txt") or return (undef);
> >         while (<FH>) {
> 
> OOPS!  Remember that $_ is *not* automatically localized during sub calls, 
> so each line read is overwriting an element of @logins.  And, of course, 
> the very last read will put undef there.
> 
> >                 $userline = $_ if m/^$user:/i;
> >         }
> >         close(FH);
> >         print "Userline is $userline";
> >         if ($userline) {
> >                 my @results;
> >                 foreach(@values) {
> 
> Here $_ is actually being localized, so no further trashing is going on.
> 
> >                         push(@results, (split(':', "$userline"))[$_]);
> >                 }
> >                 print "Gots the @results\r\n";
> >                 return ("$results[0]") if scalar(@values) == 1;
> >                 return("@results");
> >         }
> >         else {  
> >                 print "returning 0\r\n";
> >                 return(0);
> >         }
> > }
> 
> Moral of the story: if you need to loop over an array or list and you're 
> going to be doing something non-trivial (such as calling subs) in the loop, 
> use an explicit lexical ("my") loop variable rather than implicitly using 
> $_ (which, being a global variable, has all the problems associated with 
> global variables).

Wow loads of help. I was under the impression that while (<FH>) {
would make it's own aliased $_ not at all related to the foreach ()'s
$_ in logout_user... but I read in my book and they do basicly
describe exactly what you tould me... so it's only my fault and nobody
elses. Luckily my ISP blocks port 25 outbound so I never got the
chance to report with perlbug..Thanks alot,

--K-sPecial


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

Date: Thu, 30 Sep 2004 13:25:59 +0100
From: José Luis Pérez Diez <jluis@agujero-negro.escomposlinux.org>
Subject: Re: Precedence of exponentiation
Message-Id: <VA.00000831.00e4c4ea@agujero-negro.escomposlinux.org>

In article <33anl0tjhg1rdkeivs5ucv1nrf2uibika9@4ax.com>, Bart Lateur 
wrote:
> You are confusing the two types of minus sign uses: 1) as a unary sign,
> 2) as a replacement for "+" in addition, i.e. in subtraction
>
I know it , 3 if you count also the unary operator, to use - as a sign 
only the number has to be in string or in the exponent part of a real, 
form "-0.03" or '-0.03' versus 0.03 or .3e-1 but '-.3e-1'.

I usually think of the unary operator as 0-(expression).



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

Date: 30 Sep 2004 05:18:56 -0700
From: jhunterj@gmail.com (Hunter Johnson)
Subject: Re: Precedence of exponentiation
Message-Id: <1c912331.0409300418.68cb7c3b@posting.google.com>

yf110@vtn1.victoria.tc.ca (Malcolm Dew-Jones) wrote in message news:<415ae4c3@news.victoria.tc.ca>...
> Hunter Johnson (jhunterj@gmail.com) wrote:
> : anno4000@lublin.zrz.tu-berlin.de (Anno Siegel) wrote in message news:<cjduep$eme$2@mamenchi.zrz.TU-Berlin.DE>...
> : > Abigail  <abigail@abigail.nl> wrote in comp.lang.perl.misc:
> : > 
> : > [...]
> : > 
> : > > I agree that it would have been better if Perl parsed -a ** b as 
> : > > (-a) ** b, but...
> : > 
> : > I disagree.  Traditional mathematics construes -x as (-1) * x, and
> : > consequently -a ** b = (-1) * (a ** b) = -(a ** b), because ** binds
> : > tighter than *.
>  
> : Then just as consequently a ** -b = (a ** -1) * b, also because **
> : binds tighter than *. I think there's an error in the assumptions
> : somewhere.
> 
> No, 

Well, yes.

> if a ** -b, was written in (say) Latex instead of plain text

How it would be written in LaTex (say) has no bearing on Anno's
assumptions.  At least, I couldn't find any LaTex when reading between
his lines.

I agree with his conclusion that perl parses it just fine, though. :-)

Hunter
--
http://www.hunterandlori.com


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

Date: Thu, 30 Sep 2004 07:58:48 -0500
From: Tad McClellan <tadmc@augustmail.com>
Subject: Re: process control
Message-Id: <slrnclo0o8.lbb.tadmc@magna.augustmail.com>

Matt <nospamcyatlmatt@hotmail.com> wrote:
> Yes, it is very possible that I have a serious misunderstanding about how 
> environments are inherited and propogated between processes.  I will work 
> on that.  


You need to work on it right now if you want to understand this
problem that you are currently working on.


> In any case, I was looking for a more general answer to the question.  Not 
> so much how do I solve that exact problem, but how can you execute a system 
> command so that it completes before moving on to the next process. 


system() always completes before moving on to the next statement
(unless you put it into the background with sh syntax).

system() completing or not has nothing to do with your problem.

The process model has to do with your problem.


> it doesn't work.


Have you seen the Posting Guidelines that are posted here frequently?


> Jürgen Exner wrote:
>> Matt wrote:


[ snip TOFU ]

Apparently not. :-(


-- 
    Tad McClellan                          SGML consulting
    tadmc@augustmail.com                   Perl programming
    Fort Worth, Texas


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

Date: Thu, 30 Sep 2004 07:17:05 -0500
From: Tad McClellan <tadmc@augustmail.com>
Subject: Re: Sample perl code does not work (from Perl cookbook, 2nd ed.)
Message-Id: <slrnclnua1.kf2.tadmc@magna.augustmail.com>

Staale <ksflock.takeaway@yahoo.com> wrote:

> I'm realy Sorry I did not know that *.misc was considered 'higly technical'.


You did not expect that a computer programming language newsgroup
was "technical"?

You must get surprised often.


-- 
    Tad McClellan                          SGML consulting
    tadmc@augustmail.com                   Perl programming
    Fort Worth, Texas


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

Date: Thu, 30 Sep 2004 11:38:27 GMT
From: Joe Smith <Joe.Smith@inwap.com>
Subject: Re: Syntax appears inconsistent - why is this?
Message-Id: <TeS6d.146050$D%.55455@attbi_s51>

Paul Lalli wrote:

> "David Filmer" <ineverreadanythingsenttome@hotmail.com> wrote in message
>>enclose %food (not parens). I associate curlys with hashes.
> 
> Your association is incorrect.
> ( ) are used to create arrays and hashes.
> { } are used to create hash references
> [ ] are used to create array references

I would phrase it differently.
   ( ) are used to build lists, which can populate arrays and hashes.
   { } are used to create a reference to an anonymous hash.
   [ ] are used to create a reference to an anonymous array.

	-Joe


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

Date: Thu, 30 Sep 2004 11:59:57 GMT
From: Joe Smith <Joe.Smith@inwap.com>
Subject: Re: tr problem
Message-Id: <1zS6d.139579$MQ5.103523@attbi_s52>

IanW wrote:

> If I have a string like this
> 
> "listname A short description of the list"
> 
> and I want to make the "listname" part of the string upper case, how can I
> do this with tr///?

You can't.  If you ask tr/// to change one 'l' to 'L', it will do so for all.

> Incidentally, "listname" will never have any spaces in it and will always be
> at the beginning of the string,

'beginning of the string' == 'time to use a regex, such as s///, not tr///.'

   s/^(\w*)/\U$1/;	# If words do not include punctuation
   s/^(\S*)/\U$1/;	# If they do

	-Joe


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

Date: Thu, 30 Sep 2004 07:47:38 -0500
From: Tad McClellan <tadmc@augustmail.com>
Subject: Re: tr problem
Message-Id: <slrnclo03a.lbb.tadmc@magna.augustmail.com>

IanW <onedoesnot@needto.know> wrote:

> \U is another new one one me! I need a new reference book ;-)


No new book is required.

Just read the "Quote and Quote-like Operators" section in
the documentation for the programming language that you are using:

    perldoc perlop



> Btw, I could shorten that regexp more by doing:
> 
> $_ =~ s/^(\S+)/\U$1/;


If short is your goal, then you can improve it even further:

   s/^(\S+)/\U$1/;


-- 
    Tad McClellan                          SGML consulting
    tadmc@augustmail.com                   Perl programming
    Fort Worth, Texas


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

Date: Thu, 30 Sep 2004 15:33:20 +0200
From: Christian Winter <thepoet_nospam@arcor.de>
Subject: Re: tr problem
Message-Id: <415c0b21$0$8097$9b4e6d93@newsread4.arcor-online.net>

Tad McClellan schrieb:
> IanW <onedoesnot@needto.know> wrote:
[...]
> 
>>Btw, I could shorten that regexp more by doing:
>>
>>$_ =~ s/^(\S+)/\U$1/;
> 
> 
> 
> If short is your goal, then you can improve it even further:
> 
>    s/^(\S+)/\U$1/;

Or even further:

s/^\S+/\U$&/;

-Christian


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

Date: Thu, 30 Sep 2004 13:47:38 GMT
From: "Jürgen Exner" <jurgenex@hotmail.com>
Subject: Re: tr problem
Message-Id: <_7U6d.5904$ku4.51@trnddc01>

IanW wrote:
> If I have a string like this
>
> "listname A short description of the list"
>
> and I want to make the "listname" part of the string upper case, how
> can I do this with tr///?

Why do you want to use tr?
Most people would probably choose uc() instead, in particular because uc() 
will work worldwide while coding the correct character lists for non-English 
charactes for tr must be a major endevour.

> Incidentally, "listname" will never have any spaces in it and will
> always be at the beginning of the string, so I had thought that sth
> like this might work, but it just makes the whole thing upper case:
>
> $_ =~ tr/^a-z+(?=\s+)/A-Z/;

Where did you get the idea that tr would use REs?

jue 




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

Date: Thu, 30 Sep 2004 11:42:31 GMT
From: Joe Smith <Joe.Smith@inwap.com>
Subject: Re: Trailing Spaces -- Format Perl
Message-Id: <HiS6d.290373$Fg5.257745@attbi_s53>

KVN Chary wrote:

> I need to put 26 spaces at the end of line.

Have you considered:      $space = ' ' x 26;


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

Date: 30 Sep 2004 20:24:46 +1000
From: ? the Platypus {aka David Formosa} <dformosa@zeta.org.au>
Subject: Re: use warnings, was Re: problem with rand on OSX
Message-Id: <m38yascavl.fsf@dformosa.zeta.org.au>

"David H. Adler" <dha@panix2.panix.com> writes:

[...]

> For one thing the warnings pragma is more flexible than -w.  On the
> other hand, if you're using a sufficiently old version of perl, it does
> not exist.

With 5.8.0 you could switch off -w dervived warnings using no warnings
'blah'; just as effectively as if you used use warnings;  And -w takes
only two keypresses.

-- 
Please excuse my spelling as I suffer from agraphia. See
http://dformosa.zeta.org.au/~dformosa/Spelling.html to find out more.
Free the Memes.


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

Date: Thu, 30 Sep 2004 10:43:03 GMT
From: Joe Smith <Joe.Smith@inwap.com>
Subject: Re: What is this error?
Message-Id: <XqR6d.285193$mD.266139@attbi_s02>

Binny V A wrote:

> $list = `dir /b *.htm`;
> my @LIST = split(/\s+/, $list);
> 
> This script shows the error...
> dir: /b: No such file or directory (ENOENT)

DIR is a built-in command in COMMAND.EXE or CMD.EXE on Windows.

Some versions of perl for Windows have problems when using
backticks on built-ins.

Don't expect to run MS-DOS commands on Unix-type systems.

linux% /usr/bin/dir /b *.htm
/usr/bin/dir: /b: No such file or directory
index.htm   invite.htm

linux% /usr/bin/dir -1 *.htm
index.htm
invite.htm

		-Joe


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

Date: 30 Sep 2004 03:47:43 -0700
From: mt35@linuxmail.org (mt35)
Subject: Re: Write filename w/ scalar and bareword
Message-Id: <2763816a.0409300247.395cc288@posting.google.com>

Tad McClellan <tadmc@augustmail.com> wrote in message news:<slrnclmdb1.k03.tadmc@magna.augustmail.com>...
> mt35 <mt35@linuxmail.org> wrote:
> > "A. Sinan Unur" <1usa@llenroc.ude.invalid> wrote in message news:<Xns9573594CF34A5asu1cornelledu@132.236.56.8>...
> >> mt35@linuxmail.org (mt35) wrote in news:2763816a.0409290416.1ddc5229
> >> @posting.google.com:
> 
> 
> >> > my $date = `date "+%m%d%Y"`;
>  
> >> To solve your immediate problem, add a 
> >> 
> >> chomp $date;
> > 
> > This was the problem...Is my newness to perl painfully obvious yet? ;)
> 
> 
> Not at all.
> 
> I've been using Perl for mumble,mumble years, and I still
> forget to chomp() on occasion.
> 
> Your newness to programming itself seems obvious though, as you
> did not try some debugging print()s before calling on hundreds
> of other people to look at the problem.
> 
> (so try some debugging first the next time.)

As was discussed in the first, second and sixth posts of this thread,
I had tried a print $date. However, I was unable to recognize what was
happening. So debugging is great, but you also need to know how to
interpret the results, which is where I was lacking. I also do see the
benifits of what you had written (print "date is [$date]\n";) as that
would of alerted me to the additional newline that was being injected
into the variable when the "]" printed on the newline. I will use that
method next time.

Thanks.


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

Date: 6 Apr 2001 21:33:47 GMT (Last modified)
From: Perl-Users-Request@ruby.oce.orst.edu (Perl-Users-Digest Admin) 
Subject: Digest Administrivia (Last modified: 6 Apr 01)
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: due to the current flood of worm email banging on ruby, the smtp
server on ruby has been shut off until further notice. 

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


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