Re: Deleting # and other characters

2003-11-06 Thread John W. Krahn
Raghu Murthy wrote:
 
 I need to remove ./ and #from a list of files. I can do it in sed but I am
 not able to use it in my perl script. I tried to do something like this
 
 chomp ($txtlist = STDIN);
 qx' sed -e /^#/d $txtlist'; # To remove lines starting with a #
 qx' sed -es?\([  /]\)\./?\1?g $txtlist; # To remove lines starting with a
 ./
 
 I can do it if i hard code the file name but if i try to use $txtlist it
 does not work. What am i doing wrong.

Perl comes with a handy utility called s2p (sed to perl) that will help
you convert sed scripts to perl.  $txtlist does not work because qx runs
the sed program and returns the results to your perl program but you are
not doing anything with the results.

You can do it in perl something like this:

perl -i~ -pe's|^#||; s|([  /])\./|$1|g' file1 file2 file3 ... fileN


John
-- 
use Perl;
program
fulfillment

-- 
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]



Re: Deleting # and other characters

2003-11-06 Thread Dan Anderson
  I need to remove ./ and #from a list of files. I can do it in sed but I am
  not able to use it in my perl script. I tried to do something like this

# delete all .s and /s
$variable_to_remove_from =~ tr/\.\///d;
# remove the first ./ and anything before it from
# $variable_to_remove_from
if ($variable_to_remove_from =~ m/\.\//) {
  $variable_to_remove_from =~ m/\.\//;
  $variable_to_remove_from = $';  
}
# remove only ./ from the file if it exists and is on a word boundary
if ($variable_to_remove_from =~ m/\b\.\//) {
  $variable_to_remove_from =~ m/\b\.\//;
  $variable_to_remove_from = $';  
}



-- 
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]



Deleting # and other characters

2003-10-23 Thread Raghu Murthy
I tried using
next if s?\([  /]\)\./?\1?g;
and it did not work. The file looks like this

a b ./zyc/dfdk ./dkld/kdj
k l ./ksdk/ksk/ksd./kskd/kdsk
Thanks

_
Never get a busy signal because you are always connected  with high-speed 
Internet access. Click here to comparison-shop providers.  
https://broadband.msn.com

--
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]


Re: Deleting # and other characters

2003-10-23 Thread Raghu Murthy
I tried doing the following

next if s?\([  /]\)\./?\1?g;

For some reason it is not removing the ./ from the file. Any suggestions are 
welcome.
The file is in this format

a b  ./dsfj/dfl/dksl ./ksdfl/dsld

c d  ./sds/dsl/dksld   ./kdf/ksd/ksdk

Thanks

Raghu

In article [EMAIL PROTECTED], Kevin Pfeiffer wrote:

In article [EMAIL PROTECTED], Raghu Murthy wrote:

I need to remove ./ and #from a list of files. I can do it in sed but I
am not able to use it in my perl script. I tried to do something like
this
chomp ($txtlist = STDIN);
qx' sed -e /^#/d $txtlist'; # To remove lines starting with a #
qx' sed -es?\([  /]\)\./?\1?g $txtlist; # To remove lines starting with
a ./
I can do it if i hard code the file name but if i try to use $txtlist it
does not work. What am i doing wrong.
Thinking that I misunderstood the question... $txtlist is the file you want
to edit?
If you call the script so: ./strip_chars txtlistfile  new_version

then you would start the code I posted with while () { instead.

--
Kevin Pfeiffer
_
Fretting that your Hotmail account may expire because you forgot to sign in 
enough? Get Hotmail Extra Storage today!   
http://join.msn.com/?PAGE=features/es

--
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]


Re: Deleting # and other characters

2003-10-23 Thread Kevin Pfeiffer
In article [EMAIL PROTECTED], Raghu Murthy wrote:

 I tried doing the following
 
 next if s?\([  /]\)\./?\1?g;

That looks to me more like sed (as best I can tell) and not Perl.

 For some reason it is not removing the ./ from the file. Any suggestions
 are welcome.
 The file is in this format
 
 a b  ./dsfj/dfl/dksl ./ksdfl/dsld
 
 c d  ./sds/dsl/dksld   ./kdf/ksd/ksdk

Well, you could always use:

tr/\.\///d;
print;

...which would give you this:
a b  dsfjdfldksl ksdfldsld

c d  sdsdsldksld   kdfksdksdk


Or this:
s|\./||g;
print;

...which produces this:
a b  dsfj/dfl/dksl ksdfl/dsld

c d  sds/dsl/dksld   kdf/ksd/ksdk

...if that is what you want (I'm not quite sure).

-Kevin


-- 
Kevin Pfeiffer


-- 
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]



Deleting # and other characters

2003-10-22 Thread Raghu Murthy
I need to remove ./ and #from a list of files. I can do it in sed but I am 
not able to use it in my perl script. I tried to do something like this

chomp ($txtlist = STDIN);
qx' sed -e /^#/d $txtlist'; # To remove lines starting with a #
qx' sed -es?\([  /]\)\./?\1?g $txtlist; # To remove lines starting with a 
./

I can do it if i hard code the file name but if i try to use $txtlist it 
does not work. What am i doing wrong.

Thanks

Raghu

_
Want to check if your PC is virus-infected?  Get a FREE computer virus scan 
online from McAfee.
http://clinic.mcafee.com/clinic/ibuy/campaign.asp?cid=3963

--
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]


Re: Deleting # and other characters

2003-10-22 Thread Kevin Pfeiffer
In article [EMAIL PROTECTED], Raghu Murthy wrote:

 I need to remove ./ and #from a list of files. I can do it in sed but I am
 not able to use it in my perl script. I tried to do something like this
 
 chomp ($txtlist = STDIN);
 qx' sed -e /^#/d $txtlist'; # To remove lines starting with a #
 qx' sed -es?\([  /]\)\./?\1?g $txtlist; # To remove lines starting with
 a ./
 
 I can do it if i hard code the file name but if i try to use $txtlist it
 does not work. What am i doing wrong.

Can't you just do something like:

while (DATA) {
s|^#+\s*||;  # remove leading #s and any spaces
s|^\./||;# remove leading ./
print;
}

To remove the entire line add next if  in front of the regex.

-K


-- 
Kevin Pfeiffer


-- 
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]



Re: Deleting # and other characters

2003-10-22 Thread Kevin Pfeiffer
In article [EMAIL PROTECTED], Kevin Pfeiffer wrote:

 In article [EMAIL PROTECTED], Raghu Murthy wrote:
 
 I need to remove ./ and #from a list of files. I can do it in sed but I
 am not able to use it in my perl script. I tried to do something like
 this
 
 chomp ($txtlist = STDIN);
 qx' sed -e /^#/d $txtlist'; # To remove lines starting with a #
 qx' sed -es?\([  /]\)\./?\1?g $txtlist; # To remove lines starting with
 a ./
 
 I can do it if i hard code the file name but if i try to use $txtlist it
 does not work. What am i doing wrong.

Thinking that I misunderstood the question... $txtlist is the file you want
to edit?

If you call the script so: ./strip_chars txtlistfile  new_version

then you would start the code I posted with while () { instead.


-- 
Kevin Pfeiffer


-- 
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]