[22520] in Perl-Users-Digest

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

Perl-Users Digest, Issue: 4741 Volume: 10

daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Fri Mar 21 18:07:06 2003

Date: Fri, 21 Mar 2003 15:05:08 -0800 (PST)
From: Perl-Users Digest <Perl-Users-Request@ruby.OCE.ORST.EDU>
To: Perl-Users@ruby.OCE.ORST.EDU (Perl-Users Digest)

Perl-Users Digest           Fri, 21 Mar 2003     Volume: 10 Number: 4741

Today's topics:
        "-s" test on XP <john_heumann@agilent.com>
    Re: CHMOD problems <nobull@mail.com>
    Re: CHMOD problems <noreply@gunnar.cc>
    Re: CHMOD problems <southtownoutkast777@hotmail.com>
    Re: CHMOD problems <nobull@mail.com>
    Re: CHMOD problems <jurgenex@hotmail.com>
    Re: getOpenFile with -initialdir (Anno Siegel)
    Re: help writing a perl script so that it's faster than <bigj@kamelfreund.de>
    Re: How can I localize a $i at a expreg? (i5513)
        How to use Net::FTP - FTP Client class through a Firewa (Joe Kamenar)
    Re: How to use Net::FTP - FTP Client class (Kevin Cline)
    Re: How to use Net::FTP - FTP Client class (Anno Siegel)
        Memory used by hashes <nospam@euro.com>
    Re: print to file safley <usenet@tinita.de>
    Re: print to file safley <usenet@tinita.de>
    Re: print to file safley <tassilo.parseval@rwth-aachen.de>
    Re: print to file safley <usenet@tinita.de>
    Re: print to file safley <tassilo.parseval@rwth-aachen.de>
    Re: Problem with Getopt::Std and getopts().... (John Smith)
    Re: Problem with Getopt::Std and getopts().... (Gary E. Ansok)
    Re: Reverse assignment operator <torelg@start.no>
    Re: Reverse assignment operator (Anno Siegel)
        Working Perl DBD Ingres and DBI (jm)
        Digest Administrivia (Last modified: 6 Apr 01) (Perl-Users-Digest Admin)

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

Date: Fri, 21 Mar 2003 15:18:49 -0700
From: "John Heumann" <john_heumann@agilent.com>
Subject: "-s" test on XP
Message-Id: <1048285134.76581@emperor.labs.agilent.com>

Using 5.6.1, the "-s" test seemed to return true for a directory
on WinNT if a) the directory existed, and b) was not empty
(had non-zero size). This matches the documentation. On XP,
the same test fails even though the directory exists and isn't
empty. I'm guessing that the size portion of this test is incorrectly
returning 0, since "-d" returns true.

Is this a known problem on XP?

Thanks in advance,
-jh-




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

Date: 21 Mar 2003 19:06:02 +0000
From: Brian McCauley <nobull@mail.com>
Subject: Re: CHMOD problems
Message-Id: <u9he9w35gl.fsf@wcl-l.bham.ac.uk>

"David S." <southtownoutkast777@hotmail.com> chooses to insult me by
rudely vomiting TOFU in our faces:

> well actually..    it's not the only info i have. 

To what does 'it' refer?  I can't even guss the context that was
intended to appear in.

>   i setup the loops and
> stuff like this for different reasons to..   I have more source code within
> the for loops, etc.....

I suspect this is in reply to:

> >   You forgot the 'my'.
> >
> >   You used a C-style 'for' for no reason ( you could simply iterate
> >   over the values in @files).
> >
> >   You used a 'for' for no reason.  chmod() takes a list of filenames.

Still doesn't explain the lack of my or the use of the C-style for.

> and as far as checking the success of the chmod,
> i had set

I suspect this is in reply to:

> >   You forgot to check the sucess of chmod().

> $cnt = chmod 0755 $file;  (or whatever i called it)
> and $cnt was equal to 2, i have no clue what relevance that has.

Clues as to the relevance of the return values of Perl functions can
often be found by looking up the function in question in the relevant
Perl reference manual.  (Actually this applies to most programming
languages not just Perl).

Are you really saying chmod() was passed one filename and reports that
it has sucessfully changed two? Weird!
 
> "Brian McCauley" <nobull@mail.com> wrote in message
> news:u9llz8372y.fsf@wcl-l.bham.ac.uk...

> > Asking stealth CGI questions is considered rude.

> > I suspect that your problem has nothing to do with Perl so you are
> > looking for solutions in the wrong place.


Well, _is_ this a stealth CGI question?

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


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

Date: Fri, 21 Mar 2003 20:38:26 +0100
From: Gunnar Hjalmarsson <noreply@gunnar.cc>
Subject: Re: CHMOD problems
Message-Id: <b5fq3k$295sl5$1@ID-184292.news.dfncis.de>

David S. wrote:
> I'm writing a program that needs to chmod an array of cgi scripts.
----------------^^^^^^^

Are you running that program as a CGI script? In that case it can be a 
file ownership problem.

/ Gunnar



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

Date: Fri, 21 Mar 2003 20:07:12 GMT
From: "David S." <southtownoutkast777@hotmail.com>
Subject: Re: CHMOD problems
Message-Id: <QhKea.50249$fa.2921555@twister.austin.rr.com>

i didn't mean to sound rude.   I'm just commenting....

and i just have my own style of programming, which doesn't really affect too
much anyways

and yes, for some reason it returned 2...  i'm not sure why.....



"Brian McCauley" <nobull@mail.com> wrote in message
news:u9he9w35gl.fsf@wcl-l.bham.ac.uk...
> "David S." <southtownoutkast777@hotmail.com> chooses to insult me by
> rudely vomiting TOFU in our faces:
>
> > well actually..    it's not the only info i have.
>
> To what does 'it' refer?  I can't even guss the context that was
> intended to appear in.
>
> >   i setup the loops and
> > stuff like this for different reasons to..   I have more source code
within
> > the for loops, etc.....
>
> I suspect this is in reply to:
>
> > >   You forgot the 'my'.
> > >
> > >   You used a C-style 'for' for no reason ( you could simply iterate
> > >   over the values in @files).
> > >
> > >   You used a 'for' for no reason.  chmod() takes a list of filenames.
>
> Still doesn't explain the lack of my or the use of the C-style for.
>
> > and as far as checking the success of the chmod,
> > i had set
>
> I suspect this is in reply to:
>
> > >   You forgot to check the sucess of chmod().
>
> > $cnt = chmod 0755 $file;  (or whatever i called it)
> > and $cnt was equal to 2, i have no clue what relevance that has.
>
> Clues as to the relevance of the return values of Perl functions can
> often be found by looking up the function in question in the relevant
> Perl reference manual.  (Actually this applies to most programming
> languages not just Perl).
>
> Are you really saying chmod() was passed one filename and reports that
> it has sucessfully changed two? Weird!
>
> > "Brian McCauley" <nobull@mail.com> wrote in message
> > news:u9llz8372y.fsf@wcl-l.bham.ac.uk...
>
> > > Asking stealth CGI questions is considered rude.
>
> > > I suspect that your problem has nothing to do with Perl so you are
> > > looking for solutions in the wrong place.
>
>
> Well, _is_ this a stealth CGI question?
>
> --
>      \\   ( )
>   .  _\\__[oo
>  .__/  \\ /\@
>  .  l___\\
>   # ll  l\\
>  ###LL  LL\\




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

Date: 21 Mar 2003 21:13:10 +0000
From: Brian McCauley <nobull@mail.com>
Subject: Re: CHMOD problems
Message-Id: <u93clg2zkp.fsf@wcl-l.bham.ac.uk>

Once again "David S." <southtownoutkast777@hotmail.com> rudely vomits
TOFU in our faces:

> i didn't mean to sound rude.

Then stop _being_ rude.  You do _know_ that top-posting is rude don't
you?  You are spitting in my face.  Despite being asked to stop.
Don't be supprised if I seem a little unfriendly.

>   I'm just commenting....

On what?  I have no idea!  You give no context.
 
> and i just have my own style of programming, which doesn't really affect too
> much anyways

Er, what are you talking about?

Are you perhaps saying that...

  for ( $k=0; $k<@files; $k++) 

 ... rather than the more Perlish ...

  for my $k ( 0 .. $#files )

 ... or ...

  for my $file ( @files )

 ...is a harmless affectation?

Well, maybe using the C-style for is harmless but missing out the my
is not.

> and yes, for some reason it returned 2...  i'm not sure why.....

For the benifit of other readers I'll explain that this is in the
context of chmod() called with a single file argument.

I think looking into it may be productive.

> > > > I suspect that your problem has nothing to do with Perl so you are
> > > > looking for solutions in the wrong place.
> >
> > Well, _is_ this a stealth CGI question?

Well, ***IS*** this a stealth CGI question!?!?!?

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


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

Date: Fri, 21 Mar 2003 22:16:10 GMT
From: "Jürgen Exner" <jurgenex@hotmail.com>
Subject: Re: CHMOD problems
Message-Id: <KaMea.72057$iq1.43658@nwrddc02.gnilink.net>

David S. wrote:
> I'm writing a program that needs to chmod an array of cgi scripts.
> Yet everytime i run
[...]
> but all i got was,
>
> WARNING:  Can not change permissions for script.cgi
[...]

Then apparently you don't have permissions to change the access permissions
for those files

> Yet, if i manually change the permissions for files (outside of the
> perl environment), i have no problem.....

What do you mean by "perl environment"?

jue





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

Date: 21 Mar 2003 22:27:47 GMT
From: anno4000@lublin.zrz.tu-berlin.de (Anno Siegel)
Subject: Re: getOpenFile with -initialdir
Message-Id: <b5g3l3$gf0$1@mamenchi.zrz.TU-Berlin.DE>

Pascal Zerwetz <pzerwetz@yaccom.com> wrote in comp.lang.perl.misc:
> Hello
> First many thanks to Christian Winter!
> I am using perl/Tk in Cygwin, on W2k.
> When I open the getOpenFile dialog, even with use of Cwd and -initialdir =
> Cwd,

Your syntax is wrong, this can't be your actual code.  It should be
"-initialdir => getcwd".  However, this would have no visible effect
because it is also the default.  Are you confused about what your
current directory is?

Anno


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

Date: Fri, 21 Mar 2003 21:24:37 +0100
From: "Janek Schleicher" <bigj@kamelfreund.de>
Subject: Re: help writing a perl script so that it's faster than sed
Message-Id: <pan.2003.03.21.20.24.36.258422@kamelfreund.de>

Dave wrote at Fri, 21 Mar 2003 09:19:25 -0800:

> Perl newbie - standard disclaimer

?!  :-)

> I need a script that will scan a text file to verify I have correct
> data.
> 
> The text file reads:
> 
>  -----------------------------------------------------------------------
> OPEN:  File addfaa.1.1.96.73.pgg4210 to be Opened on Unit 10 Exists
>  -------------------------------------------------------------------
>    Y M D H DAY   FC STASH    PROC   EXP   LREC  GD      LEV    VC 
> 1964020100   0 1374   101       0 addfa   7008   1 0.9970        9  
> 1964020100   0 1374   101       0 addfa   7008   1 0.9750        9
> [ ... ]
>
> * I know the file is correct if: 
> [ ... ]
> 
> Since the text files have a fixed length, would it be easier to to go
> straight to line 5, examine it, then go to the last line (number
> 13798) and examine it?
> 
> I've written something that works using sed and awk, but I am not
> satisfied with the speed.  Perhaps Perl can do this faster?

Perhaps, what have you tried so far ?
Here are some ideas for you:
You can use the Tie::File module to read some lines,
if every line has the same length,
you can work with the seek command (see perldoc -f seek for details).
Another way could be to use the module File::ReadBackwards to go directly
to the last line.

I'm sorry that I don't show any code, but at the one side, I don't want to
do your job (:-)) and on the other side, I don't have any imagination what
"faster" means to you, as I don't know how ineffective your existing
solution is and how effective you'll need it. (And the most effective way
is still to write it in C).


Greetings,
Janek


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

Date: 21 Mar 2003 12:05:20 -0800
From: i5513@hotmail.com (i5513)
Subject: Re: How can I localize a $i at a expreg?
Message-Id: <a657ec02.0303211205.69a71972@posting.google.com>

anno4000@lublin.zrz.tu-berlin.de (Anno Siegel) wrote in message news:<b5f39i$nt8$1@mamenchi.zrz.TU-Berlin.DE>...
> i5513 <i5513@hotmail.com> wrote in comp.lang.perl.misc:
> > Hi! I have a new problem :(
> > 
> > Imagine (this is only a example, i'd like it was general):
> > 
> > $er = "(a) (b\w*) (b\w*) (c)";
> > $word = "d a b b c d a b b c d";
> > 
> > while ($word =~ /($er)/g)
> > {
> >   I want to know how many words are there before second b
> > }
> > 
> > How can I obtain the pos of ($4)?
> 
> That would be $-[4]. (perldoc perlvar)
Thanks! It's just I was wanted!!!!!!!!!!!!!!!!!

I didn't read perlvar!!!!

Thanks you again! Problem corrected!!


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

Date: 21 Mar 2003 12:02:02 -0800
From: joey19020@aol.com (Joe Kamenar)
Subject: How to use Net::FTP - FTP Client class through a Firewall
Message-Id: <fca4c27e.0303211202.1c00aec@posting.google.com>

Greetings,

Thanks to those who answered my previous question on using the
net::ftp. I realized that I have to get through our firewall to get to
the ftp site. I can not find any examples of how to do this.

If I have the following info, how do I construct the $ftp statement to
create the $ftp object, using the firewall parameters?

FIREWALL INFO:
HOST=ftp-gateway.xxxx.net
USERID=fundstn
PASSWORD=password

$ftp statement:
$ftp = Net::FTP->new("ftp.fund.xxxxx.com", Debug => 1) or die("Unable
to create ftp object");

If I run the statement from a computer not behind the firewall, the
object gets created. When I run it from behind the firewall, the die
condition happens.

I imagine that I need something like:
$ftp = Net::FTP->new("ftp.fund.xxxxx.com", Firewall =>
ftp-gateway.xxxx.net, Debug => 1)

but how do I specify the user ID and password?

Thanks in advance for any solutions.


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

Date: 21 Mar 2003 11:44:26 -0800
From: kcline17@hotmail.com (Kevin Cline)
Subject: Re: How to use Net::FTP - FTP Client class
Message-Id: <ba162549.0303211144.4a66f0a0@posting.google.com>

joey19020@aol.com (Joe Kamenar) wrote in message news:<fca4c27e.0303201332.233e7f54@posting.google.com>...
> Greetings,
> 
> I want to use the following sort of code in one of my scripts:
> 
> #!/usr/bin/perl
> print "Content-type: text/html\n\n";
> 
> use Net::FTP;
> 
>     $ftp = Net::FTP->new("ftp.fund.xxxxx.com", Debug => 0);
>     $ftp->login("nationuser",'xxxxxx');
> ...
> When I run this, I get the following:
> 
> Can't call method "login" on an undefined value at C:\Perl\bin\test.pl
> line 7.

Can you ftp that machine from the command line?


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

Date: 21 Mar 2003 21:05:53 GMT
From: anno4000@lublin.zrz.tu-berlin.de (Anno Siegel)
Subject: Re: How to use Net::FTP - FTP Client class
Message-Id: <b5furh$dff$1@mamenchi.zrz.TU-Berlin.DE>

Josh McAdams <jmcada@hotmail.com> wrote in comp.lang.perl.misc:
> It's possible that there is a firewall issue.  Can you manually ftp from the
> machine that you are on to the target machine using the command line program
> 'ftp'?  If you can't, then your firewall (or your targets firewall) might be
> in the way.
> 
> Also, I seem to remember that Net::FTP has different debugging levels.
> Check the documentation, but you might can set Debug=>3, or something
> similar, in order to get more messages.

[TOFU snipped]

This is good advice and makes a lot of sense. Just one objection: please
don't top-post.  See the posting guidelines for this group which are
posted regularly.

Anno


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

Date: Fri, 21 Mar 2003 14:17:42 -0800
From: Fr€d <nospam@euro.com>
Subject: Memory used by hashes
Message-Id: <3E7B8F86.6C2A@euro.com>

I am running a simple perl program that sums 5 variables over 100Gb of
data.  I have 5 hashes that use the same 12 character key.  There are
about 4 million keys.  Basically the program is:

while (<INPUT>) {
  $key =substr($_,0,12);
  extract 5 numbers from $_;
  $sum1{$key} ++;
  $sum2{$key} += $val;
  ... (for all 5 sums)
}

The job is currently running and is using about 685Mb of memory at about
2/3 the way thru the data.  80% of the keys have appeared by now I'd
expect.  

Can anyone explain why this is using so much memory?  Even given that 
all variables are double precision, I can only come up with about 20% of
what's being used.  I thought all hashes that used the same key were
stored in one place; this seems to indicate that this isn't the case.

This is perl, v5.6.1 built for i386-linux   

Thanks


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

Date: 21 Mar 2003 22:18:17 GMT
From: Tina Mueller <usenet@tinita.de>
Subject: Re: print to file safley
Message-Id: <tinhc4dy1$312$tina@news01.tinita.de>

Tassilo v. Parseval <tassilo.parseval@rwth-aachen.de> wrote:
> Also sprach Tina Mueller:

>> Tassilo v. Parseval <tassilo.parseval@rwth-aachen.de> wrote:
>> 
>>> Since you asked about safety: This is safe as long as you are sure that
>>> only processes that respect advisory locks write into these files. There
>>> could still be a program that simply opens one of the files and writes
>>> into it. But since the above script is probably the only program working
>>> with these files, it should be reasonably safe.
>> 
>> but i'd say it's only safe if you open the file for reading and
>> writing at the same time:

> Hmmh, why?

uhm, i might have overseen something here, but imagine two
processes (P1,P2) call the script. P1 reads the file.
P2 reads the file. both processes now have e.g. lines A,B,C.
P1 pushes a new line D into the array and has now A,B,C,D.
P2 does the same with E and gets A,B,C,E.
P1 writes to the file and exits. P2 writes to the file.
entry D got lost.

-- 
http://www.tinita.de/     \  enter__| |__the___ _ _ ___
http://Movies.tinita.de/   \     / _` / _ \/ _ \ '_(_-< of
http://www.perlquotes.de/   \    \ _,_\ __/\ __/_| /__/ perception
http://www.tinita.de/peace/link.html - Spread Peace


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

Date: 21 Mar 2003 22:25:54 GMT
From: Tina Mueller <usenet@tinita.de>
Subject: Re: print to file safley
Message-Id: <b5g3hi$28cnml$2@ID-24002.news.dfncis.de>

Blnukem <blnukem@hotmail.com> wrote:

> open (REPLY, "<data/msgboard/$FORM{'forum'}/$FORM{'file'}.dat");
> my @new_post = <REPLY> ;
> close(REPLY);

[...]
> push( @new_post, $posted);

> open (REPLY, ">data/msgboard/$FORM{'forum'}/$FORM{'file'}.dat");
> flock(REPLY, 2);
> print REPLY @new_post;
> flock(REPLY, 8);
> close(REPLY);

why don't you just open the file for appending?
#!perl -wT
use strict;
use Fcntl qw(:flock);
# ...
# untaint $FORM{'forum'} and $FORM{'file'}
# see
#  perldoc perlsec
open REPLY, ">>data/msgboard/$FORM{'forum'}/$FORM{'file'}.dat") or die $!;
flock REPLY, LOCK_EX;
print REPLY $posted;
close REPLY;

hth, tina
-- 
http://www.tinita.de/     \  enter__| |__the___ _ _ ___
http://Movies.tinita.de/   \     / _` / _ \/ _ \ '_(_-< of
http://www.perlquotes.de/   \    \ _,_\ __/\ __/_| /__/ perception
http://www.tinita.de/peace/link.html - Spread Peace


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

Date: 21 Mar 2003 22:26:05 GMT
From: "Tassilo v. Parseval" <tassilo.parseval@rwth-aachen.de>
Subject: Re: print to file safley
Message-Id: <b5g3ht$88r$1@nets3.rz.RWTH-Aachen.DE>

Also sprach Tina Mueller:

> Tassilo v. Parseval <tassilo.parseval@rwth-aachen.de> wrote:
>> Also sprach Tina Mueller:
> 
>>> Tassilo v. Parseval <tassilo.parseval@rwth-aachen.de> wrote:
>>> 
>>>> Since you asked about safety: This is safe as long as you are sure that
>>>> only processes that respect advisory locks write into these files. There
>>>> could still be a program that simply opens one of the files and writes
>>>> into it. But since the above script is probably the only program working
>>>> with these files, it should be reasonably safe.
>>> 
>>> but i'd say it's only safe if you open the file for reading and
>>> writing at the same time:
> 
>> Hmmh, why?
> 
> uhm, i might have overseen something here, but imagine two
> processes (P1,P2) call the script. P1 reads the file.
> P2 reads the file. both processes now have e.g. lines A,B,C.
> P1 pushes a new line D into the array and has now A,B,C,D.
> P2 does the same with E and gets A,B,C,E.
> P1 writes to the file and exits. P2 writes to the file.
> entry D got lost.

Err, but that's why you usually do a flock() on the handle. A process
requesting an exclusive lock will block until the ressource is available
again so their should never be two write accesses at the same time. 
Same for reading. A shared lock will also block if an exclusive lock is
already on the handle.

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: 21 Mar 2003 22:32:57 GMT
From: Tina Mueller <usenet@tinita.de>
Subject: Re: print to file safley
Message-Id: <b5g3up$28cnml$3@ID-24002.news.dfncis.de>

Tassilo v. Parseval <tassilo.parseval@rwth-aachen.de> wrote:
> Also sprach Tina Mueller:
>> uhm, i might have overseen something here, but imagine two
>> processes (P1,P2) call the script. P1 reads the file.
>> P2 reads the file. both processes now have e.g. lines A,B,C.
>> P1 pushes a new line D into the array and has now A,B,C,D.
>> P2 does the same with E and gets A,B,C,E.
>> P1 writes to the file and exits. P2 writes to the file.
>> entry D got lost.

> Err, but that's why you usually do a flock() on the handle. A process
> requesting an exclusive lock will block until the ressource is available
> again so their should never be two write accesses at the same time. 
> Same for reading. A shared lock will also block if an exclusive lock is
> already on the handle.

sure, but the OP is reading the file, closing it and opening it again.
even if you do both reading and writing with flock(), in that
time in between the two open()/close() there is *no* lock at all.

-- 
http://www.tinita.de/     \  enter__| |__the___ _ _ ___
http://Movies.tinita.de/   \     / _` / _ \/ _ \ '_(_-< of
http://www.perlquotes.de/   \    \ _,_\ __/\ __/_| /__/ perception
http://www.tinita.de/peace/link.html - Spread Peace


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

Date: 21 Mar 2003 22:41:36 GMT
From: "Tassilo v. Parseval" <tassilo.parseval@rwth-aachen.de>
Subject: Re: print to file safley
Message-Id: <b5g4f0$8s3$1@nets3.rz.RWTH-Aachen.DE>

Also sprach Tina Mueller:

> Tassilo v. Parseval <tassilo.parseval@rwth-aachen.de> wrote:

>> Err, but that's why you usually do a flock() on the handle. A process
>> requesting an exclusive lock will block until the ressource is available
>> again so their should never be two write accesses at the same time. 
>> Same for reading. A shared lock will also block if an exclusive lock is
>> already on the handle.
> 
> sure, but the OP is reading the file, closing it and opening it again.
> even if you do both reading and writing with flock(), in that
> time in between the two open()/close() there is *no* lock at all.

Well, true, but there is no I/O happening in this program either in
these moments. After releasing the lock for a few moments, another
process could aquire a fresh lock. So when the program opens the file
again it wont get the lock so it will block.

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: 21 Mar 2003 11:12:33 -0800
From: clearguy02@yahoo.com (John Smith)
Subject: Re: Problem with Getopt::Std and getopts()....
Message-Id: <500f84f3.0303211112.17da53a9@posting.google.com>

Barry Kimelman <barryk2@SPAM-KILLER.mts.net> wrote in message news:<MPG.18e4dc5d5c72dcc7989755@news.mts.net>...
> [This followup was posted to comp.lang.perl.misc]
> 
> In article <500f84f3.0303201636.7582a09f@posting.google.com>, John Smith 
> (clearguy02@yahoo.com) says...
> > Hi all,
> > 
> > Below is the interested part of my code: (script name is test.pl)
> > ------------------------------------
> > 
> > #! C:/perl/bin/perl -w
> > 
> > use Getopt::Std;
> > 
> > getopts('1:2:3:');
> > 
> > if ($opt_1)
> > {
> > 	$count = 1;
> > }
> > elsif ($opt_2)
> > {
> > 	$count = 2;
> > }
> > elsif ($opt_3)
> > {
> > 	$count = 3;
> > }
> > else
> > {
> > 	$count = 4;
> > }
> > 
> > --------------------------------------
> > 
> > Now when I run the following command at CMD,
> > 
> > C:\>test.pl 1
> > 
> > It compiles with no errors, but it is taking 4 as $count value (from
> > else statement).
> > 
> > Similary, when I give 2 or 3 as switch arguments to test.pl, it always
> > gets 4 for $count variable.
> > 
> > What is wrong here? I want $count =1, when I give 1 as switch and
> > $count =2, when I give 2 as switch and so on.
> > 
> > Thanks,
> > John
> > 
> 
> You have several problems :
> 
> (1) Optional parameters must be preceeded by a minus sign as in
>     test.pl -1
> 
> (2) When an option character is followed by a ":" in a call to getopts()
>     it means that that option character requires a string value as in
>     test.pl -1 string_one

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

OK, I modify the code as below:

use Getopt::Std;

getopts('12:');

if ($opt_1)
{
	$count = 1;
}
elsif ($opt_2)
{
	$count = 2;
}
else
{
	$count = 3;
}

I am on windows. Now I give commands like C:\test.pl -1, C:\test.pl /1
and CL\test.pl 1. In all three cases, $count is set to 3 only. But I
want $count =1.

when I commented out getopts function and rna the script, $count is
still set to 3.

What is wrong now?

Thanks,
John


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

Date: Fri, 21 Mar 2003 19:39:00 +0000 (UTC)
From: ansok@alumni.caltech.edu (Gary E. Ansok)
Subject: Re: Problem with Getopt::Std and getopts()....
Message-Id: <b5fpok$m45$1@naig.caltech.edu>

In article <500f84f3.0303211112.17da53a9@posting.google.com>,
John Smith <clearguy02@yahoo.com> wrote:
>OK, I modify the code as below:
>
>use Getopt::Std;
>
>getopts('12:');
>
>if ($opt_1)
>{
>	$count = 1;
>}
>elsif ($opt_2)
>{
>	$count = 2;
>}
>else
>{
>	$count = 3;
>}
>
>I am on windows. Now I give commands like C:\test.pl -1, C:\test.pl /1
>and CL\test.pl 1. In all three cases, $count is set to 3 only. But I
>want $count =1.
>
>when I commented out getopts function and rna the script, $count is
>still set to 3.
>
>What is wrong now?

When I took your code exactly as you have it above, added a print 
"Count is $count\n", and ran it on Windows as "test.pl -1", I got 
"Count is 1" as the output.

"test.pl -2" still resulted in a count of 3, since you told Getopt::Std
to expect an argument with the -2 option, and I didn't give it one.
"test.pl -2 1" did result in a count of 2.  

"test.pl /1" also resulted in a count of 3 -- I don't see anything 
in the Getopt::Std documentation to indicate it accepts '/' as an 
option identifier, even on Windows.  I believe Getopt::Long can be
set to accept this, but it doesn't by default.

I'm running Perl 5.6.1 (ActiveState build 633), with Getopt::Std 1.02.

Gary Ansok
-- 
Besides, there's nothing like the threat of imminent death 
to force one to delegate.
        -- Lois McMaster Bujold


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

Date: Fri, 21 Mar 2003 19:35:42 +0000 (UTC)
From: Tore Linde Gustavsen <torelg@start.no>
Subject: Re: Reverse assignment operator
Message-Id: <slrnb7mqd2.4ae.torelg@localhost.localdomain>

My last post is a prime example of bad wording: Here's what I meant to say:


To Tassilo and Bernard: Thanks again for good, instructive replies.

Bernard talks about perl6, and I am of course looking forward to when it
will be released.

I know it is very uncertain, but the date of release is still years
ahead in time?  

-- 
Tore Gustavsen,
torelg@start.no            


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

Date: 21 Mar 2003 21:36:25 GMT
From: anno4000@lublin.zrz.tu-berlin.de (Anno Siegel)
Subject: Re: Reverse assignment operator
Message-Id: <b5g0kp$f1o$1@mamenchi.zrz.TU-Berlin.DE>

Tore Linde Gustavsen  <torelg@start.no> wrote in comp.lang.perl.misc:
> My last post is a prime example of bad wording: Here's what I meant to say:
> 
> 
> To Tassilo and Bernard: Thanks again for good, instructive replies.
> 
> Bernard talks about perl6, and I am of course looking forward to when it
> will be released.
> 
> I know it is very uncertain, but the date of release is still years
> ahead in time?  

I don't think anybody really knows.  Those who work on it reasonably don't
commit themselves, and those who don't can only guess.

Much as I'm looking forward to its appearance, I admit that I dread the
learning that will be required before writing it fluently -- without, for
instance, relapsing into quaint perl5-isms on every occasion.

Anno


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

Date: 21 Mar 2003 14:37:44 -0800
From: john_20_28_2000@yahoo.com (jm)
Subject: Working Perl DBD Ingres and DBI
Message-Id: <c67e4bdd.0303211437.6cee62c9@posting.google.com>

I am putting this here so others may not have to search as hard.

I could not get Ingres to work with DBD/DBI and got different errors,
such as:

loadable object for module DBD::Ingres in @INC (@INC contains 
Can't locate loadable object for module DBD
Can't locate loadable object for module DBI in @INC
cc: "/opt/perl5/lib/5.6.0/PA-RISC1.1/CORE/perl.h", line 532: error 10
Cannot load /usr1/install/rl6404/ingres/bin/esqlc.  Stop
/usr/include/sys/stdsyms.h:244: #error "Large Files (ILP32) not
supported
gcc: +Onolimit: No such file or directory
and the +z flag also on gcc.

The first problem was that perl was trying to use cc and on my hp-ux
10.20 system thats not an ANSI C compiler.  And the Ansi C compiler
(aCC I think) is not free.  So, one needs to make it work with gcc.

Edit your Makefile and change:

CC = gcc
#CCCDLFLAGS = +z
CCCDLFLAGS = -fPIC

#CCFLAGS = -Ae -D_LARGEFILE_SOURCE -D_FILE_OFFSET_BITS=64
CCFLAGS = -D_LARGEFILE_SOURCE -D_FILE_OFFSET_BITS=64 -D__STDC_EXT__
#OPTIMIZE = -O +Onolimit
OPTIMIZE = -O2

I also commented out in Makefile.PL:

# HP-UX cannot link a non-PIC object file into a shared library.
#if ($Config{osname} eq 'hpux') {
 #   print "Warning: forced to build static not dynamic on
$Config{osname} $Conf
ig{osvers}\n";
  #  print "         See README for more information.\n";
   # $opts{LINKTYPE} = 'static';
#}

Furthermore, ensure this system variable is set correct II_SYSTEM.  It
must point to you Ingres installations base.  If not, you'll be
editing the c files and putting in the correct paths to your Ingres
installation.

I used a connection string like this to test [snippet]:


    $dbh = DBI->connect("DBI:Ingres:mydb;-Rmyrold/mypassword", $user,
$options or die "Couldn't connect to database: " . DBI->errstr;

I hope this helps someone


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

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


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