[10791] in Perl-Users-Digest

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

Perl-Users Digest, Issue: 4392 Volume: 8

daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Wed Dec 9 18:07:22 1998

Date: Wed, 9 Dec 98 15:00:20 -0800
From: Perl-Users Digest <Perl-Users-Request@ruby.OCE.ORST.EDU>
To: Perl-Users@ruby.OCE.ORST.EDU (Perl-Users Digest)

Perl-Users Digest           Wed, 9 Dec 1998     Volume: 8 Number: 4392

Today's topics:
    Re: Another system() question (Tad McClellan)
    Re: Another system() question (Greg Ward)
    Re: Assignment to same variable <niral@corporate.planet.net>
    Re: Assignment to same variable <uri@ibnets.com>
    Re: Assignment to same variable (Larry Rosler)
    Re: Code Bash: File Include <dgris@moiraine.dimensional.com>
    Re: Decent Editor <xidicone@iname.com>
        Emailing something from a perl CGI script <mshaw@netcom.com>
        Forward slash in Win95 ?? & Perl on Win32 <mmoon@concentric.net>
    Re: Help on s/// !!! (Greg Ward)
    Re: Help on s/// !!! (Tad McClellan)
    Re: How can I compare files? (Greg Ward)
    Re: How can I compare files? (Greg Ward)
    Re: How can I compare files? (Larry Rosler)
    Re: how to get screen size? (Greg Ward)
    Re: Left and right halves of s/// parsed differently? (Ilya Zakharevich)
    Re: Net::Ping (Greg Ward)
    Re: Perl ARRAYs <niral@corporate.planet.net>
        reading comma delimited data files (Cybernetic Bear)
    Re: Regular Expression help (brian d foy)
    Re: Still just a quickie (Larry Rosler)
    Re: strict bug in CGI.PM? (Greg Ward)
    Re: strict bug in CGI.PM? (Tad McClellan)
    Re: strict bug in CGI.PM? (Ilya Zakharevich)
        system(chmod) fails in SETUID Perl Script mike_orourke@em.fcnbd.com
        take out periods jimbob4334@my-dejanews.com
    Re: TCL <-> PERL, what's better. (Andrew M. Langmead)
    Re: TCL <-> PERL, what's better. (Tom Poindexter)
        Special: Digest Administrivia (Last modified: 12 Mar 98 (Perl-Users-Digest Admin)

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

Date: Wed, 9 Dec 1998 14:46:09 -0600
From: tadmc@metronet.com (Tad McClellan)
Subject: Re: Another system() question
Message-Id: <hinm47.4f6.ln@magna.metronet.com>

Mary E Tyler (dejahvu@erols.com) wrote:
: I am thinking of using an external c program (external to my perl
: program that is) to do something and spit back a result. A few
: questions:

: 1) if the call to system is made 

: system(myprogram.c, "@arguements")
                  ^^        ^
                  ^^        ^  ??


: how will the arguements arrive at the c program? will the c program see
: them as individual items in the ARGV array or will the perl array be
: crammed into the c array somehow?


   What happened when you tried it?

   Write a simple argecho.c and see what it does.

   That would have taken less time than typing in your post  ;-)



: 2) what is the mechanicsm for returning information (if there is one) to
: the calling perl program?


   Don't use system() for that.

   use a pipe open instead:

   open(MYPROG, "myprogram @arguments |") || die "could not fork";
   while (<MYPROG>) {
      print "from myprogram: $_";
   }
   close(MYPROG) || die "error closing myprogram";


   See also the Perl FAQ, part 8:

      "Why doesn't open() return an error when a pipe open fails?"



   Then give up on the pipe open and just use backticks  ;-)

      $from_myprogram = `myprogram @arguments`;


--
    Tad McClellan                          SGML Consulting
    tadmc@metronet.com                     Perl programming
    Fort Worth, Texas


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

Date: 9 Dec 1998 21:33:35 GMT
From: gward@thrak.cnri.reston.va.us (Greg Ward)
Subject: Re: Another system() question
Message-Id: <74mqbf$4ok$3@news0-alterdial.uu.net>

Mary E Tyler <dejahvu@erols.com> wrote:
> I am thinking of using an external c program (external to my perl
> program that is) to do something and spit back a result. A few
> questions:
> 
> 1) if the call to system is made 
> 
> system(myprogram.c, "@arguements")

First of all, you might want to compile your C program first.

Second, using system this way won't work.  Either do this:

  system "myprogram @arguments";         # assumes $" is just whitespace!

or this:

  system 'myprogram', @arguments;

The second is almost always superior (no nasty shells to mess up your
day).  RTFM ('perldoc -f system') to find out why.

> how will the arguements arrive at the c program? will the c program see
> them as individual items in the ARGV array or will the perl array be
> crammed into the c array somehow?

RTFM -- it's all explained there.

        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, 09 Dec 1998 16:08:21 -0500
From: Niral Trivedi <niral@corporate.planet.net>
To: Darren Ward <dward@pla.net.au>
Subject: Re: Assignment to same variable
Message-Id: <366EE6C5.16016BFA@corporate.planet.net>

Darren,

i guess the first mistake u are making is in syntax of '@dns[$loop]'. it
should be $dns[$loop]... i think so...

and the syntax for join is :
$domain = join('.',$dns[$loop],$domain)

i hope that will work for u....

--
Regards...
********************************************
Niral K. Trivedi, Planet Access Network Inc.
Email : niral@corporate.planet.net
Phone : 973-691-4704




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

Date: 09 Dec 1998 16:17:59 -0500
From: Uri Guttman <uri@ibnets.com>
Subject: Re: Assignment to same variable
Message-Id: <39emq9rp4o.fsf@ibnets.com>

>>>>> "NT" == Niral Trivedi <niral@corporate.planet.net> writes:

  NT> and the syntax for join is :
  NT> $domain = join('.',$dns[$loop],$domain)

  NT> i hope that will work for u....

well, it won't. that statement is a no-op that only assigns $domain to
itself. the join syntax is right but there is only a single scalar to
join so it just returns that value.

in fact, join( $string, $value ) is a silly thing to write. maybe it
should be warned under -w. if the list arg to join is a single scalar
value, it does nothing useful and the program should warn about it.

please don't post broken code like that.

uri

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


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

Date: Wed, 9 Dec 1998 14:19:34 -0800
From: lr@hpl.hp.com (Larry Rosler)
Subject: Re: Assignment to same variable
Message-Id: <MPG.10d8975527c52d769898b7@nntp.hpl.hp.com>

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

In article <39emq9rp4o.fsf@ibnets.com> on 09 Dec 1998 16:17:59 -0500, 
Uri Guttman <uri@ibnets.com> says...
> >>>>> "NT" == Niral Trivedi <niral@corporate.planet.net> writes:
> 
>   NT> and the syntax for join is :
>   NT> $domain = join('.',$dns[$loop],$domain)
> 
>   NT> i hope that will work for u....
> 
> well, it won't. that statement is a no-op that only assigns $domain to
> itself. the join syntax is right but there is only a single scalar to
> join so it just returns that value.
> 
> in fact, join( $string, $value ) is a silly thing to write. maybe it
> should be warned under -w. if the list arg to join is a single scalar
> value, it does nothing useful and the program should warn about it.
> 
> please don't post broken code like that.

Are we looking at the same thing?  I see *two* scalars to join in the 
quoted snippet.  Of course, I insist on inserting a space after every 
comma in my own code, which would make that a bit more obvious.

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


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

Date: 09 Dec 1998 15:51:05 -0700
From: Daniel Grisinger <dgris@moiraine.dimensional.com>
Subject: Re: Code Bash: File Include
Message-Id: <m31zm9udye.fsf@moiraine.dimensional.com>

Uri Guttman <uri@ibnets.com> writes:

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

>   DG> { map { open __, $_ or (warn ("oops: $_ $!") && last); print <__>
>   DG> } @files }
> 
> i can't wait til randal strangles you for the void map!

KNOCK! KNOCK!

"Who's there?"
"It's Randal."
"Come in."

"Hey, Randal, how are yo.... uhhhh.... what's the rope for?"
Randal smiles.
"Ummmm.... Randal?   Put the rope down, please.  Randal?
 Ran... aaaaaaaiiiiiIIIEEEEEE" 
<gasp><gurgle><thump>

Actually, I tried to make that not void context, but C<print map>...
didn't work the way that I wanted it to.

> use a foreach modifier and you can drop the parens on the 'or' clause

The or didn't need the parens, they were leftover from an earlier
attempt at doing that in one line.

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


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

Date: Thu, 10 Dec 1998 08:18:12 +1000
From: Jussi Jumppanen <xidicone@iname.com>
Subject: Re: Decent Editor
Message-Id: <366EF724.6450@iname.com>

Antony McNulty wrote:

> I noticed many editors mentioned were UNIX, any ideas for the PC then ?

You should take a look at the Zeus editor:

  Zeus for Windows 3.x or Win32
  A powerful text editor/ integrated development environment. Features
  include Brief, Epsilon, Emacs or Wordstar emulation,  status bar, 
  toolbar, configurable syntax colorizing, background compiler, inline
  error correction, unlimited undo/redo, keyboard macros, scripting 
  language, templates and more.

  Version: 2.70 Platforms: Windows 3.x, Windows 95 or NT  Size: 1100k

The Zeus home page has lots more details and even some nice screen 
shots of Zeus in action:

   http://ourworld.compuserve.com/homepages/jussi/zLook.htm


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

Date: Wed, 9 Dec 1998 21:28:13 GMT
From: Mark Shaw <mshaw@netcom.com>
Subject: Emailing something from a perl CGI script
Message-Id: <mshawF3pvn1.3Is@netcom.com>


[My abject apologies if this shows up twice.  I originally
posted it from my work account, which seems to be off the 
air usenet-wise, at least for outgoing posts.]

Howdy,

First, I've read the Programming FAQ (well not all of it), and it 
appears there's a more efficient way (Q4.1) to do this -- but just 
for grins could someone tell me what, specifically, I'm doing wrong 
here before I make any changes?

I've got a pair of CGI scripts that 1) present the user with a 
form to be filled out and 2) take the contents of that form and
send them to an email address (which in turn forwards them to a
pager).

The contents of the form get formatted into a single temporary
file such that whatever lives behind the email address (someone
else's code to which I am not privy) can send them on to the
pager.  The file includes the message and the pager number.

After taking care of all this collection and formatting, I do
the actual emailing as follows:

  $retval = 0xffff & system("mail $pager_address < $tempfile");

And then test $retval for errors as described on p. 230 of the
Camel Book (2nd Ed).

A previous version of the script actually used: 

  $retval = 0xffff & system("cat $tempfile | mail $pager_address");

This has worked pretty well in the past, but lately I'm getting
(with both methods) very frequent, but not consistent, occurences of 
failure -- specifically an exit status of 12 (the 'elsif ($retval > 
0x80)' case from the Camel Book).  I haven't been able to winkle out 
what '12' means from manpages and the like....

I've confirmed that the temporary file is getting written properly,
and that it's readable.  I've also confirmed that the pager address
hasn't changed or anything, by emailing the temporary file directly
to the pager address from the command line.  The only way I can make
this break is by using the CGI scripts.

System info: Netscape 4.04 under Solaris 2.6, perl ver. 5.003. 

Anyway, thanks for any info or suggestions.  I can provide more info
or the complete scripts if needed.

-- 
Mark Shaw <mshaw@netcom.com> <mshaw@ti.com>




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

Date: 09 Dec 1998 14:51:53 PST
From: Michael Moon <mmoon@concentric.net>
Subject: Forward slash in Win95 ?? & Perl on Win32
Message-Id: <366EFF5D.207C0635@concentric.net>

I am just starting with Perl and attempting to get familiar with the
NetResource module.  I am getting an error trying to execute one of the
simple examples in the docs.


use Win32::NetResource;

gives me the following error

Can't load 'C:\Perl\lib/auto/Win32/NetResource/NetResource.pll' for
module Win32
::NetResource: 31 at C:\Perl\lib/DynaLoader.pm line 450.

 at test2.plx line 2
BEGIN failed--compilation aborted at test2.plx line 2.


I imagine the error is due to the forward slashes in the PATH to
NetResource.pll.  In the Wintel environment a forward slash "/" is a
command line switch.  Is there an update or setting I need to update to
correct this, or if the error is something else that is obvious, I would
appreciate the help.

Thanks,





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

Date: 9 Dec 1998 21:17:55 GMT
From: gward@thrak.cnri.reston.va.us (Greg Ward)
Subject: Re: Help on s/// !!!
Message-Id: <74mpe3$43p$4@news0-alterdial.uu.net>

Brandon Lin <lin@wdg.mot.com> wrote:
> There's a line like the following.
> 
> ......blablabla..........<TD><!--increment
> here-->1</TD>........blablabla......
> 
> and it should be changed to
> 
> ......blablabla..........<TD><!--increment
> here-->2</TD>........blablabla......

I assume you meant for those to be on one line and not wrapped like this!

> I tried
> 
> $line=~s/<!--increment here-->(\d+)/<!--increment here-->$1+1/e

That's wrong because 

   <!--increment here-->$1+1

is not a valid Perl expression.  You probably meant

   $line=~s/<!--increment here-->(\d+)/"<!--increment here-->" . ($1+1)/e

> $line=~s/<!--increment here-->(\d+)/sprintf("<!--increment here-->$1+1")/e

And that's wrong because Perl doesn't do arithmetic when you interpolate
variables into strings; anyways, there's no point in using sprintf if 
you're not doing any % substitutions.  You probably meant:

   $line=~s/<!--increment here-->(\d+)/
            sprintf("<!--increment here-->%d", $1+1)/e

I'd go for the first one -- a bit more readable, and you really don't
need sprintf here.

Disclaimer: haven't tried any of this code, it's all off the top of my
head.  Caveat emptor, RTFM, etc. etc.

        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, 9 Dec 1998 14:36:08 -0600
From: tadmc@metronet.com (Tad McClellan)
Subject: Re: Help on s/// !!!
Message-Id: <ovmm47.4f6.ln@magna.metronet.com>

Brandon Lin (lin@wdg.mot.com) wrote:

: This might sound stupid, but it really beats me.


: I tried

: $line=~s/<!--increment here-->(\d+)/<!--increment here-->$1+1/e

   except it had a semicolon on the end?


   when you use the s///e option, you need to make the REPLACEMENT
   part be legal Perl code.

   <!--increment here-->$1+1 isn't legal Perl code.


   $line =~ s/<!--increment here-->(\d+)/ '<!--increment here-->' . ($1+1)/e;


--
    Tad McClellan                          SGML Consulting
    tadmc@metronet.com                     Perl programming
    Fort Worth, Texas


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

Date: 9 Dec 1998 21:28:56 GMT
From: gward@thrak.cnri.reston.va.us (Greg Ward)
Subject: Re: How can I compare files?
Message-Id: <74mq2o$4ok$1@news0-alterdial.uu.net>

Pep Mico <pep_mico@hp.com> wrote:
> I'm using Perl under Windows NT. How can I compare two files? I haven't
> found this file function in Perl Manuals. I just only need to know if
> files are Equals or differents.
> 
> Should I invoke COMP command from Windows NT?

If it's a quick hack, and you don't compare about portability or
efficiency or security or robustness: sure, go ahead and use the
external command.  I've done the same thing, only under Unix it's 'cmp'
(see what I mean about portability?)

Otherwise, it shouldn't be too hard to code up a little file compare
function: just open files, read them a chunk at a time (I'd use the
'read' function -- just read 4k or 8k or some reasonable chunk size),
and stop when eof or difference found.

This should do the trick:

# Compare two files (supplied by filename).  Returns false if different, 
# true if identical.  **UNTESTED CODE** -- try before you buy!
sub compare_file
{
   my ($file1, $file2) = @_;

   return 0 unless -s $file1 == -s $file2; # size mismatch -- of course fail
   local (*FILE1, *FILE2);
   open (FILE1, $file1) || die "$file1: $!\n";
   open (FILE2, $file2) || die "$file2: $!\n";

   my $chunk_size = 8192;               # or whatever you like

   while (1)
   {
      my ($buf1, $buf2);
      my $nbytes1 = read (FILE1, $buf1, $chunk_size);
      die "error reading from $file1: $!\n" unless defined $nbytes1;
      my $nbytes2 = read (FILE2, $buf2, $chunk_size);
      die "error reading from $file2: $!\n" unless defined $nbytes2;

      # if we got to eof without finding a mismatch, the files match
      $match = 1, break if $nbytes1 == 0 and $nbytes2 == 0;

      # this should not happen if my logic is right
      die "uh-oh! reached eof on one file but not the other!"
         if $nbytes1 == 0 or $nbytes2 == 0;

      # if the buffers don't match, the files don't match -- so quit now
      $match = 0, break if $buf1 ne $buf2;
   }

   close (FILE1);
   close (FILE2);
   return $match;
}

        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: 9 Dec 1998 21:30:54 GMT
From: gward@thrak.cnri.reston.va.us (Greg Ward)
Subject: Re: How can I compare files?
Message-Id: <74mq6e$4ok$2@news0-alterdial.uu.net>

Pep Mico <pep_mico@hp.com> wrote:
> I'm using Perl under Windows NT. How can I compare two files? I haven't
> found this file function in Perl Manuals. I just only need to know if
> files are Equals or differents.
> 
> Should I invoke COMP command from Windows NT?

Oops!  I'm a bonehead -- I searched CPAN for File::Compare without
thinking to look in the standard Perl library, and then posted a
complete solution.  Ignore my previous followup.

Answer: use File::Compare.  If you have Perl, you have it.  RTFM.

        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, 9 Dec 1998 14:29:36 -0800
From: lr@hpl.hp.com (Larry Rosler)
Subject: Re: How can I compare files?
Message-Id: <MPG.10d899aeb02625529898b8@nntp.hpl.hp.com>

In article <74mq2o$4ok$1@news0-alterdial.uu.net> on 9 Dec 1998 21:28:56 
GMT, Greg Ward <gward@thrak.cnri.reston.va.us> says...
 ...
>      **UNTESTED CODE** -- try before you buy!

Indeed, and perhaps unread, but withdrawn anyway.  Just a couple of 
comments:

 ...
>       my ($buf1, $buf2);
>       my $nbytes1 = read (FILE1, $buf1, $chunk_size);

'-w' gives 'uninitialized variable' warning here.  It shouldn't, but it 
does.  Sigh...

 ...
>       $match = 1, break if $nbytes1 == 0 and $nbytes2 == 0;

You write too much C code.  In Perl, this is 'last'.

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


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

Date: 9 Dec 1998 21:07:04 GMT
From: gward@thrak.cnri.reston.va.us (Greg Ward)
Subject: Re: how to get screen size?
Message-Id: <74mopo$43p$1@news0-alterdial.uu.net>

Rollo Chan <rollo@hknet.com> wrote:
> I am a 'fresh guy' of using perl.....I would like to ask....while using
> perl under UNIX...how to get the current terminal screen size by
> perl??.......I mean how to get the column number of the screen in order
> to adjust the output to fit the screen...thanks of all of your help.....

A couple of ideas: the Term::Cap module comes with Perl; you ought to be
able to get that information out of the termcap database, but it's not
entirely clear to me how that would work.  (The Term::Cap module is,
shall we say, minimally documented.)  If you're more stubborn than
me you might be able to figure it out.

Next, I see that the Module List advertises a Term::Info module; this
would presumably give you an interface to the more modern (SVR4)
terminfo database.  Again, I don't know the exact mechanics of using
Term::Info to get the terminal size, but it ought to be doable.  RTFM.

But wait!  I see here (still in the module list) Term::Size, advertised
as a "Simple way to get terminal size".  Looks like that's what you
need.  Download it from a CPAN near you, or search for it at

    http://cpan.perl.com/

if you need help.

        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: 9 Dec 1998 21:04:09 GMT
From: ilya@math.ohio-state.edu (Ilya Zakharevich)
Subject: Re: Left and right halves of s/// parsed differently?
Message-Id: <74mok9$6c2$1@mathserv.mps.ohio-state.edu>

[A complimentary Cc of this posting was sent to Larry Rosler
<lr@hpl.hp.com>],
who wrote in article <MPG.10d87b4d38fe2f5f9898b4@nntp.hpl.hp.com>:
>    $from = 'big\noses';
>    $to = 'large\eyes';
>   
>    $this = 'clowns\have\big\noses\here';
> 
> The statement after interpolation of the variables is:
> 
>    $this =~ s/\Qbig\noses\E/\Qlarge\eyes\E/g;

You assume that if

    $a = 'foo\bar';

then

    print "\Q$a";

is equivalent to 

    print "\Qfoo\bar";

It is not (and this is my main gripe about \Q).

Ilya


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

Date: 9 Dec 1998 21:10:17 GMT
From: gward@thrak.cnri.reston.va.us (Greg Ward)
Subject: Re: Net::Ping
Message-Id: <74movp$43p$2@news0-alterdial.uu.net>

bobs614@my-dejanews.com <bobs614@my-dejanews.com> wrote:
> I am attempting to ping a server, On my system the code works fine
> but when I put it on the webserver I get a ICMP Socket Error.

Off-the-top-of-my-head: might be a permissions problem.  From the
Net::Ping man page:

     If the "icmp" protocol is specified, the ping() method sends
     an icmp echo message to the remote host, which is what the
     UNIX ping program does.  If the echoed message is received
     from the remote host and the echoed information is correct,
     the remote host is considered reachable.  Specifying the
     "icmp" protocol requires that the program be run as root or
     that the program be setuid to root.

I also see in that man page that Net::Ping can send TCP or UDP "pings"
-- not the same as a traditional Unix ping, but possibly more useful
(depending on your definition of "up").  Cool!  You might try one of
those instead.

        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, 09 Dec 1998 15:53:23 -0500
From: Niral Trivedi <niral@corporate.planet.net>
To: Garth Webb <gwebb@reedtech.com>
Subject: Re: Perl ARRAYs
Message-Id: <366EE342.51758B72@corporate.planet.net>

Garth,

First of all i think u can't use ref() to get the reference...(I may be
wrong)  i.e. it just give u the reference.. meaning ARRAY,SCALAR,HASH
and etc... i have tried using ur code but it gave me like that only.. it
didn't give me the actual memory value like (0x71a7c). I don't know the
reason behind this.. but i have tried a sample code as follows and it
works.

by looking at the code u will find the place where u fogot the thing...
---------------------------------------------
#!/usr/local/bin/perl5.003

@a = ("foo");
print "a : @a\n";

$ref = \@a; # here i haven't used ref() function.....
            ^
print "ref : $ref\n";
print "\$\$ref : @$ref\n";    # will print something like ARRAY(0x71a7c)

                       ^^ # because u are using array and not a scalar
value..
                            # if u were using $a instead of @a then u
could use $$ instead of @$

$b = $ref;
print "b : @$b\n";            # will print the value of b as 'foo'
without quotes....
               ^^
----------------------------

hope everything is making sense to u....

better ways and solutions are always welcome.........
--
Regards...
********************************************
Niral K. Trivedi, Planet Access Network Inc.
Email : niral@corporate.planet.net
Phone : 973-691-4704




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

Date: Wed, 09 Dec 1998 22:22:28 GMT
From: cybear_x[nospam]@geocities.com (Cybernetic Bear)
Subject: reading comma delimited data files
Message-Id: <366eef18.17062051@news.webhart.net>

I have a comma delimited text file that contains 3 columns of data
which looks basically like this:
name, date, number-value

I can read in data one line at a time, but I would like to read the
three values into 3 seperate variables, from the same line.

I'm sure its possible, but how?  

Thanks for your time and assistance in advance,

Dave


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

Date: Wed, 09 Dec 1998 16:10:24 -0500
From: comdog@computerdog.com (brian d foy)
Subject: Re: Regular Expression help
Message-Id: <comdog-ya02408000R0912981610240001@news.panix.com>

In article <74mmr1$u7h$1@ultra.sonic.net>, "Gala Grant" <gala@sonic.net> posted:

> Can anyone tell me why
> 
> if ($line =~ /<a href="(.*)"?/i)
> 
> isn't stopping at the first " it finds?

because Perl regexen are greedy by default.  you probably wanted

   /<a href="(.*?)"/

however, HTML::Parser might be a better tool for you.

-- 
brian d foy                     <brianNOSPAM@NOSPAM.smithrenaud.com>
CGI Meta FAQ <URL:http://computerdog.com/CGI_MetaFAQ.html>
remove NOSPAM or don't.  it doesn't matter either way.


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

Date: Wed, 9 Dec 1998 14:16:03 -0800
From: lr@hpl.hp.com (Larry Rosler)
Subject: Re: Still just a quickie
Message-Id: <MPG.10d89682ed80ca9e9898b6@nntp.hpl.hp.com>

In article <74mn0h$2l3$2@news0-alterdial.uu.net> on 9 Dec 1998 20:36:33 
GMT, Greg Ward <gward@thrak.cnri.reston.va.us> says...
> Antony <amcnulty@nortel.co.uk> wrote:
 ...
> > Also, anyone ever come up with many problems in porting UNIX perl scripts
> > over to WinNT ?
> 
> Sure, replace NT with Linux.  Probably save you time in the long run.
> (Also, if you run Linux, you could always hack the kernel filesystem
> code to watch that file for you, and send a signal to your script when
> the file is updated... JUST KIDDING!)

Not funny at all.  A constructive response would be RTFM:  `perldoc 
perlport`.

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


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

Date: 9 Dec 1998 21:13:28 GMT
From: gward@thrak.cnri.reston.va.us (Greg Ward)
Subject: Re: strict bug in CGI.PM?
Message-Id: <74mp5o$43p$3@news0-alterdial.uu.net>

Software Sciences <nospam.eam@starfire.mlb.semi.harris.com> wrote:
[details of 'use strict' problem with CGI deleted]
> Does anyone know if what I'm seeing is that bug? Second, can anyone tell
> me how to determine my system's version of cgi.pm?

Don't know much about CGI.pm, but there's a fairly standard way of
putting a version number into a Perl module.  This works with CGI, and
should work with most modules:

   perl -MCGI -le 'print $CGI::VERSION'

> Thank-You.

You're welcome!

        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, 9 Dec 1998 14:28:08 -0600
From: tadmc@metronet.com (Tad McClellan)
Subject: Re: strict bug in CGI.PM?
Message-Id: <ogmm47.4f6.ln@magna.metronet.com>

Software Sciences (nospam.eam@starfire.mlb.semi.harris.com) wrote:

: Second, can anyone tell
: me how to determine my system's version of cgi.pm?


   use CGI;
   print "$CGI::VERSION\n";


--
    Tad McClellan                          SGML Consulting
    tadmc@metronet.com                     Perl programming
    Fort Worth, Texas


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

Date: 9 Dec 1998 21:42:05 GMT
From: ilya@math.ohio-state.edu (Ilya Zakharevich)
Subject: Re: strict bug in CGI.PM?
Message-Id: <74mqrd$8ht$1@mathserv.mps.ohio-state.edu>

[A complimentary Cc of this posting was sent to Software Sciences 
<nospam.eam@starfire.mlb.semi.harris.com>],
who wrote in article <366EC891.A3408987@starfire.mlb.semi.harris.com>:
> Does anyone know if what I'm seeing is that bug? Second, can anyone tell
> me how to determine my system's version of cgi.pm?

There is no such file as cgi.pm.  If you mean CGI.pm, then

      perl -de0
      DB<1> use CGI
      DB<2> v

should do it.  (Or you may combine it with -MCGI, as in other answers.)

Ilya


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

Date: Wed, 09 Dec 1998 21:50:53 GMT
From: mike_orourke@em.fcnbd.com
Subject: system(chmod) fails in SETUID Perl Script
Message-Id: <74mrbs$ri2$1@nnrp1.dejanews.com>


>I created a perl script that will allow users to "chown" files that they own
>to another valid UID on the server.  I seemed to have resolved the "tainted"
>data problem, but now the "chown" command is still failing. The Perl script
>has "4755" permissions and is owned by "root". When I run the script as
>"root", everything works O.K. But when I run the script while connected as
>the "owner" of the file I am trying to modify, I get the following message :

>chown: /export/home/lddv/test_chmod.txt: Not owner
>Could not run CHMOD at /dev/fd/3 line 48.

Below is an example of the code that I am using :

> $old_path = $ENV{"PATH"} ;
>
> $directory = "/export/home/lddv" ;
>
> $filename> = "test_chmod.txt" ;
>
> $file_owner = "lao7" ;
>
> if ($filename =~> /^([-\@\w.]+)$/) {
>   $filename = $1 ;
> } else {
>   die "Bad data in $filename" ;
> }
>
> if ($file_owner =~ /^([-\@\w.]+)$/) {
>   $file_owner = $1 ;
> } else {
>   die "Bad data in $file_owner" ;
> }
>
>
> if ($directory =~ /^([\/\-\@\w.]+)$/) {
>   $directory = $1 ;
> } else {
>   die "Bad data in $directory" ;
> }
>
> $ENV{"PATH"} = "/usr/sbin:/usr/bin";
>
> system("chown $file_owner '$directory/$filename'") && die "Could not run
> CHMOD" ;
>
> $ENV{"PATH"} = $old_path ;
> exit ;
>
> Not listed is the code that reads in a seperate file with a list of
> directories that can be modified ($directory). I also verify that $file_owner
> is a valid user on the server (getpwnam).
>


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


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

Date: Wed, 09 Dec 1998 22:44:52 GMT
From: jimbob4334@my-dejanews.com
Subject: take out periods
Message-Id: <74muh4$ubc$1@nnrp1.dejanews.com>

Hello,

How do I take the "."'s out of the variable
$release =  "2.9.0"
and assign 290 to $rls_name?

TIA,

Jim

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


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

Date: Wed, 9 Dec 1998 22:34:05 GMT
From: aml@world.std.com (Andrew M. Langmead)
Subject: Re: TCL <-> PERL, what's better.
Message-Id: <F3pyot.M51@world.std.com>

"Michalowski, Martin" <stud0v64@nortel.com> writes:

>I love TCL but all I hear about lately is PERL.

Tcl and Perl were designed by different people, designing for
different goals and with different ideas of how their languages should
act.

As time went on, the languages seemed useful for things beyond their
orignal scope, and features got added to support these new uses. As
they've grown, they've crossed paths into each others application
domain until things are now at a point where people sometimes ask
"Perl or Tcl". (But if they do, they would probably want to read
things like the FAQ which discuss it already.)

For my personal opinion, if you are working on something that is
clearly what Tcl or Perl were originally designed for, then the choice
is clear. I'd be much more likely to use Tcl over perl if I needed to
embed an interpreter into a program. I'd be much more likely to use
Perl over Tcl for a predominantly text munging task. Once you start
getting into the grey area, I'd say the choice is more personal
preference.

One can argue performance, which used to be Tcl's main flaw, but
they've done a lot of work on that. For many things that people use
Tcl and Perl for, execution speed isn't the most important factor. (If
it was, then maybe a language that compiled into machine code would be
appropriate.)

Finally, it comes down to the language designers, and it comes down to
you. And to some extent, it comes down to how close your thinking is
to the language desingers ideas.

"The most common difficult for new Tcl users is understanding when
substitutions do and do not occur. A typical scenario is for a user to
be surprised at the behavior of a script because a substitution didn't
occur when the user expected it to happen, or a substitution occurred
when it wasn't expected. However, I think that you will find Tcl's
substitution mechanism to be simple and predictable if you just
remember these two related rules:" 
John K. Ousterhout, in "Tcl and the Tk Tookit"

"THERE IS NO GENERAL RULE FOR CONVERTING A LIST INTO A SCALAR!

Each operator and function decides which sort of value it would be
most appropriate to return in a scalar context.  Some operators return
the length of the list that would have been returned in a list
context.  Some operators return the first value in the list.  Some
operators return the last value in the list.  Some operators return a
count of successful operations.  In general, they do what you want,
unless you want consistency.";
Larry Wall, in the perlfunc man page.


These two passages just describe one single feature of each language,
but they seem to be the most overt passages that show the opinions and
attitues that the languages carry with them.

If you want behavior that is "surprising" but you can use "simple and
predictable" rules to analyze it, choose Tcl. You're first guess may
not be right, but you can go over it with a few rules and figure out
what you want. If you want a language where you first guess is likely
right, but if you aren't there would be no way of knowing except for
the documentation, choose Perl.
-- 
Andrew Langmead


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

Date: Wed, 09 Dec 1998 22:35:40 GMT
From: tpoindex@nyx10.nyx.net (Tom Poindexter)
Subject: Re: TCL <-> PERL, what's better.
Message-Id: <913242940.793771@iris.nyx.net>

In article <74mc1o$at4@mercury.adc.com>,
Brand Hilton <bhilton@tsg.adc.com> wrote:
>In article <366EA907.374914D@nortel.com>,
>Michalowski, Martin <martin007@ottawa.com> wrote:
>>I love TCL but all I hear about lately is PERL.
>>
>>        - Perl in schools, Perl for the internet, etc, etc.
>>
>>why not TCL?  To me it seems like TCL code is much simpler. Is it the
>>performance?
>
>Oh, jeez... let the language wars begin :-)


We hope not!  And my follow up shouldn't be construed as promoting one.


>Performance is a factor, but certainly not the main one.
>
>You might take a look at the Perl advocacy page maintained by Tom
>Christiansen (http://language.perl.com/versus/index.html).  It's
>pretty thorough.


Unfortunately, Tom's "Tcl vs. Perl" analysis is quite a bit dated.  Tcl 8.0
has been available for two years, which addresses most technical concerns
noted in Tom's page (bytecode compiler & vm, native data representation, 
namespaces, list references, binary data, to name a few.)  Aaron Sherman's
comparision (on the same page) also suffers from the same problem.  Neither 
should be considered as reliable analysis.


>you're doing GUIs.  But, as a language, Perl's so much more powerful
>than TCL that it almost defies comparison.  I've been doing Perl for

I can't support that same statement.  I have seen users of both Perl and
Tcl create some interesting software.  I've seen both systems used in
"industrial strength, mission critical" applications.

Tcl and Perl are more complementary than competing,  No need to limit
yourself to one language when so many good ones are available. 

-- 
Tom Poindexter
tpoindex@nyx.net
http://www.nyx.net/~tpoindex/


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

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


Administrivia:

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

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


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

	subscribe perl-users
or:
	unsubscribe perl-users

to almanac@ruby.oce.orst.edu.  

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

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

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

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

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

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


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

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