You can use defined() function by checking for the
first element.
#!/usr/bin perl
use strict;
use warnings;
my @arr=(); ## empty
my $ref=\@arr; ##
if(!defined ($ref->[0]) {
# do your work here
}
if (!define ($arr->[0]) {
# do your work
}
--- dan <[EMAIL PROTECTED]> wrote: > or
>
> if (!$arr
Jeff 'japhy' Pinyan wrote:
> %Foo::Bar::Constants::. But anyway, here's the trick I'd use:
>
> *short:: = *Foo::Bar::Constants::;
> print $short::name; # $Foo::Bar::Constants::name
ah thanks, this package aliasing thingie is what i had been trying to
accomplish several hours earlier, to
Jeff 'japhy' Pinyan wrote:
> It's important to know that those "constants" aren't as efficient as
their
> non-method syntax cousins:
>
> package FOO;
> use constant BAR => 10;
>
> package main;
> print FOO::BAR; # at compile-time, Perl makes that 'print 10'
> print FOO->BAR;
On Oct 4, Chuck Belcher said:
>I can now get the first part to open and read a file, however, It still
>does not work when I am reading the directory. The print $file found in
>$in_dir does work it displays a list of files in the directory. The open
>(IN1, "<$file"); does not appear to open the f
On Oct 5, David Garamond said:
>James Edward Gray II wrote:
>> Building on this though, if you made the constants module, couldn't you
>> make them subs? I believe this is even how the use constant pragma
>> functions. Heck make it an object oriented module with static methods
>> and it's even
On Oct 5, David Garamond said:
>indeed. i still want to name my package Foo::Bar::Constants. the 'X' (or
>let's name it 'tmp') is just a temporary prefix to help ease my weary
>typing hands. in python i can do something like this:
>
> import Foo.Bar.Constants
> print Foo.Bar.Constants.alice
>
I added the use strict and use warnings now I get the following...
Global symbol "$file" requires explicit package name at crxml.pl line 8.
Global symbol "$in_dir" requires explicit package name at crxml.pl line
10.
Global symbol "$tstopen" requires explicit package name at crxml.pl line
15.
Glob
John W. Krahn wrote:
>> i run the perlscript with a file suffix like:
>> ./perlscript test1.txt
>> i am trying to reverse the contents of test1.txt line-by-line and print
>> them out. but i dont get any output.any help would be appreciated.
>
>
> print reverse <>;
>
And they say perl is hard
Hi, I use perl in a restricted environment and I don't have access to
load modules that aren't there. I would like to
Use additional modules and/or create some of my own.
Is there a workaround for this?
Thanks.
--www.ramonred.net--
>
> Hi all, this is most likely a silly question but in the past I have just
> did installs of Perl modules using the perl -MCPAN -e shell command. How
> do you install a .pm file if you already downloaded from somewhere? Thanks
> in advance as always!
>
> The standard way to install a downloade
Put
use strict;
use warnings;
at the top of most programs you ever write. As for failing calls to open(),
phrase the call like this:
open FH, "< $file" or die "Could not read $file: $!";
Once the handle is opened successfully, iterate through the file line by line
like this:
while () { ...
I can now get the first part to open and read a file, however, It still
does not work when I am reading the directory. The print $file found in
$in_dir does work it displays a list of files in the directory. The open
(IN1, "<$file"); does not appear to open the files. I am loosing hair by
the minu
On Thu, Oct 03, 2002 at 01:38:26PM +0800, [EMAIL PROTECTED] wrote:
> Hello, All:
>
> Every time I send a message to this list, I receive a message from
> [EMAIL PROTECTED] immediately afterwards. It appears to be garbage
> (lots of screwy characters...).
>
> Where is this coming from? Am I the
My goal is to spit a file or files that are in a specific directory. My
problem is that I can't read the file.
Attempt to read file:
#!/usr/bin/perl
open (IN, " < /opt/crxml/tstdir/updt1.dat");
until (eof IN) {
$line = ;
chomp $line;
print $line;
@fields = split /:/, $line;
print "$fie
On Thu, Oct 03, 2002 at 05:12:38PM -0700, Jessee Parker wrote:
> I will definitely take a look at this. How do you determine what your
> current "nice" status is?
nice, with no arguments, will give you your current nice level. ps and top
will diplay the nice level (or sometimes priority) of proc
Bob Showalter wrote:
>use Foo::Bar::Constants ();
>{ package X; Foo::Bar::Constants->import }
>print $X::alice->{name};# prints "Alice"
>
> Here your using the Exporter functionality, but exporting symbols into the
> "X" namespace instead of your current namespace. The empty paren
James Edward Gray II wrote:
> Building on this though, if you made the constants module, couldn't you
> make them subs? I believe this is even how the use constant pragma
> functions. Heck make it an object oriented module with static methods
> and it's even designed well. Just a thought.
g
> -Original Message-
> From: David Garamond [mailto:[EMAIL PROTECTED]]
> Sent: Friday, October 04, 2002 3:17 PM
> To: Bob Showalter
> Cc: [EMAIL PROTECTED]
> Subject: Re: package name alias (for shorter variable name)
>
>
> thanks for the answer, bob.
>
> Bob Showalter wrote:
> > There'
You're right and I learn something new all the time.
Building on this though, if you made the constants module, couldn't you
make them subs? I believe this is even how the use constant pragma
functions. Heck make it an object oriented module with static methods
and it's even designed well.
James Edward Gray II wrote:
> I haven't tested it, but I'm quite sure:
>
> my $p = 'Long::Package::Name';
> $p->constant;
>
> ...works as expected. If memory serves this is even allowed under the
> strict pragma. If not though, you could always localize a block with no
> strict 'refs' where
This could also be a good time to check if your editor supports macros.
Perhaps that would be a solution that would be easier on your hands but
would enable you to keep your package names simple and easy to read/edit.
-Original Message-
From: James Edward Gray II [mailto:[EMAIL PROTECTED
I haven't tested it, but I'm quite sure:
my $p = 'Long::Package::Name';
$p->constant;
works as expected. If memory serves this is even allowed under the
strict pragma. If not though, you could always localize a block with
no strict 'refs' where you need it.
James Gray
On Friday, Octobe
Chad Kellerman wrote:
> Hi everyone,
>
> What would be the easiest way to find the uptime of a linux
> machine? I don't want to use a system call. Is there a module I can
> use? Or do I have to open /proc/uptime and calculate it thru there?
>
>
> Thanks for the help..
>
> Chad
>
yes.
Timothy Johnson wrote:
> I'm not sure if this is a GOOD idea, but I THINK you can actually get away
> with something like this: In your module, insert a shorter package name,
> but keep the module in the same place. So:
>
> package Foo::Bar::Constants;
>
> #do stuff here
>
>
thanks for the answer, bob.
Bob Showalter wrote:
> There's nothing that says the file Foo/Bar/Constants.pm must have a "package
> Foo::Bar::Constants" declaration.
true, and i've realized that. i come from a python background and by
contrast, in python, filename and directory name dictate the
> -Original Message-
> From: David Garamond [mailto:[EMAIL PROTECTED]]
> Sent: Friday, October 04, 2002 2:05 PM
> To: [EMAIL PROTECTED]
> Subject: package name alias (for shorter variable name)
>
>
> i have several "constants" in a package:
>
>package Foo::Bar::Constants;
>$alic
I'm not sure if this is a GOOD idea, but I THINK you can actually get away
with something like this: In your module, insert a shorter package name,
but keep the module in the same place. So:
package Foo::Bar::Constants;
#do stuff here
package MyConst;
$Constant
i have several "constants" in a package:
package Foo::Bar::Constants;
$alice = {name=>"Alice", low=>-10, high=>21};
$bruce = {name=>"Bruce Wayne", low=>-17, high=>5};
$charlie = {name=>"Charlie", low=>-3, high=>3};
$devon = {name=>"Devon E.", low=>1, high=>29};
and i want to use t
Hi-
The standard way to install a downloaded .pm is:
tar ...
cd to created subdir
perl Makefile.PL
make
make test
make install
See the README after untaring to make sure.
Aloha => Beau.
-Original Message-
From: Jessee Parker [mailto:[EMA
In article <[EMAIL PROTECTED]>,
[EMAIL PROTECTED] (Imtiaz Ahmad) writes:
>Hi-
>
>Is there a way in PERL to automatically populate second drop down
>based on what is selected in the first drop down.
No. You need JavaScript. Because this has to run in the user's browser,
and Perl doesn't.
I'm a
On Friday, October 4, 2002, at 11:21 AM, dan wrote:
> or
>
> if (!$array[0]) {
This tests for a "true" value in the first element of an array, not if
it's empty. This test will succeed for the list (undef, 1, 2, "More
Data"), which is definitely not empty.
> # it's empty
> }
>
> your cho
On Fri, 2002-10-04 at 10:21, [EMAIL PROTECTED] wrote:
> or
>
> if (!$array[0]) {
> # it's empty
> }
>
> your choice :)
>
> dan
not quite... try that on this array:
@array = qw(0 1 2 3 4 5 6);
jjv
--
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTE
just open the package up and read the Readme file, it will tell you how to
install it
> -Original Message-
> From: Jessee Parker [mailto:[EMAIL PROTECTED]]
> Sent: Friday, October 04, 2002 12:39 PM
> To: [EMAIL PROTECTED]
> Subject: Installing a PM on Linux
>
>
> Hi all, this is most li
or
if (!$array[0]) {
# it's empty
}
your choice :)
dan
"Nikola Janceski" <[EMAIL PROTECTED]> wrote in message
[EMAIL PROTECTED]">news:[EMAIL PROTECTED]...
> if(not @array){
> # it's empty
> }
>
> > -Original Message-
> > From: Bryan Harris [mailto:[EMAIL PROTECTED]]
> > Sent: Friday,
Hi all, this is most likely a silly question but in the past I have just did
installs of Perl modules using the perl -MCPAN -e shell command. How do you
install a .pm file if you already downloaded from somewhere? Thanks in
advance as always!
Jessee
--
To unsubscribe, e-mail: [EMAIL PROTECTED
I also appreciated this solution but for a different reason...it made me look
up the $- and $+ variables. Very cool. I think it would be well worth the
time for me (and any beginner) to give perldoc perlvar a thorough read...
Cheers everyone,
Nathanael
>= Original Message From "Kipp, Ja
Thanks. I took a look at your site and book and found the chapter on look
ahead. realized how much i was underutilizing them and they could have saved
me alot of headaches. !!
> -Original Message-
> From: Jeff 'japhy' Pinyan [mailto:[EMAIL PROTECTED]]
> Sent: Friday, October 04, 2002 11:
several ways:
write a source file with your configs in it, then you can do stuff like
use foo;
or
require foo;
and they wil be loaded, you could write a small module, or use config files
check into the config.pm module, never used it so I am not sure if it is
what your looking for
if you need h
Bryan Harris wrote:
>
> What's the easiest way to check whether an array is empty?
An array in a scalar context returns the number of elements in the
array.
if ( @array == 0 ) { # explicit test for zero elements
unless ( @array ) { # implicit test for zero elements
John
--
use Perl;
program
Ah (light bulb goes on),
I played around with modules yesterday but couldn't get it
to work.. this simple example was all I needed to get
the light bulb to turn on.
Thanks for your help
-Original Message-
From: Timothy Johnson [mailto:[EMAIL PROTECTED]]
Sent: Friday, October
S Wang wrote:
>
> i have just started writing some scripts in PERL and i am trying to
> catch a deadline, i really wish i could get some help for this problem.
> any suggestion is greatly appreciated.
>
> i have a set of files with sequences aligned in the following format.
> i wonder how i can
Hi-
Is there a way in PERL to automatically populate second drop down
based on what is selected in the first drop down.
For example
If the first drop down has following three choices
air
land
sea
Then if a user is selects land then the second drop should list following
HANDLE_EMPTY() unless @array;
James Gray
On Friday, October 4, 2002, at 10:57 AM, Bryan Harris wrote:
>
>
> What's the easiest way to check whether an array is empty?
>
> I'm really feeling like a beginner today...
>
> - Bryan
>
>
> --
> To unsubscribe, e-mail: [EMAIL PROTECTED]
> For additio
if(not @array){
# it's empty
}
> -Original Message-
> From: Bryan Harris [mailto:[EMAIL PROTECTED]]
> Sent: Friday, October 04, 2002 11:58 AM
> To: Beginners Perl
> Subject: Check for empty array
>
>
>
>
> What's the easiest way to check whether an array is empty?
>
> I'm rea
What's the easiest way to check whether an array is empty?
I'm really feeling like a beginner today...
- Bryan
--
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
> -Original Message-
> From: s wang [mailto:[EMAIL PROTECTED]]
> Sent: Friday, October 04, 2002 11:00 AM
> To: [EMAIL PROTECTED]
> Subject: how can i get rid of these new line characters?
>
>
>
> i have just started writing some scripts in PERL and i am
> trying to catch a deadline, i
Oops, forgot those newlines. Need to add the 'chomp' below...
On Friday, October 4, 2002, at 10:30 AM, James Edward Gray II wrote:
> With something like the script below. (I haven't tested it.) I
> assumed the blank lines in the sample data really exist. If they
> don't, you'll need to
With something like the script below. (I haven't tested it.) I
assumed the blank lines in the sample data really exist. If they
don't, you'll need to change it a bit.
#!/usr/bin/perl
use strict;
use warnings;
my $long_line = '';
while (<>) {
if (/^\s*$/) {
print "
Another thing you might want to try is making a small module to house your
variables. You should be able to do something like this:
###
#ora.pm -- houses global variables for Oracle scripts
package Steve::ora;
$server = 'buddha';
$DB = 'mohammed';
1
#don't forget that the last lin
On Oct 4, s wang said:
>i have just started writing some scripts in PERL and i am trying to catch
>a deadline, i really wish i could get some help for this problem. any
>suggestion is greatly appreciated.
>
>i have a set of files with sequences aligned in the following format. i
>wonder how i can
On Oct 4, s wang said:
>i have just started writing some scripts in PERL and i am trying to catch
>a deadline, i really wish i could get some help for this problem. any
>suggestion is greatly appreciated.
>
>i have a set of files with sequences aligned in the following format. i
>wonder how i can
A simple, if not elegant, way of doing it assumes that you have each sequence
in its own variable, say in an array. Then:
$sequence =~ s/\n//g; #remove ALL newlines
$sequence .= "\n"; #re-add the terminal newline
>= Original Message From "Prachi Shah" <[EMAIL PROTECTED]> =
>Hmmm. One w
>> $dna =~ m{
>> (?=
>> tag
>> (?:
>> .*? tag
>> # the substr(...) is there to avoid using $&
>> (?{ push @matches, substr($dna, $-[0], $+[0] - $-[0]) })
>> )+
>> )
>> (?!)
>> }x;
First of all, I haven't benchmarked, and I had thought of d
Hmmm. One way of doing it could be to read each sequence in the file,
reading the header and the actual sequence in different variables. And then,
format the sequence variable to remove all newlines using a regular
expression. And then write them back to another file.
Hope this helps.
Prachi.
Thanks for the quick reply James,
How would I set this up in a script and have all the other scripts
be able to use it?
-Original Message-
From: Kipp, James [mailto:[EMAIL PROTECTED]]
Sent: Friday, October 04, 2002 7:33 AM
To: 'Steve Main'; [EMAIL PROTECTED]
Subject: RE: Environment set
i have just started writing some scripts in PERL and i am trying to catch a deadline,
i really wish i could get some help for this problem. any suggestion is greatly
appreciated.
i have a set of files with sequences aligned in the following format. i wonder how i
can eliminate the new line ch
On Friday, October 4, 2002, at 09:21 AM, Jerry Preston wrote:
> Hi!,
Howdy.
> I am look for a better way and a faster way to deal with a 4 - 8 meg
> data
> file. This file has been saved as an .cvs file for excel to read in.
A "better" way, is pretty open to interpretation, so here's my
Jerry Preston wrote:
>
> Hi!,
Hello,
> I am look for a better way and a faster way to deal with a 4 - 8 meg data
> file. This file has been saved as an .cvs file for excel to read in.
>
> [snip]
>
> open( FI, $file_path ) || die "unable to open $file_path $!\n";
> @file_data = ;
> c
>
> Here is my solution:
>
> my $dna = ...;
> my @matches;
>
> $dna =~ m{
> (?=
> tag
> (?:
> .*? tag
> # the substr(...) is there to avoid using $&
> (?{ push @matches, substr($dna, $-[0], $+[0] - $-[0]) })
> )+
> )
> (?!)
> }x;
>
>
you can use the %ENV hash
example:
$ENV{ORACLE_HOME} = "/opt/oracle/product/9.0.1";
> -Original Message-
> From: Steve Main [mailto:[EMAIL PROTECTED]]
> Sent: Friday, October 04, 2002 10:23 AM
> To: [EMAIL PROTECTED]
> Subject: Environment setup
>
>
> Hello list,
>
> I have an Oracle f
Cedric wrote:
>
> First of all, sorry for my poor english.
> I work with DNA sequence and want to extract relevant motives of course
> using regular expression.
> A concrete example will be better than a long description of my problem, so:
>
> Here is a string corresponding to my DNA strand :
>
Hello list,
I have an Oracle framework written in Korn shell scripts that I am
attempting to re-write in Perl. I am having trouble figuring out
how to "source" in environment variables. For the shell scripts, I have
a script that sets all of the global variables and then each script in
the fram
Hi!,
I am look for a better way and a faster way to deal with a 4 - 8 meg data
file. This file has been saved as an .cvs file for excel to read in.
All I am interested in is the first three cells of ',' delimited data.
Die,Row 0, Column 11
Test Result,1
Score,1
PMark Score,0
k Score,0
Scor
> Hi Javeed ,
>
> the last element of the array is $attt[$#attt]. If you have one line per
> element, that should do it.
Right. This is the easiest way. But, just to answer him, what he could do
using regular expression could be something like:
foreach (@attt) {
/=/ && ( ($out) = (split (/=/))
On Oct 4, Cedric said:
>cgttgctagctgctatcgatgtgctagtcgatgctagtgcatgcgtagtgcagtcatatgctaggcat
>
>I want to extract all the substrings beginning with tag and finishing with
>tag including substrings with same start point but different length like :
>
>tagctgctatcgatgtgctag
>tagctgctatcgatgtgctagtcg
On 03 Oct 2002 09:25:03 -0400, [EMAIL PROTECTED] (Chad Kellerman)
wrote:
>Hi everyone,
>
>What would be the easiest way to find the uptime of a linux
>machine? I don't want to use a system call. Is there a module I can
>use? Or do I have to open /proc/uptime and calculate it thru there?
He
On Fri, 4 Oct 2002, waytech wrote:
> hi everyone,
>
> Thanks for all replys about my question.
>
> I know here are lots of perl experts.
>
> it's amazing that someone can short
>
> that long program into one line.
>
> I am a perl newbie, i wonder
>
> whether someone can explain
First of all, sorry for my poor english.
I work with DNA sequence and want to extract relevant motives of course
using regular expression.
A concrete example will be better than a long description of my problem, so
:
Here is a string corresponding to my DNA strand :
cgttgctagctgctatcgatgtgctagtc
hi everyone,
Thanks for all replys about my question.
I know here are lots of perl experts.
it's amazing that someone can short
that long program into one line.
I am a perl newbie, i wonder
whether someone can explain what
these guys wrote(like what
Sudarshan Raghavan wrote
Hi Javeed ,
the last element of the array is $attt[$#attt]. If you have one line per
element, that should do it.
R
At 14:24 04/10/2002 +0530, Javeed SAR wrote:
>I have the following output in array @attt
>I want the last line in a variable $out.
>What should the regular expression be?
>
>
>a
Hi All,
I have the following output in array @attt
I want the last line, in this output (SYNC_CHECK = "HELLO") in a variable
$out.
What should the regular expression be?
attribute type "SYNC_CHECK"
created 04-Oct-02.09:36:42 by javeed.clearuser@BLRK35ED
"for testing"
owner: HIS\javeed
I have the following output in array @attt
I want the last line in a variable $out.
What should the regular expression be?
attribute type "SYNC_CHECK"
created 04-Oct-02.09:36:42 by javeed.clearuser@BLRK35ED
"for testing"
owner: HIS\javeed
group: HIS\clearuser
scope: this VOB (ordinary
72 matches
Mail list logo