[19909] in Perl-Users-Digest

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

Perl-Users Digest, Issue: 2104 Volume: 10

daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Fri Nov 9 18:06:03 2001

Date: Fri, 9 Nov 2001 15:05:15 -0800 (PST)
From: Perl-Users Digest <Perl-Users-Request@ruby.OCE.ORST.EDU>
To: Perl-Users@ruby.OCE.ORST.EDU (Perl-Users Digest)
Message-Id: <1005347114-v10-i2104@ruby.oce.orst.edu>
Content-Type: text

Perl-Users Digest           Fri, 9 Nov 2001     Volume: 10 Number: 2104

Today's topics:
    Re: 600 lines <no@email.com>
    Re: Anyone here know how to build HTML docs from Perl s jks@saba.bass
    Re: apply chmod() to a symlink <wwonko@rdwarf.com>
    Re: Best language for low IQ programmers? <nofreejack@NOSPAMMINGsoldierx.zzn.com>
    Re: Best language for low IQ programmers? <nofreejack@NOSPAMMINGsoldierx.zzn.com>
    Re: converting ^M characters to \n (Drew Myers)
    Re: converting ^M characters to \n (Tad McClellan)
    Re: converting ^M characters to \n <flavell@mail.cern.ch>
        date/time question: weekofyear, see my code <no_mto@hotmail.com>
    Re: date/time question: weekofyear, see my code (Tad McClellan)
    Re: date/time question: weekofyear, see my code (John J. Trammell)
    Re: date/time question: weekofyear, see my code <mbudash@sonic.net>
    Re: dhcp client broadcasting to 255.255.255.255 nobull@mail.com
    Re: Direct iteration over aoh <goldbb2@earthlink.net>
    Re: Help needed!! (bhattey)
        help with hashref <jens@irs-net.com>
    Re: how to read stdin in a while... (Tad McClellan)
    Re: how to read stdin in a while... (trwww)
    Re: I am having a problem with my perl script.  <jessica.bull@broadwing.com>
    Re: I am having a problem with my perl script. (Drew Myers)
    Re: I am having a problem with my perl script. <wwonko@rdwarf.com>
    Re: Impossible problem to crack? nobull@mail.com
        Digest Administrivia (Last modified: 6 Apr 01) (Perl-Users-Digest Admin)

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

Date: Fri, 9 Nov 2001 22:12:01 -0000
From: "Brian Wakem" <no@email.com>
Subject: Re: 600 lines
Message-Id: <UwYG7.4396$qf.851421@news2-win.server.ntlworld.com>


"Armin Bauer" <agp-soft@t-online.de> wrote in message
news:9sgd5f$h8a$07$1@news.t-online.com...
> Hi!
>
> I'm asking for a friend, who's doing Perl programming.
>
> He has a problem. When his script becomes longer than 600 lines of code,
the
> perl interpreter tells him, that there's a syntax error. he tried to put
> this code into a xyz.sub - file and require it but perl said, it was
unable
> to find the file...
>
> Is it possible that this is a limitation of perl?
>
> Armin Bauer


No.  The longest script I have written is 4858 lines long, and it works.

--
Brian




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

Date: Fri, 09 Nov 2001 20:40:41 GMT
From: jks@saba.bass
Subject: Re: Anyone here know how to build HTML docs from Perl src dist?
Message-Id: <m38zdf7k6s.fsf@saba.bass>

>>>>> "Rafael" == Rafael Garcia-Suarez <rgarciasuarez@free.fr> writes:

    Rafael> jks@saba.bass wrote in comp.lang.perl.misc:
    >> Is there anyone on this mailing list who knows a script to
    >> generate ALL of the Perl documentation in HTML format from the
    >> source distribution of Perl 5.6.1?

    Rafael> Perl comes with a tool, pod2html, that converts, as its
    Rafael> name suggests, pod to html.

    Rafael> But if you're building perl from source, look at the
    Rafael> installhtml utility and at its references in the INSTALL
    Rafael> file.

Rafael,

Thanks for responding.

I should have mentioned that I'm already aware of these tools.  They
sound nice on paper.  HTML docs from POD?  No problem, use pod2html
and installhtml.

The reason I posted is because I put in time with installhtml.  I built
tree after tree of Perl HTML docs full of broken links and without
indexes.  I read and reread the references to installhtml in the INSTALL
file before posting here.  I thought, this must be a common problem;
surely someone has a simple script that will build the Perl documentation
tree in HTML from the source distribution, with working links.  Why reinvent
the wheel; surely someone has a script that will save me from having to make
a science fair project out of this basic task.

It seems straightforward; all the tools are there, surely someone has this
all figured out and I'm missing something, right?

I need a repeatable process to build a complete, static directory tree of the
Perl documentation in HTML format from the Perl source distribution, with
working links.

Will anyone who has successfully accomplished this task please share your
procedure?

Thanks,

John


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

Date: Fri, 9 Nov 2001 19:12:29 +0000 (UTC)
From: Louis Erickson <wwonko@rdwarf.com>
Subject: Re: apply chmod() to a symlink
Message-Id: <9sh9qt$jrn$1@holly.rdwarf.com>

Radu Muschevici <grinsefisch@gmx.ch> wrote:
: apparently, if perl's chmod() is applied on a symbolic link, it 
: changes the owner of the file which the link points to.
: but how can I change the owner of the symlink itself??

Well, chmod changes the access permissions for a file, not the owner.
You'd be able to change the owner with chown.  See perldoc -f chown

Most Unix systems don't have any access permissions for the symbolic
link, anyway, so it must change the real file.  Symlinks do, however
have owners, which can be changed independently.

I'm not quite sure which you mean to be changing here, but, if it's
the permissions, you can't change those on a symlink, and if it's
the owner, then you need to use chown().



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

Date: Fri, 9 Nov 2001 22:22:10 -0000
From: "nofreejack" <nofreejack@NOSPAMMINGsoldierx.zzn.com>
Subject: Re: Best language for low IQ programmers?
Message-Id: <9shkub$dr0$1@neptunium.btinternet.com>


"Jeff Connelly" <jconnelly@nc.rr.com> wrote in message
news:WCDF7.52445$Z2.796473@nnrp1.uunet.ca...
> "Brian Metc" <BrianMetc@aol.com> wrote in message
> news:1004990076967295@aol.com...
> > I would like to get into the programing field. My problem is that I have
low
> IQ due to
> > early childhool learning deprivation and TV overdose. Simply said I am
> stuped, I am
> > pretty good amongst my friends, but not solving problems. You know what
I
> > mean. Anyways, I want to go into computor programing because of money
> > issue. I now need to choose languege for programming, simple enough
> > for me.
> >
> > My friend wh does C plus plus recommended that I learn either Visual
Basic
> or Eiffel.
> > My ex girlfriend who is a sys admin who did perl, sugested that I learn
Ada
> because
> > it has "serious type system" which is fool proof.
> >
> > She dis couraged me from using Eiffel because itr was  a language going
out
> of the
> > market, no longer used by any serious corporation, She said the same
thing
> for Ada.
> >
> > Java is simple compared to c plus plus but a scam language, based on
hype.
> >
> > This only leaves visual basic. Especally because it is used under
Windows,
> Microsoft
> > stuff is always easier.
do you smoke the weed the taliban grows? Micro$hite is useless, Im using VB
for the simple fact I ws brought Up on Risc Basic and I figure it uses the
same stone age methodology. Im not saying VB is crap, in fact its rather
nice, but its expensive and can mess ur pc, like it did mine when i first
started...

A tip from me, never try to open a system file with:
Open ("C:\windows\ [some dll]") for output as #1
print #1, "If the program works you will see this writing"
Close #1

But, if you can make a program that can load and crash less than 10 times in
a week, then Bill Gates will be out of a job. I suggest this little code
snippet

Private Sub Form_Load()
Msgbox "So far, so good, doesnt seem to crash...oh wait...windows is
loadin......",vbinformation,"Hmmm"
End
End Sub

> Wow what a troll.
>
>




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

Date: Fri, 9 Nov 2001 22:26:04 -0000
From: "nofreejack" <nofreejack@NOSPAMMINGsoldierx.zzn.com>
Subject: Re: Best language for low IQ programmers?
Message-Id: <9shl6i$2ne$1@plutonium.btinternet.com>


"Brian Metc" <BrianMetc@aol.com> wrote in message
news:1004990076967295@aol.com...
> I would like to get into the programing field. My problem is that I have
low IQ due to
> early childhool learning deprivation and TV overdose. Simply said I am
stuped, I am
> pretty good amongst my friends, but not solving problems. You know what I
> mean. Anyways, I want to go into computor programing because of money
> issue. I now need to choose languege for programming, simple enough
> for me.
>
> My friend wh does C plus plus recommended that I learn either Visual Basic
or Eiffel.
> My ex girlfriend who is a sys admin who did perl, sugested that I learn
Ada because
> it has "serious type system" which is fool proof.
>
> She dis couraged me from using Eiffel because itr was  a language going
out of the
> market, no longer used by any serious corporation, She said the same thing
for Ada.
>
> Java is simple compared to c plus plus but a scam language, based on hype.
>
> This only leaves visual basic. Especally because it is used under Windows,
Microsoft
> stuff is always easier.
>
> Would any one sugest the best language for me.
>
> Brian
>
Hi, I would suggest VB
For me it was really useful. Draw a control, double click it to bring up the
sub for a click event and make it do something sexy. And even better than
that, everything you do is prompted with some sort of drop down or tooltip,
like if you type form1. it gives you a list of all the things you can do, so
if your not sure how to make a window show, it stumped me once upon a
time... you would type form1. (or whatecer the name of the form was!) [drop
down list] [select "Show"]

Simple, they chuck in a load of samples that you can call your own. Trouble
is Biblio doesnt work!

Trust Microsoft to do a mini windoze called biblio :P




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

Date: 9 Nov 2001 11:28:59 -0800
From: bh_ent@hotmail.com (Drew Myers)
Subject: Re: converting ^M characters to \n
Message-Id: <d1b6a249.0111091128.3c69e386@posting.google.com>

tadmc@augustmail.com (Tad McClellan) wrote in message > 
> To strip carriage return characters:
> 
>    $x =~ tr/\r//d;

This is more for my education than the original poster's, but couldn't
one accomplish the same thing by the use of chomp()?

Just curious,
Drew Myers


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

Date: Fri, 09 Nov 2001 20:07:47 GMT
From: tadmc@augustmail.com (Tad McClellan)
Subject: Re: converting ^M characters to \n
Message-Id: <slrn9uoaq5.npo.tadmc@tadmc26.august.net>

Drew Myers <bh_ent@hotmail.com> wrote:
>tadmc@augustmail.com (Tad McClellan) wrote in message > 
>> To strip carriage return characters:
>> 
>>    $x =~ tr/\r//d;
>
>This is more for my education than the original poster's, but couldn't
>one accomplish the same thing by the use of chomp()?


No.


chomp() will remove only a CR at the end of $x, and only if

   $/ = "\r";

the tr/// above removes _all_ CRs regardless of the value in $/


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


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

Date: Fri, 9 Nov 2001 23:02:01 +0100
From: "Alan J. Flavell" <flavell@mail.cern.ch>
Subject: Re: converting ^M characters to \n
Message-Id: <Pine.LNX.4.30.0111092255570.30575-100000@lxplus023.cern.ch>

On Nov 9, Tad McClellan inscribed on the eternal scroll:

> >>    $x =~ tr/\r//d;
>
> the tr/// above removes _all_ CRs regardless of the value in $/

On the Mac, as I understand it, it'll remove all linefeeds, and leave
any CRs alone.  What it'll do on EBCDIC platforms, I leave to a
specialist (I left those in 1994, and have never attempted Perl on an
EBCDIC platform).

If it's \015 you're aiming to remove, wouldn't it be better to say so
directly?

cheers



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

Date: Fri, 9 Nov 2001 22:14:47 +0100
From: "MAGiC MANiAC^mTo" <no_mto@hotmail.com>
Subject: date/time question: weekofyear, see my code
Message-Id: <9shh9f$ugl$1@news.kabelfoon.nl>


This my code at the moment...

sub getdate{

  ($second, $minute, $hour, $day, $month, $year, $dayofweek, $dayofyear,
$isdst) = localtime( time );

  $month = $month + 1;
  $year = reverse $year;
  chop( $year );
  $year = reverse $year;
  $dayofyear++;
  $date = "$month/$day/$year";

}

&getdate;
print "$day/$month/$year - $hour:$minute:$second - $dayofweek -
$dayofyear\n\n";

----

I like to know how I can get or can calculate a $weekofyear
And how to change the return values with leading zerro's in a short code
way...

this is the output of my code:
9/11/01 - 22:10:56 - 5 - 313

but it should be:
09/11/2001 - 22:10:56 - 5 - 313 - 45
^ leader zerro's...                            ^ how can I get the
$weekofyear?






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

Date: Fri, 09 Nov 2001 21:31:57 GMT
From: tadmc@augustmail.com (Tad McClellan)
Subject: Re: date/time question: weekofyear, see my code
Message-Id: <slrn9uog8h.o30.tadmc@tadmc26.august.net>

MAGiC MANiAC^mTo <no_mto@hotmail.com> wrote:
>

>  ($second, $minute, $hour, $day, $month, $year, $dayofweek, $dayofyear,
>$isdst) = localtime( time );


>  $year = reverse $year;
>  chop( $year );
>  $year = reverse $year;


What are all of those contortions for?

Have you read the documentation for the function you are using?

   perldoc -f localtime

   "The proper way to get a complete 4-digit year is simply: ..."
and
   "And to get the last two digits of the year (e.g., '01' in 2001) do: ..."


>And how to change the return values with leading zerro's in a short code
>way...


The documentation for localtime() shows how to do that too.

Use the docs, Luke!


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


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

Date: Fri, 9 Nov 2001 15:45:02 -0600
From: trammell@haqq.hypersloth.invalid (John J. Trammell)
Subject: Re: date/time question: weekofyear, see my code
Message-Id: <slrn9uojkc.n7r.trammell@haqq.el-swifto.com>

On Fri, 9 Nov 2001 22:14:47 +0100, MAGiC MANiAC^mTo <no_mto@hotmail.com> wrote:
> 
> This my code at the moment...
> 
[snip]

use POSIX ('strftime');
print strftime("%d/%m/%y - %H:%M:%S - %u - %j\n", localtime);

How about using the full four-digit year, and putting it first?
Makes more sense, IMO -- YYYYMMDDhhmmss is pretty standard...

-- 
IAAMOAC.


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

Date: Fri, 09 Nov 2001 21:55:50 GMT
From: Michael Budash <mbudash@sonic.net>
Subject: Re: date/time question: weekofyear, see my code
Message-Id: <mbudash-D0EA19.13555609112001@news.sonic.net>

In article <9shh9f$ugl$1@news.kabelfoon.nl>, "MAGiC MANiAC^mTo" 
<no_mto@hotmail.com> wrote:

> This my code at the moment...
> 
> sub getdate{
> 
>   ($second, $minute, $hour, $day, $month, $year, $dayofweek, $dayofyear,
> $isdst) = localtime( time );
 
localtime() would suffice

>   $month = $month + 1;
 
$month++;

>   $year = reverse $year;
>   chop( $year );
>   $year = reverse $year;

huh? why not just

$year = $year % 100;

>   $dayofyear++;
>   $date = "$month/$day/$year";
> 
> }
> 
> &getdate;
> print "$day/$month/$year - $hour:$minute:$second - $dayofweek -
> $dayofyear\n\n";
> 
> ----
> 
> I like to know how I can get or can calculate a $weekofyear
> And how to change the return values with leading zero's in a short code
> way...
> 
> this is the output of my code:
> 9/11/01 - 22:10:56 - 5 - 313
> 
> but it should be:
> 09/11/2001 - 22:10:56 - 5 - 313 - 45
> ^ leader zero's...                            ^ how can I get the
> $weekofyear?
> 

in your subroutine:

$year += 1900;

instead of:

$year = $year % 100;

and, before your $dayofyear++ :

$weekofyear = int($dayofyear/7) + 1;

then, after your &getdate; you can:

printf ("%02d/%02d/%04d - %02d:%02d:%02d - %d - %d - %d\n", $day, 
$month, $year, $hour, $minute, $second, $dayofweek, $dayofyear, 
$weekofyear);

hth-
-- 
Michael Budash ~~~~~~~~~~ mbudash@sonic.net


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

Date: 09 Nov 2001 18:55:24 +0000
From: nobull@mail.com
Subject: Re: dhcp client broadcasting to 255.255.255.255
Message-Id: <u9n11vpyeb.fsf@wcl-l.bham.ac.uk>

jack@brainminers.net (jack) writes:

> I wwrote the following code to broadcasting a message to a DHCP server
> but having trouble getting feedback. Any suggestion would be highly
> appreciated.

I suggest you stop starting a new thread every time you post unless it
is your intent to cause annoyance.

I suggest that you send DHCP packets _from_ local UDP port 68 _to_
remote UDP port 67 and listen for the response on port 68.  This, of
course, has nothing to do with Perl.

I suggest that treating STDIN as a datagram structured stream is
likely not a good idea.

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


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

Date: Fri, 09 Nov 2001 18:04:41 -0500
From: Benjamin Goldberg <goldbb2@earthlink.net>
Subject: Re: Direct iteration over aoh
Message-Id: <3BEC6109.6749C9B@earthlink.net>

Garry Williams wrote:
> 
> On Thu, 08 Nov 2001 19:59:30 -0500, Benjamin Goldberg
> <goldbb2@earthlink.net> wrote:
> 
> > Personally, I would have done the print with your original @array
> > as:
> >
> > print $_, "\n" foreach @array;
> >
> > This is because if you print an undef value, it prints nothing [as
> > you would expect], and it produces no warnings.
> 
> So why does this happen?
> 
>   $ perl -we 'print $_'
>   Use of uninitialized value in print at -e line 1.
>   $ perl -v
> 
>   This is perl, v5.6.1 built for sun4-solaris

Umm, because I foolishly made my statement without testing it?

-- 
Klein bottle for rent - inquire within.


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

Date: 9 Nov 2001 11:27:55 -0800
From: bhattey@hotmail.com (bhattey)
Subject: Re: Help needed!!
Message-Id: <704bbfe6.0111091127.4765c8d5@posting.google.com>

Hi Chris and Jason, 

Thanks for the replies.

Here is the snippet of the code. (pls notice the commented line
halfway though the code)

sub authenticate {
$form_password = $q->param(password);
open (USERFILE, "$user_file") || die "Error opening user file.  $!\n";
$user_matched = 0;
while (<USERFILE>) {
chop($_);
($password, $user, $u_search, $u_add, $u_modify, $u_delete,
@extra_user_fields) = split(/\|/, $_);
if ($q->param(user) eq $user) {
$user_matched = 1;
$username = $user;
$user_add = $u_add;
$user_modify = $u_modify;
$user_search = $u_search;
$user_delete = $u_delete;
if (&auth_encrypt ($form_password, $password) eq $password) {
$cookie = $q->cookie(-NAME=>'user',-VALUE=>"$user",-EXPIRES=>'+3d');
} # End of if passwords match
} # End of if username matches
} # End of While
close (USERFILE);
############## THE LINE BELOW SEEMS TO MAKE THE ERROR ##############
if ($user_matched == 1 && $cookie eq "") {
$footer = "login";
$title = "Login";
$error_message = "Your password did not match your user name!";
&access_problem($error_message);
exit;    }
if ($user_matched == 0) {
$footer = "login";
$title = "Login";
$error_message = "Your user name was not found!";
&access_problem($error_message);
exit;    }
print header(-cookie=>[$cookie]);
$set_cookie = "yes";
$message = "User \"$username\" is now logged in";
$title = "Main Menu"; 
$user = $username;
&print_default($title, $message);
exit;
}


Thanks in advance for any of your suggestions.



news@roaima.freeserve.co.uk wrote in message news:<3bebedd0@news.netserv.net>...
> Jason Kelley <loophole64@home.com> wrote:
> > Let's see your code.
> 
> Not all 500+ lines of it, though. For now, just the subroutine
> encapsulating line 527.
> 
> Chris


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

Date: Fri, 09 Nov 2001 23:14:12 +0100
From: Jens Luedicke <jens@irs-net.com>
Subject: help with hashref
Message-Id: <9shkko$3rp$01$1@news.t-online.com>

hi ...

I'm using the following code to store and create a threaded mail-list
and I ask for comments and suggestions. 

while ($ref = $sth->fetchrow_hashref) {
        # do stuff ... define $mail_nodes->{$ref->{id}};

        if ($ref->{Header} =~ /Message-I[Dd]:\s+\<(.+)\>/i) {
                $mail_nodes->{message_id}{$1} = $mail_nodes->{$ref->{id}};
        }

        # this bugs me, because I need a split later:
        if ($ref->{Header} =~ /In-Reply-To:\s+\<(.+)\>/i) {
                $mail_nodes->{in_reply_to}{"$ref->{id}::" . $1} = 
$mail_nodes->{$ref->{id}};
        }

        if ($ref->{New} eq 1) {
                $mail_nodes->{is_new}{$ref->{id}} = $mail_nodes->{$ref->{id}};
        }
}

while (my ($key,$value) = each (%{$mail_nodes->{is_new}})) {
        # do stuff ...
}       

while (my ($key,$value) = each (%{$mail_nodes->{in_reply_to}})) {
        my ($id,$target) = split /::/, $key;
        # do stuff ... move node to new parent
}

-- 
Jens Luedicke
jens@irs-net.com


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

Date: Fri, 09 Nov 2001 20:07:48 GMT
From: tadmc@augustmail.com (Tad McClellan)
Subject: Re: how to read stdin in a while...
Message-Id: <slrn9uob7j.npo.tadmc@tadmc26.august.net>

Ron Hartikka <ronh@iainc.com> wrote:

><> is short for <STDIN>


No it isn't.

<STDIN> _always_ reads from STDIN.

<> _sometimes_ reads from STDIN.

If you do not know how the program was invoked, then you do
not know where <> will read from (unless you peek at @ARGV).


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


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

Date: 9 Nov 2001 14:28:36 -0800
From: toddrw69@excite.com (trwww)
Subject: Re: how to read stdin in a while...
Message-Id: <d81ecffa.0111091428.18a59dbd@posting.google.com>

"Ron Hartikka" <ronh@iainc.com> wrote in message news:<EmVG7.976$oM5.80070@typhoon.mw.mediaone.net>...
>
> <> is short for <STDIN>

actually, <> is short for:

unshift(@ARGV, '-') unless @ARGV;
while ($ARGV = shift) {
  open(ARGV, $ARGV);
  while (<ARGV>) {
    ...          # code for each line
  }
}

http://www.perldoc.com/perl5.6.1/pod/perlop.html#I-O-Operators


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

Date: Fri, 09 Nov 2001 20:46:09 GMT
From: "Jessica Bull" <jessica.bull@broadwing.com>
Subject: Re: I am having a problem with my perl script. 
Message-Id: <lgXG7.118425$tb2.9341721@bin2.nnrp.aus1.giganews.com>

I  would suggest using FILE::COPY.  It is multi-platform and is better than
going out to the system to do commands.  Also, you should perform a check
for errors.



"The Williamsons" <daffyduk@prodigy.net> wrote in message
news:MUSG7.498$gW3.96316521@newssvr15.news.prodigy.com...
> I am having a problem with my perl script.
>
> I am trying to mv info from one location to another and the script says
its
> done but the info is not there?
>
> This is the part of the script that is messed up:
>
> system("mv" .$file . "/directory/new" .$file);
>
>
>




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

Date: 9 Nov 2001 11:35:55 -0800
From: bh_ent@hotmail.com (Drew Myers)
Subject: Re: I am having a problem with my perl script.
Message-Id: <d1b6a249.0111091135.3e78907c@posting.google.com>

"The Williamsons" <daffyduk@prodigy.net> wrote in message news:<MUSG7.498$gW3.96316521@newssvr15.news.prodigy.com>...


system("mv" .$file . "/directory/new" .$file);

Get rid of the dots.

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

my $file=".test";
system("mv $file /tmp/$file");

Drew Myers


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

Date: Fri, 9 Nov 2001 19:01:23 +0000 (UTC)
From: Louis Erickson <wwonko@rdwarf.com>
Subject: Re: I am having a problem with my perl script.
Message-Id: <9sh963$jgp$1@holly.rdwarf.com>

Anno Siegel <anno4000@lublin.zrz.tu-berlin.de> wrote:
: According to The Williamsons <daffyduk@prodigy.net>:
:> I am having a problem with my perl script.
:> 
:> I am trying to mv info from one location to another and the script says its
:> done but the info is not there?
:> 
:> This is the part of the script that is messed up:
:> 
:> system("mv" .$file . "/directory/new" .$file);

: You should check the return value of the system() call to see if the
: command succeeded.  See "perldoc -f system" on how to do that. Also, if
: you have doubts about an exterior command, it is always a good idea to
: print the command instead of executing it to see if it's sane.  Do

:     print("mv" .$file . "/directory/new" .$file);
:     print "\n";

: and see what that shows you.

: You should also consider using Perl's internal rename() function instead
: of the external mv.  If you don't move across file system boundaries,
: it does the same thing.

This is all good advice, particularly printing out the command you are
trying to run via system.  It can also keep you from running a command
line that dosen't do what you want.

Looking at the perl in question, it looks pretty impossible to me.

Presuimg $file contains the name of the file, like "text.txt", the
string generated will be: mvtext.txt/directory/newtext.txt

That's probably what you meant.

I'd rewrite the line using interpolation, so it's clearer:

my $cmdline = "mv $file /directory/new/$file";
print "Running: '$cmdline'\n";
system($cmdline);

Notice that I've put single quotes around the $cmdline variable in my
print statement.  They don't do anything for Perl, but they show me if
there's blank space or other junk before or after the string.

Hope that helps some.


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

Date: 09 Nov 2001 19:13:31 +0000
From: nobull@mail.com
Subject: Re: Impossible problem to crack?
Message-Id: <u9k7wzpxk4.fsf@wcl-l.bham.ac.uk>

remy.sharp@gallio.com (Remy Sharp) writes:

> Subject: Impossible problem to crack?

Please use the subject line of your post to tell us about the subject
of your post.

> I have a large collection of shared modules, one in particular that
> contains all of web site configuration values (particular to each
> site).

That doesn't really make sense.
 
> #!/usr/local/bin/perl -w

Why you you have a shebang line in a module?

> However, when I create two test.cgi files in different directories and
> hence, web sites, and I do:
> 
> use Shared::ServerConfig;
> 
> The $serverroot variable has not been initialised in both cases. 
> Although in some other non-related places this they variables have the
> correct values.
> 
> I'm sure this has something to do with the fact I am expecting the
> module to execute when it is being loaded into the perl process, but
> using mod_perl and having a start up script, I suspect that this is
> preloaded in memory, and is overlooked.

_Pre_-loading is not necessarily the issue.  Perl modules are loaded
the first time the compiler/interpreter encounters a use() for that
module.  The whole point of mod_perl is that a single instance of the
compiler/interpreter can service multiple requests.

> This is very frustrating and I would be grateful for any imaginative
> ideas.

The unimaginative solution is simply to have your module expoer a
function that recaluculated the varaibles based on the _current_
configuration and have your script call that.

The imaginative solution is to write a module with a custom import
method so that the same module can export different values to
different namespaces.

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


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

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


Administrivia:

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

	subscribe perl-users
or:
	unsubscribe perl-users

to almanac@ruby.oce.orst.edu.  

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

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

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


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


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