[10639] in Perl-Users-Digest

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

Perl-Users Digest, Issue: 4231 Volume: 8

daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Mon Nov 16 16:07:30 1998

Date: Mon, 16 Nov 98 13:00:23 -0800
From: Perl-Users Digest <Perl-Users-Request@ruby.OCE.ORST.EDU>
To: Perl-Users@ruby.OCE.ORST.EDU (Perl-Users Digest)

Perl-Users Digest           Mon, 16 Nov 1998     Volume: 8 Number: 4231

Today's topics:
    Re: 2Q: Perl modules & htaccess kenyclark@my-dejanews.com
        Beginner Book? (Jeff Kennedy)
    Re: Beginner Book? (I R A Aggie)
        COBOL to PERL translator <oliver.muthig@ubs.com>
    Re: COBOL to PERL translator (brian d foy)
    Re: compiling modules under Win95 problems (Clinton Pierce)
        Exec question! <kempe@mtek.chalmers.se>
        exhaust memory even with close?!?!? <cordero@okcom.net>
    Re: exhaust memory even with close?!?!? <baliga@synopsys.com>
        Getting one byte at a time <nkanth@cnd.hp.com>
        Help with running Executable through CGI-Perl on WINNT mila@stars.gsfc.nasa.gov
    Re: Holy Abounding Books, Batman! (Walter Tice USG)
    Re: Holy Abounding Books, Batman! (I R A Aggie)
        How can I translate Perl prog to C? (Ping-An Tan)
        How to solve this problem? <nrana@aludra.usc.edu>
        Keyboard/Mouse Macros? ljkbrost@my-dejanews.com
        mkdir() <alcazar@netcomp.net>
    Re: mkdir() (brian d foy)
    Re: Multipliers x{m,n} (Clay Irving)
    Re: Multipliers x{m,n} (Larry Rosler)
    Re: Need to find binary data <baliga@synopsys.com>
    Re: Not to start a language war but.. meaw@my-dejanews.com
    Re: Perl Usage Survey - interpretations, anyone? (Clinton Pierce)
    Re: perl/win95 mila@stars.gsfc.nasa.gov
    Re: Positional parameter support in perl printf (Andrew Allen)
        regexp query: s//g not global <rob.hardy@ndirect.co.uk>
    Re: substitute (Joergen W. Lang)
    Re: syntax/doc question <yong@shell.com>
    Re: syntax/doc question (Andrew M. Langmead)
    Re: Unix to Win32 conversion (Jeffrey R. Drumm)
    Re: upper to lowercase (Joergen W. Lang)
        Special: Digest Administrivia (Last modified: 12 Mar 98 (Perl-Users-Digest Admin)

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

Date: Mon, 16 Nov 1998 20:25:39 GMT
From: kenyclark@my-dejanews.com
Subject: Re: 2Q: Perl modules & htaccess
Message-Id: <72q1o3$2is$1@nnrp1.dejanews.com>

Jye,

Would you please be so kind as to post your code for #2?  I would love to see
how you did this, as I've slogged through what seems like hundreds of
newsposts and websites looking for the cleanest way to do this.

Thanks!

Ken Clark
Cincinnati, OH

In article <jye-ya02408000R0311981001220001@qld.nnrp.telstra.net>,
  jye@buckconsultants.com.au (Jye Tucker) wrote:
> In article <363E0601.D176B9@wfubmc.edu>, Steve miles <smiles@wfubmc.edu>
wrote:
>
> > Hi everyone. I have two questions:
> >
> > 1. What can you type at the telnet command line to get a list of Perl
> > modules installed on your system? (I'm just using a hosting company...)
> >
> > 2. When creating a password protected membership site, is there any way
> > of getting around having to use .htaccess and it's password file for the
> > membership database? Is there a way to use Perl to let the person sign
> > in via a HTML form instead of the .htaccess popup and still be able to
> > have the contents of an entire directory protected? (Of course I'm
> > assuming you will still use an .htaccess file for the protected
> > directories, but I'm just looking for a way around the popup member
> > entrance...)
>
> Hi Steve,
>
> 1. From the perlmodlib manpage...
>
> --o--
> To find out all the modules installed on your system, including those
> without documentation or outside the standard release, do this:
>
>            % find `perl -e 'print "@INC"'` -name '*.pm' -print
> --o--
>
> 2. I just wrote a script to perform exactly the same thing that you are
> looking at. There is a .htaccess file in the protected directory to prevent
> anyone from getting in if they know the URL to that directory.
>
> It basically just reads the username and password from a form, reads a
> config file (my version generates a different page for each username), and
> makes its own HTTP request using the LWP module and the authorization_basic
> function.
>
> Hope that gives you a good start,
>
> Jye
>


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


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

Date: Mon, 16 Nov 1998 19:12:10 GMT
From: jeff.kennedy@natdecsys.com (Jeff Kennedy)
Subject: Beginner Book?
Message-Id: <3650788e.14819289@news.newsguy.com>

I need a book geared to an ABSOLUTE BEGINNER!  No perl experience, no
programming experience, no real shell scripting experience.

What would I be looking for?  Not something that assumes I know
anything!

Thanks

Jeff Kennedy


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

Date: Mon, 16 Nov 1998 15:21:01 -0500
From: fl_aggie@thepentagon.com (I R A Aggie)
Subject: Re: Beginner Book?
Message-Id: <fl_aggie-1611981521010001@aggie.coaps.fsu.edu>

In article <3650788e.14819289@news.newsguy.com>,
jeff.kennedy@natdecsys.com (Jeff Kennedy) wrote:

+ What would I be looking for?

An introductory programming text. Your local institute of higher learning
may offer such a course, and may have suggestions on appropriate texts
and assignments.

After that, you'll probably want either _Learning Perl_ or _Programming
Perl_, depending on your comfort level.

James


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

Date: Mon, 16 Nov 1998 19:00:52 +0100
From: Oliver Muthig <oliver.muthig@ubs.com>
Subject: COBOL to PERL translator
Message-Id: <36506853.25188B55@ubs.com>

Hi,

is there anything like a COBOL to PERL translator ?

Thanks.

Oliver




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

Date: Mon, 16 Nov 1998 15:56:17 -0500
From: comdog@computerdog.com (brian d foy)
Subject: Re: COBOL to PERL translator
Message-Id: <comdog-ya02408000R1611981556170001@news.panix.com>

In article <36506853.25188B55@ubs.com>, Oliver Muthig <oliver.muthig@ubs.com> posted:

> is there anything like a COBOL to PERL translator ?

if there is, it's probably similar to the old csh to perl translator :)

-- 
brian d foy                                  <comdog@computerdog.com>
CGI Meta FAQ <URL:http://computerdog.com/CGI_MetaFAQ.html>


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

Date: Mon, 16 Nov 1998 18:40:40 GMT
From: cpierce1@mail.ford.com (Clinton Pierce)
Subject: Re: compiling modules under Win95 problems
Message-Id: <365570f6.355772161@news.ford.com>

On 16 Nov 1998 14:55:42 GMT, glc@well.com (Greg L. Chapman) wrote:

>The exitstatus warning is generated by this command:
>
>D:\PERL\BIN\perl D:\perl\lib\ExtUtils\xsubpp temp000 2>&1
>                                                     ^^^^
>
>4DOS doesn't support this redirection syntax (though 4NT, TakeCommand, CMD.EXE,
>and, of course, all the Unix shells do).  

Be careful with a generalization like that!

bash$ /bin/csh
eccws7% ls 2>/dev/null   # Doesn't like this at all!
2: No such file or directory
eccws7% ls 2>&1          # ...does not do what you expect.  :-)
eccws7%



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

Date: Mon, 16 Nov 1998 19:30:58 +0100
From: jesper kempe <kempe@mtek.chalmers.se>
Subject: Exec question!
Message-Id: <36506F61.8C7F2629@mtek.chalmers.se>

Hi
I4ve got a problem:
On my computer I run win95 and a webserver with Xitami. I4ve got a very
simple thing on my page so that you can send me a message that appears
emidiately on my screen and I can answer and they can see my answer in a
frame that updates automaticly.
Ok, now to my real problem. In my very simple perl script I exec another
program written i Visual basic. The problem is that when I exec the vb
program the script pause and if i dont answer the user gets the
"document contians no data" in his browser.
Is there another way to execute  another program in perl?

Hope you understand my problem and can help me.

Any comments are appritiated...

            /Jesper Kempe
            http://malte.hemmet.s-hem.chalmers.se



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

Date: Mon, 16 Nov 1998 14:52:00 -0500
From: "Douglas L. Cordero, PhD" <cordero@okcom.net>
Subject: exhaust memory even with close?!?!?
Message-Id: <3650825F.41C6@okcom.net>

Hi guys:

My code is exhausing all of my virtual memory with
sucessive file opens.  It dies (can't open...) on
file 33 out of 263.  The files themselves are quite large.
(about 1 M each).  Hash of arrays "%array" winds up 
holding about 1 million values (before it dies) -- which is not
enough to fill up 67 M of virtual memory, I would think.  
So, it looks like its not freeing the memory after the
read is finished.  What's weird is that I am closing 
the filehandle after reading is done.  

(just a note, dxread is a fortran program that opens/reads the
linked file and screen dumps 2 values: a key and a number, which
get sucked into %array.  dxread exits properly and dumps a total
of about 100,000 lines per file.)

Any ideas what's up with it???

Thanks in advance,
-Doug Cordero


system:  IBM RS-6000 Model 397
perl version  5.003  and 5.004

------------------------------------------------------------
#!/usr/local/bin/perl5.004 -w

$| = 1;
use strict;

my $prog = 'dxread';
my $Sats = qw( noa );
my %array = ();
my ($SAT, $DXFILE, $tmp1, $tmp2, $k);

my @Files = glob "DX0*";

foreach $DXFILE (@Files) {
    print "Opening: $DXFILE\n";
    symlink( $DXFILE, 'fort.10' );
    open READPROC, "$prog|" or die "Can't open $DXFILE\n";
    while ( <READPROC> ) {
      ($tmp1,$tmp2) = split;
      push @{$array{$tmp1}},$tmp2;
    }
    close( READPROC ) or die "Could not close $DXFILE\n";
    unlink('fort.10');
    print "Finished with $DXFILE\n";
}

print "There are ",scalar(keys(%array))," keys in hash of arrays.\n";

foreach $k (keys %array) {
  print "Key $k has ",scalar(@{ $array{$k} })," values in it.\n"; 
}

print "Done\n";
---------------------------------------------------------------------


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

Date: Mon, 16 Nov 1998 12:04:06 -0800
From: Yogish Baliga <baliga@synopsys.com>
To: "Douglas L. Cordero, PhD" <cordero@okcom.net>
Subject: Re: exhaust memory even with close?!?!?
Message-Id: <36508536.DC21FC90@synopsys.com>

I suppose the problem is because of the OS limit on the number of files
that can
be opened at a time... The open file limit for your OS may be 32. That is
why
It may be because of that...

-- Baliga

"Douglas L. Cordero, PhD" wrote:

> Hi guys:
>
> My code is exhausing all of my virtual memory with
> sucessive file opens.  It dies (can't open...) on
> file 33 out of 263.  The files themselves are quite large.
> (about 1 M each).  Hash of arrays "%array" winds up
> holding about 1 million values (before it dies) -- which is not
> enough to fill up 67 M of virtual memory, I would think.
> So, it looks like its not freeing the memory after the
> read is finished.  What's weird is that I am closing
> the filehandle after reading is done.
>
> (just a note, dxread is a fortran program that opens/reads the
> linked file and screen dumps 2 values: a key and a number, which
> get sucked into %array.  dxread exits properly and dumps a total
> of about 100,000 lines per file.)
>
> Any ideas what's up with it???
>
> Thanks in advance,
> -Doug Cordero
>
> system:  IBM RS-6000 Model 397
> perl version  5.003  and 5.004
>
> ------------------------------------------------------------
> #!/usr/local/bin/perl5.004 -w
>
> $| = 1;
> use strict;
>
> my $prog = 'dxread';
> my $Sats = qw( noa );
> my %array = ();
> my ($SAT, $DXFILE, $tmp1, $tmp2, $k);
>
> my @Files = glob "DX0*";
>
> foreach $DXFILE (@Files) {
>     print "Opening: $DXFILE\n";
>     symlink( $DXFILE, 'fort.10' );
>     open READPROC, "$prog|" or die "Can't open $DXFILE\n";
>     while ( <READPROC> ) {
>       ($tmp1,$tmp2) = split;
>       push @{$array{$tmp1}},$tmp2;
>     }
>     close( READPROC ) or die "Could not close $DXFILE\n";
>     unlink('fort.10');
>     print "Finished with $DXFILE\n";
> }
>
> print "There are ",scalar(keys(%array))," keys in hash of arrays.\n";
>
> foreach $k (keys %array) {
>   print "Key $k has ",scalar(@{ $array{$k} })," values in it.\n";
> }
>
> print "Done\n";
> ---------------------------------------------------------------------



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

Date: Mon, 16 Nov 1998 12:16:07 -0700
From: Srikanth Natarajan <nkanth@cnd.hp.com>
Subject: Getting one byte at a time
Message-Id: <365079F7.FF1696BD@cnd.hp.com>

I have string which may or may not contain multi-byte chars.
I want to extract one byte at a time and check the byte(s) against
some bit masks.

Is there a way to do it?
substringing one char does not work.

Regards
Srikanth


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

Date: Mon, 16 Nov 1998 19:46:12 GMT
From: mila@stars.gsfc.nasa.gov
Subject: Help with running Executable through CGI-Perl on WINNT
Message-Id: <72pve4$a1$1@nnrp1.dejanews.com>

 I need some help asap with a project where I am trying to run a program
(.exe file located on a WIN NT disk) through CGI-Perl. The perl program I
wrote successfully calls the exe file (or any other .exe ) file, but when I
call that perl program through a CGI form on the web, it does not run that
executable. The form does indeed call the Perl correctly, as I can pass it
some variables and it returns those, but seems to ignore and pass over the
 .exe file.  Do you know how I can make the CGI run any .exe file?
'Paintshop.exe is a good alternative to the program I am trying to run. The
catch is I am doing this on Windows NT, so the whole system is different from
Unix.

The line I have in Perl (trial.pl) is something like:
open IDL,'|"c:\rsi\idl51\trial.exe "';
close IDL;

The line in CGI form that calls the Perl program is:
<FORM ACTION="http://www.ssmi.com/cgi-bin/mila/trial.pl" METHOD="post">


Please let me know if you have any suggestions as soon as you can, as I would
like something working by tomorrow. I would really apprecaite it! The main
problem is Perl calls the program (IDL as well as others like say,
paintshop.exe) through the DOS commande line correctly (perl trial.pl_, but
when I call the same problem through CGI form, it runs the perl program but
ignores the executable program to be called.

Thanks in advance,
Mila Mitra
mitra@remss.com

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


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

Date: 16 Nov 1998 15:54:00 GMT
From: tice@hunch.zk3.dec.com (Walter Tice USG)
Subject: Re: Holy Abounding Books, Batman!
Message-Id: <72phqo$15q@zk2nws.zko.dec.com>

In article <tgbtmbs9ce.fsf@noise.bsd.uchicago.edu> Darrin Edwards <d-edwards@nospam.uchicago.edu> writes:
>"David Bolton" <dbolton@IdeaPlace.org> writes:

<snip>

>I can heartily recommend 3; it contains essentially _all_ of the
>information contained in perl's man pages _plus_ more in-depth
>explanations and copious examples.  Combined with a fine index,
>makes this book great for both learning a given topic (e.g.
>regular expressions) in greater detail, as well as a reference to
>keep handy.

Programming Perl is as you say a must have as a reference, but the
Pink Camel has Chapter 6 "Real Perl Programs" which the blue camel
lacks (to it's detriment).  Both "Effective Perl Programming" and
"Perl Cookbook" are superior IMO for 'copious examples' but assume
a working knowledge of Perl.

>Best wishes,
>Darrin

W
-- 
Man in black:  Whether I am or not, you've been more than fair.
Inigo: [drawing his sword]  You seem a decent fellow...I hate to kill you.
Man in black:  You seem a decent fellow...I hate to die.
  -- from Scene 4 "Princess Bride"


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

Date: Mon, 16 Nov 1998 15:28:13 -0500
From: fl_aggie@thepentagon.com (I R A Aggie)
Subject: Re: Holy Abounding Books, Batman!
Message-Id: <fl_aggie-1611981528140001@aggie.coaps.fsu.edu>

In article <slrn750ibf.h7m.hdiwan@diwanh.stu.rpi.edu>,
hdiwan@diwanh.stu.rpi.edu () wrote:

+ I never read any books on perl. I learned by looking at source, tweaking it 
+ and RTFM. :) Good luck!

The only problem with that is you can't take it with you to restroom...

:)

James


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

Date: Mon, 16 Nov 1998 20:28:59 GMT
From: afsipat@cmc.doe.ca (Ping-An Tan)
Subject: How can I translate Perl prog to C?
Message-Id: <fW%32.5286$dB4.129200@carnaval.risq.qc.ca>

I want to convert a Perl program into a C program. I have tried to type the
following on my prompt:

perl -MO=C test1.pl > test1.c

But the following error message appears:

Can't locate O.pm in @INC.
BEGIN failed--compilation aborted.

How may I fixed the problem or Where can I find the O.pm module?
Please help!!!!

--
Ping-An Tan                           ,,,
Programmer (514) 421-4705            (. .)
----------------------------------ooO-(_)-Ooo-------
Canadian Meteorological Centre  Ping-An.Tan@ec.gc.ca


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

Date: Mon, 16 Nov 1998 12:03:12 -0800
From: Nadeem Rana <nrana@aludra.usc.edu>
Subject: How to solve this problem?
Message-Id: <Pine.GSO.4.02.9811161156570.20384-100000@aludra.usc.edu>

I am trying to solve one problem where I have a text file containing the
names of functions declarations. The syntax of the file is like this...


		funcA(
		int a,
		char b,
		dword c,
		objectA d
		)

		funcB(
		char t,
		int r,
		char y
		)

		funcA(
		if EVERYTHING is SAME over here as funcA upwards then dont
select this function else select this function too!!

		)

So im trying to remove redundancy by removing all those functions which
have EXACTLY same signatures. How can I solve this problem in PERL?

Thanks
Nadeem	



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

Date: Mon, 16 Nov 1998 19:37:23 GMT
From: ljkbrost@my-dejanews.com
Subject: Keyboard/Mouse Macros?
Message-Id: <72putj$vo4$1@nnrp1.dejanews.com>

Hello Everyone,

I have an interesting question that I could use some help in finding a
solution to.  I would like to write a progam in UNIX that would allow myself
to playback a sequence of keystrokes or even mouse clicks, basically a macro.

In an effort to minimize the recreation of the wheel, I would appreciate it
if anyone knows of a program that will perform macros in an X-Windows
environment?

If not, how would I go about sending keystokes to an active window.  What
would I need to do, or where should I start to look to find a possible
solution. Would I be able to send information to STDIN in perl and have the
beuffered data transmitted to the active program?

I have lots of questions and few answers, if you could help I would be
greatful.

Thanks,


--
Kyle Brost
----

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


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

Date: Mon, 16 Nov 1998 13:18:52 -0600
From: "illfigah" <alcazar@netcomp.net>
Subject: mkdir()
Message-Id: <72ptok$ima$1@excalibur.flash.net>


    Hello all,

    I'm relatively new to perl thus I am not well versed with the language.
I'm trying to create a directory whose path contains a variable.  It doesn't
work with the variable.  Without the variable it works fine.  Any ideas?

$new_account_directory = "/something/something_other/$variable";
 mkdir($new_account_directory, 0755);



    illfigah




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

Date: Mon, 16 Nov 1998 15:45:26 -0500
From: comdog@computerdog.com (brian d foy)
Subject: Re: mkdir()
Message-Id: <comdog-ya02408000R1611981545260001@news.panix.com>

In article <72ptok$ima$1@excalibur.flash.net>, "illfigah" <alcazar@netcomp.net> posted:

>     I'm relatively new to perl thus I am not well versed with the language.
> I'm trying to create a directory whose path contains a variable.  It doesn't
> work with the variable.  Without the variable it works fine.  Any ideas?
> 
> $new_account_directory = "/something/something_other/$variable";
>  mkdir($new_account_directory, 0755);

check the return value of mkdir to see what happened.  also check
the value of $!.

-- 
brian d foy                                  <comdog@computerdog.com>
CGI Meta FAQ <URL:http://computerdog.com/CGI_MetaFAQ.html>


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

Date: 16 Nov 1998 13:54:57 -0500
From: clay@panix.com (Clay Irving)
Subject: Re: Multipliers x{m,n}
Message-Id: <72pse1$q7b@panix.com>

In <72pmfo$bbj$1@mwrns.noaa.gov> hodges@space.srrb.noaa.gov (Gary Hodges) writes:

>Perl novice here.  Who cares?  Anyway, I have some large data files with 34
>fields of comma deliminated real numbers with no spaces in between.

>xx.xxxx,xxx.xxx,xxx.xxxx etc

>Instead of repeating  (\S+)\,(\S+)\,  34 times, can I use x{m,n} to just
>repeat (\S+)\, 34 times?  I've tried using x{m,n} a few different ways, but
>haven't had much success.

Perl Modules are your friend.
   
This program:

   #!/usr/local/bin/perl -w
   
   use Text::CSV;
   
   my $csv = Text::CSV->new();
   
   while (defined($line = <DATA>)) {
       chomp $line;
       my $status = $csv->parse($line);
       if ($status) {
           ($eeny,$meeny,$mighty) = $csv->fields();
           print "$eeny  -  $meeny  -  $mighty\n";
       }
   }
   
   __DATA__
   xx.xxxx,xxx.xxx,xxx.xxxx
   yy.yyyy,yyy.yyy,yyy.yyyy
   zz.zzzz,zzz.zzz,zzz.zzzz

outputs:
   
   xx.xxxx  -  xxx.xxx  -  xxx.xxxx
   yy.yyyy  -  yyy.yyy  -  yyy.yyyy
   zz.zzzz  -  zzz.zzz  -  zzz.zzzz
-- 
Clay Irving
clay@panix.com


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

Date: Mon, 16 Nov 1998 11:10:55 -0800
From: lr@hpl.hp.com (Larry Rosler)
Subject: Re: Multipliers x{m,n}
Message-Id: <MPG.10ba18997a28dbf5989873@nntp.hpl.hp.com>

[Posted to comp.lang.perl.misc and a copy mailed.]

In article <72pp84$d5r$1@mwrns.noaa.gov> on 16 Nov 1998 18:00:36 GMT, 
Gary Hodges <hodges@space.srrb.noaa.gov> says...
 ... 
>      I have a data file of the format (where x=number and a=alpha):
> 
> xxxxx,aaxx,xxxxxx xx:xx:xx,xxx.xxx (repeat last 33 more times).  I have the
> code 
> 
> while ($line = <IN>){
>   $line =~ m/^(\d+)\,(\S+)\,(\d+)\s+(\d+)\:(\d+)\:(\d+)\,(\S+)\, repeated
> 
> I want to store each field into a variable <$head = $1;> and so on.  Instead
> of just repeating (\S+)\, a bunch of times, I was looking for a tool that
> would do the repeating for me.  split looks like a pretty good choice to
> solve this problem.  I have spaces, colons, and commas though.  I have
> Learning Perl in front of me, so I'll continue looking into split.

If you decide that a regex is the best approach, you can construct one 
as a variable using the 'x' operator:

    my $repeated = 'repeated stuff' x count;
    /^starting stuff...$repeated...ending stuff$/o;

where the 'o' modifier is appropriate if the regex is constant for the 
duration of the program.

Alternatively, you can pick off the initial match first, then do the 
repeat using the 'g' regex modifier:

    /repeated stuff/g;

This is nice because it doesn't rely on any predetermined count.

Each approach yields a list of captured matches, and you would be well 
advised to assign the list to an array and work with offsets, than to 
use $1, $2, ...

-- 
(Just Another Larry) Rosler
Hewlett-Packard Laboratories
http://www.hpl.hp.com/personal/Larry_Rosler/
lr@hpl.hp.com


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

Date: Mon, 16 Nov 1998 11:31:31 -0800
From: Yogish Baliga <baliga@synopsys.com>
To: Srikanth Natarajan <nkanth@cnd.hp.com>
Subject: Re: Need to find binary data
Message-Id: <36507D93.6C0C0CAF@synopsys.com>

You can use getc function..

-- Baliga

Srikanth Natarajan wrote:

> I need to read a file and throw an error if it contains non ascii
> data (i.e. code > 127)
>
> The bitmask check $char & 0x80 works fine if I use it with some
> arbitrary variable which contains code > 127
>
> but when I read a file
> and then pass the character I read to the function that checks the
> bit mask the check fails.
>
> Is there any special way to read one byte at a time?
>
> I am using read(filehandle,$input,1) function call in a while loop
> where input is the scalar variable and filehandle is the handle returned
> by the open call.
>
> Srikanth



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

Date: Mon, 16 Nov 1998 19:11:13 GMT
From: meaw@my-dejanews.com
Subject: Re: Not to start a language war but..
Message-Id: <72ptcg$u8m$1@nnrp1.dejanews.com>

In article <909714669.18796@thrush.omix.com>,
  Zenin <zenin@bawdycaste.org> wrote:

> 	Ya seen JPL yet?  Forget dispatching anything, just code Java
> 	methods in pure Perl! :-)

Do you know if JPL is available for free? (I've seen it bundled with the
"perl resource kit" from Orielly but that costs money.) If it is free, where
do I get it?

Thanks for your help!
Meaw

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


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

Date: Mon, 16 Nov 1998 18:52:27 GMT
From: cpierce1@mail.ford.com (Clinton Pierce)
Subject: Re: Perl Usage Survey - interpretations, anyone?
Message-Id: <36567306.356299703@news.ford.com>

On Mon, 16 Nov 1998 10:09:36 -0800, rdm@cfcl.com (Rich Morin) wrote:
>  Top 10 most used platforms
>
>    Linux                 2697
>    Solaris               1872
>    Win 95, 98, NT        1754  <---
>    SunOS                 1006      |
> -> MacOS                  900      |
>    HP-UX                  628      |
>    Free-, Net-, OpenBSD   577      |
>    IRIX                   529      |
>    AIX                    455      |
>    DEC Unix, OSF/1        390      |
>                                    |
   -----------------------------------
  |
I'm just tickled to see the Win32 platforms so high on the list.
Maybe in the future Win32 users will get a little more respect
around here.  :-)  Maybe AOL people too.  (Me too!)


I may have clients who are Prisoners of Bill, but I've got my Get Out Of
Jail Free card--Perl.



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

Date: Mon, 16 Nov 1998 20:19:07 GMT
From: mila@stars.gsfc.nasa.gov
Subject: Re: perl/win95
Message-Id: <72q1bq$23f$1@nnrp1.dejanews.com>

Forrest,
   You can type perl hello.pl on the DOS command line. Either go to
the perl dir and type it from there. Or, if you have .pl associated with
perl.exe, it should work from any dir.

Cheers,
Mila Mitra
mila@remss.com

In article <364B3982.19EA7BFD@mail.utexas.edu>,
  dropzone@mail.utexas.edu wrote:
> Anyone know how to run a script on a Win 95  machine? In other words,
> _where_   do
> I type "perl hello.pl"?
>
>                                  Thanks, Forrest
>
>

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


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

Date: 16 Nov 1998 19:19:33 GMT
From: ada@fc.hp.com (Andrew Allen)
Subject: Re: Positional parameter support in perl printf
Message-Id: <72pts5$3fp@fcnews.fc.hp.com>

Srikanth Natarajan (nkanth@cnd.hp.com) wrote:
: Hi

: I want to know whether the printf in perl supports positional
: parameters in the format string something like that in C

: I mean in C printf("%2$d,%1$d\n", a, b) will print b,a
: and printf("%1$d,%2$d\n", a, b) will print a,b

: In perl can I do such stuff?

Seems simple enough. Here's a start:

sub psprintf
{
  my $format=shift @_;
  my(@pos);
  $format=~s{%(\d+)\$}{push(@pos,$1-1);'%'}ge;
  sprintf $format,@_[@pos],@_;
}

print psprintf('%2$d %3$d %1$d %d %d %d'."\n",1,2,3,4,5,6,7);

(I'm doing the "intuitive" thing if you mix %n$ and % specifiers, I
hope. This won't handle '%%2$' correctly, nor some other oddly-formed
constructs.)

Andrew


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

Date: Mon, 16 Nov 1998 19:08:29 +0000
From: Rob Hardy <rob.hardy@ndirect.co.uk>
Subject: regexp query: s//g not global
Message-Id: <3650782D.606765FD@NO-JUNK.ndirect.co.uk>

Hi,

I have the following:

my $b = '(?=^|\s+|$)';

# (this'll probably wrap when posted)
$test =~
s/$b(['"]?)(?![^AEIOUaeiou]+['"]?$b)([a-zA-Z][a-zA-Z']*"?)$b/$1.&x($2)/ge;

sub x { my ($a) = @_;
# Just for testing atm
return lc $a;
}


It seems that only the first occurence in the string is being matched. 
Any ideas?  Perhaps I should use a for loop and iterate instead.

Rob.
(Amend my address if replying by email)


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

Date: Mon, 16 Nov 1998 21:01:15 +0100
From: jwl@_munged_worldmusic.de (Joergen W. Lang)
Subject: Re: substitute
Message-Id: <1dilsqn.19xrw2xsm5l9wN@host056-210.seicom.net>

Todd Kempf <kempf.todd@student.uni-tuebingen.de> wrote:

> Hi,
> 
> I'm trying to change a list of characters into their hex counterparts.
> For example, to make a valid filename I have tried something like:
> 
> $vfn =~ s/\*\?\\\//%[A..F]/g;
> 
> and so on. I know, the above is just chicken scratch of what I've been
> trying to do. So the question is, how does one take a string such as
> "f*len?me" and turn it into something such as "f%3Elen%17me"? Any help
> is appreciated.
> 
> Todd

I thought they did not teach Perl in Tuebingen....
Mind if I tried ?

#!/usr/bin/perl -w

$vfn = "f*len?me";
@change_these_to_hex = ("*", "?", "\\", "/");

foreach (@change_these_to_hex)
{
    $subs =  uc "%".unpack "H*", $_;

    # change $_ into its hex representation
    # add percent sign
    # shift to uppercase

    $vfn  =~ s/\Q$_/$subs/g;

    # using \Q in regex to quote meta-signs (* ?...)
    # replace $_ with hex representation in $subs
}


print $vfn;

__END__

gives 
"f%2Alen%3Fme".

using "h" instead of "H" in unpack() gives:
"f%A2len%F3me"

Is that what you want ?

cheers,

  Joergen 

(who lives across the road from the Informatics building in Tuebingen
("Sand")...:-)
-- 
  To reply by email please remove _munged_ from address Thanks !
-------------------------------------------------------------------
   "Everything is possible - even sometimes the impossible"
             HOELDERLIN EXPRESS - "Touch the void"


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

Date: Mon, 16 Nov 1998 12:52:15 -0600
From: yong <yong@shell.com>
Subject: Re: syntax/doc question
Message-Id: <3650745F.B22977AE@shell.com>

Marty Landman wrote:

> print "elvis is alive\n"    if pingecho($hostname, timeout);
>
> I would like to know
>
> 1)    if an else block may be specified with this form of an if stmt,
> and how?

I don't think so.

Yong



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

Date: Mon, 16 Nov 1998 19:55:54 GMT
From: aml@world.std.com (Andrew M. Langmead)
Subject: Re: syntax/doc question
Message-Id: <F2J617.1Bz@world.std.com>

Marty Landman <marty@catnmoose.com> writes:

>1)    if an else block may be specified with this form of an if stmt,
>and how?

Not in combination with the if modifier, but if all you want is the
"else", you can use the "unless" instead of "if".

print "elvis is dead\n"    unless pingecho($hostname, timeout);

But you can't do both an if and else with the same modifier.

>2)    where the syntax for this particular form is shown in the Camel
>book or online

There is a part of the perlsyn man page that starts:

       Any simple statement may optionally be followed by a
       SINGLE modifier, just before the terminating semicolon (or
       block ending).  The possible modifiers are:
 
           if EXPR
           unless EXPR
           while EXPR
           until EXPR
           foreach EXPR
-- 
Andrew Langmead


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

Date: Mon, 16 Nov 1998 19:04:29 GMT
From: drummj@mail.mmc.org (Jeffrey R. Drumm)
Subject: Re: Unix to Win32 conversion
Message-Id: <36507314.606745533@news.mmc.org>

[ posted to comp.lang.perl.misc and a courtesy copy was mailed to the cited
author ]

On Mon, 16 Nov 1998 18:18:08 +0200, Basile Laderchi <killer@ath.forthnet.gr>
wrote:

>actually it has this:
>
>$date = `$date_command +"%D"`;
>$date =~ s/\n*$//;
>
>where $date_command = "/bin/date"

Why not:

my ($mon, $day, $year) = (localtime)[4, 3, 5];
$mon++; 				# 0-based index
$year = $year % 100; 			# not Y2K compliant, by
					# most definitions - "00" in 2000.
					# better would be:
					# $year = $year + 1900;

$date = sprintf ("%02i/%02i/%02i",$mon,$day,$year);

There. Now you don't need no steenkin' "date" command, and you've saved
yourself the considerable overhead Win32 charges for external processes.

-- 
                               Jeffrey R. Drumm, Systems Integration Specialist
                       Maine Medical Center - Medical Information Systems Group
                                                            drummj@mail.mmc.org
"Broken? Hell no! Uniquely implemented!" - me


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

Date: Mon, 16 Nov 1998 21:01:30 +0100
From: jwl@_munged_worldmusic.de (Joergen W. Lang)
Subject: Re: upper to lowercase
Message-Id: <1dilsxz.16d85pp11rl589N@host056-210.seicom.net>

_cim_ <cim@online.ee> wrote:

> I use this:
> 
> $text =~ tr/A-Z/a-z/;
> 
> to make the text lowercase, but it doesn't work with v d u | (and some
> other strange ones) - leaves them as they are.
> 
> help!

Please have a look at the following pieces of information - they should
hold the answer to your question.

perldoc -f lc
perldoc perllocale

hth,

Joergen
-- 
  To reply by email please remove _munged_ from address Thanks !
-------------------------------------------------------------------
   "Everything is possible - even sometimes the impossible"
             HOELDERLIN EXPRESS - "Touch the void"


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

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


Administrivia:

Special notice: in a few days, the new group comp.lang.perl.moderated
should be formed. I would rather not support two different groups, and I
know of no other plans to create a digested moderated group. This leaves
me with two options: 1) keep on with this group 2) change to the
moderated one.

If you have opinions on this, send them to
perl-users-request@ruby.oce.orst.edu. 


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

	subscribe perl-users
or:
	unsubscribe perl-users

to almanac@ruby.oce.orst.edu.  

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

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

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

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

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

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


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

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