My method sounds stupid, but still works :
my @array = ('123', 'abc', 'def', 1..9);
my $len_of_array = 0 ;
foreach my $elem(@array)
{$len_of_array += length($elem) }
print $len_of_array ; # I got '18'
my %hash = (1=>2, 2=>3, 3=>4);
foreach my $key(keys(%hash))
{$len_of_hash += length($
> I don't know if it is "better" or faster, but it is shorter. :-)
>
> $ perl -le'
> my @array = ( "123", "abc", "def", 1 .. 9 );
> my $len_of_array = do { local $"; length "@array" };
> print $len_of_array;
> '
> 18
>
> $ perl -le'
> my %hash = ( 1 => 2, 2 => 3, 3 => 4 );
> my $len_of_hash = do
ach element is assumpted not in
same length... ie.. I am not going to get the table size...
>
> Vincent
>
> -Original Message-
> From: Li Ngok Lam [mailto:[EMAIL PROTECTED]
> Sent: Thursday, April 03, 2003 5:14 PM
> To: [EMAIL PROTECTED]
> Subject: How to measur
perldoc -f srand
- Original Message -
From: "meriwether lewis" <[EMAIL PROTECTED]>
To: <[EMAIL PROTECTED]>
Sent: Saturday, April 05, 2003 10:09 AM
Subject: random sub returns same results...
> Hi Gurus!
>
> I have the following sub which creates a random
> string. Each time I call the
> I'm trying to put the string from the system("ls -al") into a variable.
@list = `ls -al`;
> It simply prints to the page and puts 1 in the variable.
What's that mean '1' anyway ?
--
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
Is there any methods or documents I can refer to learn how to write a file
at any desire position with any length without to write the whole again ?
I mean, I dont want to write to a new file, kill the old file, rename the new file,
or read the old file, modify it and rewrite the old file etc...
>
> You want seek(), and possibly tell().
>
> perldoc -f seek
>
Thanks for reply, but seems I have to clarify my question.
'seek' and 'tell' only helping me to target my position within
a file handle.
Say, if I have a 1MB file, and I just want to over write
bytes from 0 to 1000 byte then my
>
> You will probably want to open the file with a mode of "+<".
>
Yes and thank you! That does what I want now. Thank you very much !!
But I found new problem now. I did what I want if I try on a bitmap file,
but for text file, my new contents will overwrite the whole file, what's
that about
or
>
> #/!perl -w
> use strict;
> use IO::File;
>
> my $offset = 3;
> my $file_binary = "fg";
> sysopen(OUTFILE, "out.txt", O_WRONLY) or print "Couldn't open file for
> read/write ($!)\n";
> binmode OUTFILE;
> sysseek OUTFILE, $offset, 0;
> syswrite OUTFILE, $file_binary, length($file_binary);
> close
foreach my $result(@filelist) # a script snipped was given a file list
{ chomp ($result);
my $com_result = $result;
$com_result =~ s/^$root//;
# $root was a defined var, where using to target the below filter focus
# on the rest of parameter besides from the common
I would say the other name of socket programming is network programming.
The socket modules will act as a interface to deal with other machines, such
as
FTP, telnet, smtp, pop, etc.
I would recommand Network Programming with Perl, by Addison Weskey,
but that's a book, not a site =)
- Original
I've tried to use exec, system, and ``. And also with and without $| = 1;
but seems unable to do what I want.
What I want to do is suppose like this :
print "Start";
exec "notepad";
print "End";
but I found my results are :
If I can see "End", the notepad won't come,
If I can run the notepad, I
Is there anyway to modify my BIOS clock by Perl ?
and more, is there anyway to adjust my BIOS clock, so
to sync. with other time servers ?
TIA
my (%LIST, @other_list);
@other_list = ( Unknown Length Data Elems );
foreach my $col (@lists)
{
for (@other_list)
{
if ( exist $LIST{$col}[0] ) { Do_smth_2 } # But ERROR either
What should I write here ? So can push vars to $LIST{$col}
}
}
Thanks in advi
I am going to write a sub accept different types of data type.
My interface is some what like this :
$ret = mySub ( \%hash );
$ret = mySub ( [EMAIL PROTECTED] );
$ret = mySub ( \$calar );
$ret = mySub ( \&Sub );
$ret = mySub ( $calar );
$ret = mySub ( %hash );
$ret = mySub ( @rray );
Is there any
First, I would ask, how many lines in each file ? under 100 ? above 1 ?
because that effect to choose the tatic for making things done.
Well, I assume there is reasonable to carry 1 names and each name not
longer then 20 character ( consumed about 200KB, still acceptable )
and I wi
- Original Message -
From: <[EMAIL PROTECTED]>
To: "James Kelty" <[EMAIL PROTECTED]>; <[EMAIL PROTECTED]>
Sent: Wednesday, July 23, 2003 1:21 AM
Subject: RE: Reg Exp Help...
>
>
> On 22 Jul 2003 09:15:29 -0700, James Kelty <[EMAIL PROTECTE
- Original Message -
From: "Josh Corbalis" <[EMAIL PROTECTED]>
To: <[EMAIL PROTECTED]>
Sent: Wednesday, July 23, 2003 2:24 AM
Subject: print command help
> I'm writing a webmin module and I'm trying to add a search function in
right
> now but after I search for it and try to display the
>
> I have a number $page = 500;
> now i want to check that if $page matches a word character then make $page
> =1;
$page = 1 unless ( $page =~ /\d/ );
or
$page = 1 if ($page =~ /\D/ );
> so originally i did this
> my $page =500;
> if(($page =~ /\w/) || ($page <= 0)){
> $page=1;
> }
> print"$pag
if ( -d $path ) { print "Directory" }
elsif ( -f $path ) { print "File" }
else { print "Not exist" }
HTH
- Original Message -
From: "Rus Foster" <[EMAIL PROTECTED]>
To: <[EMAIL PROTECTED]>
Sent: Thursday, July 24, 2003 8:39 PM
Subject: Checking for a directory
> Hi All,
> Just trying t
Yep ! =)
Even though I can't imagine what a path is not file or directory would imply
more then not exist. But I agree to check the existence for a path by -e
is the safest operation.
- Original Message -
From: <[EMAIL PROTECTED]>
To: "LI NGOK LAM" <[EMAIL
Thanks for this great lesson, I will take account for this on my furture =))
- Original Message -
From: <[EMAIL PROTECTED]>
To: "LI NGOK LAM" <[EMAIL PROTECTED]>
Cc: <[EMAIL PROTECTED]>
Sent: Friday, July 25, 2003 12:17 AM
Subject:
How can I do this ? Or could it be done ?
Open some files ( unknown number of files ), depends on users demand.
Then start looking for some desired line ( use regex ).
I have an array to carry the info of matched data ( from which file, which line ).
while the $#array is 99 and all files would b
I hope to design an interface of a function like this (not in OO way) :
sub tell_error
{ print "Error for @_" }
sub Check_err
{ my %argv = @_;
}
Check_err ( TYPE => [1, 1, \&tell_error('Type')], DATA => [ 1, 2, \&tell_error
('Data')] );
In Check_err, I want &tell_error ('T
Is that any module can help to detect what is the right new line declaration for the
current system ? Somwhat if the system is detected be Windows, the newline
declaration is "\n", for *nix, is "\r\n" , for Mac and etc.
Thanks in advise
Thousands thanks!! That exactly what I am look for ! =))
- Original Message -
From: "Jeff 'japhy' Pinyan" <[EMAIL PROTECTED]>
To: "LI NGOK LAM" <[EMAIL PROTECTED]>
Cc: <[EMAIL PROTECTED]>
Sent: Sunday, July 27, 2003 3:40 AM
Subject: Re
Sorry I don't understand your question well, but from overall,
I guess that's all about what you want...
###
# Main.pl
use MyGoodies;
my $fedback = $MyGoodies::Error();
###
# MyGoodies.pm
package MyGoodies;
use strict;
sub Error
{check
First, your Perl is not a complete version of Perl. You just have the
compiler of Perl.
You almostly missed some very important modules such as strict, warnings,
CGI..etc.
And second, your Perl is out of dated. for Win32 OS, Perl is up to 5.8.0
now.
So go to
http://www.activestate.com/Products
: "Daniela Silva - Absoluta.net" <[EMAIL PROTECTED]>
To: "LI NGOK LAM" <[EMAIL PROTECTED]>; <[EMAIL PROTECTED]>
Sent: Thursday, July 31, 2003 1:12 AM
Subject: Re: How to read multiple files in the same time ?
> Hi,
>
> I want to do something similar,
- Original Message -
From: "Rob Dixon" <[EMAIL PROTECTED]>
To: <[EMAIL PROTECTED]>
Sent: Thursday, July 31, 2003 5:44 AM
Subject: Re: I'm a Nebie to PERL
[snap]
> > > It ran and just listed the contents of the helloworld.pl file. PERL
ran but
> > > the .pl program didn't.
> > >
> > > A
> I'm still puzzled as to how Kenneth managed to get a listing of his
> program out of a Perl command. Let us know how you're getting
> on Kenneth, if you're still watching this thread.
Hi Rob and Kenneth,
I still watching in this thread, but I am not sure did I missed something in
this thread. B
- Original Message -
From: "K. Parker" <[EMAIL PROTECTED]>
To: <[EMAIL PROTECTED]>
Sent: Saturday, August 02, 2003 12:00 PM
Subject: Uploading files
> On a site I'm developing, I'm trying to create a script that uploads
> encrypted files and saves them in a particular directory.
You wi
- Original Message -
From: "awarsd" <[EMAIL PROTECTED]>
To: <[EMAIL PROTECTED]>
Sent: Saturday, August 02, 2003 10:01 PM
Subject: use lib problem
> Hi,
>
> I have a problem maybe it is normal.
> My problem is with using lib
> now to retrieve my module i do this
> use lib "/path/to/Modul
$x = sub { $y = shift; print $y };
$X = $x;
$X -> ("123"); # prints 123;
undef $X;
$Z = $x;
$Z -> ("234"); # prints 234
Question :
1. When will you use this kind of style in your code ?
2. Any "name" for this kind of coding style ?
TIA
You are possibly missing this line :
print "Content-type: text/html\n\n";
HTH
- Original Message -
From: "mario kulka" <[EMAIL PROTECTED]>
To: <[EMAIL PROTECTED]>
Sent: Tuesday, August 05, 2003 2:32 AM
Subject: print <<"HTML code"; in NETSCAPE
> I'm using the following to print HTML to
Is there any module in Perl can dealing with Procession ID on Win32?
And does Perll able to stop or start a services / application?
Any pointers where I can start from ?
Thank you very much...
You method does work !
However, you can write as :
$line[1] /= 1000;
# which is the same as $line[1] = $line[1] / 1000;
HTH
- Original Message -
From: "Sommer, Henrik" <[EMAIL PROTECTED]>
To: <[EMAIL PROTECTED]>
Sent: Tuesday, August 05, 2003 11:05 PM
Subject: Simple question
> Hi,
>
> Is there any reason why this doesn't print the @missing?
> Ive also tried unless ($myhash{$elem} == 1) { push(@missing, $frame) }
> Any insight into what I'm doing wrong would be greatly appreciated.
> @missing = "";
Wrong assignment, should be:
my @missing = ();
my %myhash = ();
> @framelist=
open my $fh, "<", "items/list.db";
print while (<$fh>);
close $fh;
This is suppose to printout the content in items/list.db ,
but why I get somthing like "GLOB(0x162aca7)" ??
Thanks in advise.
>
> my $fh;
> open $fh, '<', 'items/list.db' or die "File error: $!";
It just the same as open my $fh =)
> print while $fh;
Hmm. I guess this is not a 'read' argument
Thanks in advise anyway =)
--
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL
x" <[EMAIL PROTECTED]>
To: "Li Ngok Lam" <[EMAIL PROTECTED]>; <[EMAIL PROTECTED]>
Sent: Monday, August 18, 2003 7:38 PM
Subject: Re: I don't understand why this happen
> - Original Message -
> From: "Li Ngok Lam" <[EMAIL PROTECTED]
>
> $string="1
> blabla";
>
> When Im printing $string I get a new line between 1 and blabla, now I
needt o
> split that.. in
>
> my($number, $real_string) = split...
my($number, $real_string) = split /\n/, $string;
HTH
--
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-m
Hi all,
That's about the whole story, but I'll make it short.
For example, I have a list like this :
123ABCDEF456
123456
654WXYZ321
987654321
ABCDEF123456
WXYZ321
By user's INTEGER input , I will have to find how many similar
patterns are matched within the list according to certain chars (user
Thanks John, and Rob.
This reply is quite close to what I am going to do,
but some critical point is wanted here I'll try to explain
my question further
>
> > That's about the whole story, but I'll make it short.
> > For example, I have a list like this :
> >
> > 123ABCDEF456
> > 123456
46 matches
Mail list logo