[25205] in Perl-Users-Digest

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

Perl-Users Digest, Issue: 7451 Volume: 10

daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Fri Nov 26 11:06:08 2004

Date: Fri, 26 Nov 2004 08:05:08 -0800 (PST)
From: Perl-Users Digest <Perl-Users-Request@ruby.OCE.ORST.EDU>
To: Perl-Users@ruby.OCE.ORST.EDU (Perl-Users Digest)

Perl-Users Digest           Fri, 26 Nov 2004     Volume: 10 Number: 7451

Today's topics:
    Re: [OT] Difference between XHTML and HTTP (WAS: charac <tadmc@augustmail.com>
    Re: [OT] Difference between XHTML and HTTP (WAS: charac <shawn.corey@sympatico.ca>
        changing local variable affects array values? <fatted@gmail.com>
    Re: changing local variable affects array values? <someone@example.com>
    Re: character encoding in CGI.pm chris-usenet@roaima.co.uk
        counting words in a file (wana)
    Re: counting words in a file <jwillmore@fastmail.us>
    Re: counting words in a file <bastard@uni-koblenz.de>
    Re: Dat files help "Att James" <someone@example.com>
    Re: Dat files help "Att James" <tadmc@augustmail.com>
    Re: escape whitespace in qw/ / <eon@hotmail.com>
    Re: Help:  separate difference length of spaces between (Jim Keenan)
    Re: IO object version 1.21 does not match bootstrap par (Eugene Borukhovich)
    Re: looking for a better regexp <eon@hotmail.com>
        perl script (seema)
    Re: perl script <do-not-use@invalid.net>
    Re: perl/c++ calculation (Cab Colino)
        post into hash table <bremse{usun.to}@wp.pl>
    Re: post into hash table <bastard@uni-koblenz.de>
    Re: Using embedded PERL with commercial applications? <spamcollector@sympatico.ca>
    Re: Using files to transfer data between processes <tadmc@augustmail.com>
        Digest Administrivia (Last modified: 6 Apr 01) (Perl-Users-Digest Admin)

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

Date: Fri, 26 Nov 2004 08:10:00 -0600
From: Tad McClellan <tadmc@augustmail.com>
Subject: Re: [OT] Difference between XHTML and HTTP (WAS: character encoding in CGI.pm)
Message-Id: <slrncqee9o.3mt.tadmc@magna.augustmail.com>

Shawn Corey <shawn.corey@sympatico.ca> wrote:
> Alan J. Flavell wrote:
>> By sheer chance, Google Groups pointed out to me that:
>> 
>> On Wed, 24 Nov 2004, Shawn Corey wrote:
>> 
>> [I'm trimming the comprehensive quote down to what I suppose you must 
>> have interpreted as the significant part.  There's no extra charge for 
>> doing this yourself, you know...]
> 
> [Yes, now the whole world knows what a hero you are.]


And now the whole world knows what an inconsiderate type of 
poster you are. You shift work from yourself to others.


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


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

Date: Fri, 26 Nov 2004 07:08:09 -0500
From: Shawn Corey <shawn.corey@sympatico.ca>
Subject: Re: [OT] Difference between XHTML and HTTP (WAS: character encoding in CGI.pm)
Message-Id: <A0Fpd.52178$Ro.2133284@news20.bellglobal.com>

Alan J. Flavell wrote:
> By sheer chance, Google Groups pointed out to me that:
> 
> On Wed, 24 Nov 2004, Shawn Corey wrote:
> 
> [I'm trimming the comprehensive quote down to what I suppose you must 
> have interpreted as the significant part.  There's no extra charge for 
> doing this yourself, you know...]

[Yes, now the whole world knows what a hero you are.]

> A truly remarkable castle that you've built in the air there; have you 
> read XHTML/1.0 Appendix C, by any chance?

Please explain what XHTML/1.0 Appendix C has to do with HTTP.

    --- Shawn


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

Date: Fri, 26 Nov 2004 14:45:08 +0100
From: fatted <fatted@gmail.com>
Subject: changing local variable affects array values?
Message-Id: <pan.2004.11.26.13.45.06.568651@gmail.com>

Can someone explain this to me please? 

use strict;
use warnings;

my @array = ( "one", "two", "three", "four", "fi_ve");

foreach my $value (@array)
{
        $value =~ s/_/ /g;
        print @array;
        print "\n";
}
------
Results in:

onetwothreefourfi_ve
onetwothreefourfi_ve
onetwothreefourfi_ve
onetwothreefourfi_ve
onetwothreefourfi ve

But:
------
use strict;
use warnings;

my @array = ( "one", "two", "three", "four", "fi_ve");

foreach (@array)
{
        my $value = $_;
        $value =~ s/_/ /g;
        print @array;
        print "\n";
}
-------
Gives:

onetwothreefourfi_ve
onetwothreefourfi_ve
onetwothreefourfi_ve
onetwothreefourfi_ve
onetwothreefourfi_ve

(Note _ on last line of this result set compared to previous).



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

Date: Fri, 26 Nov 2004 13:55:22 GMT
From: "John W. Krahn" <someone@example.com>
Subject: Re: changing local variable affects array values?
Message-Id: <eBGpd.191727$df2.144467@edtnps89>

fatted wrote:
> Can someone explain this to me please? 

[ snipped foreach examples ]

Yes, the documentation supplied with perl can.

perldoc perlsyn
[snip]
        Compound Statements

        In Perl, a sequence of statements that defines a scope is called a
        block.  Sometimes a block is delimited by the file containing it (in
        the case of a required file, or the program as a whole), and sometimes
        a block is delimited by the extent of a string (in the case of an
        eval).

        But generally, a block is delimited by curly brackets, also known as
        braces.  We will call this syntactic construct a BLOCK.

        The following compound statements may be used to control flow:

            if (EXPR) BLOCK
            if (EXPR) BLOCK else BLOCK
            if (EXPR) BLOCK elsif (EXPR) BLOCK ... else BLOCK
            LABEL while (EXPR) BLOCK
            LABEL while (EXPR) BLOCK continue BLOCK
            LABEL for (EXPR; EXPR; EXPR) BLOCK
            LABEL foreach VAR (LIST) BLOCK
            LABEL foreach VAR (LIST) BLOCK continue BLOCK
            LABEL BLOCK continue BLOCK

[snip]

        Foreach Loops

        The "foreach" loop iterates over a normal list value and sets the
        variable VAR to be each element of the list in turn.  If the variable
        is preceded with the keyword "my", then it is lexically scoped, and is
        therefore visible only within the loop.  Otherwise, the variable is
        implicitly local to the loop and regains its former value upon exiting
        the loop.  If the variable was previously declared with "my", it uses
        that variable instead of the global one, but it's still localized to
        the loop.  This implicit localisation occurs only in a "foreach" loop.

        The "foreach" keyword is actually a synonym for the "for" keyword, so
        you can use "foreach" for readability or "for" for brevity.  (Or
        because the Bourne shell is more familiar to you than csh, so writing
        "for" comes more naturally.)  If VAR is omitted, $_ is set to each
        value.

        If any element of LIST is an lvalue, you can modify it by modifying VAR
        ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
        inside the loop.  Conversely, if any element of LIST is NOT an lvalue,
        ^^^^^^^^^^^^^^^
        any attempt to modify that element will fail.  In other words, the
                                                       ^^^^^^^^^^^^^^^^^^^
        "foreach" loop index variable is an implicit alias for each item in the
        ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
        list that you're looping over.
        ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^



John
-- 
use Perl;
program
fulfillment


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

Date: Fri, 26 Nov 2004 13:29:34 +0000
From: chris-usenet@roaima.co.uk
Subject: Re: character encoding in CGI.pm
Message-Id: <umnj72-cer.ln1@moldev.cmagroup.co.uk>

Alan J. Flavell <flavell@ph.gla.ac.uk> wrote:
> Oh dear, does it really?  Can we have a CGI.pm version number on that 
> please?

Perl 5.6.1. CGI 2.752

It's been fixed by 5.8.4 (CGI 3.04)
Chris


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

Date: 26 Nov 2004 06:27:24 -0800
From: ioneabu@yahoo.com (wana)
Subject: counting words in a file
Message-Id: <bf0b47ca.0411260627.763f0888@posting.google.com>

This morning, I wrote a little script to count words in a file.  I did
this one on my pda, which happened to have 'Moby Dick' saved on the
storage card.  Writing Perl scripts on the pda is a little like
playing video games...  I wanted to print to a file the list of words
and the number of occurrence in descending order of occurrence.  The
following seemed to work, although I initially did my counting loops
wrong and only counted the first occurrence per line.  I was wondering
if I got it right and if there is a better way to do it.  'Programming
Perl' mentions the Schwartzian map-sort-map technique which I thought
might apply.  Also, the loop that does the counting below; I tried it
this way:

$words{lc $1}++ while /(\w+)/gi for (<INF>);

but it did not work.


#!/usr/bin/perl

use strict;
my $fn = "/textucation/moby10b.txt";
open (INF, $fn) or die "error: $!";
my %words;
for (<INF>)
{
    $words{lc $1}++ while /(\w+)/gi;
}
my @n = %words;
@n = reverse @n;
%words = @n;
my @k = keys %words;
sub num {$b <=> $a}
@k = sort num @k;
open (OUTF, ">file count.txt") or die "error: $!";
print OUTF "$_  $words{$_}\r\n" for (@k);

thanks!

wana


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

Date: Fri, 26 Nov 2004 10:10:52 -0500
From: James Willmore <jwillmore@fastmail.us>
Subject: Re: counting words in a file
Message-Id: <pan.2004.11.26.15.10.50.509345@fastmail.us>

On Fri, 26 Nov 2004 06:27:24 -0800, wana wrote:

> This morning, I wrote a little script to count words in a file.  I did
> this one on my pda, which happened to have 'Moby Dick' saved on the
> storage card.  Writing Perl scripts on the pda is a little like
> playing video games...  I wanted to print to a file the list of words
> and the number of occurrence in descending order of occurrence.  The
> following seemed to work, although I initially did my counting loops
> wrong and only counted the first occurrence per line.  I was wondering
> if I got it right and if there is a better way to do it.  'Programming
> Perl' mentions the Schwartzian map-sort-map technique which I thought
> might apply.  Also, the loop that does the counting below; I tried it
> this way:
> 
> $words{lc $1}++ while /(\w+)/gi for (<INF>);
> 
> but it did not work.
> 
> 
> #!/usr/bin/perl
> 
> use strict;
> my $fn = "/textucation/moby10b.txt";
> open (INF, $fn) or die "error: $!";
> my %words;
> for (<INF>)
> {
>     $words{lc $1}++ while /(\w+)/gi;
> }
> my @n = %words;
> @n = reverse @n;
> %words = @n;
> my @k = keys %words;
> sub num {$b <=> $a}
> @k = sort num @k;
> open (OUTF, ">file count.txt") or die "error: $!";
> print OUTF "$_  $words{$_}\r\n" for (@k);

I put a little something together :-)

=begin
#!/usr/bin/perl

use strict;
use warnings;

my $infile = 'words_in.txt';
my $outfile = 'words_out.txt';
my %words;

open IN, $infile 
    or die "Can't open $infile for reading: $!\n";

while(<IN>) {
    #get rid of newlines
    chomp;
    #change all non-words into spaces
    s/\W/ /g;
    #split on whitespace and place the results into an array
    my @line = split;
    #place each lowercase word from @line as a key into hash %words
    #increment the count for the key
    $words{lc $_}++ for(@line);
    # ... or, you could do ... and get rid of the above 2 steps
    #$words{lc $_}++ for( split );
}

close IN;

open OUT, '+>', $outfile
    or die "Can't open $outfile for writing: $!\n";

my $total = 0;
#sort, then reverse each key in %words
for(reverse sort keys %words) {
    print OUT "$_: $words{$_}\n";
    #increment total word count
    $total += $words{$_};
}

print OUT "total: $total\n";

close OUT;
=cut

HTH

Jim


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

Date: Fri, 26 Nov 2004 17:34:16 +0100
From: Dimitri Papoutsis <bastard@uni-koblenz.de>
Subject: Re: counting words in a file
Message-Id: <co7jfc$m3r$1@news.uni-koblenz.de>

Hello,

I didn't test it, and maybe it isn't the most efficient solution...
So what about:

        while(<IN>){
                chomp;
                s/\W/ /g;
                $file.=' '.$_;
        }

        @words=split(/\s+/,$file);
        $wordCount=@words;

Wouldn't it work ?
;o)

bye
dnp


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

Date: Fri, 26 Nov 2004 13:42:01 GMT
From: "John W. Krahn" <someone@example.com>
Subject: Re: Dat files help "Att James"
Message-Id: <JoGpd.191722$df2.125726@edtnps89>

hope@hope.com wrote:
> On Thu, 25 Nov 2004 19:02:29 -0600, Tad McClellan <tadmc@augustmail.com> wrote:
> 
>>hope@hope.com <hope@hope.com> wrote:
>>
>>>So the director where my dat files are in WinXp pro are
>>>c:\1\35 
>> ^^
>> ^^
>>
>>>So I put
>>> my  $dir = '/1/35';
>>>But that did not work  
>>
>>How come you didn't put the "c:" part in there?
>>
>>  my  $dir = 'c:/1/35';
> 
> Oh my god this just gets worse as it goes along
> 
> I went and did a search for paths in perl for windows and apache
> 
> at this site 
> http://perlmonks.thepen.com/110030.html
> 
> In Perl you can generally just use a / as your path separator (except
> on Mac OS 9, thanks Hanamaki). Why? Because Perl will automagically
> convert the / to the correct path separator for the system it is running
> on!

Perl does not convert / to \ on DOS/Windows.  The operating system itself is 
able to handle paths with slashes.  The command interpreter command.com 
however must use backslashes in paths.  (I don't know about cmd.exe)


> This means that coding Windows paths like this
> 
> $path = "\\foo\\bar\\baz";
> 
> is not required. You can just use this:
> 
> $path = "/foo/bar/baz";
> 
> so that is why I left out the c:

If the default drive is not C: then that drive will be used.  So if your 
program is currently on drive F: then "/foo/bar/baz" will become "f:/foo/bar/baz"



John
-- 
use Perl;
program
fulfillment


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

Date: Fri, 26 Nov 2004 09:09:44 -0600
From: Tad McClellan <tadmc@augustmail.com>
Subject: Re: Dat files help "Att James"
Message-Id: <slrncqehpn.3mt.tadmc@magna.augustmail.com>


[ Please learn the proper way to compose a followup very soon.

  You have the interleaving part down, that's good. Now add:

  1) trim the quoted text to just enough to establish the context
     for the comment that you are going to add.

  2) limit your line lengths to the conventional 70-72 characters.
     (you can probably set your newsreader to handle this for you)

  Thank you.
]


hope@hope.com <hope@hope.com> wrote:
> On Thu, 25 Nov 2004 19:02:29 -0600, Tad McClellan <tadmc@augustmail.com> wrote:
>>hope@hope.com <hope@hope.com> wrote:
>>> On Thu, 25 Nov 2004 13:46:28 -0600, Tad McClellan <tadmc@augustmail.com> wrote:
>>>>hope@hope.com <hope@hope.com> wrote:
>>>>> On Wed, 24 Nov 2004 14:26:58 -0800, Jim Gibson <jgibson@mail.arc.nasa.gov> wrote:
>>>>>>In article <h2r9q0lpmkd35tc7g1qkhbtova6gcm4lbg@4ax.com>,
>>>>>><hope@hope.com> wrote:
>>>>
>>>>
>>>>>>> use CGI:: Carp dw(fatelsToBrowser)

>>>>> I see the  mistakes now it should be
>>>>>>> use CGI ::Carp qw<fatelsToBrowser>;


>>You have misspelled something there, even after being told that
>>you have misspelled something there.
> 
> Ok take your point,  Have you looked at something time and time 
> again and cannot spot the mistake ? 


Yes. Many (too many) times.


> well that is what happened to me


No it isn't.

While _I_ could look at and not see it, a machine will surely see
it the very first time.

Perl spews error messages for that misspelling.

I think what really happened to you is that you ran your program
in a CGI environment where the error messages end up in your
server's error log.

Have you been looking in there?


   
It is best to get the program working *from the command line*
before moving it into a CGI environment.

Do you have command line access either on your web server or on
your computer at home/work?


>>>>>     read $fh, my $data, -s $fh;
>>>>>     my @fields = split /\n/, $data;
>>
>>
>>That is a mighty strange way of reading in the data...
>>
>>   chomp( my @fields = <$fh> );  # does the same thing, no temp variable
> 
> Hmmmm so in other words like you said up above bad code


I'd call it "bad" code, "bad" here means "could be done better" 
rather than "does bad things".

But what I was referring to earlier was "malicious" code, a 
much much worse type of thing.



>>> So the director where my dat files are in WinXp pro are
>>> c:\1\35 
>>  ^^
>>  ^^
>>> So I put
>>>  my  $dir = '/1/35';
>>> But that did not work  
>>
>>
>>How come you didn't put the "c:" part in there?
>>
>>   my  $dir = 'c:/1/35';
> 
> 
> Oh my god this just gets worse as it goes along


No, it gets better as it goes along.

If you had to remember to leave out part of the path, *that*
would be worse.

It is nice to not have to remember stuff, however you specify a
path in your filesystem, that is how you use it in Perl.

Consistent is a Good Thing.


> I went and did a search for paths in perl for windows and apache
> 
> at this site 
> http://perlmonks.thepen.com/110030.html


Thanks for including the reference.


> In Perl you can generally just use a / as your path separator 
> (except on Mac OS 9, thanks Hanamaki). Why? Because Perl will 
> automagically convert the / to the correct path
> separator for the system it is running on! This means that 
> coding Windows paths like this
> 
> $path = "\\foo\\bar\\baz";
> 
> is not required. You can just use this:
> 
> $path = "/foo/bar/baz";
> 
> 
> so that is why I left out the c:


I see 2 problems with the top article there:

1) foo\bar\baz    # Win32 uses a \

   should have been:
   foo\bar\baz    # Win32 uses a \
   foo/bar/baz    # or a / if the path is not destined for the command line

forward /slashes/ work fine in Windows filesystems, it is only
the command interpreter (COMMAND.COM) that requires the use
of \backslashes\ (because it is using /slashes/ for something else).

Try using /slashes/ in a path in any GUI Windows application (which will
open the file without the command interpreter's involvement). It ought
to work just fine.



2) Windows paths like this $path = "\\foo\\bar\\baz";

   should have been:
   Windows paths like this $path = "C:\\foo\\bar\\baz"

The author specifically said "Windows paths", but did not provide
an example that looks like a Windows path.

AFAIK, the drive letter is always required for absolute paths
on Windows filesystems.

Probably what happened there is that the author is a Unix-type
(as are most (many?) Perl programmers of significant experience)
and unconsciously used a Unixy type of path.

If he had used a "relative path" rather than an "absolute path", eg:

   $path = "My Documents/My Novel.doc"

he could have gotten away with leaving out the drive letter.  :-)


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


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

Date: Fri, 26 Nov 2004 14:09:18 GMT
From: "Leon" <eon@hotmail.com>
Subject: Re: escape whitespace in qw/ /
Message-Id: <iOGpd.510$_p5.381@newsfe1-gui.ntli.net>

"chris" <nadsinoz@hotmail.com> wrote in message
news:b8996f29.0411250741.66020368@posting.google.com...
> I have a whitespace separated list where some of the fields actually
> should have a extra whitespace character.  Is there a way I can escape
> this space so I can use qw// to create the list:
>
> @list = qw/ 1.0 UK  Y 2.5 /;
>
> where UK is actually 'UK ' (without the quotes).

@list = ('1.0', 'UK ', 'Y', '2.5');

>
> Is this possible?
>
> Thanks in advance...




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

Date: 26 Nov 2004 07:23:59 -0800
From: jkeen_via_google@yahoo.com (Jim Keenan)
Subject: Re: Help:  separate difference length of spaces between words
Message-Id: <196cb7af.0411260723.2f0d0339@posting.google.com>

Michele Dondi <bik.mido@tiscalinet.it> wrote in message news:<27ccq0dthif284vnfk3q1ka5teclosp29l@4ax.com>...
> On Thu, 25 Nov 2004 03:34:08 GMT, Jim Keenan
> <jkeen_via_google@yahoo.com> wrote:
> 
> ># rough code: untested
> >my (@data);
> 
> Why not
> 
>   my @data;
> 

[snip further refinements ]

> 
I was at work when responding to the OP and only had a few minutes to
dash off a response -- didn't even have time to test it, which I
almost always do before posting to this list.

If I had had more time, I would have refined the response as you and
subsequent posters did.  But my first inclination was to give the OP
something that spelled everything out.

Jim Keenan


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

Date: 26 Nov 2004 06:11:42 -0800
From: macroscape@yahoo.com (Eugene Borukhovich)
Subject: Re: IO object version 1.21 does not match bootstrap parameter 1.18
Message-Id: <41df378d.0411260611.3a57d14f@posting.google.com>

Sherm Pendley <spamtrap@dot-app.org> wrote in message news:<47idnT03TqnQVT_cRVn-1w@adelphia.com>...
> Eugene Borukhovich wrote:
> 
> > I have compiled form scratch some modules for ex Net::Ping and for
> > some reason can not use them.
> 
> How did you compile them? Did you use the *full* standard procedure, up 
> to and including the "make install"? Any special options or flags?

Yep the full boat perl Makefile.PL;make;make install. I dont have
problems with the default modules that came with Perl, only the newly
compiled ones - maybe should start using CPAN shell - but I think I
would get into he same boat anyhow

> > IO object version 1.21 does not match bootstrap parameter 1.18 at
> > /usr/lib/perl5/5.8.3/i386-linux-thread-multi/DynaLoader.pm line 249.
> 
> The IO module has two separate pieces, a compiled C component that's in 
> a .so file, and a Perl component that's in a .pm file. This error 
> indicates that the version number reported by these two pieces does not 
> match.
> 
> This is generally the result of an incorrectly installed module, which 
> is why I asked above how you installed it.
> 
> > I actually thought to upgrade the DynaLoader
> 
> That's absurd. The error message clearly states what module - IO - is 
> misconfigured.

So why is DynaLoader referenced? I fond that those IO messages are
misleading since at he end it actually lists the module that is
conflicting...

> sherm--


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

Date: Fri, 26 Nov 2004 13:57:35 GMT
From: "Leon" <eon@hotmail.com>
Subject: Re: looking for a better regexp
Message-Id: <jDGpd.485$_p5.13@newsfe1-gui.ntli.net>


"mike" <s99999999s2003@yahoo.com> wrote in message
news:dfd17ef4.0411251735.1b16a9d1@posting.google.com...
> hi folks
>
> i have to strip a line of empty spaces/tabs before and after a comma
> eg word1,  word2  ,word3,word4<tab>,word5
> i have to make it become word1,word2,word3,word4,word5
>
> so far i have tried
> $line =~ s/^\s+//;      #get rid of spaces in the beginining of the line
> $line =~ s/^\t+//;      #get rid of tabs in the beginning of the line
> $line =~ s/\s+,/,/g ;   #get rid of spaces before a comma
> $line =~ s/,\s+/,/g;    #get rid of spaces after a comma
> $line =~ s/\t+,/,/g;    #get rid of tables before comma
> $line =~ s/,\t+/,/g;    #get rid of tabs after comma
>
> i may have the line also containing eg
> word1,  word2  <2 tabs>  ,word3,word4<1 tab><space><space>,word5
> or other combinations of spaces/tabs .
>
> Is there a better way to do the regexp? I just need the output to be
> word1,word2,word3,word4,word5
>
> thanks for any help

The following will get rid of all \t and whitespaces (note : there is a
space (" ") immediately after the square bracketed \t ).

$line =~ s/[\t ]//g;

This will return correctly for above examples, but assume there are no
whitespaces within "word1", "word2", etc..

Hope this is of some help.





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

Date: 26 Nov 2004 07:24:42 -0800
From: seema_coma@yahoo.co.in (seema)
Subject: perl script
Message-Id: <e87f4591.0411260724.56262325@posting.google.com>

Is it possible to write a script in perl
that searches functions in all the *.h
files in the Linux box and write the output
to a file. Assume we will store the required 
functions in hash tables and use this hash table 
in our script.
seema


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

Date: 26 Nov 2004 16:32:11 +0100
From: Arndt Jonasson <do-not-use@invalid.net>
Subject: Re: perl script
Message-Id: <yzdsm6wsk1w.fsf@invalid.net>


seema_coma@yahoo.co.in (seema) writes:
> Is it possible to write a script in perl
> that searches functions in all the *.h
> files in the Linux box and write the output
> to a file. Assume we will store the required 
> functions in hash tables and use this hash table 
> in our script.

I haven't used it, but it seems the CPAN module C-Scan might be
useful. See www.cpan.org.
Whether you use hash tables is up to you, but it seems a reasonable
choice. (Actually, that last sentence makes the query sound like
a homework problem. Is it?)

The short answer if of course "yes, it's possible". It's not likely
to impress a teacher, though.


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

Date: 26 Nov 2004 03:18:16 -0800
From: fidel@mongobaer.de (Cab Colino)
Subject: Re: perl/c++ calculation
Message-Id: <4d9da5e7.0411260318.20b4d77@posting.google.com>

yeah, your right thanks.

>> a good habit to only paste code that you actually ran...
i've tried to simplfy the code, and i was sure that the
array isnt the problem.

thanks a lot

cab

Arndt Jonasson <do-not-use@invalid.net> wrote in message news:<yzdmzx66nn9.fsf@invalid.net>...
 ...


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

Date: Fri, 26 Nov 2004 14:53:17 +0000
From: Bremse <bremse{usun.to}@wp.pl>
Subject: post into hash table
Message-Id: <pegeq0lj9qjqj42a9iq7i2rqkn03rsdf5o@4ax.com>

I'm trying to put values (from form) posted by post method into hash
table, but all entries after code execution are empty (i.e.
$FORM_DATA{$forename} equals ""). Why?


read(STDIN,$query,$ENV{'CONTENT_LENGTH'});
@kv_pairs = split(/\&/, $query);
foreach $key_value (@kv_pairs)
	{
		($key, $value) = split ( /\=/, $key_value);
		$value =~ tr/+/ /;
		$value =~ s/%([\dA-Fa-f][\dA-Fa-f])/chr(hex($1))/eg;
		$FORM_DATA{$key} = $value;
	}

What's wrong?

-- 
Bremse


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

Date: Fri, 26 Nov 2004 17:45:50 +0100
From: Dimitri Papoutsis <bastard@uni-koblenz.de>
Subject: Re: post into hash table
Message-Id: <co7k51$m3r$2@news.uni-koblenz.de>

Bremse wrote:

> I'm trying to put values (from form) posted by post method into hash
> table, but all entries after code execution are empty (i.e.
> $FORM_DATA{$forename} equals ""). Why?
> 
> 
> read(STDIN,$query,$ENV{'CONTENT_LENGTH'});
> @kv_pairs = split(/\&/, $query);
> foreach $key_value (@kv_pairs)
> {
> ($key, $value) = split ( /\=/, $key_value);
> $value =~ tr/+/ /;
> $value =~ s/%([\dA-Fa-f][\dA-Fa-f])/chr(hex($1))/eg;
> $FORM_DATA{$key} = $value;
> }
> 
> What's wrong?
> 

Try this:
Just copy and use it...

sub getFormularFields{
        if($ENV{'REQUEST_METHOD'} eq 'GET'){
                $Data = $ENV{'QUERY_STRING'}
                }
        else{
                read(STDIN, $Data, $ENV{'CONTENT_LENGTH'});
        }


        my @FormularFields = split(/&/, $Daten);
        foreach my $Field (@FormularFields)  
         {
          ($name, $value) = split(/=/, $Field);   
          $value =~ tr/+/ /;
          $value =~ s/%([a-fA-F0-9][a-fA-F0-9])/pack("C", hex($1))/eg;
          $value =~ s/<!--(.|\n)*-->//g;      
          ${$name} = $value;   
          $Formular{$name}=$value;
         }
        return %Formular;
}

bye 
dnp


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

Date: Fri, 26 Nov 2004 08:55:15 -0500
From: Spam <spamcollector@sympatico.ca>
Subject: Re: Using embedded PERL with commercial applications?
Message-Id: <pan.2004.11.26.13.55.14.595963@sympatico.ca>

Why could not someone embed a lex/yacc based perl interpreter or compiler
in an application?

Perl syntax is not rocket science.



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

Date: Fri, 26 Nov 2004 09:11:56 -0600
From: Tad McClellan <tadmc@augustmail.com>
Subject: Re: Using files to transfer data between processes
Message-Id: <slrncqehts.3mt.tadmc@magna.augustmail.com>

Villy Kruse <vek@station02.ohout.pharmapartners.nl> wrote:
> On 26 Nov 2004 08:07:09 GMT,
>     Anno Siegel <anno4000@lublin.zrz.tu-berlin.de> wrote:
> 
> 
>>> There is a perl document called perlipc dedicated to this subject so
>>> that seems a fair place to start.  mandoc perlipc is supposed to give
>>
>> s/mandoc/perldoc/
>>
> 
> That would help quite a lot.


on many systems, this would help just as much:

   s/mandoc/man/


-- 
    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.  

NOTE: due to the current flood of worm email banging on ruby, the smtp
server on ruby has been shut off until further notice. 

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


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