[22878] in Perl-Users-Digest

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

Perl-Users Digest, Issue: 5099 Volume: 10

daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Mon Jun 9 18:05:59 2003

Date: Mon, 9 Jun 2003 15:05:10 -0700 (PDT)
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, 9 Jun 2003     Volume: 10 Number: 5099

Today's topics:
        AdminMisc::GetMemory(), anything for Win95 (hfs2)
    Re: Array Shift Question <TruthXayer@yahoo.com>
    Re: Array Shift Question <drew4jones@yahoo.ca>
        Cannot modify integer negation (-) in predecrement (--) (Go Perl)
    Re: Cannot modify integer negation (-) in predecrement  (Tad McClellan)
    Re: Cannot modify integer negation (-) in predecrement  <nobody@dev.null>
    Re: Changing form output (Steve)
        Forcing perl into background (Dave Ardrey)
    Re: Forcing perl into background <tassilo.parseval@rwth-aachen.de>
    Re: Forcing perl into background <graham.drabble@lineone.net>
    Re: Forcing perl into background <mothra@nowhereatall.com>
    Re: Forcing perl into background <ian@WINDOZEdigiserv.net>
    Re: Forcing perl into background <graham.drabble@lineone.net>
    Re: get pid of system command <bmetcalf@nortelnetworks.com>
    Re: How to I arrange for a socket connection to time ou <nobody@dev.null>
    Re: How to I arrange for a socket connection to time ou (John Brock)
    Re: How to I arrange for a socket connection to time ou <darnold@presicient.com>
    Re: move() from File::Copy package fails with cross-dev (Carlton Brown)
    Re: newbie: will a big array hurt performance? <grazz@pobox.com>
    Re: newbie: will a big array hurt performance? <ndronen@io.frii.com>
    Re: newbie: will a big array hurt performance? (Tad McClellan)
        passing argvs to interactive program (perl wrapper) (david)
    Re: Perl CGI and Downloading Files - How? <flavell@mail.cern.ch>
    Re: Perl CGI and Downloading Files - How? 10ghz@radiate.com
        perl Conditional compile - Running Win32 library calls  (Kir)
    Re: perl Conditional compile - Running Win32 library ca <mothra@nowhereatall.com>
    Re: Perl exam - fair or not? (Tramm Hudson)
        PERLCC  segmentation fault <hasting@agere.com>
    Re: PERLCC  segmentation fault <mothra@nowhereatall.com>
        Quick question (Avatar)
    Re: Quick question <ian@WINDOZEdigiserv.net>
    Re: Strange observation (Ralph Snart)
    Re: Unusual Can't load fail (web only) (Ralph Snart)
        Using ParseRecur from Date::Manip (Gupit)
        Digest Administrivia (Last modified: 6 Apr 01) (Perl-Users-Digest Admin)

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

Date: 9 Jun 2003 11:48:26 -0700
From: hfs2@yahoo.com (hfs2)
Subject: AdminMisc::GetMemory(), anything for Win95
Message-Id: <17f20df0.0306091048.66711460@posting.google.com>

Surprised I couldn't find a perl/win news group.  Oh well, try
you guys.

I was using the Roth AdminMisc binary for NT.  Doesn't, as advertise,
work on the Win9X strain.

I can find replacments for most of the functions, but can't find
an alternative for GetMemory.  Is there one?

Thanks.


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

Date: Mon, 09 Jun 2003 11:28:39 -0700
From: TruthXayer <TruthXayer@yahoo.com>
Subject: Re: Array Shift Question
Message-Id: <3EE4D1D7.E6B2B472@yahoo.com>

Blnukem wrote:
> 
> Hi All
> 
> @array qw(one two three);
> shift @array;
> print $_;   #Returns nothing
> 
> print @array;   #Returns "two three"
> 
> where does the "one" value go?
> 
> Thanx Blnukem

perldoc -f shift
perldoc -q array


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

Date: Mon, 09 Jun 2003 20:39:55 GMT
From: Drew Jones <drew4jones@yahoo.ca>
Subject: Re: Array Shift Question
Message-Id: <4e1cc61a47f263c9a50fbec3cfe1afab@free.teranews.com>

On Mon, 09 Jun 2003 17:30:38 GMT, "Blnukem" <blnukem@hotmail.com>
wrote:

>Hi All
>
>@array qw(one two three);
>shift @array;
>print $_;   #Returns nothing
>
>print @array;   #Returns "two three"
>
>where does the "one" value go?
>

It's best to cut and paste tested code to avoid unhelpful non-answers.

perldoc -f shift	will tell you all about shift, and 
perldoc perlfunc	will tell you about them all.

"shift @array" basically deletes the first entry.  It doesn't "go"
anywhere.  If requested, shift will return the value so you don't
"lose" it.  $original_first_element = shift @array;  

While it's true that perl often uses the $_ variable as the default
_input_ to functions, it is rarely used as the output except when
reading lines from files (e.g. while (<>) )



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

Date: 9 Jun 2003 11:14:31 -0700
From: puissant00@yahoo.com (Go Perl)
Subject: Cannot modify integer negation (-) in predecrement (--)
Message-Id: <d3825316.0306091014.1d2891fc@posting.google.com>

I am using the following code for which i am getting the error
mentioned in the subject

#counting the number of lines in observed volume file
open(FILE, "<$filename");
$lines=@myarray = <FILE>
close(FILE);
I am using active state perl on win32. This code worked fine on my
windows nt whereas on win xp its not working . I used the other ways
to count lines using while loop and increment or suing syread buffer
method. all these methods are giving me the same problem.
Any solutions please.


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

Date: Mon, 9 Jun 2003 14:28:11 -0500
From: tadmc@augustmail.com (Tad McClellan)
Subject: Re: Cannot modify integer negation (-) in predecrement (--)
Message-Id: <slrnbe9nub.hbt.tadmc@magna.augustmail.com>

Go Perl <puissant00@yahoo.com> wrote:

> open(FILE, "<$filename");


You should always, yes *always*, check the return value from open():

   open(FILE, "<$filename") or die "could not open '$filename'  $!";


> $lines=@myarray = <FILE>


You should turn "use strict" on too.


> Any solutions please.


Ask machines to help before asking people to help. 

Enable warnings and strictures.


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


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

Date: Mon, 09 Jun 2003 20:52:03 GMT
From: Andras Malatinszky <nobody@dev.null>
Subject: Re: Cannot modify integer negation (-) in predecrement (--)
Message-Id: <3EE4F327.30003@dev.null>



Go Perl wrote:

> I am using the following code for which i am getting the error
> mentioned in the subject
> 
> #counting the number of lines in observed volume file
> open(FILE, "<$filename");
> $lines=@myarray = <FILE>
> close(FILE);


Funny, when I run your code the error I get is

syntax error at try.pl line 4, near "close"
Execution of try.pl aborted due to compilation errors.

When I fix that(by adding the missing semicolon), I get nothing because 
$filename is undef and the program has no output statement anyway.

So when I fix that (by adding
$filename='/autoexec.bat';

at the beginning and

print $lines;

at the end, I get

8, which is a quite reasonable answer.

So something tells me that the four lines you posted are not your actual 
code...






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

Date: 9 Jun 2003 11:45:21 -0700
From: techadmin@shaw.ca (Steve)
Subject: Re: Changing form output
Message-Id: <2e27f51a.0306091045.a18523b@posting.google.com>

Steve May <drumspoorly@reachone.net> wrote in message news:<ve346jmo985t0b@corp.supernews.com>...
> Steve wrote:
> 
> <snip>
> 
> > 
> > 
> > Please excuse if I have offended anyone,
> >  
> 
> Offense? I think exasperation might be closer.
> 
> 
> > I am still at a loss as to where the idea that my question was
> > 'DEMANDING' comes from. I have re-read it and I simply asked a
> > question not unlike any other question in this forum. In return I
> > hoped that some one would assist me?
> > 
> 
> Ah.... no.
> 
> You posted a mail sending routine.  Presumably you were looking for a
> way to format '$message' prior to calling the routine, though that's not
> absolutely certain since you did *not* post any code dealing with the
> format issue as far as I can see.
> 
> Folks here are incredibly patient with boneheaded mistakes and errors in
> thinking IF it's clear the poster is at least trying..... I have
> personal experience on that one, trust me.  True, you will often only
> get a reference to the pertinent documentation, but getting a handle
> on the docs is 90% of learning any programming language IMHO.
> 
> But when someone seems to be asking for a whole-cloth answer,
> well, that does tend to rile the natives. :-)
> 
> 
> > As for your reference as to being burnt out from answering other
> > peoples questions, why do you answer so negativley? would it be better
> > to just not answer at all.
> > 
> 
> A number of regulars often lose patience with posters who don't seem
> to have done their homework.
> 
> Your post qualified in Gunnar's judgement...... and I'm not so sure
> he was wrong.
> 
> Anyway, you now have two choices:
> 
> 1. Get angry and refuse to learn from this little exchange.
> 2. On your next post ask for a hand-up instead of a hand-out.
> 
> Up to you, though the long term results of No. 2 should be much
> more beneficial....
> 
> 
> s.

Thanks,

Lesson learned,

Steve


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

Date: 9 Jun 2003 11:59:06 -0700
From: david.ardrey@analog.com (Dave Ardrey)
Subject: Forcing perl into background
Message-Id: <ca2d7776.0306091059.4f9d3f46@posting.google.com>

Is there a way to force a perl script to begin in the background of a
shell, right from the beginning.  I've seen other programs do this,
but I haven't the foggiest in how to implement it.

I'd like the program to start and then have the user immediately have
the command line available to him again.

Thanks.

Dave


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

Date: 9 Jun 2003 19:05:57 GMT
From: "Tassilo v. Parseval" <tassilo.parseval@rwth-aachen.de>
Subject: Re: Forcing perl into background
Message-Id: <bc2lql$56q$1@nets3.rz.RWTH-Aachen.DE>

Also sprach Dave Ardrey:

> Is there a way to force a perl script to begin in the background of a
> shell, right from the beginning.  I've seen other programs do this,
> but I haven't the foggiest in how to implement it.
> 
> I'd like the program to start and then have the user immediately have
> the command line available to him again.

See the provided answer in perlfaq8: 

    perldoc -q daemon

Tassilo
-- 
$_=q#",}])!JAPH!qq(tsuJ[{@"tnirp}3..0}_$;//::niam/s~=)]3[))_$-3(rellac(=_$({
pam{rekcahbus})(rekcah{lrePbus})(lreP{rehtonabus})!JAPH!qq(rehtona{tsuJbus#;
$_=reverse,s+(?<=sub).+q#q!'"qq.\t$&."'!#+sexisexiixesixeseg;y~\n~~dddd;eval


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

Date: Mon, 09 Jun 2003 20:12:05 +0100
From: Graham Drabble <graham.drabble@lineone.net>
Subject: Re: Forcing perl into background
Message-Id: <Xns9395CD8032FAAgrahamdrabblelineone@ID-77355.user.dfncis.de>

On 09 Jun 2003 david.ardrey@analog.com (Dave Ardrey) wrote in 
news:ca2d7776.0306091059.4f9d3f46@posting.google.com:

> Is there a way to force a perl script to begin in the background of a
> shell, right from the beginning.  I've seen other programs do this,
> but I haven't the foggiest in how to implement it.
> 
> I'd like the program to start and then have the user immediately have
> the command line available to him again.

Try starting it with wperl script.pl .



-- 
Graham Drabble
If you're interested in what goes on in other groups or want to find 
an interesting group to read then check news.groups.reviews for what 
others have to say or contribute a review for others to read.


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

Date: Mon, 9 Jun 2003 12:19:21 -0700
From: "Mothra" <mothra@nowhereatall.com>
Subject: Re: Forcing perl into background
Message-Id: <3ee4dc5f$1@usenet.ugs.com>

Hi Dave,

"Dave Ardrey" <david.ardrey@analog.com> wrote in message
news:ca2d7776.0306091059.4f9d3f46@posting.google.com...
> Is there a way to force a perl script to begin in the background of a
> shell, right from the beginning.  I've seen other programs do this,
> but I haven't the foggiest in how to implement it.
>
This might get you started
Found in F:\perl\lib\pod\perlfaq8.pod
  How do I start a process in the background?

            You could use

                system("cmd &")

            or you could use fork as documented in the section on "fork" in
            the perlfunc manpage, with further examples in the perlipc
            manpage. Some things to be aware of, if you're on a Unix-like
            system:

            STDIN, STDOUT, and STDERR are shared
                Both the main process and the backgrounded one (the "child"
                process) share the same STDIN, STDOUT and STDERR
                filehandles. If both try to access them at once, strange
                things can happen. You may want to close or reopen these for
                the child. You can get around this with "open"ing a pipe
                (see the section on "open" in the perlfunc manpage) but on
                some systems this means that the child process cannot
                outlive the parent.

            Signals
                You'll have to catch the SIGCHLD signal, and possibly
                SIGPIPE too. SIGCHLD is sent when the backgrounded process
                finishes. SIGPIPE is sent when you write to a filehandle
                whose child process has closed (an untrapped SIGPIPE can
                cause your program to silently die). This is not an issue
                with "system("cmd&")".

            Zombies
                You have to be prepared to "reap" the child process when it
                finishes

                    $SIG{CHLD} = sub { wait };

                See the section on "Signals" in the perlipc manpage for
                other examples of code to do this. Zombies are not an issue
                with "system("prog &")".


Mothra





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

Date: Mon, 09 Jun 2003 21:02:23 GMT
From: "Ian.H [dS]" <ian@WINDOZEdigiserv.net>
Subject: Re: Forcing perl into background
Message-Id: <hct9ev0lvqqh6hgbldsh1i8clgectadidf@4ax.com>
Keywords: Remove WINDOZE to reply

-----BEGIN xxx SIGNED MESSAGE-----
Hash: SHA1

Whilst lounging around on Mon, 09 Jun 2003 20:12:05 +0100, Graham
Drabble <graham.drabble@lineone.net> amazingly managed to produce the
following with their Etch-A-Sketch:

> On 09 Jun 2003 david.ardrey@analog.com (Dave Ardrey) wrote in 
> news:ca2d7776.0306091059.4f9d3f46@posting.google.com:
> 
> > Is there a way to force a perl script to begin in the background
> > of a shell, right from the beginning.  I've seen other programs
> > do this, but I haven't the foggiest in how to implement it.
> > 
> > I'd like the program to start and then have the user immediately
> > have the command line available to him again.
> 
> Try starting it with wperl script.pl .



[tk@morris:~]$ wperl
bash: wperl: command not found



wperl is a windoze only binary.



To the OP:

The other alternative (for *nix) would be to use the & char:


   $ ./myscript.pl &


I have a couple of IRC service bots running with this method and has
never caused an issue.


HTH.



Regards,

  Ian

-----BEGIN xxx SIGNATURE-----
Version: PGP 8.0

iQA/AwUBPuT13Wfqtj251CDhEQIcCQCg7PstKZ8rBSXd4G4+kud63Yf6B4gAoKDF
M/L3UcWEUfgp3HAcIJztFnY9
=ZSQR
-----END PGP SIGNATURE-----

-- 
Ian.H  [Design & Development]
digiServ Network - Web solutions
www.digiserv.net  |  irc.digiserv.net  |  forum.digiserv.net
Programming, Web design, development & hosting.


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

Date: Mon, 09 Jun 2003 22:34:07 +0100
From: Graham Drabble <graham.drabble@lineone.net>
Subject: Re: Forcing perl into background
Message-Id: <Xns9395E594E1CA9grahamdrabblelineone@ID-77355.user.dfncis.de>

On 09 Jun 2003 "Ian.H [dS]" <ian@WINDOZEdigiserv.net> wrote in 
news:hct9ev0lvqqh6hgbldsh1i8clgectadidf@4ax.com:

> [tk@morris:~]$ wperl
> bash: wperl: command not found
> 
> 
> 
> wperl is a windoze only binary.

Ah sorry about that, didn't realise. 

-- 
Graham Drabble
If you're interested in what goes on in other groups or want to find 
an interesting group to read then check news.groups.reviews for what 
others have to say or contribute a review for others to read.


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

Date: Mon, 9 Jun 2003 20:39:39 +0000 (UTC)
From: Brandon Metcalf <bmetcalf@nortelnetworks.com>
Subject: Re: get pid of system command
Message-Id: <slrnbe9rsv.1ka.bmetcalf@cash.rhiamet.com>

ericw@nospam.ku.edu writes:
 >  On Sat, 07 Jun 2003 18:09:24 -0500, Eric Wilhelm wrote:

 > > When a command is started from the bash shell with "app &", it prints
 > > the job number and pid of the process.  Is there any way to get the pid
 > > number from inside a perl script?  I could call it with system("app &")
 > > and then look in `ps ax -w` for the app name, but it seems like there
 > > must be a better way.

 >  And maybe this is the one:
 >  $pid=open(PH, "app &|")

 >  Found this in "perldoc -q external process", but it looks like I've got
 >  some reading still to figure out the why of it all.

From the docs on open():

  Open returns nonzero upon success, the undefined value
  otherwise. If the "open" involved a pipe, the return value
  happens to be the pid of the subprocess.


Brandon
-- 
And let me tell you this. The older you do get, the more rules they're
going to try to get you to follow. You just gotta keep livin' man.
L.I.V.I.N.  --Wooderson


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

Date: Mon, 09 Jun 2003 18:08:33 GMT
From: Andras Malatinszky <nobody@dev.null>
Subject: Re: How to I arrange for a socket connection to time out?
Message-Id: <3EE4CCDA.8060103@dev.null>



John Brock wrote:

> I am using Perl to write a client module which communicates with
> a server through a socket connection.  I want the client to time
> out the socket connection if the server does not respond within,
> let's say, 60 seconds,[...]


Found in C:\usr\lib\pod\perlfaq8.pod
   How do I timeout a slow event?

Use the alarm() function, probably in conjunction with a signal handler, 
as documented in the section on "Signals" in the perlipc manpage and the 
section on ``Signals'' in the Camel. You may instead use the more 
flexible Sys::AlarmCall module available from CPAN.

Does this help?



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

Date: 9 Jun 2003 14:46:21 -0400
From: jbrock@panix.com (John Brock)
Subject: Re: How to I arrange for a socket connection to time out?
Message-Id: <bc2klt$sb6$1@panix1.panix.com>

In article <3EE4CCDA.8060103@dev.null>,
Andras Malatinszky  <nobody@dev.null> wrote:
>
>
>John Brock wrote:
>
>> I am using Perl to write a client module which communicates with
>> a server through a socket connection.  I want the client to time
>> out the socket connection if the server does not respond within,
>> let's say, 60 seconds,[...]

>Found in C:\usr\lib\pod\perlfaq8.pod
>   How do I timeout a slow event?
>
>Use the alarm() function, probably in conjunction with a signal handler, 
>as documented in the section on "Signals" in the perlipc manpage and the 
>section on ``Signals'' in the Camel. You may instead use the more 
>flexible Sys::AlarmCall module available from CPAN.
>
>Does this help?

I looked at alarm() initally, but I rejected it because it wasn't
clear that it would work properly on NT (it "sends a SIGALRM signal
to the current process after EXPR seconds" -- will that work on
NT?), and because it would be nice to have finer granularity than
one second.  I may end up using alarm() if I have to, but IO::Select
just seems more elegant, and really looks to me as though it is
*intended* for doing what I want to do, if only I knew how to use
it properly.  But if I've misunderstood, and IO::Select is *not*
appropriate for setting timeouts on a socket, then I'd like to
know.  Is this what you are telling me?
-- 
John Brock
jbrock@panix.com



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

Date: Mon, 09 Jun 2003 22:01:23 GMT
From: "Dean Arnold" <darnold@presicient.com>
Subject: Re: How to I arrange for a socket connection to time out?
Message-Id: <Ts7Fa.52$3J4.6657253@newssvr15.news.prodigy.com>

How about just plain old select() ? Remember to convert
your socket file handle into a file number, and build a
bit vector. Refer to Programming Perl 3rd. ed. for details.

Note: this may not work with large file numbers (or file numbers
higher than 31), since Perl's select() doesn't appear to support
large bit vectors.

BTW: there are 2 different select()'s, make sure you grab the right one.


-- 
Dean Arnold
Presicient Corp.
www.presicient.com

"John Brock" <jbrock@panix.com> wrote in message
news:bc2klt$sb6$1@panix1.panix.com...
> In article <3EE4CCDA.8060103@dev.null>,
> Andras Malatinszky  <nobody@dev.null> wrote:
> >
> >
> >John Brock wrote:
> >
> >> I am using Perl to write a client module which communicates with
> >> a server through a socket connection.  I want the client to time
> >> out the socket connection if the server does not respond within,
> >> let's say, 60 seconds,[...]
>
> >Found in C:\usr\lib\pod\perlfaq8.pod
> >   How do I timeout a slow event?
> >
> >Use the alarm() function, probably in conjunction with a signal handler,
> >as documented in the section on "Signals" in the perlipc manpage and the
> >section on ``Signals'' in the Camel. You may instead use the more
> >flexible Sys::AlarmCall module available from CPAN.
> >
> >Does this help?
>
> I looked at alarm() initally, but I rejected it because it wasn't
> clear that it would work properly on NT (it "sends a SIGALRM signal
> to the current process after EXPR seconds" -- will that work on
> NT?), and because it would be nice to have finer granularity than
> one second.  I may end up using alarm() if I have to, but IO::Select
> just seems more elegant, and really looks to me as though it is
> *intended* for doing what I want to do, if only I knew how to use
> it properly.  But if I've misunderstood, and IO::Select is *not*
> appropriate for setting timeouts on a socket, then I'd like to
> know.  Is this what you are telling me?
> -- 
> John Brock
> jbrock@panix.com
>




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

Date: 9 Jun 2003 11:57:40 -0700
From: carltonbrown@hotmail.com (Carlton Brown)
Subject: Re: move() from File::Copy package fails with cross-device link
Message-Id: <aa611a32.0306091057.3ea1b710@posting.google.com>

Eric Amick <eric-amick@comcast.net> wrote in message news:<09a5evk2vbjrgb0959bks7gldu5rdtu5lf@4ax.com>...

> I looked at the code, and what's happening is that you're getting the
> error code from the failed rename attempt (which was saved in local
> variables) instead of the failed unlink.  I agree that the error code is
> misleading.  The fix looks quite simple; you just need to save the error
> code from the failed copy/unlink attempt before trying to clean up the
> possibly copied file, then restore the code before returning from the
> function.

Thanks.   In other words, "Don't use File::Copy::move()"   :^)

I don't expect software to be perfect, certainly my own is not all
perfect, but I do think it should at least be truthful about why it's
failing.   So I submitted a bug report to CPAN (bug ID cpan #2763).


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

Date: Mon, 09 Jun 2003 18:08:15 GMT
From: Steve Grazzini <grazz@pobox.com>
Subject: Re: newbie: will a big array hurt performance?
Message-Id: <j24Fa.53775$fT5.26306@nwrdny01.gnilink.net>

Nicholas Dronen <ndronen@io.frii.com> wrote:
> Steve Grazzini <grazz@pobox.com> wrote:
> SG> Nicholas Dronen <ndronen@io.frii.com> wrote:
>>> 
>>> If you want to do *some* read-ahead, then something like 
>>> this might work. [ snip ]
>>>
>>>      # Grab two lines after root's.  This too is arbitrary.
>>>      @d[0,1] = <$f>, <$f>;
> 
> SG> That's list context, so the first readline() slurps the
> SG> rest of the file.
> 
> I think you're mistaken.  See the perldata man page.
>
>        Entire arrays (and slices of arrays and hashes) are
>        denoted by '@', which works much like the word "these" or
>        "those" does in English, in that it indicates multiple
>        values are expected.
> 
>            @days               # ($days[0], $days[1],... $days[n])
>            @days[3,4,5]        # same as ($days[3],$days[4],$days[5])
>            @days{'a','c'}      # same as ($days{'a'},$days{'c'})

Putting *any* of those (array, slice or list) on the LHS of an
assignment forces list context, and in list context the readline()
operator slurps the rest of the file.

That's why this doesn't print "three":

    #!/usr/bin/perl

    ($d[0],$d[1]) = <DATA>, <DATA>;
    print while <DATA>

    __END__
    one
    two
    three

The first readline() slurps the rest of the file and the second
one returns an empty list.

    ($d[0],$d[1]) = (qw(one two three), ());

The third, which is in scalar context, returns undef.

-- 
Steve


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

Date: 09 Jun 2003 18:29:37 GMT
From: Nicholas Dronen <ndronen@io.frii.com>
Subject: Re: newbie: will a big array hurt performance?
Message-Id: <3ee4d211$0$203$75868355@news.frii.net>

Steve Grazzini <grazz@pobox.com> wrote:
SG> Nicholas Dronen <ndronen@io.frii.com> wrote:
>> Steve Grazzini <grazz@pobox.com> wrote:
>> SG> Nicholas Dronen <ndronen@io.frii.com> wrote:
>>>> 
>>>> If you want to do *some* read-ahead, then something like 
>>>> this might work. [ snip ]
>>>>
>>>>      # Grab two lines after root's.  This too is arbitrary.
>>>>      @d[0,1] = <$f>, <$f>;
>> 
>> SG> That's list context, so the first readline() slurps the
>> SG> rest of the file.
>> 
>> I think you're mistaken.  See the perldata man page.
>>
>>        Entire arrays (and slices of arrays and hashes) are
>>        denoted by '@', which works much like the word "these" or
>>        "those" does in English, in that it indicates multiple
>>        values are expected.
>> 
>>            @days               # ($days[0], $days[1],... $days[n])
>>            @days[3,4,5]        # same as ($days[3],$days[4],$days[5])
>>            @days{'a','c'}      # same as ($days{'a'},$days{'c'})

SG> Putting *any* of those (array, slice or list) on the LHS of an
SG> assignment forces list context, and in list context the readline()
SG> operator slurps the rest of the file.

SG> That's why this doesn't print "three":

SG>     #!/usr/bin/perl

SG>     ($d[0],$d[1]) = <DATA>, <DATA>;
SG>     print while <DATA>

SG>     __END__
SG>     one
SG>     two
SG>     three

Gotcha.  My mistake.

Regards,

Nicholas

-- 
"Why shouldn't I top-post?"    http://www.aglami.com/tpfaq.html
"Meanings are another story."  http://www.ifas.org/wa/glossolalia.html


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

Date: Mon, 9 Jun 2003 14:25:48 -0500
From: tadmc@augustmail.com (Tad McClellan)
Subject: Re: newbie: will a big array hurt performance?
Message-Id: <slrnbe9nps.hbt.tadmc@magna.augustmail.com>

Nicholas Dronen <ndronen@io.frii.com> wrote:
> Steve Grazzini <grazz@pobox.com> wrote:
> SG> Nicholas Dronen <ndronen@io.frii.com> wrote:

>>>      @d[0,1] = <$f>, <$f>;
> 
> SG> That's list context, 

> I think you're mistaken.  See the perldata man page.
> 
>        "those" does in English, in that it indicates multiple
>        values are expected.


"multiple values expected" _does_ mean "list context".


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


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

Date: 9 Jun 2003 11:24:23 -0700
From: dwlepage@yahoo.com (david)
Subject: passing argvs to interactive program (perl wrapper)
Message-Id: <b09a22ae.0306091024.253a89cd@posting.google.com>

I want to write a shell wrapper for 'login' on Solaris, but written in
perl. Could someone point me in the direction of how to interact with
an interactive program? I want the user to be able to feed in their
username / password on a single line:

perl prog.pl <username> <pwd> 

and pass this to the program. 
The program asks for :
Id: 
Enter Password:

Ive tried using system() and open() but I suspect I must have to
interact with STDOUT somehow.

open(PROG, "|/usr/bin/login");
print $_ "$1\n";
print $_ "$2\n"; 

I know this is wrong, but im just starting to try and figure it out -
get some ideas.

Thanks,

d


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

Date: Mon, 9 Jun 2003 20:45:34 +0200
From: "Alan J. Flavell" <flavell@mail.cern.ch>
Subject: Re: Perl CGI and Downloading Files - How?
Message-Id: <Pine.LNX.4.53.0306092040270.15694@lxplus096.cern.ch>

On Mon, Jun 9, 10ghz@radiate.com inscribed on the eternal scroll:

> OK, I have a small Perl script that runs on my server.

Uh-uh.

> It is supposed to show zip files for download.
> But, I don't want the User to know where those zip  files are located on the
> sevrer. Can that be done?

Yes.  But define "located"?  Do you actually understand your question?

It's nothing specific to Perl, anyway.  You seem to need some kind
of primer to WWW concepts before you understand what it is that you
really wanted to ask.  Presumably you're trying to control access in
some way, but we don't yet know how or why.  I'd suggest a group
somewhere in the comp.infosystems.www.... hierarchy would be more
apt, until you've got a question that's specific to Perl.


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

Date: Mon, 09 Jun 2003 20:34:39 GMT
From: 10ghz@radiate.com
Subject: Re: Perl CGI and Downloading Files - How?
Message-Id: <o2p9evkjn74s0e45vt291b8aplrmh6jbqs@4ax.com>

On Mon, 9 Jun 2003 20:45:34 +0200, "Alan J. Flavell" <flavell@mail.cern.ch>
wrote:

>On Mon, Jun 9, 10ghz@radiate.com inscribed on the eternal scroll:
>
>> OK, I have a small Perl script that runs on my server.
>
>Uh-uh.
>
>> It is supposed to show zip files for download.
>> But, I don't want the User to know where those zip  files are located on the
>> sevrer. Can that be done?
>
>Yes.  But define "located"?  Do you actually understand your question?
>
>It's nothing specific to Perl, anyway.  You seem to need some kind
>of primer to WWW concepts before you understand what it is that you
>really wanted to ask.  Presumably you're trying to control access in
>some way, but we don't yet know how or why.  I'd suggest a group
>somewhere in the comp.infosystems.www.... hierarchy would be more
>apt, until you've got a question that's specific to Perl.

No, wrong answer. The correct response to my question
should have been:
"put the zip somewhere in the filesystem where it's
not accessible via http, and use Perl to open
this file and to send its contents to the
browser with the appropriate content-type header."

I was just thinking in terms of providing a link when I should
have been thinking about my script actually sending the file.
Next time concentrate a little harder on what I'm thinking
and not on what I'm writing!

For anyone reading this thread here is a link to some Perl
code I found. I haven't tested it but it looks reasonable.

http://groups.google.com/groups?q=Perl+hide+files+download&hl=en&lr=&ie=UTF-8&oe=UTF-8&selm=386335db%240%24229%40nntp1.ba.best.com&rnum=5


Entia non sunt multiplicanda praeter necessitatem.


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

Date: 9 Jun 2003 12:29:49 -0700
From: rs@cyberspace.org (Kir)
Subject: perl Conditional compile - Running Win32 library calls on AIX
Message-Id: <bbceda2.0306091129.39d076ab@posting.google.com>

Fellow Perl Experts,

I need a code snippette to run both on AIX and NT.
the "use Win32::Registry" runs only on NT and causes
error on AIX.  Is there a way to write a program that runs
both on NT and AIX?  I use "eval 'use Win32::Registry' if $isNT;"
statement, but this is producing unexpected results in my program..

Please email me at rs@cyberspace.org if you have a work around for
this problem..

Many thanks,
Faithful


if (-d "c:\\") {$isNT=1;}  
if ($isNT) {&check_registry;}

sub check_registry
{
  eval 'use Win32::Registry' if $isNT;
  my $Register = "SYSTEM\\CurrentControlSet\\Services\\myservice";
  my $RegType, $RegValue, $RegKey, $value;
  my  %values;
  $HKEY_LOCAL_MACHINE->Open($Register,$hkey);
  $hkey->GetValues(\%values);
  $hkey->SetValueEx("Start",0,&REG_DWORD,2);  
 $hkey->SetValueEx("Start",0,REG_DWORD,2); 
  $hkey->Close();
}


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

Date: Mon, 9 Jun 2003 13:27:19 -0700
From: "Mothra" <mothra@nowhereatall.com>
Subject: Re: perl Conditional compile - Running Win32 library calls on AIX
Message-Id: <3ee4ec4d$1@usenet.ugs.com>

Hi Kir

> I need a code snippette to run both on AIX and NT.
> the "use Win32::Registry" runs only on NT and causes
> error on AIX.  Is there a way to write a program that runs
> both on NT and AIX?  I use "eval 'use Win32::Registry' if $isNT;"
> statement, but this is producing unexpected results in my program..
>
> Please email me at rs@cyberspace.org if you have a work around for
> this problem..
>
> Many thanks,
> Faithful
>
>
> if (-d "c:\\") {$isNT=1;}

First off, in order to load specific modules depending on the OS I use
something like this:

use warnings;
use strict;

BEGIN {
    if ( $^O =~ /MSWin32/ ) {
        require Win32::Registry;
        print "Running under WNT\n";

    }
    else {

        print "Not running under NT\n";

    }

}

This small script will run under unix as well an NT.

> if ($isNT) {&check_registry;}

Then
if ($^O =~/MSWin32/)  {
   check_registry();
}

>
> sub check_registry
> {
>   eval 'use Win32::Registry' if $isNT;

No need for the above line since it is already loaded;

>   my $Register = "SYSTEM\\CurrentControlSet\\Services\\myservice";
>   my $RegType, $RegValue, $RegKey, $value;
>   my  %values;
>   $HKEY_LOCAL_MACHINE->Open($Register,$hkey);
>   $hkey->GetValues(\%values);
>   $hkey->SetValueEx("Start",0,&REG_DWORD,2);
>  $hkey->SetValueEx("Start",0,REG_DWORD,2);
>   $hkey->Close();
> }

I hope this helps!!

Mothra




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

Date: Mon, 9 Jun 2003 20:49:53 +0000 (UTC)
From: hudson@swcp.com (Tramm Hudson)
Subject: Re: Perl exam - fair or not?
Message-Id: <bc2rth$hev$1@iruka.swcp.com>

Brian McCauley  <nobull@mail.com> wrote:
> hudson@swcp.com (Tramm Hudson) writes:
> > Brian McCauley  <nobull@mail.com> wrote:
> > > hudson@swcp.com (Tramm Hudson) writes:
> > > > And neither 'local' nor 'my' are functions.  They are keywords that
> > > > modify the storage class of variables.
> > >
> > > No, 'my' is a storage class modifier, 'local' is not.
> > 
> > While I agree that 'local' does not change the storage class of the
> > variables (they still go into the package namespace), and that it does
> > have a runtime effect as well,
>
> I am aware that the meaning of the phrase "as well" is a little
> different in American from it is in English.
>
> In English the above sentence implies you think local() has some
> semantics other than at runtime.  If this is the case then what do you
> think they are?

It tells the compiler that the variable is to be found in the package
namespace, as opposed to the current lexical scope, which is a compile
time effect rather than a runtime one.  However, it appears that
Perl 5.6.1 does not allow the direct localization of an unqualified
variable, so there is no actual compile time effect.

osbox:/tmp: cat scope2
#!/usr/bin/perl
use warnings;
use strict;

our ($bar) = 'package scope';

sub foo
{
        my $bar = 'lexical scope';
        local $bar = 'package scope again';
}
__END__
osbox:/tmp: perl scope2
Can't localize lexical variable $bar at scope2 line 10.



> > I believe it is roughly equivilant to C's "auto" storage class
> > modifier.
>
> My C is a bit rusty by IIRC C's auto is, on the contrary, analagous to
> Perl's my().

You are correct that the storage class of auto is analagous to my, but
I was describing the behaviour of the two not the actual type of storage
that they create.  The fact that they both request the default class was
my claim, not that Perl and C's default storage classes are the same.
As I wrote before:

> > [...] as storage class modifiers [auto and local]
> > both request the default storage class of the language (package
> > namespace or on the stack, respectively).

However, it is all really moot.  If you want to think of my and local
as functions, I won't stop you or even claim that it is a misunderstanding
of Perl.  It is just another way to look at it.

Trammell
-- 
  -----|----- hudson@osresearch.net                   W 240-283-1700
*>=====[]L\   hudson@rotomotion.com                   M 505-463-1896
'     -'-`-   http://www.swcp.com/~hudson/                    KC5RNF



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

Date: Mon, 9 Jun 2003 16:18:29 -0400
From: "Joe Hasting" <hasting@agere.com>
Subject: PERLCC  segmentation fault
Message-Id: <bc2q2m$8at$1@alageremail2.agere.com>

When running perlcc,  we used the -B switch, but when running the output
executable perl, it completes with:

Segmentation Fault(coredump)

Can anyone suggest a stable version, or switch combination that can make the
executable error free?  Is there an alternate perl compilier that can be
used?

thanks




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

Date: Mon, 9 Jun 2003 13:32:54 -0700
From: "Mothra" <mothra@nowhereatall.com>
Subject: Re: PERLCC  segmentation fault
Message-Id: <3ee4ed9d@usenet.ugs.com>

Hi Joe,

"Joe Hasting" <hasting@agere.com> wrote in message
news:bc2q2m$8at$1@alageremail2.agere.com...
> When running perlcc,  we used the -B switch, but when running the output
> executable perl, it completes with:
>
> Segmentation Fault(coredump)
>
> Can anyone suggest a stable version, or switch combination that can make
the
> executable error free?  Is there an alternate perl compilier that can be
> used?

I don't think perlcc has ever worked correctly. You might
want to take a look at PAR on CPAN or search the web for
PerlApp, Perl2exe.

Hope this helps

Mothra




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

Date: 9 Jun 2003 14:00:16 -0700
From: ksu1wd@mit.edu (Avatar)
Subject: Quick question
Message-Id: <415d5171.0306091300.353da158@posting.google.com>

$search=~/(.*)blah/;
I know that .* gets placed into $1.  
$search2=~/(.*)blah/;
Does that overwrite the orginal $1, append onto it, or cause an error?


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

Date: Mon, 09 Jun 2003 21:05:16 GMT
From: "Ian.H [dS]" <ian@WINDOZEdigiserv.net>
Subject: Re: Quick question
Message-Id: <qjt9evshqshjv49cs7fhcliuq5j1orq0ge@4ax.com>
Keywords: Remove WINDOZE to reply

-----BEGIN xxx SIGNED MESSAGE-----
Hash: SHA1

Whilst lounging around on 9 Jun 2003 14:00:16 -0700, ksu1wd@mit.edu
(Avatar) amazingly managed to produce the following with their
Etch-A-Sketch:

> $search=~/(.*)blah/;
> I know that .* gets placed into $1.  
> $search2=~/(.*)blah/;
> Does that overwrite the orginal $1, append onto it, or cause an
> error?  


What did your tests show?



Regards,

  Ian

-----BEGIN xxx SIGNATURE-----
Version: PGP 8.0

iQA/AwUBPuT2iWfqtj251CDhEQLC/QCeIkg4h8LrR281cYGbXU1mW7qo/NQAoJG4
Wq3jeank1AYp75YcEwzEBo7h
=QZ4q
-----END PGP SIGNATURE-----

-- 
Ian.H  [Design & Development]
digiServ Network - Web solutions
www.digiserv.net  |  irc.digiserv.net  |  forum.digiserv.net
Programming, Web design, development & hosting.


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

Date: Mon, 09 Jun 2003 19:34:13 GMT
From: snart@nospam.com (Ralph Snart)
Subject: Re: Strange observation
Message-Id: <slrnbe9o9o.248f.snart@cluttered.com>

On 7 Jun 2003 11:57:24 -0700, Go Perl <puissant00@yahoo.com> wrote:
>Basically there are 18 fields in the input line 15 are present and are
>assigned some values 16 and17 the application takes default value and
>the 20the field is the identifier 70. which i am trying to compare and
>hence the ifels loop to compare the $read==70 or not. My problem is
>there are 80 columns and each numberis given 4 columns. If i use
>$read[7]==70 it is working and printing the numbers but if i use
>$read[16]==70 its not working which it is supposed to and the line
>formatting is same %4d * 15 %20d = 80 columns 15 for 15 numbers and
>then forgetting some default values after these numbers nad moving to
>end of the line which is 70 hence %20d. Now my question is why is the
>order not working like read[16] as the end of the line and read[7] is
>working fine.

use Data::Dumper and dump out the array before you get to the if.

use Data::Dumper;
print Dumper(\@read);

also, my apologies if english is not your first language, but i have
no idea from your description exactly what it is that you are trying
to do.

-rs-


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

Date: Mon, 09 Jun 2003 19:37:37 GMT
From: snart@nospam.com (Ralph Snart)
Subject: Re: Unusual Can't load fail (web only)
Message-Id: <slrnbe9og4.248f.snart@cluttered.com>

On Sat, 7 Jun 2003 09:40:44 -0400, Mike Bobbitt <Mike@Army.ca> wrote:
>This looks like the most likely situation... Turns out my LD_LIBRARY_PATH
>appears to be null!

that's usually fine.

>I'm running RedHat 9, so I've added a definition to /etc/profile, and added
>"PassEnv LD_LIBRARY_PATH" to my httpd.conf.
>
>Does that sound right, or am I on the wrong track?

you probably want to run (as root) ldconfig to add the directories where
your perl libraries and mysql libraries live.

-rs-


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

Date: 9 Jun 2003 14:36:10 -0700
From: gupit@yahoo.com (Gupit)
Subject: Using ParseRecur from Date::Manip
Message-Id: <1ea0ec40.0306091336.3086ab87@posting.google.com>

I am having a hard time trying to get ParseRecur to work.
I want to get all dates corresponding to a certain weekday starting
from a given start date; e.g. all mondays since 4/1/03. I have tried a
lot of different combinations of the recur string but nothing seems to
work (it returns an empty string).
Has anyone come across any article which describes the ParseRecur
recur string format in more detail than the Date::Manip man page?

Thanks in advace,
Gupit


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

Date: 6 Apr 2001 21:33:47 GMT (Last modified)
From: Perl-Users-Request@ruby.oce.orst.edu (Perl-Users-Digest Admin) 
Subject: Digest Administrivia (Last modified: 6 Apr 01)
Message-Id: <null>


Administrivia:

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

	subscribe perl-users
or:
	unsubscribe perl-users

to almanac@ruby.oce.orst.edu.  

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

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

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


------------------------------
End of Perl-Users Digest V10 Issue 5099
***************************************


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