Original Message-
From: Umesh T G [mailto:[EMAIL PROTECTED]
Sent: Friday, July 29, 2005 3:47 PM
To: beginners@perl.org
Subject: Read a single line in a file.
Hello List,
I have a file with multiple lines. I want to read only the first line.
and a particular word in that line.
For eg:
Hi ,
I have to verify whether the servers [windows , Linux ] which are
integrated to my Unix machine are alive or not .
I am using Net::Ping.
Problem i am facing is , i am able to verify all Unix machines
integrated .
And not the Windows Linux machines which integrated to my UNIX box.
please
Hi ,
I have to verify whether the servers [windows , Linux ] which are
integrated to my Unix machine are alive or not .
I am using Net::Ping.
Problem i am facing is , i am able to verify all Unix machines
integrated .
And not the Windows Linux machines which integrated to my UNIX box.
Hi ,
I have to verify whether the servers [windows , Linux ] which are
integrated to my Unix machine are alive or not .
I am using Net::Ping.
Problem i am facing is , i am able to verify all Unix machines
integrated .
And not the Windows Linux machines which integrated to my UNIX box.
please
Hi ,
I have to verify whether the servers [windows , Linux ] which are
integrated to my Unix machine are alive or not .
I am using Net::Ping.
Problem i am facing is , i am able to verify all Unix machines
integrated .
And not the Windows Linux machines which integrated to my UNIX box.
Hi ,
Try below.
If you are using csh for executing perl script -- system(setenv
TEMPHOME /tmp );
If your using bash for executing perl script - $TEMPHOME =
/tmp;
system(export $TEMPHOME);
Arjun
Deserve before you desire
-Original Message-
From: Nishi Prafull
Oops ,
Mine was a wild guess and I am sorry for that. The below test was
successful in setting environment variable ...
clip
#!/usr/bin/perl
use Env;
print Before --;
print %ENV;
print \n;
$ENV{TEMP}=xxx;
print After -- \n;
print %ENV;
print \n;
system(echo $TEMP);
Hi ,
Yes dumper helped up to some extent. My HASH is some thing like below,
---
extract is HASH(0x4039ca60)
$VAR1 = {
'Cluster' = '26'
};
But I want it to be like below. How to add two keys and two values to
hash.
--
extract is
Hi ,
I have executed a Perl script from csh[c shell ] and saw that exit
number is for shell from where it is invoked .
Exit 100; at the end is captured by shell.
Exit value can be up to 127.
But I couldn't get what is number; Stands for.
Any one can help here ... please
Thanks in
Hi ,
I have a script which reads from flat file and stores data in a
variable in the form of hash.
code
-
foreach $cluster ( @{$schedules-{$DAY-[friday]}-{STRUCT}} )
-
from $cluster i have to extract cluster number and version. How can i do
that ??
flat file looks
Hi ,
Use the expression/^G.*G$/
^ Denotes the beginning of the line
$ - denotes ending of the line
if u dont want case sensitivity
use/^G.*G$/i
i -- ignores case sensitivity
Arjun
Deserve before you desire
-Original Message-
From: April T.Barrett [
Hi Kumaran,
Use strict is used to enforce declaration of variables before we use
them.
Here IN_FILE1 is file pointer variable which u are using and which is
not declared before ,
That is the reason it is working fine when u have removed the use strict
construct.
Thanks
Arjun
Deserve before you
Hi ,
I have a perl script which accepts few predefined parameters and
values for them.
It is like this :
myscript.pl -param1 value1 -param2 value2
Now my requirement is , if value is also has and hyphen - then
script should accept it and what ever i give after the -param option
should
Hi Mallik
You can use regular expression
-
$i=0;
foreach $temp (@arr)
{
if ( $temp eq 'pqr' )
{
print index is == $i \n;
last;
}
$i++;
}
-
I hope this will work ,but ur desired index is 3 not 4.
Mallik ..
Deserve before
Hi
CYGWIN installation is in two parts , I am not sure whether u have
followed that ?
And CYGWIN is like X-windows to work on UNIX session from Windows
machines... Other s/w like this are Exceed [ licensed..].
If u want I can give u the full CYGWIN s/w I have.
cheers
Arjun
Deserve before you
Hi Frnds,
If I have a number of 6 digits. How to get the last 2 digits. This
should be valid even when i have 2 digits as input.
i.e If input is 991041 then output shud be 41
if input is 41 then output shud be 41
May be junk and simple question but ..i need this ..please do respond..
Hi Frnds,
Found solution.
$len = length($temp);
if ($len 2)
{
$temp=substr($temp,$len-2,2);
}
Thanks
Arjun
Deserve before you desire
-Original Message-
From: Alfred Vahau [mailto:[EMAIL PROTECTED]
Sent: Friday, January
Hi Frnds,
I have to search for a file in a PATH and then once the file is found
, assign that full path of the that file to an environment variable.
and quit further searching.[because only full path of the first
occurance of the file is required]
PATH is defined like ---
Hi Frnds,
I have a problem with string passed as an argument to a perl script.
I am giving the string \C:\\PROGRA~1\\INTERN~1\\IEXPLORE.EXE\ as an
argument to the cmdtemplate option.
and it been taken as C:PROGRA~1INTERN~1IEXPLORE.EXE after parsing it.
what happend to the back slash.??
In
Hi Frnds,
I need to capture the current system name to a variable. I am doing like
below but , the hostname value is not getting stored in the variable.
any suggestions please ??
-
$systemserver = system(hostname);
--
Thanks
Hi Frnds,
I need to extract a string from every line of a file which are present
in a array.
The string to be extracted is present in between double quotes. I am
using below code and it is not working.
==
foreach $line2 (@objects)
{
chomp($line2); --- To
Hi Frnds,
I found some solution for my problem.
foreach $line2 (@objects)
{
chomp($line2);
if ($line2 =~ /^\s*\(\s*ObjectClass\s*(.+?)\s*\)/)
{
$var=$1;
Arjun
-Original Message-
Hi ,
Can any suggest some thing for my problem, like I need to append to a
file from last but one line of the existing file.
Ex: if a file has 6 lines then appending should be done from 6th
line
Thanks in advance
Arjun
-Original Message-
From: [EMAIL PROTECTED] [mailto:[EMAIL
Hi Frnds,
I myself found some way.Read the file to an array and created a file as
per requirement and then inserted the objects in the array to file.
for ($i=0;$i $#arr;$i++)
{
print OUTPUT $arr[$i];
}
=
Arjun
Hi,
I need to capture whole text after # character in each line from a
file.The below script is not working can any one suggest the correct
thing plz..
chomp($line1);
if ($line1 =~ /^#\(.*\)/)
{
#Hash array will remove the duplicates entries of
Hi ,
there is an existing file and I need to append text to it ,only thing
is I need to remove the last line of existing file and then need to
append text.
I hope I am clear.If there are 6 lines in a file I have remove 6th line
and then need to append the text.
Thanks in advance
Arjun
This mode will append text at the bottom not at the top.
Arjun
-Original Message-
From: [EMAIL PROTECTED]
[mailto:[EMAIL PROTECTED]
Sent: Friday, October 29, 2004 2:45 PM
To: [EMAIL PROTECTED]; [EMAIL PROTECTED]
Subject: RE: Append on top
open(MYNAME,a.txt);
-Original
Shell scripting is native to the shell in which u right them and are not
portable more imp is difficult to implement even simple logic ..but are
very fast as they are native to OS.
,where as Perl scripts are inter operable and a bit easy to write and
debug] compared to shell scripts.
This as
Hi ,
How to create a file with write permission to all users.It is now over
! it should be possible even the file exists and should not matter
what are the existing permissions.
and who ever may be the owner.
Finally file should be with 666 permissions.
I have tried umask it was not working
Good one liner I appreciate it ..
Arjun
-Original Message-
From: Ramprasad A Padmanabhan [mailto:[EMAIL PROTECTED]
Sent: Monday, October 11, 2004 4:41 PM
To: Urs Wagner
Cc: perl beginners
Subject: Re: Line replace
On Mon, 2004-10-11 at 16:23, Urs Wagner wrote:
Hello
I should
Hai !
Open the file with any file handler and use regular expression.. This
way it will work.
Open (File handler name ,file name);
While ( $string=filehandler)
{
if ( $string = ~ /^Alpha\(a,b,c\)/ )
{
$string = # . $string ;
print file handler $string ;
}
}
Arjun
Hai!
My requirement is to open file with 666 permissions.[If fine doesn't
exists it should get created ].Iam doing as below,is this ok.
===
sysopen(LOG,$main::TRACELOGFILE,O_CREATE,0666) or die Can't open
trace file $main::TRACELOGFILE;
ami
Hey guys !
Thanks for the support .the following is the code I have written.
Working fine.
===
open(LOG,$main::TRACELOGFILE) or die Can't open trace file
$main::TRACELOGFILE;
system(chown XXX:Y $main::TRACELOGFILE);
system(chmod 0666 $main::TRACELOGFILE);
33 matches
Mail list logo