[11101] in Perl-Users-Digest

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

Perl-Users Digest, Issue: 4701 Volume: 8

daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Wed Jan 20 18:05:44 1999

Date: Wed, 20 Jan 99 15:00:25 -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           Wed, 20 Jan 1999     Volume: 8 Number: 4701

Today's topics:
        arbitrary precision arithmetic <denny.john@btinternet.com>
        Background Processes. <mwatkins@promotion4free.com>
    Re: Calculate next [mon..sun]day msm@iweb.net
        email a form <bsherry@lucent.com>
    Re: email a form (Steve Linberg)
    Re: Example of Perl Cookie Implementation please dhosek@webley.com
    Re: Example of Perl Cookie Implementation please <ahongun@ecsysinc.com>
    Re: Example of Perl Cookie Implementation please (Donald L. Nash)
    Re: flock <ramune@zarathustra.calstatela.edu>
    Re: flock (Martien Verbruggen)
    Re: Help with regular expression (Greg Ward)
        Help: need to check file not being written <djc@ppp.co.uk>
    Re: How to get IP address of a local machine under NT <samuel.patton@wichita.boeing.com>
        Newbie string question,  please help :) <no_spam@no_spam.com>
    Re: Newbie string question,  please help :) <denny.john@btinternet.com>
    Re: Newbie string question,  please help :) (Sean McAfee)
    Re: Open File Detect (Greg Ward)
    Re: Open File Detect <spam.me@idea.co.uk>
    Re: Perl problem :(Offline mode... <andrewf@beausys.demon.co.uk>
    Re: Perl to C++ converter? <Savage.Ron.RS@bhp.com.au>
    Re: Printing the return value from a subroutine? (Craig Berry)
    Re: Running scripts with differing parameters. (Greg Ward)
        Shared Memory Question: Why no separate attach? (Expert rkc@ll.mit.edu
        Sorting Alphanumeric <ergowolf@mindspring.com>
    Re: Sorting Alphanumeric <uri@ibnets.com>
    Re: subroutine return values (Bart Lateur)
    Re: text indexes from lists (Martien Verbruggen)
        US jobs/JAVA, C++, Perl (Garynlang)
        write is trimming trailing blanks? <rrl@mail.com>
    Re: write is trimming trailing blanks? (Martien Verbruggen)
    Re: Year 2038 problem (Craig Berry)
        Special: Digest Administrivia (Last modified: 12 Dec 98 (Perl-Users-Digest Admin)

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

Date: Wed, 20 Jan 1999 21:53:22 -0000
From: "Denny John" <denny.john@btinternet.com>
Subject: arbitrary precision arithmetic
Message-Id: <785j38$bff$1@uranium.btinternet.com>

I was checking out the arbitrary precision boast of perl by doing 100
factorial and noticed that this calculation goes awry after 22!
ie this

printf "%f\n" , 1124000727777607680000*23 ;

returns :

25852016738884978212864.000000


which is sort of fine except its missing four zeroes before the decimal
point. I was using perl 4 and 5.004.

Any ideas ? Can someone try this with perl 5.005xxx and tell me if it works
?

Thanks.

Denny John





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

Date: Wed, 20 Jan 1999 20:03:57 -0000
From: "Mike Watkins" <mwatkins@promotion4free.com>
Subject: Background Processes.
Message-Id: <#ElKr$KR#GA.261@ntdwwaaw.compuserve.com>

Hi there,

I'll try to make this short and to the point.  I'm trying to make a script
which contains a feature to e-mail all members.  Sometimes the script will
probably have to send over 3000 personalized e-mails.  I'm trying to figure
out how I can show a "Currently Sending E-Mail" screen while the script is
sending the e-mail in the background.

Here's the code I have right now:

    foreach $line (@InputInfo) {
        @input = split (/\|/, $line);
        my $addr = $input[$EmailField];
        &MailInProgress;
        &MailMsg($addr, $FromName, $FromEmail, $line, @Message);
    }

&MailInProgress, just opens up an HTML file, and prints everything in the
file to the screen.  &MailMsg sends the e-mail message.  The only thing I'm
having trouble with is that the script waits until after it's done sending
the e-mail to display the &MailInProgress page, then it displays it once for
everytime it sends the e-mail!

Any help would be much appreciated.
Mike Watkins
mailto:mwatkins@3dmail.com






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

Date: Wed, 20 Jan 1999 22:01:58 GMT
From: msm@iweb.net
Subject: Re: Calculate next [mon..sun]day
Message-Id: <785jof$1dt$1@nnrp1.dejanews.com>

I love Date::Manip!

Install it and read the docs. You can calulate just about anything - date
delta, business days, holidays, and more.

Mike

In article <77vpeo$un8$1@nnrp1.dejanews.com>,
  marcel_anthonijsz@my-dejanews.com wrote:
> Hi,
>
> I want to calculate the date of next [mon..sun]day, what is the easiest and
> most nice way to do this? It should work after the year 0 .. (Hey, my brain
> has a Y2K bug!).
>
> Thanks,
>
> Marcel
>
> -----------== Posted via Deja News, The Discussion Network ==----------
> http://www.dejanews.com/       Search, Read, Discuss, or Start Your Own
>

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


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

Date: Wed, 20 Jan 1999 17:24:20 -0600
From: "Bill Sherry" <bsherry@lucent.com>
Subject: email a form
Message-Id: <785l0j$36@nntpb.cb.lucent.com>

I have a need to email an HTML form that a user has filled out.

I know how to create the form with HTML, I do not know how to write a script
that will extract the data from the form so that it can be emailed to
another person.

Is there software that will create the script form the form?

I have a NT server that I am using for the Web site. Most of the material I
see speaks to UNIX.


Signed,
Not a programmer




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

Date: Wed, 20 Jan 1999 17:40:37 -0500
From: linberg@literacy.upenn.edu (Steve Linberg)
Subject: Re: email a form
Message-Id: <linberg-2001991740370001@ltl1.literacy.upenn.edu>

In article <785l0j$36@nntpb.cb.lucent.com>, "Bill Sherry"
<bsherry@lucent.com> wrote:

> I have a need to email an HTML form that a user has filled out.
> 
> I know how to create the form with HTML, I do not know how to write a script
> that will extract the data from the form so that it can be emailed to
> another person.
> 
> Is there software that will create the script form the form?
> 
> I have a NT server that I am using for the Web site. Most of the material I
> see speaks to UNIX.

You can use a MAILTO: action for the form; it will mail the form's
contents to whomever you specify, although it will be escaped in the
manner URLs are.  It's readable, but you may want a decoder for the other
end.

NT lacks sendmail.  In the latest service pack there is a method for
mailing, but if you're on SP3 you'll have to use third-party software. 
There are several available; check the ms server newsgroups.

-- 
Steve Linberg, Systems Programmer &c.
National Center on Adult Literacy, University of Pennsylvania
email: <linberg@literacy.upenn.edu>
WWW: <http://www.literacyonline.org>


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

Date: Wed, 20 Jan 1999 19:43:12 GMT
From: dhosek@webley.com
Subject: Re: Example of Perl Cookie Implementation please
Message-Id: <785bke$pmc$1@nnrp1.dejanews.com>

In article <36a60631.1769028@news.enteract.com>,
  syarbrou@nospam.enteract.com (Steve .) wrote:
> I want to have a script on my unix box that when someone fills out a
> form and submits it, the perl script will place a cookie on their
> system to let me know next time they come in that they filled out the
> form.

> Next time they come in, I want to be able to check for that cookie,
> and if it exists, redirect elsewhere.  I know how to do the redirect,
> but was hoping to see some real examples of using cookies in a perl
> script.  Thanks.

perldoc CGI will give you basic information. If you want something more
sophisticated, you can also look at perldoc CGI::Cookie

If you don't have perldoc on your system, you should fix that. But a quick
search on Yahoo for CGI.pm will turn up the perldoc CGI information as a web
page.

-dh

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


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

Date: Wed, 20 Jan 1999 13:13:24 -0800
From: "A. H. Ongun" <ahongun@ecsysinc.com>
Subject: Re: Example of Perl Cookie Implementation please
Message-Id: <785gel$ha9$1@news-2.news.gte.net>

Check cnet.com go to downloads select the development tools:source code
section.
There is a file called Cookie-lib.pl 0.911 that will help you.

Hope this helps,

Andy

Steve . wrote in message <36a60631.1769028@news.enteract.com>...
>I want to have a script on my unix box that when someone fills out a
>form and submits it, the perl script will place a cookie on their
>system to let me know next time they come in that they filled out the
>form.
>
>Next time they come in, I want to be able to check for that cookie,
>and if it exists, redirect elsewhere.  I know how to do the redirect,
>but was hoping to see some real examples of using cookies in a perl
>script.  Thanks.
>
>Steve




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

Date: Wed, 20 Jan 1999 15:35:36 -0600
From: D.Nash@utexas.edu (Donald L. Nash)
Subject: Re: Example of Perl Cookie Implementation please
Message-Id: <D.Nash-2001991535370001@bubba.ots.utexas.edu>

In article <19990120135432.04802.00000185@ng-ch1.aol.com>,
phelanp806@aol.com (PhelanP806) wrote:

>On a slightly more serious note, I think Steve can find what he's looking for
>in CPAN.  I don't do cookies from within Perl, but I'm pretty sure there is
>some code in one of the modules in CPAN that does.

I remember seeing a cookie module last time I poked around in CPAN.  That
was after I wrote my own cookie module, of course. :-(  Oh well.  Cookies
aren't that hard to deal with.

-- 
Donald L. Nash, <D.Nash@utexas.edu>, PGP Key ID: 0x689DA021
The University of Texas System Office of Telecommunication Services


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

Date: 20 Jan 1999 12:36:32 -0800
From: Graffiti <ramune@zarathustra.calstatela.edu>
Subject: Re: flock
Message-Id: <785eoh$obl$1@zarathustra.calstatela.edu>

In article <36A537C9.12BF@colorado.edu>,
Collin Starkweather  <collin.starkweather@colorado.edu> wrote:
>The 2 (the LOCK_EX constant) requests an exclusive lock (noone else
>should be able to access it).  8 (the LOCK_UN constant) unlocks the
>file.  1 requests a shared lock (the LOCK_SH constant) (truthfully, I
>don't know what this is all about).  

Basically, an exclusive lock is often used when you're gonna write to
the file and you don't want other processes to see a file that may be
in an inconsistant state.  A shared lock is used when several processes
can read the file, and you're not worried about it reading the file as
another process modifies it.

Example of an exclusive lock:

Process A and B have a file open read-write.  Process C has it open
read-only.  Process A starts to write to the file.  Process C tries
to read from the file.  It blocks.  Process B tries to write to the
file.  It blocks.  Process A finishes.  Process C starts to read
from the file.  Process B is still waiting.  Process C finishes.
Process B begins the write.

Example of a shared lock:

Process A and B has a file open read-write.  Process C has it open
read-only.  Process A starts to write to the file.  Process B tries
to write, but blocks.  Process C tries to read and succeeds.
Process A finishes the write.  Process B's write kicks in.  Process
C is still reading.

Get it? :-)

Of course, I may have made tons of errors, so please, feel free to
flame^H^H^H^H^Hcorrect me. :-)

-- DN


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

Date: Wed, 20 Jan 1999 22:16:28 GMT
From: mgjv@comdyn.com.au (Martien Verbruggen)
Subject: Re: flock
Message-Id: <0Bsp2.19$Rq1.2736@nsw.nnrp.telstra.net>

In article <36a5a747@csnews>,
	Tom Christiansen <tchrist@mox.perl.com> writes:
>  [courtesy cc of this posting sent to cited author via email]
> 
> In comp.lang.perl.misc, 
>     Zenin <zenin@bawdycaste.org> writes:
>:	Don't use raw values if you can avoid it as they
>:	aren't guaranteed to be the same on all systems.
> 
> This is less true than you would imagine.  See pp_sys.c

Are you referring to the part at the top where the flock() constants
are being set? Doesn't that part confirm what Zenin wrote? If I read
it correctly, the whole preprocessor part that deals with flock()
reads <fcntl.h>, then checks whether each of the flock() constants
have been defined, and if not, it sets them to the most common values.

The above, to me, means that on a system that has fcnlt.h and that
defines these constants, they may have any value. Only if the
constants are not defined, they are assumed to have the 'standard'
values.

Sure, I agree that the normal values are very, very common, but still,
there is no guarantee.

Now, where did I go wrong?

Martien
-- 
Martien Verbruggen                  | 
Interactive Media Division          | Think of the average person. Half of
Commercial Dynamics Pty. Ltd.       | the people out there are dumber.
NSW, Australia                      | 


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

Date: 20 Jan 1999 21:41:10 GMT
From: gward@cnri.reston.va.us (Greg Ward)
Subject: Re: Help with regular expression
Message-Id: <785ihm$su$1@news0-alterdial.uu.net>

Network Operations <root@coredcs.com> wrote:
> I have the following regexp that I'm attempting to decipher.  The
> input variable is text(a paragraph of regular words).
> 
> $text =~ s/([^\012]{1,90})\s/$1\012/sg;
> 
> I believe that it's trying to do something with FF characters.

Nope -- you're confusing decimal and octal.  In any Perl regexp or
string (or any C string, or strings for many C-influenced languages, for
that matter), "\0xxx" denotes an octal character.  \012 == 10 (decimal),
which is the linefeed character (== "\n" on Unix systems).

I'll see if I can't decipher that regexp for you: [^\012] means any
character *except* linefeed, and {1,90} means "repeated 1 .. 90 times".
\s is any whitespace character (a single space, tab, newline, etc.)

Thus, this regex finds strings of up to 90 characters (except linefeed)
followed by a space, and changes the space to a linefeed.  If it's only
going to run on a Unix platform, it can be rewritten as follows:

    s/(.{1,90})\s/$1\012/g;

because normally Perl's regex engine interprets '.' as "any character
*except* newline" -- the 's' modifier takes away the "except newline"
bit.  As long as "\012" == "\n" (which is true under Unix), then you can
drop the 's' modifier and change the slightly cryptic '[^\012]' with
'.'.

> However what happens is that it seems to drop the last word of the
> last sentence down a line(looks like maybe a newline or carriage
> return gets put in before the last word of the last line).

That's exactly what it does.  Is that not what it's supposed to do?

> Any help you can give would be appreciated.  I'm going to poke through
> Mastering Reg Exp from ora.

Pretty advanced book -- if you're uncomfortable with regular expressions
in general, you might want a gentler intro.  Didn't someone write a
'perlretut' man page recently?  (Like, since 5.00502, to be included in
5.00503... am I dreaming?)

        Greg
-- 
Greg Ward - software developer                    gward@cnri.reston.va.us
Corporation for National Research Initiatives    
1895 Preston White Drive                      voice: +1-703-620-8990 x287
Reston, Virginia, USA  20191-5434               fax: +1-703-620-0913


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

Date: Wed, 20 Jan 1999 20:32:09 +0000
From: Dave Crawford <djc@ppp.co.uk>
Subject: Help: need to check file not being written
Message-Id: <36A63D42.5FE41FDF@ppp.co.uk>

help, I'm new to perl, but am enjoying current project.

need to check a file which to see whether or not it is still bening written to
by a remote application ie ISDN transmission.

Needd to copy file once file is stable!! for 15 seconds.

have loop to check for files and folders, and copy etc, but am unable to check
for stable condition.

Files currently on Mac, mounted by NT perl on NT pulling file from Mac to NT drive.


thanks for any of your help.

Dave Crawford
Software Support Engineer
PPP Ltd

djc@ppp.co.uk


end


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

Date: Wed, 20 Jan 1999 19:55:43 GMT
From: "Sam Patton" <samuel.patton@wichita.boeing.com>
Subject: Re: How to get IP address of a local machine under NT
Message-Id: <F5vJCq.Du5@news.boeing.com>

Whats your seeing is a loopback address.

Type ipconfig and it will show the ip of the unit,  the subnet mask and the
default gateway address.
thats on NT.  I don't know about UNIX.

>;; ipconfig
>
>That's ifconfig. It gives me 127.0.0.1.
>
>
>Of course, this doesn't have anything to do with Perl.
>
>
>
>Abigail
>--





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

Date: Wed, 20 Jan 1999 15:31:05 -0600
From: "Ban Spam Now" <no_spam@no_spam.com>
Subject: Newbie string question,  please help :)
Message-Id: <785i0u$odp@sjx-ixn6.ix.netcom.com>

I'm really new to this.

Given a string of length 0 to n

How do I loop through the string character by character and perform an
operation based on the current character?

in pseudo code

for i = 1 to length(string)
  if string(i) = "M" do something
  if string(i) = "E" do something
end for

how to do it in Perl?






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

Date: Wed, 20 Jan 1999 21:50:25 -0000
From: "Denny John" <denny.john@btinternet.com>
Subject: Re: Newbie string question,  please help :)
Message-Id: <785its$8gb$1@mendelevium.btinternet.com>

try substring

ie something like

if ( substring( $string , i , 1 ) eq "x" ) {
# do something
}



Ban Spam Now wrote in message <785i0u$odp@sjx-ixn6.ix.netcom.com>...
>I'm really new to this.
>
>Given a string of length 0 to n
>
>How do I loop through the string character by character and perform an
>operation based on the current character?
>
>in pseudo code
>
>for i = 1 to length(string)
>  if string(i) = "M" do something
>  if string(i) = "E" do something
>end for
>
>how to do it in Perl?
>
>
>
>




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

Date: Wed, 20 Jan 1999 22:05:19 GMT
From: mcafee@waits.facilities.med.umich.edu (Sean McAfee)
Subject: Re: Newbie string question,  please help :)
Message-Id: <zqsp2.3141$Ge3.13792461@news.itd.umich.edu>

In article <785i0u$odp@sjx-ixn6.ix.netcom.com>,
Ban Spam Now <no_spam@no_spam.com> wrote:
>Given a string of length 0 to n
>How do I loop through the string character by character and perform an
>operation based on the current character?

>in pseudo code
>for i = 1 to length(string)
>  if string(i) = "M" do something
>  if string(i) = "E" do something
>end for

>how to do it in Perl?

I'd do it this way:

$string = <STDIN>;
while ($string =~ /(.)/gs) {
    if ($1 eq "M") {
        # do something
    } elsif ($1 eq "E") {
        # do something else
    } ...
}

You ought to read the perlre man page if you haven't already.  Perl's
regular expressions can handle just about any text-processing task you can
imagine.  I always feel slightly dirty when I have to resort to substr() or
index().

-- 
Sean McAfee | GS d->-- s+++: a26 C++ US+++$ P+++ L++ E- W+ N++ |
            | K w--- O? M V-- PS+ PE Y+ PGP?>++ t+() 5++ X+ R+ | mcafee@
            | tv+ b++ DI++ D+ G e++>++++ h- r y+>++**          | umich.edu


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

Date: 20 Jan 1999 21:17:25 GMT
From: gward@cnri.reston.va.us (Greg Ward)
Subject: Re: Open File Detect
Message-Id: <785h55$a$1@news0-alterdial.uu.net>

Bob Davis <Robert.Davis@jhuapl.edu> wrote:
> Is there anyway that I can detect that a file is currently opened by
> another process?  Specifically, I need to be able to detect when an FTP
> transfer completes so I can then move the file someplace else.

Wow!  Somebody asked a good question -- thank you!  (Good because a)
it's interesting, and b) you explained *why* you need to do some
slightly weird thing, allowing us to come up with alternate strategies
instead of coming up with lots of ways to do what may be a bad thing.
That seems to happen a lot around here...)

There must be some way under Unix to find out if a file is open; after
all, the 'fuser' command does it.  But I don't know what it is, and I
don't know if it's easily accessible through Perl.  If you're *really*
curious, you could track down an open source version of 'fuser' (such as
the one included with any Linux distribution) and Read The Fine Source.
Or maybe someone here will know.

HOWEVER, because I am ignorant of how fuser works, I have some other
ideas.  First, most Unices let you rename (or even delete!) a file while
it's still open, even if another process is still writing to it.  That
process will continue uninterrupted, although the file under its old
name will no longer be accessible.  Of course, this only works if you're
using the rename(2) system call (or Perl's interface to it), so you
can't move across filesystems -- that's done by the 'mv' command, and is
implemented as "copy-and-delete".  (You'd do it in Perl with the
File::Copy module and the 'unlink' builtin.)  So, as long as your moving
within the same filesystem, you could just use 'rename' and forget about
it -- the ftp'ing process won't mind.

Another approach is to put the transfer under your control by using the
Net::FTP module.  That way you'll know exactly when it's finished -- but
if you want the transfer to run asynchronously, you'll have to fork (or
use threads) -- gets tricky, but you still have a better shot at finding
out what happened with your transfer than you do if you're eg. using an
external 'ftp' program.  Whether this'll work depends a lot on your
particular application.

Another idea that will depend on your particular application: if your
script launched the process that's doing the transfer, you could just
'waitpid' for it (or handle SIGCHLD signals) to know when it's done.

        Greg
-- 
Greg Ward - software developer                    gward@cnri.reston.va.us
Corporation for National Research Initiatives    
1895 Preston White Drive                      voice: +1-703-620-8990 x287
Reston, Virginia, USA  20191-5434               fax: +1-703-620-0913


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

Date: Wed, 20 Jan 1999 21:23:51 +0000
From: Kiril <spam.me@idea.co.uk>
Subject: Re: Open File Detect
Message-Id: <36A64967.103B79C4@idea.co.uk>

Bob Davis wrote:
> 
> Is there anyway that I can detect that a file is currently opened by
> another process?  Specifically, I need to be able to detect when an FTP
> transfer completes so I can then move the file someplace else.
> Thanks,
> Bob

not necessarily a perl solution, but can you get the sender
to encode the file size into the file name ?


K


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

Date: Wed, 20 Jan 1999 22:03:48 +0000
From: Andrew Fry <andrewf@beausys.demon.co.uk>
Subject: Re: Perl problem :(Offline mode...
Message-Id: <mDnGVBAELlp2Ewdi@beausys.demon.co.uk>

In article <36A626B6.948C9E72@mail.northgrum.com>, James M. Stern
<sternji@mail.northgrum.com> writes
>Herein, a gentle reply to a point of view that usually draws harsh ones.

Gentle ? Perhaps. Patronising ? Certainly!

>Andrew Fry wrote:
>
>> [... What module was prompting for "offline mode" values?] 
>> I am well aware of manuals, on-line docs, etc ... but I dont have
>> time to plough through lots of manuals/docs (do you ???), and I
>> know by experience that one doesnt always find what one is looking for
>> in documentation.
>
>How much does one find by not looking?  How long does it take to look? 
>Much less time than it takes to receive a reply from clpm.

Not looking ? Wait a momemt ... I've read:
* CGI Developers Guide (Sams.Net)
* Learning Perl (O'Reilly)
* Programming Perl (O'Reilly)
* Perl Cookbook (O'Reilly)
* numerous articles and examples on all the main Perl websites

Just how much reading are you expecting me to do ???

>> The fact is that I run a small comms/networking consultancy & software
>> house ... and we work to very tight deadlines. Having the time to read
>> and learn is something of a luxury.
>
>No, a necessity.
>
>First, it saves time.  Learning by trial and error involves many errors
>and great trials.  Had you read the CGI documentation (under 40 pages,
>unformatted), you would have been in a good position to guess the cause
>right away.  Had you read about the Perl debugger, you could have found
>the cause without even the CGI documentation.  (Also, since Perl comes
>with complete source code, you could have searched the installed Perl
>files for the word "offline".)  In any case you would have had the
>answer within minutes.

I am gradually getting to grips with the Perl documentation, and I
realize the importance of documentation ... but I dont agree that
reading documentation always saves time. It depends on how much
documentation is involved, how well written it is and whether it covers
the specific areas of interest in the right level of detail. I have read
countless documents that havent told me what I have wanted to know.
Furthermore, it isnt reading documents per se that keeps my company
in business. One can only spend so much time reading documentation!

>
>Second, the trial-and-error "solution" may have hidden bugs that won't
>show up until your code goes into production.  Your deadlines will only
>get tighter when the customer demands immediate fixes for those.
>
>By the way, I'll bet the regulars in this group are busier than you. 
>People who read manuals usually are in demand to clean up after people
>who don't.  :-)
>
>> I appreciate the helpful replies, but frankly, I dont see the point in
>> these discussion groups if the reply is just going to be 'read the
>> manual'!
>
>I'm saying:  Read the manual.  You owe it to your customer and yourself.

I guess you could use this response to *every* new query that arises on
this newsgroup.
I do read manuals. I'll wager a bet that I've read more ISO, ITU
documents, RFCs, UNIX man pages, NT SDK documents, etc ... than you
have.
But please try not to be so bloody patronising. I have a degree in
Computer Science, have run my own company for 15 years and have worked
for some big companies (inc AT&T, X/Open, ICL) and on some big projects.
I realize the importance of documentation and I know what my priorities
are, thank you very much.

I am a newcomer to this newsgroup ... but, frankly, I find these
responses of 'read the manual' unhelpful. Why bother ?????
To those who did provide a useful response: thanks again!

---
Andrew Fry
"Time flies like an arrow. Fruit flies like a banana". (Groucho Marx).


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

Date: Thu, 21 Jan 1999 09:28:34 +1100
From: "Ron Savage" <Savage.Ron.RS@bhp.com.au>
Subject: Re: Perl to C++ converter?
Message-Id: <785l6m$fos19@atbhp.corpmel.bhp.com.au>

Nice try, Tom, but more likely it's a typo, in that he really wants a C++ to
Perl converter... :-)

--
Ron Savage
Office (preferred): Savage.Ron.RS@bhp.com.au
Home: rpsavage@ozemail.com.au
http://www.ozemail.com.au/~rpsavage
Tom Christiansen wrote in message <36a59ef0@csnews>...
> [courtesy cc of this posting sent to cited author via email]
>
>In comp.lang.perl.misc, Gino Cerro  <gino@wpi.edu> writes:
>:Is there a script that converts Perl code to C++ code (for Unix/Linux)? I
>:thought I saw a listing for one a few weeks (while surfing some Perl web
>:pages) and cannot remember where.
>:
>
>That's a FAQ.  The short answer is you don't want to do that, even though
>you think you do.
>
>--tom
>--
>"If projectile vomiting ever becomes an Olympic event, you'll do
> yourself proud."
>    --Hobson, "Arthur II"




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

Date: 20 Jan 1999 21:22:00 GMT
From: cberry@cinenet.net (Craig Berry)
Subject: Re: Printing the return value from a subroutine?
Message-Id: <785hdo$2vn$1@marina.cinenet.net>

Jens Johanneson (jens.johanneson@edicom.se) wrote:
: Is there a way for me to print this four lines example code in only two
: lines?
: 
: $tmp = &myFunc();
: print "This is the first return value of myFunc =$tmp";
: $tmp = &myFunc();
: print "This is the second return value of myFunc =$tmp";

Heck, you can do it in one line (well, one statement and function call):

  print 'This is the first return value from myFunc =', myFunc(),
        'This is the second return value from myFunc =', myFunc();

Note that your strings contain no newlines, so it'll all get jammed
together on one output line.

Another way to do it more neatly is:

  printf <<EOS, myFunc(), myFunc();
  This is the first return value from myFunc =%s
  This is the second return value from myFunc =%s
  EOS

This version does provide newlines after each string.

-- 
   |   Craig Berry - cberry@cinenet.net
 --*--    Home Page: http://www.cinenet.net/users/cberry/home.html
   |      "The hills were burning, and the wind was raging; and the
       clock struck midnight in the Garden of Allah."


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

Date: 20 Jan 1999 21:23:35 GMT
From: gward@cnri.reston.va.us (Greg Ward)
Subject: Re: Running scripts with differing parameters.
Message-Id: <785hgn$a$2@news0-alterdial.uu.net>

Ban Spam Now <no_spam@no_spam.com> wrote:
> I am maintaining an existing Perl script for the first time.

Good luck!  For your sake I hope it's well-written...

> I am thinking of writing a generalized function, within the script, which
> executes the ksh script passed as a parameter to it. The reason for my
> re-write is that there are a lot of functions, which basically do the same
> thing but run different ksh scripts  its crying out for a general
> function.

Excellent idea.  BTW, your post contains non-ASCII characters (octal 226
and 222).  USENET is an ASCII text medium, please keep it that way.
You're not using one of those Microsoft OS's, are you?

> The problem I have is that some of the ksh files have parameters and
> some dont.  The number of parameters vary and the parameters are
> always variables which exist within the Perl script.
> 
> So, at run time, not only do I need to know the ksh script Im going
> to run (the easy bit, I can read it from the file), but I also need to
> know which parameters to pass it and somehow know which Perl variable
> they will be.

Yeah, this is a snap.  Think "array reference".  Here's an example:

   sub run_script
   {
      my ($script_name, $script_args) = @_;

      system $script_name, $script_args;
      die "$script_name failed!\n" unless $? == 0;
   }

   # ...

   run_script ('script1', ['args', 'for', 'script1']);

'man perlsub' for information on passing parameters to a subroutine, and
'man perlref' for information on references.  These are both *really*
basic features of Perl, so if you don't understand them you might want
to pick up a copy of *Learning Perl* by Randal Schwartz and Tom
Christiansen and, umm, learn Perl.  Avoid books with numbers, time
limits, or insults in the title (eg. the dreaded "Teach Yourself to
Master CGI Programming and Maintain a World-Wide-Web site in Perl 5 in
21 Days or 7 Weeks Whichever Comes Sooner for Dummies or Your Money
Back").

        Greg
-- 
Greg Ward - software developer                    gward@cnri.reston.va.us
Corporation for National Research Initiatives    
1895 Preston White Drive                      voice: +1-703-620-8990 x287
Reston, Virginia, USA  20191-5434               fax: +1-703-620-0913


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

Date: Wed, 20 Jan 1999 16:28:55 -0500
From: rkc@ll.mit.edu
Subject: Shared Memory Question: Why no separate attach? (Expert)
Message-Id: <36A64A32.2340041F@ll.mit.edu>

I am writing a perl application that is communicating with another
process via shared memory. In perl, the shmread operation combines
attaching, reading, and detatching all into one operation. Since we'll
be pushing alot of data back and forth, I don't want to incur the cost
of all of those kernel operations. Is there a strong reason why I
shouldn't write a C module that has separate attach,  read/write, and
detach operations? (e.g., does this mess up some perl memory internals?)

If I can't do this, then what is the recommended perl IPC for Unix systems?

Thanks for your help,

Rob
-- 
Dr. Robert K. Cunningham       Information System Technology Group
  rkc@ll.mit.edu                     MIT Lincoln Laboratory           
*** My comments, my opinions: my responsibility.


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

Date: Wed, 20 Jan 1999 16:28:06 -0500
From: x <ergowolf@mindspring.com>
Subject: Sorting Alphanumeric
Message-Id: <36A64A66.7F23BF36@mindspring.com>

I am trying to sort some files that begin with a letters followed by
numbers.  I want to sort in numeric order so that I can rename them.  I
am getting the same result with the options the spaceship(1) and  the
Swartzian Transform(2).  I have a feeling I am making a dumb mistake.
Any help would be greatly appreciated!

lines from my script:

chdir("C:/temp2");
@filelist = glob("*.jpg");

1.) @filelist = sort { $a <=> $b } @filelist;

2.) @filelist = map  { $_->[0] }
            sort { $a->[1] cmp $b->[1] or $a->[2] <=> $b->[2] }
            map  { [ $_, /([A-Za-z]+)(\d+)/ ] } @filelist;


 foreach $item1 (@filelist) {
     chomp ($item1);
     $item2 = "$counter.jpg";
     ++$counter;
     print "item1\t$item1\nitem2\t$item2\n\n";


Produce the following result:

item1 webcama_1.jpg
item2 1.jpg

item1 webcama_10.jpg
item2 2.jpg

item1 webcama_11.jpg
item2 3.jpg

item1 webcama_12.jpg
item2 4.jpg

item1 webcama_13.jpg
item2 5.jpg

item1 webcama_14.jpg
item2 6.jpg

item1 webcama_15.jpg
item2 7.jpg

item1 webcama_16.jpg
item2 8.jpg

item1 webcama_17.jpg
item2 9.jpg

item1 webcama_18.jpg
item2 10.jpg

item1 webcama_19.jpg
item2 11.jpg

item1 webcama_2.jpg
item2 12.jpg

item1 webcama_20.jpg
item2 13.jpg

item1 webcama_21.jpg
item2 14.jpg

item1 webcama_22.jpg
item2 15.jpg

item1 webcama_3.jpg
item2 16.jpg

item1 webcama_4.jpg
item2 17.jpg

item1 webcama_5.jpg
item2 18.jpg

item1 webcama_6.jpg
item2 19.jpg

item1 webcama_7.jpg
item2 20.jpg

item1 webcama_8.jpg
item2 21.jpg

item1 webcama_9.jpg
item2 22.jpg

EOF


Just another Perl newbie





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

Date: 20 Jan 1999 17:01:59 -0500
From: Uri Guttman <uri@ibnets.com>
Subject: Re: Sorting Alphanumeric
Message-Id: <397luh38o8.fsf@ibnets.com>

>>>>> "x" == x  <ergowolf@mindspring.com> writes:

  x> I am trying to sort some files that begin with a letters followed by
  x> numbers.  I want to sort in numeric order so that I can rename them.  I
  x> am getting the same result with the options the spaceship(1) and  the
  x> Swartzian Transform(2).  I have a feeling I am making a dumb mistake.
  x> Any help would be greatly appreciated!

  x> lines from my script:

  x> chdir("C:/temp2");
  x> @filelist = glob("*.jpg");

  x> 1.) @filelist = sort { $a <=> $b } @filelist;

  x> 2.) @filelist = map  { $_->[0] }
  x>             sort { $a->[1] cmp $b->[1] or $a->[2] <=> $b->[2] }
  x>             map  { [ $_, /([A-Za-z]+)(\d+)/ ] } @filelist;
                                         ^^^
  x> item1 webcama_1.jpg
                  ^

you forgot the _ as part of the file name.


as an alternative you could try a printable sort like this: (tested)

@filelist = map substr( $_, 18 ),
	    sort
            map sprintf( "%15s%03d$_", /([A-Za-z]+)_(\d+)/ ),  @filelist;

hth,

uri

-- 
Uri Guttman                             Hacking Perl for Ironbridge Networks
uri@sysarch.com				uri@ironbridgenetworks.com	


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

Date: Wed, 20 Jan 1999 19:38:39 GMT
From: bart.lateur@skynet.be (Bart Lateur)
Subject: Re: subroutine return values
Message-Id: <36a63063.584456@news.skynet.be>

Rob S wrote:

>I have a subroutine which prints a line before it finishes
>and control goes back to the main program. How can I use
>the return value, 1 or 0 from a "successful subroutine print" back in
>the main body of the program?

I don't get it. You want to see if the print worked?

	sub something {
		...
		return print "blah blah blah";
		#or drop the "return"
	}

	&something or die "Could not print: $!";
	
	Bart.


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

Date: Wed, 20 Jan 1999 22:09:44 GMT
From: mgjv@comdyn.com.au (Martien Verbruggen)
Subject: Re: text indexes from lists
Message-Id: <Iusp2.14$Rq1.2736@nsw.nnrp.telstra.net>

In article <7852pl$hat$1@nnrp1.dejanews.com>,
	sno@ais.org writes:

[There really is no need to quote your whole original article when
following up to it yourself.]

> Well, I guess it was a lamer question.  After pondering this issue overnight
> it seemed to me that if there isn't a perl utility (say 'enum') that would

There isn't.

> give the result I wanted, I would either make my own sub or create a
> look-up table with hashes.

If you don't want to store your data in memory structured in the way
that you want to use it (see my other post), then a lookup table is
definitely the go.

Martien
-- 
Martien Verbruggen                  | 
Interactive Media Division          | This matter is best disposed of from a
Commercial Dynamics Pty. Ltd.       | great height, over water.
NSW, Australia                      | 


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

Date: 20 Jan 1999 22:50:19 GMT
From: garynlang@aol.com (Garynlang)
Subject: US jobs/JAVA, C++, Perl
Message-Id: <19990120175019.28336.00000287@ng10.aol.com>

We have several JAVA, PERL, C++ jobs opening
in S. California. 
Gary Lang
Gary N. Lang
Vice President of ACD,Inc.
E-mail: garynlang@aol.com
http://www.acdcon.com/


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

Date: Wed, 20 Jan 1999 16:31:07 -0600
From: Robert Lang <rrl@mail.com>
Subject: write is trimming trailing blanks?
Message-Id: <36A6592B.2DD442D@mail.com>

Hello.

I'm having a bit of trouble with FORMAT and write.

The records that we are writing must be 350 chars long.  (Padded with
blanks.)

No matter what I do, write seems to trim the blanks for me.  (Naughty,
naughty, write.  I almost think that I'm using a Microsoft product.  ;-)

I appreciate that fact that perl is trying to save space for me, but
that is not what I want.

Any help will be greatly appreciated.

Regards,

Robert Lang
rrl@xnet.com




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

Date: Wed, 20 Jan 1999 22:43:22 GMT
From: mgjv@comdyn.com.au (Martien Verbruggen)
Subject: Re: write is trimming trailing blanks?
Message-Id: <e_sp2.24$Rq1.2736@nsw.nnrp.telstra.net>

In article <36A6592B.2DD442D@mail.com>,
	Robert Lang <rrl@mail.com> writes:

> The records that we are writing must be 350 chars long.  (Padded with
> blanks.)

You could use sprintf for that.

# perldoc -f sprintf

Martien
-- 
Martien Verbruggen                  | 
Interactive Media Division          | I think I think, therefore I think I
Commercial Dynamics Pty. Ltd.       | am.
NSW, Australia                      | 


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

Date: 20 Jan 1999 21:26:50 GMT
From: cberry@cinenet.net (Craig Berry)
Subject: Re: Year 2038 problem
Message-Id: <785hmq$2vn$2@marina.cinenet.net>

Trond Michelsen (mike@crusaders.no) wrote:
: If I'm not mistaking (I just might) this number is represented as an
: 32-bit integer only if you're using a 32-bit computer. If this is the
: case I'll claim that the date-rollover is not your biggest problem if
: you're still using a 32-bit computer in 2038.

As with the Y2K problem, the biggest problem is not the representation
inside programs, but the representation in external data stores.  If your
multi-GB DB contains 32-bit time_t fields, modifying it and all the code
using it to use 64-bit time_t without incurring significant downtime may
be tricky.

-- 
   |   Craig Berry - cberry@cinenet.net
 --*--    Home Page: http://www.cinenet.net/users/cberry/home.html
   |      "The hills were burning, and the wind was raging; and the
       clock struck midnight in the Garden of Allah."


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

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

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