[11147] in Perl-Users-Digest

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

Perl-Users Digest, Issue: 4747 Volume: 8

daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Mon Jan 25 19:07:20 1999

Date: Mon, 25 Jan 99 16:00:20 -0800
From: Perl-Users Digest <Perl-Users-Request@ruby.OCE.ORST.EDU>
To: Perl-Users@ruby.OCE.ORST.EDU (Perl-Users Digest)

Perl-Users Digest           Mon, 25 Jan 1999     Volume: 8 Number: 4747

Today's topics:
    Re: Can you pattern match using an array? <kimntodd@dontspamus.execpc.com>
        CDDA Access? <amcleod@caribSPAMsurf.com>
    Re: Execute of Program on Server (Alastair)
        getprotobyname() problems <jbuckley@verity.com>
    Re: Getting the last number in an IP addr with a regex. <tripp.lilley@perspex.com>
    Re: Help compiling Perl w/ threads on Linux (Alastair)
        help with HTML FORMS to ARRAYS, PLEASE? <paxtond@ix.netcom.com>
    Re: help with HTML FORMS to ARRAYS, PLEASE? <ludlow@us.ibm.com>
    Re: How do I split this string? aqumsieh@matrox.com
    Re: How long would the Unixes last without Perl? <kperrier@blkbox.com>
    Re: How long would the Unixes last without Perl? <kperrier@blkbox.com>
    Re: How long would the Unixes last without Perl? (K. Krueger)
    Re: How long would the Unixes last without Perl? <dgris@moiraine.dimensional.com>
    Re: How long would the Unixes last without Perl? <dgris@moiraine.dimensional.com>
    Re: How to calculate time difference? (Larry Rosler)
        Insecure dependecies in File::Find & File::Path? remnants@my-dejanews.com
    Re: libwww and broken pipe? (I R A Aggie)
    Re: MacPerl crashes when another process hogs the CPU f psu22377@my-dejanews.com
        Printing back gif-file (counter) (Marc-A. Woog)
    Re: Printing back gif-file (counter) <staffan@ngb.se>
    Re: sorting dates <jacklam@math.uio.no>
    Re: spread rows from a huge textfile? ThorstenBelka@gmx.de
    Re: sysread.... /n help????? (J Holden)
        Using setpgrp with open jslater7193@my-dejanews.com
        Version Check <nrd1mmc@nrd.ups.com>
    Re: Version Check (Alastair)
    Re: Why do these two programs give different results? (Larry Rosler)
    Re: Y2K? dhosek@webley.com
        Special: Digest Administrivia (Last modified: 12 Dec 98 (Perl-Users-Digest Admin)

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

Date: Mon, 25 Jan 1999 17:51:21 -0600
From: "End User" <kimntodd@dontspamus.execpc.com>
Subject: Re: Can you pattern match using an array?
Message-Id: <78ivvb$725$1@news1-alterdial.uu.net>

I would think that you could, but it wouldnt be as clean as what you are
proposing.

Such that:

@array = <STDIN>;
while (defined($line=<STDIN>)){
    foreach $array(@array) {
        $s = substr(/$array/,$line);
        if ($s =~ /$string/i){
            do something here}
                            }




It should compare


Bob Freedman wrote in message <36AC8DC9.66C04D87@esdim.noaa.gov>...
>Can you match a pattern using an array of strings?
>
>if (/@key/i) {....
>




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

Date: Mon, 25 Jan 1999 16:49:42 -0400 (AST)
From: "Angus McLeod" <amcleod@caribSPAMsurf.com>
Subject: CDDA Access?
Message-Id: <nzpyrbqpnevofhespbz.f64xyu0.pminews@news.caribsurf.com>

Is there any code around to assist in accessing the internet CDDA servers?




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

Date: Mon, 25 Jan 1999 23:45:15 GMT
From: alastair@calliope.demon.co.uk (Alastair)
Subject: Re: Execute of Program on Server
Message-Id: <slrn7aq0hu.59.alastair@calliope.demon.co.uk>

Kevin Keil <kevink@NOSPAMinfograph.com> wrote:
>I setup a new server that I want to execute a .exe program. It is giving me
>a "CGI Error."

Who cares. Stop crossposting.

-- 

Alastair
work  : alastair@psoft.co.uk
home  : alastair@calliope.demon.co.uk


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

Date: Mon, 25 Jan 1999 18:04:50 -0500
From: Jeremy Buckley <jbuckley@verity.com>
Subject: getprotobyname() problems
Message-Id: <36ACF892.735C18F2@verity.com>

I'm hitting some  performance problems running Perl socket code on AIX
4.1.5, and have narrowed  it down to the getprotobyname() calls in the
IO modules.  The first call to this function takes a very long time
(more than 30 seconds) to return, but does come back with the correct
information.  Subsequent calls are very fast.  The system I'm working on
does not have DNS configured, but the /etc files (/etc/protocols in
particular) are there and readable.  My Perl is 5.004.  Any ideas what
might be going on?  Please copy email.

Thanks.




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

Date: Mon, 25 Jan 1999 17:36:04 -0500
From: Tripp Lilley <tripp.lilley@perspex.com>
Subject: Re: Getting the last number in an IP addr with a regex.
Message-Id: <36ACF1D4.3C1FBCC3@perspex.com>

"Allan M. Due" wrote:
> 
> Well I still don't know what the actual permissable IP range is so I have two
> assumptions.
> 
> 1) you can't have multiple 0s between dots by themseleves.  Thus
> 112.000.000.12 is not permissable.  Then we might piggyback on Mikes near miss
> and use

The "typical" representation of an IP address is something known as
"dotted-decimal" or "dotted-quad" notation. Four numbers, each 0 - 255,
separated by dots. Treating each of those numbers as a byte in a
four-byte, MSB -> LSB (left to right) value will yield the 32-bit IP
address.

The notion of "validity" for an IP address has several levels. There is
"validity" in the sense that it resolves to a 32-bit integer value.
There is "validity" in the sense that the 32-bit integer value might be
a meaningful address within the context of a given subnet. There is
"validity" in the sense that the 32-bit integer might be a valid
multicast address. There is "validity" in the sense that the 32-bit
integer might be a network address, not a host address.

Point is, the "validity" of the address depends a lot on the context :-)
Sadly. This whole thread is causing me to cringe at the prospect of how
much code I have to add to my "lean" IPv4 address conversion module that
was almost ready for primetime. <sigh>

BTW: "112.000.000.12" is 'valid' under a certain set of constraints
(particularly, if the owner of the 112.0.0.0/8 network either has not
subnetted the network :-), or if they have gear that won't barf at the
prospect of routing to a "0" subnet).


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

Date: Mon, 25 Jan 1999 23:43:30 GMT
From: alastair@calliope.demon.co.uk (Alastair)
Subject: Re: Help compiling Perl w/ threads on Linux
Message-Id: <slrn7aq0ce.59.alastair@calliope.demon.co.uk>

alex@digitalfoundry.com <alex@digitalfoundry.com> wrote:
>I've tried compiling both the latest stable and dev sources with threads and
>get errors with both.  I am running Linux 2.0.35 and gcc 2.7.2.3  I haven't
>had much experience so excuse any ignorance.  I have searched hi and low for
>help on threads before posting.  Anyone have any pointers to resources I can
>use?

If you posted some error messages then maybe someone might know what the problem
is.

-- 

Alastair
work  : alastair@psoft.co.uk
home  : alastair@calliope.demon.co.uk


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

Date: Mon, 25 Jan 1999 17:55:18 -0500
From: Danny Paxton <paxtond@ix.netcom.com>
Subject: help with HTML FORMS to ARRAYS, PLEASE?
Message-Id: <36ACF652.C2C6FB38@ix.netcom.com>

I want to take a string of letters from an HTML form say:
ABCBBBDCEADAAAEC...etc and put them in an array with each individual
letter taking up a single location.  What would the code be?  The reason
that I want it to be this way is that the Form will just be a way for a
data entry person to enter scoring from a test and the easiest way for
them is to enter them as a string without any commas, etc.  Then, of
course, I want to be able to score the test (each letter actually will
represent a particular number associated with the letter and the
particular location in the array) and send an email response and write
the result to a file (these two present no problem for me).



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

Date: Mon, 25 Jan 1999 17:13:51 -0600
From: James Ludlow <ludlow@us.ibm.com>
Subject: Re: help with HTML FORMS to ARRAYS, PLEASE?
Message-Id: <36ACFAAF.D2514C46@us.ibm.com>

Danny Paxton wrote:
 
> I want to take a string of letters from an HTML form say:
> ABCBBBDCEADAAAEC...etc and put them in an array with each individual
> letter taking up a single location.  What would the code be?  The reason

$ perldoc -f split

-- 
James Ludlow (ludlow@us.ibm.com)
(Any opinions expressed are my own, not necessarily those of IBM)


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

Date: Mon, 25 Jan 1999 22:56:50 GMT
From: aqumsieh@matrox.com
Subject: Re: How do I split this string?
Message-Id: <78isrd$e66$1@nnrp1.dejanews.com>

In article <36ABD993.56369F44@_usa_.net>,
  Murali Ravipudi <myparu@_usa_.net> wrote:
> I would :
>
>   $string="inet addr:.................";
>   split / /,$string; shift; $string = shift; split /:/, $string; shift;
>   $result=shift;
>
> comments....

That is just silly and complicated ... besides, the use of implicit split to
@_ is deprecated and shouldn't be used anymore.

why not just:

@ary = (/:(\S+)/g);

$ary[0] will now contain the fist ip, $ary[1] the second .. and so on..

>
> murali
>
> Ken Williams wrote:
> >
> > inet addr:192.168.0.1  Bcast:192.168.0.255  Mask:255.255.255.0
> >
> > The above is from ifconfig.  I need to pull the IP's out.  Specifically the
> > first.  How do I split with a starting character of : and an ending
character
> > of space?

Ala

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


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

Date: 25 Jan 1999 16:23:26 -0600
From: Kent Perrier <kperrier@blkbox.com>
Subject: Re: How long would the Unixes last without Perl?
Message-Id: <ysi1zkjm1pd.fsf@blkbox.com>

abigail@fnx.com (Abigail) writes:

> Kent Perrier (kperrier@blkbox.com) wrote on MCMLXXII September MCMXCIII
> in <URL:news:ysiaez9l1o8.fsf@blkbox.com>:
> !! abigail@fnx.com (Abigail) writes:
> !! 
> !! > Doesn't HP ship perl4 by default? And doesn't RedHat come with some
> !! > form of Perl?
> !! > 
> !! 
> !! I don't have any experience with HP-UX and I don't consider RedHat a 
> !! commercial unix.
> 
> 
> What's your definition of a commercial Unix then?
> 

The ability to purchase a machine with the OS preinstalled and I have the 
option of purchasing 24x7 support from someone (preferrable the HW vendor)
with monetary strings attached for level of service.  As I stated in a
previous post, this is coming to Linux, its just not here yet.

Kent


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

Date: 25 Jan 1999 16:20:35 -0600
From: Kent Perrier <kperrier@blkbox.com>
Subject: Re: How long would the Unixes last without Perl?
Message-Id: <ysi3e4zm1u4.fsf@blkbox.com>

Daniel Grisinger <dgris@moiraine.dimensional.com> writes:

> Kent Perrier <kperrier@blkbox.com> writes:
> 
> >                                            I don't consider RedHat a 
> > commercial unix.
> 
> Ummmmm.... so is it not unix, or not commercial?
> 

I don't consider it commercial.  This is rapidly changing, though.  With 
both Compaq and IBM coming out and providing commercial support the distinction
between commercial and not commercial is bluring.

Kent


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

Date: 25 Jan 1999 14:50:54 -0800
From: kirbyk@best.com (K. Krueger)
Subject: Re: How long would the Unixes last without Perl?
Message-Id: <78isge$465$1@shell2.ba.best.com>

In article <ysi1zkjm1pd.fsf@blkbox.com>,
Kent Perrier  <kperrier@blkbox.com> wrote:
>> 
>> What's your definition of a commercial Unix then?
>
>The ability to purchase a machine with the OS preinstalled and I have the 
>option of purchasing 24x7 support from someone (preferrable the HW vendor)
>with monetary strings attached for level of service.  As I stated in a
>previous post, this is coming to Linux, its just not here yet.
>
You might want to get a little more caught up on the times, then, and
check out:
http://www.varesearch.com/

Looks to me like what you're looking for.  (And I have no vested interest
in the company.  In fact, technically, I have a vested interest against
the company, but that's hardly my fault.)

This has little to do with Perl, by this point. Apologies.

-- 
Kirby Krueger      O-     kirbyk@best.com 
<*> "Most .sigs this small can't open their own jump gate."


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

Date: 25 Jan 1999 16:16:16 -0700
From: Daniel Grisinger <dgris@moiraine.dimensional.com>
Subject: Re: How long would the Unixes last without Perl?
Message-Id: <m34spfgczj.fsf@moiraine.dimensional.com>

dhosek@webley.com writes:

> I'd define a commercial Unix as one which you cannot get for free 

Well, now that Solaris has been deemed non-commercial I'd have to
say that linux undoubtedly beats the hell out of all of the
commercial unixes. :-)

Seriously, if it is sold it is, by definition, commercial.  Maintaining
that it isn't is some form of Newspeak that serves no purpose other
than obfuscating communication.

Remember, proprietary and commercial are not synonymous.

dgris
-- 
Daniel Grisinger          dgris@moiraine.dimensional.com
perl -Mre=eval -e'$_=shift;;@[=split//;;$,=qq;\n;;;print 
m;(.{$-}(?{$-++}));,q;;while$-<=@[;;' 'Just Another Perl Hacker'


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

Date: 25 Jan 1999 16:36:11 -0700
From: Daniel Grisinger <dgris@moiraine.dimensional.com>
Subject: Re: How long would the Unixes last without Perl?
Message-Id: <m3zp77exhw.fsf@moiraine.dimensional.com>

Kent Perrier <kperrier@blkbox.com> writes:

> Daniel Grisinger <dgris@moiraine.dimensional.com> writes:
> > Kent Perrier <kperrier@blkbox.com> writes:
> > >                                            I don't consider RedHat a 
> > > commercial unix.

> > Ummmmm.... so is it not unix, or not commercial?

> I don't consider it commercial.

It must be nice to go through life disregarding inconvenient things
like what the words you use actually mean.  It must be much easier to
just be able to say random things and then redefine all of the terms
until they mean what you wanted.

To make it more explicit- by definition, if something is produced
and sold for a profit, it is commercial.  It doesn't matter what
_you_ consider it, it doesn't matter that the source is available 
or that it can be had for free.  The fact that it is sold for a 
profit leaves no room for interpretation or equivocation.

Red Hat is commercial.  Period.

dgris
-- 
Daniel Grisinger          dgris@moiraine.dimensional.com
perl -Mre=eval -e'$_=shift;;@[=split//;;$,=qq;\n;;;print 
m;(.{$-}(?{$-++}));,q;;while$-<=@[;;' 'Just Another Perl Hacker'


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

Date: Mon, 25 Jan 1999 14:26:59 -0800
From: lr@hpl.hp.com (Larry Rosler)
Subject: Re: How to calculate time difference?
Message-Id: <MPG.11168f92fcf123299899c5@nntp.hpl.hp.com>

[Posted and a courtesy copy mailed.]

In article <78ikdn$6ni$1@nnrp1.dejanews.com> on Mon, 25 Jan 1999 
20:32:55 GMT, g200@my-dejanews.com <g200@my-dejanews.com> says...
 ...
> I have a list of strings like:
> 
> YYMMDD HHmmss
> --------------------
> 990101 010101 start job1
> 990101 120151 end job1
> 990102 225959 start job2
> ...
> -----------------------
> 
> I like to calculate the time-span in job1, job2....
> I am thinking of transfer the start, and end timestamp into
> 'epoch sec', then i can do the math.
> but How could i use perl functions (time, localtime...)
> to convert the "YYMMDD HHMMSS" into epoch sec?
> I hope i don't need any "module" because
> my system adm won't feel happy about installing any 'optional'
> stuffs....

You don't need no steenkin' modules!  (And you just turned off most of 
the Time::Local answers :-)

I posted a short snippet recently that you can adapt for this purpose.  
Look it up under my name using DejaNews, possible keyword 'localtime'.

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


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

Date: Mon, 25 Jan 1999 22:42:57 GMT
From: remnants@my-dejanews.com
Subject: Insecure dependecies in File::Find & File::Path?
Message-Id: <78is1f$dfe$1@nnrp1.dejanews.com>

Hi--

I'm trying to use File::Find and File::Path in scripts with taint check-
ing enabled and keep running into 'Insecure dependency' errors with the
fragments of perl included below.

Does anyone know a way around this in a taint-happy fashion, short of
growing my own routines or hacking the modules to untaint files or dirs
I don't explicitly name?

TIA!

    perl5 -wT -MFile::Find -e '$ENV{PATH} = "/bin";' \
      -e 'sub wanted { print $File::Find::name, "\n" if -d }' \
      -e 'find( \&wanted, "/tmp" );'

 ... gets me ...

    Insecure dependency in chdir while running with -T switch
    at /usr/local/lib/perl5/5.00502/File/Find.pm line 133.

 ... while ...

    perl5 -wT -MFile::Path -e '$ENV{PATH} = "/bin";' \
      -e 'rmtree(["/tmp/1/2/3/4/5"],0,1)'

 ... works fine if the directory '5' is empty, but returns one of
the following if a file or sub-directories exist anywhere under
'5' ...

    Insecure dependency in unlink while running with -T switch at
    /usr/local/lib/perl5/5.00502/File/Path.pm line 210.

    Insecure dependency in rmdir while running with -T switch at
    /usr/local/lib/perl5/5.00502/File/Path.pm line 188.

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


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

Date: Mon, 25 Jan 1999 17:04:30 -0500
From: fl_aggie@thepentagon.com (I R A Aggie)
Subject: Re: libwww and broken pipe?
Message-Id: <fl_aggie-2501991704300001@aggie.coaps.fsu.edu>

In article <78if4k$1sr$1@nnrp1.dejanews.com>, ftn@yesbox.net wrote:

+ If I try to get a page I get (very often) Broke pipe, and the program dies,
+ I've tried both get in LWP::Simple and
+ LWP::UserAgent

Could you show us a bit of code? just enough to allow someone to replicate
your problem?

+ right now I use `lynx -source $url` instead, but I would prefer using the
+ libwww (so I can simulate being mozilla 4 or something,

You also get to avoid spawning two more processes. Have you tried using
`lwp-download $url`?

+ since some webpages
+ just sends an annoying message that I should get a better browser)

Someone should write a 'bot to send nastygrams to those webmasters that
they need a better brand of content... :\

James


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

Date: Mon, 25 Jan 1999 22:54:56 GMT
From: psu22377@my-dejanews.com
Subject: Re: MacPerl crashes when another process hogs the CPU for too long
Message-Id: <78isnr$e2a$1@nnrp1.dejanews.com>

In article <schinder-2201992037080001@schinder.clark.net>,
  schinder@leprss.gsfc.nasa.gov wrote:
> In article <36a8d23c.87730940@news.uswest.net>, psu22377@odin.cc.pdx.edu
wrote:
>
> }  Running MacPerl 5.2.0r4 on a Power Mac G3 233 w/128Mb RAM, running
> }  MacOS
> }  8.5
> }
> }  I have a perl script that launches an application, then periodically
> }  checks to see if that launched process has exited.  The application is
> }  standard ANSI C++, and so the way it runs on MacOS, the launched
> }  application does not yield back any processor time.  The whole
> }  machine, including Perl, is essentially "frozen" while the launched
> }  application runs (MacPerl does not get any processor time, not even
> }  enough to update it's spinning cursor).  When the application exits,
> }  MacPerl gets some processor time once again and continues to run the
> }  script.
> }
> }  The problem comes if the application runs for upwards of an hour
> }  before exit.  This means that basically MacPerl is suspended for about
> }  an hour. MacPerl crashes with a Type 1, Type 3 or a Type 11 error.  Is
> }  there any reason why MacPerl, if "suspended" by another process
> }  hogging the CPU, would crash? I downloaded the source for MacPerl and
> }  looked around the main event loop. Is there anything with a call to
> }  sleep() that might result in a problem if perl was suspended then
> }  resume an several hours later?
> }
> }  The perl script launches the C++ application in parallel with
> }  Mac::Processes, LaunchApplication.  the process hash %Processes is
> }  used to check whether the application is running or not.
> }
> }  the CPU, the more likely for MacPerl to crash when it finally gets
> }  some CPU time.
> }
> }  the perl script had a while loop checking if the processes exited,
> }  with a call to sleep from perl (i.e. sleep 10;) before continuing in
> }  the while loop.  Could the command sleep, if MacPerl were frozen in
> }  the middle of execution of a perl script's "sleep" for a few hours,
> }  would MacPerl possibly crash on regaining processor time?
> }
> }  I was thinking that maybe there would be some kind of overflow problem
> }  if MacPerl was trying to return how many seconds were actually "slept"
> }  if it were frozen for a long time.
>
> Two things come to mind, although neither may be the real problem.  First,
> are you sure your C++ application stays in it's own playpen?  It may be
> walking on MacPerl's memory while it's running.  Second, are you sure
> MacPerl has a big enough memory partition?  If you use modules at all (and
> you are), you need more than MacPerl is configured to ask for out of the
> box.  Until recently, I gave MacPerl 7.5 Mb, now I give it 30Mb.  MacPerl
> running out of memory isn't a pretty sight.
>

Thanks for the reply Paul.
1. fairly certain that the C++ app is not misbehaving. It is cross platform
code that has been tested on multiple platforms for leaks and overwrites.

2. on the second point, you may be on to something.  Out of box, MacPerl seems
to be running with 4Mb allocated.  The perl script makes use of several
modules, and it seems like MacPerl does run pretty close to its out of box 4Mb
limit when running the script.  That is a very good point - will up the limit
much higher. Thanks!

3. the c++ app was changed to use period calls to 'cout' during its
execution, since the iostream implementation we are using on the Mac seems to
be written in a way that's friendly to cooperative multitasking, when the
stream is flushed.  Its kind of hackish, but at least it doesn't pollute the
cross platform code with mac specific code for yielding processor time.  It
allows MacPerl and even the Finder enough processor time to MacPerl to update
its spinning camel cursor, and enough time to Finder to actually update the
time on the clock.

Not sure if these changes have solved the problem yet, but they are certainly
a good start. Thanks for the help. Michael Ferrante
<psu22377@odin.cc.pdx.edu>


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


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

Date: Mon, 25 Jan 1999 21:50:54 GMT
From: mwoog@pobox.ch (Marc-A. Woog)
Subject: Printing back gif-file (counter)
Message-Id: <3731e6c9.3151578@news.datacomm.ch>

Hi,

I hope I didn't miss anything in the FAQ but I couldn't find anything
on this one:

HTML:
[...]
<IMG SRC="/cgi-bin/counter.cgi" WIDTH="0" HEIGHT="0"
[...]

counter.cgi:
[...]
open (GIFFILE, "$gif") || bail ("Couldn't open gif: $!");
binmode GIFFILE;
while (<GIFFILE>) { print $_; }
close(GIFFILE);
[...]
while $gif is a 1x1-picture.

But this doesn't quite work (the rest of the script does: no
"bailing") cause NS Navigator is showing the symbol for a not-existent
picture. To be more specific: it works on my windows machine but
doesn't on the unix server (even played around with chmod for the
gif). I am assuming that I am printing back a non-valid picture on
unix. How can I correct that?

Thanks for any help,

Marc


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

Date: Mon, 25 Jan 1999 23:01:03 +0100
From: Staffan Liljas <staffan@ngb.se>
Subject: Re: Printing back gif-file (counter)
Message-Id: <36ACE99F.67BD986F@ngb.se>

Marc-A. Woog wrote:
> I hope I didn't miss anything in the FAQ but I couldn't find anything
> on this one:

This is not a perl question.

> counter.cgi:
> [...]
> open (GIFFILE, "$gif") || bail ("Couldn't open gif: $!");
> binmode GIFFILE;
> while (<GIFFILE>) { print $_; }
> close(GIFFILE);
> [...]

Did you remember to output the correct header, ie saying
print "Content-Type: image/gif\n\n";
before starting to print the image?

If not -- that's where you are wrong. But if it is, this is not a perl
question.

Staffan


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

Date: Mon, 25 Jan 1999 19:49:43 +0100
From: Peter John Acklam <jacklam@math.uio.no>
Subject: Re: sorting dates
Message-Id: <36ACBCC7.9302F071@math.uio.no>

Eric Smith wrote:
> 
> I have a csv which contains a date field and I would like my
> script to sort the lines by the date field.
> 
> csv ->
> 29/09/98,this,that,theother
> 23/09/98,this,that,theother
> 23/04/98,this,that,theother

See perlfaq4 - How do I sort an array by (anything)? 

  #!perl -w

  print map { $_->[0] }
        sort { $b->[3] <=> $a->[3]
                        or
               $b->[2] <=> $a->[2]
                        or
               $b->[1] <=> $a->[1] }
        map { [ $_, m!^([^/]+)/([^/]+)/([^,]+)! ] }
        <>;

Peter

-- 
Peter J. Acklam - jacklam@math.uio.no - http://www.math.uio.no/~jacklam



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

Date: Mon, 25 Jan 1999 22:39:09 GMT
From: ThorstenBelka@gmx.de
To: gward@thrak.cnri.reston.va.us
Subject: Re: spread rows from a huge textfile?
Message-Id: <78irqb$dca$1@nnrp1.dejanews.com>

In article <77l7mm$8kt$1@news0-alterdial.uu.net>,
  gward@cnri.reston.va.us wrote:

>    LINE:
>    while (defined ($line = <INFILE>))
>    {
>       (write $line to file1), next LINE if ($line meets condition1);
>       (write $line to file2), next LINE if ($line meets condition2);
>       (write $line to file3), next LINE if ($line meets condition3);
>       (write $line to file4), next LINE if ($line meets condition4);
>    }
>
Dear Greg,

thanks alot for being so kind to help me ...but i didn4t understand how to
handle it with LINE.
I4m new to programming languages but i found a way to do what i ment.

require "profile3.txt";
 opendir (DVZ,"$cl1pc_target");

 @Array=grep(/access-.*/,readdir(DVZ));
 open (DIN,"directory.txt");
 @clkeys = <DIN>;
 close(DIN);
 $cl1logfile=$Array[0];

for($i=0; $i<=$#clkeys; $i++)
{
  chop ($clkeys[$i]);
  system("mkdir $cl1pc_target$clkeys[$i]");

}
  system("mkdir $cl1pc_target\\rest");
  open (DEFOUT,">>$cl1pc_target\\rest\\$cl1logfile");
  open (IN,"$cl1pc_target$cl1logfile");
  binmode (IN);
  @file = <IN>;
  close(IN);

  for ($k=0; $k<=$#file; $k++)
  {
	for($i=0; $i<=$#clkeys; $i++)
	{

  		if ($file[$k] =~ /\"GET \/$clkeys[$i]/)
  		{
  			open (OUT,">>$cl1pc_target$clkeys[$i]\\$cl1logfile");
  			print OUT $file[$k];
                        close OUT;
			last;
  		};
	};

  	if ($i== $#clkeys)
	{
		print DEFOUT $file[$k];
	};
};

This may be not the most performant way....but it works;-)
I think it would be more performant if it wouldnt open and close the OUT-Files
this often but i didn4t found a way to tell PRINT to which File to print to.

Mabe someone knows how?

Thorsten Belka

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


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

Date: Mon, 25 Jan 1999 22:13:08 GMT
From: jholden@voyager.net (J Holden)
Subject: Re: sysread.... /n help?????
Message-Id: <78iq9o$g63@news.voyager.net>

could do it like this....

open (FILE, "< $file");
$i=0;
while ($data[$i] = <FILE>) {
comp($data[$i]);
$i++;
}

J

On Mon, 25 Jan 1999 13:44:28 GMT, mikeob@itas.netnospam (Gigatron)
wrote:

>
>Hello All,
>
>I would like to read one line at a time in a text file. Say I have
>five lines, each line ending with /n
>I will use sysread to read the text file until it finds /n 
>After finding the occurance of the first /n I am confused as how to
>proceed. At this point I want to take the first line data and stick it
>in a scalar. 
>
>How can perl achieve this?



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

Date: Mon, 25 Jan 1999 22:37:52 GMT
From: jslater7193@my-dejanews.com
Subject: Using setpgrp with open
Message-Id: <78irnv$dbd$1@nnrp1.dejanews.com>



  If anyone can help me figure this out, I would really
appreciate it.

  I need to open a process from my perl (perl -v =
"version 5.004_04 built for sun4-solaris") program. I need
to read both STDERR and STDOUT from the process. I need
to process the data from the process while it is running.
I can't wait for the process to complete since it may
run for several hours.

I would typically do this using shell redirection and
open:

   open ("process 2>&1 |");

  However, I also want to put the process I am opening
into a separate process group (using setpgrp or
POSIX::setpgid).

  I can't seem to get the process to be in the proper
process group and use the shell redirection at the same
time.

  # This code works, process group gets set
  $pid = open("process |");  # Note redirection is turned off
  setpgrp($pid, $pid);

  # This code doesn't work...
  $pid = open("process 2>&1 |"); # Note shell redirection is on.
  setpgrp($pid, $pid);

  # This code also fails to set the process group...
  $pid = open("/usr/bin/process |"); # Going to the shell again?
  setpgrp($pid, $pid);

  In the second example perl appears to be happy, but the
  process $pid does not get a new process group, it stays
  in the parent perl script process group. Apparently there
  is something going on with the shell that is causing
  me problems.

  Any ideas and/or suggestions? I've looked at some FAQs and
  read through the perlipc man page, but I'm still missing
  something.

   Thanks.


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


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

Date: Mon, 25 Jan 1999 17:20:08 -0500
From: "Murtuza Chhil" <nrd1mmc@nrd.ups.com>
Subject: Version Check
Message-Id: <78iqmq$4343@biko.telecom.ups.com>

Hi,
Is there any way I could check the version of a dll or ocx , so that I do
not overwrite a newer version with an older one...

Thanx Chhil




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

Date: Mon, 25 Jan 1999 23:40:52 GMT
From: alastair@calliope.demon.co.uk (Alastair)
Subject: Re: Version Check
Message-Id: <slrn7aq09n.59.alastair@calliope.demon.co.uk>

Murtuza Chhil <nrd1mmc@nrd.ups.com> wrote:
>Hi,
>Is there any way I could check the version of a dll or ocx , so that I do
>not overwrite a newer version with an older one...

Don't know. What's your perl question?

-- 

Alastair
work  : alastair@psoft.co.uk
home  : alastair@calliope.demon.co.uk


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

Date: Mon, 25 Jan 1999 14:19:19 -0800
From: lr@hpl.hp.com (Larry Rosler)
Subject: Re: Why do these two programs give different results?
Message-Id: <MPG.11168dc6258837539899c4@nntp.hpl.hp.com>

In article <36ACD166.3C4C@bayou.uh.edu> on Mon, 25 Jan 1999 14:17:42 -
0600, Zhengdong Zhang <zzhang@bayou.uh.edu> says...
> I wrote the following two programs as a practice. Both of them list all
> the files in a specified directory. To exclude the subdirectories I used
> " next if -d; " in both programs. But it works only in the first. I can
> not figure out the reason.
 ...
> chdir $dir || die "cannot cd to $dir: $!";
> print "The files in the directory $dir are:\n";
> foreach (sort <.*>)
> {
>    next if -d;
>    print "$_\n";
> }

The glob returns filenames only, not paths.  The chdir on the first 
program makes $_, the default argument of '-d', be interpreted relative 
to the current directory.  Your second program does not have the 'chdir' 
statement, so you must explicitly make the argument for '-d' absolute.

     next if -d "$dir/$_";

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


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

Date: Mon, 25 Jan 1999 20:30:22 GMT
From: dhosek@webley.com
Subject: Re: Y2K?
Message-Id: <78ik8v$6k0$1@nnrp1.dejanews.com>

In article <78b38j$pkn$1@client2.news.psi.net>,
  abigail@fnx.com wrote:
> dhosek@webley.com (dhosek@webley.com) wrote on MCMLXX September MCMXCIII
> in <URL:news:78aah9$3mp$1@nnrp1.dejanews.com>:

> \\ The fact that the localtime function returns a year in 2-digit format
> \\ confuses a lot of people who assume that this means that it will return 00
> \\ for the year 2000. It will, in fact return 100 for the year 2000. To
convert
> \\ a year to 4-digit format (which presumably was the source of the original
> \\ poster's concern), it is adequate to simply add 1900 to the year. On the

> Yes. But if you compare two dates, it doesn't matter whether you add 1900
> on both sides or not....

But since one date came from an external source, you want to make sure that
the date derived from localtime matches the format of the other date.
Apologies if I was unclear about what I was saying.

> \\ other hand, if you're still using a 32-bit system in the year 2038, Unix
date
> \\ functions in general will fail (or at least those that use seconds since
> \\ 1970).

> 64-bits aren't the answer for that. I've 64-bit hardware, and a 64-bit
> OS, but my time still wraps in 2038. The problem isn't the hardware or
> the OS. The year 2038 problem is exactly the same as with Y2K: external
> storage and synchronisation.

The claim is that by the year 2038, our systems will use 64-bit ints and thus
the appropriate system calls will return a 64-bit value. Of course
compatibility with older software might dictate continued use of 32-bit ints
and there will be a serious problem with Unix in 2038. So I suppose we'll
want to hang on to the leftover shotgun shells and canned food once we make
it through the Y2K apocolypse.

-dh

Todays Y2K tip: stock up on canned food a little bit at a time over the next
11 months. If your neighbors see you loading your pantry with canned goods in
December, they'll come to your door first when the apocolypse comes.

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


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

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


Administrivia:

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

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

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

	subscribe perl-users
or:
	unsubscribe perl-users

to almanac@ruby.oce.orst.edu.  

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

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

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

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

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

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


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

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