[12320] in Perl-Users-Digest

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

Perl-Users Digest, Issue: 5920 Volume: 8

daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Tue Jun 8 12:07:18 1999

Date: Tue, 8 Jun 99 09:00:31 -0700
From: Perl-Users Digest <Perl-Users-Request@ruby.OCE.ORST.EDU>
To: Perl-Users@ruby.OCE.ORST.EDU (Perl-Users Digest)

Perl-Users Digest           Tue, 8 Jun 1999     Volume: 8 Number: 5920

Today's topics:
    Re: __DATA__ <gellyfish@gellyfish.com>
    Re: a simple search and replace <fruffet@kaptech.com>
        Calling an applet from perl <greynaga@yahoo.com>
        can i variably name an array? mikecard@my-deja.com
    Re: can i variably name an array? philc@hempseed.com
    Re: can i variably name an array? (Randal L. Schwartz)
    Re: can i variably name an array? (Greg Bacon)
    Re: can i variably name an array? <tchrist@mox.perl.com>
    Re: can i variably name an array? (Tad McClellan)
    Re: can i variably name an array? (Larry Rosler)
    Re: can i variably name an array? <arnej@fc.hp.com>
    Re: can i variably name an array? <droby@copyright.com>
        CGI saving file dialog box <Edouard.Ouin@tinet.ie>
    Re: Choosing a time module and working with it <james@britlinks.co.uk>
        Converting UTF-8 to ISO-8859-1 <main@isk.kth.se>
    Re: Creating an external config file. How ? (Tad McClellan)
    Re: Creating an external config file. How ? (Larry Rosler)
    Re: DBD::ODBC <eyounes@aol.com>
        Extract file name from path <pjain@usol.com>
    Re: Extract file name from path (Greg Bacon)
    Re: Extract file name from path <dpodbori@email.msn.com>
    Re: Get Date in Perl <droby@copyright.com>
    Re: getting perl output(HTML code) from a remote host. <rootbeer@redcat.com>
    Re: how can i do this? (Larry Rosler)
    Re: How to use <!--exec to pass arguments in cgi ? <thomas.distler@icn.siemens.de>
    Re: How write a perl program that connects to a remote  <fruffet@kaptech.com>
    Re: How write a perl program that connects to a remote  <dominikl@pyramid.de>
        if loop ? <mark.stellaard@knoware.nl>
    Re: know Perl to maintain Perl (was: Re: I pass an arra (Greg Bacon)
    Re: NT perl question(probably simple) <rootbeer@redcat.com>
        Special: Digest Administrivia (Last modified: 12 Dec 98 (Perl-Users-Digest Admin)

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

Date: 8 Jun 1999 15:11:45 +0100
From: Jonathan Stowe <gellyfish@gellyfish.com>
Subject: Re: __DATA__
Message-Id: <375d24a1@newsread3.dircon.co.uk>

Andre Arpin <arpin@adan.kingston.net> wrote:
> When I run this program I get the following error message
> 
> Read on closed filehandle <DATA> at D:\XX.PL line 6.
> 
> Is it possible to read data within a package
> 
> 
> package a_package;
> 
> BEGIN
> {
>  while (<DATA>)
>  {
>   print $_;
>  }
> }
> 
> __DATA__
> this is a test
> 

Its not a matter of reading from <DATA> within a package its a matter of
trying to read from <DATA> in a BEGIN block - that is at compile time -
the DATA filehandle is not opened until runtime.  It will work fine if
you lose the BEGIN block.

/J\
-- 
Jonathan Stowe <jns@gellyfish.com>



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

Date: Tue, 8 Jun 1999 16:59:34 +0200
From: "Fred Ruffet" <fruffet@kaptech.com>
Subject: Re: a simple search and replace
Message-Id: <7jjb51$1mv$1@gatekeeper.ornano.kapt.com>

>this should simply do a global replace of all the instances of <p><strong>
>with <p>.  but it doesn't seem to do anything.  if i change the
>>>(append) to a > (write over) i end up with an empty file.

In my opinion, it makes something, but you don't save it. You read the file,
and replace on the line you've read, but you do nothing with the result, you
should have a file open on output, to write into it, and, if you like, at
end, when file are closed, replace the input by the output.
You can't write the file you read (you don't have records, indexes, and so
on, to replace a line...)

So, it could become :
open (INDEXIN, "<bond.html") || die "Can't open file: $!\n";
open (INDEXOUT, ">bond2.html") || die "Can't open file: $!\n";
while ($line=<INDEXIN>) {
    $line=~ s/<p><strong>/<p>/g;
    print INDEXOUT $line;
}
close (INDEXIN);
close (INDEXOUT);
rename "bond2.html", "bond.html";

regards,



Fridiric Ruffet - fruffet@kaptech.com
"Seach for perfection is all very well,
 But to look for Heaven, is to leave here in hell." G.M.Summer





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

Date: Tue, 08 Jun 1999 14:18:17 GMT
From: Gerardo <greynaga@yahoo.com>
Subject: Calling an applet from perl
Message-Id: <7jj8mv$lts$1@nnrp1.deja.com>

Hi there,

I'm trying to call an applet from a perl script. I keep getting:
"Applet Files class Files could not be loaded"
This message doesn't tell me much, but I think that is not finding the
applet.

This is the way I'm calling it:
 .....
print '<applet codebase="cgi-bin/test" code="Files.class"
archive="gfiles.jar" width=600 height=250>';
print '</applet>';
 .....

I've tried putting absolute path in codebase, I have the .class and .jar
files in cgi-bin/test.
I have Netscape Comm. 4.07 and the script is running on Linux.

Any help is much appreciated
Gerardo


Sent via Deja.com http://www.deja.com/
Share what you know. Learn what you don't.


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

Date: Tue, 08 Jun 1999 13:12:12 GMT
From: mikecard@my-deja.com
Subject: can i variably name an array?
Message-Id: <7jj4r4$kbs$1@nnrp1.deja.com>

hello

is it possible to give an array an interpolated name?

suppose i have

		$array_name = "mikes_array";

now i want to use the scalar $array_name to create an array
@mikes_array.

i have looked in the books and in this ng and tried many different
things one of them being @$array_name (which i knew wouldnt work because
it was just too ugly).

is this possible or am i just dreaming.

mike cardeiro


Sent via Deja.com http://www.deja.com/
Share what you know. Learn what you don't.


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

Date: Tue, 08 Jun 1999 13:33:52 GMT
From: philc@hempseed.com
Subject: Re: can i variably name an array?
Message-Id: <7jj63v$krk$1@nnrp1.deja.com>

In article <7jj4r4$kbs$1@nnrp1.deja.com>,
  mikecard@my-deja.com wrote:
> hello
>
> is it possible to give an array an interpolated name?

Yes!

$array = "mikes_array";
$$array[0] = "cool";
print $mikes_array[0];

Isn't perl just the coolest!


Sent via Deja.com http://www.deja.com/
Share what you know. Learn what you don't.


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

Date: 08 Jun 1999 07:54:07 -0700
From: merlyn@stonehenge.com (Randal L. Schwartz)
Subject: Re: can i variably name an array?
Message-Id: <m1wvxeeoa8.fsf@halfdome.holdit.com>

>>>>> "mikecard" == mikecard  <mikecard@my-deja.com> writes:

mikecard> hello
mikecard> is it possible to give an array an interpolated name?

Not all things possible are wise.  This being one of them.

mikecard> i have looked in the books and in this ng and tried many different
mikecard> things one of them being @$array_name (which i knew wouldnt work because
mikecard> it was just too ugly).

Did you try that?  Without "use strict" on (which you SHOULD be using),
it does do what you think it does!

mikecard> is this possible or am i just dreaming.

You're hallucinating if you want to do something that way.  Symbolic
References are meant to be used only behind the scenes.
Most likely what you want is a hash of array refs, then you can use:

	@{$data{$array_name}}

where you would have used your @$array_name, and

	$data{$array_name}[$n]

to access element $n of that array.  This puts everyting into %data
(good) rather than Perl's symbol table (bad).

print "Just another Perl hacker,"

-- 
Name: Randal L. Schwartz / Stonehenge Consulting Services (503)777-0095
Keywords: Perl training, UNIX[tm] consulting, video production, skiing, flying
Email: <merlyn@stonehenge.com> Snail: (Call) PGP-Key: (finger merlyn@teleport.com)
Web: <A HREF="http://www.stonehenge.com/merlyn/">My Home Page!</A>
Quote: "I'm telling you, if I could have five lines in my .sig, I would!" -- me


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

Date: 8 Jun 1999 14:55:15 GMT
From: gbacon@itsc.uah.edu (Greg Bacon)
Subject: Re: can i variably name an array?
Message-Id: <7jjasj$qdv$1@info2.uah.edu>

In article <7jj4r4$kbs$1@nnrp1.deja.com>,
	mikecard@my-deja.com writes:
: is it possible to give an array an interpolated name?

<URL:http://www.deja.com/getdoc.xp?AN=484280423&fmt=text>

Greg
-- 
Bluto: My advice to you is to start drinking heavily.
Otter: Better listen to him, Flounder. He's pre-med.


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

Date: 8 Jun 1999 09:03:05 -0700
From: Tom Christiansen <tchrist@mox.perl.com>
Subject: Re: can i variably name an array?
Message-Id: <375d30a9@cs.colorado.edu>

     [courtesy cc of this posting mailed to cited author]

In comp.lang.perl.misc, 
    mikecard@my-deja.com writes:
:is it possible to give an array an interpolated name?
:suppose i have
:		$array_name = "mikes_array";
:now i want to use the scalar $array_name to create an array
:@mikes_array.

Don't do that.

--tom

=head2 How can I use a variable as a variable name?

Beginners often think they want to have a variable contain the name
of a variable.

    $fred    = 23;
    $varname = "fred";
    ++$$varname;         # $fred now 24

This works I<sometimes>, but it is a very bad idea for two reasons.

The first reason is that they I<only work on global variables>.
That means above that if $fred is a lexical variable created with my(),
that the code won't work at all: you'll accidentally access the global
and skip right over the private lexical altogether.  Global variables
are bad because they can easily collide accidentally and in general make
for non-scalable and confusing code.

Symbolic references are forbidden under the C<use strict> pragma.
They are not true references and consequently are not reference counted
or garbage collected.

The other reason why using a variable to hold the name of another
variable a bad idea is that the question often stems from a lack of
understanding of Perl data structures, particularly hashes.  By using
symbolic references, you are just using the package's symbol-table hash
(like C<%main::>) instead of a user-defined hash.  The solution is to
use your own hash or a real reference instead.

    $fred    = 23;
    $varname = "fred";
    $USER_VARS{$varname}++;  # not $$varname++

There we're using the %USER_VARS hash instead of symbolic references.
Sometimes this comes up in reading strings from the user with variable
references and wanting to expand them to the values of your perl
program's variables.  This is also a bad idea because it conflates the
program-addressable namespace and the user-addressable one.  Instead of
reading a string and expanding it to the actual contents of your program's
own variables:

    $str = 'this has a $fred and $barney in it';
    $str =~ s/(\$\w+)/$1/eeg;		  # need double eval

Instead, it would be better to keep a hash around like %USER_VARS and have
variable references actually refer to entries in that hash:

    $str =~ s/\$(\w+)/$USER_VARS{$1}/g;   # no /e here at all

That's faster, cleaner, and safer than the previous approach.  Of course,
you don't need to use a dollar sign.  You could use your own scheme to
make it less confusing, like bracketed percent symbols, etc.

    $str = 'this has a %fred% and %barney% in it';
    $str =~ s/%(\w+)%/$USER_VARS{$1}/g;   # no /e here at all

Another reason that folks sometimes think they want a variable to contain
the name of a variable is because they don't know how to build proper
data structures using hashes.  For example, let's say they wanted two
hashes in their program: %fred and %barney, and to use another scalar
variable to refer to those by name.

    $name = "fred";
    $$name{WIFE} = "wilma";     # set %fred

    $name = "barney";           
    $$name{WIFE} = "betty";	# set %barney

This is still a symbolic reference, and is still saddled with the
problems enumerated above.  It would be far better to write:

    $folks{"fred"}{WIFE}   = "wilma";
    $folks{"barney"}{WIFE} = "betty";

And just use a multilevel hash to start with.

The only times that you absolutely I<must> use symbolic references are
when you really must refer to the symbol table.  This may be because it's
something that can't take a real reference to, such as a format name.
Doing so may also be important for method calls, since these always go
through the symbol table for resolution.

In those cases, you would turn off C<strict 'refs'> temporarily so you
can play around with the symbol table.  For example:

    @colors = qw(red blue green yellow orange purple violet);
    for my $name (@colors) {
        no strict 'refs';  # renege for the block
        *$name = sub { "<FONT COLOR='$name'>@_</FONT>" };
    } 

All those functions (red(), blue(), green(), etc.) appear to be separate,
but the real code in the closure actually was compiled only once.

So, sometimes you might want to use symbolic references to directly
manipulate the symbol table.  This doesn't matter for formats, handles, and
subroutines, because they are always global -- you can't use my() on them.
But for scalars, arrays, and hashes -- and usually for subroutines --
you probably want to use hard references only.
-- 
    Let's say the docs present a simplified view of reality...    :-)
            --Larry Wall in  <6940@jpl-devvax.JPL.NASA.GOV>


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

Date: Tue, 8 Jun 1999 06:02:02 -0400
From: tadmc@metronet.com (Tad McClellan)
Subject: Re: can i variably name an array?
Message-Id: <qmpij7.ecp.ln@magna.metronet.com>

mikecard@my-deja.com wrote:

: is it possible to give an array an interpolated name?


   Yes.

   But you do not want to.

   See the "Symbolic references" section in perlref.pod


: suppose i have

: 		$array_name = "mikes_array";

: now i want to 


   No you don't.


: use the scalar $array_name to create an array
: @mikes_array.

: i have looked in the books and in this ng and tried many different
: things one of them being @$array_name (which i knew wouldnt work because
: it was just too ugly).

: is this possible or am i just dreaming.


  It is both possible, and a Very Bad Idea.

      http://www.plover.com/~mjd/perl/varvarname.html


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


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

Date: Tue, 8 Jun 1999 07:35:06 -0700
From: lr@hpl.hp.com (Larry Rosler)
Subject: Re: can i variably name an array?
Message-Id: <MPG.11c6c9ead8d9574f989b90@nntp.hpl.hp.com>

In article <7jj63v$krk$1@nnrp1.deja.com> on Tue, 08 Jun 1999 13:33:52 
GMT, philc@hempseed.com <philc@hempseed.com> says...
> In article <7jj4r4$kbs$1@nnrp1.deja.com>,
>   mikecard@my-deja.com wrote:
> > is it possible to give an array an interpolated name?
> 
> Yes!
> 
> $array = "mikes_array";
> $$array[0] = "cool";
> print $mikes_array[0];
> 
> Isn't perl just the coolest!

This is not cool at all.  Using a variable as a symbol is called 
Symbolic References, which comes up at least once a day here and is 
blown away.

This is cool:

my %data;
my $array = 'mikes_array';
$data{$array} = [ 'cool' ];
print $data{'mikes_array'}[0];

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


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

Date: Tue, 08 Jun 1999 09:20:00 -0600
From: Arne Jamtgaard <arnej@fc.hp.com>
Subject: Re: can i variably name an array?
Message-Id: <375D34A0.2700@fc.hp.com>

mikecard@my-deja.com wrote:

> hello

> is it possible to give an array an interpolated name?

> suppose i have

>                 $array_name = "mikes_array";

> now i want to use the scalar $array_name to create an array
> @mikes_array.

> i have looked in the books and in this ng and tried many different
> things one of them being @$array_name (which i knew wouldnt work
> because it was just too ugly).

> is this possible or am i just dreaming.

Ugly it may be, but it should have worked for you when you tried it.
It worked for me...

Arne

------------------------------------------
$arrayname = "mike";

@$arrayname = (1,1,2,3,5,8,13,21,34,55);

foreach $item(@mike) {
    print "Item: $item\n";
    }
------------------------------------------
Output:

Item: 1
Item: 1
Item: 2
Item: 3
Item: 5
Item: 8
Item: 13
Item: 21
Item: 34
Item: 55
------------------------------------------

Now, why you'd want to do this is still up inthe air, but it can be
done...


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

Date: Tue, 08 Jun 1999 14:55:52 GMT
From: Don Roby <droby@copyright.com>
Subject: Re: can i variably name an array?
Message-Id: <7jjatj$mtd$1@nnrp1.deja.com>

In article <7jj63v$krk$1@nnrp1.deja.com>,
  philc@hempseed.com wrote:
> In article <7jj4r4$kbs$1@nnrp1.deja.com>,
>   mikecard@my-deja.com wrote:
> > hello
> >
> > is it possible to give an array an interpolated name?
>
> Yes!
>
> $array = "mikes_array";
> $$array[0] = "cool";
> print $mikes_array[0];
>
> Isn't perl just the coolest!
>

This works, and perl is indeed the coolest.

But you should try not to use this feature unless you REALLY need it,
and then use it very carefully.  See perlfaq7 under the heading  "How
can I use a variable as a variable name?" for further info on this
stuff, and look at http://www.plover.com/~mjd/perl/varvarname.html for
a great explanation of what can go wrong.

--
Don Roby


Sent via Deja.com http://www.deja.com/
Share what you know. Learn what you don't.


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

Date: Sun, 06 Jun 1999 15:24:19 +0100
From: Edouard Ouin <Edouard.Ouin@tinet.ie>
Subject: CGI saving file dialog box
Message-Id: <375A8493.89A8A903@tinet.ie>

hi,

In a web browser, is it possible in CGI to open the FileSaving default
dialog box, to allow people to choose the name and the directory of the
file they want to save.

thank's for your time.

-- 
---------------------------------------------------------
Edouard Ouin
Telecom Internet                    Tel: (353) 1 701 0182
Unit B, East Point Business Park    Fax: (353) 1 701 1086
Fairview                            http://www.tinet.ie
Dublin 3                            Edouard.Ouin@tinet.ie
Ireland                             Mobile : 087 289 0934


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

Date: Tue, 8 Jun 1999 12:13:13 +0100
From: James Stewart <james@britlinks.co.uk>
Subject: Re: Choosing a time module and working with it
Message-Id: <ant0811130b0Lh==@ch0128.charis.co.uk>

Larry Rosler <URL:mailto:lr@hpl.hp.com> wrote:
> James Stewart <james@britlinks.co.uk> says...
> > Also, how is it best to go through the array deleting these entries?
> > I thought about some sort of loop, but if the numbering of the array
> > changed because I'd deleted an element, wouldn't that mess this up?
> 
> Yes, it would (unless you did it back-to-front).  That's what the 'grep' 
> function is used for.  `perldoc -f grep`
> 
> my $when = '19990601';
> 
> my @new = grep $_->[0] =~ m%(\d\d)/(\d\d)/(\d{4})% &&
>                  "$3$2$1" ge $when, @array;

I need $when to contain the date on which the script is run. I used the
following code ... is there a better way of getting the four digit year
than simply tagging on "19"?

(,,,$mday,$mon,$year,,,)=localtime(time);
$year = "19".$year ;
my $today = $year.$mon.$mday;

The array @final includes the following entries:

@final[0][0] 04/06/1999
@final[1][0] 08/06/1999
@final[2][0] 16/06/1999

and running it yesterday (08/06/1999) I said:

my @new = grep $_->[0] =~ m%(\d\d)/(\d\d)/(\d{4})% && "$3$2$1" ge $today, @final;

the result seemed to be that the entire array was deleted.

James.
-- 
James Stewart     - james@britlinks.co.uk      | "Telecom ignored us and 
The Britlinks     - http://www.britlinks.co.uk | democracy has died."
Phantom Tollbooth - http://www.tollbooth.org   |       -- Fat And Frantic

Sixpence None The Richer in the UK - http://www.britlinks.co.uk/sixpence/



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

Date: Tue, 08 Jun 1999 17:27:00 +0200
From: Martin Insulander <main@isk.kth.se>
Subject: Converting UTF-8 to ISO-8859-1
Message-Id: <375D3644.C2A2B315@isk.kth.se>

Hi all,

I've been fiddling around with the XML::Parser module a bit,
and I have a slight problem. The module converts the parsed
data to UTF-8 (Unicode) format, and I need to convert it back
to ISO-8859-1 (which the original document is).

Anyone know of a couple of lines that do this?

I read something about a "utf8" module that would do this, but
when "use utf8" didn't work, so I guess my perl interpreter is
too old. Upgrading is not an option, since I'm not the sysadmin
here..

Any help appreciated. Please reply by mail.
/ Martin

-- 
Martin Insulander - Webmaster @ KTH IS Kista
main@isk.kth.se	  http://www.isk.kth.se/~main	+46-8-7521920


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

Date: Tue, 8 Jun 1999 04:52:40 -0400
From: tadmc@metronet.com (Tad McClellan)
Subject: Re: Creating an external config file. How ?
Message-Id: <oklij7.u5p.ln@magna.metronet.com>

Greg Savage (greg@paradox.net.au) wrote:
: I am looking for
: an efficient routine to read in the following pairs, ignoring # comments
: and assign them to variables.


: I guess a hash would be a good start but am unsure to the structure.


---------------------------
#!/usr/bin/perl -w
use strict;

my %vars;

while (<DATA>) {
   chomp;
   next if /^#/;

   my($name, $value) = split / /, $_, 2;
   $vars{$name} = $value;
}

foreach (sort keys %vars) {
   print "$_ ==> $vars{$_}\n";
}

__DATA__
# This is a comment
logdir /var/log
logfile local0
warning 2
limit 5
admin admin@domain.com
---------------------------


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


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

Date: Tue, 8 Jun 1999 07:16:05 -0700
From: lr@hpl.hp.com (Larry Rosler)
Subject: Re: Creating an external config file. How ?
Message-Id: <MPG.11c6c57b7e6bc33e989b8d@nntp.hpl.hp.com>

[Posted and a courtesy copy sent.]

In article <01beb1ac$7eda9ca0$f34f39cb@stingray> on 8 Jun 1999 20:46:06 
-0800, Greg Savage <greg@paradox.net.au> says...
> I have compilled my perl script and now need to store my configuration
> options in an external text file for ease of modification. I am looking for
> an efficient routine to read in the following pairs, ignoring # comments
> and assign them to variables.

<SNIP> data reproduced below

> I guess a hash would be a good start but am unsure to the structure.

You are so right!

#!/usr/local/bin/perl -w
use strict;

my %hash;

while (<DATA>) {
    next if /^#/;
    next unless /(\S+)\s+(.+)/;
    $hash{$1} = $2;
}

# Replacing the above readable code by a one-liner, for fun:
# /^([^#\s]\S*)\s+(.+)/ and $hash{$1} = $2 while <DATA>;

print map "$_: $hash{$_}\n" => sort keys %hash;
__END__
# This is a comment
logdir /var/log
logfile local0
warning 2
limit 5
admin admin@domain.com

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


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

Date: Tue, 8 Jun 1999 16:44:18 +0200
From: "Ysteric's" <eyounes@aol.com>
Subject: Re: DBD::ODBC
Message-Id: <7jj9oo$dl5@news.vtcom.fr>

I've tried with the DBD::XBase ... same result.

Eric







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

Date: Tue, 08 Jun 1999 10:42:26 -0700
From: Piyush Jain <pjain@usol.com>
Subject: Extract file name from path
Message-Id: <375D5601.67D5F8AF@usol.com>

Hello everyone,

I have a situation where the path could either be from the UNIX or
Windows machine of the form C:\dir1\dir2\dir3\file1.html

I need to be able to read the file name file1.html into a variable. I am
new to perl so any help or suggestions would be appreciated.

Thanks,

piyush


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

Date: 8 Jun 1999 15:08:54 GMT
From: gbacon@itsc.uah.edu (Greg Bacon)
Subject: Re: Extract file name from path
Message-Id: <7jjbm6$qdv$3@info2.uah.edu>

In article <375D5601.67D5F8AF@usol.com>,
	Piyush Jain <pjain@usol.com> writes:
: I have a situation where the path could either be from the UNIX or
: Windows machine of the form C:\dir1\dir2\dir3\file1.html
: 
: I need to be able to read the file name file1.html into a variable. I am
: new to perl so any help or suggestions would be appreciated.

Have a look at the File::Basename module.

Greg
-- 
Arrogance is bliss.
    -- Elizabeth L. Kaminsky


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

Date: Tue, 8 Jun 1999 11:11:20 -0400
From: "Dmitry P." <dpodbori@email.msn.com>
Subject: Re: Extract file name from path
Message-Id: <#UvHJCcs#GA.283@cpmsnbbsa03>

You will enjoy the File::Basename module (a part of standard Perl library,
thorougly covered in the perl documentation and in The Camel Book)

Here is the code snippet from the Perl Module documentation:

    use File::Basename;

    ($name,$path,$suffix) = fileparse($fullname,@suffixlist)
    fileparse_set_fstype($os_string);
    $basename = basename($fullname,@suffixlist);
    $dirname = dirname($fullname);

    ($name,$path,$suffix) = fileparse("lib/File/Basename.pm","\.pm");
    fileparse_set_fstype("VMS");
    $basename = basename("lib/File/Basename.pm",".pm");
    $dirname = dirname("lib/File/Basename.pm");


Piyush Jain <pjain@usol.com> wrote in message
news:375D5601.67D5F8AF@usol.com...
> Hello everyone,
>
> I have a situation where the path could either be from the UNIX or
> Windows machine of the form C:\dir1\dir2\dir3\file1.html
>
> I need to be able to read the file name file1.html into a variable. I am
> new to perl so any help or suggestions would be appreciated.
>
> Thanks,
>
> piyush




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

Date: Tue, 08 Jun 1999 13:54:17 GMT
From: Don Roby <droby@copyright.com>
Subject: Re: Get Date in Perl
Message-Id: <7jj7a4$l9v$1@nnrp1.deja.com>

In article <x7ogir73vh.fsf@home.sysarch.com>,
  Uri Guttman <uri@sysarch.com> wrote:
>
>   ot> Share what you know. Learn what you don't.
>
> what a crock. when's the last time we have seen a good answer from a
> deja posting. (stowe in london being excepted. why are you using
deja?)
>

Well, I THINK I posted one reasonable answer yesterday...

And I'm neither stowe nor in london.  ;-)

I use deja for lack of a real newsfeed.  Sometime soon, I'll probably
get things set up so I don't have to use it anymore, and then I'll stop.
It's bad, but it's sufficient for my current level of activity.

> uri, the happy whinger!
>

Whinge on!

--
Don Roby


Sent via Deja.com http://www.deja.com/
Share what you know. Learn what you don't.


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

Date: Tue, 8 Jun 1999 08:47:57 -0700
From: Tom Phoenix <rootbeer@redcat.com>
Subject: Re: getting perl output(HTML code) from a remote host.
Message-Id: <Pine.GSO.4.02A.9906080847050.26349-100000@user2.teleport.com>

On Tue, 8 Jun 1999 perl_beginner@my-deja.com wrote:

>      Is there anyway I can get the output of perl from a remote host
> and put it in a localhost without using SSI?

It sounds as if you want to make a program which accesses a remote web
server. Use the LWP package for that. Good luck!

-- 
Tom Phoenix       Perl Training and Hacking       Esperanto
Randal Schwartz Case:     http://www.rahul.net/jeffrey/ovs/



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

Date: Tue, 8 Jun 1999 06:38:44 -0700
From: lr@hpl.hp.com (Larry Rosler)
Subject: Re: how can i do this?
Message-Id: <MPG.11c6bcbcff75bf57989b8b@nntp.hpl.hp.com>

[Posted and a courtesy copy sent.]

In article <7jiioq$f52$1@nnrp1.deja.com> on Tue, 08 Jun 1999 08:03:42 
GMT, smnayeem@my-deja.com <smnayeem@my-deja.com> says...
> I cant work out how to access each element of an array of array using
> two for loops.
> heres my code :
> 1 my $header = [[a,b,c],[d,e,f],[g,h,i],[j,k,l]];

Those letters are barewords that make the compiler (and me) groan.

> 2    	for ($i = 0;$i <= $#$header; $i++) {
> 3      	  for ($j = 0;$j <= $#[$header->[$i]];$j++) {
                                  ^             ^
                                  {             }

Curly brackets indicate dereferencing.  Square brackets indicate ref to 
anonymous array.

> 4	    print ($header->[$i][$j],"\t");
> 5      	  }
> 6      	  print "\n";
> 7    	}
>  (please remove the line numbers)

Good.  The formatting stinks in any case.  :-)

> so as it looks, the problem is in line 3 where i used $#[$header->[$i]]
> for getting the count of the array. I also tried $#$header->[$i] but
> that doesnt work either, can someone shed some lights here pls.

You were right about where the error lay.
It should be $#{$header->[$i]}

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


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

Date: Tue, 08 Jun 1999 16:27:25 +0200
From: distler <thomas.distler@icn.siemens.de>
Subject: Re: How to use <!--exec to pass arguments in cgi ?
Message-Id: <375D284C.AC2F4781@icn.siemens.de>

Just another note:
To use the my example,  your html page has to be generated by the perl
script.

Your example doesn' work because calling as http xxx?asdf uses the get
method. With exec it works different and so you have to redesign your perl
script.



smgpage@hotmail.com wrote:

> Dear Expert !
>     I head is broken into two now after testing the whole nite and I
> need your help now !How to pass arguments in the TAG
>    <!-- exec cgi="/cgi-bin/action.pl --> ???
>
>     I can run http://www.mysite.com/cgi-bin/action.pl?45665 by typing in
> the location of netscape but when I embeded the TAG  (<!...>)in HTML it
> says eror eror and nothing more but eror ! Please Tell me how to pass
> arguments with the above tag !
>
> *45665 is my argument which is a filename. I want to opne that file for
> some data and display it in my HTML page. It is just like counter. But
> because I need to use lots of data files in one page I need to tell th
> cgi which file to use.
>
> Kindly email you help to me at smgpage@hotmail.com !
>
> THANKS IN ADVANCE !
>
> James Yap
>
> Sent via Deja.com http://www.deja.com/
> Share what you know. Learn what you don't.



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

Date: Tue, 8 Jun 1999 15:21:09 +0200
From: "Fred Ruffet" <fruffet@kaptech.com>
Subject: Re: How write a perl program that connects to a remote Oracle database server without configuring any connections? NT
Message-Id: <7jj5cg$utn$1@gatekeeper.ornano.kapt.com>

>No text!
with DBI (which is not much text at all :-)





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

Date: Tue, 08 Jun 1999 17:17:35 +0200
From: Dominik Leinfelder <dominikl@pyramid.de>
Subject: Re: How write a perl program that connects to a remote Oracle database server without configuring any connections? NT
Message-Id: <375D340F.E76C7600@pyramid.de>

Lim Chong Sun schrieb:

> No text!

No way!

I think _minimum_ requirements you'll need is a tnsnames.ora file, where
your server and the DB you want to access is defined. It's included in
some kind of client, which garants you access to the DBserver...
Further I dont't think, simply downloading oraperl or DBD:ORACLE stuff
will help much w/o client...

If I'm wrong or someone has other experience - pls pls pls tell me (us)
! ;)

greetinx
Dominik Leinfelder



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

Date: Tue, 8 Jun 1999 16:30:56 +0200
From: "Mark Stellaard" <mark.stellaard@knoware.nl>
Subject: if loop ?
Message-Id: <7jj9a5$pka$1@tasmania.dev.ict.nl>

hello people out there,

I have a problem using ActivePerl v5.004,
when I use a simple piece of code like e.g.

if ($tmp_arg eq "-a"){
    push (@array, $foo);
    push (@array1, $bar);
}

it only executes the first push statement? after the if loop.
Why doesn't the second push statement work?
can anybody please tell me?

greets Mark NJAPH not yet another Perl hacker :-(







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

Date: 8 Jun 1999 15:11:12 GMT
From: gbacon@itsc.uah.edu (Greg Bacon)
Subject: Re: know Perl to maintain Perl (was: Re: I pass an array...)
Message-Id: <7jjbqg$qdv$4@info2.uah.edu>

In article <1dt1ux5.1flobui1gvmskxN@p67.block2.tc1.state.ma.tiac.com>,
	rjk@linguist.dartmouth.edu (Ronald J Kimball) writes:
: Hey, I've got my fallacies, and you've got yours:

Tu quoque.

Greg
-- 
In a literary light, if UNIX is the Great Novel, Perl is the Cliffs Notes.
    -- Thomas Scoville


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

Date: Tue, 8 Jun 1999 08:32:16 -0700
From: Tom Phoenix <rootbeer@redcat.com>
Subject: Re: NT perl question(probably simple)
Message-Id: <Pine.GSO.4.02A.9906080831340.26349-100000@user2.teleport.com>

On Mon, 7 Jun 1999, Bob Perini wrote:

> This is being called by another function and it doesn't seem to print
> out the $error variable.

See whether you can make a small (five or ten lines) self-contained
program which shows the trouble you're having. Thanks!

-- 
Tom Phoenix       Perl Training and Hacking       Esperanto
Randal Schwartz Case:     http://www.rahul.net/jeffrey/ovs/



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

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


Administrivia:

Well, after 6 months, here's the answer to the quiz: what do we do about
comp.lang.perl.moderated. Answer: nothing. 

]From: Russ Allbery <rra@stanford.edu>
]Date: 21 Sep 1998 19:53:43 -0700
]Subject: comp.lang.perl.moderated available via e-mail
]
]It is possible to subscribe to comp.lang.perl.moderated as a mailing list.
]To do so, send mail to majordomo@eyrie.org with "subscribe clpm" in the
]body.  Majordomo will then send you instructions on how to confirm your
]subscription.  This is provided as a general service for those people who
]cannot receive the newsgroup for whatever reason or who just prefer to
]receive messages via e-mail.

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

	subscribe perl-users
or:
	unsubscribe perl-users

to almanac@ruby.oce.orst.edu.  

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

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

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

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

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

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


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

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