[22014] in Perl-Users-Digest

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

Perl-Users Digest, Issue: 4236 Volume: 10

daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Mon Dec 9 14:05:56 2002

Date: Mon, 9 Dec 2002 11:05:11 -0800 (PST)
From: Perl-Users Digest <Perl-Users-Request@ruby.OCE.ORST.EDU>
To: Perl-Users@ruby.OCE.ORST.EDU (Perl-Users Digest)

Perl-Users Digest           Mon, 9 Dec 2002     Volume: 10 Number: 4236

Today's topics:
        can't display HTML file in browser PERLProgrammer@nowhere.com
        cgi and perl on windows 98 ? <os7man@attbi.com>
    Re: cgi and perl on windows 98 ? <wsegrave@mindspring.com>
    Re: cgi and perl on windows 98 ? <flavell@mail.cern.ch>
    Re: Currency Regular expression (Tad McClellan)
        Difference between assignment and push statement <stremitz@consultant.com>
    Re: Difference between assignment and push statement <perl-dvd@ldschat.com>
    Re: Difference between assignment and push statement <dave@dave.org.uk>
    Re: Difference between assignment and push statement (Tad McClellan)
    Re: Difference between assignment and push statement ctcgag@hotmail.com
        Getopt::Long::GetOptions and a command line option name <sacha.raybaud@hp.com>
        hashed filehandles? <daniel.heiserer@bmw.de>
    Re: Help Im losing faith! VERY JUICY PROBLEM! <cpryce@pryce.net>
    Re: HoH problems (LazyPerfectionist)
        need to create 2 perl administration scripts for window <hamunaptra@pandora.be.NOSPAM>
    Re: OT: Re: How to substitute ' by \' (Tad McClellan)
    Re: porting a routine which uses uint32_t ()
        Trouble with macintosh file access (Colin)
    Re: Trouble with macintosh file access (Tad McClellan)
    Re: VBA equivalent of Range in Perl <usenet@dwall.fastmail.fm>
        which UI for Perl? <erik@pax07e3.mipool.uni-jena.de>
    Re: which UI for Perl? <twhu@lucent.com>
    Re: Why doesn't my array grow? (Rob Richardson)
    Re: Why doesn't my array grow? (Tad McClellan)
        Digest Administrivia (Last modified: 6 Apr 01) (Perl-Users-Digest Admin)

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

Date: 9 Dec 2002 18:55:55 GMT
From: PERLProgrammer@nowhere.com
Subject: can't display HTML file in browser
Message-Id: <at2ovr$uct$1@news.netmar.com>

My PERL script creates several HTML files (in the same directory), but when I
try to display any of them in a browser, I get an 'HTTP 500 Internal server
error' message. Any ideas as to why this is happening?



 -----  Posted via NewsOne.Net: Free (anonymous) Usenet News via the Web  -----
  http://newsone.net/ -- Free reading and anonymous posting to 60,000+ groups
   NewsOne.Net prohibits users from posting spam.  If this or other posts
made through NewsOne.Net violate posting guidelines, email abuse@newsone.net


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

Date: Mon, 09 Dec 2002 17:51:26 GMT
From: Eric Osman <os7man@attbi.com>
Subject: cgi and perl on windows 98 ?
Message-Id: <3DF4D5C8.1D15B5FC@attbi.com>


I've got both a quick request, and then more questions
that are more specific:

The quick request:  on my windows 98 system, what
                   (hopefully free or shareware) do
                   I need to install in order to test
                   CGI scripts before putting them
                   up on an actual web host



The more specific questions:

o        Using "mailto:" url pointer, can I make it
         actually SEND an email, or will user always
         be left in their email client and they have
         to click the send button themselves

o        What I'm really trying to implement is to have
         a filled-out-form on an html page be sent
         through email when SUBMIT button is pressed.

         For this purpose, if I can't use "mailto:",
         should I be using CGI ?

o        If CGI, is there one package I can install
         on my windows 98 to test this ?  Or do
         I have to install a separate web server piece
         AND cgi-perl interpretation piece AND
         some sort of procmail piece to send the
         actual email ?

By the way, I know html and java and javascript well,
plus unix shell scripting.  I'm new to CGI
and PERL however, and fairly new to running web
server software.  However, I have run apache tomcat
java servlet software before.  (Maybe that will
support all this stuff ?  Do you know ?)

Thanks for any info to help me get going here.  I'm
basically trying to figure what I need to install
on my windows 98 system to develop and test perl
cgi scripts called from html.

Thanks.

/Eric

-- 
PLEASE NOTE: comp.infosystems.www.authoring.cgi is a
SELF-MODERATED newsgroup. aa.net and boutell.com are
NOT the originators of the articles and are NOT responsible
for their content.

HOW TO POST to comp.infosystems.www.authoring.cgi:
http://www.thinkspot.net/ciwac/howtopost.html


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

Date: Mon, 09 Dec 2002 18:15:50 GMT
From: "William Alexander Segraves" <wsegrave@mindspring.com>
Subject: Re: cgi and perl on windows 98 ?
Message-Id: <at2mtb$m79$1@slb5.atl.mindspring.net>

"Eric Osman" <os7man@attbi.com> wrote in message
news:3DF4D5C8.1D15B5FC@attbi.com...
>
> I've got both a quick request, and then more questions
> that are more specific:
>
> The quick request:  on my windows 98 system, what
>                    (hopefully free or shareware) do
>                    I need to install in order to test
>                    CGI scripts before putting them
>                    up on an actual web host

IndigoPerl, available free from www.indigostar.com, gives you Perl, Apache,
and a nice GUI package manager.

Bill Segraves



-- 
PLEASE NOTE: comp.infosystems.www.authoring.cgi is a
SELF-MODERATED newsgroup. aa.net and boutell.com are
NOT the originators of the articles and are NOT responsible
for their content.

HOW TO POST to comp.infosystems.www.authoring.cgi:
http://www.thinkspot.net/ciwac/howtopost.html


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

Date: Mon, 09 Dec 2002 18:59:53 GMT
From: "Alan J. Flavell" <flavell@mail.cern.ch>
Subject: Re: cgi and perl on windows 98 ?
Message-Id: <Pine.LNX.4.40.0212091945550.8521-100000@lxplus076.cern.ch>

On Dec 9, Eric Osman inscribed on the eternal scroll:

> The quick request:  on my windows 98 system, what
>                    (hopefully free or shareware) do
>                    I need to install in order to test
>                    CGI scripts before putting them
>                    up on an actual web host

Indigoperl is easiest.  Activestate Perl, plus Apache win32, is
another option.  (google will find them easily...)

> o Using "mailto:" url pointer,

"mailto:" has nothing to do with CGI.  CGI is an interface between
an http server and your program.

When you ask your mailto: question in an appropriate place, you'll
presumably get told that if you're thinking of writing it in a form
action attribute, you'd be advised to think again.

>          be left in their email client and they have
>          to click the send button themselves

I should bloody-well hope so.  Who wants to be sending inadvertent
emails?  You trying to write a virus or something?

> o        What I'm really trying to implement is to have
>          a filled-out-form on an html page be sent
>          through email when SUBMIT button is pressed.

Have you thought this through?  What are you really trying to achieve?
Lots of people messing around like that have found themselves creating
spam-relays, and getting their server blacklisted, so be sure you know
what you're getting into.

> By the way, I know html and java and javascript well,
> plus unix shell scripting.  I'm new to CGI
> and PERL however,

Look: CGI is a programming interface, it's practically independent of
programming language.

Perl is a programming language, that does all kinds of jobs, most of
which have nothing to do with CGI.

[f'ups narrowed]

> and fairly new to running web
> server software.  However, I have run apache tomcat
> java servlet software before.  (Maybe that will
> support all this stuff ?  Do you know ?)

Yes and yes.

> Thanks for any info to help me get going here.

Define your real-world task.  That's where the dragons lie.

The details of implementing them are otherwise straightforward, since
you say you have experience with at least some programming language.

> I'm
> basically trying to figure what I need to install
> on my windows 98 system to develop and test perl
> cgi scripts called from html.

That's easy if you already have experience with a programming
language.  See the answer I gave at the start.  Read and re-read the
Perl FAQs[1], and the relevant documentation to which they point you.

[1] and if the next question is "where are they?" - install Perl and
that's where they will be.

have fun.


-- 
PLEASE NOTE: comp.infosystems.www.authoring.cgi is a
SELF-MODERATED newsgroup. aa.net and boutell.com are
NOT the originators of the articles and are NOT responsible
for their content.

HOW TO POST to comp.infosystems.www.authoring.cgi:
http://www.thinkspot.net/ciwac/howtopost.html


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

Date: Mon, 9 Dec 2002 08:47:34 -0600
From: tadmc@augustmail.com (Tad McClellan)
Subject: Re: Currency Regular expression
Message-Id: <slrnav9b86.2dl.tadmc@magna.augustmail.com>

Elf <smltestau@yahoo.com.au> wrote:

> I'm trying to write a regular expression which will validate a
> currency string.


> new RegExp( /^\$?\d+(?:,\d{3})*(?:\.\d{1,2}){0,1}$/ );

> That works fine.  The next bit doesn't.
> (?:\.\d{1,2}){0,1} - an optional group of a full stop followed by 1 or
> 2 digits


It works for me...


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

$_ = '1,234,567.89';

if ( /^\$?\d+(?:,\d{3})*(?:\.\d{1,2}){0,1}$/ ) {
   print "matched\n";
}
else {
   print "No match\n";
}
----------------------------


outputs "matched".


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


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

Date: Mon, 09 Dec 2002 09:37:24 -0500
From: Alexander Stremitzer <stremitz@consultant.com>
Subject: Difference between assignment and push statement
Message-Id: <3DF4AAA4.4010909@consultant.com>

my %myhash = ();

$myhash{$patid}{$accno} = [ $tmp ];
push @{ $myhash{$patid}{$accno} }, $tmp;

What is the difference between the 2 statements above ? They seem to do 
the same thing in my program. Is one preferred over the other ?

Thanks for enlightening me,
Alex

-- 
All man's miseries derive from not being able to sit quietly in a room alone. (Pascal)



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

Date: Mon, 9 Dec 2002 07:58:52 -0700
From: "David" <perl-dvd@ldschat.com>
Subject: Re: Difference between assignment and push statement
Message-Id: <D52J9.5696$K5.2693@fe01>

"Alexander Stremitzer" <stremitz@consultant.com> wrote in message
news:3DF4AAA4.4010909@consultant.com...
> my %myhash = ();
>
> $myhash{$patid}{$accno} = [ $tmp ];
> push @{ $myhash{$patid}{$accno} }, $tmp;
>
> What is the difference between the 2 statements above ? They seem to
do
> the same thing in my program. Is one preferred over the other ?
>

These do pretty much accomplish the same thing.  According to my
understanding, here's how it works.

$myhash{$patid}{$accno} = [ $tmp ];

Says "define this value as an array ref, then assign the array ref
values"

push @{ $myhash{$patid}{$accno} }, $tmp;

This says "push this value onto the array pointed to by this hash
element, oh wait, there is no array yet.  Ok let me make one, ok now we
push the value on".
For defining the value, I much prefer the first method, but the second
method is used when you need to add values to the array and you don't
want to redefined the whole array.

I don't remember the exact circumstance, but I do recall having trouble
with the values of the anonymous array once when defining it with the
second method, so yes, I defiantly recommend the first.

Regards,
David





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

Date: Mon, 09 Dec 2002 15:17:22 +0000
From: "Dave Cross" <dave@dave.org.uk>
Subject: Re: Difference between assignment and push statement
Message-Id: <pan.2002.12.09.15.17.21.551250@dave.org.uk>

On Mon, 09 Dec 2002 09:37:24 +0000, Alexander Stremitzer wrote:

> my %myhash = ();
> 
> $myhash{$patid}{$accno} = [ $tmp ];
> push @{ $myhash{$patid}{$accno} }, $tmp;
> 
> What is the difference between the 2 statements above ? They seem to do 
> the same thing in my program. Is one preferred over the other ?

If you know that $myhash{$patid}{$accno} is empty then you're right that
they do the same thing.

If there's already a value in $myhash{$patid}{$accno} then they do very
different things. That might be a reason for choosing between them.

Dave...

-- 
  Brian: Oh screw Maximilian!
  Sally: I do.
  Brian: So do I.



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

Date: Mon, 9 Dec 2002 09:54:26 -0600
From: tadmc@augustmail.com (Tad McClellan)
Subject: Re: Difference between assignment and push statement
Message-Id: <slrnav9f5i.2tg.tadmc@magna.augustmail.com>

Dave Cross <dave@dave.org.uk> wrote:
> On Mon, 09 Dec 2002 09:37:24 +0000, Alexander Stremitzer wrote:
> 
>> my %myhash = ();
>> 
>> $myhash{$patid}{$accno} = [ $tmp ];
>> push @{ $myhash{$patid}{$accno} }, $tmp;
>> 
>> What is the difference between the 2 statements above ? They seem to do 
>> the same thing in my program. Is one preferred over the other ?
> 
> If you know that $myhash{$patid}{$accno} is empty then you're right that
> they do the same thing.
> 
> If there's already a value in $myhash{$patid}{$accno} then they do very
> different things. 


Because the 2nd one (might) make use of "autovivification", which is
only "triggered" when you attempt to dereference undef.

   perldoc perlref

and

   http://tlc.perlarchive.com/articles/perl/ug0002.shtml


To see the difference:

--------------------------
#!/usr/bin/perl
use warnings;
use strict;
use Data::Dumper;

my $tmp = 'foobar';
my $patid = 'foo';
my $accno = 'bar';

my %anon = ();
$anon{$patid}{$accno} = [ 'something' ];
$anon{$patid}{$accno} = [ $tmp ];        # overwrites with new anon array
print Dumper(\%anon), "\n";

my %push = ();
$push{$patid}{$accno} = [ 'something' ];
push @{ $push{$patid}{$accno} }, $tmp;   # adds an element to anon array
print Dumper(\%push), "\n";
--------------------------


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


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

Date: 09 Dec 2002 17:24:44 GMT
From: ctcgag@hotmail.com
Subject: Re: Difference between assignment and push statement
Message-Id: <20021209122444.930$gb@newsreader.com>

Alexander Stremitzer <stremitz@consultant.com> wrote:
> my %myhash = ();
>
> $myhash{$patid}{$accno} = [ $tmp ];
> push @{ $myhash{$patid}{$accno} }, $tmp;
>
> What is the difference between the 2 statements above ?

One assigns a ref to a one element array into the double hash,
the other adds one element into the array already referenced by the
double hash (creating the array first, if appropriate).

> They seem to do
> the same thing in my program.

As long as $myhash{$patid}{$accno} is either undefined or a ref to an
empty array, they do the same thing.  Otherwise, they don't do the same
thing.

> Is one preferred over the other ?

If the statement will only be executed once, then I prefer the first
(although I have to question the wisdom of using an array when it will
only hold a single value.)  If the statement is executed multiple times,
then they do different things and the preferred one is the one that
does the right thing.

Xho

-- 
-------------------- http://NewsReader.Com/ --------------------
Usenet Newsgroup Service              New Rate! $9.95/Month 50GB


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

Date: Mon, 9 Dec 2002 15:39:26 +0100
From: "sacha raybaud" <sacha.raybaud@hp.com>
Subject: Getopt::Long::GetOptions and a command line option name that contains colon (":") character
Message-Id: <7Y1J9.15$Bd1.280599@news.cpqcorp.net>

Hi,

I encounter the following trouble with GetOptions.

One of the command line argument is named "test:arg1". Therefore, I tried to
write something like this:

        my ($ret);

         # Command line parameters
          my ($arg1);

          # Get parameter values
          $ret=&GetOptions('test:arg1=s' => \$arg1);

This does not work because the colon between test and arg1 has also a
meaning for perl in the context of GetOptions.
I tried to "disable" the meaning of colon but I did not succeed in.

Do you have any ideas that could help?

Thanks and best regards,

Sacha




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

Date: Mon, 09 Dec 2002 19:12:48 +0100
From: HEISERER DANIEL <daniel.heiserer@bmw.de>
Subject: hashed filehandles?
Message-Id: <3DF4DD20.6BBB925@bmw.de>

This is a multi-part message in MIME format.
--------------7C7ED9A4DD74E0CEBBBAA767
Content-Type: text/plain; charset=us-ascii
Content-Transfer-Encoding: 7bit

Hi,

I try to write to a filehandle which is a hash

foreach $t(keys %M){
open($op{$t},">file.$t");
}
foreach $t(keys %M){
	printf $op{$t} "hello mr %s \n",$M{$t};
}

Obviously this does not work because perl is unable to use this hash
approach for filehandles.

How can I achieve that or something like that?
I absolutely hate to loop around with if-loops

thanks, daniel
--------------7C7ED9A4DD74E0CEBBBAA767
Content-Type: text/x-vcard; charset=us-ascii;
 name="daniel.heiserer.vcf"
Content-Transfer-Encoding: 7bit
Content-Description: Card for HEISERER DANIEL
Content-Disposition: attachment;
 filename="daniel.heiserer.vcf"

begin:vcard 
n:Daniel;Heiserer,
tel;fax:41696
tel;home:1409782
tel;work:21187
x-mozilla-html:FALSE
adr:;;;;;;
version:2.1
email;internet:daniel.heiserer@bmw.de
x-mozilla-cpt:;-3136
fn:Heiserer, Daniel
end:vcard

--------------7C7ED9A4DD74E0CEBBBAA767--



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

Date: Mon, 09 Dec 2002 09:27:26 -0600
From: cp <cpryce@pryce.net>
Subject: Re: Help Im losing faith! VERY JUICY PROBLEM!
Message-Id: <BA1A127E.12FA3%cpryce@pryce.net>

in article 4379a3c8.0212080614.fea46a7@posting.google.com, LazyPerfectionist
at mod3@hotmail.com wrote on 12/8/02 8:14 AM:

> Im trying to do a look up table...eg

I don't understand what you mean by that. I'm not sure that you understand
what you mean by that?

> 
> data set in file 
>                 #SUBJECT NAME MARK
>                 FRENCH JANE 83
>                 ...etc

Is the #SUBJECT a typo, or are the records actually keyed by a student ID?

> I want the %data to contain
>                 SUBJECT = FRENCH
>                 NAME = JANE
>                 MARK = 83
>                 etc...
> 
> So when I read it from a file I use the header as a look up table
>                 SUBJECT = ^(FRENCH|ENGLISH|MATHS)
>                 NAME = \b[A-Z]+\b
>                 etc..

I'm not sure why you read the data in that way.
> 
> the data key1 contains the line no
>                 %data{$lineno}
> 
> the data key2 contains the headings
>                 $data{$lineno}{SUBJECT} = $values[0]
> 
> So I thought later I could do something like this
>            for $lineno (keys %data)
>             for(0..#header)
>              if( $data{$lineno}{$_} !~ /values header{$_}/)
>               print (not valid)
> 
>           or better
> 
>            for $lineno (keys %data)
>             if($data{$lineno}{keys %{$i}} !~ /values %{$i}/)
>              print (experimental idea)

Not really sure what you're doing here. Not sure where you're generating the
array @values (or why). You'd have to show more code.

> in the first case I would have to take the %data along with the header
> but in the second case the %data has all I need...
> 
> What Im trying to achieve is a way to reduce the use of loops by
> letting the hash do everything...

> 
> Is there a way to map 'HASH(0x9122b38)'?

Yes, but don't do that .

> 
> Im i thinking about this the wrong way?

I think so. I've attached a short program that parses the data that you've
shown. I haven't added any error checking, as the data that you've shown is
an incomplete sample, so I've no idea what can and can't go wrong. If your
data actually contains student ID's, that would make for a better primary
key for the %data hash than line numbers.

 perldoc perlvar will explain the $. variable.
 perldoc -f split will explain the use of split without args.

#!/usr/local/bin/perl -w

use strict;

my %data; 

my (@headers, @records);
while (<DATA>) { 
    chomp;
    my %temp;
    if ($. == 1 ) {
        # First line, get the headers
        @headers = split;
    } else {
        # Not the first line, get data
        @records = split;
        for my $index (0..$#records) {
            $temp{$headers[$index]} = $records[$index];
            $data{$.} = \%temp;
        }
    }
}
# Now, if we want all of Jane's scores, we can say...

my $student = 'JANE';
my @scores; 

foreach (keys %data) {
    push @scores, $data{$_} if $data{$_}{NAME} eq $student;
} 

print "Scores for $student : \n";

foreach my $score (@scores) {
    print "\t$score->{'#SUBJECT'}: $score->{MARK}\n";
} 

# Or all of the scores for a certain Subject Sorted by student name

@scores = ();
my $subject = 'FRENCH';
foreach (keys %data) {
    push @scores, $data{$_} if $data{$_}{'#SUBJECT'} eq $subject;
} 

print "\nScores for $subject Class : \n";

foreach my $score (sort{ $a->{NAME} cmp $b->{NAME} } @scores) {
    print "\t$score->{NAME}: $score->{MARK}\n";
} 


__DATA__
#SUBJECT NAME MARK
FRENCH JANE 83
MATH JANE 75
FRENCH ANNA 93






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

Date: 9 Dec 2002 08:55:19 -0800
From: mod3@hotmail.com (LazyPerfectionist)
Subject: Re: HoH problems
Message-Id: <4379a3c8.0212090855.68ec11ea@posting.google.com>

mauzo@ux-019-11.csv.warwick.ac.uk (Ben Morrow) wrote in message news:<asvr2i$qng$1@wisteria.csv.warwick.ac.uk>...
> mod3@hotmail.com (LazyPerfectionist) wrote:
> >
> >Im trying to do a look up table...eg
> >
> >data set in file 
> >                  #SUBJECT NAME MARK
> >                  FRENCH JANE 83
> >                  ...etc
> >
> >I want the %data to contain 
> >                  SUBJECT = FRENCH
> >                  NAME = JANE
> >                  MARK = 83
> >                  etc...
> >
> >So when I read it from a file I use the header as a look up table
> >                  SUBJECT = ^(FRENCH|ENGLISH|MATHS)
> >                  NAME = \b[A-Z]+\b
> >                  etc..
> >
> >the data key1 contains the line no 
> >                  %data{$lineno}
> 
> $data{$lineno}
> 
> >
> >the data key2 contains the headings 
> >                  $data{$lineno}{SUBJECT} = $values[0]
> >
> >So I thought later I could do something like this
> >             for $lineno (keys %data)
> >              for(0..#header)
> 
> $#header, or better for(@header).
> But I don't think this is what you mean anyway...
> 
> >               if( $data{$lineno}{$_} !~ /values header{$_}/)
> 
> This won't work :)
> 
> >                print (not valid)
> >
> >            or better 
> >
> >             for $lineno (keys %data)
> >              if($data{$lineno}{keys %{$i}} !~ /values %{$i}/)
> 
> Nor will this. :)
> 
> >               print (experimental idea)
> >
> >in the first case I would have to take the %data along with the header
> >but in the second case the %data has all I need...
> >
> >What Im trying to achieve is a way to reduce the use of loops by
> >letting the hash do everything...
> 
> Ah, I see now. I think what you want is closer to this: [all untested]
> 
> >data set in file (just for reference)
> >                  #SUBJECT NAME MARK
> >                  FRENCH JANE 83
> >                  ...etc
> >
> 
> my @data;          # a hash keyed by numbers only should usually be an array
> my @subjects = qw/FRENCH ENGLISH MATHS/;
> my $subjects;
> {
>   local $" = "|";
>   $subjects = qr/@subjects/;
> }
> # you could just have my $subjects = qr/FRENCH | ENGLISH | MATHS/x;, but I
> # think this is nicer (you can get the list of subjects from elsewhere...)
> 
> while(<INPUT>) {
>   next if /^#/;         # skip comments
> 
>   /^ ($subjects) \s+ (.*?) \s+ (\d+) $/x or print "line $. is invalid", next;
>      # we check for invalid lines here
>      # you may need to adjust this re to suit the exact format of the data
>      # /x is your friend
> 
>   push @data, { subject => $1, # I have an aversion to CAPS :)
>                 name    => $2,
>                 mark    => $3
>               };
> }
> 
> This has the slight problem that you lose line number information: the array
> only contains valid lines. This can be solved by using
> 
> my $line;
> while {<INPUT>) {
>   $line = undef;
>   next if /^#/;
>  
>   /^ ($subjects) \s+ (.*?) \s+ (\d+) $/x or print "line $. is invalid", next;
> 
>   $line = { subject => $1,
>             name    => $2,
>             mark    => $3
>           };
> }
> continue {
>   push @data, $line;
> }
> 
> which will create undef entries for comments and lines which were invalid.
> 
> I think before you go much further you need to read perldoc perllol quite
> carefully :)
> 
> >p.s. thanks for your patience ben...
> 
> No problem :)
> 
> Ben

Took your advise after hitting a very hard wall... thanks for all your help Ben!


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

Date: Mon, 09 Dec 2002 17:22:49 GMT
From: "HamuNaptra" <hamunaptra@pandora.be.NOSPAM>
Subject: need to create 2 perl administration scripts for windows
Message-Id: <Jj4J9.43039$Ti2.6715@afrodite.telenet-ops.be>

I need to create 2 perl scripts for administrtaion on a win200.
Since I am a newbie at perl, I'm asking here if someone can help me on this?

first script

a script that uses a quota system for userdirectories
a) the script needs to work automatically once a day
b) if a user directory reaches x MB a warning is placed in the user directory in
a textfile
c) if it reaches y MB a backup is made of all the files, the original files are
deleted and a file is placed containing a message
d) warn the sysem admin of these operations

second script

a script that can remove profiles from a directory, the profile Administrator,
All users en Default User may not be deleted.
the script shouldn't delete the running profile if a user is logged in.

if someone can fill in some of the parts that I need to do, their very welcome
to do this.




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

Date: Mon, 9 Dec 2002 07:48:07 -0600
From: tadmc@augustmail.com (Tad McClellan)
Subject: Re: OT: Re: How to substitute ' by \'
Message-Id: <slrnav97om.2dl.tadmc@magna.augustmail.com>

Paul van Eldijk <rev_1318@hotmail.com> wrote:
> Tad McClellan wrote:
>> Julian Mehnle <julian@mehnle.net> wrote:
>>> Francesco Moi <francescomoi@europe.com> wrote:
>>>> I'm trying to substitute the character ' by \' into a string:
>> 
>>>   $text =~ s/\'/\\\'/g;
>>                ^    ^
>>                ^    ^

>> Backslashes make your code hard to read and understand, so you should
>> only backslash when you _must_ backslash.
>> 
>> None of the underlined backslashes above are needed.
>  
> Of course you're right, but...
> For a less experienced Perl-user it is often difficult to know which
> characters need to be escaped and which don't. 


I do not write code with the thought that maintainers of Perl code
do not know Perl.

Unnecessary backslashes slow down human understanding of the code,
you must mentally un-escape them to know what the code does. Time
is money. I code so as to save as much money as possible.


> Also, it is feasable that a
> non-meta character like , say, ', will in the future be a special
> character. 


It already is meta in variable names.

Try this (with warnings enabled):

   $_ = 'something';
   my $Tad = 'Tad McClellan';
   s/$Tad's/his/g;

:-)


> I think that a generalisation of using backslash-escaping for
> non-alphanumeric characters makes a Perl program easier to interpret for
> an unexperienced user. 


Perhaps, but I don't write code for non-Perl programmers.

You could at least have Perl do the backslashing for you, so
you don't need to mentally filter them out when trying to
understand the code:


   m/\Qmatch.and+/;

rather than:

   m/match\.and\+/;


> The rule is then simple:
> - All alphanumeric characters are litterals, 


x is special, yet is not escaped.

   print 'Perl ' x 5;


> all escaped ones are special;


But they're not.

\o is escaped yet is not special.

So you have to learn all of the exceptions. Note that all of the
exceptions are the complement of what is "meta". Why not just
learn what is meta in the first place?


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


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

Date: 9 Dec 2002 10:06:17 -0600
From: fishbowl@m0x0.conservatory.com ()
Subject: Re: porting a routine which uses uint32_t
Message-Id: <3df4bf79$1_3@corp.newsgroups.com>

In article <e615828f.0212072305.55a9c25e@posting.google.com>,
Sisyphus <kalinabears@hdc.com.au> wrote:

>Might the Inline::C module be of some use here ?

Thank you for pointing out Inline::C to me.  It gave me the 
best performance of anything I've tried so far.  Next best
was using Bit::Vector. 

I wonder if there is a straighforward way to take the Inline::C
version and turn it directly into an XS lib; I imagine the runtime
performance will be the same with an improved load time.

I try to keep up with perl development and CPAN, but I still manage
to miss things like Inline::C!

I cooked up an example to help illustrate the problem I have.
I wonder if there is a way to do this purely in perl, perhaps
even without using an arithmetic procedure?  e.g., "use Magic;"

_________[ C Code Example ]____O/________________________________
                               o\
#include <sys/types.h>
#define PRIME 37
#define BUCKETS 1800
#define LIMIT 255

int h_val(void *value){

        const unsigned char *key;
        static uint32_t  h;      
        static unsigned char i=0;

        key = value;

        for (h=0, i=0; (i <= LIMIT) && *key; i++){
            h =(h * PRIME) ^ (*key++ - ' ');
        }

        return (int) (h % BUCKETS);
}

__[ perl that I think should give the same answer ]__________________________________________________________________

sub h_val {
    my $value = shift;
    my $h=0;
    map { 
        $h += (($h * $PRIME) ^ (ord($_) - 32)); 
    } split(//, $value, $LIMIT);
    return $h % $BUCKETS;
}





-----= Posted via Newsfeeds.Com, Uncensored Usenet News =-----
http://www.newsfeeds.com - The #1 Newsgroup Service in the World!
-----==  Over 80,000 Newsgroups - 16 Different Servers! =-----


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

Date: 9 Dec 2002 07:05:22 -0800
From: nathantwist@attbi.com (Colin)
Subject: Trouble with macintosh file access
Message-Id: <24fda70e.0212090705.5356c768@posting.google.com>

Hey guys. I've been working on a script that deals with renaming files
on a macintosh hard drive. I know the filename changing works (you
guys helped ;-) )
but i cant open any files. As far as i can tell, ive got the file
location syntax down, but no dice. the program doesnt error at all,
runs smooth as ever. I just dont get any results. I was wondering
whether or not this has anything to do with the way macs deal with
underscores in names ? if you were to click on a mac file on the
desktop to rename it, the underscore and everything after it
disappear. (?) Anywho, heres the code. Thanks again !

$directory = "Macintosh HD:namechange";

opendir(DIR, $directory) or die ("Directory Open Failed reading $input
- $!");
while (defined($filename = readdir(DIR)))
{  if ((-f "$directory/$filename") && ($filename =~
/^([a-z]+)_([a-z]+)\.html$/i))
   
{    
print "Renaming $filename To $2_$1.html\n";
  rename ("$filename", "$2_$1.html") or die "Rename $filename To
$2_$1.html Failed - $!";
   } }


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

Date: Mon, 9 Dec 2002 09:58:24 -0600
From: tadmc@augustmail.com (Tad McClellan)
Subject: Re: Trouble with macintosh file access
Message-Id: <slrnav9fd0.2tg.tadmc@magna.augustmail.com>

Colin <nathantwist@attbi.com> wrote:

> Hey guys. I've been working on a script that deals with renaming files
> on a macintosh hard drive.


> {  if ((-f "$directory/$filename") && ($filename =~
                        ^
                        ^

That is not the directory separator on Macs.

   use File::Spec;


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


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

Date: Mon, 09 Dec 2002 15:58:07 -0000
From: "David K. Wall" <usenet@dwall.fastmail.fm>
Subject: Re: VBA equivalent of Range in Perl
Message-Id: <Xns92DF6F945AF8Bdkwwashere@216.168.3.30>

FMAS <massion@gmx.de> wrote on 09 Dec 2002:

> I wonder if there is something similar to the range function of
> VBA in perl. 
> 
> I want first to define one or more Text range(s) in a document
> Then I want to find out if a particular string is in the range(s)
> if yes --> some action (e.g. DEL the whole range)

I don't really do VB, but I do have Visual Studio 6 here -- I take it 
you mean a Range object?  If so, and based on my cursory reading of 
the Range docs, you'll have to just read the portion of the file into 
memory and manipulate it yourself.  See

    perldoc -q file/insert 

    "How do I change one line in a file/delete a line in a 
    file/insert a line in the middle of a file/append to the
    beginning of a file?"

seek(), sysread(), and index() should be useful, as well as the 
substitution operator: s///.

-- 
David K. Wall - usenet@dwall.fastmail.fm
"Oook."


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

Date: 9 Dec 2002 16:24:59 GMT
From: Erik Braun <erik@pax07e3.mipool.uni-jena.de>
Subject: which UI for Perl?
Message-Id: <slrn4av9deb.76iv.erik@pax07e3.mipool.uni-jena.de>

I'm looking for a Perl Module, which provides interactive dialogs,
and some extensions like Radio buttons or file requestors.

I found some Modules (Dialog, Perlmenu, Cdk, Curses), but did not test 
everything, as this is a lot of work. Is someone around here, who
had the same problem and can me recommend or discourage from one 
of these?

erik


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

Date: Mon, 9 Dec 2002 10:49:34 -0500
From: "Tulan W. Hu" <twhu@lucent.com>
Subject: Re: which UI for Perl?
Message-Id: <at2e2r$3u3@netnews.proxy.lucent.com>

Have you looked Perl/Tk at http://www.perltk.org?
Tutorial at http://www.perltk.org/contrib/perltk-01/index.htm
Lots of widgets for you to use.

"Erik Braun" <erik@pax07e3.mipool.uni-jena.de> wrote in message ...
> I'm looking for a Perl Module, which provides interactive dialogs,
> and some extensions like Radio buttons or file requestors.
>
> I found some Modules (Dialog, Perlmenu, Cdk, Curses), but did not test
> everything, as this is a lot of work. Is someone around here, who
> had the same problem and can me recommend or discourage from one
> of these?
>
> erik




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

Date: 9 Dec 2002 06:14:54 -0800
From: therobs@n2net.net (Rob Richardson)
Subject: Re: Why doesn't my array grow?
Message-Id: <f79bc007.0212090614.66ceb431@posting.google.com>

"Dave Cross" <dave@dave.org.uk> wrote in message news:<pan.2002.12.09.07.56.02.188541@dave.org.uk>...
> On Sun, 08 Dec 2002 20:16:44 +0000, Rob Richardson wrote:
> 
> > I am trying to generate a calendar.
> 
> Have you looked at Calendar::Simple?
> 
> <http://search.cpan.org/dist/Calendar-Simple/>
> 
> Dave...

Dave,

Well, here's the situation, in case you're curious.  The program will
be used by the Cuyahoga Valley Scenic Railroad, for volunteers to sign
up to work on trains.  The input file is a comma-separated file
containing the month, day, year, train name, time to arrive, and
volunteers for that train.  There could be any number of trains on a
given day (although in practice, there's never more than two).  If
there are no trains for a day, there is no entry in the file for that
day.

The information on trains for a day will be held in a hash keyed by a
string containing the date, like "12.9.02".  So the calendar I'm
generating is actually a 42-element array holding either "" (for
invalid dates) or the date string.

Rob, who will go look at Calendar-Simple


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

Date: Mon, 9 Dec 2002 08:41:32 -0600
From: tadmc@augustmail.com (Tad McClellan)
Subject: Re: Why doesn't my array grow?
Message-Id: <slrnav9ass.2dl.tadmc@magna.augustmail.com>

Rob Richardson <therobs@n2net.net> wrote:

> for ($i = 0; $i < 42; $i++)

   foreach my $i ( 0 .. 41 )  # same effect, easier to understand


> 	$currentIndex = $startIndex + $i;

> 		$calendar[currentIndex] = ""


> What don't I know yet?


That you should enable warnings and strictures in your Perl programs.

   use strict;
   use warnings;


Either one would have pointed out what is wrong with your code
in *milliseconds*.


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


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