[17530] in Perl-Users-Digest

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

Perl-Users Digest, Issue: 4950 Volume: 9

daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Wed Nov 22 14:05:44 2000

Date: Wed, 22 Nov 2000 11:05:18 -0800 (PST)
From: Perl-Users Digest <Perl-Users-Request@ruby.OCE.ORST.EDU>
To: Perl-Users@ruby.OCE.ORST.EDU (Perl-Users Digest)
Message-Id: <974919917-v9-i4950@ruby.oce.orst.edu>
Content-Type: text

Perl-Users Digest           Wed, 22 Nov 2000     Volume: 9 Number: 4950

Today's topics:
    Re: (newB): What would cause line 1 fail? <mischief@velma.motion.net>
    Re: Binding Variables and DBI <jeff@vpservices.com>
    Re: CGI in a table nobull@mail.com
    Re: default perl to execute in current dir ? dtbaker_dejanews@my-deja.com
    Re: disk free (IGuthrie)
        GET FREE BUCKS! <do@nothing.eh>
    Re: Help: multiple DB files, regular expressions, and s (CloneTwo)
        how do I merge blocks of text from different lines? <-@-.com>
    Re: how do I merge blocks of text from different lines? <wells@cedarnet.org>
    Re: how do I merge blocks of text from different lines? nobull@mail.com
        How to Install Crypt::SSLeay on Remote Host? horace700@my-deja.com
    Re: How to output query row-by-row to HTML <michael.segulja@sgi-lsi.com>
    Re: How to output query row-by-row to HTML <tward10@jaguar.com>
        I need to create proegrma like iescrow.com <dario@kateka.lt>
    Re: looking for PERL GUI debugger for UNIX (Chris Fedde)
    Re: looking for PERL GUI debugger for UNIX <mischief@velma.motion.net>
    Re: Need help with file splitting (Rafael Garcia-Suarez)
    Re: Need help with file splitting (Garry Williams)
        New Perl-IDE available <PCXsoft@intag.de>
        newbie pipe question satkinson@skydesk.com
    Re: newbie pipe question nobull@mail.com
    Re: perl version of html tag nobull@mail.com
        Perl XS <soumen.das@cp.net>
    Re: permissions issue...i think nobull@mail.com
        Problem r/w binary files toby_m_kramer@my-deja.com
    Re: Problem r/w binary files nobull@mail.com
        Problem reading/writing binary file toby_m_kramer@hotmail.com
    Re: Problem reading/writing binary file <Petri_member@newsguy.com>
    Re: Problem with simple del file script jkipp@mbna.com
        Digest Administrivia (Last modified: 16 Sep 99) (Perl-Users-Digest Admin)

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

Date: Wed, 22 Nov 2000 16:13:38 -0000
From: Chris Stith <mischief@velma.motion.net>
Subject: Re: (newB): What would cause line 1 fail?
Message-Id: <t1ns5ijg89q568@corp.supernews.com>

nobull@mail.com wrote:
> earlie <earlie@my-deja.com> writes:

>> I am running a file that says only:
>> #! usr/bin/perl -wcT

This does nothing. It normally tells Unix what program to use
as an interpreter. On NT Perl will read its options from here,
but it has already started and didn't start with Taint mode.
Since Perl needs to know it is to start with Taint mode before
it actually starts, it gives the error "Too late for -T". Hence
the explanation, terse but entirely accurate, from nobull.
 
>> and I get the following:
>> The specified CGI application misbehaved by not returning a complete set
>> of HTTP headers. The headers it did return are:

The above error message is something apart from Perl's Taint mode
error message. It means that your script didn't return a full set
of HTTP headers. That says what it means. If you're going to run
a program as CGI, you need for the program to behave as CGI. You
need to remember that CGI is as CGI does. There's no magic switch
to make a program in Perl or in any other language behave as a
CGI-capable program.

Any CGI (this is a FAQ, BTW, and isn't a Perl issue) needs to return
HTTP headers according to the HTTP specifications. An HTTP header
contains some formatted text and then a newline. The last HTTP header
before the content needs a double newline - equivalent to a blank
line between the headers and the content, just like an email message.
The actual headers you can find in any reference for HTTP or CGI.
The only one most of my scripts carry is "Content-type: text/html\n\n".

I'm not certain if the CGI error listed above is in the Perl FAQ in
the standard docs, but i am certain it is a FAQ for this newsgroup.

>> Too late for "-T"

Follow nobull's advice here. `perldiag' is a useful resource, and
one which probably answers more quickly than the newsgroup.

> Perl error messages are explained in the "perldiag" manual.  This
> error is no exception.

>> This is on winNT

> That's no excuse for not reading the manuals.  NT doesn't understand
> #! so whatever application is calling perl.exe is going to have to
> start it with the -T switch.

Like I said before, although this explanation is terse, it's entirely
accurate.


Happy Thanksgiving tomorrow, my fellow Americans. The rest of you have
a wonderful day as well.

Chris
--
Christopher E. Stith
Motion Internet
mischief@motion.net

"The rest of the world watches our TV news and thinks we're all
backwoods rubes," Mark said. (Mark is my friend and coworker.)
"I'd say that's pretty accurate," I replied. Here's to being from
the most powerful country in the modern world, run almost entirely
by and for backwoods rubes. ;)



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

Date: Wed, 22 Nov 2000 08:57:50 -0800
From: Jeff Zucker <jeff@vpservices.com>
Subject: Re: Binding Variables and DBI
Message-Id: <3A1BFB0E.9AB05D2C@vpservices.com>

Honza Pazdziora wrote:
> 
>         $dbh->do('begin procedure_name(?, ?, ?); end;', {},
>                 @param_array);
> 
> but make sure the array really has three elements or you get
> an error.

Or, to make it totally generic and not have to care about how many
elements there are in the arrray (as long as some other part of the
script knows how many columns can be used for that particular database
and procedure):

  my $param_str = (join ',', ('?') x scalar @param_array);
  my $sql       = qq/BEGIN PROCEDURE_NAME ($param_str); end;/    
  $dbh->do( $sql, {}, @param_array);

-- 
Jeff


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

Date: 22 Nov 2000 18:03:30 +0000
From: nobull@mail.com
Subject: Re: CGI in a table
Message-Id: <u9lmubrij1.fsf@wcl-l.bham.ac.uk>

"Jim" <jaedma@yahoo.com> writes:

> I have a perl cgi script (a clock) that I want to put into a table in an
> html page. I cant figure out what code to put the table cell (img...embed
> ect).

What you need in HTML to embed one document in another is idependant
of what language you used to write the program that generated the
embeded document.  Check newsgroups/manuals/websites that deal with HTML.

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


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

Date: Wed, 22 Nov 2000 18:54:08 GMT
From: dtbaker_dejanews@my-deja.com
Subject: Re: default perl to execute in current dir ?
Message-Id: <8vh4of$32o$1@nnrp1.deja.com>

In article <slrn91mee4.u4i.tim@degree.ath.cx>,
  tim@degree.ath.cx (Tim Hammerquist) wrote:
> Honza Pazdziora <adelton@fi.muni.cz> wrote:
> > dtbaker_dejanews@my-deja.com <dtbaker_dejanews@my-deja.com> wrote:
> > > I am having trouble tracking down the difference in the install or
> > > configuration of either windows or perl between two windows 98
PCs. One
> > > one PC, perl scripts execute with the working directory set to the
dir
> > > where the script is, and on the other, it defaults to /usr/bin
where
> > > perl.exe is installed.
>
> We need more details.  Is Perl in the same place?  Is it the same
build
> of Perl?  How are the scripts being executed?
------------------

is is the exact same version of ActivePerl on both machines. Scripts
execute the same with via my webserver (xitami), but the difference is
when I execute in the windows explorer with a double-click.

I have examined the file association closely, and dont see a difference
between the machines. Both are configured to recognize the .pl extension
and open with:

C:\usr\bin\Perl.exe "%1" %*


any more ideas?

Dan


Sent via Deja.com http://www.deja.com/
Before you buy.


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

Date: 22 Nov 2000 16:56:58 GMT
From: iguthrie@aol.com (IGuthrie)
Subject: Re: disk free
Message-Id: <20001122115658.28261.00002108@ng-md1.aol.com>

>
>>It does not work with NFS under Linux.  At least not with the NFS 
>>module/daemon provided with RedHat 6.2 or Slackware 7.1.
>
>If you can send me the ouput of a statvfs() call on an NFS filesystem under
>RH
>6.2 I can try to make the module compatible. Right now I dont have a Linux
>system avaliable so I cant get the output myself.

I was able to test the module and it didnt work with RH 6.2 NFS Filesystems. I
found the problem and fixed it. There will be a new version on CPAN 0.65 you
can try out. I would be very interested in finding out if this fixes your
problem.

Thanks,
Ian


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

Date: Wed, 22 Nov 2000 20:17:02 +0300 (MSK)
From: "FREE Bucks" <do@nothing.eh>
Subject: GET FREE BUCKS!
Message-Id: <Earn_free@bucks>

Are you SMART programmer?

If (TRUE)  goto {

http://www.dreamwater.com/tech/salesgiant/smarty2001.html
                }
and get your EXTRA fee

You are also welcome at:

http://www.dreamwater.com/tech/salesgiant/team2000.html

=========================
Being smart is being rich!



















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

Date: 22 Nov 2000 16:12:31 GMT
From: clonetwo@aol.com (CloneTwo)
Subject: Re: Help: multiple DB files, regular expressions, and substitutions 
Message-Id: <20001122111231.02020.00002417@ng-ch1.aol.com>

Hi all,

I thank you all for the help so far. As it was pointed out, I forgot to give
the details of the database files. The olddbfile (and the 'booklink' file) has
the following tab separated fields for each book:

isbn  subject  author  title  publisher  price  binding  store  link 

That is a total of nine fields. The newDBfile is missing the store and link
fields, giving it a total of seven fields. Each file uses different
abbreviations for subject, publisher,etc. The only field that is consistent
between all files is the isbn number.  

I also forgot to mention that I am using the Macperl application for MacOS and
I don't have access to a command line.

Is it possible to solve the problem using hash tables when there a so many
fields, or is there a better way to do resolve this? 



Thanks,

Toni


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

Date: Wed, 22 Nov 2000 17:01:42 -0800
From: "Mauro" <-@-.com>
Subject: how do I merge blocks of text from different lines?
Message-Id: <8vgqjl$rqj$1@nslave3.tin.it>

________input is____
[1]|some text
[2]|I've an apple
[3]|I eat the apple

separatortag

1. HALLO
2. HI
3. FOOBAR

_______output must be_____
HALLO|some text
HI|I've an apple
FOOBAR|I eat the apple

do you know the way to do that?

Mauro




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

Date: Wed, 22 Nov 2000 11:12:11 -0600
From: Stephen Wells <wells@cedarnet.org>
Subject: Re: how do I merge blocks of text from different lines?
Message-Id: <3A1BFE6B.853ECB54@cedarnet.org>

Mauro wrote:
> 
> ________input is____
> [1]|some text
> [2]|I've an apple
> [3]|I eat the apple
> 
> separatortag
> 
> 1. HALLO
> 2. HI
> 3. FOOBAR
> 
> _______output must be_____
> HALLO|some text
> HI|I've an apple
> FOOBAR|I eat the apple
> 
> do you know the way to do that?
> 
> Mauro

here's one way:

----------------
#!perl -w
use strict;

my %lines1;
my %lines2;
while (<DATA>) {
       chomp;
       $lines1{$1} = $2 if /^\[(\d+)\]\|(.*)/;
       $lines2{$1} = $2 if /^(\d+)\.\s(.*)/;
}

print $lines2{$_}, "|", $lines1{$_}, "\n"
    foreach (sort {$a<=>$b} keys %lines2);

__DATA__
[1]|some text
[2]|I've an apple
[3]|I eat the apple
 
 separatortag
 
1. HALLO
2. HI
3. FOOBAR

__END__
---------------------------

HTH,
STEVE


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

Date: 22 Nov 2000 18:00:53 +0000
From: nobull@mail.com
Subject: Re: how do I merge blocks of text from different lines?
Message-Id: <u9pujnrin5.fsf@wcl-l.bham.ac.uk>

"Mauro" <-@-.com> doesn't want to do his homework:

> ________input is____
> [1]|some text
> [2]|I've an apple
> [3]|I eat the apple
> 
> separatortag
> 
> 1. HALLO
> 2. HI
> 3. FOOBAR
> 
> _______output must be_____
> HALLO|some text
> HI|I've an apple
> FOOBAR|I eat the apple
> 
> do you know the way to do that?

Yes, I'd write a program.  Probably in Perl.  If I couldn't program
I'd either learn how to or hire someone who could.  I'd do it for 50
Euro.

I've finally realised the pattern to Mauro's recent posts in this
(clpm) group.  At first I figured him for some sort of deranged troll
but now I realise that they are homework exercises.

If you make a reasonable effort at your homework but can't quite get
it right then you'll find many people here (including me) will look at
your attempt and explain what you've done wrong.  There's a _lot_ of
free and friendly Perl consultancy here if you play by the rules. If
you simply post your homework questions here then you will not find us
very friendly.

Perhaps you should tell your teacher that Perl/Unix is too hard for you.

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


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

Date: Wed, 22 Nov 2000 17:28:43 GMT
From: horace700@my-deja.com
Subject: How to Install Crypt::SSLeay on Remote Host?
Message-Id: <8vgvo4$up8$1@nnrp1.deja.com>

I'd like to use LWP to retrieve a secure page from my Hypermart
account. Presently I get a 501 error & modlist.pl says crypt::ssleay is
not installed. I understand that so long as module does not require
compilation, one can upload module in user directory. The only changes
I'm told would be to create appropriate use's & require's to the
script. Basically I've got 3 questions?
1. Can Crypt::SSLeay be successfully installed in a remote user
directory?

2. Would I just add "use /path/to/Crypt::SSLeay" to script?

3. Exactly what "require" (or do I even need a require call?) call do I
need.

Many thanks in advance for everyone's help.


Sent via Deja.com http://www.deja.com/
Before you buy.


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

Date: Wed, 22 Nov 2000 10:28:57 -0600
From: "Michael Segulja" <michael.segulja@sgi-lsi.com>
Subject: Re: How to output query row-by-row to HTML
Message-Id: <3a1bf209_1@newsa.ev1.net>

Oh man, now I feel stupid!!  I can't believe that was the reason I couldn't
get it to work like I wanted.  Thanks so much for your help!  In a addition
to Perl, I need to learn HTML much better.  I thought I was covered there,
but obviously I was wrong.  It never occurred to me the problem was HTML.


Thanks again for you quick response,

Michael



wrote in message news:3A1BE838.BD5AFBE3@fujitsu-siemens.com...
Michael Segulja wrote:

Although this is an HTML question more than a Perl question:

In HTML, a newline is not represented by a newline character but rather
by a "line break":
<br>

--Begin Perl code

my $genre = "\"Rock\"";

my $ary_ref = $dbh->selectall_arrayref("SELECT DISTINCT artist FROM
mp3main
        WHERE genre=$genre");

foreach my $item(@$ary_ref) {
push @ary, $item->[0];
}

print "$_<br>\n" for @ary;
---------^^^^

--End Perl code

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




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

Date: Wed, 22 Nov 2000 16:07:45 -0000
From: "Trevor Ward" <tward10@jaguar.com>
Subject: Re: How to output query row-by-row to HTML
Message-Id: <8vgr0i$9206@eccws12.dearborn.ford.com>

You need to put a new line in the array or after each print

Michael Segulja <michael.segulja@sgi-lsi.com> wrote in message
news:3a1be372$1_2@newsa.ev1.net...
> I have a database that stores MP3 information.  I have a Perl script that
> runs a query on the database depending on the genre.  I want each row to
be
> output to an HTML page line by line, but I'm not sure how to do it.
Here's
> the code I have so far:
>
> --Begin Perl code
>
> my $genre = "\"Rock\"";
>
> my $ary_ref = $dbh->selectall_arrayref("SELECT DISTINCT artist FROM
mp3main
>         WHERE genre=$genre");
>
> foreach my $item(@$ary_ref) {

either

> push (@ary, "$item->[0]\n");
> }
>
or

   foreach (@ary)
  {
    print "$_\n"
   }
> print "$_\n" for @ary;
>
> --End Perl code
>
> This works, but it output everything to one line, i.e.:
>
>                         Artist 1 Artist 2 Artist 3 Artist 4
>
> I want it to output each row one line at a time like this:
>
>                     Artist 1
>                     Artist 2
>                     Artist 3
>                     Artist 4
>
> I tried this:
>
> --Being Perl code
>
> my $genre = "\"Rock\"";
>
> my $sth = $dbh->prepare("SELECT DISTINCT artist FROM mp3main WHERE
> genre=$genre");
> $sth->execute();
>
> my $row = $sth->fetchrow_hashref;
>
> while (my @fieldNames = keys %$row) {
>
> foreach my $fieldName(@fieldNames) {
>         print "$fieldName\n";
>         }
> }
>
> $sth->finish();
>
> --End Perl code
>
> This doesn't work.  It actually outputs the word artist.  I'm a beginner
at
> this, and I'm using this project as a way to learn Perl, so I hope
somebody
> can help me.  I've tried reading the documentation in perldoc DBI on the
> different fetchrow commands, but I just get more confused I guess.
>
>
> Thanks very much for your help,
>
> Michael
>
>




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

Date: Wed, 22 Nov 2000 20:20:03 -0800
From: "Dario" <dario@kateka.lt>
Subject: I need to create proegrma like iescrow.com
Message-Id: <8vh2kf$2o0k$1@taidint.taide.lt>

I need to create proegrma like iescrow.com




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

Date: Wed, 22 Nov 2000 16:11:59 GMT
From: cfedde@fedde.littleton.co.us (Chris Fedde)
Subject: Re: looking for PERL GUI debugger for UNIX
Message-Id: <jfSS5.5$QX6.170913792@news.frii.net>

[A cc of this was set to Ilya Zakharevich <ilya@math.ohio-state.edu>]

In article <8vg02l$d7m$1@charm.magnus.acs.ohio-state.edu>,
Ilya Zakharevich <ilya@math.ohio-state.edu> wrote:
>
> The minimum is to highlight the current line, of course...
>

Obviously.  More would be useful.  It needs a colorization and
some kind of marker for those who dont have (or choose not to use)
color.

>> My vision at that time was that the code viewing window would be
>> entirely passive while the interactive command line debugger
>> continued in a separate window.
>
> This is a useful first approximation.  But you can already do it with
> a slave vi (or less?).
>

The slave vi mode that TomC built was what prompted me to use a
simpler passive screen.   All that was needed was to position the
current line in the window and mark it.  VI and less are way overkill
for this. I simply painted the screen from an array.

chris
-- 
    This space intentionally left blank


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

Date: Wed, 22 Nov 2000 17:17:29 -0000
From: Chris Stith <mischief@velma.motion.net>
Subject: Re: looking for PERL GUI debugger for UNIX
Message-Id: <t1nvt9n4gnp6bd@corp.supernews.com>

Ilya Zakharevich <ilya@math.ohio-state.edu> wrote:
> [A complimentary Cc of this posting was sent to Chris Fedde
> <cfedde@fedde.littleton.co.us>],
> who wrote in article <dhJS5.681$Bf7.190241280@news.frii.net>:

> Why syntax highlight?  If you want it, just use M-x perldb in Emacs...
> Debugger needs visual feedback on breakpoint etc much more than the
> syntax highlight...

Personally, I find that vim enhanced highlights Perl pretty well
although not flawlessly. Since I use vi much more often than Emacs,
I found this to be quite handy. It will highlight HTML, C, and some
other languages as well.

(Unfortunately|thankfully) vim doesn't send email or browse web
pages. It is a pretty powerful editor, though, and one that should
be considered if you need things useful to programmers such as
bracket matching, syntax highlighting, macro capability, both text
string and regex searching, and more but do not need a fully
programmable editor such as Emacs.

Some people will always prefer Eacs to vi, and some people will
always prefer vi to Emacs (kind of like C++/Eiffel or Perl/Python).
For those who don't yet have a preference, try both. Both are good
editors. Some people don't realize that any of the editors derived
from vi have so many features. Heck, back in the days when I was
new to Linux (when Linux was fairly new itself) and I had some
exposure to other Unixy operating systems but not much, I wouldn't
give Emacs or vi either one much of a chance because I found joe.
Coming from a pre-Windows PC environment, joe was a good tool to
help me along. It didn't keep meeting my needs, though, so I explored
the other options. Now that I have explored many options, vim enhanced
is what i use for most of my Perl coding.

Chris

--
Christopher E. Stith - mischief@motion.net
"In programming, as in much of the rest of life, your objective is
to explain an arbitrarily complex task in an arbitrarily simple way,
so that an entity with an arbitrarily low amount of intelligence and
common sense can make sense of your instructions. In this way, it is
not much different from technical support, except the error message
you get from the computer is more likely to make sense."



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

Date: Wed, 22 Nov 2000 16:17:10 GMT
From: rgarciasuarez@free.fr (Rafael Garcia-Suarez)
Subject: Re: Need help with file splitting
Message-Id: <slrn91nsda.laf.rgarciasuarez@rafael.kazibao.net>

Sunner wrote in comp.lang.perl.misc:
> Hi.
> I have a script that's supposed to write a report out of a logfile.
> At first the logfile is crammed with all sorts of stuff, but now the
> script reduces it to the two parts I need, an ID number, and a status
> code that tells how an operation went.
> A processed file might look like this:
> 10002000 0
> 10002000 0
> 10001000 0
> 10002000 3
> 10002000 2
> 10001000 5
> With the 8 digit number being the ID and the 1 digit number being the
> code.
> Now as long as there arent too many operations performed, counting them
> by hand is feasible, but with 1000 ops its a bit harder.
> 
> So what I wanna do is make a short report that would look something
> like:
> 10002000 had 2 code 0's
> 10002000 had 1 code 3's
> 10002000 had 1 code 2's
> 10001000 had 1 code 0's
> 10001000 had 1 code 5's
> Or something similar.
> It doesnt need to contain anything else than the ID, status code, and
> number of times really.

Use a hash. Attempt at an implementation :

  my %hash = ();
  while (<>) { # This reads your modified logfile
    chomp;
    my ($id,$code) = split;
    ++$hash{"$id-$code"};
  }
  for (keys %hash) {
    my ($id,$code) = split '-';
    print "$id had $hash{$_} code $code's\n";
  }

-- 
# Rafael Garcia-Suarez / http://rgarciasuarez.free.fr/


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

Date: Wed, 22 Nov 2000 17:32:00 GMT
From: garry@ifr.zvolve.net (Garry Williams)
Subject: Re: Need help with file splitting
Message-Id: <kqTS5.1340$xb1.85479@eagle.america.net>

On Wed, 22 Nov 2000 15:49:37 GMT, Sunner
<johan.sunnerstig@netgiro.com> wrote:
>I have a script that's supposed to write a report out of a logfile.
>At first the logfile is crammed with all sorts of stuff, but now the
>script reduces it to the two parts I need, an ID number, and a status
>code that tells how an operation went.  A processed file might look
>like this:
>
>10002000 0
>10002000 0
>10001000 0
>10002000 3
>10002000 2
>10001000 5
>
>With the 8 digit number being the ID and the 1 digit number being the
>code.
>
>Now as long as there arent too many operations performed, counting
>them by hand is feasible, but with 1000 ops its a bit harder.
>
>So what I wanna do is make a short report that would look something
>like:
>
>10002000 had 2 code 0's
>10002000 had 1 code 3's
>10002000 had 1 code 2's
>10001000 had 1 code 0's
>10001000 had 1 code 5's
>
>Or something similar.
>
>It doesnt need to contain anything else than the ID, status code, and
>number of times really.
>
>How can this be done in a decently short time(I havent got the kind of
>time to read through a 1000 page perl bible at the present time)?

Well, that's okay.  Why shouldn't I read it instead.  My time's less
valuable anyway.  Hmmm.  

    $ cat x
    #!/usr/local/bin/perl -w
    use strict;
    my %counts;
    while (<DATA>) {
	my ($id, $code) = split;
	$counts{$id}{$code}++;
    }
    foreach my $id (reverse sort keys %counts) {
	foreach my $code (sort keys %{ $counts{$id} }) {
	    print "$id had $counts{$id}{$code} code $code\'s\n";
	}
    }
    __END__
    10002000 0
    10002000 0
    10001000 0
    10002000 3
    10002000 2
    10001000 5 
    $ perl x
    10002000 had 2 code 0's
    10002000 had 1 code 2's
    10002000 had 1 code 3's
    10001000 had 1 code 0's
    10001000 had 1 code 5's
    $

-- 
Garry Williams


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

Date: Wed, 22 Nov 2000 18:29:32 +0100
From: "Alexander Adam" <PCXsoft@intag.de>
Subject: New Perl-IDE available
Message-Id: <8vgvti$60g$00$1@news.t-online.com>

Hello,

Under http://www.perlperfect.com we have a new Perl-IDE which is better and
cheaper than Perlbuilder 2.0.
A visual Perl/Tk designer is also available.

For more information on "PerlPerfect" or "<P-Design>" look on the homepage:
  http://www.perlperfect.com


Thank you,

A. Adam
--
PCX Software




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

Date: Wed, 22 Nov 2000 16:52:41 GMT
From: satkinson@skydesk.com
Subject: newbie pipe question
Message-Id: <8vgtko$t3r$1@nnrp1.deja.com>

I have a UNIX perl script where I want to convert UNIX style paths to
DOS style path in a pipe. From the shell I'd do something like this:

cat myfile | tr '/' '\'

However, I can't get the following to work in perl:

open(FILE,"cat myfile | tr '/' '\' |");

If get not translations when I read from the pipe. What am I doing
wrong?

Thanks,

StevenA


Sent via Deja.com http://www.deja.com/
Before you buy.


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

Date: 22 Nov 2000 18:07:44 +0000
From: nobull@mail.com
Subject: Re: newbie pipe question
Message-Id: <u9hf4zribz.fsf@wcl-l.bham.ac.uk>

satkinson@skydesk.com writes:

> I have a UNIX perl script where I want to convert UNIX style paths to
> DOS style path in a pipe. From the shell I'd do something like this:
> 
> cat myfile | tr '/' '\'

Would you really?  Gives me an error must be you have a different
shell.  Does it actually work though?

And would you really go for the "useless use of cat award"?

> However, I can't get the following to work in perl:
> 
> open(FILE,"cat myfile | tr '/' '\' |");

If it doesn't work at the shell prompt then I would not expect it to
work when called from Perl.

> If get not translations when I read from the pipe. What am I doing
> wrong?

You mean appart from using the external tr program when there's a
perfectly good Perl builtin function to do the same thing and which
even has the same name?

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


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

Date: 22 Nov 2000 18:07:11 +0000
From: nobull@mail.com
Subject: Re: perl version of html tag
Message-Id: <u9itpfricw.fsf@wcl-l.bham.ac.uk>

richard_dobson@my-deja.com writes:

> I am returning input data from the user to the browser in the form of a
> table. Does anyone know how to specify the cell width so that if the
> data contained in it is over a certain length it starts a new line and
> extends the row downwards instead of across?

Any attributes passed to any of the CGI.pm HTML element generator
functions will simply propagate through to the generated HTML unless
they have a special meaning to CGI.pm.

If you want CGI.pm to export generator functions for HTML elements not
in the ':html3' group (or even ones completely unknown to CGI.pm) then
simply ask for them by name in the export lists.

If you don't know the underlying HTML elements and attibutes that you
use to control the widths of table columns then this is not a Perl
related question and you need to go read a book on HTML.

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


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

Date: Wed, 22 Nov 2000 10:59:00 -0800
From: "Soumen Das" <soumen.das@cp.net>
Subject: Perl XS
Message-Id: <t1o5vnclqurq58@corp.supernews.com>

Hi,

I am planning to write Perl wrappers over C++ libraries on NT and Solaris
using Perl Xs. I have already been thru the perlxstuts and perlxs man pages.

The problem that I am having is as follows -
On NT :
- There are multiple cpp files and .h files.
- the exported interfaces are consolidated in one header file.
- i need to build the perl wrappers over these exported interfaces.
- the .c file generated by xubpp is he interface file that got generated but
it failed to compile with the rest of the .cpp files.

My questions are as follows :
1. Is it required to build the entire project again with the .c file
generated ?
2. How should I tweak my build options ? (Command line build does not work
as well)
3. Where can I get more information on Using XS with C++ ?

Thanks,
Soumen




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

Date: 22 Nov 2000 18:04:13 +0000
From: nobull@mail.com
Subject: Re: permissions issue...i think
Message-Id: <u9k89vrihu.fsf@wcl-l.bham.ac.uk>

akothek@my-deja.com writes:

> i tried system("cd /home/mydir") but that did not do it...also tried
> ENV{PWD} = "home/mydir" and that didnt work either!!!

Look in the list of Perl builtin functions - look for one that changes
the current working directory.

Of course relying on the user having '.' in their PATH is a "Bad
Thing(TM)".  Better to call programs by full pathname.

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


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

Date: Wed, 22 Nov 2000 15:58:08 GMT
From: toby_m_kramer@my-deja.com
Subject: Problem r/w binary files
Message-Id: <8vgqeb$qo2$1@nnrp1.deja.com>



Dear all:

I have problem reading binary files in the
following simple code:

open (O,">test.dat") or die "Can't open file for
writing!\n";
for (my $i=0;$i<1000;$i++) {
        my $buf = pack "NNNa10", $i, $i*10, $i*5,
"ABCDEFGHIJ";
        print O $buf;
}
close (O);

open (R,"+<test.dat") or die "Can't open file!\n";

for (my $i=0;$i<1000;$i++) {
        my $buf;
        read(R, $buf, 22) == 22 or die "Can't
read data!\n";
        # sizeof(N)*3 + sizeof(char)*10 = 22
        my ($m, $n, $o, $p) = unpack "NNNa10",
$buf;
        if ($m ne "" && $n ne "") { print "$m:$n:
$o:$p\n"; }
}

close (R);

Theoretically this should write to a binary file
a list of records with three numbers and a string
of 10 characters, and then read from that file to
reproduce/print the data.  The first part
(writing) seems fine (with a 22k file produced).
The second part (reading) prints fine, but only
up to the 25th record.  After that, 'read'
returns 0 (then the script dies).  According to
documentation, 'read' returns 0 when it reaches
EOF.  That however cannot be possible since there
should be 1000 records (in the 22k file) and the
script shouldn't find EOF at the 25th record.  If
you can reproduce the problem, let me know.  I am
using ActivePerl on Win32.

TIA.  Help appreciated.

Toby


Sent via Deja.com http://www.deja.com/
Before you buy.


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

Date: 22 Nov 2000 18:01:27 +0000
From: nobull@mail.com
Subject: Re: Problem r/w binary files
Message-Id: <u9ofz7rimg.fsf@wcl-l.bham.ac.uk>

toby_m_kramer@my-deja.com writes:

> Subject: Re: Problem r/w binary files

[ snip code with no binmode() ]

>                                ...on Win32.

perldoc -f binmode

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


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

Date: Wed, 22 Nov 2000 16:15:50 GMT
From: toby_m_kramer@hotmail.com
Subject: Problem reading/writing binary file
Message-Id: <8vgrfg$rid$1@nnrp1.deja.com>



I have problem reading/writing binary files.  I somehow can't get the
following *simple* code to work properly:

# First part: writing binary file
open (O,">test.dat") or die "Can't open file for writing!\n";

for (my $i=0;$i<1000;$i++) {
        my $buf = pack "NNNa10", $i, $i*10, $i*5, "ABCDEFGHIJ";
        print O $buf;
}
close (O);

# Second part: reading binary file
open (R,"+<test.dat") or die "Can't open file!\n";

for (my $i=0;$i<1000;$i++) {
        my $buf;
        read(R, $buf, 22) == 22 or die "Can't read data!\n";
        my ($m, $n, $o, $p) = unpack "NNNa10", $buf;
        if ($m ne "" && $n ne "") { print "$m:$n:$o:$p\n"; }
}

close (R);

In the first part, the code should save 1000 "records" of three big-
endian numbers and a string of 10 characters, with each record
occupying 22 bytes (3*4 + 10*1).  The first part of the script produces
a "saved" file that is roughly 22kbytes (or 22 bytes * 1000 records).
So far so good.

However, in the second part only the first 26 records are printed, with
the script "dying" at the 27th record.  It turns out that the "read"
function returns 0.  According to documentation, a return value of 0
means the file pointer reaching EOF, but that is not possible since the
27th record is/should be no-where close to EOF.

I have no clue why this is so, especially given that there is really no
hidden magic in the script.  If you can reproduce the problem, let me
know.  Help appreciated.  I am using ActivePerl on Win32, and if anyone
has other results on other platforms, let me know as well.  Thanks!

-Toby


Sent via Deja.com http://www.deja.com/
Before you buy.


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

Date: 22 Nov 2000 09:59:07 -0800
From: Petri Oksanen <Petri_member@newsguy.com>
Subject: Re: Problem reading/writing binary file
Message-Id: <8vh1hb01bhr@edrn.newsguy.com>

In article <8vgrfg$rid$1@nnrp1.deja.com>, toby_m_kramer@hotmail.com says...

> I have problem reading/writing binary files.

>open (O,">test.dat") or die "Can't open file for writing!\n";

binmode O;

>open (R,"+<test.dat") or die "Can't open file!\n";

binmode R;

> I am using ActivePerl on Win32,

You have my sympathy.
Read up on this, you'll need it:
perldoc -f binmode


Petri Oksanen



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

Date: Wed, 22 Nov 2000 17:42:24 GMT
From: jkipp@mbna.com
Subject: Re: Problem with simple del file script
Message-Id: <8vh0hu$vlb$1@nnrp1.deja.com>

In article <slrn91nnv7.l5d.rgarciasuarez@rafael.kazibao.net>,
  rgarciasuarez@free.fr (Rafael Garcia-Suarez) wrote:
> jkipp@mbna.com wrote in comp.lang.perl.misc:
> > I am trying to go through a directory and delete files that are
older
> > than 30 days. Here is what I have, it will print the files, no
problem,
> > but will not delete. Thanks for any suggestion
> > Jim
> > ------
> > $path='h:\dbm\mediacreate';
> >
> > opendir (WDIR, "$path") or die "Can't open $path: $!";
> >
> > while ($file= readdir WDIR) {
> > 	next if $file=~/^\./;
> >         $age= -M "$path/$file";
> >
> > 	if ($age > 30) {
> >             # print "$file\n"; # this works
> >              `del $file` # this does not
> > 	      # unlink $file #this does not
>
> unlink "$path/$file" or warn "Can't unlink $path/$file: $!\n";
>
> > 		}
> >     }
>
> You figured out correctly how to calculate the age of the file. Its
> path is "$path/$file", not $file. Adding a warning including the $!
> variable (as I did) would have helped you to find the cause of the
> error.
>
> --
> # Rafael Garcia-Suarez / http://rgarciasuarez.free




Thanks I got it working now. Here is what I have:
$path='h:\\dbm\\mediacreate';

opendir (WDIR, "$path") or die "Can't open $path : $!";
while ($file= readdir WDIR) {
	next if $file=~/^\./;
	$age= -M "$path/$file";

		if ($age > 30) {
      	unlink ("$path/$file") or die "Could not delete: $path/$file:
$!";

	}
}



>


Sent via Deja.com http://www.deja.com/
Before you buy.


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

Date: 16 Sep 99 21:33:47 GMT (Last modified)
From: Perl-Users-Request@ruby.oce.orst.edu (Perl-Users-Digest Admin) 
Subject: Digest Administrivia (Last modified: 16 Sep 99)
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: The mail to news gateway, and thus the ability to submit articles
| through this service to the newsgroup, has been removed. I do not have
| time to individually vet each article to make sure that someone isn't
| abusing the service, and I no longer have any desire to waste my time
| dealing with the campus admins when some fool complains to them about an
| article that has come through the gateway instead of complaining
| to the source.

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 V9 Issue 4950
**************************************


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