[18545] in Perl-Users-Digest

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

Perl-Users Digest, Issue: 713 Volume: 10

daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Thu Apr 19 09:16:30 2001

Date: Thu, 19 Apr 2001 06:16:06 -0700 (PDT)
From: Perl-Users Digest <Perl-Users-Request@ruby.OCE.ORST.EDU>
To: Perl-Users@ruby.OCE.ORST.EDU (Perl-Users Digest)
Message-Id: <987686166-v10-i713@ruby.oce.orst.edu>
Content-Type: text

Perl-Users Digest           Thu, 19 Apr 2001     Volume: 10 Number: 713

Today's topics:
    Re: Flame Target (Si Ballenger)
    Re: Flame Target <msoftmonkeySPAM@crosswinds.net>
    Re: Flame Target <msoftmonkeySPAM@crosswinds.net>
    Re: Flame Target <msoftmonkeySPAM@crosswinds.net>
    Re: Flame Target <illusi0n@REMOVEspeakeasy.net>
    Re: Flame Target <gellyfish@gellyfish.com>
    Re: Grab a remote directory w/o FTP...Oops! <gellyfish@gellyfish.com>
    Re: Grab a remote directory w/o FTP (BUCK NAKED1)
    Re: Grab a remote directory w/o FTP <bart.lateur@skynet.be>
        grep assistance <skpurcell@hotmail.com>
    Re: grep assistance <newspost@coppit.org>
    Re: grep assistance <abe@ztreet.demon.nl>
    Re: grep assistance <ren@tivoli.com>
    Re: grep assistance <skpurcell@hotmail.com>
    Re: hash references (Damian James)
        help for a basic hash value access question <Francis.Derive@wanadoo.fr>
    Re: help for a basic hash value access question <kellikellin@netscape.net>
    Re: help for a basic hash value access question (Gwyn Judd)
    Re: help needed with sorting Hash <lsdeshmukh@micron.com>
        help with manipulating a 2-d array <milliwave@rfengineering.freeserve.co.uk>
    Re: help with manipulating a 2-d array <chrisw+usenet@dynamite.com.au>
        Help:  how to install getpwuid and getlogin? u518615722@spawnkill.ip-mobilphone.net
    Re: Help:  how to install getpwuid and getlogin? nobull@mail.com
    Re: hex to binary conversion (Abigail)
    Re: How can u group together fields and sum them up <ruben@www2.mrbrklyn.com>
        How do I do a DF type operation? <dave.nospam@cwcom.net>
        How do I get Main Directory? (BUCK NAKED1)
    Re: How do I get Main Directory? (Eric Bohlman)
    Re: how do i suppress STDOUT <clarke@hyperformix.com>
        Digest Administrivia (Last modified: 6 Apr 01) (Perl-Users-Digest Admin)

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

Date: Sun, 15 Apr 2001 22:34:24 GMT
From: shb@vnet.net (Si Ballenger)
Subject: Re: Flame Target
Message-Id: <3ada1e56.16456511@166.82.1.9>

On Sun, 15 Apr 2001 21:09:49 GMT, Uri Guttman <uri@sysarch.com>
wrote:

>>>>>> "SB" == Si Ballenger <shb@vnet.net> writes:
>
>  SB> #!/usr/local/bin/perl
>  SB>      print "Content-type: text/plain", "\n";
>  SB>      print "Status: 204 Alan and brian's usual answer!", "\n\n";
>
>hey, troll, you make moronzilla look bright.
>
>ever heard of here docs, or one print statement, or \n inside of a
>string?
>
>you are an admitted troll and obviously a bad perl coder as well. now
>scoot along with the rest of your kindergarden class as it is nap time
>for you. you are not permitted in the adult newsgroup.
>
>uri

Come on uri, is that the best you can do??? Trolling for usenet
a**wipes is interesting, but you striking the same bait twice is
pretty amazing! Get your two buddies in here so we can see 3 on a
hook! Seems like none of the three of you actually know if n/n/
or just n/ makes a difference. Come on, YES or NO. Lets see you
do your stuff! Now you can always fade away to mommies skirt with
the "plonk" of defeat and avoid an answer!   waiting... as the
line quickly spins off the reel...


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

Date: Sun, 15 Apr 2001 20:17:36 -0400
From: "Joseph André" <msoftmonkeySPAM@crosswinds.net>
Subject: Re: Flame Target
Message-Id: <9bddp7$8oh7n$1@ID-50051.news.dfncis.de>

> For what its worth it works fine for me.

What browser/ISP are you using? Not that it's likely to have an effect,
but...




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

Date: Sun, 15 Apr 2001 20:01:44 -0400
From: "Joseph André" <msoftmonkeySPAM@crosswinds.net>
Subject: Re: Flame Target
Message-Id: <9bdcre$8q8cc$1@ID-50051.news.dfncis.de>


>  In some newsgroups, if you quote the entire previous posting and put
>  your comments above it, people are likely to "flame" you for "top
>  posting" or posting "Jeopardy style" (after the U.S. TV game show in
>  which contestants first see an answer and then have to come up with
>  the corresponding question). This is more likely in groups that have
>  a high concentration of long-time newsgroup users. They're not really
>  doing this as a "power trip" (at least not usually); they're
>  genuinely irritated at what they see as the waste of network and
>  human resources that such postings entail.


In other newsgroups, you may get flamed for doing the opposite. It's a silly
matter, really. Especially if it's as short as what I quoted.




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

Date: Sun, 15 Apr 2001 20:04:48 -0400
From: "Joseph André" <msoftmonkeySPAM@crosswinds.net>
Subject: Re: Flame Target
Message-Id: <9bdd17$8ngjr$1@ID-50051.news.dfncis.de>

> >> Content-Type: text/html\n\n
> >
> >what's that extra line doing there?
>
> In laymen's terms: no blank line in front of that header line, please.

Does that refer to the /n or the actual line break I placed there with my
Enter key? Excuse me, for I'm used to C++, which wouldn't care.




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

Date: Mon, 16 Apr 2001 02:40:13 -0400
From: "illusion" <illusi0n@REMOVEspeakeasy.net>
Subject: Re: Flame Target
Message-Id: <tdl4rginvcd37a@corp.supernews.com>

since when does tripod support perl cgi?



Joseph André <msoftmonkeySPAM@crosswinds.net> wrote in message
news:9bb38j$8jbaf$1@ID-50051.news.dfncis.de...
> Hello, I am new to Perl, but not to programming. My question is about CGI
> programming in Perl at Tripod. Specifically, I wrote my first script, here
> it is:
>
> #!/usr/local/bin/perl
>
> print <<END;
>
> Content-Type: text/html\n\n
>
>
>
> <html>
>
> <body bgcolor="#000000" text="#ffffff">
> BOO!
> </body>
>
> </html>
>
> END
>
>
> and the URL is http://wmbgt.tripod.com/cgi-bin/script.pl
> If you go there, you will find that the browser seems to be loading for
> about a minute, and then you get this error:
>
> Proxy Error
> The proxy server received an invalid response from an upstream server.
> The proxy server could not handle the request GET /cgi-bin/script.pl.
>
> Reason: Could not connect to remote machine: Connection timed out
>
>
>
>
> Can anyone tell me what I'm doing wrong? Or is it Tripod's fault? Are
there
> special things I have to worry about at Tripod that would affect this?
This
> is my first attempt at a Perl script remember, however I am an experienced
> Javascripter, HTMLer, and semi-experienced C++er. Or else, flame me, tell
me
> my question is off topic for some unforseen reason, and refer me to an
FAQ,
> as I have seen happen countless times to other people on other newsgroups.
> Thanks very much.
>
> Joseph
>
>




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

Date: 16 Apr 2001 10:10:51 GMT
From: Jonathan Stowe <gellyfish@gellyfish.com>
Subject: Re: Flame Target
Message-Id: <9begfb$s5p$2@plutonium.btinternet.com>

"Joseph André" <msoftmonkeySPAM@crosswinds.net> wrote:
>> >> Content-Type: text/html\n\n
>> >
>> >what's that extra line doing there?
>>
>> In laymen's terms: no blank line in front of that header line, please.
> 
> Does that refer to the /n or the actual line break I placed there with my
> Enter key? Excuse me, for I'm used to C++, which wouldn't care.
> 

The blank line above the Content-Type header you inserted with your enter
key.

/J\
-- 
Jonathan Stowe                      |
<http://www.gellyfish.com>          |      This space for rent
                                    |


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

Date: 16 Apr 2001 10:19:28 GMT
From: Jonathan Stowe <gellyfish@gellyfish.com>
Subject: Re: Grab a remote directory w/o FTP...Oops!
Message-Id: <9begvg$s5p$4@plutonium.btinternet.com>

BUCK NAKED1 <dennis100@webtv.net> wrote:
> I meant...
> 
> use LWP::Simple;
> @files = get('http://www.ibm.com/');
> foreach $file(@files) {
> print "$file\n"; };

What made you think this was going to retrieve the filenames - the get()
function of LWP::Simple simply returns the content returned from the
web server. As brian suggested you will need to parse the returned data
to obtain the links therein.  There is however no way to discover what
files might be in that location other than what the web server might care
to disclose.

You could look at the lwp-mirror program that is distributed with LWP.

/J\
-- 
Jonathan Stowe                      |
<http://www.gellyfish.com>          |      This space for rent
                                    |


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

Date: Mon, 16 Apr 2001 00:54:57 -0500 (CDT)
From: dennis100@webtv.net (BUCK NAKED1)
Subject: Re: Grab a remote directory w/o FTP
Message-Id: <28514-3ADA8931-201@storefull-245.iap.bryant.webtv.net>

 
Re: Grab a remote directory w/o FTP   
 
> comdog@panix.com (brian=A0d=A0foy) 
> > (BUCK NAKED1) wrote: 
> > How would you grab all the files from > > a remote website directory
when you > > don't know the name of the files in the > > directory, and
don't know the user-
> > name or password in order to use 
> > FTP? Can you do this with LWP? I've > > tried something like... 
> > use LWP::Simple;
> > @files =3D get('http://www.ibm.com/'); 

> perhaps you wanted something like: 
> use HTML::SimpleLinkExtor;
> use LWP::Simple; 
> $\=A0=3D=A0$,=A0=3D=A0"\n"; 
> my $extor =3D HTML::SimpleLinkExtor->new(); 
> my $html =3D get "http://www.perl.org/"; 
> $extor->parse($html); 
> print $extor->links; 

I noticed you wrote that module. Good job! ...but that's a link
extractor isn't it? If so, I don't think that's what I want. I've tried
to make my question clearer in a new thread.

Thanks, though.

Regards,
Dennis



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

Date: Mon, 16 Apr 2001 08:31:27 GMT
From: Bart Lateur <bart.lateur@skynet.be>
Subject: Re: Grab a remote directory w/o FTP
Message-Id: <3abldtgelc7r3g7v9a91gapeb7244lm50j@4ax.com>

BUCK NAKED1 wrote:

>How would you grab all the files from a remote website directory when
>you don't know the name of the files in the directory

You can't. If using the plain directory in LWP's get() returns a file
list, well, then you can parse that HTML file and get each of the files
listed. But otherwise you're out of luck. There's no way you can *know*
what files exist on the server if it doesn't tell you. The main file
(index file) in that directory might give you some clue, but there may
be extra files in that directory which aren't referenced anywhere, and
which you only can retrieve if you do know their exact name.

-- 
	Bart.


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

Date: Tue, 17 Apr 2001 13:18:21 -0500
From: "spurcell" <skpurcell@hotmail.com>
Subject: grep assistance
Message-Id: <3adc89a7$0$21828@wodc7nh6.news.uu.net>

Hello,
I have the following code, but cannot validate from the docs if this is
correct procedure. I have a directory with a lot of folders in there, but I
am trying to grep out only ones that begin with 2-4 digits and end with
searchresults or views.
eg.
1234searchresults
1234views
67views
67searchresults

So I did the following, but I am not sure if this is solid. I have tested
and it appears OK, but I cannot find it in the Owl. So my question is, is
the line that is doing the second grep proper? Or should I possibly use a
match operator or map instead? I work alone, so I have no one here to ask?

Thanks
Scott.

#### code in question here #########
    opendir (SESSIONDIR, "$sessions");
    my @allFiles = grep !/^\./, readdir SESSIONDIR;
    closedir SESSIONDIR;
    my @dirs = grep /(searchresults|views)/, @allFiles; # this line





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

Date: Tue, 17 Apr 2001 14:38:34 -0400
From: David Coppit <newspost@coppit.org>
To: spurcell <skpurcell@hotmail.com>
Subject: Re: grep assistance
Message-Id: <Pine.SUN.4.33.0104171434230.25869-100000@mamba.cs.Virginia.EDU>

[posted & mailed]

On Tue, 17 Apr 2001, spurcell wrote:

> I have a directory with a lot of folders in there, but I
> am trying to grep out only ones that begin with 2-4 digits and end with
> searchresults or views.
> eg.
> 1234searchresults
> 1234views
> 67views
> 67searchresults

>     opendir (SESSIONDIR, "$sessions");
>     my @allFiles = grep !/^\./, readdir SESSIONDIR;
>     closedir SESSIONDIR;
>     my @dirs = grep /(searchresults|views)/, @allFiles; # this line

I think you can just do this:

    opendir (SESSIONDIR, "$sessions");
    my @dirs = grep /^\d{2,4}\D.*(searchresults|views)$/, readdir SESSIONDIR;
    closedir SESSIONDIR;

It didn't look like you were handling the "begins with 2-4 digits"
constraint you specified. Also, your pattern doesn't match
searchresults or views at the end of the folder name. (The \D is to
avoid matching more than 4 digits at the beginning.)

--
David



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

Date: Tue, 17 Apr 2001 21:15:58 +0200
From: Abe Timmerman <abe@ztreet.demon.nl>
Subject: Re: grep assistance
Message-Id: <qp4pdt4nmt12d2e5no0hampefmnmk5g7ko@4ax.com>

On Tue, 17 Apr 2001 14:38:34 -0400, David Coppit <newspost@coppit.org>
wrote:

> On Tue, 17 Apr 2001, spurcell wrote:
> 
> > I have a directory with a lot of folders in there, but I
> > am trying to grep out only ones that begin with 2-4 digits and end with
> > searchresults or views.
> > eg.
> > 1234searchresults
> > 1234views
> > 67views
> > 67searchresults
> 
> >     opendir (SESSIONDIR, "$sessions");

You should test the result of opendir(), and there is no need for the
quotes.

	opendir (SESSIONDIR, $sessions) 
		or die "Can't opendir '$sessions': $!";

> >     my @allFiles = grep !/^\./, readdir SESSIONDIR;
> >     closedir SESSIONDIR;
> >     my @dirs = grep /(searchresults|views)/, @allFiles; # this line
> 
> I think you can just do this:
 ...
>     my @dirs = grep /^\d{2,4}\D.*(searchresults|views)$/, readdir SESSIONDIR;
                               ^^^^

That makes the sample data _not_ match, it should be optional.

	my @dirs = grep /^\d{2,4}(?:\D.*)?(searchresults|views)$/
		=> readdir SESSIONDIR;

This still allows for a "\n" as the last character of the name.

Also, if you only want directories, why not explicitly test for them?

	my @dirs = grep {
		-d "$sessions/$_" &&
		 /^\d{2,4}(?:\D.*)?(searchresults|views)\z/
	} readdir SESSIONDIR;

-- 
Good luck, Abe
Amsterdam Perl Mongers http://amsterdam.pm.org
perl -wle '$_=q@Just\@another\@Perl\@hacker@;print qq@\@{[split/\@/]}@'


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

Date: 17 Apr 2001 13:56:42 -0500
From: Ren Maddox <ren@tivoli.com>
Subject: Re: grep assistance
Message-Id: <m366g34aol.fsf@dhcp9-172.support.tivoli.com>

On Tue, 17 Apr 2001, newspost@coppit.org wrote:

> On Tue, 17 Apr 2001, spurcell wrote:
> 
>> I have a directory with a lot of folders in there, but I
>> am trying to grep out only ones that begin with 2-4 digits and end with
>> searchresults or views.
>> eg.
>> 1234searchresults
>> 1234views
>> 67views
>> 67searchresults
> 
> 
>     opendir (SESSIONDIR, "$sessions"); my @dirs = grep
>     /^\d{2,4}\D.*(searchresults|views)$/, readdir SESSIONDIR;
>     closedir SESSIONDIR;

That \D is forcing there to be a non-digit between the digits and the
string ("searchresults" or "views"), which the example data
demonstrates to be incorrect.

Now, I'm not sure if the correct answer for the OP is to leave out the
"\D.*" altogether, or to replace it with something like "(?=\D).*?"
(the "?" is optional here, but seems more in line with the goal).

On the other hand, I expect that this is one of those cases (quite
common, actually) where it is really better to split the regex in two:

  grep /^\d{2,4}\D/ && /(searchresults|views)$/, readdir SESSIONDIR;

That really seems to fit the specification better (and is even likely
to be faster -- not that performance should even remotely be an issue
here).

Finally, if only directories should be returned, it's probably worth
putting that restriction in the grep (first):

  grep -d && /^\d{2,4}\D/ && /(searchresults|views)$/, readdir SESSIONDIR

-- 
Ren Maddox
ren@tivoli.com


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

Date: Tue, 17 Apr 2001 13:48:46 -0500
From: "spurcell" <skpurcell@hotmail.com>
Subject: Re: grep assistance
Message-Id: <3adc90c8$0$12681@wodc7nh6.news.uu.net>

Thanks David,
I am testing it now.

Sincerely Appreciated.



"David Coppit" <newspost@coppit.org> wrote in message
news:Pine.SUN.4.33.0104171434230.25869-100000@mamba.cs.Virginia.EDU...
> [posted & mailed]
>
> On Tue, 17 Apr 2001, spurcell wrote:
>
> > I have a directory with a lot of folders in there, but I
> > am trying to grep out only ones that begin with 2-4 digits and end with
> > searchresults or views.
> > eg.
> > 1234searchresults
> > 1234views
> > 67views
> > 67searchresults
>
> >     opendir (SESSIONDIR, "$sessions");
> >     my @allFiles = grep !/^\./, readdir SESSIONDIR;
> >     closedir SESSIONDIR;
> >     my @dirs = grep /(searchresults|views)/, @allFiles; # this line
>
> I think you can just do this:
>
>     opendir (SESSIONDIR, "$sessions");
>     my @dirs = grep /^\d{2,4}\D.*(searchresults|views)$/, readdir
SESSIONDIR;
>     closedir SESSIONDIR;
>
> It didn't look like you were handling the "begins with 2-4 digits"
> constraint you specified. Also, your pattern doesn't match
> searchresults or views at the end of the folder name. (The \D is to
> avoid matching more than 4 digits at the beginning.)
>
> --
> David
>




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

Date: 17 Apr 2001 08:20:57 GMT
From: damian@qimr.edu.au (Damian James)
Subject: Re: hash references
Message-Id: <slrn9dnv4k.e61.damian@puma.qimr.edu.au>

David Millman chose Mon, 16 Apr 2001 13:40:04 -0400 to say this:
>if i'm passing in references to a hash in a subroutine, how
>do i get the actual hash data.
>
>...
>$r = dostuff(%$foo,%$bar);
>...
>why doesn't that work?
>

Because you're NOT passing references -- you are explicitly dereferencing
them first, and passing the resulting list.

You probably wanted to do something like:

	$r = dostuff($foo,$bar);

I find it helps to always include curlies in such dereferencing, to make
sure there's no doubt about what's going on. Eg:

	sub dostuff {
		my %x = %{$_[0]};
		my %y = %{$_[1]};
	}

But I would tend just to keep them as references and dereference when they're
used (with arrow notation).

You should reread perldoc perlref.

HTH,

Cheers,
Damian
-- 
@:=grep!($;+=m!$/|#!),split//,<DATA>;@;=0..$#:;while(@;){for($;=@;;--$;;){;(
$:=rand$;+$|)==$;&&next;@;[$;,$:]=@;[$:,$;]}push@|,shift@;if$;[0]==@|;select
$,,$,,$,,1/80;print qq x\bxx((@;+@|)*$|++),@:[@|,@;],!@;&&$/} __END__
Just another Perl Hacker # rev 3 -- a JAPH in progress, I guess...


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

Date: 17 Apr 2001 22:30:36 +0200
From: "Francis Derive" <Francis.Derive@wanadoo.fr>
Subject: help for a basic hash value access question
Message-Id: <B7027493-9190C@193.248.254.195>


Bonjour !

I want a value associated to some key to be a list.
With %hash = ();
I would say @hash{2} = ("a","b","c"); # '@' for the list context, and the
list. 

But print @hash{2} says only "a".

Why so ?

Thank you. Francis .




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

Date: Tue, 17 Apr 2001 15:59:27 -0500
From: kelli norman <kellikellin@netscape.net>
Subject: Re: help for a basic hash value access question
Message-Id: <3ADCAEAF.7D9FA8C6@netscape.net>

francis:
you could do:

%hash = (2=>['a','b','c']);
print "hash{2} = @{$hash{2}}\n";

hope this helps.
--
Francis Derive wrote:
> 
> Bonjour !
> 
> I want a value associated to some key to be a list.
> With %hash = ();
> I would say @hash{2} = ("a","b","c"); # '@' for the list context, and the
> list.
> 
> But print @hash{2} says only "a".
> 
> Why so ?
> 
> Thank you. Francis .


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

Date: Tue, 17 Apr 2001 21:31:13 GMT
From: tjla@guvfybir.qlaqaf.bet (Gwyn Judd)
Subject: Re: help for a basic hash value access question
Message-Id: <slrn9dpdgu.8mn.tjla@thislove.dyndns.org>

In article <B7027493-9190C@193.248.254.195>,
Francis Derive <Francis.Derive@wanadoo.fr> wrote:
>I want a value associated to some key to be a list.
>With %hash = ();
>I would say @hash{2} = ("a","b","c"); # '@' for the list context, and the
>list. 
>
>But print @hash{2} says only "a".

That's because a hash value (or an array value) can only be a scalar. An
array is not a scalar. Fortunately, a reference to an array is a scalar:

$hash{2} = [qw(a b c)];

-- 
Gwyn Judd (print `echo 'tjla@guvfybir.qlaqaf.bet' | rot13`)
Better dead than mellow.


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

Date: Tue, 17 Apr 2001 11:23:55 -0600
From: "Lalit Deshmukh" <lsdeshmukh@micron.com>
Subject: Re: help needed with sorting Hash
Message-Id: <9bhu79$e5r$1@admin-srv3.micron.com>

This is how I would print the hash values by sorting values.. However I have
not tried how to print the corrsponding keys..

#!/usr/local/bin/perl

my %hash = (a => 7, b => 1, c => 3);

@values = sort (values %hash);
foreach $value (@values) {
    print "$value\n";
}

Good luck
-Lalit

afshin akbari wrote in message <3ACA0608.86016145@sympatico.ca>...
>All,
>
>
>Is there a way to to sort and print a hash based on the
>value field.
>
>suppose we have,
>
>%hash (a => 7,
> b => 1,
> c => 3);
>
>result should be:
>
>%hash (b => 1,
> c => 3,
> a => 7);
>
>Thanks in advance.
>aa-




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

Date: Tue, 17 Apr 2001 20:30:28 +0100
From: "Milliwave" <milliwave@rfengineering.freeserve.co.uk>
Subject: help with manipulating a 2-d array
Message-Id: <9bi5fb$rpr$1@newsg1.svr.pol.co.uk>

Hello,

I would be grateful if someone could spend some time trying to inform me how
to get pass this
hurdle. I have the following 2-d array which has the following format, an
example:

P 12  20 30 40 50 34 23 22                    (8 elements wide)
    11 10 11 20 20 33                                (6 elements wide)
    10 12 22 12                                           ( 4 elements wide)
    34 33;                                                      ( 2 elements
wide)
P 12  20 30 40 50 34 23 22
    11 12 13 44;

The maximum width vaires between 2 elements wide upto a maximum of 8, the
randomn
nature of the array is illustrated above. The arraylength per a "P" is does
not have a limit!

Questions1
--------------
The following code was used to write the above data into the array

     $point_call_line_information = "$_";
     @point1 = $poly_call_line_information;
     @point1 = split;
     push @point2 ,[ @point1 ];


The first query I have is, how do I do one of the following;
1) write the single empty space(s) as seen in the array below the "P", into
the array?
2) or detect and eleminate the P before writing into the array?

Question2
--------------
At some point in my code, I am introducing a reset to the array on detecting
the ; (semicolon)
at the end of the P statement(as seen in the array). How do I re-initialise
or destroy the existing contents of the array?

Question3
-------------
I would finaly like to add a contant to either columns 2, 4 , 6 and 8
and/or columns 1,3,5 and 7?
This would be done with  a for loop, counting down the arraylength. This
would be only done
when I am printing the exisiting contents prior to deleting the contents, as
mentioned above in question2.

for ($i=0 $i,<= $arraylength -1; $i++)
{


}


Your help is appreciated
cheers

The following is an example of adding 50 to the even columns to the above
array
P 12 70 30 90 50 84 23 72 ------constant of 50 added
    11 60 11 70 20 83
    10 62 22 62
    34 83;          ---------- Reset of array at this point!
P 12  20 30 40 50 34 23 22 ------ constant not added in this section
    11 12 13 44;





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

Date: Wed, 18 Apr 2001 11:29:39 +1000
From: "Chris W" <chrisw+usenet@dynamite.com.au>
Subject: Re: help with manipulating a 2-d array
Message-Id: <Y76D6.4$FB.69701@news.interact.net.au>

Here's a possible approach but the TMTOWTDI:

#!perl -w
use strict;
use warnings;

my @array;
my $row = 0;
my $lastrow = 0; # used as a flag: > 0 then this is last row

while (<DATA>) {
 chomp;
 next if m/^\s+$/;

 if (s/^P\s*//g) { # new matrix if s/// returns > 0
  @array = ();
  $lastrow = 0;
  $row = 0;
 }
 $lastrow = s/\s*;//g; # remove trailing ; if present

 push @{$array[$row++]}, split;

 if ($lastrow) {
  # do stuff to matrix
  print_matrix(\@array);
  add_to_odd(\@array);
  print_matrix(\@array);
 }
}

sub print_matrix {
 my $m = shift;
 foreach my $r (@$m) {
  print join(':', @{$r}), "\n";
 }
 print "----------------------\n";
}

sub add_to_odd {
 my $m = shift;
 foreach my $r (@$m) {
  my $col = 0;
  map {$_ += 50 if $col++%2 == 1 } @$r;
 }
}

__DATA__
P 12  20 30 40 50 34 23 22
  11 10 11 20 20 33
  10 12 22 12
  34 33;

P 12  20 30 40 50 34 23 22
  11 12 13 44;





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

Date: Tue, 17 Apr 2001 15:54:22 GMT
From: u518615722@spawnkill.ip-mobilphone.net
Subject: Help:  how to install getpwuid and getlogin?
Message-Id: <l.987522862.1376281738@[198.138.198.252]>

I am an Oracle DBA.  I installed perl 5.06 
on my NT 2000, but when I run a program 
defrag.pl,I got an error message that getpwuid
and getlogin are not implemented, 
and I am so new to perl, I do not know
how I can get these two functions.

Could somebody help me out?

Thanks
 



-- 
Sent by dbadba62 from hotmail  element from com
This is a spam protected message. Please answer with reference header.
Posted via http://www.usenet-replayer.com/cgi/content/new


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

Date: 17 Apr 2001 18:18:29 +0100
From: nobull@mail.com
Subject: Re: Help:  how to install getpwuid and getlogin?
Message-Id: <u9itk3igwq.fsf@wcl-l.bham.ac.uk>

u518615722@spawnkill.ip-mobilphone.net writes:

> I am an Oracle DBA.  I installed perl 5.06 
> on my NT 2000, but when I run a program 
> defrag.pl,I got an error message that getpwuid
> and getlogin are not implemented, 
> and I am so new to perl, I do not know
> how I can get these two functions.

Get a real OS :-)

Sorry, couldn't resist.

Those functions are part of the OS specific API to the Unix
authentication/session model.  Any program that uses them (whether
written n Perl or C or whatever) is Unix specific.

Look at the script and remove those calls, replacing the code that
uses them with something appropriate for your environment.

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


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

Date: Thu, 19 Apr 2001 10:24:14 +0000 (UTC)
From: abigail@foad.org (Abigail)
Subject: Re: hex to binary conversion
Message-Id: <slrn9dtf6e.5l9.abigail@tsathoggua.rlyeh.net>

RayJ (rayj00@yahoo.com) wrote on MMDCCLXXXVII September MCMXCIII in
<URL:news:3ADDF286.9090302@yahoo.com>:
"" I have this code:
"" # @values[0] = 85
"" 
"" 
"" $string = sprintf("%8b",@values[0]);
"" print "$string\n";
"" 
"" the print statement returns: 1010101
"" 
"" What gives?


That's very strange. "# @values[0] = 85" shouldn't actually assign
anything. How did you manage to get 85 in $values [0]?

Note that '1010101' would be the expected answer if 85 is in $values [0].


Abigail
-- 
$_ = "\nrekcaH lreP rehtona tsuJ"; my $chop; $chop = sub {print chop; $chop};
$chop -> () -> () -> () -> () -> () -> () -> () -> () -> () -> () -> () -> ()
-> () -> () -> () -> () -> () -> () -> () -> () -> () -> () -> () -> () -> ()


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

Date: Sun, 15 Apr 2001 19:38:24 +0400
From: "Brooklyn Linux Solutions CEO" <ruben@www2.mrbrklyn.com>
Subject: Re: How can u group together fields and sum them up
Message-Id: <20010415.190147.964445884.9754@www2.mrbrklyn.com>

In article <OM1C6.2192$Ce4.215108@news1.rdc1.ct.home.com>, "Dan Sugalski"

> What perl does is take the key and apply a hashing function to it, which
> returns an integer that's used as the offset into an array.>>>


Does this mean if the hashing function returns an integer 123,234,344,566
- that it is going to create a C array with 100 million elements???

Ruben


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

Date: Thu, 19 Apr 2001 08:23:57 +0100 (BST)
From: "Dave Saville" <dave.nospam@cwcom.net>
Subject: How do I do a DF type operation?
Message-Id: <qnirfnivyyrpjpbzarg.gc1h3x0.pminews@news.cwcom.net>

Hi

I need to be able to find the amount of free space in a file system. Unix df
in a system call is not an option as I need to run on multiple platforms.

TIA

Regards

Dave Saville

NB switch saville for nospam in address




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

Date: Mon, 16 Apr 2001 00:39:53 -0500 (CDT)
From: dennis100@webtv.net (BUCK NAKED1)
Subject: How do I get Main Directory?
Message-Id: <28514-3ADA85A9-199@storefull-245.iap.bryant.webtv.net>

My perl coding below works fine for getting a subdirectory listing, such
as  "http://downtowndisco.hypermart.net/mid/a-f/"  ... but how do I get
the main directory listing of something like
"http://downtowndisco.hypermart.net/" ?
When I try, all I get is an index page.

#!/usr/local/bin/perl -wT
print "Content-type: text\html\n\n";
use CGI::Carp qw(fatalsToBrowser);
use LWP::Simple;
use strict;

my @files = get("http://downtowndisco.hypermart.net/mid/a-f/");
foreach my $file(@files) {
print "$file\n"; };


FWIW... in searching for how to do this, I came across a similar hack by
Randall Schwartz at
http://www.stonehenge.com/merlyn/WebTechniques/col05.html, but I don't
think it's quite what I'm looking for. 

Any H-E-L-P would be appreciated. :-0

--Dennis

 



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

Date: 16 Apr 2001 07:00:37 GMT
From: ebohlman@omsdev.com (Eric Bohlman)
Subject: Re: How do I get Main Directory?
Message-Id: <9be5al$l9k$6@bob.news.rcn.net>

BUCK NAKED1 <dennis100@webtv.net> wrote:
> My perl coding below works fine for getting a subdirectory listing, such
> as  "http://downtowndisco.hypermart.net/mid/a-f/"  ... but how do I get
> the main directory listing of something like
> "http://downtowndisco.hypermart.net/" ?
> When I try, all I get is an index page.

There is, in general, no way to do this.  HTTP doesn't provide any method 
for listing directories (in fact it doesn't even have a concept of 
"directories").  All it knows about is resource names.  An HTTP server 
*may*, upon receiving a request for a particular resource, generate a 
listing of directories and output in some form (usually an HTML document), 
but how or when it does this is *entirely* up to the server and its 
administrator.  Note that the resources transmitted over HTTP need not 
even correspond to filesystem objects on the server.  But once again, HTTP 
doesn't provide any method with the semantics of "return a list of all 
resources that match some criteria."



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

Date: Tue, 17 Apr 2001 08:52:11 -0500
From: "ac" <clarke@hyperformix.com>
Subject: Re: how do i suppress STDOUT
Message-Id: <9TXC6.151$Lt.85965@news.uswest.net>

Thanks, Jay and Jonathan. I'll give this a shot.

Allan




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

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


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