[22742] in Perl-Users-Digest

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

Perl-Users Digest, Issue: 4963 Volume: 10

daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Fri May 9 09:07:16 2003

Date: Fri, 9 May 2003 06:05:10 -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           Fri, 9 May 2003     Volume: 10 Number: 4963

Today's topics:
    Re: haiku for french perl <roderick991@yahoo.com>
    Re: How do you create a biniary file in Perl. (Anno Siegel)
        How many groups have a regex? (i5513)
    Re: How many groups have a regex? <auch-ich-m@g-kein-spam.com>
    Re: How many groups have a regex? (Anno Siegel)
        How many groups? SOLVED! (i5513)
    Re: How many groups? SOLVED! (Anno Siegel)
    Re: How to find the size of a directory??? <bigus AT creationfactor DOT net>
    Re: How to find the size of a directory??? (Helgi Briem)
    Re: How to find the size of a directory??? <jurgenex@hotmail.com>
    Re: How to find the size of a directory??? <bigus AT creationfactor DOT net>
    Re: ignore first line of input file <nobull@mail.com>
    Re: Logic(al nightmare!) (Tad McClellan)
    Re: Newbie how to split file (Anno Siegel)
    Re: Perl Directories (SuperStar)
    Re: Perl Directories <nobull@mail.com>
    Re: Perl Directories <nobull@mail.com>
    Re: Perl Directories <jurgenex@hotmail.com>
    Re: Perl Directories (Helgi Briem)
        python -> perl help urllib.urlopen <k.robert@gmx.de>
    Re: Recursive copying question (Anno Siegel)
        Total Utter Just Delivered Perl Newbie with a Pignant Q <roderick991@yahoo.com>
    Re: Total Utter Just Delivered Perl Newbie with a Pigna <josef.moellers@fujitsu-siemens.com>
    Re: Total Utter Just Delivered Perl Newbie with a Pigna (Anno Siegel)
    Re: Total Utter Just Delivered Perl Newbie with a Pigna <roderick991@yahoo.com>
    Re: web page contents into a perl script <tassilo.parseval@rwth-aachen.de>
    Re: web page contents into a perl script (Helgi Briem)
    Re: web page contents into a perl script <ubl@schaffhausen.de>
    Re: web page contents into a perl script (Tad McClellan)
    Re: web page contents into a perl script (Tad McClellan)
        Digest Administrivia (Last modified: 6 Apr 01) (Perl-Users-Digest Admin)

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

Date: Fri, 9 May 2003 11:03:26 +1000
From: "Rod" <roderick991@yahoo.com>
Subject: Re: haiku for french perl
Message-Id: <b9g8su$j9nps$1@ID-82947.news.dfncis.de>


serge.john.swilting <serge.john.swilting@wanadoo.fr> wrote in message
news:b8ugvp$h6c$1@news-reader14.wanadoo.fr...
: #!/usr/bin/env perl
:
: #use strict;
: #
: #
: #troll haiku french perl programmeur
: ###################
: #big bad in english
: ###################
: #new version of language wiever
: ###################
: #my wife: http://perso.wanadoo.fr/john.swilting/only/bellaminette.xpm
: #answer1: http://perso.wanadoo.fr/john.swilting/only/answer1.xpm
: #answer2: http://perso.wanadoo.fr/john.swilting/only/answer2.xpm
:
: #do you like my wife
: #
: #yes
: #
: #if(/$answer1/)
: #ok its nice
: #if(/$answer2/)
: #bad be careful
: #
: ###################
: #new version of language viewer
: ###################
: #
: #serge.john.swilting@wanadoo.fr
: #
: #dedicasse au statisticien
:
: print "do you like my wife";
: chomp($answer);
: $answer=<STDIN>;
:
better be careful here !




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

Date: 9 May 2003 11:24:05 GMT
From: anno4000@lublin.zrz.tu-berlin.de (Anno Siegel)
Subject: Re: How do you create a biniary file in Perl.
Message-Id: <b9g34l$qd6$2@mamenchi.zrz.TU-Berlin.DE>

Tassilo v. Parseval <tassilo.parseval@post.rwth-aachen.de> wrote in comp.lang.perl.misc:
     
>     seek F, SEEK_SET, 20;           # jump to 20th byte
>     seek F, SEEK_CUR, 20;           # 20 bytes ahead from the current pos
>     seek F, SEEK_END, -20;          # 20 bytes before EOF

You have the second and third parameter of seek swapped.

Anno


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

Date: 9 May 2003 05:23:03 -0700
From: i5513@hotmail.com (i5513)
Subject: How many groups have a regex?
Message-Id: <a657ec02.0305090423.1d2d5f9e@posting.google.com>

Hi again, I need a copy of $1..$last after a $var =~ /$er/ is done.

Is there any var that says how many groups are there at last expression evaluate?

For example, I'd like:

$var =~ /$er/;
# $n_groups = n_match_parents ($er) 
map { $groups{$_} = ${$_}} 0 .. $n_groups;

How I can get $n_groups?
Thank you very much.


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

Date: Fri, 9 May 2003 14:45:05 +0200
From: =?ISO-8859-1?Q?Andr=E9?= Malo <auch-ich-m@g-kein-spam.com>
Subject: Re: How many groups have a regex?
Message-Id: <1b265mi1r6mnandparker@news.perlig.de>

* i5513 wrote:

> Hi again, I need a copy of $1..$last after a $var =3D~ /$er/ is done.
>
> Is there any var that says how many groups are there at last expression e=
valuate?

Just count the opening parentheses in $er, which aren't followed by a
question mark.

nd
--=20
package Hacker::Perl::Another::Just;print
qq~@{[reverse split/::/ =3D>__PACKAGE__]}~;

#  Andr=E9 Malo  #  http://www.perlig.de  #


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

Date: 9 May 2003 12:46:46 GMT
From: anno4000@lublin.zrz.tu-berlin.de (Anno Siegel)
Subject: Re: How many groups have a regex?
Message-Id: <b9g7vm$1lk$2@mamenchi.zrz.TU-Berlin.DE>

i5513 <i5513@hotmail.com> wrote in comp.lang.perl.misc:
> Hi again, I need a copy of $1..$last after a $var =~ /$er/ is done.
> 
> Is there any var that says how many groups are there at last expression
> evaluate?
> 
> For example, I'd like:
> 
> $var =~ /$er/;
> # $n_groups = n_match_parents ($er) 
> map { $groups{$_} = ${$_}} 0 .. $n_groups;
> 
> How I can get $n_groups?

Find the "@-" and "@+" arrays in perlvar.  $#- turns out to be the
number of captures in the last match.

Anno


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

Date: 9 May 2003 05:41:20 -0700
From: i5513@hotmail.com (i5513)
Subject: How many groups? SOLVED!
Message-Id: <a657ec02.0305090441.4e716f8b@posting.google.com>

Well, I'm sorry, I was thinking ...

@group = ();
$i = 1;
while (defined (${$i}))
{
  $group[$i-1] = ${$i};
  $i++;
}


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

Date: 9 May 2003 12:49:57 GMT
From: anno4000@lublin.zrz.tu-berlin.de (Anno Siegel)
Subject: Re: How many groups? SOLVED!
Message-Id: <b9g85l$1lk$3@mamenchi.zrz.TU-Berlin.DE>

i5513 <i5513@hotmail.com> wrote in comp.lang.perl.misc:
> Well, I'm sorry, I was thinking ...
> 
> @group = ();
> $i = 1;
> while (defined (${$i}))
> {
>   $group[$i-1] = ${$i};
>   $i++;
> }

Have you tried this under strictures?  "${$i}" is a symbolic reference.
You really don't need that here.  See the replies to your original
question.

Anno


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

Date: Fri, 9 May 2003 11:52:12 +0100
From: "Bigus" <bigus AT creationfactor DOT net>
Subject: Re: How to find the size of a directory???
Message-Id: <b9g1a6$sje@newton.cc.rl.ac.uk>


"Malte Ubl" <ubl@schaffhausen.de> wrote in message
news:b9fr0l$lqt$1@news.dtag.de...
> Jürgen Exner wrote:
> > Or do you mean the size of all files in this directory and recursively
all
> > sub directories? Then have a look at File::Find. In the wanted()
function
> > just add the size of each file (from -s) in a global variable.
>
> Or better yet, a lexical variable with its scope outsite the wanted
closure.
>

or if it's Windows, then issue a DIR command and extract the total size from
the 2nd to last line of it's output ;-)

Bigus




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

Date: Fri, 09 May 2003 11:10:46 GMT
From: helgi@decode.is (Helgi Briem)
Subject: Re: How to find the size of a directory???
Message-Id: <3ebb8c6f.2492301740@news.cis.dfn.de>

On Fri, 9 May 2003 11:52:12 +0100, "Bigus" <bigus AT
creationfactor DOT net> wrote:

>> Jürgen Exner wrote:
>> > Or do you mean the size of all files in this directory and recursively
>> >all sub directories? Then have a look at File::Find. In the wanted()
>> >function just add the size of each file (from -s) in a global variable.

>or if it's Windows, then issue a DIR command and extract the
>total size from the 2nd to last line of it's output ;-)
 
That will only work for one directory level.  Juergen's
suggestion to use File::Find is still the best suggestion 
(by far).


-- 
Regards, Helgi Briem
helgi DOT briem AT decode DOT is


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

Date: Fri, 09 May 2003 12:47:55 GMT
From: "Jürgen Exner" <jurgenex@hotmail.com>
Subject: Re: How to find the size of a directory???
Message-Id: <%rNua.6462$zu6.4051@nwrddc02.gnilink.net>

Helgi Briem wrote:
> On Fri, 9 May 2003 11:52:12 +0100, "Bigus" <bigus AT
> creationfactor DOT net> wrote:
>
>>> Jürgen Exner wrote:
>>>> Or do you mean the size of all files in this directory and
>>>> recursively all sub directories? Then have a look at File::Find.
>>>> In the wanted() function just add the size of each file (from -s)
>>>> in a global variable.
>
>> or if it's Windows, then issue a DIR command and extract the
>> total size from the 2nd to last line of it's output ;-)
>
> That will only work for one directory level.  Juergen's
> suggestion to use File::Find is still the best suggestion
> (by far).

Thanks, but actually if you want a non-portable non-Perl solution for the
recursive case (like "dir" for non-recursive onWindows) then "du -s" or "dir
/s" would be the answer.
But of course in that case the OP would not have asked in a Perl NG.

jue
jue




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

Date: Fri, 9 May 2003 13:56:23 +0100
From: "Bigus" <bigus AT creationfactor DOT net>
Subject: Re: How to find the size of a directory???
Message-Id: <b9g8hq$13as@newton.cc.rl.ac.uk>


"Helgi Briem" <helgi@decode.is> wrote in message
news:3ebb8c6f.2492301740@news.cis.dfn.de...
> On Fri, 9 May 2003 11:52:12 +0100, "Bigus" <bigus AT
> creationfactor DOT net> wrote:
>
> >> Jürgen Exner wrote:
> >> > Or do you mean the size of all files in this directory and
recursively
> >> >all sub directories? Then have a look at File::Find. In the wanted()
> >> >function just add the size of each file (from -s) in a global
variable.
>
> >or if it's Windows, then issue a DIR command and extract the
> >total size from the 2nd to last line of it's output ;-)
>
> That will only work for one directory level.  Juergen's
> suggestion to use File::Find is still the best suggestion
> (by far).

Yes, probably. DIR would work though:

DIR d:\mydir\*.* /s

/s meaning include all subdirectories.

Bigus




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

Date: 09 May 2003 12:26:34 +0100
From: Brian McCauley <nobull@mail.com>
Subject: Re: ignore first line of input file
Message-Id: <u9wuh0wec5.fsf@wcl-l.bham.ac.uk>

Josef Möllers <josef.moellers@fujitsu-siemens.com> writes:

> kderaedt wrote:
> >     This is probably a dummy question.  What is the easiest way to ignore
> > the first line of a input file.

> > while(<IN>) {
> > 
> > }
> > 
> > The first line contains data that I not need.
> 
> Just read it:
> 
> <IN>;

That works unless you accidently put it in the last like of a block
thats evaluated in a list context.  This is, admittedly, quite
unlikely.

Also it relies on the undocumented fact that readline() treats a void
context as scalar. Whilst I'd never expect this to change, for the
sake of clarity, more than safety I'd spell it out:

scalar <IN>;

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


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

Date: Fri, 9 May 2003 06:47:50 -0500
From: tadmc@augustmail.com (Tad McClellan)
Subject: Re: Logic(al nightmare!)
Message-Id: <slrnbbn5b6.2d4.tadmc@magna.augustmail.com>

Brad Walton <sammie@greatergreen.com> wrote:


Please do not top-post.

Please see the Posting Guidelines that are posted here frequently:

   http://mail.augustmail.com/~tadmc/clpmisc.shtml


> Yeah, I know the variable for the DB is looong, 


I did not say anything about long variables...


>  tie @DB, 'Tie::File', $dormantstatdb or "cannot open $dormantstatdb: $!


> if you see anything wrong there let me know.


There is a bug in the code quoted above.

You should always enable warnings when developing Perl code,
it would have pointed out that bug for you...



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


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

Date: 9 May 2003 11:11:41 GMT
From: anno4000@lublin.zrz.tu-berlin.de (Anno Siegel)
Subject: Re: Newbie how to split file
Message-Id: <b9g2dd$qd6$1@mamenchi.zrz.TU-Berlin.DE>

Bill Smith <wksmith@optonline.net> wrote in comp.lang.perl.misc:
> 
> "Freidrich" <fclack50@yahoo.com> wrote in message
> news:b9dpun$hupgo$1@ID-82947.news.dfncis.de...
> > Hello,
> >
> > Pardon my English. new to Perl have not used it
> >
> > I have file is 28 bytes
> > and I need to  have text name = 12 bytes char and textnumber = 16bytes
> > numerics.
> >
> > Can please tell how to split,
> >     ($textname, $textnumber) = split(/    /$line)
> 
> You do not need split, just the list context.

Granted you don't need split, but you can use it to break a string
at a given point:

    pos( $line) = 12;
    my( $textname, $textnumber) = split /\G/, $line;

Anno


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

Date: 9 May 2003 03:10:47 -0700
From: mnabbas@hotmail.com (SuperStar)
Subject: Re: Perl Directories
Message-Id: <95d0e029.0305090210.8460805@posting.google.com>

Thanks for all your valuable input. 

Just to simplify my query, I start of by reading my Drive in Windows
2000. I am printing out a list of all the directories in the drive and
allow myself to read another directory by submitting the actual
directory name I wish to traverse.

Simple enough the program wouldnt work unless the full directory path
is inputted to the traverse function I created( hence the errors from
readdir). Furthermore I had some programming experience in Java. It is
simple enough to to get the 'Parent Directory' of the previously
selected file/dir (same file class but extra functions to play with).
If I were to use the same technique as I do in Java I would have to
include the previous directory path with my input, therefore instead
of just inputting just '\Perl' I would have to reference the previous
directory path and include it when I use the readdir in the transverse
function i.e. readdir("D:"."\Perl").

By the way nobull, you're right it isnt 'transverse' its 'traverse'.
Next time dont be too analytical and stick to the logic (dont be a
tight ass --no offense!!).

Yours

Super Star


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

Date: 09 May 2003 12:32:38 +0100
From: Brian McCauley <nobull@mail.com>
Subject: Re: Perl Directories
Message-Id: <u9u1c4we21.fsf@wcl-l.bham.ac.uk>

mnabbas@hotmail.com (SuperStar) writes:

> Thanks for all your valuable input. 

What we were all saying is you were not expressing your problem
clearly.  Expressing your problem clearly is 80% of solving it.

> Just to simplify my query, I start of by reading my Drive in Windows
> 2000. I am printing out a list of all the directories in the drive and
> allow myself to read another directory by submitting the actual
> directory name I wish to traverse.

Sorry I don't understand what you mean by "another directory".  That
would be one not in the list of all the directories in the drive.  So
do you mean a directory on a different drive?

> Simple enough the program wouldnt work unless the full directory path
> is inputted to the traverse function I created( hence the errors from
> readdir).

Sorry can't see the readdir() or the errors.  Actually I can't see
your code at all.  Especially if you have difficulty expressing your
problem in English a few lines of Perl is worth a 1000 words of prose.

This and other valuable advice can be found in the posting guidelines.

> Furthermore I had some programming experience in Java. It is
> simple enough to to get the 'Parent Directory' of the previously
> selected file/dir (same file class but extra functions to play with).
> If I were to use the same technique as I do in Java I would have to
> include the previous directory path with my input, therefore instead
> of just inputting just '\Perl' I would have to reference the previous
> directory path and include it when I use the readdir in the transverse
> function i.e. readdir("D:"."\Perl").

Note: In Perl we conventionally put the slash the other way even in Windows.
Note: You should always enable warings (Unrecognized escape \P passed through)

Are you asking how to get from a non-fully qualified path to a fully
qualified one?

  Cwd::abs_path()

If this is not what you are asking try asking again - this time make
sure you answer:

What do you want to achieve?

What did you try?

How did it fail?

This and other valuable advice can be found in the posting guidelines.

> By the way nobull, you're right it isnt 'transverse' its 'traverse'.

You missed my point.  The word 'traverse' when applied to directories
has at least one special technical meaning.  This meaning is different
from the concept you are trying to convey (which may be 'list' or
'list recusively' I haven't quite worked out which yet).

> Next time dont be too analytical and stick to the logic

*Boggle*

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


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

Date: 09 May 2003 12:42:42 +0100
From: Brian McCauley <nobull@mail.com>
Subject: Re: Perl Directories
Message-Id: <u9llxgwdl9.fsf@wcl-l.bham.ac.uk>

Brian McCauley <nobull@mail.com> writes:

>  ... You should always enable warings ...

Freudian slip?

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


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

Date: Fri, 09 May 2003 12:58:13 GMT
From: "Jürgen Exner" <jurgenex@hotmail.com>
Subject: Re: Perl Directories
Message-Id: <FBNua.6472$zu6.4891@nwrddc02.gnilink.net>

SuperStar wrote:
> Thanks for all your valuable input.

What input? What are you referring to?

> Just to simplify my query, I start of by reading my Drive in Windows
> 2000. I am printing out a list of all the directories in the drive and
> allow myself to read another directory by submitting the actual
> directory name I wish to traverse.

How do you do that? Show us your code, pruned as much as possible to still
expose your problem. Otherwise there is no way of helping you.

> Simple enough the program wouldnt work unless the full directory path
> is inputted to the traverse function I created( hence the errors from
> readdir).

What error? Please quote the error message literally with coy-and-paste
(don't retype it).

> Furthermore I had some programming experience in Java. It is
> simple enough to to get the 'Parent Directory' of the previously
> selected file/dir

Sure, just the same way as in any other programming language: you just go to
"..".

> (same file class but extra functions to play with).
> If I were to use the same technique as I do in Java I would have to
> include the previous directory path with my input, therefore instead
> of just inputting just '\Perl' I would have to reference the previous
> directory path and include it when I use the readdir in the transverse
> function i.e. readdir("D:"."\Perl").

No idea what you are talking about.
If you have a directory 'What/ever/the/path/is' and you want to access the
parent directory either snip off the last part (I think there is a module on
CPAN to handle paths) or just append "..": 'What/ever/the/path/is/..'

> By the way nobull, you're right it isnt 'transverse' its 'traverse'.
> Next time dont be too analytical and stick to the logic (dont be a
> tight ass --no offense!!).
>
> Yours
>
> Super Star

Maybe neither super nor star after all?

jue




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

Date: Fri, 09 May 2003 13:04:04 GMT
From: helgi@decode.is (Helgi Briem)
Subject: Re: Perl Directories
Message-Id: <3ebba714.2499122718@news.cis.dfn.de>

On Fri, 09 May 2003 12:58:13 GMT, "Jürgen Exner"
<jurgenex@hotmail.com> wrote:

>What error? Please quote the error message literally with 
> coy-and-paste (don't retype it).
  ^^^^^

Oh, what delicious irony.
-- 
Regards, Helgi Briem
helgi DOT briem AT decode DOT is


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

Date: Fri, 9 May 2003 13:19:49 +0200
From: "Robert" <k.robert@gmx.de>
Subject: python -> perl help urllib.urlopen
Message-Id: <3ebb8ee6$0$17799$9b622d9e@news.freenet.de>

for some odd reason I need to translate a
small python cgi script containing

   import cgi,urllib
   ...
   print urllib.urlopen( targeturl, post ).read()

to Perl. for standalone Perl I found

   use CGI;
   require("url_get.pl");
   ...
   print url_get( $targeturl . "?" . $post);

working, but it doesn't work in a cgi script - url_get not there (mod_perl,
path-problems, ...?). And I cannot rely on more than standard perl
installation on the web server. obviously one cannot "use url_get;" like
"use CGI;"

those perl modules, usage, path and docu I do not come through. What would
be a likely solution?

Robert






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

Date: 9 May 2003 10:30:30 GMT
From: anno4000@lublin.zrz.tu-berlin.de (Anno Siegel)
Subject: Re: Recursive copying question
Message-Id: <b9g006$o0c$1@mamenchi.zrz.TU-Berlin.DE>

Sara <genericax@hotmail.com> wrote in comp.lang.perl.misc:
> merlyn@stonehenge.com (Randal L. Schwartz) wrote in message
> news:<fc942dbf91a78b091e4631e672573f37@TeraNews>...
> >mes and dates.  I
>   .
>   .
>   .
> > 
> > Untested, but I usually do pretty good on this on the first try. :)
> > 
> 
> Hmmm I've *heard* that about you Randall! haha.. See you at OSCON..
                                        ^^
Have you ...?

Anno


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

Date: Fri, 9 May 2003 10:12:07 +1000
From: "Rod" <roderick991@yahoo.com>
Subject: Total Utter Just Delivered Perl Newbie with a Pignant Question
Message-Id: <b9g5sp$jateb$1@ID-82947.news.dfncis.de>

Hi

I'm new with Perl, wet behind the ears even,

Can you just call Perl as you would with a a shell script with arguments, if
so how (?) as all the examples I've seen make it far more complicated than a
shell script for accepting command line arguments, dealing with STDIN as you
would with C using ARGV, ARGC. If it's so great why all the overhead as you
don't need in a bash script ??

eg in Bash . . .

#!/bin/sh
# change to home directory
cd $HOME
case $# in
     0) echo " no arguments" ;;
     1) echo "one argument $1";;
     2) echo "two arguments $2";;
     *) echo "bugger!";;
esac





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

Date: Fri, 09 May 2003 14:21:12 +0200
From: Josef =?iso-8859-1?Q?M=F6llers?= <josef.moellers@fujitsu-siemens.com>
Subject: Re: Total Utter Just Delivered Perl Newbie with a Pignant Question
Message-Id: <3EBB9D38.802A1851@fujitsu-siemens.com>

Rod wrote:
> =

> Hi
> =

> I'm new with Perl, wet behind the ears even,
> =

> Can you just call Perl as you would with a a shell script with argument=
s, if
> so how (?) as all the examples I've seen make it far more complicated t=
han a
> shell script for accepting command line arguments, dealing with STDIN a=
s you
> would with C using ARGV, ARGC. If it's so great why all the overhead as=
 you
> don't need in a bash script ??
> =

> eg in Bash . . .
> =

> #!/bin/sh
> # change to home directory
> cd $HOME
> case $# in
>      0) echo " no arguments" ;;
>      1) echo "one argument $1";;
>      2) echo "two arguments $2";;
>      *) echo "bugger!";;
> esac

Take a look at perldoc perlvar and search for @ARGV.
In contrast to e.g. C-programs, there is no predefined $ARGC, so your
example could (TMTOWTDI) be written as

#! /usr/bin/perl -w
chdir $ENV{HOME};
if ($#ARGV =3D=3D -1) {
    print "no arguments\n";
} elsif ($#ARGV =3D=3D 0) {
    print "one argument $ARGV[0]\n";
} elsif ($#ARGV =3D=3D 1) {
    print "two arguments $ARGV[1]\n";
} else {
    print "bugger!\n";
}

(untested!)

Josef
-- =

Josef M=F6llers (Pinguinpfleger bei FSC)
	If failure had no penalty success would not be a prize
						-- T.  Pratchett


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

Date: 9 May 2003 12:35:27 GMT
From: anno4000@lublin.zrz.tu-berlin.de (Anno Siegel)
Subject: Re: Total Utter Just Delivered Perl Newbie with a Pignant Question
Message-Id: <b9g7af$1lk$1@mamenchi.zrz.TU-Berlin.DE>

Rod <roderick991@yahoo.com> wrote in comp.lang.perl.misc:
> Hi
> 
> I'm new with Perl, wet behind the ears even,
> 
> Can you just call Perl as you would with a a shell script with arguments, if
> so how (?) as all the examples I've seen make it far more complicated than a
> shell script for accepting command line arguments, dealing with STDIN as you
> would with C using ARGV, ARGC. If it's so great why all the overhead as you
> don't need in a bash script ??

So?  Perl programming gives you a lot more control over details than
shell scripting does, so there are more details to take care of.

If your problem is better solved with a shell script, use the shell script.

> eg in Bash . . .
> 
> #!/bin/sh
> # change to home directory
> cd $HOME
> case $# in
>      0) echo " no arguments" ;;
>      1) echo "one argument $1";;
>      2) echo "two arguments $2";;
>      *) echo "bugger!";;
> esac

Are you asking how to do that in Perl?  Here is one way:

    #!/usr/local/bin/perl
    use strict; use warnings; $| = 1;

    chdir ( $ENV{ HOME});
    my $num =
        ( 'no arguments',  'one argument', 'two arguments')[ scalar @ARGV];
    print defined $num ? "$num @ARGV\n" : "bugger\n";

Anno




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

Date: Fri, 9 May 2003 10:55:29 +1000
From: "Rod" <roderick991@yahoo.com>
Subject: Re: Total Utter Just Delivered Perl Newbie with a Pignant Question
Message-Id: <b9g8e2$isgsg$1@ID-82947.news.dfncis.de>


Anno Siegel <anno4000@lublin.zrz.tu-berlin.de> wrote in message
news:b9g7af$1lk$1@mamenchi.zrz.TU-Berlin.DE...
: Rod <roderick991@yahoo.com> wrote in comp.lang.perl.misc:
: > Hi
: >
: > I'm new with Perl, wet behind the ears even,
: >
: > Can you just call Perl as you would with a a shell script with
arguments, if
: > so how (?) as all the examples I've seen make it far more complicated
than a
: > shell script for accepting command line arguments, dealing with STDIN as
you
: > would with C using ARGV, ARGC. If it's so great why all the overhead as
you
: > don't need in a bash script ??
:
: So?  Perl programming gives you a lot more control over details than
: shell scripting does, so there are more details to take care of.
:
: If your problem is better solved with a shell script, use the shell
script.
:
: > eg in Bash . . .
: >
: > #!/bin/sh
: > # change to home directory
: > cd $HOME
: > case $# in
: >      0) echo " no arguments" ;;
: >      1) echo "one argument $1";;
: >      2) echo "two arguments $2";;
: >      *) echo "bugger!";;
: > esac
:
: Are you asking how to do that in Perl?  Here is one way:
:
:     #!/usr/local/bin/perl
:     use strict; use warnings; $| = 1;
:
:     chdir ( $ENV{ HOME});
:     my $num =
:         ( 'no arguments',  'one argument', 'two arguments')[ scalar
@ARGV];
:     print defined $num ? "$num @ARGV\n" : "bugger\n";
:
so 'my' is similar in that it is like arguments to main in C ???

: Anno
:
:




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

Date: 9 May 2003 10:09:27 GMT
From: "Tassilo v. Parseval" <tassilo.parseval@rwth-aachen.de>
Subject: Re: web page contents into a perl script
Message-Id: <b9fuon$b48$1@nets3.rz.RWTH-Aachen.DE>

Also sprach Ahab:

> I've using top post method for years. Not going to stop now. Far better  to
> get to the crux of the message straight off, instead wading through the same
> stuff over and over again in each follow-up message.

Ridiculous. Are you writing articles for others to read or solely for
your own reading-pleasure? If you are writing for the rest of this
group, then stop top-posting because most of the regulars will ignore
you otherwise.

> Besides the rules on that link didn't help me solve my problem. Maybe should
> have a rule that says group responses should be relevant to the query,
> rather than about draconian guidelines. It would save on bytes.

This group will be more inclinded to help you if you give up your
egocentrism as shown above.

Good luck,
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: Fri, 09 May 2003 10:28:54 GMT
From: helgi@decode.is (Helgi Briem)
Subject: Re: web page contents into a perl script
Message-Id: <3ebb82d5.2489843075@news.cis.dfn.de>

On Fri, 9 May 2003 17:43:17 +0800, "Ahab"
<nospam@spamfreeland.com> wrote:

>I've using top post method for years. Not going to stop now. Far better  to
>get to the crux of the message straight off, instead wading through the same
>stuff over and over again in each follow-up message.
>
>Besides the rules on that link didn't help me solve my problem. Maybe should
>have a rule that says group responses should be relevant to the query,
>rather than about draconian guidelines. It would save on bytes.

**PLONK**
-- 
Regards, Helgi Briem
helgi DOT briem AT decode DOT is


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

Date: Fri, 09 May 2003 14:11:42 +0200
From: Malte Ubl <ubl@schaffhausen.de>
Subject: Re: web page contents into a perl script
Message-Id: <b9g92r$ra6$1@news.dtag.de>

Ahab wrote:
> Besides the rules on that link didn't help me solve my problem. Maybe should
> have a rule that says group responses should be relevant to the query,

For support, please call

1-900-PERLHELP ($5.40/min)

I also accept other payment methods (If you pay in advance). $200 per 
hour. You can send me an email if you are interested.


malte



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

Date: Fri, 9 May 2003 06:53:47 -0500
From: tadmc@augustmail.com (Tad McClellan)
Subject: Re: web page contents into a perl script
Message-Id: <slrnbbn5mb.2d4.tadmc@magna.augustmail.com>

Ahab <nospam@spamfreeland.com> wrote:

> I've using top post method for years. Not going to stop now.


Welcome to the killfile then.

Good luck with your future Perl questions.


> have a rule that says group responses should be relevant to the query,


You seem to misunderstand what a discussion newsgroup is about.


   In <u93dhkluz2.fsf@wcl-l.bham.ac.uk> nobull@mail.com wrote:

      This is a discussion group not a helpdesk.  You post something 
      we discuss it's implications.  If the discussion happens to 
      answer a question you've asked that's incidental.



> rather than about draconian guidelines. It would save on bytes.


The guidelines were meant to save you from being widely 
ignored forevermore.

They've failed in this case.


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


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

Date: Fri, 9 May 2003 07:47:47 -0500
From: tadmc@augustmail.com (Tad McClellan)
Subject: Re: web page contents into a perl script
Message-Id: <slrnbbn8rj.2d4.tadmc@magna.augustmail.com>

Ahab <nospam@spamfreeland.com> wrote:

> I've using top post method 


It is not about you. It is about the audience that you are writing to.


> for years. 


You've been on newsgroups for years and still ask a FAQ?

Perhaps you are just a slow learner.


> Not going to stop now. 


You are an inconsiderate person.


> Far better  to
> get to the crux of the message straight off, instead wading through the same
> stuff over and over again in each follow-up message.


You've been on newsgroups for years and still don't know about
the proper format for a followup?

The same stuff does not appear over and over in a properly quoted
followup, so I don't know what you mean there.


> Besides the rules on that link didn't help me solve my problem.


First, we are not here to solve your problems, we are here to
discuss Perl programming.

Second, it DOES answer your Frequently Asked Question.


The Posting Guidelines say:

   Check the Perl Frequently Asked Questions
   ...
   You can use the "-q" switch with perldoc

Your question was:

   I want to read the contents of that html page into a perl script
                                       ^^^^^^^^^

so a well-socialized Usenaut would then try:

   perldoc -q html

      "How do I fetch an HTML file?"

which *is* an answer to your question.


> It would save on bytes.


*You* have wasted the time of thousands of people around the world.

Rather presumptuous of you to lecture on how to save bandwidth.


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


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

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


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