[12467] in Perl-Users-Digest

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

Perl-Users Digest, Issue: 6067 Volume: 8

daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Sun Jun 20 16:07:13 1999

Date: Sun, 20 Jun 99 13:00:19 -0700
From: Perl-Users Digest <Perl-Users-Request@ruby.OCE.ORST.EDU>
To: Perl-Users@ruby.OCE.ORST.EDU (Perl-Users Digest)

Perl-Users Digest           Sun, 20 Jun 1999     Volume: 8 Number: 6067

Today's topics:
    Re: %IS THIS SCRIPT ANY GOOD ?% %IS THIS SCRIPT ANY GOO (Bill)
    Re: %IS THIS SCRIPT ANY GOOD ?% %IS THIS SCRIPT ANY GOO (Eric Bohlman)
    Re: 'Perl core' or 'perl core'? <uri@sysarch.com>
    Re: 'Perl core' or 'perl core'? (Eric Bohlman)
    Re: Afraid to ask about Y2K! (n.o. s.p.a.m, m.a.a.m.)@ix.netcom.com (Clifford Orlofsky)
        bug? "Odd number of elements..." <bhuston@eden.com>
    Re: bug? "Odd number of elements..." <rick.delaney@home.com>
    Re: cookies <nemesis@stop-spam.org>
    Re: Cure for document deficiency <uri@sysarch.com>
    Re: Cure for document deficiency (Bill)
    Re: Cure for document deficiency <uri@sysarch.com>
    Re: Database Management Problem <hasant@trabas.co.id>
    Re: deleting part of a string <hasant@trabas.co.id>
    Re: function to read a line & return it (Eric Bohlman)
        Garbage collection question <eivind@solbors.no>
    Re: HOW DO I PAD A STRING IN PERL?? <uri@sysarch.com>
    Re: How to remove space <rick.delaney@home.com>
    Re: How to remove space <rootbeer@redcat.com>
    Re: How to remove space (Bill)
    Re: How to remove space (Marcel Grunauer)
        how to remove spaces in a line weiq@cs.dal.ca
    Re: Perl breaks after install; not finding "require" fi <greg@gpconsulting.com>
    Re: Perl Module query <hasant@trabas.co.id>
    Re: PerlScript vs JScript vs VBScript for WSH (Marcel Grunauer)
        Special: Digest Administrivia (Last modified: 12 Dec 98 (Perl-Users-Digest Admin)

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

Date: Sun, 20 Jun 1999 12:08:52 -0700
From: moseley@best.com (Bill)
Subject: Re: %IS THIS SCRIPT ANY GOOD ?% %IS THIS SCRIPT ANY GOOD ?%
Message-Id: <MPG.11d6dc21e3a277f4989752@206.184.139.132>

In article <376d19a3.115198437@news.cheapnet.co.uk>, sam@cheapnet.co.uk 
says...
> On Sun, 20 Jun 1999 06:46:00 -0700, moseley@best.com (Bill) wrote:
> 
> >In article <376c91be.80404466@news.cheapnet.co.uk>, sam@cheapnet.co.uk 
> >says...
> >> this is my first PERL script - i have been learning for 6 days.
> >> it works fine but is it good or crap ?
> >
> >My internal parser crashed and returned "failed to 'use strict'"
> >
> >But I'd guess the answer is if it solves your problem correctly then it 
> >is perfect.
> which platform and version of perl ?
> i am using activestate 517 on NT 4 .
> 
Pardon my obtuseness.  My point was to use strict.  perldoc strict will 
tell you more.  -w and use strict will save you time in the long run, 
IMO.

-- 
Bill Moseley mailto:moseley@best.com


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

Date: Sun, 20 Jun 1999 19:27:35 GMT
From: ebohlman@netcom.com (Eric Bohlman)
Subject: Re: %IS THIS SCRIPT ANY GOOD ?% %IS THIS SCRIPT ANY GOOD ?%
Message-Id: <ebohlmanFDn4pz.339@netcom.com>

sam@cheapnet.co.uk (sam@cheapnet.co.uk) wrote:
: this is my first PERL script - i have been learning for 6 days.
: it works fine but is it good or crap ?

Most of my comments deal with stylistic points.

It would be nice to have a "#!" line to hold the "-w" switch; on NT in a 
non-CGI context the pathname is going to be ignored, so something like

#!perl -w

will suffice.  It's also a good idea to "use strict;"; doing so will require
you to declare all your variables.

: # This script sets the home drive letter and the logon script variable
: for all users
: # in a particluar global group. Before using the module some of the
: global variables may need to # be changed.Of particular interest are 
: # $domain => NT domain name
: # logonscript => name of the login script in the User Environment
: Profile of UMD
: # homedriveletter => sets the value in the Connect X: to button in the
: User Environment Profile # # of UMD
: # SMccartin 18/06/1999 
: 
: # Required Modules
: use Win32;
: use Win32::AdminMisc;
: use Win32::NetAdmin;
: 
: 
: # File to print the output to
: $file = "c:\\users.txt";

It's poor style to use generic variable names like "$file" in anything 
but tiny, one-off scripts.  What happens if you make some changes that 
require you to use another file?

It's generally a good idea to use single quotes rather than double quotes 
when quoting purely literal strings that don't require variable 
interpolation.  In this case, using single quotes would avoid the need to 
double up the backslashes.

: open (FILE, ">$file");

Major point here.  *Always* check to see if an attempt to open a file was 
successful, and do *not* plow ahead if it wasn't!  In most cases, failure 
to check an open will merely result in you wasting lots of time 
debugging, but in some contexts it can lead to loss of data.

: 
: # declare some global variables first

You're actually initializing these, not declaring them.  If you stuck 
"my" in front of these lines, you'd be declaring them as well, and you'd 
be making them package lexicals rather than globals, which is generally a 
Good Thing.

: $domain=PARIS;

Is 'PARIS' a constant declared in one of the modules, or is it intended 
as a literal string?  If the latter, quote it.

: $logonscript='lb_logon';
: $pdc=Win32::AdminMisc::GetPDC($domain);
: $homedriveletter='M:';
: 
: # globalgroup is the name of the global group you wish to extract
: information from
: $globalgroup='lambeth';
: 
: # USER_SCRIPT_PATH
: # The path of the user's logon script, .CMD, .EXE, or .BAT file.
: $attrib1 = USER_SCRIPT_PATH;
: $attrib1value = $logonscript;
: 
: # USER_HOME_DIR_DRIVE
: # The drive letter to map the USER_HOME_DIR to if it is a UNC.
: $attrib2 = USER_HOME_DIR_DRIVE;
: $attrib2value = $homedriveletter;
: 
: # Get the list of members of the Domain Users global group from the
: pdc and place them in an # # # array called @username
: # This function like most in PERL returns a value: 0 for failure 1 for
: success
: # If 0 is returned the die statement is executed
: 
: Win32::NetAdmin::GroupGetMembers($pdc,$globalgroup,\@username) or die
: print FILE "operation aborted. I could not get group members. Check to
: ensure $globalgroup is a valid global group on domain $domain\n";


This is a rather strange way to use die().  It might be better written as:

unless (Win32...) {
  print FILE "...";
  die;
}

: 
: 
: # Main loop
: # dump any username ending with a $
: # a bug shows up workstatations in the output along with user names
: 
: # eg COMP-DC-1$ 
: 
: foreach $username(@username) {# start main for loop
: next if ($username =~ /\$$/);

It would be nice to indent here.
: 
: print FILE "$username"; # prints a list of usernames from the group
: domain users

No need for those quotes.

: 
: $out=Win32::AdminMisc::UserSetMiscAttributes($domain, $username,
: $attrib1, $attrib1value, $attrib2, $attrib2value);
: 
: 	if ($out==0) # ie function failed. 1 is success 0 is failure
: 		{print FILE "could not set attributes for user
: $username\n";}
: 	else { print FILE "\n";}

This would be a little more readable if turned around, which is easy 
given that 0 is treated as false:

if ($out) {
  print FILE "\n";
} else {
  print FILE "could not...";
}

But why do you want to log just a blank line when you set the attributes 
successfully?

: 
: } # end main for loop
: close FILE;


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

Date: 20 Jun 1999 15:15:01 -0400
From: Uri Guttman <uri@sysarch.com>
Subject: Re: 'Perl core' or 'perl core'?
Message-Id: <x77loyadl6.fsf@home.sysarch.com>

>>>>> "RD" == Rick Delaney <rick.delaney@home.com> writes:

  RD> [posted & mailed]
  RD> Larry Rosler wrote:
  >> 
  >> Uri Guttman and I are completing a paper for the upcoming Perl
  >> Conference in Monterey, on new efficient sorting techniques.  We
  >> disagree on the capitalization in the following paragraph, and are
  >> trying to get a consensus from the wise heads in this newsgroup.

  RD> Let me guess; Uri wants all caps removed.
  RD> <ducking>

<smack>

actually you are wrong. larry used the lower case as he was referring to
the perl core of the binary. i thought it would be more consistant to
capitalize Perl. hence this thread.

  RD> Because it is intended for internal use by Perl core components,
  RD> further discussion. (Perl core uses it I<only> when "dumping";
  RD> concerned with detailed perl-core behaviour or implementing a
  RD> Current categories under CPAN/modules/by-category/ include perl core
  RD> functionality is now integrated into the Perl core language: One can
  RD> and will result in mysterious hangs and/or Perl core dumps when the
  RD> Function whose names are in all upper case are reserved to the Perl
  RD> core,

nice search!

  RD> 'Perl core' seems more common.  I think that makes more sense.  The core
  RD> stuff of Perl is built into perl but it still has to do with the Perl
  RD> *language*.

one vote for me!

i agree. we are staying inside the Perl core and not executing any perl
language in the sort function. how the perl binary handles it is
irrelevent.

uri

-- 
Uri Guttman  -----------------  SYStems ARCHitecture and Software Engineering
uri@sysarch.com  ---------------------------  Perl, Internet, UNIX Consulting
Have Perl, Will Travel  -----------------------------  http://www.sysarch.com
The Best Search Engine on the Net -------------  http://www.northernlight.com


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

Date: Sun, 20 Jun 1999 19:10:21 GMT
From: ebohlman@netcom.com (Eric Bohlman)
Subject: Re: 'Perl core' or 'perl core'?
Message-Id: <ebohlmanFDn3x9.1tw@netcom.com>

Larry Rosler (lr@hpl.hp.com) wrote:
: "Even the simplest custom sort in Perl will be less efficient than using 
: the default comparison. The default sort runs entirely in C code in the 
: [Pp]erl core, but any sortsub must execute Perl code. A well-known 
: optimization is to minimize the amount of Perl code executing and to try 
: to stay inside the [Pp]erl core as much as possible. Later we will show 
: various optimization techniques for Perl sorts that will reduce the 
: amount of Perl code executed."
: 
: So, which should it be, 'Perl core' or 'perl core'?

My vote is for "perl core."  The core of the interpreter ("perl") is indeed 
made up of C code (OK, *compiled* C code), but the core of the language 
("Perl") doesn't consist of C statements.



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

Date: Sun, 20 Jun 1999 19:18:26 GMT
From: Orlofsky(n.o. s.p.a.m, m.a.a.m.)@ix.netcom.com (Clifford Orlofsky)
Subject: Re: Afraid to ask about Y2K!
Message-Id: <376d3bb8.12692975@nntp.ix.netcom.com>

On Sat, 19 Jun 1999 22:46:08 GMT, finsol@ts.co.nz wrote:

<snip>
>>
>I have read and re-read the paragraph I wrote and I still can't
>understand why you consider it incorrect.  The divide by 100 is used to
>eliminate the Year 2000 as being a leap year.  The divide by 400 is
>required to determine whether it is the exception to the rule and to
>re-include it.  By all means, do correct me again if necessary if I am
>wrong.
>
>If you consider my wording clumsy, can you provide an alternative that
>would be better understood? Perhaps then your argument would be clearer.
>
>Jocelyn Amon
>
>--
>Financial Solutions Limited
>http://www.ts.co.nz/~finsol/
>
>
>Sent via Deja.com http://www.deja.com/
>Share what you know. Learn what you don't.


My apologies. Your description of the leap year algorythm is correct.
I wrote my message at 3 in the morning and then went to bed. Obviously
I was lacking sleep when I wrote my original message! When I woke up
the next day, I realized that I had misread your paragraph. I
immediately attempted to cancel my message, but USENET had a seven
hour headstart.

But strictly speaking, does the leap year example belong on that page?
It's not really part of the Y2K syndrome. After all, if you're at the
point where you want to determine leap years, don't you already have
to successfully deal with greater than 2 digit year representations?


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

Date: Sun, 20 Jun 1999 19:12:03 GMT
From: Bill Huston <bhuston@eden.com>
Subject: bug? "Odd number of elements..."
Message-Id: <72bb3.265$o7.57164@typhoon-sf.snfc21.pbi.net>


I just found what looks like a bug. (5.004_04 built for i486-linux)
The following code has a syntax error: it uses "sub{args}" intending
"sub(args)".  Yet it passes compilation, but produces a strange warning:
"Odd number of elements in hash list at odd2 line 6":

  #!/usr/bin/perl -w
  
  sub sub_a{};
  sub sub_b  {
    my %args = ( @_ ) ;
    if (defined $args{FOO}) {            # warning on this line! 
        $args{BOZO} = sub_a{$args{FOO}}  # oops, used a{} not a()!  
    } 
    @args=%args;
    print "sizeof hash: ", scalar %args , 
          ", sizeof array: ", scalar @args , 
          ", keys: ", scalar keys %args, 
          ", values: ", scalar values %args, "\n";
  }
  sub_b(FOO=>0);

Prints:
   sizeof hash: 2/8, sizeof array: 4, keys: 2, values: 2

Questions:

1:    What is the meaning of bareword{stuff}? Shouldn't it
      produce a syntax error? (unless it is meant to
      dereference a hash reference returned by the
      sub named "bareword" ??)

2:    Why is the "Odd number..." warning produced where it is?

Thanks, 

--
Bill Huston (bhuston@eden.com)       Sun Jun 20 11:32:02 PDT 1999
http://mu.clarityconnect.net  <== things w/eyes and a brain ONLY!

"A woman without a man is like a fish without a bicycle"
      -- bumper sticker seen in Cooperstown, NY


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

Date: Sun, 20 Jun 1999 19:41:57 GMT
From: Rick Delaney <rick.delaney@home.com>
Subject: Re: bug? "Odd number of elements..."
Message-Id: <376D43C4.16B94BCC@home.com>

[posted & mailed]

Bill Huston wrote:
> 
> I just found what looks like a bug. (5.004_04 built for i486-linux)

Maybe a little one.

> The following code has a syntax error: it uses "sub{args}" intending
> "sub(args)".  Yet it passes compilation, but produces a strange warning:
> "Odd number of elements in hash list at odd2 line 6":

Nothing strange there and not a syntax error.

>   #!/usr/bin/perl -w
> 
>   sub sub_a{};

That's a weird looking sub.

>   sub sub_b  {
>     my %args = ( @_ ) ;
>     if (defined $args{FOO}) {            # warning on this line!
>         $args{BOZO} = sub_a{$args{FOO}}  # oops, used a{} not a()!

Looks like the warning is for the wrong line.  It should be for this
line where you are creating an anonymous hash with one element

    { $args{FOO} }


> Questions:
> 
> 1:    What is the meaning of bareword{stuff}? Shouldn't it
>       produce a syntax error? (unless it is meant to
>       dereference a hash reference returned by the
>       sub named "bareword" ??)

No, it means you are passing a reference to the (poorly constructed)
anonymous hash {stuff} to the subroutine bareword.

> 
> 2:    Why is the "Odd number..." warning produced where it is?

Beats me, but if you add another statement between those two lines it
then reports the correct line number.

-- 
Rick Delaney
rick.delaney@home.com


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

Date: Sun, 20 Jun 1999 13:38:12 -0600
From: "nemesis" <nemesis@stop-spam.org>
Subject: Re: cookies
Message-Id: <7kjg3a$580$1@ns2.incc.net>

You're funny.....

Get the "Perl Cookbook" from SAMS.....

Good section on PERL and cookies.....

Abigail <abigail@delanet.com> wrote in message
news:slrn7mgglj.ejb.abigail@alexandra.delanet.com...
> Leonid Goltser (leonid76@erols.com) wrote on MMCXV September MCMXCIII in
> <URL:news:7k8vk8$co4$1@autumn.news.rcn.net>:
> () Where can I find a tutoring about creating cookies with perl?
>
>
> Here's one, but it beats me what cookies have to do with Perl.
>
>
>    TOASTED-COCONUT COOKIES
>
>    1 1/2 cups sweetened flaked coconut
 .......




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

Date: 20 Jun 1999 15:20:47 -0400
From: Uri Guttman <uri@sysarch.com>
Subject: Re: Cure for document deficiency
Message-Id: <x73dzmadbk.fsf@home.sysarch.com>

>>>>> "DC" == Dave Cross <dave@dave.org.uk> writes:

  DC> On Sun, 20 Jun 1999 07:22:39 -0700, moseley@best.com (Bill) wrote:

  >> BTW -- If the documentation is so damn good, then why are those books so 
  >> popular?  Oh, I guess there is still room in this world for good 
  >> teachers.

  DC> Also it's difficult to read the online docs in the bath or on the
  DC> train.

then print them out! i first got my perl5 docs before blue camel came
out by using a company doublesided laser with 3 hole paper. i printed all
the perlpod docs at that time. made for nice reading away from the
screen.

uri

-- 
Uri Guttman  -----------------  SYStems ARCHitecture and Software Engineering
uri@sysarch.com  ---------------------------  Perl, Internet, UNIX Consulting
Have Perl, Will Travel  -----------------------------  http://www.sysarch.com
The Best Search Engine on the Net -------------  http://www.northernlight.com


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

Date: Sun, 20 Jun 1999 12:33:21 -0700
From: moseley@best.com (Bill)
Subject: Re: Cure for document deficiency
Message-Id: <MPG.11d6e1dacba3357b989754@206.184.139.132>

In article <x73dzmadbk.fsf@home.sysarch.com>, uri@sysarch.com says...
> >>>>> "DC" == Dave Cross <dave@dave.org.uk> writes:
>   DC> Also it's difficult to read the online docs in the bath or on the
>   DC> train.
> 
> then print them out! i first got my perl5 docs before blue camel came
> out by using a company doublesided laser with 3 hole paper. i printed all
> the perlpod docs at that time. made for nice reading away from the
> screen.

But did you print on water proof paper?

I'm waiting for the docs to come out on Audio tape.  Perfect for those 
long family vacations in the car.

-- 
Bill Moseley mailto:moseley@best.com


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

Date: 20 Jun 1999 15:54:25 -0400
From: Uri Guttman <uri@sysarch.com>
Subject: Re: Cure for document deficiency
Message-Id: <x7r9n68x72.fsf@home.sysarch.com>

>>>>> "B" == Bill  <moseley@best.com> writes:

  B> In article <x73dzmadbk.fsf@home.sysarch.com>, uri@sysarch.com says...
  >> >>>>> "DC" == Dave Cross <dave@dave.org.uk> writes:
  DC> Also it's difficult to read the online docs in the bath or on the
  DC> train.
  >> 
  >> then print them out! i first got my perl5 docs before blue camel came
  >> out by using a company doublesided laser with 3 hole paper. i printed all
  >> the perlpod docs at that time. made for nice reading away from the
  >> screen.

  B> But did you print on water proof paper?

no, but the stains add to the flavor of the text.

  B> I'm waiting for the docs to come out on Audio tape.  Perfect for those 
  B> long family vacations in the car.

i am sure that will put your kids to sleep for the duration of the
trip. hmmm, sounds like a neat thing to market! sleeping aids for
children: tom c. reciting the perl docs on tape or cd.

uri

-- 
Uri Guttman  -----------------  SYStems ARCHitecture and Software Engineering
uri@sysarch.com  ---------------------------  Perl, Internet, UNIX Consulting
Have Perl, Will Travel  -----------------------------  http://www.sysarch.com
The Best Search Engine on the Net -------------  http://www.northernlight.com


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

Date: Mon, 21 Jun 1999 01:20:49 +0700 (JAVT)
From: Hasanuddin Tamir <hasant@trabas.co.id>
To: comp.lang.perl.misc@list.deja.com
Subject: Re: Database Management Problem
Message-Id: <Pine.LNX.3.96.990621011844.16772C-100000@borg.intern.trabas.co.id>

On Fri, 18 Jun 1999, Tim Forman wrote:

forman] sub DeleteCarFromDatabase
forman] {
forman] 
forman] open(DB,"<" . "$cardatabase") || die " Cannot open $cardatabase \n";
forman] 
forman] open (NEWFILE, ">foo2.txt") || die "Can't open a new file\n";
forman] 
forman] while (<DB>)
forman]   {
forman]    $db = $_;
forman]    ($db_id,$make,$model,$year,$miles,$price,$etc,$image)=split("::",$db);
forman] 
forman]    if($db_id != $id){
forman]       print (NEWFILE "$db");
forman]    }#end if
forman] 
forman]   }
forman]  close(NEWFILE);
forman]  close(DB);
forman] `mv foo2.txt foo.txt`;
        ^^^^^^^^^^^^^^^^^^^^^
forman] }

I'm sure that rename() can handle this.


-hasan-

Hasanuddin Tamir              hasant@trabas.co.id
Meitraco Bahana Sejahtera        www.trabas.co.id
=================================================
 ...and the news server screws up again :-(




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

Date: Mon, 21 Jun 1999 01:32:13 +0700 (JAVT)
From: Hasanuddin Tamir <hasant@trabas.co.id>
To: comp.lang.perl.misc@list.deja.com
Subject: Re: deleting part of a string
Message-Id: <Pine.LNX.3.96.990621012916.17964A-100000@borg.intern.trabas.co.id>

On 18 Jun 1999, Abigail wrote:

abigail] JQ (pigs_can_fly@mindless.com) wrote on MMCXVII September MCMXCIII in
abigail] <URL:news:376a79fc.62397051@news.cyberway.com.sg>:
abigail] // 
abigail] // I need to delete whatever follows the LAST occurence of /, including
abigail] // the last /
abigail] 
abigail] 
abigail] s{/[^/]*$}{};

or,

use File::Basename;
$string_without_whatever_follows_last_slash_including_itself =
   dirname($original_string);


-hasan-
Hasanuddin Tamir              hasant@trabas.co.id
Meitraco Bahana Sejahtera        www.trabas.co.id
=================================================
 ...and the news server screws up again :-(




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

Date: Sun, 20 Jun 1999 19:01:23 GMT
From: ebohlman@netcom.com (Eric Bohlman)
Subject: Re: function to read a line & return it
Message-Id: <ebohlmanFDn3IB.1D4@netcom.com>

Rick Delaney (rick.delaney@home.com) wrote:
: [Aside] Just what exactly is the definition of 'script kiddie', that I
: see mentioned here so often?  I think I resemble that remark.

Someone who attempts to write Perl (or, rarely, other) code, often for
pay, without having even an elementary mental model of how the language
works and with little or no desire to develop one.  IOW, someone who
thinks at the level of "tell me what to type to make ___ happen," or
alternatively someone who can recite code but can't comprehend it.  Not to
be confused with a novice programmer, who is someone who realizes that he
needs a mental model to code properly and is in the early stages of
developing one.  The script kiddie treats any piece of Perl code as a 
black box no matter what its size is.  The novice programmer, OTOH, tries 
to understand code.





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

Date: Sun, 20 Jun 1999 19:01:20 +0000
From: Eivind Trondsen <eivind@solbors.no>
Subject: Garbage collection question
Message-Id: <376D3A80.8D294625@solbors.no>


Hi

I am migrating a large mass of users from one database to another, and
the process involves some mailsending and password generation, so I rely
on my favorite language rather than do it all on the SQL level.

This means I'll have a large array of hashes in memory. My question is
this;

Will the construct

while ( $user = pop @$users ) { 
	...
}

be better than

foreach $user ( @$users ) { 
	...
}

in that it will allow the array elements (hashes) to be garbage
collected as I go along? I believe it is so, but would like confirmation
from someone more guru than myself (I'm _positive_ someone that fits
that bill must exist somewhere :-)

Cheers!

-- 
Eivind Trondsen - SOL Bxrs AS               http://www.solbors.no
Tlf  22 11 35 14        Fax  22 11 35 13          Mob  924 14 969

Feeling amorous, she looked under the sheets and cried, "Oh, no,
it's Microsoft!"


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

Date: 20 Jun 1999 15:04:23 -0400
From: Uri Guttman <uri@sysarch.com>
Subject: Re: HOW DO I PAD A STRING IN PERL??
Message-Id: <x7aetuae2w.fsf@home.sysarch.com>

>>>>> "JS" == Jonathan Stowe <gellyfish@gellyfish.com> writes:

  JS> On Sun, 20 Jun 1999 06:23:19 GMT Perry Fecteau wrote:
  >> Tad McClellan wrote:
  >>> 
  >>> Perry Fecteau (perfecto@ct2.nai.net) wrote:
  >>> : for example, i want 23 to look like 00023...
  >>> 
  >>> : how do i do that??
  >>> 
  >>> $num = '000' . $num if $num == 23;
  >>> 
  >> wrong.  i want fixed length padding.  ie, i want a 5 digit number zero
  >> fill if the number is less than 5 digits.

and you want a sense of humor. both tad's and my solutions are very
facetious and goofy perl.

  JS> Ah but you didnt say that did you ?

  JS> Then you probably want to read what the documentation says about the
  JS> functions sprintf & printf .

or read the very nice answer to the faq on this subject.

uri

-- 
Uri Guttman  -----------------  SYStems ARCHitecture and Software Engineering
uri@sysarch.com  ---------------------------  Perl, Internet, UNIX Consulting
Have Perl, Will Travel  -----------------------------  http://www.sysarch.com
The Best Search Engine on the Net -------------  http://www.northernlight.com


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

Date: Sun, 20 Jun 1999 19:06:22 GMT
From: Rick Delaney <rick.delaney@home.com>
Subject: Re: How to remove space
Message-Id: <376D3B6E.C5215CA3@home.com>

[posted & mailed]

weicai@my-deja.com wrote:
> 
> I am wondering if anyone know the right way to
> remove the spaces at the begin of a new line

Probably thousands know how to do that.  Thousands have certainly asked
before.  If you'd like to know too, read the FAQ:

    How do I strip blank space from the beginning/end of a string?

If you can't find this, don't worry.  I'm sure tchrist will be sending
you one shortly.

-- 
Rick Delaney
rick.delaney@home.com


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

Date: Sun, 20 Jun 1999 12:10:46 -0700
From: Tom Phoenix <rootbeer@redcat.com>
Subject: Re: How to remove space
Message-Id: <Pine.GSO.4.02A.9906201210060.20762-100000@user2.teleport.com>

On Sun, 20 Jun 1999 weicai@my-deja.com wrote:

> I am wondering if anyone know the right way to
> remove the spaces at the begin of a new line

Yes, the people who put that answer into the FAQ would know. :-)

-- 
Tom Phoenix       Perl Training and Hacking       Esperanto
Randal Schwartz Case:     http://www.rahul.net/jeffrey/ovs/



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

Date: Sun, 20 Jun 1999 12:24:53 -0700
From: moseley@best.com (Bill)
Subject: Re: How to remove space
Message-Id: <MPG.11d6dfe45b589e6b989753@206.184.139.132>

In article <7kj9j1$lic$1@nnrp1.deja.com>, weicai@my-deja.com says...
> "               the begin has 15 space"
> 
> what I want is the folloing
> "the bigin has 15 space"

one way:

s/^\x20{15}the begin/the bigin/;

perldoc perlre

-- 
Bill Moseley mailto:moseley@best.com


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

Date: Sun, 20 Jun 1999 19:09:18 GMT
From: marcel.grunauer@lovely.net (Marcel Grunauer)
Subject: Re: How to remove space
Message-Id: <376f3c3f.34268064@enews.newsguy.com>

On Sun, 20 Jun 1999 17:49:24 GMT it came to pass that
weicai@my-deja.com produced 20 lines that required the following
response:

>Hi, Friend
>
>I am wondering if anyone know the right way to
>remove the spaces at the begin of a new line

The right way is to read perlfaq4: How do I strip blank space from the
beginning/end of a string?

Marcel



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

Date: Sun, 20 Jun 1999 18:04:59 GMT
From: weiq@cs.dal.ca
Subject: how to remove spaces in a line
Message-Id: <7kjag6$lrr$1@nnrp1.deja.com>

Hi, Friends

I am wondering if anyone can help me how to remove the spaces in the
begining of a new line

such as when user entered
"           there are 11 or more spaces in the front"
-----------------------------------------------
What I want is: remove all the spaces in the begining and
let the spaces in other places unchanged. Such as:

"there are 11 or more spaces in the front"


Thanks and have nice day

Wei


Sent via Deja.com http://www.deja.com/
Share what you know. Learn what you don't.


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

Date: Sun, 20 Jun 1999 12:04:10 -0700
From: Greg Postlewait <greg@gpconsulting.com>
Subject: Re: Perl breaks after install; not finding "require" files in @INC
Message-Id: <376D3B2A.C047F8AF@gpconsulting.com>

After reading 300+ bug reports at ActiveState, I've learned this is a bug
with the current release (5.517)

Greg Postlewait wrote:

> I just upgraded by perl install from 4.x to the latest from activestate
> (5.x).  ALL of my scripts are now failing, so something has gone
> terribly wrong.  After reading as many FAQ's, tips, etc, I found the
> "PerlIS-ERR.TXT" file in \bin which has helped a lot.
>
> *** 'D:\inetpub\wwwroot\dworld\cgi-bin\job_editor.cgi' error message at:
> 1999/06/20 10:53:30
> Can't locate dworld_globals.cgi in @INC (@INC contains: C:/PERL/lib
> C:/PERL/site/lib .) at D:\inetpub\wwwroot\dworld\cgi-bin\job_editor.cgi
> line 4.
>
> JOB_EDITOR.CGI starts off as such...
>
> #!/usr/bin/perl
> require "dworld_globals.cgi";
> require "job_services.cgi";
> require "jobpagebuild_services.cgi";
>
> #######################################
>
> &parse_input(*form_fields);
> $action = $form_fields{"action"};
> if ($action eq ""){
>   &EditJob;
> }
>
> etc...
>
> I've tried doing a chdir before the "require" statements, but that
> doesn't work (neither does lib).
>
> ANY ideas?
>
> Thanks,
>
> Greg Postlewait



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

Date: Mon, 21 Jun 1999 01:13:16 +0700 (JAVT)
From: Hasanuddin Tamir <hasant@trabas.co.id>
To: comp.lang.perl.misc@list.deja.com
Subject: Re: Perl Module query
Message-Id: <Pine.LNX.3.96.990621010626.16772B-100000@borg.intern.trabas.co.id>

On Fri, 18 Jun 1999, evil Japh wrote:

jeffp] Date: Fri, 18 Jun 1999 18:56:39 -0400
jeffp] From: evil Japh <jeffp@crusoe.net>
jeffp] To: comp.lang.perl.misc@list.deja.com
jeffp] Subject: Re: Perl Module query
jeffp] Reply-To: comp.lang.perl.misc@list.deja.com
jeffp] 
jeffp] > Is there a simple way to determine what modules are loaded on a server
jeffp] > with out asking the ISP or Admin?
jeffp] 
jeffp] Yes, it's the pminst program in the Perl Power Tools, available at
jeffp] http://language.perl.com/ppt.

No, it's part of pmtools:

   http://language.perl.com/misc/pmtools-1.00.tar.gz

(and `pmeth' is missing from the list on the `Makefile.PL' file.)

It's totally different idea.  PPT implements unix utilities
in Perl way.  PMTools (don't know how to correctly write this)
is all about Perl modules.


-hasan-
Hasanuddin Tamir              hasant@trabas.co.id
Meitraco Bahana Sejahtera        www.trabas.co.id
=================================================
 ...and the news server screws up again :-(




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

Date: Sun, 20 Jun 1999 19:16:39 GMT
From: marcel.grunauer@lovely.net (Marcel Grunauer)
Subject: Re: PerlScript vs JScript vs VBScript for WSH
Message-Id: <37703ccf.34412021@enews.newsguy.com>

On Sun, 20 Jun 1999 12:16:05 +0900 it came to pass that "Sangjin Han"
<truejaws@bbs.para.co.kr> used an obscure tool Microsoft Outlook
Express 5.00.2314.1300 and produced 35 lines that required the
following response:

>I read a sample wsh vbscript for printing Environment variables.
>
[snip offensive VBScript code]
>
>And I could write an equivalent WSH-JScript source easily.
[snip offensive JScript code]
>-------------------------------------
>
>But I could not write the PerlScript version.
>
>I hope the perl version does not use $ENV variable.
It most certainly won't.

The normal way to print the environment variables is:

#!/usr/bin/perl -w
use strict;

foreach (keys %ENV) {
  print "$_ = $ENV{$_}\n";
}

As for opening a shell and writing to it from within WSH, I'd probably
use something like Win32::OLE.


Marcel



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

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


Administrivia:

Well, after 6 months, here's the answer to the quiz: what do we do about
comp.lang.perl.moderated. Answer: nothing. 

]From: Russ Allbery <rra@stanford.edu>
]Date: 21 Sep 1998 19:53:43 -0700
]Subject: comp.lang.perl.moderated available via e-mail
]
]It is possible to subscribe to comp.lang.perl.moderated as a mailing list.
]To do so, send mail to majordomo@eyrie.org with "subscribe clpm" in the
]body.  Majordomo will then send you instructions on how to confirm your
]subscription.  This is provided as a general service for those people who
]cannot receive the newsgroup for whatever reason or who just prefer to
]receive messages via e-mail.

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.  

To submit articles to comp.lang.perl.misc (and this Digest), send your
article to perl-users@ruby.oce.orst.edu.

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.

The Meta-FAQ, an article containing information about the FAQ, is
available by requesting "send perl-users meta-faq". The real FAQ, as it
appeared last in the newsgroup, can be retrieved with the request "send
perl-users FAQ". Due to their sizes, neither the Meta-FAQ nor the FAQ
are included in the digest.

The "mini-FAQ", which is an updated version of the Meta-FAQ, is
available by requesting "send perl-users mini-faq". It appears twice
weekly in the group, but is not distributed in the digest.

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 V8 Issue 6067
**************************************

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