[16573] in Perl-Users-Digest

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

Perl-Users Digest, Issue: 3985 Volume: 9

daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Fri Aug 11 11:05:27 2000

Date: Fri, 11 Aug 2000 08:05:14 -0700 (PDT)
From: Perl-Users Digest <Perl-Users-Request@ruby.OCE.ORST.EDU>
To: Perl-Users@ruby.OCE.ORST.EDU (Perl-Users Digest)
Message-Id: <966006314-v9-i3985@ruby.oce.orst.edu>
Content-Type: text

Perl-Users Digest           Fri, 11 Aug 2000     Volume: 9 Number: 3985

Today's topics:
    Re: [Q]s: sizeof in perl, ioctl.ph... <kj0@mailcity.com>
        Access html file from perl <mgangloff@framacom.com>
    Re: calculating with getting a formula out of a $string (Martien Verbruggen)
    Re: CPAN problem (Anno Siegel)
        CPAN.pm wants to install 5.6 nobull@mail.com
        Expect.pm with Apache and ASP rockvz@my-deja.com
    Re: FileField Problem <lincolnmarr@europem01.nt.com>
    Re: FileField Problem <jsr@lucent.com>
    Re: Get the Time <godzilla@stomp.stomp.tokyo>
    Re: GREP - type of script... <bart.lateur@skynet.be>
        Help - weird cgi-perl problem praty@my-deja.com
        How to Access a hash value? <fthomas@colonypapers.com>
    Re: London =?iso-8859-1?Q?=A330=2D35K?= Perl Programmer <care227@attglobal.net>
    Re: London =?iso-8859-1?Q?=A330=2D35K?= Perl Programmer <godzilla@stomp.stomp.tokyo>
    Re: Newbie: can't run my test script at my Web Host <lmoran@wtsg.com>
        Organizing and verifying a set of tree structures <bart.lateur@skynet.be>
    Re: Perl code for a newbie!! <craig.pugsley@mimesweeper.com>
    Re: Perl code for a newbie!! <rajeev@faircomm.net>
    Re: Perl code for a newbie!! <craig.pugsley@mimesweeper.com>
    Re: Perl code for a newbie!! <craig.pugsley@mimesweeper.com>
    Re: Perl code for a newbie!! <kperrier@blkbox.com>
    Re: Perl code for a newbie!! <craig.pugsley@mimesweeper.com>
    Re: Perl code for a newbie!! <rajeev@faircomm.net>
    Re: Perl mods for MySQL <bart.lateur@skynet.be>
    Re: Pipe on WinNT <abe@ztreet.demon.nl>
    Re: Pipe on WinNT <abe@ztreet.demon.nl>
        pipes <jhijas@yahoo.es>
    Re: Pop Ups <info@digitaltango.com>
        Digest Administrivia (Last modified: 16 Sep 99) (Perl-Users-Digest Admin)

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

Date: 11 Aug 2000 10:57:39 -0400
From: kj0 <kj0@mailcity.com>
Subject: Re: [Q]s: sizeof in perl, ioctl.ph...
Message-Id: <8n1493$ieb$1@panix3.panix.com>


Thanks!

In <hrd6ps0lecrrotflnj5jfbg0pg3413lulk@4ax.com> Abe Timmerman <abe@ztreet.demon.nl> writes:

>	L An unsigned long value.
>		(This 'long' is _exactly_ 32 bits, which may differ from
>		what a local C compiler calls 'long'.  If you want
>		native-length longs, use the '!' suffix.)

My perlfunc (v. 5.0005_02) says nothing about the '!' suffix.  Is that
a v. 5.6 addition?

KJ


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

Date: Fri, 11 Aug 2000 16:57:37 +0200
From: "Gloff" <mgangloff@framacom.com>
Subject: Access html file from perl
Message-Id: <8n14ae$1i9$1@reader1.fr.uu.net>



Is it possible, on one or another way (copy with ftp?), to access, from a
cgi application, an html file in another server than the one were the cgi
script is working?
I mean , for exemple, using the file access functions, (open / close etc...)
to access an html file from its URL, like:
open(MYFILE,"http://www.mydomain.com/myfile.htm");


Thank's for help


Gloff






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

Date: 11 Aug 2000 13:26:03 GMT
From: mgjv@martien.heliotrope.home (Martien Verbruggen)
Subject: Re: calculating with getting a formula out of a $string
Message-Id: <slrn8p7vce.ee0.mgjv@martien.heliotrope.home>

On 11 Aug 2000 12:31:58 +0100,
	nobull@mail.com <nobull@mail.com> wrote:
> 
> # Do do this
> $formula = sub { $_ * 1.16 };
> do { local $_ = $int; &$formula };
> 
> Note: I'm using the $_ parameter convention here for passing a single
> argument to a subroutine.  You can use the more conventional @_
> convention if you prefer:

Running the chance that I offend:

\begin{lecture} 

I think it is important to state here that $_ is not actually _passed_
into the subroutine. The subroutine just accesses the value of $_ that
it can see when it executes. The do{} block has a local variable in
there. To avoid interpretation errors there, it may be beter to use an
explicitly named global variable, or indeed, just use $_[0], as stated
later:

> $formula = sub { $_[0] * 1.16 };
> $formula->($int);

Many people have trouble distinguishing @var and $var, so I'd certainly
avoid any code that could muddle the difference between @_ and $_. There
hardly is any payoff in it, and a lot of possibilities for error and/or
misinterpreation.

\end{lecture}

Martien
-- 
Martien Verbruggen              | 
Interactive Media Division      | Useful Statistic: 75% of the people
Commercial Dynamics Pty. Ltd.   | make up 3/4 of the population.
NSW, Australia                  | 


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

Date: 11 Aug 2000 13:28:28 -0000
From: anno4000@lublin.zrz.tu-berlin.de (Anno Siegel)
Subject: Re: CPAN problem
Message-Id: <8n0v1s$8or$1@lublin.zrz.tu-berlin.de>

Herbert Moses <herbmoses@worldnet.att.net> wrote in comp.lang.perl.misc:
>
>
>--
>
>Hi,
>Having trouble with CPAN. Trying to install ANYTHING and get the following:
>
>
>
>Trying with "/usr/bin/lynx -source" to get
>    ftp://carroll.cac.psu.edu/pub/CPAN/modules/03modlist.data.gz
>
>gzip: yes/sources/modules/03modlist.data: not in gzip format

That's a bug on older versions of CPAN.  It has been fixed, but
the nasty thing is, it stops you from upgrading CPAN.

To work around it, quit the CPAN shell and gzip
yes/sources/modules/03modlist.data in place.  The file should be
03modlist.data.gz then.  Now run CPAN again. You may have to
repeat the process for up to two more similar files.  Then upgrade
CPAN.  Then install Bundle::Netlib, so CPAN doesn't have to use
lynx to retrieve files.  Then install MD5, or whatever.

The other errors you have seen (which I snipped) may well go away
after that.

Oh, and apparently the directory that is normally ".cpan" is called
"yes" in your case.  This may be because during CPAN configuration
you answered "yes" to a question that expected a directory name.
This is not a problem for CPAN, but it may be for you when you
ask yourself what the directory "yes" is good for, so, while you're
at it you may want to correct that too.

Anno


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

Date: 11 Aug 2000 15:30:04 +0100
From: nobull@mail.com
Subject: CPAN.pm wants to install 5.6
Message-Id: <u9og2zvpjn.fsf@wcl-l.bham.ac.uk>

Whenever I try to install a module from CPAN that is dependant on
IO::Socket or some other path of the standard distribution CPAN.pm
tries to install Perl-5.6 on my system.

Is there any way to avoid this?

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


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

Date: Fri, 11 Aug 2000 13:24:11 GMT
From: rockvz@my-deja.com
Subject: Expect.pm with Apache and ASP
Message-Id: <8n0upl$h1s$1@nnrp1.deja.com>

Hi,

I have a problem in using Expect.pm with the ASP
module.
NOTE: The same code when run in the cgi-bin
environment
works.

The following 2 errors are generated at random
E1>
Errors Output

> Can't locate object method "CLOSE" via package
"Apache::ASP::Request" at
/usr/lib/perl5/site_perl/5.005/Expect.pm line 80.
, /usr/lib/perl5/site_perl/5.005/Apache/ASP.pm line
1229


E2>
no run-time error as above here
"Never got password prompt on 164.164.10.161, 2:EOF"

Q>
Why am i getting these errors in random?
What is this CLOSE method that Im unable to locate

------------------------------------------------
# My program is say use_expect_ssh.asp
# it uses open ssh to execute a command on a
# remote machine. Expects the password

<% @Language=PerlScript %>
<%

use Expect;
use CGI;

# Optional debugging, explained later.
 $Expect::Debug=0;
 $Expect::Exp_Internal=1;
 $Expect::Log_Stdout=0; # On by default.

## some host
@hosts = ("123.165.10.161");

my($USER)= "abc";
my($PWORD)= "abc123";
my($HOST)= "123.165.10.161";
my($REMCMD)= "who";

my($L_FILE)= "/tmp/junk.out";

# command to be executed using ssh
$REMCMD = $REMCMD . ">junk.out";

sub dossh()
{
  ## the problem is with spawn()
  $rlogin=Expect->spawn("/opt/bin/ssh -l $USER $HOST
\"$REMCMD\"");

  $rlogin->expect(50, -re, "word:") || die "Never got
password prompt on $host,".$rlogin->exp_error()."\n";

  # We got the prompt, so send a password.
  print $rlogin $PWORD . "\r";

  return $rlogin;

}

sub main {

  my $ssh = dossh();
  my $pid = $ssh->pid();
  print "pid = " . $pid . "\n";

  ## this step is required
  my $stat = waitpid($pid, 0);
  print "stat = " . $stat . "\n";
  $ssh->hard_close();
}

## call main here
main();

%>

----------------------------------------------------
The html code could be

<html>

<form action="use_expect_ssh.asp" method="post"
target=A2>

<input type=submit>
</form>
</html>



regards
and thanks in advane
rock


Sent via Deja.com http://www.deja.com/
Before you buy.


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

Date: Fri, 11 Aug 2000 16:44:52 +0200
From: "Marr, Lincoln [HOOF:4713:EXCH]" <lincolnmarr@europem01.nt.com>
Subject: Re: FileField Problem
Message-Id: <39941163.247077FF@europem01.nt.com>

Make sure that in the HTML of your script the input is named 'filefield' (ie <INPUT
TYPE="text" NAME="filefield"> and then try doing:
$q = new CGI;
$filefield = $q->param("filefield");

when you submit the form you should get a name/value pair and you can now do
whatever you want with the scalar... This has worked for me (naming the scalar
filefield and also the param) but I don't know why... anyone got any ideas?

James Stephen Roberts wrote:

> I am writing a Perl/CGI code that should allow a user to input a filename and
> directory into a field and then the program should be able to retrieve this path
> and store it as a scalar value. When I use $path_name = $q->param('filefield')
> it returns a file handle. I just want the file path and name. If anyone can
> offer any help on this please let me know. Also, if you need some of the code
> just let me know and I will post it. Thanks.
>
> Steve Roberts



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

Date: Fri, 11 Aug 2000 10:55:06 -0400
From: James Stephen Roberts <jsr@lucent.com>
Subject: Re: FileField Problem
Message-Id: <399413CA.FF81CFC1@lucent.com>

"Marr, Lincoln [HOOF:4713:EXCH]" wrote:
> 
> Make sure that in the HTML of your script the input is named 'filefield' (ie <INPUT
> TYPE="text" NAME="filefield"> and then try doing:
> $q = new CGI;
> $filefield = $q->param("filefield");
> 
> when you submit the form you should get a name/value pair and you can now do
> whatever you want with the scalar... This has worked for me (naming the scalar
> filefield and also the param) but I don't know why... anyone got any ideas?
> 
> James Stephen Roberts wrote:
> 
> > I am writing a Perl/CGI code that should allow a user to input a filename and
> > directory into a field and then the program should be able to retrieve this path
> > and store it as a scalar value. When I use $path_name = $q->param('filefield')
> > it returns a file handle. I just want the file path and name. If anyone can
> > offer any help on this please let me know. Also, if you need some of the code
> > just let me know and I will post it. Thanks.
> >
> > Steve Roberts


I declare the filefield in the perl code and not the html. It is from the CGI
library. 

$q = new CGI;
$q->filefield(-name=>'bitmapname');
$bitmapname = $q->param('bitmapname');

Once I have done this, the $bitmapname only contains the name of the file and
not the entire path.

I need the entire path to send as an argument to another function.

Steve Roberts


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

Date: Fri, 11 Aug 2000 06:28:33 -0700
From: "Godzilla!" <godzilla@stomp.stomp.tokyo>
Subject: Re: Get the Time
Message-Id: <3993FF81.38AD50B8@stomp.stomp.tokyo>

Kermit wrote:
 
> Sorry...   Ribbit.
 
> Tom Wrote:
> FYI, I'm sure the newsgroup would appreciate question-type 
> postings, rather than (simple) arbitrary code snippets.


Kermit, you forgot to genuflect, fall to your
knees and slobber his glossy black jack boots.

Godzilla!


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

Date: Fri, 11 Aug 2000 14:58:32 GMT
From: Bart Lateur <bart.lateur@skynet.be>
Subject: Re: GREP - type of script...
Message-Id: <ao48ps45qc1v46k4s8c79h0p0s9r808fnl@4ax.com>

Larry Rosler wrote:

>>   Can't do inplace edit without backup.
>> 
>> this error is explained in perldiag
>
>The behavior (which is the same in 5.6.0) should be documented in 
>perlrun, where I quoted from.  This is a documentation bug.

Is it? I would think it is an implementation bug. I can imagine what
happens under Unix...

 * The old file is renamed to a temporary backup name.
 * A new file is created with the same path as the old file had. It
remains open for writing.
 * The backup file is opened for reading.
 * Then, the name is deleted from the directory listing (AKA
"unlinked"); but the file still exists since it's open. 

All that before the first line is processed. Go ahead, Perl!

Once the backup file is closed, the system will automatically free the
space it took. So now it's deleted.

This mechanism doesn't work in Win32, nor on DOS, nor on Mac. 

Conclusion: the port for those platforms should be rewritten so that the
backup file is deleted once it's closed, *by perl*. So that's a "before"
and an "after" task.

-- 
	Bart.


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

Date: Fri, 11 Aug 2000 14:20:42 GMT
From: praty@my-deja.com
Subject: Help - weird cgi-perl problem
Message-Id: <8n123k$jp6$1@nnrp1.deja.com>

Am trying to write a perl script to be able to upload files without
using ftp.

I do a
&ReadParse(\%cgi_data,\%cgi_cfn,\%cgi_ct,\%cgi_sfn);

to read all the data send by post.

I want to read the destination from the form itself and I want to
rename the file in the perl script to the name entered in the  form.

Surprisingly
rename($cgi_sfn{'upfile'},"/tmp/testfile")
works
but the following doesnt
rename($cgi_sfn{'upfile'},$cgi_data{'completepath'})

(Completepath is what I have the complete filename in the form, the
value of $cgi_data{'completepath'} is "/tmp/testfile" as verified by
printing)

Whats going wrong ? I'm new to perl - is the language so weird ?

Thanks in advance,
Praty


Sent via Deja.com http://www.deja.com/
Before you buy.


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

Date: Fri, 11 Aug 2000 10:53:26 -0400
From: "Frank L. Thomas" <fthomas@colonypapers.com>
Subject: How to Access a hash value?
Message-Id: <gqUk5.9042$Yl1.301091@nntp3.onemain.com>

The following code is intended to take input passed to this script. When I
try to print the value in the hash table corresponding to $users{$userid},
there is no value. I can print out the entire hash but cannot reference a
value of the hash. Any thoughts?

#!/usr/local/bin/perl

use CGI qw(:standard);

my $custnum = param("CustNum");
my $userid = param("UserID");


if(open(MASTPASS, "filename")){

 $key = <MASTPASS>;

 while($key ) {   #read in customer number and user name from file
  chomp($key);
  $value = <MASTPASS>;
  chomp($value);
  $users{$key} = $value;
  $key = <MASTPASS>;}

 close (MASTPASS);
 print "Content-type: text/html\n\n";
  print "<head>\n";
  print "<title>On line ordering</title>\n";
  print "</head>";
  print "<body>";
  print "<h1>Output Screen </h1>";
  print "<h1>", $userid, $custnum, $value, $users{$userid}, "</h1>"; #this
is the line I have a question about
  print "</body>";




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

Date: Fri, 11 Aug 2000 09:35:48 -0400
From: Drew Simonis <care227@attglobal.net>
Subject: Re: London =?iso-8859-1?Q?=A330=2D35K?= Perl Programmers Required
Message-Id: <39940134.BF88E2BD@attglobal.net>

checker wrote:
> 
> Show me a better place to talk to quality Perl programmers than
> in a Perl NewsGroup.
> 
> Keep it coming gents.

If you want to talk, then by all means do so.  If you want to 
offer jobs, you are off topic.  Posting off topic is not a 
good thing.  Know what this means?

*plonk*


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

Date: Fri, 11 Aug 2000 07:07:21 -0700
From: "Godzilla!" <godzilla@stomp.stomp.tokyo>
Subject: Re: London =?iso-8859-1?Q?=A330=2D35K?= Perl Programmers Required
Message-Id: <39940899.B16F11D6@stomp.stomp.tokyo>

checker wrote:

(snippage)

> Show me a better place to talk to quality Perl programmers
> than in a Perl NewsGroup.


Such ironic humor.

Godzilla!


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

Date: Fri, 11 Aug 2000 10:59:58 -0400
From: Lou Moran <lmoran@wtsg.com>
Subject: Re: Newbie: can't run my test script at my Web Host
Message-Id: <iRSUOeWwM39UX7=qfrjI6scL9SCN@4ax.com>

Bet on the shebang being wrong... ask your host to email you the
shebang they use (#!/PATH/TO/PERL)

On Fri, 11 Aug 2000 01:30:01 GMT, Guillaume
<guillaume.lahitette@cwusa.com> wrote:

>Hello Perl lovers,
>
>I am new to Perl (I am a Java developer). I have been searching thru the 
>FAQs and threads but am still desperate.
>
>My Web Host created a cgi-bin directory for me. I uploaded my dummy test.pl  
>(see code below) to make sure it has been created properly. I have tried a 
>couple of Perl invocations but Netscape 4.7 still returns an HTTP Error 404 
>Not Found when I can see test.pl using my WS_FTP client!
>I posted a readme.txt file in the cgi-bin and I can access the page fine.
>Is there something wrong with my script?
>
>According to netcraft.com, my web host is running Microsoft-IIS/4.0 on NT4 
>or Windows 98.
>
>Thanks a million for your help,
>
>Guillaume.
>
>
>#!/usr/bin/perl.exe -w
>
>print "Content-type: text/html\n\n";
>print " ";
>print "<HEAD><TITLE>Test Page</TITLE></HEAD>\n";
>print "<HTML><BODY><B>PERL IS WORKING PROPERLY!!!</B></BODY></HTML>";


 ...no Y2K was fine, it was W2K we had the problems with...
lmoran@wtsg.com


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

Date: Fri, 11 Aug 2000 13:11:17 GMT
From: Bart Lateur <bart.lateur@skynet.be>
Subject: Organizing and verifying a set of tree structures
Message-Id: <hdu7psgn362q3e1kd9a992q02tvecb7f13@4ax.com>

I have the subtask of modifiying data that should be ordered in a
treelike structure. The user can modify the relationship between two
items, so that if one is subordinate to the other, the reverse can't be
true. No cycles. It's not just *verifying* that there are no cycles, but
*removing* the inverse link, if this link did exist before. Also, not
all items are indeed linked to each other. So it's a very loose tree. (a
bush?)

I'm looking for suggestions on what data structures and data
organization I could use, to ease writing the program that maintains it
in a state of integrity.

-- 
	Bart.


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

Date: Fri, 11 Aug 2000 14:12:11 +0100
From: "Craig Pugsley" <craig.pugsley@mimesweeper.com>
Subject: Re: Perl code for a newbie!!
Message-Id: <MYSk5.942$iE4.9647@news2-win.server.ntlworld.com>

OK. Problem. Call me a real dullard, but what do you have to do to get this
running?
(As I said, I'm a bit of a newbie!) From what I can gather, if I make a
textfile from this code and call it something like
"LineStripper.pl", then call the perl compiler with the command like:

"perl linestripper.pl c:\files\ 1"

It should work? The two arguments are the path of the directory and the line
to be stripped. Is this right?

Thanks very much indeed!!

CraigP


"Craig Pugsley" <craig.pugsley@mimesweeper.com> wrote in message
news:nfSk5.835$iE4.8548@news2-win.server.ntlworld.com...
> Thanks very much indeed. That will really help get me sorted.
> If you had to write the code by hand, then THANKS!!!
> If not, then THANKS ANYWAY!!!
>
> CraigP
>
>
> "Christopher M. Jones" <christopher_j@uswest.net> wrote in message
> news:ZIRk5.17$WW5.35151@news.uswest.net...
> >
> > "Craig Pugsley" <craig.pugsley@mimesweeper.com> wrote:
> > > I'm looking for some Perl code to chop the first line off a large
> > collection
> > > of separate text files. The code should be give the path of a
directory
> > > containing the (large number of) files, it should then strip the nth
> line
> > > out of the file, and replace the original file. It shouldn't copy the
> file
> > > (if this can be helped!), as I'm going to be dealing with in excess of
> 600
> > > separate text files!!!
> >
> >
> > #!/usr/bin/perl
> >
> > $basedir = ARGV[0];
> > $searchpattern = "*.txt";
> > $linenum = $ARGV[1];
> >
> > while(<$basedir/$searchpattern>)
> >     {
> >     $filename = $_;
> >     unless ( open (FILE, "<$filename") )
> >         { print "Unable to open '$filename' for reading.\n"; next; }
> >     @file = <FILE>;
> >     close (FILE);
> >
> >     delete ($file[$linenum]);
> >
> >     unless ( open (FILE, ">$filename") )
> >         { print "Unable to open '$filename' for writing.\n"; next; }
> >     print FILE @file;
> >     close (FILE);
> >     }
> >
> > print "Done.\n";
> >
> >
> >
>
>




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

Date: Fri, 11 Aug 2000 14:10:26 +0100
From: "Rajeev" <rajeev@faircomm.net>
Subject: Re: Perl code for a newbie!!
Message-Id: <8n0u6g$1t7$1@news.icl.se>

Hi

Not trying to being critical. I am a new to perl myself.

But, should the line

delete ($file[$linenum]);

read as

delete ($file[$linenum - 1]);

Cheers

Rajeev




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

Date: Fri, 11 Aug 2000 14:23:47 +0100
From: "Craig Pugsley" <craig.pugsley@mimesweeper.com>
Subject: Re: Perl code for a newbie!!
Message-Id: <F7Tk5.957$iE4.9832@news2-win.server.ntlworld.com>

You're probably right (doesn't the line number start at 0?). BUT....

    This doesn't solve my problem!!!

Any ideas?

CraigP

"Rajeev" <rajeev@faircomm.net> wrote in message
news:8n0u6g$1t7$1@news.icl.se...
> Hi
>
> Not trying to being critical. I am a new to perl myself.
>
> But, should the line
>
> delete ($file[$linenum]);
>
> read as
>
> delete ($file[$linenum - 1]);
>
> Cheers
>
> Rajeev
>
>




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

Date: Fri, 11 Aug 2000 14:40:58 +0100
From: "Craig Pugsley" <craig.pugsley@mimesweeper.com>
Subject: Re: Perl code for a newbie!!
Message-Id: <NnTk5.984$iE4.10059@news2-win.server.ntlworld.com>

I keep getting this error message:

delete argument is not a HASH element or slice at linecutter.pl line 17.



"Craig Pugsley" <craig.pugsley@mimesweeper.com> wrote in message
news:MYSk5.942$iE4.9647@news2-win.server.ntlworld.com...
> OK. Problem. Call me a real dullard, but what do you have to do to get
this
> running?
> (As I said, I'm a bit of a newbie!) From what I can gather, if I make a
> textfile from this code and call it something like
> "LineStripper.pl", then call the perl compiler with the command like:
>
> "perl linestripper.pl c:\files\ 1"
>
> It should work? The two arguments are the path of the directory and the
line
> to be stripped. Is this right?
>
> Thanks very much indeed!!
>
> CraigP
>
>
> "Craig Pugsley" <craig.pugsley@mimesweeper.com> wrote in message
> news:nfSk5.835$iE4.8548@news2-win.server.ntlworld.com...
> > Thanks very much indeed. That will really help get me sorted.
> > If you had to write the code by hand, then THANKS!!!
> > If not, then THANKS ANYWAY!!!
> >
> > CraigP
> >
> >
> > "Christopher M. Jones" <christopher_j@uswest.net> wrote in message
> > news:ZIRk5.17$WW5.35151@news.uswest.net...
> > >
> > > "Craig Pugsley" <craig.pugsley@mimesweeper.com> wrote:
> > > > I'm looking for some Perl code to chop the first line off a large
> > > collection
> > > > of separate text files. The code should be give the path of a
> directory
> > > > containing the (large number of) files, it should then strip the nth
> > line
> > > > out of the file, and replace the original file. It shouldn't copy
the
> > file
> > > > (if this can be helped!), as I'm going to be dealing with in excess
of
> > 600
> > > > separate text files!!!
> > >
> > >
> > > #!/usr/bin/perl
> > >
> > > $basedir = ARGV[0];
> > > $searchpattern = "*.txt";
> > > $linenum = $ARGV[1];
> > >
> > > while(<$basedir/$searchpattern>)
> > >     {
> > >     $filename = $_;
> > >     unless ( open (FILE, "<$filename") )
> > >         { print "Unable to open '$filename' for reading.\n"; next; }
> > >     @file = <FILE>;
> > >     close (FILE);
> > >
> > >     delete ($file[$linenum]);
> > >
> > >     unless ( open (FILE, ">$filename") )
> > >         { print "Unable to open '$filename' for writing.\n"; next; }
> > >     print FILE @file;
> > >     close (FILE);
> > >     }
> > >
> > > print "Done.\n";
> > >
> > >
> > >
> >
> >
>
>




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

Date: 11 Aug 2000 09:01:25 -0500
From: Kent Perrier <kperrier@blkbox.com>
Subject: Re: Perl code for a newbie!!
Message-Id: <6E60DD18CCE2557B.2ABFB9858DD937B8.8B9CAFAB7E970246@lp.airnews.net>

"Craig Pugsley" <craig.pugsley@mimesweeper.com> writes:

> I'm looking for some Perl code to chop the first line off a large collection
> of separate text files. The code should be give the path of a directory
> containing the (large number of) files, it should then strip the nth line
> out of the file, and replace the original file. It shouldn't copy the file
> (if this can be helped!), as I'm going to be dealing with in excess of 600
> separate text files!!!

How much are you willing to pay for me to write it for you?

TANSTAAFL.

Kent
-- 
We are in fact well and truly doomed.
				-- Jamie Zawinski
				   http://www.jwz.org/gruntle/nscpdorm.html


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

Date: Fri, 11 Aug 2000 15:26:02 +0100
From: "Craig Pugsley" <craig.pugsley@mimesweeper.com>
Subject: Re: Perl code for a newbie!!
Message-Id: <22Uk5.1053$iE4.11329@news2-win.server.ntlworld.com>

I will pay you 10 MEEEELLLIIIOOONNN dollars if you can get it sorted.

"TANSTAAFL"? - please, explain...

CraigP

"Kent Perrier" <kperrier@blkbox.com> wrote in message
news:6E60DD18CCE2557B.2ABFB9858DD937B8.8B9CAFAB7E970246@lp.airnews.net...
> "Craig Pugsley" <craig.pugsley@mimesweeper.com> writes:
>
> > I'm looking for some Perl code to chop the first line off a large
collection
> > of separate text files. The code should be give the path of a directory
> > containing the (large number of) files, it should then strip the nth
line
> > out of the file, and replace the original file. It shouldn't copy the
file
> > (if this can be helped!), as I'm going to be dealing with in excess of
600
> > separate text files!!!
>
> How much are you willing to pay for me to write it for you?
>
> TANSTAAFL.
>
> Kent
> --
> We are in fact well and truly doomed.
> -- Jamie Zawinski
>    http://www.jwz.org/gruntle/nscpdorm.html




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

Date: Fri, 11 Aug 2000 15:41:22 +0100
From: "Rajeev" <rajeev@faircomm.net>
Subject: Re: Perl code for a newbie!!
Message-Id: <8n13gu$4ip$1@news.icl.se>

Hi Craig

I tried the following code and it works. I added -w to the first line, $ was
missing in ARGV[0] in the third line and line 15 now has $linenum -1.

Cheers

Rajeev
++++++++
#!/usr/bin/perl -w

$basedir = $ARGV[0];
$searchpattern = "*.txt";
$linenum = $ARGV[1];

while(<$basedir/$searchpattern>)
    {
    $filename = $_;
    unless ( open (FILE, "<$filename") )
        { print "Unable to open '$filename' for reading.\n"; next; }
    @file = <FILE>;
    close (FILE);

    delete ($file[$linenum -1]);

    unless ( open (FILE, ">$filename") )
        { print "Unable to open '$filename' for writing.\n"; next; }
    print FILE @file;
    close (FILE);
    }





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

Date: Fri, 11 Aug 2000 13:12:41 GMT
From: Bart Lateur <bart.lateur@skynet.be>
Subject: Re: Perl mods for MySQL
Message-Id: <2uu7psci72kuf94imv08cquvqq6p2gaqr7@4ax.com>

<((>< <yamar420@my-deja.com> wrote:

>Everytime I try
>to untar the Mysql bin file it tells my it has a checksum error. After
>looking around I found notes stating that I needed to load GNUtar. I
>have since then installed it, but still have problems untarring the
>file. Does anyone know how to correct this ?

I think you've got a corrupt file. Try downloading it again.

-- 
	Bart.


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

Date: Fri, 11 Aug 2000 16:28:11 +0200
From: Abe Timmerman <abe@ztreet.demon.nl>
Subject: Re: Pipe on WinNT
Message-Id: <pt28ps4n25d9jbpm1obaqk56cosmtlimod@4ax.com>

On Fri, 11 Aug 2000 13:34:15 +0200, Peter Gunreben
<pgunreben@lucent.com> wrote:

> Hi,
> 
> I'm currently trying to port some perl scripts to
> WinNT (ActivePerl5.09). The mechanism to catch a 
> pipe worked well under UNIX, but it seems that
> it doesn't work under WinNT. Does anyone know how
> to overcome this issue.
> 
> Example:
> 
> open(UP,"update.pl |") || die "Can't spawn update";

	open UP, 'perl update.pl |' or die "Pipe problem: $!";

> while($i = <UP>) {
>    print "Got $i\n";
> }
> close(UP);

You should check the return of that close, it's where problems during
the pipe are reported.

	perldoc -f close


-- 
Good luck,
Abe


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

Date: Fri, 11 Aug 2000 16:45:41 +0200
From: Abe Timmerman <abe@ztreet.demon.nl>
Subject: Re: Pipe on WinNT
Message-Id: <uf38ps0e9q3gfboe16cr9676t66n2ofa73@4ax.com>

On Fri, 11 Aug 2000 04:49:21 -0700, "Christopher M. Jones"
<christopher_j@uswest.net> wrote:

> My first instinct would be to say install Linux.

And my first instinct to that reaction is *plonk*

NT is a reality and one day you may have to come to terms with it.
A question about porting Perl-code to Win32 does not give you the right
to make unhelpful statements about changing OSes.

If you don't have anything to contribute, don't post!

> ;)
no winks or nudges

[followups set] 

-- 
Good luck,
Abe


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

Date: Fri, 11 Aug 2000 15:12:10 +0200
From: Javier Hijas <jhijas@yahoo.es>
Subject: pipes
Message-Id: <3993FBAA.ED1B3C0@yahoo.es>

I am traslating a shell script where you can find things like this:

rsh $HOMESERVER "cp /home/EMBL/stdprofile /home/${acc_name}/.profile"
rsh $HOMESERVER "cp /home/EMBL/stdkshrc /home/${acc_name}/.kshrc" 
rsh $HOMESERVER "cp /home/EMBL/stdlogin /home/${acc_name}/.login" 
rsh $HOMESERVER "cp /home/EMBL/stdcshrc /home/${acc_name}/.cshrc"
rsh $HOMESERVER "cp /home/EMBL/stdexrc /home/${acc_name}/.exrc"
rsh $HOMESERVER "cp /home/EMBL/stdelmrc /home/${acc_name}/.elm/elmrc"

 which makes the script really slow. Now in perl I want to avoid this
using only one rsh with a pipe to introduce all the commands. I tried it
in this way:

open(HSERVER,"|rsh pc-cg13")  || die "can't fork: $!";
print HSERVER "mkdir test\n" || print "print did'n work"; 


Perl doesn't complaint at all, but it does not create a dir called test.
I checkd all the permisions.


Another problem I have doing this is that I don't know how could I get
the error messages from the commands I input to the rshell.

Is there any way to solve all this?

thanks in advance.


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

Date: Fri, 11 Aug 2000 14:46:29 GMT
From: "Etienne Laverdiere" <info@digitaltango.com>
Subject: Re: Pop Ups
Message-Id: <9lUk5.5738$K5.189971@news20.bellglobal.com>

<script language='javascript'>
window.alert('Message');
</script>
"Joel Nelson" <joelnelson@home.net> wrote in message
news:39901B06.F19D7396@home.net...
> Nick Gushlow wrote:
>
> > Help.
> >
> > Can anybody tell me how to invoke alert windows?
> > Basically I have a form page, and if the user doesn't fill in required
> > information I want a little alert box to pop up and inform them so and
send
> > them back to the page  to fill out the details they missed.
>
> Hmmm, sounds like your asking a web question. If that is the case then
look in
> a javascript newsgroup!
>
> Joel
>




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

Date: 16 Sep 99 21:33:47 GMT (Last modified)
From: Perl-Users-Request@ruby.oce.orst.edu (Perl-Users-Digest Admin) 
Subject: Digest Administrivia (Last modified: 16 Sep 99)
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.  

| NOTE: The mail to news gateway, and thus the ability to submit articles
| through this service to the newsgroup, has been removed. I do not have
| time to individually vet each article to make sure that someone isn't
| abusing the service, and I no longer have any desire to waste my time
| dealing with the campus admins when some fool complains to them about an
| article that has come through the gateway instead of complaining
| to the source.

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 V9 Issue 3985
**************************************


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