[11121] in Perl-Users-Digest

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

Perl-Users Digest, Issue: 4721 Volume: 8

daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Fri Jan 22 11:06:27 1999

Date: Fri, 22 Jan 99 08:00:20 -0800
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, 22 Jan 1999     Volume: 8 Number: 4721

Today's topics:
    Re: Chgrp <jdf@pobox.com>
    Re: Chgrp (Clay Irving)
    Re: Converting String to Integer... (Alexander Gavrenkov)
    Re: File Upload. (Sam Curren)
        Finding keys in $HASH{}{} <mpriatel@activesystems.ca>
    Re: How long would the Unixes last without Perl? <richardsonja@logica.com>
    Re: how to copy file (Clay Irving)
        More help! <c-denman@dircon.co.uk>
        multi-dimensional arrays - more help please! <c-denman@dircon.co.uk>
    Re: multi-dimensional arrays with hashes help please <partha@mihy.mot.com>
    Re: Perl Criticism droby@copyright.com
    Re: Perl Criticism (Des Herriott)
    Re: Perl Criticism (I R A Aggie)
    Re: Perl XS ? <Arved_37@chebucto.ns.ca>
        Please help me with a client/server problem (Win32) (Markus Hdfner)
    Re: Regular Expression Question <jdf@pobox.com>
    Re: Regular Expression Question <jdf@pobox.com>
    Re: Safely editing /etc/passwd. (Mike Ellwood)
    Re: Sending SMS messages with perl script ?? tomten@my-dejanews.com
    Re: string to integer conversion <tbriles@austin.ibm.com>
    Re: The Documeantion (was Re: Perl problem :(Offline mo <jdf@pobox.com>
    Re: Yet another basic question. (Clay Irving)
        Special: Digest Administrivia (Last modified: 12 Dec 98 (Perl-Users-Digest Admin)

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

Date: 22 Jan 1999 16:21:11 +0100
From: Jonathan Feinberg <jdf@pobox.com>
To: nathan@ici.net (Nathan Clemons)
Subject: Re: Chgrp
Message-Id: <m3sod3mizc.fsf@joshua.panix.com>

nathan@ici.net (Nathan Clemons) writes:

> Is there a chgrp function under Perl 5.004_04? Do you have to be root
> to use it, if so?

> (Already did a perldoc -f chgrp and didnt see it.)

So close...

   $ perldoc -f chown

-- 
Jonathan Feinberg   jdf@pobox.com   Sunny Brooklyn, NY
http://pobox.com/~jdf


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

Date: 22 Jan 1999 10:48:10 -0500
From: clay@panix.com (Clay Irving)
Subject: Re: Chgrp
Message-Id: <78a6jq$gio$1@panix.com>

In <36a88e0e.68930840@news.ici.net> nathan@ici.net (Nathan Clemons) writes:

>Is there a chgrp function under Perl 5.004_04? Do you have to be root
>to use it, if so?

>--Nathan.

>(Already did a perldoc -f chgrp and didnt see it.)

perldoc perlfunc

[...]

     chown LIST
             Changes the owner (and group) of a list of files.
             The first two elements of the list must be the
             NUMERICAL uid and gid, in that order.  Returns the
             number of files successfully changed.
[...]

-- 
Clay Irving
clay@panix.com


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

Date: Fri, 22 Jan 1999 06:17:53 -0800
From: gavh2@hotmail.com (Alexander Gavrenkov)
Subject: Re: Converting String to Integer...
Message-Id: <oD0q2.4414$IJ3.36721918@WReNphoon2>

pack - takes an array or list of values and packs it into a binary
structure.



*** Posted from RemarQ - http://www.remarq.com - Discussions Start Here (tm) ***


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

Date: Fri, 22 Jan 1999 07:27:15 -0800
From: samc@empirewest.com (Sam Curren)
Subject: Re: File Upload.
Message-Id: <MPG.111238b2a02f58fb9896d4@news.sonic.net>


Use CGI.pm

-Sam

In article <788vgl$v25$1@nnrp1.dejanews.com>, horng@earthlink.net says...
> I have a similar question.  I need to upload files using the web browser.  The
> input type for the HTML form is "file" so that i can browse the local file
> lists.  The question is, how can I transfer files from client side to the
> server?  By using ftp.pl package??  I appreciate any help.
> 
> Felix
> 
> 
> In article <36A6ED92.7EC03B43@khayal.com>,
>   Ghulam Hussein Kara <ghulam@khayal.com> wrote:
> > Assuming that your file input variable is "cv" , the following should
> > suffice :
> >
> > #-------Beginning Code----------
> >
> > #!/usr/bin/perl
> > require "cgi-lib.pl";
> > &ReadParse;
> > open (F, ">uploaded.dat");
> > print F "$in{'cv'}\n";
> > close (F);
> >
> > #-------End of Code-------------
> > Note : You can name the new file  to whatever you want instead of
> > "uploaded.dat" depending on type.e.g "wordfile.doc"
> >
> > piece of cake, huh?
> >
> > Alex Blyumenkrants wrote:
> >
> > > Hi!
> > >
> > > I have the following problem:
> > >
> > > i need to upload a file from an Html,
> > > if i use type="file"
> > > what should i do to save this file in my Cgi?
> > >
> > > Thank You,
> > > Alex
> >
> >
> 
> -----------== Posted via Deja News, The Discussion Network ==----------
> http://www.dejanews.com/       Search, Read, Discuss, or Start Your Own    
> 


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

Date: Fri, 22 Jan 1999 10:12:52 -0500
From: "Mark Priatel" <mpriatel@activesystems.ca>
Subject: Finding keys in $HASH{}{}
Message-Id: <XC0q2.10001$7l6.307132@tor-nn1.netcom.ca>

I'm building a script which performs a batch process to find out how many
times a style appears in a document.  To keep all the data in one place, I'm
sticking the data in a structure like this:

$statistics{$filename}{$style}

To find all the filenames present, I'd do a:
@files = keys %statistics;

But how would I find all the keys present in the {$style}
structure...array...field...(whatever you call it...)?!


-------------------------------------------
Mark Priatel
ActiveSystems, Inc.





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

Date: Fri, 22 Jan 1999 15:25:24 -0000
From: "James Richardson" <richardsonja@logica.com>
Subject: Re: How long would the Unixes last without Perl?
Message-Id: <78a599$39e@romeo.logica.co.uk>


Greg Ward wrote in message <787uac$do3$1@news0-alterdial.uu.net>...
>I know lots of Python hackers who would love to see the last of Perl.
>They're all irrationally biased against Perl, but they probably don't
>use it every day.  (Although there is still one mailing list on
>python.org that uses Majordomo -- they've converted all the others to
>use Mailman, which of course is written in Python.)
>
Now now, remember that my Commodore 64 is better than your Spectrum and my
big brother will punch you if you disagree. :-)

Perl4 is distributed by HP as part of the OS, but perlmodern compiles out of
the box, so theres no problem.

Ever since 95, (when I first met perl), its been on the up and up...

WRT your comment about distributing installation scripts written in perl, I
have been involved in doing exactly that. Maintaining a version of perl for
every single client HW/OS combination was _much_ easier than maintaining 8
to 10 installation scripts that have to run across
irix/sunos/solaris/hpux/aix etc etc..... Just install perl  and you're off.
The code can check what architecture you are on, and run the appropriate
system dependant stuff.
All the minor (but they give major headaches) differences betweent the
command line options for all these flavours of unix go straight out the
window.

James






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

Date: 22 Jan 1999 10:43:35 -0500
From: clay@panix.com (Clay Irving)
Subject: Re: how to copy file
Message-Id: <78a6b7$g76$1@panix.com>

In <78a041$9vn$1@MU.icmp.lviv.ua> "Yaroslav Buga" <buga@ipm.lviv.ua> writes:

>Does anybody know how to copy file in perl?

perldoc File::Copy

-- 
Clay Irving
clay@panix.com


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

Date: Fri, 22 Jan 1999 15:13:18 -0000
From: "Chris" <c-denman@dircon.co.uk>
Subject: More help!
Message-Id: <78a4hh$32q$1@starburst.uk.insnet.net>

This is a multi-part message in MIME format.

------=_NextPart_000_001A_01BE4619.BDB5FD60
Content-Type: text/plain;
	charset="iso-8859-1"
Content-Transfer-Encoding: quoted-printable

I have loads of data files that I need to sort.

Here is one data file:

name:chris:
age:27:
sex:male:

What I do, for easy access, is to load in the file and then turn it into =
a hash array like so:

open(FILE,"001.dat");
@lines=3D<FILE>;
close FILE;
foreach $line (@lines){
    ($left,$right)=3Dsplit(/:/,$line);
    $DATA{$left}=3D$right;
    }

I have a loop to do this for all the files, but what if I only want =
cirtain files depending on their content like so:

$counter=3D0;

@files=3D<*.dat>
foreach $file (@files){
    open(FILE,$file);
    @lines=3D<FILE>;
    close FILE;
    undef $DATA;
    foreach $line (@lines){
        ($left,$right)=3Dsplit(/:/,$line);
        $DATA{$left}=3D$right;
        }
   =20
    if($DATA{'age'}<20){
        $NEWARRAY[$counter++]=3D$DATA;    # THIS LINE IS WRONG - HOW DO =
I DO IT?
        }
    }

for($loop=3D0;$loop<@NEWARRAY;loop++){        #AND THIS IS ALSO WRONG
    foreach $key (keys %NEWARRAY[$loop]){    #AND HERE
        print "$NEWARRAY[$loop]{$key}\n\n";        #AND HERE
        }
    }

Oh dear, I know what I want to do, but its the right syntax I want.

I wont hastle any more after this one!

Chris D

------=_NextPart_000_001A_01BE4619.BDB5FD60
Content-Type: text/html;
	charset="iso-8859-1"
Content-Transfer-Encoding: quoted-printable

<!DOCTYPE HTML PUBLIC "-//W3C//DTD W3 HTML//EN">
<HTML>
<HEAD>

<META content=3Dtext/html;charset=3Diso-8859-1 =
http-equiv=3DContent-Type>
<META content=3D'"MSHTML 4.72.2106.6"' name=3DGENERATOR>
</HEAD>
<BODY bgColor=3D#ffffff>
<DIV><FONT color=3D#000000 size=3D2>I have loads of data files that I =
need to=20
sort.</FONT></DIV>
<DIV><FONT color=3D#000000 size=3D2></FONT>&nbsp;</DIV>
<DIV><FONT color=3D#000000 size=3D2>Here is one data file:</FONT></DIV>
<DIV><FONT color=3D#000000 size=3D2></FONT>&nbsp;</DIV>
<DIV><FONT color=3D#000000 size=3D2>name:chris:</FONT></DIV>
<DIV><FONT color=3D#000000 size=3D2>age:27:</FONT></DIV>
<DIV><FONT color=3D#000000 size=3D2>sex:male:</FONT></DIV>
<DIV><FONT color=3D#000000 size=3D2></FONT>&nbsp;</DIV>
<DIV><FONT color=3D#000000 size=3D2>What I do, for easy access, is to =
load in the=20
file and then turn it into a hash array like so:</FONT></DIV>
<DIV><FONT color=3D#000000 size=3D2></FONT>&nbsp;</DIV>
<DIV><FONT color=3D#000000 =
size=3D2>open(FILE,&quot;001.dat&quot;);</FONT></DIV>
<DIV><FONT size=3D2>@lines=3D&lt;FILE&gt;;</FONT></DIV>
<DIV><FONT size=3D2>close FILE;</FONT></DIV>
<DIV><FONT size=3D2>foreach $line (@lines){</FONT></DIV>
<DIV><FONT size=3D2>&nbsp;&nbsp;&nbsp;=20
($left,$right)=3Dsplit(/:/,$line);</FONT></DIV>
<DIV><FONT size=3D2></FONT><FONT color=3D#000000 =
size=3D2>&nbsp;&nbsp;&nbsp;=20
$DATA{$left}=3D$right;</FONT></DIV>
<DIV><FONT size=3D2>&nbsp;&nbsp;&nbsp; }</FONT></DIV>
<DIV>&nbsp;</DIV>
<DIV><FONT color=3D#000000 size=3D2>I have a loop to do this for all the =
files, but=20
what if I only want cirtain files depending on their content like=20
so:</FONT></DIV>
<DIV><FONT color=3D#000000 size=3D2></FONT>&nbsp;</DIV>
<DIV><FONT size=3D2>$counter=3D0;</FONT></DIV>
<DIV><FONT color=3D#000000 size=3D2></FONT>&nbsp;</DIV>
<DIV><FONT color=3D#000000 size=3D2>@files=3D&lt;*.dat&gt;</FONT></DIV>
<DIV><FONT color=3D#000000 size=3D2>foreach $file (@files){</FONT></DIV>
<DIV><FONT color=3D#000000 size=3D2>
<DIV><FONT color=3D#000000 size=3D2>&nbsp;&nbsp;&nbsp;=20
open(FILE,$file);</FONT></DIV>
<DIV><FONT size=3D2>&nbsp;&nbsp;&nbsp; =
@lines=3D&lt;FILE&gt;;</FONT></DIV>
<DIV><FONT size=3D2>&nbsp;&nbsp;&nbsp; close FILE;</FONT></DIV>
<DIV><FONT size=3D2>&nbsp;&nbsp;&nbsp; undef $DATA;</FONT></DIV>
<DIV><FONT size=3D2>&nbsp;&nbsp;&nbsp; foreach $line =
(@lines){</FONT></DIV>
<DIV><FONT size=3D2>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;=20
($left,$right)=3Dsplit(/:/,$line);</FONT></DIV>
<DIV><FONT size=3D2></FONT><FONT color=3D#000000=20
size=3D2>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;=20
$DATA{$left}=3D$right;</FONT></DIV>
<DIV><FONT size=3D2>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; =
}</FONT></DIV>
<DIV><FONT size=3D2></FONT>&nbsp;&nbsp;&nbsp; </DIV>
<DIV>&nbsp;&nbsp;&nbsp; if($DATA{'age'}&lt;20){</DIV>
<DIV>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;=20
$NEWARRAY[$counter++]=3D$DATA;&nbsp;&nbsp;&nbsp; # THIS LINE IS WRONG - =
HOW DO I=20
DO IT?</DIV>
<DIV>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; }</DIV></FONT><FONT=20
color=3D#000000 size=3D2>&nbsp;&nbsp;&nbsp; }</FONT></DIV>
<DIV><FONT color=3D#000000 size=3D2></FONT>&nbsp;</DIV>
<DIV><FONT color=3D#000000=20
size=3D2>for($loop=3D0;$loop&lt;@NEWARRAY;loop++){&nbsp;&nbsp;&nbsp;&nbsp=
;&nbsp;&nbsp;&nbsp;=20
#AND THIS IS ALSO WRONG</FONT></DIV>
<DIV><FONT color=3D#000000 size=3D2>&nbsp;&nbsp;&nbsp; foreach $key =
(keys=20
%NEWARRAY[$loop]){&nbsp;&nbsp;&nbsp; #AND HERE</FONT></DIV>
<DIV><FONT color=3D#000000 =
size=3D2>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; print=20
&quot;$NEWARRAY[$loop]{$key}\n\n&quot;;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbs=
p;&nbsp;=20
#AND HERE</FONT></DIV>
<DIV><FONT color=3D#000000 =
size=3D2>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;=20
}</FONT></DIV>
<DIV><FONT color=3D#000000 size=3D2>&nbsp;&nbsp;&nbsp; }</FONT></DIV>
<DIV><FONT color=3D#000000 size=3D2></FONT>&nbsp;</DIV>
<DIV><FONT color=3D#000000 size=3D2>Oh dear, I know what I want to do, =
but its the=20
right syntax I want.</FONT></DIV>
<DIV><FONT color=3D#000000 size=3D2></FONT>&nbsp;</DIV>
<DIV><FONT color=3D#000000 size=3D2>I wont hastle any more after this=20
one!</FONT></DIV>
<DIV><FONT color=3D#000000 size=3D2></FONT>&nbsp;</DIV>
<DIV><FONT color=3D#000000 size=3D2>Chris D</FONT></DIV></BODY></HTML>

------=_NextPart_000_001A_01BE4619.BDB5FD60--



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

Date: Fri, 22 Jan 1999 15:45:24 -0000
From: "Chris" <c-denman@dircon.co.uk>
Subject: multi-dimensional arrays - more help please!
Message-Id: <78a6bp$3hu$1@starburst.uk.insnet.net>

This is a multi-part message in MIME format.

------=_NextPart_000_0043_01BE461E.39CDBBA0
Content-Type: text/plain;
	charset="iso-8859-1"
Content-Transfer-Encoding: quoted-printable

I have loads of data files that I need to sort.
=20
Here is one data file:
=20
name:chris:
age:27:
sex:male:
=20
What I do, for easy access, is to load in the file and then turn it into =
a hash array like so:
=20
open(FILE,"001.dat");
@lines=3D<FILE>;
close FILE;
foreach $line (@lines){
    ($left,$right)=3Dsplit(/:/,$line);
    $DATA{$left}=3D$right;
    }

I have a loop to do this for all the files, but what if I only want =
cirtain files depending on their content like so:
=20
$counter=3D0;
=20
@files=3D<*.dat>
foreach $file (@files){
    open(FILE,$file);
    @lines=3D<FILE>;
    close FILE;
    undef $DATA;
    foreach $line (@lines){
        ($left,$right)=3Dsplit(/:/,$line);
        $DATA{$left}=3D$right;
        }
   =20
    if($DATA{'age'}<20){
        $NEWARRAY[$counter++]=3D$DATA;    # THIS LINE IS WRONG - HOW DO =
I DO IT?
        }
    }
=20
for($loop=3D0;$loop<@NEWARRAY;loop++){        #AND THIS IS ALSO WRONG
    foreach $key (keys %NEWARRAY[$loop]){    #AND HERE
        print "$NEWARRAY[$loop]{$key}\n\n";        #AND HERE
        }
    }
=20
Oh dear, I know what I want to do, but its the right syntax I want.
=20
I wont hastle any more after this one!
=20
Chris D

------=_NextPart_000_0043_01BE461E.39CDBBA0
Content-Type: text/html;
	charset="iso-8859-1"
Content-Transfer-Encoding: quoted-printable

<!DOCTYPE HTML PUBLIC "-//W3C//DTD W3 HTML//EN">
<HTML>
<HEAD>

<META content=3Dtext/html;charset=3Diso-8859-1 =
http-equiv=3DContent-Type>
<META content=3D'"MSHTML 4.72.2106.6"' name=3DGENERATOR>
</HEAD>
<BODY bgColor=3D#ffffff>
<DIV>
<DIV><FONT color=3D#000000 size=3D2>I have loads of data files that I =
need to=20
sort.</FONT></DIV>
<DIV><FONT color=3D#000000 size=3D2></FONT>&nbsp;</DIV>
<DIV><FONT color=3D#000000 size=3D2>Here is one data file:</FONT></DIV>
<DIV><FONT color=3D#000000 size=3D2></FONT>&nbsp;</DIV>
<DIV><FONT color=3D#000000 size=3D2>name:chris:</FONT></DIV>
<DIV><FONT color=3D#000000 size=3D2>age:27:</FONT></DIV>
<DIV><FONT color=3D#000000 size=3D2>sex:male:</FONT></DIV>
<DIV><FONT color=3D#000000 size=3D2></FONT>&nbsp;</DIV>
<DIV><FONT color=3D#000000 size=3D2>What I do, for easy access, is to =
load in the=20
file and then turn it into a hash array like so:</FONT></DIV>
<DIV><FONT color=3D#000000 size=3D2></FONT>&nbsp;</DIV>
<DIV><FONT color=3D#000000 =
size=3D2>open(FILE,&quot;001.dat&quot;);</FONT></DIV>
<DIV><FONT size=3D2>@lines=3D&lt;FILE&gt;;</FONT></DIV>
<DIV><FONT size=3D2>close FILE;</FONT></DIV>
<DIV><FONT size=3D2>foreach $line (@lines){</FONT></DIV>
<DIV><FONT size=3D2>&nbsp;&nbsp;&nbsp;=20
($left,$right)=3Dsplit(/:/,$line);</FONT></DIV>
<DIV><FONT size=3D2></FONT><FONT color=3D#000000 =
size=3D2>&nbsp;&nbsp;&nbsp;=20
$DATA{$left}=3D$right;</FONT></DIV>
<DIV><FONT size=3D2>&nbsp;&nbsp;&nbsp; }</FONT></DIV>
<DIV>&nbsp;</DIV>
<DIV><FONT color=3D#000000 size=3D2>I have a loop to do this for all the =
files, but=20
what if I only want cirtain files depending on their content like=20
so:</FONT></DIV>
<DIV><FONT color=3D#000000 size=3D2></FONT>&nbsp;</DIV>
<DIV><FONT size=3D2>$counter=3D0;</FONT></DIV>
<DIV><FONT color=3D#000000 size=3D2></FONT>&nbsp;</DIV>
<DIV><FONT color=3D#000000 size=3D2>@files=3D&lt;*.dat&gt;</FONT></DIV>
<DIV><FONT color=3D#000000 size=3D2>foreach $file (@files){</FONT></DIV>
<DIV><FONT color=3D#000000 size=3D2>
<DIV><FONT color=3D#000000 size=3D2>&nbsp;&nbsp;&nbsp;=20
open(FILE,$file);</FONT></DIV>
<DIV><FONT size=3D2>&nbsp;&nbsp;&nbsp; =
@lines=3D&lt;FILE&gt;;</FONT></DIV>
<DIV><FONT size=3D2>&nbsp;&nbsp;&nbsp; close FILE;</FONT></DIV>
<DIV><FONT size=3D2>&nbsp;&nbsp;&nbsp; undef $DATA;</FONT></DIV>
<DIV><FONT size=3D2>&nbsp;&nbsp;&nbsp; foreach $line =
(@lines){</FONT></DIV>
<DIV><FONT size=3D2>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;=20
($left,$right)=3Dsplit(/:/,$line);</FONT></DIV>
<DIV><FONT size=3D2></FONT><FONT color=3D#000000=20
size=3D2>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;=20
$DATA{$left}=3D$right;</FONT></DIV>
<DIV><FONT size=3D2>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; =
}</FONT></DIV>
<DIV><FONT size=3D2></FONT>&nbsp;&nbsp;&nbsp; </DIV>
<DIV>&nbsp;&nbsp;&nbsp; if($DATA{'age'}&lt;20){</DIV>
<DIV>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;=20
$NEWARRAY[$counter++]=3D$DATA;&nbsp;&nbsp;&nbsp; # THIS LINE IS WRONG - =
HOW DO I=20
DO IT?</DIV>
<DIV>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; }</DIV></FONT><FONT=20
color=3D#000000 size=3D2>&nbsp;&nbsp;&nbsp; }</FONT></DIV>
<DIV><FONT color=3D#000000 size=3D2></FONT>&nbsp;</DIV>
<DIV><FONT color=3D#000000=20
size=3D2>for($loop=3D0;$loop&lt;@NEWARRAY;loop++){&nbsp;&nbsp;&nbsp;&nbsp=
;&nbsp;&nbsp;&nbsp;=20
#AND THIS IS ALSO WRONG</FONT></DIV>
<DIV><FONT color=3D#000000 size=3D2>&nbsp;&nbsp;&nbsp; foreach $key =
(keys=20
%NEWARRAY[$loop]){&nbsp;&nbsp;&nbsp; #AND HERE</FONT></DIV>
<DIV><FONT color=3D#000000 =
size=3D2>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; print=20
&quot;$NEWARRAY[$loop]{$key}\n\n&quot;;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbs=
p;&nbsp;=20
#AND HERE</FONT></DIV>
<DIV><FONT color=3D#000000 =
size=3D2>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;=20
}</FONT></DIV>
<DIV><FONT color=3D#000000 size=3D2>&nbsp;&nbsp;&nbsp; }</FONT></DIV>
<DIV><FONT color=3D#000000 size=3D2></FONT>&nbsp;</DIV>
<DIV><FONT color=3D#000000 size=3D2>Oh dear, I know what I want to do, =
but its the=20
right syntax I want.</FONT></DIV>
<DIV><FONT color=3D#000000 size=3D2></FONT>&nbsp;</DIV>
<DIV><FONT color=3D#000000 size=3D2>I wont hastle any more after this=20
one!</FONT></DIV>
<DIV><FONT color=3D#000000 size=3D2></FONT>&nbsp;</DIV>
<DIV><FONT color=3D#000000 size=3D2>Chris =
D</FONT></DIV></DIV></BODY></HTML>

------=_NextPart_000_0043_01BE461E.39CDBBA0--



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

Date: Fri, 22 Jan 1999 20:16:54 +0530
From: Ramanujam Parthasarathi <partha@mihy.mot.com>
To: Chris Denman <c-denman@dircon.co.uk>
Subject: Re: multi-dimensional arrays with hashes help please
Message-Id: <36A88F5E.704CC9C1@mihy.mot.com>

I would suggest an array of hash-references in your case. Consider the
following code:

/whichever/path/perl -w
use strict;

my (@array, $one) = ();

push @founddata, ({'name' =>'Chris', 'age'=>'27'}); # push reference to
hash
push @founddata, ({'name'=> 'Fred', 'age'=>'Fred'});
# and so on.....

foreach $one (@founddata) {
    foreach $key (keys %$one) {
        print "$key : $one->{$key}\n\n";
    }
}


HTH
-Partha

Chris Denman wrote:

> Now, I know this code will not work:
>
> $founddata[0]{'name'}='Chris';
> $founddata[0]{'age'}='27';
> $founddata[1]{'name'}='Fred';
> $founddata[1]{'age'}='Fred';
>
> $cnt=0;
> foreach $one (@founddata){
>     foreach $key (keys %founddata[$cnt]){
>         print "$founddata[$cnt]{$key}\n\n";
>         }
>     $cnt++;
>     }
>
> But I need to do the same with legitimate code, anyone know how?
>
> Thanks in advance!
>
> Chris Denman





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

Date: Fri, 22 Jan 1999 14:46:42 GMT
From: droby@copyright.com
Subject: Re: Perl Criticism
Message-Id: <78a30e$sds$1@nnrp1.dejanews.com>

In article <fl_aggie-2101991741550001@aggie.coaps.fsu.edu>,
  fl_aggie@thepentagon.com (I R A Aggie) wrote:
> In article <787psa$tq1$1@nnrp1.dejanews.com>, droby@copyright.com wrote:
>
> + In article <fl_aggie-2001991000310001@aggie.coaps.fsu.edu>,
> +   fl_aggie@thepentagon.com (I R A Aggie) wrote:
>
> + > I see...topmind is here to protect us from ourselves. Before long, he'll
be
> + > working for the government, certifying programmers and languages that they
> + > comply with new government regulations.
>
> + Oh, my!  D'ya suppose he might have had something to do with GOSIP?
>
> I'm about to betray my ignerence, but what is GOSIP, other than the obvious
> non-acronym, lowercase version?
>

Government OSI Profile, a FIPS (Federal Information Processing Standard)
specifying an OSI configuration for use in the US Government.

Basically, NIST decided in the mid 1980's to require all  government machines
to have an OSI network stack. Such was pretty much unavailable, as OSI
existed only on paper.	It was quite a bit of paper, but there was no real
implementation.

--
Don Roby

-----------== Posted via Deja News, The Discussion Network ==----------
http://www.dejanews.com/       Search, Read, Discuss, or Start Your Own    


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

Date: 22 Jan 1999 15:10:13 GMT
From: dherriot@uk.oracle.com (Des Herriott)
Subject: Re: Perl Criticism
Message-Id: <78a4cl$h97$2@newshost.oracle.co.uk>

On Thu, 14 Jan 1999 07:06:30 GMT, topmind@technologist.com <topmind@technologist.com> wrote:
> No, only those anal about language (english). The more
> practical of us here are concentrating on wether
> saving keystrokes or maintainability is
> more important.

Actually, the more practical of us here are just getting on with using &
discussing this useful language.

Look, if you don't like the language, go and use something else.  You're
not going to persuade anyone here that Perl is as deficient as you say,
because, frankly, your arguments just aren't convincing.

It's possible to write unmaintainable code in any language.  I've
written plenty Perl in my time, and haven't had a complaint about
maintainability from my colleagues yet, because in 'production' code, I
make a considerable effort to avoid obfuscation.

-- 
Des Herriott, Oracle Corporation UK Ltd.
dherriot@uk.oracle.com
 - speaking for myself, not my employer.


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

Date: Fri, 22 Jan 1999 10:27:51 -0500
From: fl_aggie@thepentagon.com (I R A Aggie)
Subject: Re: Perl Criticism
Message-Id: <fl_aggie-2201991027510001@aggie.coaps.fsu.edu>

In article <78a30e$sds$1@nnrp1.dejanews.com>, droby@copyright.com wrote:

+ Basically, NIST decided in the mid 1980's to require all  government machines
+ to have an OSI network stack. Such was pretty much unavailable, as OSI
+ existed only on paper.  It was quite a bit of paper, but there was no real
+ implementation.

Ah, that explain's topmind's experience with large, detailed projects, and
his insistence that "implementation doesn't matter".

James


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

Date: Fri, 22 Jan 1999 11:58:54 -0400
From: Arved Sandstrom <Arved_37@chebucto.ns.ca>
Subject: Re: Perl XS ?
Message-Id: <Pine.GSO.3.95.iB1.0.990122115706.23813A-100000@halifax.chebucto.ns.ca>

On Fri, 22 Jan 1999, Marius Kjeldahl wrote:

> Tristan Krakau wrote:
> > 
> > I have a huge library with C-functions and some header files and I want
> > to create a XS Interface to use them in my perl script.
> > Is there any tool to automatically generate this?
> 
> Search for "perl" and "SWIG".

Or read up on the use of 'h2xs' in perlxstut.




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

Date: 22 Jan 1999 15:22:39 GMT
From: mhaefner@hrz.tu-darmstadt.de (Markus Hdfner)
Subject: Please help me with a client/server problem (Win32)
Message-Id: <78a53v$beb$1@sun27.hrz.tu-darmstadt.de>

#This example  sends a dos command to  the server, where it should execute. -> 
this works!
#...but why can't I send a message back to the client ? Does "system" 
blockading the socket ?


#This is the client:


use IO::Socket;

#command arguments (=dos command) in variable
$anzahl=@ARGV;
$dummy="";
for ($i=0;$i<=$anzahl;$i++){$dummy=$dummy.@ARGV[$i]." ";}
$remote_command=$dummy;

#creating socket
$socket=new IO::Socket::INET   (PeerAddr => "localhost",
				PeerPort => "666",
				Proto => "tcp",
				)or die "no connection";

#sending message to server (this works)
$socket->autoflush(1);
print  $socket $remote_command;

#receiving message from server (this doesn't work)
while($data=<$socket>){print $data;}
close $socket

#------------------------------------------------------------------------------
-------------------------------------------------------------------------------
--

#This is the server:

#creating server socket
use IO::Socket;
$request_client = IO::Socket::INET->new( LocalPort => 666, Listen => 5, Reuse 
=> 1 );

#receiving message from server
while ($new_client = $request_client->accept()) {
	     while (defined ($buf =<$new_client>)) 
           {   
				 print $buf;		
				 #executing dos command (till here it works)			
				 system <$buf."\n">;
		                        					
	}
}

#sending client the execute dos-command (this doesn't work)
print $request_client   $buf;			
close ($request_client);



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

Date: 22 Jan 1999 16:15:33 +0100
From: Jonathan Feinberg <jdf@pobox.com>
To: bart.lateur@skynet.be (Bart Lateur)
Subject: Re: Regular Expression Question
Message-Id: <m3yamvmj8q.fsf@joshua.panix.com>

bart.lateur@skynet.be (Bart Lateur) writes:

> parab0la@my-dejanews.com wrote:
> 
> >I'm try to match the pattern /helloworld/ or /byeworld/.  Is there any way
> >that I can combine them in one regexp, something like /\(hello|bye\)world/ ?
> 
> Is your syntax based on the syntax in Nisus (wordprocessor), or
> something?

emacs regexen also use backwhacks to distinguish magic parens from
literal ones, though the meaning is reversed from Perl usage.  Same is 
true of P*thon, sed, grep...  It's an understandable mistake to make,
if you're used to one or more of those environments.

-- 
Jonathan Feinberg   jdf@pobox.com   Sunny Brooklyn, NY
http://pobox.com/~jdf


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

Date: 22 Jan 1999 16:19:45 +0100
From: Jonathan Feinberg <jdf@pobox.com>
To: bart.lateur@skynet.be (Bart Lateur)
Subject: Re: Regular Expression Question
Message-Id: <m3vhhzmj1q.fsf@joshua.panix.com>

bart.lateur@skynet.be (Bart Lateur) writes:

> Drop the backwhacks before the parens. Backwhacks are for QUOTING
> non-word characters (anything but leter, digits, underscore).

That's not quite true.  Backwhacks are for quoting regular expression
metacharacters and variable prefixes.  There are plenty of non-word
characters that don't require quoting.  Furthermore, a metacharacter
in one regex is a literal in another, depending on the regex
delimiter.

-- 
Jonathan Feinberg   jdf@pobox.com   Sunny Brooklyn, NY
http://pobox.com/~jdf


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

Date: 22 Jan 1999 14:17:42 GMT
From: mwe@unixfe.cc.rl.ac.uk (Mike Ellwood)
Subject: Re: Safely editing /etc/passwd.
Message-Id: <78a1a6$2td0@newton.cc.rl.ac.uk>

jbritain@home.com wrote:


: 5. Consider, that you may need to make the original temporarily
: unavailable to prevent other users from doing simultaneous updates of
: their accounts while the process is running.

Is there any way of locking out a critical file like this
from being updated by another process?
--
Mike.Ellwood@rl.ac.uk


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

Date: Fri, 22 Jan 1999 15:07:58 GMT
From: tomten@my-dejanews.com
Subject: Re: Sending SMS messages with perl script ??
Message-Id: <78a485$thg$1@nnrp1.dejanews.com>

In article <77jumi$6ta$1@nnrp1.dejanews.com>,
  tomten@my-dejanews.com wrote:
> In article <77cthn$3gu$1@koza.nl.net>,
>   "Peter Davidse" <ptrdvds@zeelandnet.nl> wrote:
> > For a hobby project i need to send SMS messages from a linux based
> > webserver. Does any one know how to send SMS messages with perl.
> >
> > Short :
> > Ping -> no reply -> SMS to my GSM
> >
> >
> check out:
> http://wkweb5.cableinet.co.uk/Npearce/email2SMS.html

I've made a shell script that I use to send SMS or pager messages if status of
servers changes. I'm using the SMS_client located at:
http://www.styx.demon.co.uk/

You can of course make it to do whatever you want.
I'm running it as a cronjob every 10th minute.

Make it executable and change the "homedir" path to the one you want, and
make a "nettest.servers" file whith servers you want to ping for. This
version just logs and echos messages.

No garantees!

/Fredrik Corneliusson

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

#!/bin/sh
#
# This program pings the hosts in file "nettest.hosts", logs and leaves
# massage if status of hosts changes.
# Fredrik Corneliusson OSO 990122
# e-mail: fredrikc@oso.chalmers.se

error=0
send_SMS=0
homedir="/home/fredrikc/mobil_alarm/nettest/"
config_file="nettest.servers"
logfile="ping.log"
errfile=".pingerr"
err_message="`date '+%x %T'` ERR: Cant reach:"
ok_message="`date '+%x %T'` OK: Can reach again:"
message=
err=
ok=

servers=`grep -v "^\#" $homedir$config_file | grep -v "^$"`

	echo `date` >> $homedir$logfile

if [ ! -f "$homedir$errfile" ]
	then
	echo > $homedir$errfile
	fi


for i in $servers
do
  if ping -c 1 $i > /dev/null 2>&1
    then
	echo "$i OK"
	echo -e "\t$i\tOK" >> $homedir$logfile

	 if [ `grep $i $homedir$errfile > /dev/null` ]
	   then
	    ok="$ok $i,"
	    grep -v "$i" $homedir$errfile > $homedir$errfile
	    send_SMS=1
	 fi

    else
	echo "$i NOT OK!!!"
	echo -e "\t$i\tNOT OK!!!" >> $homedir$logfile
	 if [ ! `grep "$i" $homedir$errfile ` ]
	   then
	    echo "$i" >> $homedir$errfile
	    err="$err $i,"
	    send_SMS=1
	 fi
	error=1
  fi
done
echo "" >> $homedir$logfile

# Do this if status changes
if [ $send_SMS -eq 1 ]
  then
   if [ $err ]
   then
    message=$err_message$err
   fi
   if [ $ok ]
   then
    message="$message $ok_message$ok"
   fi

# Your command to send massage goes here
    echo $message
    exit 1
fi
exit 0

-----------== Posted via Deja News, The Discussion Network ==----------
http://www.dejanews.com/       Search, Read, Discuss, or Start Your Own    


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

Date: Fri, 22 Jan 1999 09:21:43 -0600
From: Tom Briles <tbriles@austin.ibm.com>
Subject: Re: string to integer conversion
Message-Id: <36A89787.1CEC91C8@austin.ibm.com>

Lee Benfield wrote:

> Err, james, I'm sure this is bound to be in
>
> a) the FAQ
> b) (definitely) the Manual.
>
> use
>
> int($mystring)
>
> Lee.
>
> James wrote:
> >
> > Sirs,
> >
> > Hi.. I'm new to perl. I would like to know how will i Convert a string
> > number "47" to integer number 47 ?? For example, I have this program that
> > adds 2 to "47". So i have to convert "47" to 47 then add 2 to make it 49
> > then convert it back to "49" string.. how ??
> >
> > thanx for any help u can give me..
> >
> > James
>
> --
> -=-=-=-=-=-=-=-=-=-=-=-=-=-=-
> Lee Benfield, Ford Motor Co.

Err, lee,

perldoc -f int

"Returns the integer portion of EXPR.  If EXPR is omitted, uses $_."

See Eric's response.

- Tom



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

Date: 22 Jan 1999 16:09:07 +0100
From: Jonathan Feinberg <jdf@pobox.com>
Subject: Re: The Documeantion (was Re: Perl problem :(Offline mode...)
Message-Id: <m3zp7bmjjg.fsf@joshua.panix.com>

Andrew Fry <andrewf@beausys.demon.co.uk> writes:

> In article <7854ev$14a$1@gellyfish.btinternet.com>, Jonathan Stowe
> <gellyfish@btinternet.com> writes

> >I would certainly find time to search the appropriate documentation
> >thoroughly before I asked a question of anyone.
> 
> Obviously you have more time on your hands than I do.

Obviously you think our time isn't worth as much as yours.

> Well, if that's your view, why dont you just post a standard reply to
> *every* query telling the poster to go and read the documentation ?

If that's your view, why don't you go ask other people to do the rest
of your job, too?

*PLONK*

-- 
Jonathan Feinberg   jdf@pobox.com   Sunny Brooklyn, NY
http://pobox.com/~jdf


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

Date: 22 Jan 1999 10:46:20 -0500
From: clay@panix.com (Clay Irving)
Subject: Re: Yet another basic question.
Message-Id: <78a6gc$gfm$1@panix.com>

In <78a24u$fbe@dfw-ixnews10.ix.netcom.com> "Ban Spam Now" <no_spam@no_spam.com> writes:

>Thanks Ala.  BTW what is "perlvar"?

Part of the documentation included with the Perl distribution. For example:

   $ perldoc perlvar
    
       
    
    PERLVAR(1)     User Contributed Perl Documentation     PERLVAR(1)
    
    
    
    NAME
         perlvar - Perl predefined variables
    
    DESCRIPTION
         Predefined Names
    
         The following names have special meaning to Perl.  Most
         punctuation names have reasonable mnemonics, or analogues in
         one of the shells.  Nevertheless, if you wish to use long
         variable names, you just need to say
    
             use English;
    
         at the top of your program.  This will alias all the short
         names to the long names in the current package.  Some even
         have medium names, generally borrowed from awk.
[...]
    
-- 
Clay Irving
clay@panix.com


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

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


Administrivia:

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

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

The Perl-Users Digest is a retransmission of the USENET newsgroup
comp.lang.perl.misc.  For subscription or unsubscription requests, send
the single line:

	subscribe perl-users
or:
	unsubscribe perl-users

to almanac@ruby.oce.orst.edu.  

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

To submit articles to comp.lang.perl.announce, send your article to
clpa@perl.com.

To request back copies (available for a week or so), send your request
to almanac@ruby.oce.orst.edu with the command "send perl-users x.y",
where x is the volume number and y is the issue number.

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

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

For other requests pertaining to the digest, send mail to
perl-users-request@ruby.oce.orst.edu. Do not waste your time or mine
sending perl questions to the -request address, I don't have time to
answer them even if I did know the answer.


------------------------------
End of Perl-Users Digest V8 Issue 4721
**************************************

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