[22585] in Perl-Users-Digest

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

Perl-Users Digest, Issue: 4806 Volume: 10

daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Wed Apr 2 14:06:04 2003

Date: Wed, 2 Apr 2003 11:05:08 -0800 (PST)
From: Perl-Users Digest <Perl-Users-Request@ruby.OCE.ORST.EDU>
To: Perl-Users@ruby.OCE.ORST.EDU (Perl-Users Digest)

Perl-Users Digest           Wed, 2 Apr 2003     Volume: 10 Number: 4806

Today's topics:
    Re: -M switch cannot be used the #! line (Tony Skelding)
    Re: -M switch cannot be used the #! line <nobull@mail.com>
    Re: Deducing variable name during initialization <jll@soundobjectlogic.com>
    Re: Deducing variable name during initialization <ubl@schaffhausen.de>
        Dialup using Perl <graham.drabble@lineone.net>
    Re: Help me with a Perl Script <family2@aracnet.com>
    Re: Help me with a Perl Script (Helgi Briem)
        how can i get a list of documents from perldoc? <john-s@moving-picture.com>
    Re: how can i get a list of documents from perldoc? <tassilo.parseval@rwth-aachen.de>
    Re: how can i get a list of documents from perldoc? <Graham.T.Wood@oracle.com>
        how to do psftp from perl on Windows NT (Anonymous)
    Re: Loading STDOUT into a variable <sbour@niaid.nih.gov>
        Odd UTF-8 error with Switch.pm (Simon Fairey)
    Re: Perl editors <usenet@dwall.fastmail.fm>
        Perl One-Liner <jc_va@hotmail.com>
    Re: Perl One-Liner <uri@stemsystems.com>
    Re: Perl One-Liner <tassilo.parseval@rwth-aachen.de>
    Re: Perl One-Liner <jc_va@hotmail.com>
    Re: Perl One-Liner <nobull@mail.com>
    Re: piped commands <user@someserver123abc.com>
    Re: Problem with a subroutine executing another instanc <fdee@fesfs.com>
    Re: regex question <scare.crow@oz.land>
    Re: regex question <usenet@dwall.fastmail.fm>
    Re: regex question <NoSpamPleaseButThisIsValid2@gmx.net>
    Re: Sending quit <Juha.Laiho@iki.fi>
    Re: strict, global vars and 'require' <simon.oliver@nospam.umist.ac.uk>
    Re: strict, global vars and 'require' <nobull@mail.com>
    Re: use modules with same namespace <perl-dvd@darklaser.com>
        Digest Administrivia (Last modified: 6 Apr 01) (Perl-Users-Digest Admin)

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

Date: 2 Apr 2003 08:02:49 -0800
From: tony@skelding.co.uk (Tony Skelding)
Subject: Re: -M switch cannot be used the #! line
Message-Id: <a78026a1.0304020802.610e3738@posting.google.com>

helgi@decode.is (Helgi Briem) wrote in message news:<3e89b425.298701850@news.cis.dfn.de>...
> On 1 Apr 2003 07:03:30 -0800, tony@skelding.co.uk (Tony
> Skelding) wrote:
> 
> >I want to use the -M switch on the #! line of a script.  The Camel
> >says this cannot be done and there should be no need to do it - you
> >can always put a use in the file instead.  For my purpose, putting a
> >use in the script is not an option - I can explain why if anyone is
> >interested.
> 
> I would be.  Pretty bizarre limitation if you ask me.

The reason I'd like to use -MMyModule on the #! line...

I am working on a big system containing lots of legacy scripts (Korn,
Bourne, Perl - you name it).  Some of theses scripts are run via cron,
some via rsh,  some from applications, some directly from the command
line and some from other scripts.  A lot of scripts are probably
obsolete. There are certainly a fair few that nobody seems to know
about.

I want to add some auditing code to all these scripts and and one easy
way is to auto generate a line of code at the top of each script
like...

#!/usr/bin/perl -MAudit='#!xxxxx'

where #!xxx is the original shebang line.

This effectively turns them all into Perl scripts.

The original idea was that the Audit::import() method would receive
the '#!xxxx' as an argument.  Once it has done it's necessary auditing
it would then interpret the original shebang line and pass the script
onto the appropriate interpreter (complete with any original switches)
using exec.

The trouble is it doesn't work.  I get the 'Too late for "-MAudit"
option' error.  If I don't try to pass the original shebang line it
works but then I cannot do quite what I want.  Obviously, if I try to
autogenerate a 'use Audit' as the second line of each script the
target interpreter will then blow up.


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

Date: 02 Apr 2003 17:38:11 +0100
From: Brian McCauley <nobull@mail.com>
Subject: Re: -M switch cannot be used the #! line
Message-Id: <u9adf8rh1o.fsf@wcl-l.bham.ac.uk>

tony@skelding.co.uk (Tony Skelding) writes:

> I am working on a big system containing lots of legacy scripts (Korn,
> Bourne, Perl - you name it).  Some of theses scripts are run via cron,
> some via rsh,  some from applications, some directly from the command
> line and some from other scripts.  A lot of scripts are probably
> obsolete. There are certainly a fair few that nobody seems to know
> about.
> 
> I want to add some auditing code to all these scripts and and one easy
> way is to auto generate a line of code at the top of each script
> like...
> 
> #!/usr/bin/perl -MAudit='#!xxxxx'
> 
> where #!xxx is the original shebang line.
> 
> This effectively turns them all into Perl scripts.
> 
> The original idea was that the Audit::import() method would receive
> the '#!xxxx' as an argument.

One work-round.

#!/usr/local/audit/xxxx

For each different interpreter used in the legacy scripts you'd need a
separate entry under the /usr/local/audit/ directory.  All would, in
fact, be symlinks to a C wrapper for your audit Perl script.

Does involve rather a lot of exec()s for each script invocation.

-- 
     \\   ( )
  .  _\\__[oo
 .__/  \\ /\@
 .  l___\\
  # ll  l\\
 ###LL  LL\\


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

Date: Wed, 02 Apr 2003 14:25:44 GMT
From: Jean-Louis Leroy <jll@soundobjectlogic.com>
Subject: Re: Deducing variable name during initialization
Message-Id: <lz8yutht5d.fsf@toots.sol>

>           my $foo : Person = Object->new('Person');
>           $foo->{name} = 'Homer';
>           $foo->{age} = 39;

This doesn't work because the Attribute::Handlers can't deduce the
typeglob for a lexical variable. The attributes mechanism passes a
hard reference to the handler and Attribute::Handlers scans the
corresponding stash until it finds one that contains the hard
ref. There are none for lexicals.

OTOH, if I use 'our' variables it works. Also, it seems that syntax
like 'our Dog $spot' is accepted but that doesn't override the package
in which attribute handlers are looked for.

But thanks a lot anyway, I had overlooked that idea of scanning the
stash and you pointed me in the right direction. I think I can live
with the two restrictions mentioned above.
-- 
Jean-Louis Leroy
Sound Object Logic
http://www.soundobjectlogic.com


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

Date: Wed, 02 Apr 2003 16:37:59 +0200
From: Malte Ubl <ubl@schaffhausen.de>
Subject: Re: Deducing variable name during initialization
Message-Id: <b6evq3$pe4$1@news.dtag.de>

Jean-Louis Leroy wrote:
>>          my $foo : Person = Object->new('Person');
>>          $foo->{name} = 'Homer';
>>          $foo->{age} = 39;
> 
> 
> This doesn't work because the Attribute::Handlers can't deduce the
> typeglob for a lexical variable. The attributes mechanism passes a
> hard reference to the handler and Attribute::Handlers scans the
> corresponding stash until it finds one that contains the hard
> ref. There are none for lexicals.

There is, sort of. Take a look at PadWalker.



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

Date: Wed, 02 Apr 2003 16:46:56 +0100
From: Graham Drabble <graham.drabble@lineone.net>
Subject: Dialup using Perl
Message-Id: <Xns9351AAB83C98Bgrahamdrabblelineone@ID-77355.user.dfncis.de>

I've got some scripts that require access to the internet to work. 
Whilst these work well when I'm at uni with a always on connection they 
fail when I'm at home and need to dial up before I have a net 
connection. What I need is a way to get perl to check whether a 
connection exists and, if it doesn't, dial up and supply the username 
and password for the ISP. I've had a look in the FAQs but can't find 
anything. If it helps I'm using Win 2000.

-- 
Graham Drabble
If you're interested in what goes on in other groups or want to find 
an interesting group to read then check news.groups.reviews for what 
others have to say or contribute a review for others to read.


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

Date: Wed, 02 Apr 2003 07:37:48 -0600
From: Abernathey Family <family2@aracnet.com>
Subject: Re: Help me with a Perl Script
Message-Id: <3E8AE7AC.9670E65D@aracnet.com>

"Susan G. Conger" wrote:
> 
> Hi,
> 
> i have been trying to figure out how to create a simple Perl script that
> has a list of files that it opens and add the following line at the top
> of the file:#if !defined (MAC_COMPILE) and an #endif as then last line
> in the file.  The file list should be hard codded at the top of the
> script.  Something like fileList=xyz.cpp,xyz2.cpp and then a for loop
> would read the string variable and do the operation on the file.  Can
> someone please help with this.
> 
> Thanks,
> Susan
> 
Susan, most of the kiddies who post here are much too snotty to actually
help. Most of the regulars are theology students from the
perldoc-is-revelation-from-a-deity seminary.

Here's some thoughts: Put the list of files in an array. Use a 'foreach'
to itterate through the array of files. 'grep' the file to find out if
it has the `define. If it does, make a backup copy. Open a destination
file for writing. Use a while (<>) loop to read the backup copy line by
line, making whatever mods you want, writing the results to the
destination file. Close and be done with it.

Google away for awhile in script achives looking for examples. What you
want to do is very common and I think seeing an example would be much
more helpful than trying to learn how to use perldoc.

Hope this helps.


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

Date: Wed, 02 Apr 2003 16:22:23 GMT
From: helgi@decode.is (Helgi Briem)
Subject: Re: Help me with a Perl Script
Message-Id: <3e8b0b55.386565412@news.cis.dfn.de>

On Wed, 02 Apr 2003 07:37:48 -0600, Abernathey Family
<family2@aracnet.com> wrote:

>> i have been trying to figure out how to create a simple Perl script that
>> has a list of files that it opens and add the following line at the top
>> of the file:#if !defined (MAC_COMPILE) and an #endif as then last line
>> in the file.  The file list should be hard codded at the top of the
>> script.  Something like fileList=xyz.cpp,xyz2.cpp and then a for loop
>> would read the string variable and do the operation on the file.  Can
>> someone please help with this.

>Susan, most of the kiddies who post here are much too snotty to actually
>help. Most of the regulars are theology students from the
>perldoc-is-revelation-from-a-deity seminary.

Susan,  please pay no attention to this "Abernathy Family" 
person. He/she comes here only to troll and mislead 
beginners and has no knowledge of Perl in particular nor 
programming in general.

>Google away for awhile in script achives looking for examples. 

Don't do that.  The examples in 'perldoc -q insert'
will show you how to do this correctly.  There are
scripts all over the web yes, but most of them are
awful.

>What you want to do is very common

Yes, that is true.  That is why it is addressed in 
great detail in the Frequently Asked Question 
section of the Perl documentation that comes 
bundled with every distribution of Perl.  It can
also be accessed on the web through www.perldoc.com,
but having it on your own machine is much better
in every way.

>and I think seeing an  example would be much more helpful 
>than trying to learn  how to use perldoc.

That's pretty stupid as the very first thing in the perldoc
in question is an example.  

Perldoc is easy and good.  Nothing is more helpful
to a beginning Perl programmer than to learn perldoc
and how to use it.  

In short:

- Every distribution of Perl comes with full and complete
 documentation, including a FAQ section.

- This documentation can be browsed and searched
  with  a small program named perldoc.

- Good Windows distributions for Perl are available
  at activestate.com and indigostar.com

- To use perldoc, open a command prompt window
  and type perldoc  QUERY where QUERY can be:
   DOCUMENT (for example perldoc perlrun)
    -f FUNCTION ( for example perldoc -f open)
    -q KEYWORD (for example perldoc -q insert)
  MODULE  (for example perldoc File::Find )

- The Windows distributions mentioned above also
   have the documentation in HTML format if you
  prefer that.  I use both interchangeably.
-- 
Regards, Helgi Briem
helgi DOT briem AT decode DOT is


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

Date: Wed, 2 Apr 2003 18:43:41 +0100
From: John Strauss <john-s@moving-picture.com>
Subject: how can i get a list of documents from perldoc?
Message-Id: <20030402184341.10c9ae57.john-s@moving-picture.com>

how does one get a list of documents from perldoc?

if i know the name of one of the documents, say,
perlfunc, i can run "perldoc -l perlfunc", and look
for other .pod files in perlfunc.pod's parent directory.
but that solution requires someone new to perl to know
the name of a document, etc.

is this a FAQ? i checked "perldoc -iq" with perldoc,
documentation, pagename, pod, and a few other args,
and got no hits.

anyway, i'm hoping perldoc can tell me what documents
it can show me.

so, can it?


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

Date: 2 Apr 2003 17:51:01 GMT
From: "Tassilo v. Parseval" <tassilo.parseval@rwth-aachen.de>
Subject: Re: how can i get a list of documents from perldoc?
Message-Id: <b6f7u5$35$1@nets3.rz.RWTH-Aachen.DE>

Also sprach John Strauss:

> how does one get a list of documents from perldoc?
> 
> if i know the name of one of the documents, say,
> perlfunc, i can run "perldoc -l perlfunc", and look
> for other .pod files in perlfunc.pod's parent directory.
> but that solution requires someone new to perl to know
> the name of a document, etc.

Simply try

    perldoc perl

and you'll get a list of all available manpages along with a few words
on what they are about.

Tassilo
-- 
$_=q#",}])!JAPH!qq(tsuJ[{@"tnirp}3..0}_$;//::niam/s~=)]3[))_$-3(rellac(=_$({
pam{rekcahbus})(rekcah{lrePbus})(lreP{rehtonabus})!JAPH!qq(rehtona{tsuJbus#;
$_=reverse,s+(?<=sub).+q#q!'"qq.\t$&."'!#+sexisexiixesixeseg;y~\n~~dddd;eval


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

Date: Wed, 02 Apr 2003 18:56:49 +0100
From: Graham Wood <Graham.T.Wood@oracle.com>
Subject: Re: how can i get a list of documents from perldoc?
Message-Id: <3E8B2461.ED020329@oracle.com>

This is a multi-part message in MIME format.
--------------3E2CAEE4036F155DDBF6EB4C
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 7bit

John Strauss wrote:

> anyway, i'm hoping perldoc can tell me what documents
> it can show me.
>
> so, can it?

"perldoc perl" will list what docs it can show you.

Graham

--------------3E2CAEE4036F155DDBF6EB4C
Content-Type: text/x-vcard; charset=UTF-8;
 name="Graham.T.Wood.vcf"
Content-Transfer-Encoding: 7bit
Content-Description: Card for Graham Wood
Content-Disposition: attachment;
 filename="Graham.T.Wood.vcf"

begin:vcard 
n:;Graham
x-mozilla-html:FALSE
adr:;;;;;;
version:2.1
email;internet:Graham.Wood@oracle.com
fn:Graham Wood
end:vcard

--------------3E2CAEE4036F155DDBF6EB4C--



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

Date: 2 Apr 2003 07:21:00 -0800
From: lkelias@yahoo.com (Anonymous)
Subject: how to do psftp from perl on Windows NT
Message-Id: <71b85a88.0304020721.756edaf6@posting.google.com>

I am trying to call psftp from my Perl script.  However, when I run
the script, nothing happens.  When I run the psftp command from the
command prompt, the ftp works fine.  Here's my code:

@stdOut = `psftp -b $ftpFile -bc -be -i $keyFile -batch $serverName`;

Is this the right way to call psftp?

Thanks,
Leena


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

Date: Wed, 02 Apr 2003 11:02:18 -0500
From: Stephan Bour <sbour@niaid.nih.gov>
Subject: Re: Loading STDOUT into a variable
Message-Id: <BAB073BA.6D27%sbour@niaid.nih.gov>

in article slrnb8k0hv.3tn.tadmc@magna.augustmail.com, Tad McClellan at
tadmc@augustmail.com wrote on 4/1/03 16:18:

> Stephan Bour <sbour@niaid.nih.gov> wrote:
>> in article slrnb8i0a4.27c.tadmc@magna.augustmail.com, Tad McClellan at
>> tadmc@augustmail.com wrote on 3/31/03 22:02:
>> 
>>> Stephan Bour <sbour@niaid.nih.gov> wrote:
>>> 
>>>> system("ifconfig");
>>> 
>>>> there any way to assign the content of STDOUT to a variable
>>> 
>>>  perldoc -f system
>>> 
>>> *plonk*
>>> 
>> Thanks to those who actually provided help.
> 
> 
> You're welcome.
> 
> ( the help I offered was: you should read the docs for the functions
> that you use, else you will not know what to expect when you
> call them.
> )
> 
> 
>> I realize that most of the
>> newbie questions I (and others) ask can be solved by reading a FAQ or help
>> file somewhere. What you pros have to understand is that beginners don't
>> always know where and how to look for those simple answers.
> 
> 
> I already do understand that.
> 
> I don't killfile for asking a FAQ (and that isn't what you did).
> 
> I killfile people that sign contracts without reading them,
> which _is_ what you did.
> 
> Now I know that in the real world folks don't read the docs for
> the functions they invoke, but at the *very first* sign of
> trouble they should know to go fix that.
> 
> Those that don't will be a time-sink that draws time away from
> more deserving posters.
> 
> 
>> I never post a
>> question before doing my very best to answer it myself with the resources I
>> have. Please forgive me if that sometimes is not good enough.
> 
> 
> Are you saying that you did not know how to look up Perl functions?
> 

I do consider telling me about perldoc help, so thanks. I didn't know about
that resource and I'm glad it was pointed out to me. In my struggle to learn
my first programming language I mostly rely on books but sometimes even the
simplest explanations in those beginner books are unclear to me because I
have no programming experience. I am a scientist making an exciting but
sometimes painful transition to bioinformatics and I'm pretty isolated. The
fact is, everyone struggles with the post or don't post question: should I
ask a question to the list if I know I could possibly find the answer myself
with two hours of intense guess work while it would take a knowledgeable
person 5 minutes to point me in the right direction? You tell me.
Cheers,
Stephan.



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

Date: 2 Apr 2003 08:19:56 -0800
From: simon.fairey@ft.com (Simon Fairey)
Subject: Odd UTF-8 error with Switch.pm
Message-Id: <af9e67d1.0304020819.3491c249@posting.google.com>

Hi,

Used my first 'switch' statement today and when it runs I get the
following:

Malformed UTF-8 character (unexpected continuation byte 0x9e, with no
preceding start byte) in bitwise and (&) at
/opt/customer/local/perl58/lib/5.8.0/Switch.pm line 251.

I'm running Perl 5.8 on Solaris 5.8.

I tried using the 'no utf8' pragma and making sure UTF8 is not in any
of my locale information but it still keeps coming up.

I've hear that Perl now implicitly converts everything to UTF8 and
that it causes a performance hit so I wanted to switch it off anyway
so I guess I'm hoping if I get it switched off properly my problem
will also go away?

Thank

Si


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

Date: Wed, 02 Apr 2003 15:19:23 -0000
From: "David K. Wall" <usenet@dwall.fastmail.fm>
Subject: Re: Perl editors
Message-Id: <Xns93516902EFE15dkwwashere@216.168.3.30>

Stephen Adam <00056312@brookes.ac.uk> wrote:

> I know there are editors available for Perl have these functions and
> am hoping I could get some advice on which one I should use. I am
> programing under windows XP and want an editor which will be easy to
> use for a programer relatively new to Perl though I would like as much
> functionality as possible.

http://tinyurl.com/8o3b


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

Date: Wed, 02 Apr 2003 17:28:21 GMT
From: "Buck Turgidson" <jc_va@hotmail.com>
Subject: Perl One-Liner
Message-Id: <0d7006ef08f711192bcda067ac3274b9@news.teranews.com>

I found a perl one-liner to print the os block size on Unix.  How can I tell
what is the range of the other subscripts, and their meaning?



perl -e '$a=(stat ".")[11]; print $a'




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

Date: Wed, 02 Apr 2003 17:43:16 GMT
From: Uri Guttman <uri@stemsystems.com>
Subject: Re: Perl One-Liner
Message-Id: <x7vfxwlrrg.fsf@mail.sysarch.com>

>>>>> "BT" == Buck Turgidson <jc_va@hotmail.com> writes:

  BT> I found a perl one-liner to print the os block size on Unix.  How
  BT> can I tell what is the range of the other subscripts, and their
  BT> meaning?

  BT> perl -e '$a=(stat ".")[11]; print $a'

ok, how hard can this be? what is the only call of note in that code. i
see print but that is nothing special. hmmm, the only other term is
stat. what could that be? it can't be a sub since none were declared. it
must be a perl function!! this is fun! ok, now where do we find
information about perl functions? does usa today come to mind? no, you
think perldoc like any red-blooded perl hacker would do. and what option
of perldoc shows you information about individual builtin perl
functions? yes, you know this one. it is used in so many rtfm posts here
it should be burned into your retinas. yes, it is the -f option. so
let's put it all together and we get:

perldoc -f stat

uri

-- 
Uri Guttman  ------  uri@stemsystems.com  -------- http://www.stemsystems.com
--Perl Consulting, Stem Development, Systems Architecture, Design and Coding-
Search or Offer Perl Jobs  ----------------------------  http://jobs.perl.org


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

Date: 2 Apr 2003 17:43:28 GMT
From: "Tassilo v. Parseval" <tassilo.parseval@rwth-aachen.de>
Subject: Re: Perl One-Liner
Message-Id: <b6f7g0$sse$1@nets3.rz.RWTH-Aachen.DE>

Also sprach Buck Turgidson:

> I found a perl one-liner to print the os block size on Unix.  How can I tell
> what is the range of the other subscripts, and their meaning?

By looking it up in the perldocs. From the command-line:

    perldoc -f stat

Depending on your Perl distribution, this documentation also comes as
HTML. The above can then be found by reading about the stat() function
in perlfunc.

> perl -e '$a=(stat ".")[11]; print $a'

Tassilo
-- 
$_=q#",}])!JAPH!qq(tsuJ[{@"tnirp}3..0}_$;//::niam/s~=)]3[))_$-3(rellac(=_$({
pam{rekcahbus})(rekcah{lrePbus})(lreP{rehtonabus})!JAPH!qq(rehtona{tsuJbus#;
$_=reverse,s+(?<=sub).+q#q!'"qq.\t$&."'!#+sexisexiixesixeseg;y~\n~~dddd;eval


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

Date: Wed, 02 Apr 2003 17:46:44 GMT
From: "Buck Turgidson" <jc_va@hotmail.com>
Subject: Re: Perl One-Liner
Message-Id: <c3ae96577462975e4103a27560e4826d@news.teranews.com>

"Uri Guttman" <uri@stemsystems.com> wrote in message
news:x7vfxwlrrg.fsf@mail.sysarch.com...
> >>>>> "BT" == Buck Turgidson <jc_va@hotmail.com> writes:
>
>   BT> I found a perl one-liner to print the os block size on Unix.  How
>   BT> can I tell what is the range of the other subscripts, and their
>   BT> meaning?
>
>   BT> perl -e '$a=(stat ".")[11]; print $a'
>
> ok, how hard can this be? what is the only call of note in that code. i
> see print but that is nothing special. hmmm, the only other term is
> stat. what could that be? it can't be a sub since none were declared. it
> must be a perl function!! this is fun! ok, now where do we find
> information about perl functions? does usa today come to mind? no, you
> think perldoc like any red-blooded perl hacker would do. and what option
> of perldoc shows you information about individual builtin perl
> functions? yes, you know this one. it is used in so many rtfm posts here
> it should be burned into your retinas. yes, it is the -f option. so
> let's put it all together and we get:
>
> perldoc -f stat
>
> uri
>
> --
> Uri Guttman  ------  uri@stemsystems.com  --------
http://www.stemsystems.com
> --Perl Consulting, Stem Development, Systems Architecture, Design and
Coding-
> Search or Offer Perl Jobs  ----------------------------
http://jobs.perl.org


Jeez, are you hyperventilating yet?






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

Date: 02 Apr 2003 18:38:20 +0100
From: Brian McCauley <nobull@mail.com>
Subject: Re: Perl One-Liner
Message-Id: <u9wuicpzoz.fsf@wcl-l.bham.ac.uk>

"Buck Turgidson" <jc_va@hotmail.com> writes:

> I found a perl one-liner to print the os block size on Unix.  How can I tell
> what is the range of the other subscripts, and their meaning?
> 
> perl -e '$a=(stat ".")[11]; print $a'

You appear to have a question about the 'stat' function in Perl.

You can get answers by looking up the 'stat' function in the Perl
reference manuals.  (The Perl reference manual that documents built-in
functions is 'perlfunc'.  You can print a particular entry from it
using the 'perldoc -f' command.)

Note: there's nothing very Perl-specific about this.  If you have
questions about any feature of any thing you can often find out the
answer by looking up the feature in the reference manual for the
thing.



-- 
     \\   ( )
  .  _\\__[oo
 .__/  \\ /\@
 .  l___\\
  # ll  l\\
 ###LL  LL\\


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

Date: Wed, 02 Apr 2003 09:45:55 -0500
From: stinkbomb <user@someserver123abc.com>
Subject: Re: piped commands
Message-Id: <3E8AF7A3.5363564B@someserver123abc.com>



Josef Möllers wrote:
> 
> stinkbomb wrote:
> >
 ....

> 
> Is performance such an issue for you?
> 

yeah, sort of.


-----------== Posted via Newsfeed.Com - Uncensored Usenet News ==----------
   http://www.newsfeed.com       The #1 Newsgroup Service in the World!
-----= Over 100,000 Newsgroups - Unlimited Fast Downloads - 19 Servers =-----


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

Date: Wed, 2 Apr 2003 11:12:42 -0500
From: "Jay" <fdee@fesfs.com>
Subject: Re: Problem with a subroutine executing another instance of itself
Message-Id: <%YDia.61636$r03.900402@wagner.videotron.net>

Thanks for the tip, I did and found out where my mistakes were. Now it works
fine:-)

Dje

"Bob Walton" <bwalton@rochester.rr.com> wrote in message
news:3E8A2C25.8010709@rochester.rr.com...

> Add the lines:
>
>      use strict;
>      use warnings;
>
> --
> Bob Walton
>




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

Date: Wed, 02 Apr 2003 17:32:19 +0200
From: Eric Moors <scare.crow@oz.land>
Subject: Re: regex question
Message-Id: <pan.2003.04.02.17.32.19.545838.14037@oz.land>

On Wed, 02 Apr 2003 14:08:08 +0200, Anno Siegel wrote:

> Eric Moors  <scare.crow@oz.land> wrote in comp.lang.perl.misc:
>> Hi,
>> 
>> I'm having a problem with a regex:
>> 
>> I'm trying to convert some long binary numbers
>> 
>> 	00000100001010
>> into
>> 	00-0001-0000-1010
> 
> That's a FAQ:  "perldoc -q 'with commas'" finds it.  Okay, you want a
> "-" instead of a ",", but that's the whole difference.

I've read the FAQ entry, but I still don't understand why my solution
doesn't work. I'm learning perl at the moment, and used regexes before,
kinda thought I understood them too. But why my solution fails still
isn't obvious to me. (The FAQ solution works great ofcourse)

Eric


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

Date: Wed, 02 Apr 2003 16:43:23 -0000
From: "David K. Wall" <usenet@dwall.fastmail.fm>
Subject: Re: regex question
Message-Id: <Xns93517740B5034dkwwashere@216.168.3.30>

Eric Moors <scare.crow@oz.land> wrote:

> On Wed, 02 Apr 2003 14:18:28 +0200, Tore Aursand wrote:
> 
>> On Wed, 02 Apr 2003 13:55:34 +0200, Eric Moors wrote:
>>> Subject: regex question
>> 
>> Please put the subject of your posting in the Subject field.
> 
> Ehmm...
> I thought I did just that.
> What's wrong with it?

Regexes cover a huge amount of territory, so "regex question" doesn't 
really say much about the problem.  Something like "formatting binary 
numbers with a regex" would have been more informative.  Or maybe "insert 
a dash every four digits with regex".  You get the idea.

Regexes are used so much in Perl that using a subject of "regex question" 
is like posting to an automobile group with a subject of "engine 
question."  :-)



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

Date: Wed, 02 Apr 2003 18:54:59 +0200
From: Wolf Behrenhoff <NoSpamPleaseButThisIsValid2@gmx.net>
Subject: Re: regex question
Message-Id: <3E8B15E3.D3811105@gmx.net>

Eric Moors wrote:
> 
> On Wed, 02 Apr 2003 14:08:08 +0200, Anno Siegel wrote:
> 
> > That's a FAQ:  "perldoc -q 'with commas'" finds it.  Okay, you want a
> > "-" instead of a ",", but that's the whole difference.
> 
> I've read the FAQ entry, but I still don't understand why my solution
> doesn't work. I'm learning perl at the moment, and used regexes before,
> kinda thought I understood them too. But why my solution fails still
> isn't obvious to me. (The FAQ solution works great ofcourse)

Because this line is wrong:
  $pattern =~ s{^([01]*)([01]{4})(\.[01]{4})*} {$1\.$2$3};
it should be
  $pattern =~ s{^([01]*)([01]{4})((\.[01]{4})*)} {$1\.$2$3};
                                 ^            ^
This is because your parentheses only match and capture ONE block.
Because you put the '*' outside the parens they don't capture the whole
string.

Simplified:
'aaa' =~ m/^(a)*$/;
print $1; # prints 'a' but not 'aaa'.

Wolf



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

Date: Wed, 02 Apr 2003 14:32:00 GMT
From: Juha Laiho <Juha.Laiho@iki.fi>
Subject: Re: Sending quit
Message-Id: <b6es37$29t$1@ichaos.ichaos-int>

Dale Bohl <dbohl@sgi.com> said:
>Tony Curtis wrote:
>> Dale Bohl <dbohl@sgi.com> said:
>> > I want to check the version of sendmail that's running
>> > on a group of rwmote hosts with perl.
>> 
>> Net::SMTP should be just the ticket (see method banner() ).
>
>I don't want to rely on a module.

You're already relying on quite a lot of other things.
Then why not rely on a module?

Of course, you can download the module, read through it to understand it,
copy relevant parts to your code, and be done. Then you're not relying
on the module - so, if someone finds a fault in the module and new version
is released, you'll have to check whether the changes in the module affect
the parts you copied.

Or, you can write the whole thing yourself, and one by one repeat all
the mistakes that were already found and fixed in the module.
-- 
Wolf  a.k.a.  Juha Laiho     Espoo, Finland
(GC 3.0) GIT d- s+: a C++ ULSH++++$ P++@ L+++ E- W+$@ N++ !K w !O !M V
         PS(+) PE Y+ PGP(+) t- 5 !X R !tv b+ !DI D G e+ h---- r+++ y++++
"...cancel my subscription to the resurrection!" (Jim Morrison)


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

Date: Wed, 02 Apr 2003 15:59:27 +0100
From: Simon Oliver <simon.oliver@nospam.umist.ac.uk>
Subject: Re: strict, global vars and 'require'
Message-Id: <3E8AFACF.2090000@nospam.umist.ac.uk>

joe wrote:
> LS,
> 
> I'd be so grateful if anyone could tell me how to solve my problem. It's
> like this...
> 
> Just recently I started writing my scripts using the correct codes, that is
> I use the 'strict' function. This function requires a variable to be
> declared using 'my varName'. But when I import a script via 'require
> plop.cgi', this script doesn't see the vars declared in the main script!
> 
> I've tried to use packages, but this won't do the the trick for me. Can
> anone help me out here...?!?
> 

Use fully qualified variable names like $main::var, or go OO and provide 
methods that return the values of your variables.

-- 
   Simon Oliver



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

Date: 02 Apr 2003 18:01:43 +0100
From: Brian McCauley <nobull@mail.com>
Subject: Re: strict, global vars and 'require'
Message-Id: <u965pwrfyg.fsf@wcl-l.bham.ac.uk>

"joe" <tunmaster@hotmail.com> writes:

> Just recently I started writing my scripts using the correct codes, that is
> I use the 'strict' function.

You mean pragmatic module not function.

> This function requires a variable to be declared using 'my varName'.

No it does not. The my() function is used to declare lexically scoped
variables.  Lexically scoped variables are not associated with a
package and only accessible withing the current lexical scope -
i.e. in the same source file and before the next block-closing brace.
They are not accessible via symbolic references and logically
shouldn't be available via eval(STRING) - but they are.

Most variables should be declared as lexically scoped but there are
alternatives.

The 'vars' module can be used to declare package variables.  Declaring
package variables is optional (even under strict) but you can't refer
an undeclared package variable without using an explicit package
prefix or a lexically scoped alias (see below).  The decaration of a
package variable is not lexically scoped and once a package variable
has been declared it can re referred to without qualification in any
file so long as the appropriate package directive is in effect.

The our() function can be used to declare lexically scoped alaiases
for package variables.  This is generally the preferred way to access
package variables.  Note: some people think of our() as declaring
package variables.  Most of the time it is OK to think of it this way
even though it's not strictly accurate.

> But when I import a script via 'require plop.cgi',

Why would you put the suffix '.cgi' on a file that's intended to be
loaded via the Perl require() mechanism?  When I see a file with a
 .cgi suffix I tend to assume it's designed to be called as an
executable and to communicate using the CGI API.

> this script doesn't see the vars declared in the main script!
> 
> I've tried to use packages, but this won't do the the trick for me.

How did you reach this concusion?

-- 
     \\   ( )
  .  _\\__[oo
 .__/  \\ /\@
 .  l___\\
  # ll  l\\
 ###LL  LL\\


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

Date: Wed, 02 Apr 2003 14:44:16 GMT
From: "David" <perl-dvd@darklaser.com>
Subject: Re: use modules with same namespace
Message-Id: <4HCia.24$NY5.10799@news-west.eli.net>

"peter pilsl" <pilsl_usenet@goldfisch.at> wrote in message
news:3e89f73a$1@e-post.inode.at...
>
> to split a big module into several smaller modules I use the following
way.
>
> package mymodule;
>
> use submodule1;
> use submodule2;
>
> ....
>
> where submodule1 und submodule2 is only a collection of subs.
> Cause many subs in submodule1 make calls to subs in the mainmodule and
even
> in submodule2 I didnt give submodule1 and submodule2 a own namespace,
but
> also use the same namespace.
>
> So submodule1 reads like this:
>
> package mymodule;
>
> sub1{...}
> sub2{...}
>
> 1;
>
>
> It seems to work - even with mod_perl - but it doesnt seem very ok to
me.
> Are there any drawbacks on this ?  (beside the fact that it isnt good
style)

Well essentially all you are doing is breaking out subs from your
original script.  This is a good idea when it makes sense to clump
certain groups of subs together, however, you don't need to make them
modules and use "use".  Here is a common way to just break out subs.

Name the file .pl instead of .pm
execute "require" instead of "use"

With this process, your main module would look like:

#############################
package mymodule;

require "submodule1.pl";
require "submodule2.pl";
#############################

And your submodule1 would look like:

#############################
sub1{...}
sub2{...}

1;

#############################

As you can see, with this there is no need to re-declare the
package/namespace you want these subs in, as it will be inherited from
the package in to which it was required.

Regards,
David
perl -e'print for map chr$_+1,"111100113107044099117099132"=~/(.{3})/g'





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

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.  

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


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